I am using OpenCV mobile captures with an OV5647 camera sensor. The sensor works when I symlink the correct sensor config and use the camera-test.sh
script. However, when I try to use the following OpenCV code, I always get blank frames and an empty jpeg at the end.
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <unistd.h> // sleep()
int main()
{
cv::VideoCapture cap;
cap.set(cv::CAP_PROP_FRAME_WIDTH, 320);
cap.set(cv::CAP_PROP_FRAME_HEIGHT, 240);
cap.open(0);
const int w = cap.get(cv::CAP_PROP_FRAME_WIDTH);
const int h = cap.get(cv::CAP_PROP_FRAME_HEIGHT);
fprintf(stderr, "%d x %d\n", w, h);
cv::Mat bgr;
for (int i = 0; i < 3; i++)
{
cap >> bgr;
// ignore first frame because of image processor
if (bgr.empty() && i != 0) {
fprintf(stderr, "blank frame!\n");
}
sleep(1);
}
cap.release();
// write image
cv::imwrite("out.jpg", bgr);
return 0;
}
Is there something special that I need to do to get OpenCV to use the correct camera config? It appears it is still trying to use the camera as a GC2083 as shown by the program output:
opencv-mobile MIPI CSI camera with cvi
opencv-mobile HW JPG decoder with cvi
ISP Vipipe(0) Allocate pa(0x96822000) va(0x0x3fd6566000) size(291120)
pfnSnsProbe failed ffffffff
gc2083_standby