Camera freezes on first frame with " Invalid number of channels in input image" in logcat

extern C and references? is that C++ code? that won’t work.

anyway, you pass a 1-channel image to cvtColor ('scn' is 1) while asking it to convert from a 3-channel image.

check the number of channels on frame.