I am working on a project to make a circuit for machine vision project. Basically, the circuit needs to take a picture (320×240), search for some features, and then give a command based on the features.

For example, if no red arrow is found, then a "clear" command will send. If a red arrow is found, then the circuit needs to send out the direction of the arrow.

My question is: if I want to finish each cycle (from taking a picture to direction outputting) in 2 seconds, would it be possible to use a PIC microcontroller? Which PIC controller and camera would allow me to do that?

NOTE: my boss needs an ACAP (as cheap as possible) solution.

  • 1
    \$\begingroup\$ You should tell your boss that ACAP is not a specification. You need an actual budget. \$\endgroup\$ – stevenvh Aug 5 '12 at 6:12
  • \$\begingroup\$ I think I can sell my solution to my boss if the cost for the circuit and camera is less than USD$60. \$\endgroup\$ – Superhero Aug 5 '12 at 6:27
  • \$\begingroup\$ How fast does the recognition need to be? \$\endgroup\$ – suha Aug 5 '12 at 6:50
  • 2
    \$\begingroup\$ @Superhero The time will totally depend on the complexity required for detection. You need to give much more info. I think three weeks is not long enough for you to complete it. \$\endgroup\$ – geometrikal Aug 5 '12 at 8:06
  • 1
    \$\begingroup\$ A single color image at 24 bit color depth is 320×240×3 bytes in size. Not much of a chance that a PIC has 230400 bytes of free RAM. You can of course reduce color depth to 8 bits (3 bits for red, 3 bits for green, two bits for blue), then your image will still use 76800 bytes and that will probably not fit in an average PIC either (I never studied PIC datasheets, but near 100kB RAM for a simple microcontroller sounds unlikely to me). \$\endgroup\$ – jippie Aug 5 '12 at 10:01

It's plausible that a PIC32 will be able to do this job, but it depends enormously on the details of your recognition algorithm. Here are some possible algorithms you might be intending to implement:

  • Detect a bright red arrow, which is always the same size, in a well lit scene of completely non-red objects.
  • Detect a bright red arrow, which is can be different sizes, in a well lit scene of completely non-red objects.
  • Detect a reddish arrow, which is can be different sizes, in a poorly lit scene of objects, many of which of which might also be red, and where the background might also be red.

The first one would be a much simpler algorithm than the last.

Whatever you do, you'll have to take quite a bit of care with you use of memory and processing resources. The PIC32s have a maximum of 128k memory, which should be enough to store the image:

320x240 = 75kB.

...as long as you only store the hue component. Alternatively, you may be willing to store a lower resolution image with 24-bit colour.

160*120 = 56kB.

If you can give us some details of the exact nature of the recognition, and the algorithm, we may be able to help more:

  • Have you implemented this already on a PC?
  • Is the arrow always much redder than the background?
  • Will the arrow always be the same size on the image?
  • Will it always be the same arrow? Or might it be a hand-drawn arrow?
  • \$\begingroup\$ Thanks for your answer. The arrow is always redder than the background. The arrow is not always the same size. You can assume the arrow in my case is (x1 i + y1 j) is the end and (x2 i + y2 j) is the head. The x1, x2,y1,y2 will be changed every time on a image. It is not a hand - drawn arrow \$\endgroup\$ – Superhero Aug 5 '12 at 13:53
  • \$\begingroup\$ @Superhero - Can you post an example image ? \$\endgroup\$ – Rocketmagnet Aug 5 '12 at 13:54
  • \$\begingroup\$ Actually I will use my system to detect two metal plates alignment. The idea is a red line on the top edge on a metal plate. The 2nd plate will be on top of the 1st plate. If everything is aligned perfectly, the 2nd plate will totally cover the red line on the 1st plate. If either one shifts, the red line will be seen, then I have to tell what is the angle of the red line seen by the camera, so that some adjustment can be done in that situation. \$\endgroup\$ – Superhero Aug 5 '12 at 14:17
  • \$\begingroup\$ @Superhero -Have you considered just using a Raspberry Pi or something ? \$\endgroup\$ – Rocketmagnet Aug 5 '12 at 14:23
  • \$\begingroup\$ Do I need to install an OS on the Raspberry Pi ? I don't have any experience of Raspberry Pi at all \$\endgroup\$ – Superhero Aug 5 '12 at 14:42

I too was going to suggest the Raspberry Pi. It comes preloaded with a Linux based OS, but there is a lot of hacking going on to give it enormous functionality on top of what you get out of the box. People have got Android running on it, but more helpful (if you are new to it) would be what Adafruit just released: Adafruit Raspberry Pi Educational Linux Distro. It is a brand new Linux distro specifically for the Raspberry Pi, making a lot of things much easier to do on it. I think a huge amount of complexity will be removed from your project if you use something other than an MCU.

  • \$\begingroup\$ Right now Raspberry PI has long delivery time and in limited buying quantities. For example you can not order 10000 pcs. That might eliminate it in many commercial projects, probably including this one. \$\endgroup\$ – avra Aug 6 '12 at 9:10
  • \$\begingroup\$ @avra I don't think he mentioned that he needed to make that many, but I understand your point. Although I think they lifted the limit on the number you can buy - I think. \$\endgroup\$ – capcom Aug 6 '12 at 11:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.