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
- 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]