ValYouW / flutter-opencv-stream-processing

Running OpenCV C++ code inside a flutter app processing real-time camera frames
MIT License
83 stars 12 forks source link

A maximum of 3 markers can only be detect #7

Open gotecq-thudang opened 3 months ago

gotecq-thudang commented 3 months ago

Thank you for sharing. i tried your demo test but only up to 3 markers can be detect Hope you could help

ValYouW commented 2 months ago

I don't recall such limitation, did you try to debug it?

gotecq-thudang commented 2 months ago

I don't recall such limitation, did you try to debug it?

I checked and found this code limits the number of markers that can be detected res.size() < 3

`vector ArucoDetector::detectArucos(Mat frame, int misses) { vector res; vector<vector> cands = findSquares(frame);

for (int i = 0; i < cands.size() && res.size() < 3; ++i) {
    vector<Point2f> cnt = cands[i];
    vector<int> sig = getContoursBits(frame, cnt, 36);
    for (int j = 0; j < m_dict.sigs.size(); ++j) {
        if (equalSig(sig, m_dict.sigs[j], misses)) {
            ArucoResult ar;
            ar.corners = cnt;
            ar.index = j;
            res.push_back(ar);
            break;
        }
    }
}

return res;

}`

I tried increasing the size, it worked but it seemed unstable, Is there anything I can do to make it run more stable?, thank you

ValYouW commented 2 months ago

What do you mean more stable? If you want the detection to be more "flexible" you can increase the "misses" parameter I think (how many aruco "bits" can be missed and still consider the marker valid)

gotecq-thudang commented 2 months ago

In my case there are 4 markers, but the detection will change back and forth between 3 and 4 markers. What can I do to detect 4 fixed markers? Hope you could help

ValYouW commented 2 months ago

I don't think it's the number of markers that matter but the location of the marker in the frame and its angle that makes a marker to "flicker"

gotecq-thudang commented 2 months ago

yes, it flicker, but I don't think it's a matter of location and angle

https://github.com/ValYouW/flutter-opencv-stream-processing/assets/126755528/68b22c36-d195-4bdc-8831-184648fa3318

ValYouW commented 2 months ago

It actually looks pretty good I think, my experience with image processing is that there is always some noise when processing live camera feed. In the video I see the printed marker is not fully black, there are some white spots, try to paint then black and test.