Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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).

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, 320x240, the number of bytes in the image captured through OpenCV is 230400, 230400, while they are 115200 115200 when captured by Android API.

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

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 3-bytes per pixel, as compared to Android native capture which is 1.5 bytes 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).

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).