color detection using camera

Status
Not open for further replies.

fuxi

New member
hi,

i would like to do simple environment color detection using a cheap and small camera - which would be the best approach?
i was thinking about a halloween costume which could detect surrounding colours and adapt them to LEDs.
i'm aware of raspberry + openCV but afaik there's nothing like that for arduino - there's a camera module called OPENMV CAM H7 PLUS which features an ARM Cortex M7 cpu running at 480 MHz but it's pretty expensive ..
shouldn't it be possible with the teensy 4.1's fast cpu? it should use a small + cheap cam (or even several) which simple read out color information in realtime - is there a arduino library for handling video streams / color- and object detection?

thanks!
 
If you think of a photodiode as a single pixel camera, you can make a very low resolution color detector by using three of them. Either get ones that target the color frequencies you care about or get ones that sense full spectrum daylight and put translucent gel in front of each to allow you to measure the red, green, and blue. Normally, an op amp circuit is recommended for conditioning the photodiode output, but if you don't need high precision or high speed, you can do pretty well with the photodiodes connected directly to analog inputs. I've built a couple of gadgets for measuring the level of illumination in a skylight or indoors this way.

Code:
void setup() {
  pinMode(PHOTODIODE_CATHODE_RED, INPUT_PULLDOWN);
  pinMode(PHOTODIODE_ANODE_BLACK, OUTPUT);
  digitalWriteFast(PHOTODIODE_ANODE_BLACK, 0);
}


int readLight() {
  const auto count = 1024L;
  digitalWriteFast(PHOTODIODE_ANODE_BLACK, 1);
  auto sum = 0L;
  for (auto i = 0L; i < count; ++i) {
    sum += analogRead(PHOTODIODE_CATHODE_RED);
  }
  digitalWriteFast(PHOTODIODE_ANODE_BLACK, 0);
  return sum / count;
}

The photodiode I'm using is an ancient PBX81-1.

Note, I do not know if this would work as well on a T4.1 as it does in my case. I've done this with T3 and T LC.
 
Last edited:
Status
Not open for further replies.
Back
Top