a Line pixel comparison beetwen 2 frames of the same video

asked 2018-03-28 06:43:03 -0500

Hi everybody, I tried to found something in other topics, but i saw nothing dealing with my problems.

I try to compare a horizontal line between different frames of the same video, for example a frame each 0.1seconde, in order to know if the pixels color are the same or not, a way to count changing for a crossing line.

Can someone help me or give me some ideas, because i'm new in open cv i don't know if there are some fonctions for that.

thank u

edit retag flag offensive close merge delete

Comments

what are you trying to achieve ? what is the purpose of your program ?

berak gravatar imageberak ( 2018-03-29 01:31:17 -0500 )edit

i have a video, and i drew a line on the video in order to know how much cars crossed the line. My idea was to check the pixel's color corresponding to my hypothetic line, if they change frame after frame. If the color changes it means that the line is crossed, if not: no one crossed. Ex: we imagine a white line on the video. If a blue car cross the line, we will have blue pixel's color on the line. that was my idea. But i'm trying to do it, but didn't found any methode to compare pixel of a video. I was thinking about it, i converted my video into several images that i stored in a file. But don't know how to implement that line pixel ( between 2 points) comparison from a frame reference to other frames.

Chronos gravatar imageChronos ( 2018-03-29 07:23:09 -0500 )edit

So i'm here,

import cv2

vidcap = cv2.VideoCapture('video.avi')

success,image = vidcap.read()

count = 0

success = True

while success:

cv2.imwrite("frame%d.jpg" % count, image)

success,image = vidcap.read()

print ('Read a new frame: ', success)

count += 1

Chronos gravatar imageChronos ( 2018-03-29 07:26:19 -0500 )edit