3

I don't know lots of things about the electronics field and controllers. But I want to know how to combine an opencv program with a red traffic light? I know that the answer is something that is micro controller but I only know that there is a compiler AVR which can compile C to hex and then working with micro controllers.

But OpenCV (which I think I won't run on C) is high level and probably won't work with AVR.

So what should I do to combine a machine vision program (by OpenCV & C++) and the timer of a traffic red light?

  • Changing my programming language and library is so difficult for me, according to some reasons.
  • My program must be real-time.
  • If there is another system(not controllers and ...) which it costs doesn't much and can run opencv programs, it can be used by me.

If you need anymore details just tell me.

10 Rep
  • 2,217
  • 7
  • 19
  • 33
Milad R
  • 1,854
  • 9
  • 25
  • 36
  • possible duplicate of [Opencv on TI microcontroller](http://stackoverflow.com/questions/10348075/opencv-on-ti-microcontroller) – karlphillip May 11 '12 at 18:36
  • It is obvious that I read that question before, but the person who answered that question said that it will work slowly, but being real-time is so important for me + specifically I said I want this on a traffic red light, so maybe there is a better answer! – Milad R May 11 '12 at 18:43
  • 1
    How are you going to connect your camera to your microcontroller? – Steven Lu May 11 '12 at 18:54
  • what processing power and memory does such traffic red light have to work with? define _real-time_: framerate, image size? – moooeeeep May 11 '12 at 19:59
  • I want to calculate the car numbers, so real-time means calculating the cars in each frame in the video in a short time. I don't know for example the exact number of "Frame per Second" But I know the quality of taking video by the camera is not very high. – Milad R May 11 '12 at 20:56
  • @StevenLu: I don't know about electronics. It is another problem that I have. If you know something about connecting ... please give me some advice if you can. – Milad R May 11 '12 at 21:01
  • I'm just trying to be realistic here... You should probably set your goal (initially) to be something more like accomplishing your OpenCV task using a modern computer and webcam, rather than an AVR µC. It's gonna be a LOT easier that way. – Steven Lu May 12 '12 at 06:25
  • 1
    Instead of getting openCV to work on a µC, you could try using ROS.org to communicate with the semaphore while running openCV on a normal linux machine. – Steve Heim May 12 '12 at 09:49

2 Answers2

8

The answer is not a microcontroller. That's one class too low. Get an ARM SoC (System On Chip) that comes with a DSP (Digital Signal Processor). They're quite common. For instance, the BCM2835 which is used in the Raspberry Pi. According to Broadcom, it should handle 220 Megapixels/second.

MSalters
  • 173,980
  • 10
  • 155
  • 350
  • If you compile OpenCV on the Pi, will it automatically take advantage of the Broadcom? – cjm2671 Apr 09 '14 at 15:00
  • @cjm2671: It doesn't matter whether you compile it **on** the Pi, it matters whether you compile it **for** the Pi. I'm not sure if the DSP is actually used by OpenCV, and in particular, by which algorithms (DSP's are sufficiently different that you can't just flip one compiler switch and magically have extra performance) – MSalters Apr 10 '14 at 10:03
  • OK, well after nearly 20 hours OpenCV 3 compiled on the Pi, so I'll start to experiment and see what the performance is like! Thanks! – cjm2671 Apr 11 '14 at 11:32
  • so.. @cjm2671 how was the performance? Also, which version of the pi are you using? Thanks! – 40pro Dec 04 '15 at 01:19
  • Many ARMs have OpenCL support as part of their core build which OpenCV supports – VoteCoffee Mar 09 '20 at 22:09
2

I originally reported this question as possible duplicate, but you asked some other questions that need to be addressed.

OpenCV provides a C interface as well as a C++ interface since version 2.0. So in theory, it is possible to configure and build OpenCV using a C compiler, but I don't know the difficulty behind this task since I never done it myself. Note that most of the C++ interface is coded only as a wrapper around the C interface.

About achieving real-time processing, that depends entirely on the processing power of your device and the algorithms you choose to use in your solution.

We recently had a discussion about real-time processing and OpenCV in this thread.

Community
  • 1
  • 1
karlphillip
  • 92,053
  • 36
  • 243
  • 426