**
Inventing a bike or shooting ducks with a webcam
The idea of creating such a mini-game has been warming ever since I first heard about how to build a pistol for a dandy. The whole point was that there was only a single photoresistor, and at the moment of the shot the whole screen was painted black, and the remaining white spot was a duck. Those. hit light, miss dark.
Using c # + xna, my idea ended in a complete crash, namely, the player sees the mark for a long time. This is actually the essence of my question. How can this be avoided? The problem is not exactly in the processing of photos, perhaps in getting the bitmap from the camera (although it takes not too long), it is possible that a significant amount of time also passes between drawing on the XNA screen of the draw method. I will try to bring the source code into a more beautiful view, if someone decides to help with the question.
So the prototype is simple. The game menu, in which it does not allow further play, if the user does not have a single connected webcam and the game itself, where ducks fly in an infinite loop, if the duck flew past the screen and was not shot down - some action (my deer laughs laughing ).
The main consideration was the definition of the label. I took aforge as a basis for getting a picture from the camera. On Stack, my question was not successful. The hit recognition algorithm itself was laid down as follows:
- Transformation of bitmap from camera to monochrome image.

- In a certain area from the center, we look for white spots and select each of them with rectangles.
- We are looking for rectangles inside which there is the same rectangle. (Here it was possible to check the distance from the center and finish, since this method gave 90% accurate recognition of misses).
- Check that the matrix of colors in the rectangle corresponds to light-dark-light-dark-light.
- Check how far from the center of the photo - the center of the rectangle. Those. how much we aim at the duck. We give the result.
The recognition logic is in the CenterTest class, and, accordingly, the project itself can be taken on the same github.
