[PYTHON] PGM that takes the difference of the specified rectangular area from the camera and makes a sound when the rate of change exceeds a certain rate

PGM that takes the difference of the specified rectangular area from the camera and makes a sound when the rate of change exceeds a certain rate


Register the rectangular area (2 places) that detects the difference from the camera in advance, and the difference of the rectangular area from the camera is a constant rate with another PGM. It is a PGM that makes a sound when the above is reached. (If you improve this, just move your eyes and mouth I think I can do something like Taiko no Tatsujin w ...)
This PGM github URL: https://github.com/NanjoMiyako/ImageDiffAndSound
How to use 1. First, execute registCaribRect.py and register two rectangular areas for difference. (Drag the rectangular area with the drag, then save the rectangular area A to the variable with the'a'key, save the rectangular area B to the variable with the'b' key, and then press the's' key to save each rectangular area to'caribRects.txt' Save to file as.) 2. Next, call playSoundByImageDiff.py with the following command line arguments. Command line argument 1: File in the registered rectangular area (file path of caribRects.txt) Command line argument 2: The rate of change of the reference that makes a sound by the difference of the rectangular area A Command line argument 3: The rate of change of the reference that makes a sound by the difference of the rectangular area B Command line argument 4: Number of seconds (floating point) interval to take the difference of rectangular area A Command line argument 5: Number of seconds (floating point) interval to take the difference of rectangular area B

Command line argument example: python playSoundByImageDiff.py C:\hogehoge\caribRects.txt 1.5 3.0 0.2 0.5

  1. After execution, each rectangular area will be drawn as a rectangular line segment from the screen on the camera. A sound is produced when a difference is detected by blinking that part.

Referenced site Draw a line on the live image of the camera at the mouse event of opencv (python) --Qiita File I / O — Python Online Learning Service PyQ Documents Split a string in Python (delimiter, newline, regular expression, number of characters) | note.nkmk.me Convert a character string to a number and calculate it with a number | Introduction to Python Convert number string str to number int, float in Python | note.nkmk.me
Sample sound source site used Pocket Sound-Free Sound Effect Material / BGM Download [mp3]

Recommended Posts

PGM that takes the difference of the specified rectangular area from the camera and makes a sound when the rate of change exceeds a certain rate
A game-like PGM that compares the PGM that registers poses from the background image with the registered pose image and camera image to measure the pose match rate according to the music.
The story of making a sound camera with Touch Designer and ReSpeaker
From a book that makes the programmer's way of thinking interesting (Python)
A python script that gets the number of jobs for a specified condition from indeed.com
A script that pings the registered server and sends an email with Gmail a certain number of times when it fails
A server that returns the number of people in front of the camera with bottle.py and OpenCV
A story that makes it easy to estimate the living area using Elasticsearch and Python
Extract only the sound of a specific instrument from a MIDI file and make it a separate file