hi all
i have only recently started learning about arduino and i am currently trying to build a led cube.i find the whole thing very interesting.i am thinking about a new project and i am collecting knwoledge about stuff i could use.right now i am wondering how i can use a camera to "see" something and recognize colors.i have seen videos with robots doing that but i dont actually understand what it takes for it to be done...any help would be appreciated
All newbie camera questions get the same answer. You can't do that with an Arduino.
omg now u are killing me...i have seen so many projects with that function but not any with an arduino,i didnt think this was because it cant do it...is it something that i cant do it any way as long as i work with an arduino or if i buy an extra shield (and what would that be) i would be able to?and if u know,why exactly cant arduino do something like that?
Severe lack of horsepower to do much with images. Its an 8 bit microcontroller with 2k of ram. A similar amount of computing power to the late 70's early 80's personal computers. They didn't do images either.......
Yes, it is something you could do with an extra shield. That shield would need to have a pentium chip, lots of memory, and a USB interface for the camera to connect to. It would use only the TX, RX, and ground pins of the Arduino. The shield would send serial data to the Arduino.
As far as I know, no one currently has any of the shields in production.
The Arduino simply does not have enough memory to hold even one frame of data from the camera in memory, it can not read the entire frame before the camera has refreshed the frame, and it does not have the floating point hardware needed to perform the calculations required to track an object.
Aside from those trivial reasons, there is no reason it wouldn't work.
although i believe i got no chance in that,just to make it clear,i dont want to see colors ine video,only in images,so the camera can take a snap and then somehow the colors could be identified...i any case...can u propose me some other way then to identify colors in an object?i guess it has something to do with photodiode but i cant say that i understand their use completely
First off, this isn't a cell phone/text messaging forum. If you can't type out whole words and phrases, you aren't really welcome here.
Proper use of spaces and punctuation is appreciated, too.
We need to stop talking in general terms, and start talking in specific terms. Do you have some specific camera in mind?
Most cameras output jpeg files. A jpeg file is a compressed image format. In order to make use of the data in the picture, it must first be uncompressed. That means that entire image must be read into memory at once. Given that the Arduino has, typically, 2K of memory, and that one pixel requires 5 bytes (x, y, r, g, & b) to define it, you could hold a maximum of 400 pixels AFTER decompression. Keeping in mind that the compressed and decompressed images must both be in memory at once, that limits you to less than 200 pixels. That would be a 14 x 14 pixel picture.
Another thing to keep in mind is that the decompression software is very complex, and probably wouldn't fit into the Arduino's code space.
It sounds like your real question is, "can I detect colors?" One way to do this is a camera, and since you said the word camera everyone has jumped in to say "Nope! Arduino can't do it"
If all you want to do is detect the color of objects, then look at this sensor:
This camera should work for you.
It most likely won't be real-time, but it should work. You might have to use just a small portion of the image also..
@Coyote: have you actually implemented JPEG decode on an Arduino?
Hard, isn't it?
@Groove,
Lol, you're right. Didn't realize jpeg is such a pain.
I was figuring the link sprite was a viable module being there is no intense timing and quantity of data.
Jpeg is a lossy compression algorithm..
The robots you see doing that are using or mini portatil pc's, or powerfull arm's, usually the blackfin dev board that already have cameras included.
If using one pc openCv is the way to go.
The great thing about JPEG is that the 8x8 compression blocks give a easily-separable DC value for each of the Y U and V components, effectively the average shade of each block.
The tricky bit is the buffering requirements, decoding it in the first place (although, from memory, the DC values are delta-coded) and relating YUV to RGB.
If you just want color, I'm just talking off the top of my head, but what if you'd go analogue, with an amplified (1V->5V) composite signal; only reading chrominance and luminance of a certain part of the image and not even storing the rest of it?
It would take lots of trial and error and calibrating until you're reading the correct pulses and get the ATMels A/D converter to read the right parts of the pulse and then trying /the right part of right scan line... but I think it could be done. Although, I don't remember how fast the composite carrier frequency is. Maybe too fast :-/
I don't remember how fast the composite carrier frequency is
It is about 4.5MHz.
Maybe too fast
By a long long way.
Interesting project. Here are my ideas regarding this. Not a full story but maybe something to get you going.
-
As everyone says, the memory is an issue. So why not attach an SD-card to Arduino. I have seen many people do that. Then you would have the memory to hold a jpeg?
-
A camera module, that is able to take snapshots in its own memory would be needed. Then read the compressed packages of the .jpeg file 100 or so bytes a time, as Arduino's serial buffers is only 128 bytes. Write these packages of around 100 bytes to the SD card attached.
-
At this point you would have the jpeg data as hex stored to the memory. Now I do not know enough of the structure of a jpeg, but I guess you would be able to start going through the data byte by byte to figure what the color values are numerically.
As I said, i really dont know much about jpeg and what it stores in its data. But if we can figure out the location of a certain pixel represented in the jpeg file (we know the resolution of the picture), we could take its numerical value for each color, compare that value to something else and make arduino to pass over the color or something.
Someone with some understanding of jpeg format could comment on this last part.
When it comes to Arduino's processing capabilities, we all have time don't we.
Someone with some understanding of jpeg format could comment on this last part.
The issue with jpeg is that the data is compressed, in a lossy fashion. That means that you have no idea where in the file the data for the 37th pixel in the 42nd row is. You can not just read some number of bytes and expect that those bytes correspond to n rows or n columns of pixels.
The SD card idea holds no value I'm afraid.
The memory restriction in question is a memory problem, not a storage space problem.
Storage space is fairly easy to solve, theres I2C EEPROM, flash and SD cards that you mentioned (I'm sure there are even more solutions)... but it gets hard to give the chip extra memory. Though I do believe I've read on the forum.. somewhere, it is possible to extend the memory on a mega?
I have a feeling it'd be hard, and not really worth the trouble compared to simply using a 2nd chip, but still...
That means that you have no idea where in the file the data for the 37th pixel in the 42nd row is.
We could go around the whole issue by taking a RAW snapshot. The problem with that is, at least for my camera module uCam-TTL by 4d Systems, the module seems to feed all of the raw data just straight over to the Arduino, which overflows the serial buffer.
It would be fairly simple to work with the RAW file. Any ideas how to avoid the overflow? Its funny how they say in the data sheet of the camera module:
As the transmission of an uncompressed (RAW) image does not require the package mode, it is not
necessary to set the package size for an uncompressed image. All of the pixel data for the RAW image will
be sent continuously until completion.
Though I do believe I've read on the forum.. somewhere, it is possible to extend the memory on a mega?
That would still be pretty a.w.e.s.o.m-o :o What about serial buffer, would it be possible to set that higher too. 128 bytes is not enough in all uses.
What about serial buffer, would it be possible to set that higher too. 128 bytes is not enough in all uses.
Yes, it is possible to change the serial buffer size. However a serial buffer of 128 characters gives a good balance between memory utilization and potential data loss. If you need a larger buffer, that is a good indication that you need to be paying more attention to the serial data that is incoming, and removing it from the buffer faster.
And, of course, that is the problem with reading data from a camera. There is usually no place to put the data fast enough to read all of it before some starts to be lost.
Even if you could store the whole image in memory, for a video camera, there would be another frame of data arriving before you got done dealing with the last frame.