Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Track 3 SPECIFIC bubble in videostream full of bubbles

I want to track 3 bubbles in videos(converted to GIF for uploading) like this

and append the x,y in vectors or lists for cv::polylines. I can track if there is ONLY bubble in every frame and draw a track line for it with polylines but when I want to append ALL OF THEM in lists so I can select the bubbles I want, stuff goes WRONG.

I cant append the x and y of a bubble in its own vector.

code is simple but I made A CODE for anyone who needed the obvious code:

   Mat frame,edgeFrame;
    vector<vector<Point>> cnts;
    vector<Vec3i> hie;
    vector<Point2f> XY;
    float r;
    // specific vector for each bubble
    vector<Point> firstBubble,secondBubble,thirdBubble,fourthBubble,millionthBubble;
while(true){
        cap >> frame;
        canny(frame, edgeFrame, 50, 150, 3);
        findContours(edgeFrame, cnts, hie, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE);

        for(int i = 0 ; i < cnts.size() ; i ++){
         minEnclosingCircle(cnts[i], XY, r);

         circle(frame, XY , r , Scalar(0,0,0), 1 , LINE_AA);

         // append the XY of contour to the specific list
         //AKA the problem

}
}

to be more clear I want to draw from vectors like track lines: the GOal

P.S : one,two,three,four, ... is the name of vector.

this is not the only video that I want to track my bubbles.

bubbles are eggZaklty the same color and shape but the radius is not constant and it can be chaotic

THE BUBBLES CAN MOVE HORIZONTALLY TOO

Track 3 SPECIFIC bubble in videostream full of bubbles

I want to track 3 bubbles in videos(converted to GIF for uploading) like this

and append the x,y in vectors or lists for cv::polylines. I can track if there is ONLY bubble in every frame and draw a track line for it with polylines but when I want to append ALL OF THEM in lists so I can select the bubbles I want, stuff goes WRONG.

I cant append the x and y of a bubble in its own vector.

code is simple but I made A CODE for anyone who needed the obvious code:

   Mat frame,edgeFrame;
    vector<vector<Point>> cnts;
    vector<Vec3i> hie;
    vector<Point2f> XY;
    float r;
    // specific vector for each bubble
    vector<Point> firstBubble,secondBubble,thirdBubble,fourthBubble,millionthBubble;
while(true){
        cap >> frame;
        canny(frame, edgeFrame, 50, 150, 3);
        findContours(edgeFrame, cnts, hie, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE);

        for(int i = 0 ; i < cnts.size() ; i ++){
         minEnclosingCircle(cnts[i], XY, r);

         circle(frame, XY , r , Scalar(0,0,0), 1 , LINE_AA);

         // append the XY of contour to the specific list
         //AKA the problem

}
}

to be more clear I want to draw from vectors like track lines: the GOal

P.S : one,two,three,four, ... is the name of vector.

this is not the only video that I want to track my bubbles.

bubbles are eggZaklty the same color and shape but the radius is not constant and it can be chaotic

THE BUBBLES CAN MOVE HORIZONTALLY TOO

EDIT: Can I use something "like" optical flow on binary images? what I want is in lk_track in python examples