ov5640分辨率调整傻瓜攻略【verilog版】

文章介绍了如何使用Verilog对OV5640摄像头的分辨率进行简单调整,通过修改特定的24位数据字段来设置水平和垂直宽度。提供了将分辨率从默认的2592x1944调整到640x480的示例,详细解释了如何将十进制分辨率转换为十六进制并应用到代码中。建议初学者查阅OV5640的数据手册以获取更多信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

某verilog菜狗最近开始研究摄像头了,查了很多资料说的都太高级了,这里记录一下一些非常简单的傻瓜都能看懂的ov5640调整分辨率的方式

在你的代码中找到如下字段(长得差不多就行),主要是看后面的24位数据。

在这24位数据里面,其中前16位为你需要调整的参数的地址(不同参数的具体地址可以通过查询ov5640的datasheet得到,在这里我们只列出需要调整的参数地址),后8位为你需要调整的数值。

        10'd223: lut_data <= {8'h78 , 24'h38080A};//水平宽度高字节[11:8],默认值为0A
        10'd224: lut_data <= {8'h78 , 24'h380920};//水平宽度低字节[7:0],默认值为20
        10'd225: lut_data <= {8'h78 , 24'h380a07};//垂直高度高字节[10:8],默认值为07
        10'd226: lut_data <= {8'h78
R58点亮ov5640.txt 开发板:深圳市索智科技有限公司SC3817R开发板,全志R16(CPU:Quad-Core Cortex-A7 CPU) http://www.allwinnertech.com/clq/r/R16.html 全志官网R16的简介 android4.4.2/linux3.4.39 2016/7/18 16:38 1、配置ov5640在android层配置的分辨率为vga(预览/拍照/录像) 注意:系统自带的快拍APP就在这里查找分辨率参数发送到camera的HAL层。 这里得分辨率设置为:640x480 驱动里面搜索可以设置为:2592x1936, 2048x1536, 1600x1200, 1280x960, 1280x960, 1024x768, 1920x1080 ,1280x720, 800x600, 640x480 R:\wyb\wen_ov5640_r16\android\device\softwinner\astar-evb20\configs\camera.cfg ;------------------------------------------------------------------------------- ; 用于camera的配置 ; ; 采用格式: ; key = key_value ; 注意: 每个key需要顶格写; ; key_value紧跟着key后面的等号后面, 位于同一行中; ; key_value限制大小为256字节以内; ; ;------------------------------------------------------------------------------- ;------------------------------------------------------------------------------- ; exif information of "make" and "model" ;------------------------------------------------------------------------------- key_camera_exif_make = MAKE_A31S key_camera_exif_model = MODEL_A31ST ;------------------------------------------------------------------------------- ; 1 for single camera, 2 for double camera ;------------------------------------------------------------------------------- number_of_camera = 1 ;------------------------------------------------------------------------------- ; CAMERA_FACING_BACK ; gc0307 ov2640 ;------------------------------------------------------------------------------- camera_id = 0 ;------------------------------------------------------------------------------- ; 1 for CAMERA_FACING_FRONT ; 0 for CAMERA_FACING_BACK ;------------------------------------------------------------------------------- camera_facing = 0 ;------------------------------------------------------------------------------- ; 1 for camera without isp(using built-in isp of Axx) ; 0 for camera with isp ;------------------------------------------------------------------------------- use_builtin_isp = 0 ;------------------------------------------------------------------------------- ; camera orientation (0, 90, 180, 270) ;------------------------------------------------------------------------------- camera_orientation = 90 ;------------------------------------------------------------------------------- ; driver device name ;------------------------------------------------------------------------------- camera_device = /dev/video0 ;------------------------------------------------------------------------------- ; device id ; for two camera devices with one CSI ;------------------------------------------------------------------------------- device_id = 0 used_preview_size = 1 key_support_preview_size = 640x480 key_default_preview_size = 640x480 used_picture_size = 1 key_support_picture_size = 640x480 key_default_picture_size = 640x480 used_flash_mode = 0 key_support_flash_mode = on,off,auto key_default_flash_mode = on used_color_effect=0 key_support_color_effect = none,mono,negative,sepia,aqua key_default_color_effect = none used_frame_rate = 1 key_support_frame_rate = 10 key_default_frame_rate = 10 used_focus_mode = 0 key_support_focus_mode = auto,infinity,macro,fixed,continuous-video,continuous-picture key_default_focus_mode = auto used_scene_mode = 0 key_support_scene_mode = auto,portrait,landscape,night,night-portrait,theatre,beach,snow,sunset,steadyphoto,fireworks,sports,party,candlelight,barcode key_default_scene_mode = auto used_white_balance = 0 key_support_white_balance = auto,incandescent,fluorescent,warm-fluorescent,daylight,cloudy-daylight key_default_white_balance = auto used_exposure_compensation = 1 key_max_exposure_compensation = 3 key_min_exposure_compensation = -3 key_step_exposure_compensation = 1 key_default_exposure_compensation = 0 2、没有/dev/video1,只有/dev/video0 R:\wyb\wen_ov5640_r16\android\device\softwinner\astar-evb20\ueventd.sun8i.rc /dev/video0 0666 media media #/dev/video1 0666 media media 3、在init.rc(init.sun8i.rc)中加载ov5640.ko这个驱动模块。 R:\wyb\wen_ov5640_r16\android\device\softwinner\astar-evb20\init.sun8i.rc #csi module insmod /system/vendor/modules/videobuf-core.ko insmod /system/vendor/modules/videobuf-dma-contig.ko insmod /system/vendor/modules/cam_detect.ko #insmod /system/vendor/modules/actuator.ko #insmod /system/vendor/modules/ad5820_act.ko insmod /system/vendor/modules/cci.ko insmod /system/vendor/modules/vfe_os.ko insmod /system/vendor/modules/vfe_subdev.ko #insmod /system/vendor/modules/gc0307.ko #insmod /system/vendor/modules/ov2035.ko #insmod /system/vendor/modules/ov2640.ko insmod /system/vendor/modules/ov5640.ko insmod /system/vendor/modules/vfe_v4l2.ko 启动之后实际加载的摄像头的驱动模块: shell@astar-evb20:/ $ lsmod gt82x 9849 0 - Live 0x00000000 bma250 7848 0 - Live 0x00000000 sunxi_schw 12559 0 - Live 0x00000000 (O) rtl8150 9023 0 - Live 0x00000000 sunxi_keyboard 3021 0 - Live 0x00000000 sw_device 13916 0 - Live 0x00000000 vfe_v4l2 445444 1 - Live 0x00000000 ov5640 27129 0 - Live 0x00000000 vfe_subdev 4523 2 vfe_v4l2,ov5640, Live 0x00000000 vfe_os 3951 2 vfe_v4l2,vfe_subdev, Live 0x00000000 cci 21775 2 vfe_v4l2,ov5640, Live 0x00000000 videobuf_dma_contig 5567 1 vfe_v4l2, Live 0x00000000 videobuf_core 16520 2 vfe_v4l2,videobuf_dma_contig, Live 0x00000000 bcm_btlpm 7442 0 - Live 0x00000000 bcmdhd 629907 0 - Live 0x00000000 mali 209314 20 - Live 0x00000000 (O) lcd 41263 0 - Live 0x00000000 disp 992816 8 mali,lcd, Live 0x00000000 nand 282774 0 - Live 0x00000000 (O) shell@astar-evb20:/ $ 4、驱动程序:ov2640.c及其V4L2的适配层。 配置ov2640.c的编译选项,只需要修改device目录中的Makefile打开ov5640(默认打开)即可: R:\wyb\wen_ov5640_r16\lichee\linux-3.4\drivers\media\video\sunxi-vfe\device\ov5640.c R:\wyb\wen_ov5640_r16\lichee\linux-3.4\drivers\media\video\sunxi-vfe\device\Makefile obj-m += ov2640.o R:\wyb\wen_ov5640_r16\lichee\linux-3.4\drivers\media\video\sunxi-vfe\Kconfig R:\wyb\wen_ov5640_r16\lichee\linux-3.4\drivers\media\video\sunxi-vfe\Makefile 5、 R:\wyb\wen_ov5640_r16\lichee\tools\pack\chips\sun8iw5p1\configs\evb-20\sys_config.fex ;-------------------------------------------------------------------------------- ;vip (video input port) configuration ;vip_used: 0:disable 1:enable ;vip_mode: 0:sample one interface to one buffer 1:sample two interface to one buffer ;vip_dev_qty: The quantity of devices linked to capture bus ; ;vip_define_sensor_list: If you want use sensor detect function, please set vip_define_sensor_list = 1, and ; verify that file /system/etc/hawkview/sensor_list_cfg.ini is properly configured! ; ;vip_dev(x)_pos: sensor position, "rear" or "front", if vip_define_sensor_list = 1,vip_dev(x)_pos must be configured! ; ;vip_dev(x)_isp_used 0:not use isp 1:use isp ;vip_dev(x)_fmt: 0:yuv 1:bayer raw rgb ;vip_dev(x)_stby_mode: 0:not shut down power at standby 1:shut down power at standby ;vip_dev(x)_vflip: flip in vertical direction 0:disable 1:enable ;vip_dev(x)_hflip: flip in horizontal direction 0:disable 1:enable ;vip_dev(x)_iovdd: camera module io power handle string, pmu power supply ;vip_dev(x)_iovdd_vol: camera module io power voltage, pmu power supply ;vip_dev(x)_avdd: camera module analog power handle string, pmu power supply ;vip_dev(x)_avdd_vol: camera module analog power voltage, pmu power supply ;vip_dev(x)_dvdd: camera module core power handle string, pmu power supply ;vip_dev(x)_dvdd_vol: camera module core power voltage, pmu power supply ;vip_dev(x)_afvdd: camera module vcm power handle string, pmu power supply ;vip_dev(x)_afvdd_vol: camera module vcm power voltage, pmu power supply ;x indicates the index of the devices which are linked to the same capture bus ;fill voltage in uV, e.g. iovdd = 2.8V, vip_devx_iovdd_vol = 2800000 ;fill handle string as below: ;axp22_eldo3 ;axp22_dldo4 ;axp22_eldo2 ;fill handle string "" when not using any pmu power supply ;-------------------------------------------------------------------------------- [csi0] vip_used = 1 vip_mode = 0 vip_dev_qty = 1 vip_define_sensor_list = 0 vip_csi_pck = port:PE00 vip_csi_mck = port:PE01 vip_csi_hsync = port:PE02 vip_csi_vsync = port:PE03 vip_csi_d0 = port:PE04 vip_csi_d1 = port:PE05 vip_csi_d2 = port:PE06 vip_csi_d3 = port:PE07 vip_csi_d4 = port:PE08 vip_csi_d5 = port:PE09 vip_csi_d6 = port:PE10 vip_csi_d7 = port:PE11 vip_csi_sck = port:PE12 vip_csi_sda = port:PE13 vip_dev0_mname = "ov5640" vip_dev0_pos = "rear" vip_dev0_lane = 1 vip_dev0_twi_id = 2 vip_dev0_twi_addr = 0x78 vip_dev0_isp_used = 0 vip_dev0_fmt = 0 vip_dev0_stby_mode = 0 vip_dev0_vflip = 0 vip_dev0_hflip = 0 vip_dev0_iovdd = "axp22_dldo3" vip_dev0_iovdd_vol = 2800000 vip_dev0_avdd = "" vip_dev0_avdd_vol = 2800000 vip_dev0_dvdd = "" vip_dev0_dvdd_vol = 1800000 vip_dev0_afvdd = "" vip_dev0_afvdd_vol = 2800000 vip_dev0_power_en = vip_dev0_reset = port:PE14 vip_dev0_pwdn = port:PE15 vip_dev0_flash_en = vip_dev0_flash_mode = vip_dev0_af_pwdn = 6、开发板上摄像头的I2C挂载在TWI2上面了,逻辑是需要打开的(但是不打开也能够用,很奇怪!): ;---------------------------------------------------------------------------------- ;i2c configuration ; twi_used = twix enable ;---------------------------------------------------------------------------------- [twi0] twi_used = 1 twi_scl = port:PH02 twi_sda = port:PH03 [twi1] twi_used = 1 twi_scl = port:PH04 twi_sda = port:PH05 [twi2] twi_used = 0 twi_scl = port:PE12 twi_sda = port:PE13 直接配置摄像头的I2C了: vip_csi_sck = port:PE12 vip_csi_sda = port:PE13 不过奇怪的是,摄像头并没有向其它平台那样生成这个设备节点: /sys/class/i2c-adapter/i2c-2/2-0030 shell@octopus-f1:/ $ shell@octopus-f1:/ $ cd /sys/class/i2c-adapter/i2c-2/ shell@octopus-f1:/sys/class/i2c-adapter/i2c-2 $ shell@octopus-f1:/sys/class/i2c-adapter/i2c-2 $ ll drwxr-xr-x root root 1970-01-02 08:06 2-003b --w------- root root 4096 1970-01-02 08:06 delete_device lrwxrwxrwx root root 1970-01-02 08:06 device -> ../../twi.2 -r--r--r-- root root 4096 1970-01-02 08:06 name --w------- root root 4096 1970-01-02 08:06 new_device drwxr-xr-x root root 1970-01-02 08:06 power lrwxrwxrwx root root 1970-01-02 08:06 subsystem -> ../../../../bus/i2c -rw-r--r-- root root 4096 1970-01-02 08:06 uevent shell@octopus-f1:/sys/class/i2c-adapter/i2c-2 $ 可能是ov2640的驱动程序不完整,没有通过i2c_detect来注册2-003c这个节点。 直接在驱动程序中读取I2C,还是对的。device ID = 0x5640。 7、摄像头使用的是客户提供: 设置为VGA分辨率是: vsync=7.5hz href=15khz xclk=24mhz pclk=85mhz
FPGA设计实现OV5640 摄像头采集数据VGA显示输出Verilog设计逻辑Quartus工程源码文件,FPGA型号Cyclone4E系列中的EP4CE10F17C8,Quartus本18.0。 module ov5640_rgb565_1024x768_vga( input sys_clk , //系统时钟 input sys_rst_n , //系统复位,低电平有效 //摄像头接口 input cam_pclk , //cmos 数据像素时钟 input cam_vsync , //cmos 场同步信号 input cam_href , //cmos 行同步信号 input [7:0] cam_data , //cmos 数据 output cam_rst_n , //cmos 复位信号,低电平有效 output cam_pwdn , //cmos 电源休眠模式选择信号 output cam_scl , //cmos SCCB_SCL线 inout cam_sda , //cmos SCCB_SDA线 //SDRAM接口 output sdram_clk , //SDRAM 时钟 output sdram_cke , //SDRAM 时钟有效 output sdram_cs_n , //SDRAM 片选 output sdram_ras_n , //SDRAM 行有效 output sdram_cas_n , //SDRAM 列有效 output sdram_we_n , //SDRAM 写有效 output [1:0] sdram_ba , //SDRAM Bank地址 output [1:0] sdram_dqm , //SDRAM 数据掩码 output [12:0] sdram_addr , //SDRAM 地址 inout [15:0] sdram_data , //SDRAM 数据 //VGA接口 output vga_hs , //行同步信号 output vga_vs , //场同步信号 output [15:0] vga_rgb //红绿蓝三原色输出 ); //parameter define parameter SLAVE_ADDR = 7'h3c ; //OV5640的器件地址7'h3c parameter BIT_CTRL = 1'b1 ; //OV5640的字节地址为16位 0:8位 1:16位 parameter CLK_FREQ = 26'd65_000_000; //i2c_dri模块的驱动时钟频率 65MHz parameter I2C_FREQ = 18'd250_000 ; //I2C的SCL时钟频率,不超过400KHz parameter CMOS_H_PIXEL = 24'd1024 ; //CMOS水平方向像素个数,用于设置SDRAM缓存大小 parameter CMOS_V_PIXEL = 24'd768 ; //CMOS垂直方向像素个数,用于设置SDRAM缓存大小 //wire define wire clk_100m ; //100mhz时钟,SDRAM操作时钟 wire clk_100m_shift ; //100mhz时
FPGA读写OV5640摄像头显示例程 Verilog逻辑源码Quartus工程文件+文档说明,FPGA型号Cyclone4E系列中的EP4CE6F17C8,Quartus本17.1。 本实验将采用 500 万像素的 OV5640 摄像头模组(模块型号:AN5640)为大家显示更高分辨率 的视频画面。OV5640 摄像头模组最大支持 QSXGA (2592x1944)的拍照功能,支持 1080P、720P、 VGA、QVGA 视频图像输出。本实验将 OV5640 配置为 RGB565 输出,先将视频数据写入外部存储 器,再从外部存储器读取送到 VGA、LCD 等显示模块。 module top( input clk, input rst_n, output cmos_scl, //cmos i2c clock inout cmos_sda, //cmos i2c data input cmos_vsync, //cmos vsync input cmos_href, //cmos hsync refrence,data valid input cmos_pclk, //cmos pxiel clock output cmos_xclk, //cmos externl clock input [7:0] cmos_db, //cmos data output cmos_rst_n, //cmos reset output cmos_pwdn, //cmos power down output vga_out_hs, //vga horizontal synchronization output vga_out_vs, //vga vertical synchronization output[4:0] vga_out_r, //vga red output[5:0] vga_out_g, //vga green output[4:0] vga_out_b, //vga blue output sdram_clk, //sdram clock output sdram_cke, //sdram clock enable output sdram_cs_n, //sdram chip select output sdram_we_n, //sdram write enable output sdram_cas_n, //sdram column address strobe output sdram_ras_n, //sdram row address strobe output[1:0] sdram_dqm, //sdram data enable output[1:0] sdram_ba, //sdram bank address output[12:0] sdram_addr, //sdram address inout[15:0] sdram_dq //sdram data ); parameter
### 设置 OV5640 摄像头模块分辨率的方法 为了设置 OV5640分辨率,需要配置多个寄存器以指定所需的图像尺寸和其他特性。这些寄存器可以通过 I2C 总线访问。 #### 配置寄存器 OV5640 使用一组特定的寄存器来定义输出图像的各种属性,包括但不限于: - 图像宽度和高度 - 输出格式(YUV, RGB) - 特殊功能(如自动曝光) 具体来说,要改变分辨率为 1280x1024 (SXGA),则需写入如下几个关键寄存器[^3]: | 寄存器名称 | 地址 | 默认值 | |--|-----------| | TEST_PATTERN | 0x7F | 0x00 | | IMAGE_MODE | 0x3D | 0x0A | 对于 SXGA 分辨率的具体设置命令序列可以在 CrazyBingo 提供的教学资源中找到更详细的指导[^1]。 #### 示例代码 下面是一个简单的 Python 脚本片段用于初始化并设定 OV5640 到所需分辨率: ```python import smbus def set_ov5640_resolution(i2c_bus, resolution='sxga'): bus = smbus.SMBus(i2c_bus) # Reset camera to default settings first. reset_camera(bus) if resolution.lower() == 'sxga': config_sxga_mode(bus) def reset_camera(bus): """Reset the camera using a predefined sequence.""" pass def config_sxga_mode(bus): """Configure camera into SXGA mode with specific registers""" register_settings = [ (0x3d, 0x0a), # Set image size and format ... ] for reg_addr, value in register_settings: bus.write_byte_data(DEVICE_ADDRESS, reg_addr, value) ``` 此脚本展示了如何利用 `smbus` 库通过 I2C 协议向 OV5640 发送指令,从而调整其工作模式至 SXGA 分辨率
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值