Opencv7 with a Raspberry Pi

Discussion related to "under the hood" OpenMV topics.
User avatar
Bonzadog
Posts: 2
Joined: Tue Dec 13, 2016 10:56 am
Location: Germany

Opencv7 with a Raspberry Pi

Postby Bonzadog » Fri Jan 05, 2018 10:05 am

5.1.2018

Due to the documentation being rather a dearth, I need to ask a few elementary question before I start new projects.

For Project #1: I would like to connect the M7 to a Raspberry Pi 3 look for, say, a blue object and yellow rectangular object,
count them and send the coordinates of the found objects to the raspberry pi3 so a robot arm may pick them up.
I would have to, of course, somehow convert the M7 coordinates to the Robot Arm coordinates - this may be interesting to achieve.
Perhaps detecting the robot arm on the M7 and send coordinates of the arm to the rpi for coordinate transformation.

Project # 2: using the M7 camera to find a path through obstacles perhaps reading the M7 camera input into the RPi and run opencv
for that pathway detection.

Project 3 is face detection: the detected face must be sent to the RPi (jpg) for processing - also unknow faces sent to the RPi3.
I think this will not be an easy task.

Can one reprogramme the Camera via the RPi3? This is to use create multifunctionality when events demand that.

Thank you for any assistance
User avatar
kwagyeman
Posts: 1771
Joined: Sun May 24, 2015 2:10 pm

Re: Opencv7 with a Raspberry Pi

Postby kwagyeman » Fri Jan 05, 2018 10:57 am

Project 1 is very easy, the find_blobs method does all this for you and tells you the centroid of objects. You can then send these centroids to the Pi via a UART. See the pixy emulation example for how to send packet data over the UART using the struct module.

Project 2 involves path planning. We don't offer any higher level Ai ish support like that. If you know how to code these type of algorithms from scratch then you can hand roll them to run in python on the M7. Otherwise, sure find a path planning lib on the Pi and use that.

Project 3 is easy, just use our face finder, and on detection of a face jpeg compress the image and send it to the Pi.

...

None of these projects above though need the OpenMV Cam. What's your reason for using it with the Pi and not the Pi Cam? Yes, I understand we make the CV part a lot easier. If you're good with serial comms then this trade-off makes sense.
Nyamekye,
User avatar
Bonzadog
Posts: 2
Joined: Tue Dec 13, 2016 10:56 am
Location: Germany

Re: Opencv7 with a Raspberry Pi

Postby Bonzadog » Fri Jan 05, 2018 12:38 pm

Thank you for your reply.

I do not think it is all so easy as you state.

I could use an RPi camera but what then is the point of the M7 Camera.

Can one send programmes to the M7 from a RPi3?

I'll I'll need to finalise the high-level designs and reconsider the projects.
User avatar
kwagyeman
Posts: 1771
Joined: Sun May 24, 2015 2:10 pm

Re: Opencv7 with a Raspberry Pi

Postby kwagyeman » Fri Jan 05, 2018 8:43 pm

Yeah, we have OpenMV IDE for the Raspberry Pi.

Since we're a MicroPython board you can also use the MicroPython control python script to tell the board what to do by uploading a new MicroPython script to it.
Nyamekye,
mannybranden7
Posts: 7
Joined: Mon Dec 11, 2017 10:25 pm

Re: Opencv7 with a Raspberry Pi

Postby mannybranden7 » Tue Apr 10, 2018 3:31 pm

kwagyeman wrote:
Fri Jan 05, 2018 10:57 am
Project 1 is very easy, the find_blobs method does all this for you and tells you the centroid of objects. You can then send these centroids to the Pi via a UART. See the pixy emulation example for how to send packet data over the UART using the struct module.

Project 2 involves path planning. We don't offer any higher level Ai ish support like that. If you know how to code these type of algorithms from scratch then you can hand roll them to run in python on the M7. Otherwise, sure find a path planning lib on the Pi and use that.

Project 3 is easy, just use our face finder, and on detection of a face jpeg compress the image and send it to the Pi.

...

None of these projects above though need the OpenMV Cam. What's your reason for using it with the Pi and not the Pi Cam? Yes, I understand we make the CV part a lot easier. If you're good with serial comms then this trade-off makes sense.
Is there any sample code that demonstrates how to send the jpg image that is taken by the M7 and send it over to the Pi?
User avatar
kwagyeman
Posts: 1771
Joined: Sun May 24, 2015 2:10 pm

Re: Opencv7 with a Raspberry Pi

Postby kwagyeman » Tue Apr 10, 2018 5:53 pm

What method do you plan to use for reception?

send.uart(I'm going.compressed_for_ide()) is enough if you are sending over a UART.
Nyamekye,
mannybranden7
Posts: 7
Joined: Mon Dec 11, 2017 10:25 pm

Re: Opencv7 with a Raspberry Pi

Postby mannybranden7 » Tue Apr 10, 2018 7:49 pm

kwagyeman wrote:
Tue Apr 10, 2018 5:53 pm
What method do you plan to use for reception?

send.uart(I'm going.compressed_for_ide()) is enough if you are sending over a UART.
We planned on using the fastest possible way to send the image since the camera will be moving at around 25mph and we need it to detect, capture, send, and then again continuously detect blobs. Looking over the forums, it seemed like SPI was the way to go but I could be wrong?
User avatar
kwagyeman
Posts: 1771
Joined: Sun May 24, 2015 2:10 pm

Re: Opencv7 with a Raspberry Pi

Postby kwagyeman » Wed Apr 11, 2018 2:46 am

No, SPI is defiantly the way to go. The code is effectively the same. On the PI you need it to be a SPI slave to receive the data.
Nyamekye,
mannybranden7
Posts: 7
Joined: Mon Dec 11, 2017 10:25 pm

Re: Opencv7 with a Raspberry Pi

Postby mannybranden7 » Sat Apr 14, 2018 6:21 pm

kwagyeman wrote:
Wed Apr 11, 2018 2:46 am
No, SPI is defiantly the way to go. The code is effectively the same. On the PI you need it to be a SPI slave to receive the data.
You're saying the camera needs to be a slave and the pi the master, right? Thats what I see in the example you have for the arduino.

I'm having a lot of difficult connecting the two together. I am using the example from the arduino spi slave example code as a reference to try and implement it for the Pi but I am not receiving anything on the Pi. I get a bunch of garbage data and not sure what could be wrong. I also do not really understanding how to send the data from the M7 using the ustruct pack and then put the data back together into a jpg image. Can you possible show how to set this up? This could be really helpful for this project we are working on and future projects that we plan on working on and integrating with a Pi.
User avatar
kwagyeman
Posts: 1771
Joined: Sun May 24, 2015 2:10 pm

Re: Opencv7 with a Raspberry Pi

Postby kwagyeman » Sat Apr 14, 2018 9:12 pm

Hi, the camera has to be a SPI master, it's works really bad as a slave device.

That said, you can get video data through USB with the camera. In fact, OpenMV IDE runs on the Raspberry PI: https://openmv.io/pages/download

The camera will appear as a VCP port on the PI and you can push data through that at 12 Mb/s. Note that you can just push the blob detections.

Note that, the same code working in OpenMV IDE that prints stuff to the terminal in OpenMV IDE will print to the VCP port when opened by another program.
Nyamekye,
ChesLans
Posts: 1
Joined: Tue May 01, 2018 12:43 pm

Re: Opencv7 with a Raspberry Pi

Postby ChesLans » Tue May 01, 2018 1:36 pm

Hi...as per my knowledgethe blue filter will be installed on the Earth Observing Astro Pi unit for the duration of the mission. It basically stops visible red and green, but lets visible blue and infrared pass through into the camera. It permits a type of EO analysis of vegetation on ground. Infrared then goes into the red RGB channel of the image data.

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 3 guests