摄像头驱动程序设计

合集下载

实验十五 USB 摄像头驱动和应用实验

实验十五 USB 摄像头驱动和应用实验

2.3 视频捕获函数与其捕获线程
int CCameraCode::StartStreaming (HDC hdc, RECT *prect, WORD wFormat, WORD wFrame, DWORD dwInterval) { PTHREADSTRUCT pThd = (PTHREADSTRUCT)LocalAlloc (LPTR, sizeof (THREADSTRUCT)); if (!pThd) return ERROR_NOT_ENOUGH_MEMORY; // Load parameter passing struct pThd->wFormat = wFormat; pThd->wFrame = wFrame; pThd->rect = *prect; pThd->dwInterval = dwInterval; pThd->hdc = hdc; pThd->pCamercode =this;
2
USB 设备的识别过程,包括 USB 总线枚举过程、设备类配置过程等。而 USB 的通信过 程,则按层次依次分为信号层、协议层和数据传输层进行。下面分别对上述过程进行描述。 数据传输层 接 协议层 USB 主机 信号层 USB 总线接口 端 点 口
逻辑通信
物理通信
图 2 USB 通信的逻辑结构
a) USB 设备的识别过程: 总线枚举过程: 当一个新的 USB 设备接入集线器(HUB)的某个端口上,集线器就会通过“状态改变管 道”向 USB 主机(USB Host)报告新的设备的接入。主机询问集线器确认新设备的接入后, 等待一段时间后,向端口发出复位命令并使能该端口。 在端口复位完毕后,该端口就有效了,此时 USB 设备出于默认状态,地址为 0。接着主 机给设备分别一个唯一的地址,设备进入有地址状态。 主机从设备中读取所有配置描述符,并且根据读取的配置描述符为设备指定一个配置。 这样设备就可以得到所需要的电量和其他资源,设备已经准备就绪。 设备类配置: 总线枚举完毕后,从设备的角度讲,它已经可以正常工作了,但是主机尚未为该设备的 不同接口分配具体的客户端驱动程序。 因此此时主机端协议软件找到设备中每个接口所需要 的驱动程序,然后驱动程序从接口的选择设置中选出最合适的,为接口中端点创建管道。 如此完成所有接口的配置,设备的配置过程就彻底完成了。USB 设备就像非 USB 设备一 样传输数据了。 USB 通信原理 USB 的通信就是指 USB 设备与 USB 主机之间的通信。物理上,总线上的设备通过一条物 理连线和主机通信,所有的设备共享这个物理链路。逻辑上,主机给每个设备提供了一条逻 辑的连接,每个设备都有这样一条点对点的连接。 为了细化 USB 的通信机制,协议开发者采用了分层的概念。USB 通信逻辑上分成三层: 信号层、协议层和数据传输层。 信号层用来传输位信息流的信息,在这里传输的数据称为包(Packet) ;协议层用来实 现包字节流的信息,它们在信号层被编码成 NRZI 位信息传送出去,这里的包信息流称为事 务处理(Transaction) ;数据传输层用来实现在功能接口间传输有一定意义的信息, 这些信 息在协议层被打包为包格式,这里的信息流称为传输(Transfer) 。下面分析各个层次进行 数据传输I CCameraCode::ReadFrameThread (PVOID pArg) { int rc = 0; BOOL f; DWORD dwBytes; THREADSTRUCT Thd; FORMATPROPS fmtData; int nFrameCnt = 0; DWORD dwTick = 0; DWORD dwErr = 0; if (!pArg) return -1; // Copy over params Thd = *(PTHREADSTRUCT)pArg; CCameraCode *pCameracode=(CCameraCode*)Thd.pCamercode; LocalFree (pArg); rc = pCameracode->GetFormatInformation (Thd.wFormat, Thd.wFrame, &fmtData); if (rc) return rc; // Initialize the conversion library rc =pCameracode->pMjpe2bmp-> InitDisplayFrame (NULL); RECT rect; if ((Thd.rect.right == 0) && (Thd.rect.bottom == 0)) SetRect (&rect, Thd.rect.left, Thd.rect.top, Thd.rect.left + fmtData.dwWidth, Thd.rect.top + fmtData.dwHeight); else rect = Thd.rect; // Parameters needed to start a stream STARTVIDSTRUCT svStruct; dwBytes = 0; svStruct.cbSize = sizeof (STARTVIDSTRUCT); svStruct.wFormatIndex = Thd.wFormat; svStruct.wFrameIndex = Thd.wFrame; svStruct.dwInterval = Thd.dwInterval; svStruct.dwNumBuffs = NUMBUFFS; svStruct.dwPreBuffSize = PREBUFFSIZE; svStruct.dwPostBuffSize = 0; // Start the video stream f = DeviceIoControl ( pCameracode->hCam, IOCTL_CAMERA_DEVICE_STARTVIDEOSTREAM, (LPVOID)&svStruct, sizeof (STARTVIDSTRUCT), 0, 0, &dwBytes, NULL); if (f) { GETFRAMESTRUCT gfsIn;

ClareVision 摄像头和NVR驱动程序集成 - 说明书

ClareVision 摄像头和NVR驱动程序集成 - 说明书

ClareVision Camera and NVR Control4 Driver Integration Release NotesOnline DocumentationManufacturer Website: /Support Site: /contactChange LogRevision Date Description1.0.0 04/5/2021 Initial Version2.0.0 05/4/2021 Adding support for Smart Events and Notification Snapshots3.0.0 06/02/2021 Added ability to choose the video stream used.4.0.0 07/12/2021 Added support for cameras behind a CLR NVR using virtual host5.0.0 08/25/2021 Bug Fixes and Add support for driver auto update.6.0.0 02/10/2022 Add Support for Intrusion Events for Value Series WiFi CameraFixes virtual host camera snapshot bug7.0.0 05/31/2022 Adds support for SDDP for CLR NVR’sFixes snapshot issue for Android devices when remote IntroductionThe ClareVision Camera and NVR Driver integrates CLR-V camera and NVR models with Control4 to add streaming video and camera events into a Control4 system. Cameras on the same network as the Control4 controller or cameras plugged directly into an NVR port can be integrated in a Control4 project. To integrate cameras behind an NVR please refer to the Integrating Cameras Behind an NVR section.Notes:•This driver requires Control4 OS 3.0.0 or later to operate.•This driver requires that the ClareVision camera be on the same network as the Control4 system.•This driver supports all ClareVision cameras and NVRs with model numbers starting with “CLR-V”.•This driver replaces the ClareVision NVR Driver Version 1. Please use this driver and virtual host to integrate all ClareVision CLR Cameras on your network or connected to a CLR NVR port.InstallationFollow the installation instructions that came with your ClareVision camera and verify you can connect to the camera’s web interface. Clare Controls does not assume responsibility for damages caused by improper installation, connection to the network, or use of the device.For full ClareVision installation and configuration, see ClareVision User Manual.SDDP SetupInstall, configure, and test the ClareVision device. Verify that all cameras and the NVR device are on the same network as the Control4 system, configured, and able to be accessed from a web browser before integrating with Control4. Before proceeding, please confirm your device’s firmware is up to date, please refer to the Updating Your Devices Firmware section for further instructions. SDDP requires NVR firmware version 22.1.23.4 or greater.To add the driver (SDDP):1. Confirm SDDP is enabled, and the broadcast sett ings are correct. Navigate to the NVR’sweb UI, select Configuration > System > Network. Select the SDDP Configuration taband confirm the SDDP Enable option is selected. Next confirm the follow parameters are correct and click Save.•Product Type: clarecontrols:camera_clarevision•Driver File Name: clarevision.c4zNote: If the SDDP Configuration tab is not available please confirm your device is up to date.2. Access Composer and browse to the Discovered tab.System Design > Discovered3. Sort the list of discovered SDDP devices by Manufacturer.The ClareVision NVR device is listed with:Type: CameraManufacturer: Clare ControlsModel: (The model of the NVR discovered)Address field: clarecontrols:camera_clarevision4. Double-click on the discovered NVR to add the device to the project.5. Once added to the project click on the newly added device. Confirm that the username is“admin” or enter another user and click Set.6. Next, enter the cameras password and click Set.7. Update the HTTP and RTSP ports to correspond with the NVR channel you areconfiguring. Please refer to the Cameras Behind an NVR section for help configuring the ports.Notes:1. The password for the device is the password of the camera. Cameras that wereco nnected to the NVR new out of the box will have the NVR’s admin password.2. The SDDP process will take care of adding the first camera device. Please refer to theCameras Behind an NVR section for any additional cameras to be added.Camera SetupThis section is for the setup of standalone cameras. If the camera you are wishing to add is connect to an NVR, please proceed to the Cameras Behind an NVR section. Install, configure, and test the ClareVision camera. Verify that the camera is on the same network as the Control4 system, configured, and fully functional in the camera’s web interface before integrating with Control4.Note: The driver .c4z file may need to be added to your Control4/Drivers folder or the driver can be added through Composer by navigating to the Driver menu, then Add or Update Driver. Please compare the driverTo add the Camera to your project8. Confirm Driver has been added to Composer.9. Navigate to Items > Search10. Search for ClareVision and double click on the “ClareVision Camera and NVR Driver”11. Once added to the project, click on the newly added device. Enter the camera’s IPaddress and c onfirm that the username is “admin” (case sensitive) and enter thecamera’s password and click Set for each item.Notes:1. The password for the camera is set by the user. The default password is the first 6characters of the camera’s serial number. The serial number is located on thecamera’s label and the box. If you have not done so, please navigate to the camera’sIP address in a web browser and login with the username “admin”and the defaultpassword. The camera will prompt you to change the password. If a camera hasbeen previously plugged into a CLR NVR, the camera will have the NVR’s password.2. Clare recommends using a static IP address or a DHCP reservation to prevent thecamera’s IP address from changing. If the camera’s IP address changes the came rawill not be accessible from Control4.12. Confirm the camera is successfully connected by viewing the Properties tab underAdvanced Properties in Composer Pro. The Camera’s Model, Firmware, and SerialNumber fields will be populated.13. The ClareVision camera driver supports the ability for the integrator to choose whichcamera stream Control4 Navigators will use for streaming video. The driver is defaultedto use the Sub Stream, but can be changed to use the Main or Third stream bynavigating to Advanced Properties > Properties. Select the camera stream and clickSet.Note: Value series cameras staring with model number CLR-V100 do not support a Third Stream. For Value series cameras please use the Sub or Main Streams.Cameras Behind an NVRClareVision CLR model cameras plugged directly into an NVR port can be integrated by using Virtual Host. To setup your NVR and Control4 project:1. Confirm your NVR firmware is up to date. Please refer to the Updating Your DeviceFirmware section for further instructions. If you do not see virtual host as an option, your NVR is not up to date.2. Navigate to Configuration > Channel > Camera and note the port numbers at the end ofthe camera URL in the Connected column. For Channel 1, the HTTP port would be10001 and the RTSP port would be 10201.Note: If the RTSP Virtual Host URL is not listed under the Connected column pleaseconfirm your devices firmware version is up to date. Refer to the Updating Your Devices Firmware for further instruction.3. In Composer add a ClareVision Camera and NVR Driver by navigating to Items >Search. Next, Search for ClareVision Camera and NVR Driver and double click on thesearch result to add a camera device to your Control4 project.4. Enter the IP address of the NVR, the virtual host port for the HTTP port, and RTSP Portand click Set for each. The below is an example for NVR channel 2.5. Enter the cameras password and click SET.NOTE: The password used is the password of the camera, not the NVR. If the camera was plugged into the NVR new out of the box it may have been activated with the NVR’spassword. If needed, you can confirm the cameras password by navigating to the NVR’s IP address with : and the HTTP of the virtual host port. There you can attempt to sign intocamera to confirm the password. Example for channel 1: 192.168.1.x:10001.Supported FeaturesOnce the camera is added to the project in Composer Pro, the Control4 user interface displays the camera under the security subsystem.•Snapshot: The ability to get a snapshot image from the camera device.•RTSP Stream: The ability to view the camera’s live video stream.•Notification Snapshot: The ability to attach a camera snapshot to a push notification.•Motion Events: The ability to create programming actions based on motion events.•Smart Events: The ability to create programming actions based on Line Crossing, Intrusion, Loitering, and People Gathering events.EventsThe ClareVision Camera and NVR Driver supports programming action on motion and smart events in a Control4 project. Examples of programming actions include turning on a light, sending a push notification, or triggering a camera stream to play on a Control4 Navigator such as T3/T4 Touchscreens and onscreen Navigators when an event is detected.NOTE: Events are only supported for CLR model camera. To use a 3rd party camera, use the Control4 driver for that camera specific camera device using the corresponding NVR virtual host ports for HTTP and RTSP.To start receiving events:1. Navigate to the Camera Device’s Advanced Properties.System Design > Camera Device > Advanced Properties > PropertiesSelect “Enabled” from the dropdown menu and click Set.2. Navigate to the Sensors category.Items > My Drivers > Sensors3. From the Sensors category, search for and double click a Motion Sensor for each sensoralarm type you are using to add a sensor device to the project. Rename the MotionSensor to match the smart event.4. Under the ClareVision Camera connection, drag the Control Outputs for the MotionSensor and any Smart Event alarms you will be using to its corresponding item in theCONTACT_SESNOR Input Devices section below.Notes:•When the sensor is first added, it will read as “State: opened, Verified: No”. Once it receives its first event, it will go to “State: Closed, Verified:Yes”. Thi s must berepeated for each sensor.•The Invert Sensor and Enable Debounce Timer options should remain at their default values.5. Now that the events are enabled, actions can be programmed for motion and smartsensor events.Note: Value series cameras supports only Motion events. The Value series WiFi camera adds support for Intrusion events. Performance and Color series cameras support all event types. Updating Your Devices FirmwareCameras and NVR devices need to be up to date to take advantage of new features and bug fixes. You can view your devices firmware version my navigating to the device’s settings in the ClareVision app, then Device Information.The currently available firmware versions can be confirmed and downloaded here:https:///clarevision-firmwareIf a devices firmware requires an update, please first use the ClareVision app to get your device up to date. The ClareVision app will prompt the user to update when a newer version is available.To manually update a devices firmware, download the appropriate version from the link above and install the firmware on the device:For an NVR:• Navigate to the NVR’s web UI, then select Configuration > Maintenance > Manual Upgrade. Browse to the location of the downloaded firmware and click Upgrade.For a Camera:• Navigate to the Camera’s web UI, then select Configuration > System > SystemConfiguration > Maintenance. Browse to the location of the downloaded firmware and click Upgrade.PropertiesThe ClareVision Camera Driver properties available in Control4 include:• Version : The version of the Control4 driver.• Camera Model : The model of the camera.• Firmware : The version of firmware on the camera.• Serial Number : The serial number of the camera.• Stream : The camera RTSP stream Control4 will use for video.Main StreamSub StreamThird Stream• Events : The property selector to enable or disable camera events.• Log Level : A list of logging levels (for example: debug, trace, critical).• Log Mode : Allows the user to select the desired logging mode.1 – Off2 – Print3 – Log4 – Print and LogTroubleshootingMobile user interface not working:Refresh the project Navigator. Once refreshed, the mobile user interface updates and displays the correct status. Director not receiving video or events:1. Verify that the camera is working in the camera’s web interface.2. Verify the Cameras username and password are correct.3. If the camera is functional, restart the main controller.Note: Refresh Navigators, Refresh Project or restart of Composer will not resolve this. Limitations•MJPEG stream format is not supported.•H.265 stream format is not supported.Contact informationClare Controls, LLC.7519 Pennsylvania Ave, Suite 104Sarasota, FL 34243General: 941.328.3991Fax: 941.870.9646Integrator/Dealer Support: 941.404.1072******************************。

智能家居监控系统USB摄像头驱动的开发与实现

智能家居监控系统USB摄像头驱动的开发与实现
i f US i tra e US g、 B ne fc 、 B
— _
D v e r es一 >/选择 U p ot S pr 一 > 】 u
— - — — — —
US u p r Bsp o t
{} S p o r o ts eU B u p rf s- i S t oH d
像 头是 U B .协议的。 S1 1 U B只是一个总线 , S 只提供一个数据通路 。 S U B总线 驱动程序并不知道一个设备具体如何操作 , 有哪些行 为。 个设备具体实现什么功能 , 由设备 自己来决定 。 于 要 对

译进 内核 , 具体实现如下 :
ma eme u o fg k n cn i
h s e di t ot npo 表示 ,它 们之 间的 n
关系如图 3 所示 。
D v e r es一 > / ei i r cD v / 选择设备 Z 3 1 C 0
< >M utme i u p r 一 l i das p o t > 木 木M ut e i o es p o t 宰术 术 li d ac r u p r 水 m <水 Vi e o i u > d 0F rL n x
[ U Bdv e l yt (E R C T D 木 S ei e s m D P E A E ) 】 cf s e i
[ U Bdv e l sdvcs E R C T D S ei a - ei ( P E A E ) ] ccs eD
< > OHCIHCD u p r sp o t
译进入 内核 , 内核初始化时 自动加载 , 在 本设计采用 的是 编译进 内核的方式 。 由于在 Lnx 2 . . iu一 .3 6的内核 中已有 68 Z 0 0 的驱 动代码 , C31 我们只需要修改 配置菜 单 , 使其 编

WindowsCE下USB摄像头驱动开发以OV511为例附带全部源代码以及讲解

WindowsCE下USB摄像头驱动开发以OV511为例附带全部源代码以及讲解

这部分讲解如何在Windows 下实现 一样的功能。
Windows 的控制传输
查看MSDN,IssueControlTransfer和 IssueVendorTransfer是用来进行控制传输的,但两个函数 有什么区别呢? 看MSDN,IssueControlTransfer的第一个参数是 hPipe,就是说,在使用IssueControlTransfer之前,必须 用OpenPipe打开管道。 OpenPipe函数需要端点描述作为参数。但是,端点0是 没有这个描述可以用的(MSDN: However, endpoint zero (0) never has a USB_ENDPOINT structure)。 我没测试自己指定描述是否可以,但是, IssueVendorTransfer提供了更为方便的途径。这个函数默 认从端点0进行控制传输。 如果是其他端点的控制传输,是要用 IssueControlTransfer的。
Windows 下 流接口USB驱动程序加载的流程
6.接着CAM_Init函数被调用,参数就是ActiveDevice函数的 参数1,然后依据这个参数,在注册表中找到USB驱动程序的上下 文,并返回,这样对该流接口驱动的操作,就可以找到USB驱动 的上下文,并且交换数据。 以上这些工作完成之后,USB设备的信息被保存,并且USB 驱动程序上下文也被流接口驱动所记载。流接口USB驱动的加载 完成。我们就看见那个输入驱动程序名称的对话框消失了。如果前 面6个步骤中任何一步不成功,将不会使用这个驱动程序,会反复 弹出这个对话框,提示输入驱动程序名称,直到这些过程全部正确 完成。
HKEY_LOCAL_MACHINE\Drivers\Active中的项目。 注意:USB驱动程序不通过注册表API来操作注册表,而是通过 USBD提供的函数。

基于WindowsCE.Net的USB摄像头驱动设计

基于WindowsCE.Net的USB摄像头驱动设计
维普资讯
第2 卷 第 7 0 期
20 0 7年 OUR NAL OF W UHAN UNI VERS ⅡY CI NCE AND NGI ERI OF S E E NE NG
V _ 0 NO. Ol 2 7 J 12 o u.0 7
图 1 Wid wsCE. t US n o Ne 下 B
进行数据 的传输 。在做 US B摄像头 的数据传输时 ,还需要 了解设备 的传输
结构 图 2 就展示 了 US B设备端点和管道 的拓扑结构 :
系 统 结 构
目前 ,WiC n E拥有两种驱动 的架构模 型 ,一是本机设备驱动 ,一种是流接 口设备 驱动。 在 Wid w ENe 中流接 口驱动程序 主要接受两种命令 :从设备管理程序来 的命令 ; no s . t C 应用程序通过调用系 统调用来的命令. 3 图 展示 了流接 口驱动程序和其他 系统 部件 之间的关系 。 目前 ,WiC n E拥有 两种驱动 的架构模型 ,一是本机设备 驱动 ,一种是流接 口设备驱动 。在 Wid ws ENe no . t C 中流接 口驱动程序主要接受两种命令 :
基于 Widws EN t U B摄像头驱动设计 n o :e 的 S C
刘 莉 ,唐 静
( 武汉科技学院 电信学院,湖北 武汉 4 0 7 ) 3 0 3 摘 要 :目前在 Wi o s EN t n w C .e 下采用 U B摄像头设备实现 图像实时采集开始普及 ,其驱动的设计 d S
l 驱 动 设 计 原 理 分 析
Wid w ENe 的 US no s . t C B系统软件 分为两 层 :U B设备驱动程序层 S 和底层的 wid w E实 现的函数层。U B设备驱动程序 主要负责利用 系 no s C S 统 提供的底 层接 口配置设备 ,和设备进行通讯 。底层 的 函数提本身又 由两

基于stm32f407平台ov2640驱动程序设计

基于stm32f407平台ov2640驱动程序设计

基于STM32F407平台OV2640驱动程序设计黄健,罗国平,杜丽君(乐山师范学院计算机科学学院)【摘要】随着监控技术的发展,有的具有个性化的摄像头需要用户自己设计和研究。

本文基于STM32F407平台,对进行OV2640了个性化的驱动程序设计。

【关键词】RFID;OV2640;STM32【中图分类号】TP274【文献标识码】A【文章编号】1006-4222(2015)19-0246-02引言随着计算机技术的发展,嵌入式系统越来越多应用在各种微型控制系统中,如无人机控制系统、可视对讲门禁系统、机器人视觉系统、场景监控系统等,这些系统中大量使用摄像头,市面上有很多摄像头可以买,但是具有个性化的摄像头还是需要用户自己设计和研究,比如要求摄像头嵌入到控制系统中、要求具有视频捕捉功能、要求具有图像识别、对象跟踪功能、要求具有工程定时功能(客户到期不付款、摄像头自动失效)等等。

这些功能是需要用户自己去设计和研究。

在无人机控制系统中视频传输技术,是实现无人机远程视频传输重要技术之一,在无人机控制系统应用领域具有非常重要的意义。

1OV2640视频采集系统构成OV2640摄像头是OV公司生产的CMOSUXGA(1632伊1232)图像传感器,该摄像头通过SCCB总线控制,可以输出整帧、子采样、缩放和取窗口等方式的各种分辨率8/10位影像数据。

UXGA图像模式最高输出15帧/秒。

用户可以完全控制图像质量、数据格式和传输方式。

所有图像处理功能过程包括珈玛曲线、白平衡、对比度、色度等都可以通过SCCB接口编程来实现。

OmniVision图像传感器应用独有的传感器技术,通过减少或消除光学或电子缺陷如固定图像噪声、拖尾、浮散等,提高图像质量,得到清晰稳定的彩色图像。

STM32F407平台是Cotex_M4ARM平台处理能力非常强大。

并自带DCMI接口,支持DMA传输,因此在传输效率上非常高。

DCMI(数字摄像头接口)接口是一个同步并行接口,能够接收外部8位、10位、12位或14位CMOS摄像头模块发出的高速数据流。

基于Linux的USB摄像头驱动程序设计

ub s

个具体 的 U B摄像头 驱动 的分析 , 出了 Ln S 给 i=下 U B摄 t S
1 Ln 中 U BP i= t S C摄 像 头 驱 动 程序

和 ub d】 ie 其 中注册 驱动程 序必须 在初始 s e gt , 【 sr e

像头驱动程序编写 的整 体框 架以及具 体实现方案。 U B设备在某种情 况下 整个 设备 只需 要 一个 驱动 程序 S 来进行数据处理 , 但在其他情况下可能每一个接 口( 吐 : h e ) 就需 要一 个 驱动 程序 来进行 数 据处 理。在 Ln it =操作 系统 中, 有一个 叫做“ S U B核 心” 的子 系统 , 的作用 是 提供 支持 它 U B 备驱 动 程序 的 A I 应 用 编 程 接 口) U B 的主 机 S设 P( 和 S ( 0 r驱动程序 。它提供 了许多数据结构 、 H s) 宏定义和功能 函 数来对硬件或设备进行支持 。在 lnx Ju 下编 写 U B设备的驱 S 动程序从严格意义上讲 , 就是使用这些 U B核心 的子 系统定 S 义的数据结构、 和函数来 编写数据的处理功能 。 宏 Ln it U B内核子 系统 中 , =的 S 提供 了几个 与 设备 驱动 程 序开发直接相关 的核心数据结构 , 它们在整个 设备驱 动程序 的框 架中起着灵魂 的作用 , 定义 于 内核 源代码 的 <l u/s. i xub n
度也 日益提高 。2 4 x .. 及其以后版本的 内核对 U B的支持 已 S
比较完 善。但 相对 Wi o s U B设 备 的驱 动 还不 完 善 , n w, S d 以 U B摄 像 头 为 例 , i= 仅 提 供 了 如 P /.S C E T 、 S Ln t HIP 、 R A E I I)IE H等知名 品牌 的摄像 头驱 动。而对于 市场 上 的各 种 LGT C 型号 U B摄像 头 ,it S L =支持 却很 少 , n 如需 在 L t i =下使 用这 n

嵌入式Linux下CMOS摄像头驱动的设计与实现

F AN o o g Gu d n ,SHIHo g u ’ Z n ri HANG Ja in

(.C lg nom t nSi c n e nlg , og u n esy h n h i 0 60,hn ; 1 ol eo fr ai c nead Tc o y D nh aU ir t,Sa g a 2 12 C ia e fI o e h o v i
关键 词 : 入 式 Ln x 驱 动 ; MO 摄 像 头 ; 嵌 iu ; C S 信号 量 ; C I
中图分 类号 :P 6 . T381
文献标 志码 : A
文章 编号 :0 0—0 8 ( 0 0 0 0 6 0 10 6 2 2 1 ) 3— 0 8— 3
De i n a mplm e a i n fCn OS c m e a drv r ba e n e b dd d Li u sg nd i e nt to o a r ie sdo m e e n x
r a ie mu t e l li—t s n l z a k a d mut i—tr a e .Te ti d c tst a ,whe e e a r c se un smu a e u l hed d s n i ae h t n s v r lp o e s sr i h n o sy,
tecm r r e ol epi hg t it b digtep o t atm t ay ute, t ol c h a ead v r udk e ihs bly yj g r ry uo a cl .F r r icuda— i c n a i u n h i i i l h

0 引 言
嵌 入式 图像 处理 的应 用 范 围 日益 广泛 , 为 图 作

摄像头驱动VID+PID大全

最常见的摄像头硬件ID:VID_0AC8&PID_0302VID_0AC8是中芯微的代码,常见方案如下:USB\VID_0AC8&PID_303B 301PLH方案/driver/301plh.htm USB\VID_0AC8&PID_301B 301B方案/driver/301B.htm USB\VID_0AC8&PID_305B 305B方案/driver/305B.htmUSB\VID_0AC8&PID_307B ZS211方案/driver/ZS211.htm USB\VID_0ac8&PID_0321 VC0321 /driver/VC0321.htm USB\VID_0ac8&PID_0323 VC0323 /driver/VC0323.htm USB\VID_0ac8&PID_0323 ZC0323P /driver/ZC0323P.htm USB\VID_0ac8&PID_0328 /driver/ZC0326.ht mUSB\VID_0ac8&PID_0326 ZC0326 /driver/ZC0326.htm中星微无驱方案摄像头1/driver/VM332.htm支持下列硬件ID:USB\VID_0ac8&PID_3313USB\VID_0ac8&PID_0331USB\VID_0ac8&PID_331BUSB\VID_0ac8&PID_0332USB\VID_0ac8&PID_332DUSB\VID_0ac8&PID_3330USB\VID_0ac8&PID_3332USB\VID_0ac8&PID_3333USB\VID_0ac8&PID_3340USB\VID_0ac8&PID_3342USB\VID_0ac8&PID_3343USB\VID_0ac8&PID_0336USB\VID_0ac8&PID_336DUSB\VID_0ac8&PID_3410USB\VID_0ac8&PID_3420USB\VID_0ac8&PID_3430USB\VID_0ac8&PID_3440USB\VID_0ac8&PID_3000中星微无驱方案2/driver/Vimicro_UVC.htm 支持硬件ID:USB\VID_0ac8&PID_3313USB\VID_0ac8&PID_0331USB\VID_0ac8&PID_331BUSB\VID_0ac8&PID_0332USB\VID_0ac8&PID_332DUSB\VID_0ac8&PID_3330USB\VID_0ac8&PID_3332USB\VID_0ac8&PID_3333USB\VID_0ac8&PID_3340USB\VID_0ac8&PID_3342USB\VID_0ac8&PID_3343USB\VID_0ac8&PID_336DUSB\VID_0ac8&PID_3370USB\VID_0ac8&PID_3380USB\VID_0ac8&PID_3410USB\VID_0ac8&PID_3420USB\VID_0ac8&PID_3430USB\VID_0ac8&PID_3440USB\VID_0ac8&PID_3450USB\VID_0ac8&PID_3460USB\VID_0ac8&PID_3470USB\VID_0ac8&PID_3480USB\VID_0ac8&PID_3490USB\VID_0ac8&PID_3610USB\VID_0ac8&PID_3016USB\VID_0ac8&PID_3000USB\VID_0ac8&PID_3630VID_0C45是台湾松翰电子Sonix出的。

使用VC++摄像头程序设计

“Up”:向上移动。在预览模式下可用DirectShowAPI来向上移动预览视频。
在浏览图片模式下放大图片后不能把整个图片都显示出来,所以把查看窗口向上移。
在浏览视频模式下跟浏览视频一样
“Right”:向右移动。参照“Up”功能
”Left”:向左移动。参照“Up”功能
“Down”:向下移动。参照“Up”功能
按下“0”“90””180”“270”来旋转相应的角度。
按下“+”,“-”,”Up”,“Down”,“Right”,“Left”,“C”来现实相应的功能。
按下“Save”保存图片,保存修改后的图片(即放大缩小,添加文字,上下左右移后的图片)没有修改则不用保存
按下“Print”打印图片,打印修改后的图片(即放大缩小,添加文字,上下左右移后的图片)
软件大体功能:
1.摄像头的设置如:亮度,Zoom,亮度,对比度等。
2.保存图片并在图片上添加文字。
3.图片预览实现图片的放大,缩小,在放大状态下图片的左右移动,上下移动。图片的旋转0,90,180,270度。
4.视频的保存使用压缩视频后保存并添加文字。
5.视频预览实现视频的放大,缩小,在放大状态下视频的左右移动,上下移动。视频的旋转0,90,180,270度。
Exposure:曝光,用来调节曝光DirectS来调节增益DirectShow提供此API。选择Auto自动增益
Brightness:亮度,用来调节亮度DirectShow提供此API
Contrast:对比度,用来调节对比度DirectShow提供此API
按下“Save”停止录制视频并保存视频,播放刚刚录制的视频,并把视频的缩略图放到小框里
按下“Print”打印图片,打印视频的第一帧。
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

v4l2视频处理的步骤: 视频处理的步骤: 视频处理的步骤
1:打开设备。 2:设置设备属性,图形分辨率,亮度。 3:协定数据格ห้องสมุดไป่ตู้。 4:协定输入输出方法。 5:输入,输出循环。 6:关闭设备。
urb结构体简介 结构体简介
Linux 内核中的USB代码通过一个称为urb (USB 请求块)的东西和所有的USB设备通 信。 urb 被用来以一种异步的方式往/ 从特定的 USB 设备上的特定USB端点发送/ 接收数据。 重用单个的urb,这取决于驱动程序的需要。 设备中的每个端点都可以处理一个urb 队列, 所以多个urb可以在队列为空之前发送到同一 个端点
memcpy(cam->sysfs.frame_header, cam->sof.header, soflen); printk( "Video frame captured: %lu " "bytes\n", (unsigned long)(b)); if (!(*f)) goto resubmit_urb; } else if (eof) { (*f)->state = F_ERROR; } if (sof) /* (1) */ goto start_of_frame; } else if (eof) { printk( "EOF without SOF\n"); continue; } else { printk("Ignoring pointless isochronous frame\n"); continue; } } else if ((*f)->state == F_QUEUED || (*f)->state == F_ERROR) {
if (!(*f)) (*f) = list_entry(cam->inqueue.next, struct sn9c120_frame_t, frame); imagesize = (cam->sensor.pix_format.width * cam->sensor.pix_format.height * cam->sensor.pix_format.priv) / 8; if (cam->sensor.pix_format.pixelformat == V4L2_PIX_FMT_JPEG) imagesize += 589; /* length of jpeg header */ soflen = sn9c120_sof_length(cam); for (i = 0; i < urb->number_of_packets; i++) { unsigned int img, len, status; void *pos, *sof, *eof; len = urb->iso_frame_desc[i].actual_length; status = urb->iso_frame_desc[i].status; pos = urb->iso_frame_desc[i].offset + urb->transfer_buffer; if (status) { printk( "Error in isochronous frame\n"); (*f)->state = F_ERROR; cam->sof.bytesread = 0; continue; }
摄像头驱动的特殊性
摄像头属于视频类设备。在目前的Linux核心 中,视频部分的标准是Video for Linux(简称 V4L)。这个标准其实定义了一套接口,内核、 驱动、应用程序以这个接口为标准进行交流
V4L2简介 简介
一个Linux系统用来处理视频图形的接口。它 由一个视频接口
标准以及一系列的API组成。
驱动原理图: 驱动原理图:
static void sn9c120_urb_complete(struct urb *urb) //ok { struct sn9c120_device* cam = urb>context; struct sn9c120_frame_t** f; size_t imagesize, soflen; u8 i; int err = 0; if (urb->status == -ENOENT) return;
SNONIX 120摄像头驱动程序设计 摄像头驱动程序设计
By:刘京 李康年 刘权 陈靖
主要内容: 主要内容:
USB摄像头驱动简介 V4L2简介 v4l2视频处理的步骤 urb结构体简介 驱动原理
USB摄像头驱动 摄像头驱动
USB摄像头以其良好的性能和低廉的价格得到 广泛应用 但由于摄像头所用芯片的不同,以及传感器的 多样性,需对其进行驱动程序的编写
resubmit_urb: urb->dev = cam->usbdev; err = usb_submit_urb(urb, GFP_ATOMIC); if (err < 0 && err != -EPERM) { cam->state |= DEV_MISCONFIGURED; printk( "usb_submit_urb() failed\n"); } wake_up_interruptible(&cam->wait_frame); }
f = &cam->frame_current; if (cam->stream == STREAM_INTERRUPT) { cam->stream = STREAM_OFF; if ((*f)) (*f)->state = F_QUEUED; cam->sof.bytesread = 0; printk( "Stream interrupted by application\n"); wake_up(&cam->wait_stream); } if (cam->state & DEV_DISCONNECTED) return; if (cam->state & DEV_MISCONFIGURED) { wake_up_interruptible(&cam->wait_frame); return; } if (cam->stream == STREAM_OFF || list_empty(&cam->inqueue)) goto resubmit_urb;
else { if (cam->sensor.pix_format.pixelformat == V4L2_PIX_FMT_SN9C10X || cam->sensor.pix_format.pixelformat == V4L2_PIX_FMT_JPEG) { if (sof - pos >= soflen) { eof = sof - soflen; } else { /* remove header */ eof = pos; (*f)->buf.bytesused -= (soflen - (sof - pos)); } goto end_of_frame; } else { printk( "SOF before expected EOF after " "%lu bytes of image data\n", (unsigned long) ((*f)->buf.bytesused)); goto start_of_frame; } } } }
urb的生命周期(一) 的生命周期( 的生命周期
由USB 设备驱动程序创建。 分配给一个特定USB 设备的特定端点。 由USB 设备驱动程序递交到USB 核心。
urb的生命周期(二) 的生命周期( 的生命周期
由USB 核心递交到特定设备的特定USB 主控 制器驱动程序。 由USB 主控制器驱动程序处理,它从设备进 行USB 传送。 当urb 结束之后,USB 主控制器驱动程序通知 USB设备驱动程序。
memcpy((*f)->bufmem + (*f)->buf.bytesused, pos, img); if ((*f)->buf.bytesused == 0) do_gettimeofday(&(*f)->buf.timestamp); (*f)->buf.bytesused += img; if ((*f)->buf.bytesused == imagesize || ((cam->sensor.pix_format.pixelformat == V4L2_PIX_FMT_SN9C10X || cam->sensor.pix_format.pixelformat == V4L2_PIX_FMT_JPEG) && eof)) { u32 b; b = (*f)->buf.bytesused; (*f)->state = F_DONE; (*f)->buf.sequence= ++cam->frame_count; spin_lock(&cam->queue_lock); list_move_tail(&(*f)->frame, &cam->outqueue); if (!list_empty(&cam->inqueue)) (*f) = list_entry( cam->inqueue.next, struct sn9c120_frame_t, frame ); else (*f) = NULL; spin_unlock(&cam->queue_lock);
redo: sof = sn9c120_find_sof_header(cam, pos, len); if (likely(!sof)) { eof = sn9c120_find_eof_header(cam, pos, len); if ((*f)->state == F_GRABBING) { end_of_frame: img = len; if (eof) img = (eof > pos) ? eof - pos - 1 : 0; if ((*f)->buf.bytesused + img > imagesize) { u32 b; b = (*f)->buf.bytesused + img imagesize; img = imagesize - (*f)->buf.bytesused; printk("Expected EOF not found: video " "frame cut\n"); if (eof) printk( "Exceeded limit: +%u " "bytes\n", (unsigned)(b)); }
相关文档
最新文档