Merge pull request #110 from mikljohansson/add-binocular-camera-support

Add binocular camera support
This commit is contained in:
Neucrack
2021-05-31 10:02:52 +08:00
committed by GitHub
3 changed files with 670 additions and 554 deletions

View File

@@ -0,0 +1,35 @@
#include <Sipeed_GC0328.h>
#include <Sipeed_ST7789.h>
SPIClass spi_(SPI0); // MUST be SPI0 for Maix series on board LCD
Sipeed_ST7789 lcd(320, 240, spi_);
Sipeed_GC0328 camera(FRAMESIZE_QVGA, PIXFORMAT_RGB565, &Wire);
// Use left camera if true, right camera when true
bool leftCamera = true;
void setup()
{
Serial.begin(115200);
lcd.begin(15000000, COLOR_RED);
// Start camera in binocular mode
if(!camera.begin(true))
Serial.printf("camera init fail\n");
else
Serial.printf("camera init success\n");
camera.run(true);
}
void loop()
{
// Switch left/right cameras
camera.shutdown(leftCamera);
leftCamera = !leftCamera;
uint8_t*img = camera.snapshot();
if(img == nullptr || img==0)
Serial.printf("snap fail\r\n");
else
lcd.drawImage(0, 0, camera.width(), camera.height(), (uint16_t*)img);
}

File diff suppressed because it is too large Load Diff

View File

@@ -34,8 +34,10 @@ public:
~Sipeed_GC0328();
virtual bool begin();
bool begin(bool binocular);
virtual void end();
bool reset();
bool reset(bool binocular = false);
void debug(bool enable);
bool setPixFormat(pixformat_t pixFormat);
bool setFrameSize(framesize_t frameSize);
virtual bool run(bool run);
@@ -47,8 +49,10 @@ public:
virtual uint8_t* snapshot();
virtual uint16_t* getRGB565(){ return (uint16_t*)_dataBuffer; };
virtual uint8_t* getRGB888(){ return _aiBuffer; };
virtual void setRotaion(uint8_t rotation);
virtual void setRotation(uint8_t rotation);
virtual void setInvert(bool invert);
virtual void shutdown(bool enable);
void setFlip(bool flip);
private:
uint8_t* _dataBuffer; // put RGB565 data
@@ -61,6 +65,7 @@ private:
TwoWire *_i2c; // replace sccb
bool _vflip;
bool _hmirror;
bool _debug;
int dvpInit(uint32_t freq = 14000000);
int dvpInitIrq();