HIKVISION DS-4 Series Manual

HIKVISION DS-4 Series Manual

Encoding/decoding card sdk documentation

Advertisement

Technical Manual
DS-4xxx Encoding/Decoding Card
SDK Documentation
Version 5.1
(For Linux)
Hangzhou Hikvision Digital Tech. Co., Ltd.
1
© 2006-2010 by HIKVISION. All rights reserved.

Advertisement

Table of Contents
loading

Summary of Contents for HIKVISION DS-4 Series

  • Page 1 Technical Manual DS-4xxx Encoding/Decoding Card SDK Documentation Version 5.1 (For Linux) Hangzhou Hikvision Digital Tech. Co., Ltd. © 2006-2010 by HIKVISION. All rights reserved.
  • Page 2 HIKVISION and then only on the condition that this notice is included in any such reproduction. No information as to the contents or subject...
  • Page 3: Table Of Contents

    StopVideoCapture(); ..................20 4.2.27. StartSubVideoCapture() ................. 20 4.2.28. StopSubVideoCapture() ................. 20 4.2.29. SetIBPMode(); ....................21 4.2.30. SetDefaultQuant(); ..................21 4.2.31. SetEncoderPictureFormat() ; ................. 22 4.2.32. SetSubEncoderPictureFormat() ..............22 4.2.33. SetupBitrateControl() ; ................... 22 © 2006-2010 by HIKVISION. All rights reserved.
  • Page 4 StartVideoPreviewEx() ................... 35 4.2.71. SetEncoderAudioOutput() ................36 Decoding Card SDK ....................37 5.1. API of Encoding Card .................. 37 5.1.1. HW_InitDecDevice() ..................37 5.1.2. HW_ReleaseDecDevice() ................37 5.1.3. HW_ChannelOpen() ..................37 5.1.4. HW_ChannelClose()..................37 © 2006-2010 by HIKVISION. All rights reserved.
  • Page 5 5.1.41. SetDisplayRegion ()..................44 5.1.42. ClearDisplayRegion () ................... 44 5.1.43. SetDisplayRegionPosition () ................45 5.1.44. FillDisplayRegion () ..................45 5.1.45. SetDecoderAudioOutput() ................45 5.1.46. SetDecoderVideoOutput()................45 5.1.47. SetDecoderVideoExtOutput()................. 46 5.1.48. SetEncoderVideoExtOutput() ................. 46 © 2006-2010 by HIKVISION. All rights reserved.
  • Page 6 HW_GetCurrentAbsoluteTime() ..............47 5.1.52. HW_LocateByAbsoluteTime() ................ 47 5.1.53. HW_LocateByFrameNumber()............... 48 5.1.54. HW_InputDataByFrame(int hChannel,char* pBuf,int nSize) ......48 5.1.55 Avoid the flash of the image while decoding........... 48 5.1.56. RegisterDecoderVideoCaptureCallback()............48 5.1.57. HW_SetDecoderVideoCapture() ..............49 © 2006-2010 by HIKVISION. All rights reserved.
  • Page 7: Hikvision Card Overview

    It is a bridge between digital and analog system, and strongly support concentrative digital surveillance solution. The SDK of Hikvision DS-4000 series card is made up of encoding system SDK, network SDK and player SDK. This manual especially describes encode system SDK and decode system SDK, as to the other SDK you can refer to the relevant documents.
  • Page 8 CIF/QCIF encoding. DS-4216HFVI supports 16 channels 4CIF/2CIF/CIF/QCIF real-time encoding and 16 sub channels CIF/QCIF encoding. Note: Reboot your computer after the driver installed. Demo program included in our SDK must run on XWINDOW. © 2006-2010 by HIKVISION. All rights reserved.
  • Page 9: Sdk Version Update

    6. Fixed bugs that when grab BMP, the image maybe dislocation, and when grab Jpg image, the operation may be timeout and can‘t be resumed. 7. Fixed image decoded by DS-400xMDI will be corrupted, including NTSC QCIF image. New Function: © 2006-2010 by HIKVISION. All rights reserved.
  • Page 10 6. There have watchdog In DS4016HCSI. You could call SetWatchDog() to enable it. The DS4002MD and DS4004MD: H.264 High Resolution Video & Audio Matrix Decode Board Decode function: 1. Each DS4002MDI can realize 4 channels QCIF,CIF,2CIF or 3 channels DCIF, 2 channel © 2006-2010 by HIKVISION. All rights reserved.
  • Page 11 6. Support the mixed insert of HI series board, HCI series board and MDI board in one PC. 7. Within one SDK, it can simultaneously support HI, HCI and MDI board. 8. Most of the API in decoding part can be compatible with the SDK of previous Hikvision‘s decode card DS-4004D.
  • Page 12: Data Structure Definition

    3.4 Frame data Stat. typedef struct tagFramsStatistics{ ULONG VideoFrames; Video frame ULONG AudioFrames; Audio frame ULONG FramesLost; Lost frame ULONG QueueOverflow; Buffer overflow }FRAMES_STATISTICS, *PFRAMES_STATISTICS; 3.5 The preview rectangle typedef struct tagRect{ short RectTop; © 2006-2010 by HIKVISION. All rights reserved.
  • Page 13 576/32=18 lines (in PAL). The corresponding width of 0-21 unit of the DWORD is 704/32=22 rows. Among them, 1 means motion and o still, and can also call the original analyses result of MotionAnalyzer(). © 2006-2010 by HIKVISION. All rights reserved.
  • Page 14: Encoding Card Sdk

    Set the parameter for the video as luminance, saturation, contrast,: SetVideoPara() F.Motion detection mode 1 Set the precision for the detect: AdjustMotionDetectPrecision() Set the area and amount: SetupMotionDetection() Start motion detect: StartMotionDetection() Analyzer: MotionAnalyzer() G.Motion detection mode 2 Set motion detection: SetupMotionDetectionEx() © 2006-2010 by HIKVISION. All rights reserved.
  • Page 15: Channelclose()

    Release resource: DeInitDSPs() The SetStreamType() and SetSubStreamType () could not be called while encoding. Others setting as video parameters, OSD、 Logo、 image format、 frame rate、 bit rate、 coefficient all could be called while encoding. © 2006-2010 by HIKVISION. All rights reserved.
  • Page 16 The callback function will return encoded frame and Motion detection Frame. Explanation: Open channels and get operation handle. All operations related with this channel need use this handle; Return value: >=0 —success and it is channel handle; -1 – failed; © 2006-2010 by HIKVISION. All rights reserved.
  • Page 17 //the encode channel count in the board UINT firstEncodeChannelIndex; //index of first encode channel UINT decodeChannelCount; //the decode channel count in the board UINT firstDecodeChannelIndex; //the index for the first decoding channel UINT displayChannelCount; //the display channel count © 2006-2010 by HIKVISION. All rights reserved.
  • Page 18 Get the encode channel count in the system. Return value: The total number of encoding channels; 4.2.12. int GetDecodeChannelCount() Explanation: Get the decode channel count in the system. Return value: The total number of decoding channels; © 2006-2010 by HIKVISION. All rights reserved.
  • Page 19 4.2.15. int GetCapability(int hChannelHandle, CHANNEL_CAPABILITY *Capability); Parameter: int channelHandle channel handle CHANNEL_CAPABILITY *Capability refer to section 3.3 Explanation: Get the information of special function of the board; Return value: 0—success; -1 – failed; © 2006-2010 by HIKVISION. All rights reserved.
  • Page 20 4.2.19. int GetVideoPara(int channelHandle, VideoStandard_t *VideoStandard, int *Brightness, int *Contrast, int *Saturation, int *Hue); Parameter: int channelHandle window handle; VideoStandard_t *VideoStandard video format (refer to section 2.3); int *Brightness pointer of Brightness value (0--255); © 2006-2010 by HIKVISION. All rights reserved.
  • Page 21 To get stream type; Return value: 0 – success; -1 - fail; 4.2.23. int SetSubStreamType (HANDLE hChannelHandle, int type) Parameter: int channelHandle channel handle int type stream type as the master channel Explanation: © 2006-2010 by HIKVISION. All rights reserved.
  • Page 22 0—success; -1 – failed; 4.2.27. int StartSubVideoCapture(int channelHandle) Parameter: int channelHandle channel handle Explanation: To start the sub-channel video capture Return value: 0—success; -1 – failed; 4.2.28. int StopSubVideoCapture(int channelHandle) Parameter: int channelHandle channel handle © 2006-2010 by HIKVISION. All rights reserved.
  • Page 23 MPEG standard. The lower the quantitative coefficient is, the better the quality and the higher the bit rate. On the contrary, the worse the quality is and the lower the bit rate. © 2006-2010 by HIKVISION. All rights reserved.
  • Page 24 While if the data stream is smaller than the maximum baud rate then DSP don‘t bother it; the adjustable error is <10%; Return value: 0—success; -1 – failed; 4.2.34. int SetBitrateControlMode(int channelHandle, BitrateControlType_t brc) Parameter: int channelHandle channel handle © 2006-2010 by HIKVISION. All rights reserved.
  • Page 25 The format for all video output channel will adopt the defaulted format when the system startup. Note: this function can only be run before system initialization (calling InitDSPs), or it is invalid. 4.2.37. int SetVideoDetectPrecision(int hChannelHandle,unsigned int value) Parameter: int hChannelHandle channel handle; int value precision Explanation: © 2006-2010 by HIKVISION. All rights reserved.
  • Page 26 OSD string over active video. int twinkleInterval when the value is 1, brightness of OSD will be adjusted according to brightness of background. When background is too bright, brightness of OSD will be lower © 2006-2010 by HIKVISION. All rights reserved.
  • Page 27 Enable or disable the OSD. It can make the currently system time(such as year , month , day ,hour ,minute and second ) or custom string overlay with the real-time active video window, translucent processing is also permitted. © 2006-2010 by HIKVISION. All rights reserved.
  • Page 28 Note: For the location will be changed as the picture format. If the location is changed, some char will exceed the range of the image then it will be not display. But the call will be return ok. © 2006-2010 by HIKVISION. All rights reserved.
  • Page 29 (0-575) int w width (0-128) (the size of it must be the same as the width of the original image ) int h height (0-128) © 2006-2010 by HIKVISION. All rights reserved.
  • Page 30 (0-6) int iFastMotionDetectFps frame interval of high speed motion detection (0-12) , the value 0 is means there is no need of high motion detection and usually it is 2 © 2006-2010 by HIKVISION. All rights reserved.
  • Page 31 SDK refer to section 2.5 for the motion information format; Notes: Motion detection and the encoding are independent from each other; the user program can run motion detection under the condition of no running encoding program. Return value: 0—success; -1 – failed; © 2006-2010 by HIKVISION. All rights reserved.
  • Page 32 (>13) , the value of 0 is means there is no need of low speed motion detection UINT delay The delay after the last motion detect RECT *rectList rectangle array iAreas number of rectangle © 2006-2010 by HIKVISION. All rights reserved.
  • Page 33 Return value: >0 – sound level; -1 - fail; 4.2.58. int RegisterImageStreamCallback(IMAGE_STREAM_CALLBACK, void *context) Parameter: IMAGE_STREAM_CALLBACK callback function © 2006-2010 by HIKVISION. All rights reserved.
  • Page 34 Explanation: To get the original image. The original image of DS40xxHCI is the standard 4CIF format (including QCIF encoding), the user program can call SaveYUVToBmpFile to create 24 byte bmp file. Return value: © 2006-2010 by HIKVISION. All rights reserved.
  • Page 35 DS-42xxHCI card supports CIF JPEG image; DS-42xxHFVI card supports 4CIF JPEG image; DS-40xxHSI card supports CIF JPEG image; DS-40xxHCI/HCSI card supports 4CIF JPEG image. 4.2.63. int SetupSubChannel(int channelHandle, int iSubChannel); Parameter: int channelHandle channel handle int iSubChannel subchannel © 2006-2010 by HIKVISION. All rights reserved.
  • Page 36 Explanation: Force the current frame encode as I frame. We can read this I frame from data stream and used in the internet transmission independently. Return value: 0—success; -1 – failed; © 2006-2010 by HIKVISION. All rights reserved.
  • Page 37 0 means use the timer to sync the preview mode NORMAL_SIZE, D1_SIZE, DCIF_SIZE, QCIF_SIZE, MINI_SIZE The definition as follows: #define NORMAL_SIZE /* just not change */ #define D1_SIZE /* 704 x 576 */ #define DCIF_SIZE /* 528 x 288 */ © 2006-2010 by HIKVISION. All rights reserved.
  • Page 38 Output channel that can be 0 only. Return Values: If the function succeeds, the return value is 0. If the function fails, the return value is -1. Remarks: Only DS-42xxHFVI Card support this function © 2006-2010 by HIKVISION. All rights reserved.
  • Page 39 5.1.5. int HW_OpenStream(int hChannel,char* pFileHead,int nHeadSize); Explanation: Open the interface for the Stream mode(just as open the file) ; Parameter: hChannel channel handler pFileHead the data for the file head; nHeadSize the length for the file head; © 2006-2010 by HIKVISION. All rights reserved.
  • Page 40 Parameter: hChannel channel handler; 5.1.10. int HW_Play(int hChannel); Explanation: Start decoding; Parameter: hChannel channel handler; 5.1.11. int HW_Stop(int hChannel); Explanation: Stop decoding; Parameter: hChannel channel handler; 5.1.12. int HW_Pause(int hChannel ,ULONG bPause); Explanation: © 2006-2010 by HIKVISION. All rights reserved.
  • Page 41 5.1.17. int HW_StopCapFile(int hChannel); Explanation: Stop capturing Parameter: hChannel channel handler 5.1.18. int HW_GetPictureSize(int hChannel,ULONG* pWidth, ULONG* pHeight); Explanation: Get the size of the picture Parameter: hChannel channel handler *pWidth width for the picture © 2006-2010 by HIKVISION. All rights reserved.
  • Page 42 -4 is stop,then call with HW_Pause(hChannel,0) could play just one frame -3 ------ 1/8 -2 ------ 1/4 -1 ------ 1/2 0 ------ normal 1 ------ 2 double fast 2 ------ 4 multiple fast 3 -------8 multiple fast 4 ------- the highest speed Parameter: © 2006-2010 by HIKVISION. All rights reserved.
  • Page 43 JUMP_BACKWARD: back; 5.1.27. int HW_GetVersion(PHW_VERSION pVersion); Explanation: Get the information for the version Parameter: pVersion information, describe as follow typedef struct { ULONG DspVersion, DspBuildNum; ULONG DriverVersion, DriverBuildNum; ULONG SDKVersion, SDKBuildNum; }HW_VERSION, *PHW_VERSION; © 2006-2010 by HIKVISION. All rights reserved.
  • Page 44 Explanation: Get the current time Parameter: hChannel; channel handler times(ms) ; * pFrameTime 5.1.33. int HW_GetPlayedFrames(int hChannel,ULONG *pDecVFrames); Explanation: Get the frame counts that have decoded Parameter: hChannel channel handler; *pDecVFrames frame counts © 2006-2010 by HIKVISION. All rights reserved.
  • Page 45 Start video display on the Vga;Just as the function StartVideoPreview() Please refer to the Section4.16 Parameter: pPreviewConf Please refer to the section 4.16 useSyncSem If set, the sdk will post pPreviewConf->SyncSem when decode one frame 5.1.39. int HW_StopDecChanVgaDisplay(int hChannel); Explanation: Stop video display © 2006-2010 by HIKVISION. All rights reserved.
  • Page 46 + 2 QCIF areas ErrorCodeInvalidDevice:nDisplayChannel is overflow ErrorCodeInvalidArgument:nRegionCount is overflow,or pParam is error or the area overstep the limit. 5.1.42. int ClearDisplayRegion (UINT nDisplayChannel,UINT nRegionFlag) Parameter: UINT nDisplayChannel the index for the display channel © 2006-2010 by HIKVISION. All rights reserved.
  • Page 47 0,1,2 or 3.The Sdk will close the former audio output before start new data output 5.1.46. int SetDecoderVideoOutput(UINT nDecodeChannel,UINT nPort,UINT bOpen,UINT nDisplayChannel,UINT nDisplayRegion,UINT nReserved) Parameter: UINT nDecodeChannel the index for the decode channel UINT nPort the output port for the decode © 2006-2010 by HIKVISION. All rights reserved.
  • Page 48 2 port output. So the nPort must be 0 or 1. This API is fit for combination use of DS-40xxHCI and MDI card, or DS-42xxHFVI card. But DS-42xxHFVI card only output single channel and nPort should be 0. New API in v4.1 SDK © 2006-2010 by HIKVISION. All rights reserved.
  • Page 49 Locate the playing by absolute time. It will be valid after set the index and on file mode Note:the millisecond in the struct SYSTEMTIME is invalid now and always is 0. And the begin time could get by calling HW_GetFileAbsoluteTime() © 2006-2010 by HIKVISION. All rights reserved.
  • Page 50 UINT nChannelNumber, void *DataBuf, UINT width, UINT height, UINT nFrameNum, UINT nFrameTime, SYSTEMTIME*pFrameAbsoluteTime, void *context) UINT nChannelNumber Channel handle void *DataBuf Address of buffer UINT width Width of image UINT height Height of image © 2006-2010 by HIKVISION. All rights reserved.
  • Page 51 Start or stop grabbing decoded data in yuv420 format. Parameters: HANDLE hChannel Channel handle BOOL bStart Start or Stop grabbing. UINT param Reserved, value is 0 Return Value: Return 0 if successful, return error code if failed. © 2006-2010 by HIKVISION. All rights reserved.

Table of Contents