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
main.cpp
- Committer:
- rulla
- Date:
- 2016-11-16
- Revision:
- 2:4ebec58ffaca
- Parent:
- 1:c98598814170
- Child:
- 3:9244869157bd
File content as of revision 2:4ebec58ffaca:
// // OV7670 + FIFO AL422B camera board test // #include "mbed.h" #include "OV7670.h" #include "ST7735_TFT.h" OV7670 cam( p28,p27, // SDA,SCL(I2C / SCCB) p23,NC,p25, // VSYNC,HREF,WEN(FIFO) Port0,0x07878000, p26,p29,p30) ; // RRST,OE,RCLK ST7735_TFT TFT(p5, p6, p7, p8, p9, p10,"TFT"); // mosi, miso, sclk, cs, rs, reset Serial pc(USBTX,USBRX); #define SIZEX (160) #define SIZEY (120) #define SIZE SIZEX*SIZEY //unsigned char bank0[SIZE]; //unsigned char *bank1 = (unsigned char *)(0x2007C000); unsigned char bank0,bank1,bank2,bank3; int main() { pc.baud(115200); // 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_orientation(3); // Select orientation */ TFT.set_orientation(3); cam.Reset() ; pc.printf("\r\nDefault\r\n"); int i; char data1[OV7670_REGMAX],data2[OV7670_REGMAX]; for (i=0;i<OV7670_REGMAX;i++) { data1[i]=cam.ReadReg(i); // READ REG //if ((i & 0x0F) == 0) pc.printf("\r\n%02X : ",i); //pc.printf("Add %02X = %02X ,",i,data); } cam.InitQQVGA() ; pc.printf("\r\nDefault\r\n"); for (i=0;i<OV7670_REGMAX;i++) { data2[i]=cam.ReadReg(i); // READ REG // if ((i & 0x0F) == 0) pc.printf("\r\n%02X : ",i); if(data1[i]!=data2[i]) pc.printf("Add %02X = %02X/%02X ,",i,data1[i],data2[i]); } int j=0; //while(j<15){ while(1){ // Kick things off by capturing an image cam.CaptureNext() ; while (cam.CaptureDone()==0) ; pc.printf("Done %d\n",cam.CaptureDone()); int x=0,y=0, r=0,g=0,b=0,colour; char rr,gg,bb; // Start reading in the image data from the camera hardware buffer cam.ReadStart(); for (int i = 0; i < SIZE; i++) { //if(i==0) cam.ReadOneByte(); bank0 = cam.ReadOneByte(); bank1 = cam.ReadOneByte(); //bank1=0; //RGB rr=(bank1 & 0x1f) ; gg= ((bank0<<3) & 0x38) | ((bank1>>5)&0x07); b=(bank0 & 0xf8)>>3 ; //444 /* b = (bank0 & 0x0F) ; g = (bank1 & 0xF0) >> 4 ; r = (bank1 & 0x0F) ; */ colour = ((r<<11)+(g<<5)+b); if(i%200==0) pc.printf("RGB %d %d %d, B0 %d, B1 %d\n",rr,gg,b,bank0,bank1); // TFT.pixel(x,y,colour); TFT.pixel(x,y,rr); x++; if(i%SIZEX==0) x=0,y++; } cam.ReadStop() ; //TFT.Bitmap(0,0,160,60,bank1); //TFT.Bitmap(0,60,160,60,bank0); x=0;y=0; /* for (int i = 0; i <= SIZE; i++) { if(i==SIZEX) x=0,y++; r=(bank0[i]&0xF8)>>3; // TFT.pixel(x,y,bank0[i]); } */ //j++; } }