3D point cloud scanner with OV7670 camera and line laser.
Dependencies: ADXL345_I2C_ HMC5843_ OV7670_ok SDFileSystem ST7735_TFT Servo mbed
Fork of OV7670_edm_full by
3D point cloud scanner with OV7670 FIFO camera and line laser. I take the brightest pixels in an image, I measure their horizontal displacement to deduce a depth value, and I generate XYZ coordinates. The camera is rotating, and I know the angle, so I can map 3D space in cylindrical coordinates. The home of the project is http://angelomottolese.eu.ai/sitoScanner.html
Diff: main.cpp
- Revision:
- 0:aabbf2286bf2
- Child:
- 1:c98598814170
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Mar 27 19:10:18 2012 +0000 @@ -0,0 +1,106 @@ +// +// OV7670 + FIFO AL422B camera board test +// +#include "mbed.h" +#include "ov7670.h" +#include "stdio.h" +#include "SPI_TFT.h" +#include "string" +#include "Arial12x12.h" +#include "Arial24x23.h" +#include "Arial28x28.h" +#include "font_big.h" + +OV7670 camera( + p28,p27, // SDA,SCL(I2C / SCCB) + p21,p22,p20, // VSYNC,HREF,WEN(FIFO) + p19,p18,p17,p16,p15,p14,p13,p12, // D7-D0 + p23,p24,p25) ; // RRST,OE,RCLK + +// the TFT is connected to SPI pin 5-7 +SPI_TFT TFT(p5, p6, p7, p8, p9,"TFT"); // mosi, miso, sclk, cs, reset + +Serial pc(USBTX,USBRX); + +#define SIZEX (160) +#define SIZEY (120) + +int main() { + + // Set up the TFT + TFT.claim(stdout); // Send stdout to the TFT display + TFT.background(Black); // Set background to black + TFT.foreground(White); // Set chars to white + TFT.cls(); // Clear the screen + TFT.set_font((unsigned char*) Arial12x12); // Select the font + TFT.set_orientation(3); // Select orientation + + printf("Testing..."); + + int i ; + pc.baud(115200) ; + pc.printf("Camera resetting..\r\n") ; + + camera.Reset() ; + + pc.printf("Before Init...\r\n") ; + pc.printf("AD : +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F") ; + for (i=0; i<OV7670_REGMAX; i++) { + int data ; + data = camera.ReadReg(i) ; // READ REG + if ((i & 0x0F) == 0) { + pc.printf("\r\n%02X : ",i) ; + } + pc.printf("%02X ",data) ; + } + pc.printf("\r\n") ; + + camera.InitQQVGA() ; + + pc.printf("After Init...\r\n") ; + pc.printf("AD : +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F") ; + for (i=0; i<OV7670_REGMAX; i++) { + int data ; + data = camera.ReadReg(i) ; // READ REG + if ((i & 0x0F) == 0) { + pc.printf("\r\n%02X : ",i) ; + } + pc.printf("%02X ",data) ; + } + pc.printf("\r\n") ; + + // CAPTURE and SEND LOOP + while (1) { + pc.printf("Hit Any Key to send RGBx160x120 Capture Data.\r\n") ; + while (!pc.readable()) ; + pc.getc() ; + camera.CaptureNext() ; + while (camera.CaptureDone() == false) ; + pc.printf("*\r\n") ; + camera.ReadStart() ; + i = 0 ; + int colour; + + for (int y = 0; y < SIZEY; y++) { + int r,g,b,d1,d2 ; + for (int x = 0; x < SIZEX; x++) { + d1 = camera.ReadOneByte() ; // upper nibble is XXX , lower nibble is B + d2 = camera.ReadOneByte() ; // upper nibble is G , lower nibble is R + b = (d1 & 0x0F) ; + g = (d2 & 0xF0) >> 4 ; + r = (d2 & 0x0F) ; + pc.printf ("%1X%1X%1X",r,g,b) ; + + // Calculate colour + colour = r << 11; + colour += g << 5; + colour += b; + + // Display pixel on TFT screen + TFT.pixel(x, y, colour); + } + pc.printf("\r\n") ; + } + camera.ReadStop() ; + } +}