Skip to content
Advertisement

How do you make the code check which section a tracked object is in?

sorry if the title is unclear. I’m making a code in OpenCV-Python that tracks the location of my pet goldfish and outputs a keystroke depending on which quadrant of the frame she is in. I’ve already gotten the program to track my fish and output her location in coordinates, but how do I convert this into a keystroke (W, A, S, D)? Like, if the fish is in quadrant one, output W, and if the fish is in quadrant two, output A.

This is the code I have so far.

JavaScript

Thanks for the help.

Advertisement

Answer

If I understand you correctly you want to put an image up with the frame, that image depends on what direction your fish is going. Like you’re steering it with the wasd commands right? To place an image ofe another image:

JavaScript

So you just “cut” out a piece and paist your pic in the hole it left.

Let me know if it works! Have fun!

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement