CAM-GC2083 with OpenCV-mobile producing blank or low quality images (Duo S)

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

1 Like

After reading the documentation again (opencv-mobile | Milk-V), I found this paragraph: “The first frame is black because the ISP is still counting image information and it is too late for the ISP to automatically process it.”.

So this explains why the first capture is blank. I think that the blank first image still requires a fix.

Have not found any help for the image quality issue.

/mika

1 Like

No replies in almost month. I assume that this is the “quality” of the camera. I have ordered some ArduCams (IMX519). Hopefully I can find help and use these with my duo-s to improve image quality (and not need to fallback to raspberry, because I really like the form factor of duo-s).

/mika