-
Notifications
You must be signed in to change notification settings - Fork 10
Program Details
dram55 edited this page Aug 8, 2019
·
3 revisions
- Every 250ms the program reads a frame from the video feed.
- This frame will be added to a buffer containing the last 16 frames.
- On a separate thread is the following processing:
- If a black screen is detected:
- Check the buffer for a level screen.
- Run the reference image and current frame through
OpenCv.AbsDiff() - Take the resultant image and run it through a
OpenCv.ThresholdBinary()filter. - Take the resultant image and count the non-blank pixels.
- Divide the non-blank pixels by the total pixels in the frame.
- Subtract this value from 1 to get the percentage the images match.
- If the images are at least a 90% match:
- Grab the level author, level code & level name screeb regions from the current frame based on predefined rectangles.
- Run each of these through the
OpenCv.GammaCorrect()andOpenCv.Resize()filters for better contrast and size. This gives better results for the OCR. - Pass these images to the Tesseract library to perform the OCR.
- For the level code, use the whitelist command to help with accuracy:
tessedit_char_whitelist ABCDEFGHJKLMNPQRSTUVWXYZ0123456789-
- For the level code, use the whitelist command to help with accuracy:
- Write the results to a JSON output file.
- Broadcast new level info thru the Websockets server.
- Run the reference image and current frame through
- For each image frame in the buffer:
- For each available template image: (death icons, exit level button, start over button)
- Run the frame and template image through
OpenCv.MatchTemplate(). - If there is a match:
- Broadcast this event thru the Websockets server.
- Run the frame and template image through
- For each available template image: (death icons, exit level button, start over button)
- Check the buffer for a level screen.
- If a clear screen is detected
- Delay, to wait until the clear details are displayed on screen.
- Determine if comments are on the clear screen - this affects where the buttons and clear time are read from.
- For each available template image: (world record, first clear)
- Run the clear screen frame and template image through
OpenCv.MatchTemplate(). - If there is a match:
- Broadcast this event thru the Websockets server.
- Run the clear screen frame and template image through
- For each available template image: (world record, first clear)
- Read the clear time from the screen via Tesseract OCR library.
- Broadcast the clear event and clear time thru the Websockets server.