求助:摄像头OV2640驱动一直出错,无法通过验证-Arduino中文社区 - Powered by Discuz!

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 8045|回复: 15

[未解决] 求助:摄像头OV2640驱动一直出错,无法通过验证

[复制链接]
发表于 2020-3-21 09:26 | 显示全部楼层 |阅读模式
21.jpg
 楼主| 发表于 2020-3-21 09:27 | 显示全部楼层
出错信息如下:


[mw_shl_code=arduino,true]Arduino:1.8.12 (Windows 10), 开发板:“Sipeed Maixduino Board, Default, 400MHz CPU Clock Frequency, 1.5 Mbps, Default”

sketch_mar21a:7:15: error: cannot declare variable ‘camera’ to be of abstract type ‘Sipeed_OV2640’
Sipeed_OV2640 camera(FRAMESIZE_QVGA, PIXFORMAT_RGB565);
~~
In file included from C:\Users\Eagler8\Documents\Arduino\sketch_mar21a\sketch_mar21a.ino:1:
C:\Users\Eagler88\AppData\Local\Arduino15\packages\Maixduino\hardware\k210\0.3.11\libraries\Sipeed_OV2640\src/Sipeed_OV2640.h:36:7: note: because the following virtual functions are pure within ‘Sipeed_OV2640’:
class Sipeed_OV2640 : public Camera{
~~~~~~~~~
In file included from C:\Users\Eagler88\AppData\Local\Arduino15\packages\Maixduino\hardware\k210\0.3.11\libraries\Sipeed_OV2640\src/Sipeed_OV2640.h:4,
from C:\Users\Eagler88\Documents\Arduino\sketch_mar21a\sketch_mar21a.ino:1:
C:\Users\Eagler88\AppData\Local\Arduino15\packages\Maixduino\hardware\k210\0.3.11\libraries\Camera\src/Camera.h:79:18: note: ‘virtual void Camera::setRotation(uint8_t)’
virtual void setRotation(uint8_t rotation) = 0;
~~~~~~~
“Adafruit_GFX.h” 对应多个库
已使用: C:\Users\Eagler88\Documents\Arduino\libraries\Adafruit_GFX_Library
未使用:C:\Users\Eagler88\Documents\Arduino\libraries\arduino_956473
未使用:C:\Users\Eagler88\AppData\Local\Arduino15\packages\Maixduino\hardware\k210\0.3.11\libraries\Adafruit-GFX-Library
exit status 1
cannot declare variable ‘camera’ to be of abstract type ‘Sipeed_OV2640’

在文件 -> 首选项开启
“编译过程中显示详细输出”选项
这份报告会包含更多信息。[/mw_shl_code]
 楼主| 发表于 2020-3-21 09:28 | 显示全部楼层
程序

[mw_shl_code=arduino,true]#include <Sipeed_OV2640.h>
#include <Sipeed_ST7789.h>

SPIClass spi(SPI0); // MUST be SPI0 for Maix series on board LCD
Sipeed_ST7789 lcd(320, 240, spi);

Sipeed_OV2640 camera(FRAMESIZE_QVGA, PIXFORMAT_RGB565);

void setup()
{
Serial.begin(115200);
lcd.begin(15000000, COLOR_RED);
if(!camera.begin())
Serial.printf(“camera init fail\n”);
else
Serial.printf(“camera init success\n”);
camera.run(true);
}

void loop()
{
uint8_timg = camera.snapshot();
if(img == nullptr || img==0)
Serial.printf(“snap fail\n”);
else
lcd.drawImage(0, 0, camera.width(), camera.height(), (uint16_t)img);
}
[/mw_shl_code]
 楼主| 发表于 2020-3-21 09:29 | 显示全部楼层
本帖最后由 eagler8 于 2020-3-21 09:31 编辑

附录:完整的<Sipeed_OV2640.h>库文件

[mw_shl_code=arduino,true]#ifndef __SIPEED_OV2640_H
#define __SIPEED_OV2640_H

#include “Camera.h”

#define OV9650_ID (0×96)
#define OV2640_ID (0×26)
#define OV7725_ID (0×77)
#define MT9V034_ID (0×13)
#define LEPTON_ID (0×54)
#define OV_CHIP_ID (0×0A)
#define ON_CHIP_ID (0×00)
#define GC0328_ID (0×9d)
#define GC0328_ADDR (0×42)

typedef enum {
GAINCEILING_2X,
GAINCEILING_4X,
GAINCEILING_8X,
GAINCEILING_16X,
GAINCEILING_32X,
GAINCEILING_64X,
GAINCEILING_128X,
} gainceiling_t;

typedef enum {
FRAMERATE_2FPS =0×9F,
FRAMERATE_8FPS =0×87,
FRAMERATE_15FPS=0×83,
FRAMERATE_30FPS=0×81,
FRAMERATE_60FPS=0×80,
} framerate_t;

class Sipeed_OV2640 : public Camera{

public:
Sipeed_OV2640(framesize_t frameSize = FRAMESIZE_QVGA, pixformat_t pixFormat = PIXFORMAT_RGB565);
Sipeed_OV2640(uint16_t width, uint16_t height, pixformat_t pixFormat = PIXFORMAT_RGB565);
Sipeed_OV2640();


virtual bool begin();
virtual void end();
bool reset();
bool setPixFormat(pixformat_t pixFormat);
bool setFrameSize(framesize_t frameSize);
virtual bool run(bool run);
virtual int id();
/**
* @return pixels
*         If pixels format is RGB565: return RGB565 pixels with every uint16_t one pixel, e.g. RED: 0xF800
*/
virtual uint8_t* snapshot();
virtual uint16_t* getRGB565(){ return (uint16_t*)_dataBuffer; };
virtual uint8_t* getRGB888(){ return _aiBuffer; };
virtual void setRotation(uint8_t rotation);
virtual void setInvert(bool invert);
private:
uint8_t* _dataBuffer; // put RGB565 data
uint8_t* _aiBuffer; // put RGB888 data
uint8_t _resetPoliraty; // reset poliraty flag
uint8_t _pwdnPoliraty; // PWDN poliraty flag
uint8_t _slaveAddr; // camera address
uint8_t _id;
uint32_t _freq;

int dvpInit(uint32_t freq = 24000000);
int dvpInitIrq();

int cambus_scan();
int cambus_read_id(uint8_t addr,uint16_t *manuf_id, uint16_t *device_id);
int cambus_scan_gc0328(void);
int cambus_readb(uint8_t slv_addr, uint8_t reg_addr, uint8_t *reg_data);
int cambus_writeb(uint8_t slv_addr, uint8_t reg_addr, uint8_t reg_data);
int cambus_readw(uint8_t slv_addr, uint8_t reg_addr, uint16_t *reg_data);
int cambus_writew(uint8_t slv_addr, uint8_t reg_addr, uint16_t reg_data);
int cambus_readw2(uint8_t slv_addr, uint16_t reg_addr, uint16_t *reg_data);
int cambus_writew2(uint8_t slv_addr, uint16_t reg_addr, uint16_t reg_data);

int sensor_ov_detect();
int sensro_gc_detect();

int ov2640_reset();
int ov2640_read_reg(uint8_t reg_addr);
int ov2640_write_reg(uint8_t reg_addr, uint8_t reg_data);

int ov2640_set_pixformat(pixformat_t pixformat);
int ov2640_set_framesize(framesize_t framesize);
int ov2640_set_framerate(framerate_t framerate);
int ov2640_set_contrast(int level);
int ov2640_set_brightness(int level);
int ov2640_set_saturation(int level);
int ov2640_set_gainceiling( gainceiling_t gainceiling);
int ov2640_set_quality(int qs);
int ov2640_set_colorbar(int enable);
int ov2640_set_auto_gain(int enable, float gain_db, float gain_db_ceiling);
int ov2640_get_gain_db(float *gain_db);
int ov2640_set_auto_exposure(int enable, int exposure_us);
int ov2640_get_exposure_us(int *exposure_us);
int ov2640_set_auto_whitebal(int enable, float r_gain_db, float g_gain_db, float b_gain_db);
int ov2640_get_rgb_gain_db(float *r_gain_db, float *g_gain_db, float *b_gain_db);
int ov2640_set_hmirror(int enable);
int ov2640_set_vflip(int enable);
int sensor_snapshot( );
int reverse_u32pixel(uint32_t* addr,uint32_t length);
};

#endif[/mw_shl_code]




 楼主| 发表于 2020-3-21 09:32 | 显示全部楼层
OV2640摄像头


0 (5).jpg
发表于 2020-3-21 09:33 | 显示全部楼层
Camera.h库不存在
 楼主| 发表于 2020-3-21 09:44 | 显示全部楼层

这个库有的,是安装Maixduino板子时打包的
25.jpg
 楼主| 发表于 2020-3-21 09:51 | 显示全部楼层

这个库,需要再拷贝一次吗?
发表于 2020-3-21 13:33 | 显示全部楼层
eagler8 发表于 2020-3-21 09:51
这个库,需要再拷贝一次吗?

具体的没实践过唉,您可以尝试一下
 楼主| 发表于 2020-3-21 15:15 | 显示全部楼层
Creeper666 发表于 2020-3-21 13:33
具体的没实践过唉,您可以尝试一下

都试过了,还是过不了验证
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|手机版|Arduino中文社区

GMT+8, 2024-11-28 11:56 , Processed in 0.081298 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表