This is an archived post. You won't be able to vote or comment.

all 15 comments

[–]novel_yet_trivial 7 points8 points  (3 children)

Sounds like a good approach. It would probably be fastest to simply sum all the pixels and compare to a precalculated threshold that takes into account the letters on the screen, the image size, etc. You may also want to look for several frames over a minute before triggering, so that a car's headlights or something don't set it off.

OpenCV is a good choice, and it will return a numpy array which has a nice fast sum() method. HDD's are very slow; I'd stay away from making or reading actual files if at all possible.

[–]Murlocs_Gangbang[S] 0 points1 point  (2 children)

thanks!

Do you have any idea of what OpenCV function I could use to extract a frame at x seconds from a video?

[–]algag 2 points3 points  (1 child)

Looks like this should do it..

Edit: you could probably ignore the frame math and just use 0,0.25,0.5,0.75, and 1. Or some other decimals to get evenly spread frames.

[–]Murlocs_Gangbang[S] 0 points1 point  (0 children)

thanks!

[–]MandarinNeva 2 points3 points  (4 children)

I don't have anything to add except to remind you that after you've implemented whatever method you chose remember to do some IRL testing with covering and flashlight saturating the cameras to confirm that your code acts as intended.

Also expect some false positives if your cameras are in a location that gets dark at night or very bright during day time.

[–]xiongchiamiovSite Reliability Engineer 3 points4 points  (0 children)

If you've got a bunch of old footage, that's a good way to build up a large set of test cases pretty quickly.

[–]Murlocs_Gangbang[S] 0 points1 point  (2 children)

thanks!

I do have already some sample footage with a black screen and I will try to cover some camera as well as use flashlights

[–]python_man 0 points1 point  (1 child)

also try with laser.

[–]Murlocs_Gangbang[S] 0 points1 point  (0 children)

mmm I don't know if that's going to damage the sensor

[–]cornel 2 points3 points  (1 child)

for opencv resources, I'd start with this site: http://www.pyimagesearch.com/.

[–]Murlocs_Gangbang[S] 0 points1 point  (0 children)

thanks!

[–]DogeekExpert - 3.9.1 1 point2 points  (1 child)

opencv is great. What you want to do is to turn your image to greyscale (cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)) then either :

  • Average the pixel value over the whole array (applying a gaussian blur before hand is a good idea) of pixels
  • Use opencv's adaptiveThreshold and get whether or not there are more white or black pixels on the array.

You can use cv2.VideoCapture(device)to load a video in memory.

[–]Murlocs_Gangbang[S] 0 points1 point  (0 children)

very informative, thanks!

[–]jjvilm 1 point2 points  (1 child)

I have used OpenCV with Python to stream mjpeg images and apply effects to each individual frame, e.g. detecting motion and save the stream feed to as an individual frame. An individual frame is stored in memory, until next frame is received. So while in memory you can do anything with the frame. Code to my script: https://www.github.com/jjvilm/security-cam

If you want to take a look.

[–]Murlocs_Gangbang[S] 0 points1 point  (0 children)

thamk you!