Machine vision system using an FGPA, VHDL coding, an omnivision OV7670 camera and an ILI9325 based TFT

Knipsel.JPG

Hi all, Over the past months I've been coding hard in VHDL language to develop my own Vision system!

Video here https://youtu.be/5gtSyW1ybTQ

I was fed up with 2-5 frames per second I got with for example an AVR, Arduino or even an ARM M3 series when image processing. Having some experience with VHDL and FPGA's via my work I thought: it must be possible to have real-time 30 fps image processing in color? Yes it is possible! It's all based on a Xilinx Spartan-6 board with an XC6SLX9 FPGA on-board. It's not really suitable yet to use on a robot or something. But it prooves its possible and it looks quite cool I think. I wrote VHDL to: -initialise an ILI9325 based 2.4" TFT screen and show QVGA images in RGB565 format on it -initialise an Omnivision OV7670 camera via its SCCB interface and get it to pump out 30 fps in RGB565 format -code to write to and read from an Averlogic AL422B FIFO memory (mine is not built to the OV7670 like many available on Ebay, I have a plain OV7670 and developed a PCB to stack on top of the headers of my FPGA board) -code to do template matching (compare the datastream from the camera with the datastream from FIFO memory where 1 frame is stored) -code to do image tresholding (no FIFO required) The images are stored with the push of a button from the OV7670 to the AL422B Fifo The movie shows the template matching variant. Matching pixels I show either black or as they come from the camera view. Differing/non-matching I make either black or white whichever works in which situation. I was planning to use this to check printed circuit boards for wrong or missing components but its too sensitive right now to do that (when the "reference" board is removed from camera view and the board-under-test is placed back it must be aligned to the micrometer like the reference board otherwise the whole TFT screen lights up like a christmas tree with false detections / differing pixels..... It could be used as a movement detection system in your house! I hope you like what you see!

Hi Bajdi

Hi Bajdi

Tnx! I have a pixy, works better then my system but I wanted to do it from scratch and as fast as possible :slight_smile:

LMR gives me a hard time with embedding the video, so I put the link in the text now. And its here as well https://youtu.be/5gtSyW1ybTQ

Cheers!

Vision System

Could you post some details of the physical implementation? I am about to start a video project with similar components.

Hi ggallant

Hi,

I’m thinking hard wether or not to give all the sourcecode. It has cost me lots of time, when its out of my hands it is gone forever so let me think about that…

Here is my toplevel of the design, I made this one as a schematic instead of as VHDL. It gives some more overview.

You can see all my VHDL blocks. All the vision blocks use a state machine. The bus connection AL422B- OV7670 is externally connected thats why you dont see something like AL422B_DATA_OUT. After powerup all blocks wait 100mS as a power on reset. Then it all starts and everything is at 25MHz which is 1/2 of my FPGA board clock frequency (see the divider block on the toplevel). I did this since the OV7670 is guaranteed until 48MHz so 50MHz is too fast (I tested it, it does not work).

The ILI9325 is configured first in RGB565 mode 16bit. When its done it signals to the ov7670_init_sccb and then the OV7670 is configured too. When that is done it signals to AL422B_WRITE that its done and 1 frame could be written to the FIFO.

This is not required, the template matching block in the mean time passes through the normal camera view to the ILI9325 driver which puts it on the TFT. 

When my board button SW2 is pushed 1 frame gets written to the FIFO, the WRITE block signals to the read block that data is available and this block starts reading and feed this to the TEMPLATE MATCH block. Then either template matched mode(s) or normal cam view or the data from memory can be put on the TFT (toggled by SW1)

Now if you want to program this yourself: I used mostly state machines and I took the various examples in C code as starting point (widely available on the internet)

Knipsel.jpg

 

hmm picture too small…again!