Hi,
I’ve been using MilkV DuoS board and GC2083 camera to capture images and uploading them to cloud. Something strange is happening with the firmware/opencv. The first image captured is always blank, even in the tutorial (opencv-mobile | Milk-V).
The other problem I am facing is that the images (after the first one) produced by the camera are not good in full resolution (1920x1080). Here is example image:
And I need to wait before capturing second image. If no wait, image will be grayscale. I am using version 4.10.0 of opencv-mobile (opencv-mobile-4.10.0-milkv-duo).
My code:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <unistd.h> // sleep()
#include <iostream>
#include <stdio.h>
int main(int argc, char* argv[])
{
if(argc < 2)
{
std::cerr << "Too few arguments.\nUSAGE: capt <image filename>" << std::endl;
return -1;
}
cv::VideoCapture cap;
cap.set(cv::CAP_PROP_FRAME_WIDTH, 1920);
cap.set(cv::CAP_PROP_FRAME_HEIGHT, 1080);
cap.open(0);
if(!cap.isOpened())
{
std::cerr << "ERROR: Unable to open camera." << std::endl;
cap.release();
return -1;
}
const int w = cap.get(cv::CAP_PROP_FRAME_WIDTH);
const int h = cap.get(cv::CAP_PROP_FRAME_HEIGHT);
fprintf(stderr, "Using resolution of %d x %d\n", w, h);
cv::Mat img;
// First image is all black for some reason..
cap >> img;
// Second image will be grayscale, if no wait.. Stream copy takes time?!?
sleep(1);
cap >> img;
// Just in case..
sleep(1);
cap.release();
std::vector<int> compression_params;
compression_params.push_back(cv::IMWRITE_JPEG_QUALITY);
compression_params.push_back(90);
cv::imwrite(argv[1], img, compression_params);
img.release();
return 0;
}
First I thought that this is a low light issue, but even after installing 100W lamp, there is no gain in image quality. Can someone reproduce this, or even better, suggest a fix?
/mika