I have an input file with the frame number and x,y coordinates for every frame in a video. Ex:
<frame#> <x>,<y>
3984 346,983
How would I use this information to draw these points on the respective frames and save the video with this information?
Just commenting here as Reine's comment below needs a correction. The second value should be the (x,y)
of the endpoint, not the height and the width.
Alternatively, use just the rec
-argument call, which does take the (x, y, w, h)
form.
What do you want to draw? I'm assuming you want to mark out that specific spot? Then I would suggest you drawing a small rectangle/square around that specific pixel. Here's the python code:
cv2.rectangle(img,(xCoor,yCoor),(width,height),(255,0,255),3)
img is that frame you input. xCoor and yCoor are x and y coordinates. In your case its xCoor=346, yCoor=983. Width and Height is how wide and tall you want your rectangle to be. (255,0,255) are just rbg values for your drawn lines. Last parameter (3) is line thickness.
If you want to mark a dot or a spot, try drawing a tiny circle around your x and y coordinates with cv2.circle().
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.