using open cv to control relay
Hi all,
First off, I'm new to the forum so I wanted to say hi.
Also, as you can tell from my name, I am very new to all this, but I'm eager to learn, so any help would be much appreciated!
Ok, so I want to use open cv to be able to identify 3 colors: red blue, and green. and then when it detects those colors, sends a signal to the GPIO pins to open and close a relay.
I've played around with some code that I have found, but frankly, I'm lost.
Again, any help would be greatly appreciated!
And your problem is...? What did you try? It seems that you didn't invest the minimal effort to solve this.
I'm lost as to how I should even start this project to be quite frank. I've been reading through all the tutorials I can find on open cv and it seems that everything is geared to capturing images and processing them, but not actually doing anything physical, if that makes sense. I want the program to be able to pick out either green, blue, or red colors. Then, once one of those colors is detected, send a signal to a relay to turn on a pump for a specified length of time. If you could just point me in the right direction I would greatly appreciate it!
an image will be helpful to understand your need
@sturkmen. U don't needed images. Probably used webcam.
@Noob87. What ur pi model OS? R u using webcam or picamera?
I do not have relay switch. I can substitute for leds
I'm sorry, I should have been more clear. I'm using a raspberry pi4 and a picamera. I have been able to alter code to pick up the three colors I need. I guess now my question is how do I get the program once it finds a color (say blue) to send a signal to the GPIO pins to turn on my relay for the pump? Once the program finds a color, is that stored as a variable which can be used to send such signal? I'm really confused. Thanks again everyone for your time.
I am using pi4 with 4gb/8gb, Buster v10. Thonny 3.7.3. I posted my answer detected blue colour. Notitced, I used 5% for 100 and 105. If ur colour is slightly than my. U can in increasing 10% to make sure rectangle doesn't shaking.. Btw, I do no have the code with me.I'm off for a years.
With this:
Btw, u can used
VideoCapturer
api with picamera