Ask Your Question
0

bounding box around the detected Object in real time video

asked 2018-03-15 17:28:53 -0600

komms gravatar image

link:[followed the same code] (https://docs.opencv.org/2.4/doc/tutor...)

During real time video, the bounding box is becoming a point at the joining of the montage as marked in red shape, even though the matches are good.

image description

edit retag flag offensive close merge delete

Comments

" even though the matches are good." -- however, the homography is bad, as you can see.

it only found 6 matching points, that's probably not enough (not enough texture in your object image ?)

also: be careful there, H might be empty(), if it could nout build a homography at all, you have to check, before proceeding !

berak gravatar imageberak ( 2018-03-16 01:26:14 -0600 )edit

btw, it does not detect "objects" at all, only keypoints

berak gravatar imageberak ( 2018-03-16 05:09:50 -0600 )edit

H is not empty. With more texture, obviously the number of key points increased, now the good_matches.size() is varying between 40-60 with a few outliers. But still there is no bouding box around the keypoints of the object in real time. It is still at the corner as depicted in the above figure and sometimes with weird polygon shapes out of the bounds of keypoints. what could be the possible reason? Is there any minimum limit to number of matching points?

komms gravatar imagekomms ( 2018-03-16 06:20:51 -0600 )edit

all i'm saying is, that H can be empty, and your program will crash then, so check.

also, the boundingbox is not around the keypoints (it does not know about any kp), it's only the original rect, projected by H

"minimum limit " -- something like 5, iirc. below, it won't find any H

the quality of your matches unfortunaly does not say anything about how good/bad H will be

berak gravatar imageberak ( 2018-03-16 06:31:13 -0600 )edit

thank you :) I will check.

komms gravatar imagekomms ( 2018-03-16 07:16:33 -0600 )edit

@berak link: same link as above does this code detects objects in real-time video? or In real-time, are we supposed to make a tracker object to successfully detect and track the object?

komms gravatar imagekomms ( 2018-03-17 13:13:29 -0600 )edit

"does this code detects objects" -- NO. NEVER.

it detects keypoints, that's all it ever does. don't be mislead.

IF you're lucky to have enough good matches (you arent, above), you may try to find the homography from the matches, and try to project the initial boundingbox with that, to find a new position of "some part of the scene". but that's not "object detection" at all. it does not know about any "objects", only "there's 1 small part of the original scene", and "another image of the whole scene" (which might be scaled, rotated)

you have to strike out the word "object" anywhere in this context, it's only misleading.

berak gravatar imageberak ( 2018-03-17 13:24:12 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-03-21 12:43:03 -0600

komms gravatar image

updated 2018-03-21 13:56:10 -0600

solved the problem, in real-time, i declared all the variables and vector and Mat outside the loop. here is the correction.

   `while (key != 27)
  {

    Mat frame;
    cap >> frame;

    if (framecount < 2)
    {
        framecount++;
        continue;
    }


    Mat des_image, img_matches;
    vector<KeyPoint> kp_image;
    //vector<vector<DMatch>> matches;
    vector<DMatch >matches;
    vector<DMatch > good_matches;
    vector<Point2f> obj;
    vector<Point2f> scene;
    vector<Point2f> scene_corners(4);
    Mat H;
    Mat image;`
edit flag offensive delete link more

Comments

@berak when i delete the ifloop from the code, the bounding box is not stable(i mean its moving abruptly with weird polygon shapes). moreover if increase the condition in the loop to if (framecount<20) the framerate is not slow when compared with previous one. what role is framecount loop playing here. but one thing , its making the boundingBox stable.

komms gravatar imagekomms ( 2018-03-21 12:51:21 -0600 )edit

sorry, i do not understand, what you're saying. try to explain, again ?

berak gravatar imageberak ( 2018-03-21 13:16:00 -0600 )edit

@berak in short , During Real time video , the if conditional loop defined in the above code is giving me good results, but i didn't understand why it is used?

If I comment the loop then im getting an error named Error: Assertion failed (_queryDescriptors.type() == trainDescType) in knnMatchImpl which is clearly explained in this link https://stackoverflow.com/questions/22337841/assertion-failed-querydescriptors-type-traindesccollection0-type-in-k I don't understand how this error and loop are linked. my guess is - as webcam takes time to start and get the first frame till then the features detected from first video frame will be zero. so do you think this is the reason for that error? i hope you understand :)

komms gravatar imagekomms ( 2018-03-21 14:03:04 -0600 )edit

oh, if you have an older webcam, it might indeed need a "warmup", and the 1st soandso frames may be entirely black/unusable.

known problem. and the cure is similar to what you do -- read a few frames, throw them away and then start doing something for real.

berak gravatar imageberak ( 2018-03-22 07:08:33 -0600 )edit

thank you :)

komms gravatar imagekomms ( 2018-03-22 07:27:53 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-03-15 17:28:53 -0600

Seen: 1,339 times

Last updated: Mar 21 '18