EEVblog Electronics Community Forum

Electronics => Projects, Designs, and Technical Stuff => Topic started by: yanir on February 16, 2014, 12:56:49 am

Title: Machine Vision on Microcontroller
Post by: yanir on February 16, 2014, 12:56:49 am
Anyone do any work with machine vision? I'm looking to implement some basic machine vision tasks on an STM32F4 (ARM cortex M4). I'd like to use OpenCV but it may not compile for this part. Can anyone point me to some libraries or resources. I've read that I may need to implement the algorithms my self. Not out of the question but it would be nice to save the time.

Thanks
Title: Re: Machine Vision on Microcontroller
Post by: nctnico on February 16, 2014, 01:02:35 pm
What kind of algorithms do you need? Do you really want to use a microcontroller for this? OpenCV needs lot of memory but it does come with almost every algorithm you'd need. If you want to develop fast then a board with some kind of Linux would be the best option.
Title: Machine Vision on Microcontroller
Post by: yanir on February 16, 2014, 08:55:48 pm
This is for a custom board I'm designing that is cost sensitive. And I don't want to spend time booting into an OS. The stm32f4 is quite capable and there are examples of face tracking projects implemented on it.
I don't need  every algorithm. Id strip out most of it, but id like basic image manipulation, compression, and algorithms related to basic object recognition. I am adding ram beyond what is available on the part.
 
I'd also use other libraries if you have a recommendation.





Sent from my iPhone using Tapatalk 2
Title: Re: Machine Vision on Microcontroller
Post by: senso on February 16, 2014, 09:10:36 pm
Using a Freescale iMX233 would no add THAT much cost, and a stripped linux will boot in a couple of seconds at most.
Title: Machine Vision on Microcontroller
Post by: yanir on February 16, 2014, 09:38:00 pm
Couple of seconds is 2 seconds too long for this application.

I've worked with an imx23 on a prior project and it's not a good part to use on new designs.


Sent from my iPhone using Tapatalk 2
Title: Re: Machine Vision on Microcontroller
Post by: dannyf on February 16, 2014, 10:00:29 pm
Depending on what vision you ate talking about, the simplest could be done with two photo resistors and a 555.
Title: Machine Vision on Microcontroller
Post by: yanir on February 16, 2014, 10:13:03 pm
I'm using a CMOS camera.
One application is to wait for an object of interest to be detected, take a full frame snapshot to be retrieved later.

What options I have to 'detect' will be determined by how much of the library I can support. Has anyone compiled opencv for a similar processor?


Sent from my iPhone using Tapatalk 2
Title: Re: Machine Vision on Microcontroller
Post by: nctnico on February 16, 2014, 10:25:05 pm
I have compiled standard applications on an ARM microcontroller before (like PolarSSL). You'll likely need a POSIX compliant environment providing stubs for syslog, fread, fwrite, fopen, etc and support for malloc, realloc and free. Implementing malloc, free, realloc is not difficult although the biggest challenge is to prevent memory fragmentation. Maybe you need threads/multitasking as well. The easiest way to get multitasking is using an RTOS (realtime OS). Booting will be quick. You have to analyse what OpenCV needs in terms of memory management and threads first. If some processing task takes a long time it will help to have multitasking in order to keep the user and/or communication interface going.

In my last OpenCV project I created some simple C++ classes around the coordinate lists used by OpenCV so the memory gets freed automagically when the list goes out of scope. AFAIK there is also a standard C++ inteface to OpenCV but the documentation for that is even more scarse than the documentation on OpenCV itself.
Title: Re: Machine Vision on Microcontroller
Post by: AlfBaz on February 16, 2014, 10:46:03 pm
Quote
Couple of seconds is 2 seconds too long for this application.
Considering your requirements this may not  be appropriate but thought I'd post this anyway.

STM32F429 UcLinux port (https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?View=%7bE1E1A7CE%2d0B5B%2d453B%2d8263%2d1E808C92B673%7d&RootFolder=%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fSTM32Discovery%2fuCLinux%20on%20STM32F429I%2dDISCO&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&currentviews=2032)

They say a couple of seconds boot time but if memory serves me well it seemed almost instantaneous when I tried it
Title: Re: Machine Vision on Microcontroller
Post by: yanir on February 16, 2014, 11:29:56 pm

They say a couple of seconds boot time but if memory serves me well it seemed almost instantaneous when I tried it

That's pretty nice. I'll check it out. Thanks
Title: Re: Machine Vision on Microcontroller
Post by: yanir on February 16, 2014, 11:34:22 pm
AFAIK there is also a standard C++ inteface to OpenCV but the documentation for that is even more scarse than the documentation on OpenCV itself.

I don't get why it's so poorly documented. I was first introduced to opencv over 10 years ago and I would have expected this to improve over that time.

RTOS does seem like the way to go. I'd like to get some proof of concept stuff done quickly however.