Azzera filtri
Azzera filtri

Webcam colored object tracking, how to leave a lasting path from centroid of an object

1 visualizzazione (ultimi 30 giorni)
So I have already have a code that tracks two object's centroids/borders/distances, and I would like to further add to this to track the position of the objects and leave a lasting path of the trail of the object's centroids.
Most examples I have examined only use this for an imported video, so if anyone knows any resources that use a live webcam video for this task would be very helpful.
Here is the section of my code for annotate the image with aforementioned plots, just wondering how I need to go about creating this trail that will stay on the output figure
imshow(RGB);
imshow(redYellowOverlay);
hold on;
plot(rjMean,riMean, 'g-x', 'LineWidth',5)
plot(yjMean,yiMean, 'g-x', 'LineWidth',5)
plot([rjMean,yjMean],[riMean,yiMean],'b','LineWidth',2);
RGB is the snapshot taken from the webcam, redYellowOverlay is the border code, ri/rj/yi/yj means are the centroid coordinates and all plot() lines are plotting of centroids/distances onto the figure

Risposte (2)

Sourabh
Sourabh il 23 Feb 2023
One workaround which I can think of for your problem is storing the previous centroid positions for each object and then plotting a line connecting them to the current centroid position on each frame.
To use a live webcam video, you can read frames from the webcam using the snapshot function from the Image Acquisition Toolbox.
Alternatively, you can use the snapshot method of a webcam object from the Support Package for USB Webcams.
You might find this example relevant for your use case:
Hope this helps!

Image Analyst
Image Analyst il 23 Feb 2023
You need to plot the whole vector, from time=0, rather than just the last point.
My attached code doesn't do that but it might be useful for people learning how to track a moving colored object in a video.

Categorie

Scopri di più su MATLAB Support Package for IP Cameras in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by