A simple OpenCV interface for light and motion detection within a drawn ROI.
- draw a rectangle ROI of any size directly onto your video of interest
- set a threshold for motion or light detection
- save frames in which light or motion is detected
- download and run draw_roi.py
- to run roi detection, run
detection(vid, type, threshold)
- tip: to use your video webcam, set
vid
as0
- tip: to use your video webcam, set
- a separate window for the videofeed should open.
- draw your roi by clicking the point that you want to be the top left corner of the roi followed by the point you want to be the bottom right corner of the roi. this should draw a blue rectangle roi on the frame.
- to delete a drawn roi, right click and the blue box should disappear.
- once an roi is drawn, between frame motion or pixel intensity will be calculated within it. frames in which motion or intensity is greater than the given threshold will be labeled ROI: motion/light on {}th frame and saved to your output csv.
- close the window by hitting
q
on the keyboard. this may take multiple tries if you haven't selected the video feed window. - detection will keep running until the last frame in the video or until the window is closed.
- detected frames will be saved in a csv to the file path specified!
roi-detection is integratable with Bonsai.
OpenCV, numpy, pandas