Ask Your Question

arsalank2's profile - activity

2019-05-06 21:14:29 -0600 received badge  Notable Question (source)
2017-07-27 07:24:08 -0600 received badge  Notable Question (source)
2016-02-26 08:39:00 -0600 received badge  Popular Question (source)
2015-04-01 09:08:02 -0600 received badge  Popular Question (source)
2013-02-11 08:28:03 -0600 received badge  Student (source)
2013-02-11 02:50:23 -0600 commented answer Android camera image rotation

How to get access to the camera object?

2013-02-07 06:24:19 -0600 commented answer Android camera image rotation

You are right, but I need to set this from native code, not from Java side.

2013-02-07 06:05:05 -0600 commented answer Android camera image format is not NV21

Thanks for the information. Is CV_CAP_ANDROID_COLOR_FRAME_RGB default format?

Next question, how to change the camera format? I could not find any suitable method in VideoCapture. I tried setting the properties (VideoCapture::set)CV_CAP_PROP_FOURCC,CV_CAP_PROP_FORMATandCV_CAP_PROP_CONVERT_RGB` but the application crashes with following error:

OpenCV Error: One of arguments' values is out of range.
2013-02-05 09:31:05 -0600 received badge  Supporter (source)
2013-02-05 08:44:48 -0600 received badge  Autobiographer
2013-02-05 08:19:31 -0600 commented answer Android camera image format is not NV21

I have tested it with various devices (e.g. Samsung Galaxy S2 and S3), not on an emulator. I do not want to change to another color format, I just need NV21 which is the standard.

Why cv::Mat has 3 bytes per pixel instead of 1.5? Am I reading it incorrectly?

2013-02-05 07:43:55 -0600 asked a question Android camera image rotation

Does OpenCV support different device orientations (i.e. portrait and lanscape etc.) on Android?

I am capturing camera frames on the native side. If the device orientation is not landscape, the images are rotated. Is there a way to fix the rotation without manually rotating the captured image?

2013-02-05 07:40:39 -0600 received badge  Editor (source)
2013-02-05 07:39:53 -0600 asked a question Android camera image format is not NV21

I managed to capture the camera frames on the native side by calling:

cv::VideoCapture videoCapture(CV_CAP_ANDROID + 0);
videoCapture.set(CV_CAP_PROP_FRAME_WIDTH, 320);
videoCapture.set(CV_CAP_PROP_FRAME_HEIGHT, 240);

cv::Mat image;
videoCapture >> image;

However, the captured image has 3-bytes per pixel, as compared to Android native capture which is 1.5 bytes per pixel. For example, in case of 320x240, the number of bytes in the image captured through OpenCV is 230400, while they are 115200 when captured by Android API.

How can I capture images with NV21 format (i.e. 1.5 bytes per pixel).