Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Webcam for EV3 object detection. #747

Open
KooshaKayani opened this issue Jul 3, 2020 · 9 comments
Open

Using Webcam for EV3 object detection. #747

KooshaKayani opened this issue Jul 3, 2020 · 9 comments

Comments

@KooshaKayani
Copy link

Hey I'm trying to make an object detection code to detect black and silver balls. I'm tried to use pixycam2 but it only detect hue colors. I want to know if there is any way to use pixy as webcam and write a new algorithm with TensorFlow lite and open cv. but I don't know how to use pixy as webcam or if its possible to do so. If not is there any other way to do such a thing like using raspberry pi and then connecting it to ev3 (which I don't know how to do that). Or should I use an other webcam? But I don't know what webcam to use. can someone help me with any of those questions? that would be really appreciated.

@QuirkyCort
Copy link

Going for Robocup? Those balls can be rather challenging to detect reliably.

No idea if you can use a pixycam as a webcam, but you should be able to just get a cheap webcam and get it to work with ev3dev. A quick google suggests that the Logitech C270 and Logitech C920 works fine.

The EV3 is very slow compared to a Raspberry Pi. You may get better results if you use the pi to perform the object detection and send the result to the EV3. You can send the results via a network link; just connect them the same way that you would connect an EV3 to a computer.

@WasabiFan
Copy link
Member

The advice from @QuirkyCort is good. In addition:

The USB port on the EV3 is only USB1.1, making it inadequate for even moderate video bitrates. It can work, but it won't be pleasant, and as mentioned above the processing on the EV3's slow CPU will be extremely limited.

Doing the computations on an external RasPi would make a lot of sense. I've personally had success with doing color-based detection on Raspberry Pi Zero, which is on the very low end of CPU specs but is very likely to fit into your size/profile budget. If you have extra space and power, a full RasPi is certainly capable -- the RasPi 4s are super powerful, for their class!

To connect a RasPi to the EV3, the easiest option is probably (?) to modify an EV3 cable so you can connect it to the RasPi via UART. I am having trouble finding the posts I know we've had about how to do this, but @dlech may know. Another option may be to plug the RasPi in via USB, using the RasPi's client (OTG) port.

@KooshaKayani
Copy link
Author

thanks @QuirkyCort and @WasabiFan I will be trying to connect a raspberry pi to ev3.
Do you have any advice for object detection? I'm trying to use TensorFlow light.
@QuirkyCort & @WasabiFan can you explain how to connect ev3 and raspberry more clearly cause unfortunately most of the records are old, incomplete or not clear in the internet.
thanks koosha.

@KooshaKayani
Copy link
Author

Also is there anyway for them to communicate via USB cable?

@dlech
Copy link
Member

dlech commented Jul 6, 2020

Raspberry Pi is a Linux computer, so connecting the EV3 to it is the same as any other Linux computer.

@KooshaKayani
Copy link
Author

@dlech Is there any way for me to connect raspberry and ev3 via Bluetooth and python?
I need to complete a task in raspberry and send the result to ev3 using Bluetooth or any other fast form of communication if its possible.

@QuirkyCort
Copy link

Connecting the RPI to EV3: https://www.ev3dev.org/docs/tutorials/connecting-to-the-internet-via-bluetooth/
The RPI is a linux computer, so follow the steps for Ubuntu. If you're not running Ubuntu on your RPI, you may need to modify the steps a little.

Sending data from RPI to EV3: https://realpython.com/python-sockets/
Once connected, you can send data over the network. If both ends are running Python, the above will give you a starting point.

@KooshaKayani
Copy link
Author

thanks @QuirkyCort that helps a lot

@WesleyJ-128
Copy link

Do you have any advice for object detection? I'm trying to use TensorFlow light.

You could use GRIP, which gives you a GUI for designing an OpenCV pipeline, then creates Java or Python code to run that pipeline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants