As a common consumer commodity, digital camera its basic principle is to use CCD optical coupling device to convert the light signal into electrical signals, after a/D conversion, data compression and so on through the serial port or USB port in the PC-side application control of the picture (mostly JPEG format) to the PC's hard drive.
The current PC-side applications are provided by the camera manufacturer. Few people have noticed that some digital camera manufacturers provide developers with a relatively rich SDK (Software Development Kit) resources to facilitate the use of digital cameras for image collection and monitoring of development work. The SDK Development Kit generally consists of a header file (. H), a library file (. lib), and a dynamic link library file (. dll). Kodak, the United States is the world's camera manufacturing and a number of imaging standards for the lead. This article will take the Kodak DC280 SDK as an example to introduce the SDK and its application, so that interested developers can use the data camera in the project in their own programming.
1 SDK Structure diagram
The SDK control layer, between the application and the specified SDK control layer (for the DC280SDK control layer for the DS280 camera), is the main function of receiving the application's Dc280_opencamera () instruction, while the specified camera SDK control layer is transferred into the memory area; receive dc2x0 _closecamera () directive, while releasing the memory area of the specified Camera SDK control layer. Specifies that the Camera SDK layer is located under the SDK control layer, supports all functions that access the camera, and passes the function execution result status code (that is, the error code) to the application via the SDK control layer. Specifies that the lower level of the camera control layer is the driver layer. Drivers are used to deal directly with external devices.
2 SDK Function classification
Functions within the SDK can generally be grouped into the following categories according to the type of action:
(1) Camera initialization function: mainly includes _closecamera () and _opencamera ().
(2) Camera control functions: mainly including _getstatus (), _getconfig (), _setconfig (), _controlcameratime (), _controlcameraid (), _ Controltakepicture (), _resetcamera ().
(3) Picture management function: _takepicture (), _resetcamera ().
(4) Picture information get function: _getcamerapictinfo (), _getallpicturename (), _getnativepicture ().
(5) File transfer function: _getfileformcamera (), _setfiletocamera.
(6) Other types of functions: including the battery power data acquisition function, the last Operation return code acquisition function, and so on.
3 A typical example of SDK usage
Here's a simple example of taking a picture to give the reader a general idea of the generic pattern of programming, as shown in Figure 2. First of all, camera initialization is to open the camera, and then read the current camera in the parameters set, modify some parameters as needed, then take pictures, and finally turn off the camera to free memory. The routines are as follows:
The following are typical routines for SDK usage:
#include "F210.h"
OSErr ret;
DC280_Camera ;Camera;
DC280_ImgProcData ThumbImgInfo;
DC280_TakePictInfo TakePictInfo;
DC280_PictInfo GenericPictInfo;
DC280_SpecificPictInfo SpecificPictInfo;//打开相机
DC280_OpenCamera(VersionData,CameraData); //获取相机设置参数
ret=DC280_ControlTakePicture(&Camera,TRUE,0L,(VOIDPTR &TakePictInfo);
//修改需要变动的参数
ret=DC280_ControlTakePicture(&Camera,FALSE,(VOIDPTR&TakePictInfo); //拍照
ret=DC280_TakePicture(&Camera,TRUE,&ThumbImgInfo,&GenericPictInfo,(VOIDPTR)&SpecificPictInfo);
//可以根据需要加上文件传递函数等
DC210_CloseCamera(CameraData); //关闭相机
Where the second parameter of Dc280_controltakepicture is Getsetflag. When True, gets the setting parameter from the camera, or false to convey the changed parameters to the camera. The data structure of Dc280_camera is as follows:
typedef struct {DC210_PortNum PortNum;
DC210_BitRate BitRate;
DC210_CameraType CamType;
BOOL CameraOpenFlag;
VOIDPTR InternalUseOnly;
}DC280_Camera ;
This paper introduces the SDK and the development of camera application by using the DC280 SDK development tool of Kodak Company. Other company SDK usage methods are basically similar, except that the function name is slightly different and the usage is consistent. A detailed description of the functions and their parameters in the SDK can be found in the camera manufacturer's English web site from the development tools list.