Jul 14, 2016 10:52 AM
(This post was last modified: Jul 14, 2016 10:55 AM by SIM-1725686.)
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.
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.


