Good info or project about blob detection, line following or similar using camera and microcontroller

tnx I thought it was me who just was too tired to find DELETE!

.

Hi Telefox, another good

Hi Telefox, another good idea which I was unaware of: I can bring in the OpenCV to my embedded system? Now that is something I will dig into tonight! I indeed develop in C.

The heavy math Iā€™ve run intoā€¦ thats not for me. I found tons of impressive 4-page papers of universities and I found 2 complete books in pdf about Robot Vision. As soon as the first Matrix calculations hit my head I felt at school again. That stuff I preserve for work in my free time I like to get my hands dirty and be as practical as possible.

I even found a book containing every imaginable vision/image processing algorithm there is, in C language. But here I stumbled over the problem not knowhing what to do with this algorythm. I will dig into the info you gave me and that of Birdmum. Hopefully I find some code in whatever language which I will dig into deep and translate to my system

There used to be an open

There used to be an open source AVR Cam project, which used a camera that would send frame grabs to an on-board Mega 8 for processing and the microcontroller would talk with other hosts over serial (either computer or microcontroller). The output would be coordinates of the bounding boxes for the color the camera module is looking for. That was done on the camera module.

On your own microcontroller, having the bounding box, lets you determine the size of the blob and the center point coordinates of that box. Then, you can determine how far off-center the box is in the frame and move the robot or the camera (mouted on a head) to center the blob in the frame. If you know the height of the camera, the angle it is facing down to have the blob centered on the frame, you can calculate the distance to the object (represented by the blob) if the object is sitting on the floor, of course.

I have such an AVRcam module, but I havenā€™t been able with my limited programming knowledge to make good use of it. I also have an Arduino library, but it is limited and works awfully slow (slower than the camera can actually work).Ā 

Oh, it seems that the projectā€™s page is still active, so you can take a look at the provided embeded code:

http://www.jrobot.net/Projects/AVRcam.html

another discution on LMR thread:Ā https://www.robotshop.com/letsmakerobots/node/23611

and the AVRcam Arduino library:Ā http://www.societyofrobots.com/robotforum/index.php?topic=2679.0

oh, and I also found a resurrection of the AVRcam here:Ā http://www.bot-thoughts.com/2012/06/avrcam-resurrection.html

huh, there also seems to be an ArduCam project:Ā http://www.arducam.com/

Man, lots of options hereā€¦ let us know what you do!

What a big coincidence!

Hi Ro-Bot-X

This is a big coincidence! Yesterday evening I was tracking down the lead I got from Birdmum and Telefox.

Telefox told me about openCV on embedded systems. When looking for that it quickly became clear that this would be a new struggle or challange (it depends how to look at it) because I found no one who had some compact embedded code availble (but I keep looking). While I searched the internet I found a post about Jrobot and checked it out. First impression is this is exactly what I need. So I already downloaded his AVR code and will take a look at it the coming days (its a big project).

I surely let you know what I do, I plan to write something about it on LMR as well. It frustrated me that there is no project or post that guides you through like a tutorial. I know its a lot of work thats probably why and the ones understanding how this all works might not be able at all to 100% put it on paper.

I will start with Jrobot and will go through the rest of your links as well. Man am I glad I put this post out, finally Iā€™m making progress again

Nice, Iā€™ve heard about the

Nice, Iā€™ve heard about the AVR Cam many times but I didnā€™t realise it was open source.

If you can get the AVR Cam code up and running maybe you could look adding some more processing options - colour-based blob tracking is nice, but itā€™s not exactly robust in real world conditions. I sometimes develop computer vision programs for work so I can give you some help if you want to try out some basic pattern/object recognitionā€¦ could be the sort of thing you are looking for.

You are way ahead of me!

Haha TeleFox i just am starting to get the hang of this! I got wandered off the AVRcam because I checked the CMUcam as well, this one I heard about while looking into the other info.

I found an exact example of what I try to do as my ā€œhello worldā€ in image processing: find a color. Red in this example.

Its right here http://www.cmucam.org/attachments/download/328/mbot3d.zip

But Iā€™ll keep your offer in mind for sure, If you are developing your own vision programs you are my master!

Right now i would be extremely happy if I can follow the red colored object with my stm32-ov7670 combination. My end goal would be doing basic object detection indeed but that will probably not succeed with the STM32, I think I need a bigger gun for that

Follow up

Hi Guys

Iā€™m back again. Iā€™m stuck againā€¦

I was digging into this piece of code which was written to follow the reddest object it detected. I think I mentioned it here in the discussion, its from the CMUcam website. There I saw some pixel magic which made me test my camera to see if its colors were ok. So I grab a qqvga frame of pixels and for a specific pixel at x,y I show its value on the TFT screen and also I take it apart in RGB565 components R,G and B. Then what I saw keeps me puzzled for some time now.

Black is not black, it should give me 0x0000 or R=0,G=0,B=0. Instead I get R=2,G=4,B=2. And I have 2 boards with the same OV7670 camera (and same code loaded) with same results. Since then I tried everything I could think of to make Black BLACK aahā€¦ To no availā€¦ First I thought maybe some databits ā€œstickā€ or something but if I take random measurements I learned that every of the 16 bits becomes 1 or 0 at a time. Just not all 0ā€™s for Black. (The same goes for my white, its not decimal 65535 but 63000 something)

I tried whitebalance settings, black color corrections, R gain G gain B gain. Etc etc etc. Then just some OV7670 register settings from about 8 different sources which I collected during my searches. Does not change it.

I have seen some guys working with YuV getting the correct black values for their setup, that is decimal 0,128 for each pixel. I can not use this because my TFT is rgb565 and I have no code yet to pump it to a PC via the UART or something :frowning:

So I come to you once again, is there anybody on the forum that can explain this behaviour. It seems to me if black is not completely black then red is not entirely red, right? Soā€¦my setup+code is useles until I fix this? Right? Or not?

Ā 

Not robust indeed

Unless you have a pretty stable lighting environment itā€™s very erratic. I managed to get my AVRcam clone working a couple months ago but found it was too finicky for my uses. Slight differences in brightness was enough to make recognizing more than one color difficult at best.

I still have a few AVRcam

I still have a few AVRcam boards for the clone I designed awhile back if youā€™re interested. Theyā€™re not pefect but they do work. For one the MAX232 serial converter doesnā€™t work for some reason but it speaks TTL just fine. Who uses serialĀ theseĀ days anyways? lolĀ I was using the ubiquitous FT232Ā converter board for communications with my computer via USB. Worked great.

It was kind of difficult and more expensive to find theĀ C3088 board back then but theyā€™re more available now. I recommend aliexpress if ebay doesnā€™t have any listed. IIRC they were something like $50 with shipping back then but IĀ see they can be had for ~$30-40 now.

It took some time to figure out how to get the ATmega8 to work right but if you have difficulties I can offer advice, for sure.

If you want the naked board + switch I can sell you a set. What sayā€¦ $10 incl. S&H? Iā€™m able to provide pictures and whatnot if you like. The power switch I used was a unique modelĀ and it doesnā€™t seat 100% perfect due to my bad package design in eaglecad. It doesĀ work though (it just sits really high). Knock off a dollar if you donā€™t want it.

Or if you want you can buy the assembled cam module I have. I would have to tally up what it cost me but I would be willing to let it go for that amount plus shipping if youā€™re interested. I have a few unassembled sets so it wouldnā€™t break my heart :slight_smile:

The cam is adequate for tracking one color butĀ they areĀ fussy about lighting and such. Tracking more than one color was a task in varying lighting conditions. You have to set the color ranges that itā€™s looking for and sometimes they overlap. Yellow in the dark looks a lot like orange in reallyĀ bright light, for instance.Ā Someone has a linefollower on this board that uses an AVRcam and it seems to work well in some applications.

Hey JaxIt seems you have

Hey Jax

It seems you have sort of the same issues with a totally different camera. Tnx for your offer, its a good offer but I stick to the ov7670 for a while. Not only because I bought 2 (with fifo) and 2 without but also the amount of effort/time it took me to get it to workā€¦iā€™m determined to get this to work. Or live with its limitations. Maybe I do what bdk6 suggests. If I just ignore the noise error and put some boundaries then it might work.

I also have a camera from 4d systems, that one was supposed to be simple via the UART but somehow the camera was broken all along. Here I spent also many hours and in the end I got the 60 dollars back I paid. Its not even the money thats worst, its the time!!

Maybe when Iā€™m ready to flush 2x OV7670 down the toilet Iā€™ll dig into your AVR cam clone :slight_smile:

Ā 

Donā€™t flush it! :smiley:

It sounds like youā€™re on your way with the 7670. Iā€™m excited to see success on your side. You have some big brains backing you and I see victory in your camp sometime in the future.

The offer is standing if you find you would like to tinker with an AVRcam after all. The bits arenā€™t going anywhere :slight_smile:

Hi JAXHaha no I wonā€™t flush

Hi JAX

Haha no I wonā€™t flush it, had a good night sleep so back to business tonight after work. Iā€™m an electronics developer so used to put my teeth in stuff :slight_smile:

Iā€™m going to let this thing do what I want. And if I get it right I plan to write an article about it and put it somewhere here on LMR. As we speak there are still people buying this cheap tempting camera and end up confused. The time it took me to get the SCCB interface working, pfff and then to get data out of it. I even had to route the wiring in a specific way: power supply + databus wires bundled together and all others from sccm/vsync line etc in another bundle and keep it seperated because they interfere. It results in some spacy infrared-like pictures on the TFT (like Predator haha). Not so handy if you are debugging and try to find out what settings work for my TFT and STM32.

Iā€™ll keep u posted

oh I forgot!

ā€¦,.I also have a raspberry pi with the new Omnivision HD camera waiting for me to unpack. So if this totally flops then Iā€™ll get into that. But I was waiting actually for some code/library/projects to pop up, I figured maybe on the Pi some other people can start it and I hop in later when I see some successful projects :slight_smile:

YES! Black is black!!!

Hey all,

Making progress here, this might sound stupid but for me after many many hours of struggling Iā€™m very happy that at least my black is BLACK now! It seems one of the 174 registers I use (borrowed from the internet) and controls the RGB565 mode has another niceĀ  feature. ITs called data format - output full range enable.

My register setting was 00 for the 2 involved bits. This means the range is limited from 0x10 to 0xF0. I now changed it so that the range is 0x00 to 0xFF again. And now if I cover the lens: ALL 0ā€™S!

One thing is for sure I will never buy those cheap cameraā€™s with the 100% sort-it-out-yourself level again.

Clipboard01.jpg

Good find there!Strange that

Good find there!

Strange that the output range was limited by default, I guess the 0x10 to 0xF0 range is a better fit for some other image format.

Tnx!

Tnx! The default is C0 but these register settings are from the internet and are somewhat messy. During my search I also encountered several double register-settings. First the set it to a value and later on the same register to different values. I guess everybody is struggling for a long time with these settings and so you get some messy files on the internet. Who traces back his steps and cleans up :wink:

I think its a strange setting though, especially that you can use it with RGB565, this has already the limit of 5 bits for R, 6 for G and 5 for B so limit it more is not so useful.

I still got 1 to tackle: white is not white yet. Its far from that. But now Iā€™ve seen that I can fix this with registersettings Iā€™ll keep going. Got a nice calibration method where a white spot is drawn on the TFT where the specific pixel is I measure (I only take 1 pixel of the sensor and ā€œpointā€ it to a color, the data I compare with an RGB565 color picker)

But soonā€¦ I will be ready to go do something with the camera instead of debugging

Thank you all

Thank you all for coming up with ideas about where to find image processing info. Via your links I ended up on this site:

http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/robot/blob_detection/

So I did not directly find my lead to go on but there was so many good info that I found a good site that explains a simple/intermediate image processing task.

While I write this I am looking with a big smile at my STM32 TFT screen. On it is a moving image of my camera, it is tracking (for now, for demo purpose) a bright light source where R,G and B are > decimal 245. All pixels that have R,G and B components > 245 are white on my TFT, the rest is black. And right in the middle of those pixels (the blob) is a nice red cross. I CAN DETECT A COLOR BLOB AND ITS CENTER, whahoe! Now my future robots will get much more interesting.

Next will be that 2 servo motors for pan and tilt are mounted, they will move the camera or my robot to have the blob right in the middle of the camera view. Ultimately the blob will be a red ball or something, not a bright light. Makes it a little more challenging. I still got many questions like for example how to track multiple blobs. But thats for later.

If I have this blob following working up and running its time for a little article about it, maybe I can help others on the forum to do some basic image processing stuff!

sorry for my mess on the forum

ā€¦I got no clue how to reply correctly to a post so the order of my replies is chaos :frowning:

Your replies seem to follow a logical order to me.

Are you maybe seeing newer posts first? There is the option to show newer posts first vs older first. I canā€™t stand the newest first. It makes following things difficult. :slight_smile:

For reference the comment layout options are between your original post and the forum responses. They are labeled comment viewing options.

That was it

I had indeed selected view NEW comment first.

But what I tried to do is give a general reply, to my own and first post, not as a reply to a sub-post. On my PC my newest comment is now between the first post and the one about black=black, I wanted it after all the problems were solved / as last post since I started

Seems more difficult now that image processing!!