Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

Little Example of Motion Detection with Computer Vision

Hey guys, just found out about the EmguCV library (port of OpenCV to C#), and have been playing around with it.

The release of Pokemon Go has me really interested in augmented reality all of a sudden. I was thinking it would be cool if eventually games like those could include motion sensors...

Anyways, a first step towards something like this, I whipped a small app that you control by moving a bowl (or something circular). The procedure is straightforward:

1. Use computer vision to detect a circle.
2. Calculate its location, x and y, based on center and radius
3. Calculate ratio of each as compared to image's width and height, respectively
4. Calculate ratio of image size to window size
5. Multiply x and y by the ratio of the first ratio to the second ratio (three ratios total)
6. Move a cursor to the calculated position
7. #PROFIT





Here's a short video of it in action. You'll notice that when I hover over the button in the application, its text changes from "INACTIVE" to "ACTIVE." In addition, it is easily possible to outline the detected circle, in any color (I chose pink) in the preview window at the bottom of the form.

Also, here is the source code. Hopefully somebody can benefit from reading it.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Legends] by itcorpJul 29, 2026 01:40 PM 2 177 Jul 29, 2026 01:40 PM
Last Post: itcorp
[.NET] by xxdarklord65xxMay 27, 2017 11:32 AM 4 207 May 27, 2017 11:32 AM
Last Post: xxdarklord65xx
[Python] by SapienceApr 24, 2017 08:28 AM 22 616 Apr 24, 2017 08:28 AM
Last Post: Sapience