Capture the Ipcamera image of the sea Conway and turn it into an image that OPENCV can handle (ii)

Source: Internet
Author: User
Tags call back

Hai Kang wei visual ipcamera image capture

Capture the Ipcamera image and turn it into a OPENCV can be processed iplimage image (i)

Capture the Ipcamera image and turn it into a OPENCV can be processed iplimage image (ii)


Use of the Hai Kang Wei video camera model: ds-2cd4026fwd-(A) (P)


Hai Kang Wei visual ipcamera image capture method has two kinds:

(1) Use the net_dvr_capturejpegpicture_new inside the SDK to carry on the video capture picture

(2) capture real time stream, decode real time stream into YV12, then convert to RGB


In my last blog post, I introduced the first method, but since net_dvr_capturejpegpicture_new the function takes a long time and cannot be real-time, the second method must be continued.

In this blog post, I'll introduce the second method to convert the captured Ipcamera camera image into a iplimage image that OPENCV can handle.


In the implementation of the capture Hai Kang Wei view ipcamera image, into OpenCV can be processed iplimage image (a) inside the method, found that can not be real-time, this system I want to do for people to see, is to need real-time demo, this kind of affirmation is not. Tangled for a long time. Then look at Hai Kang Wei as the "Equipment Network SDK use manual _v4.2", which has a preview module sample program, unfortunately I have been unable to run, reported the error is Procgetconsolewindow The Getconsolewindow in the Getconsolewindow is redefined and has been successfully debugged.


There is no way, play Hai Kang customer service, but Haikang customer service I really have no language, Beijing completely cannot connect, direct dozen Hangzhou, played four or five times finally a person to answer the phone, the other party does not understand, and then said that an engineer to call back. OK, it's finally back. He told me Http://www.hikvision.com/cn/download_more_401.html here is a routine, with a functional example. Suddenly have hope, routine is VC6.0 project, changed some place, finally can run. So, his MFC project related to the code out, reorganization. Then realize the capture YV12 format video stream function, light has YV12 or not, need to turn YV12 into Yuv4:4:4, and then convert the YUV chroma space into RGB chroma space, this process is in the letter Decbfun callback function (callback function please see here.) ) inside the execution.


Not much to say, on the code.


#include <cstdio> #include <cstring> #include <iostream> #include "Windows.h" #include "HCNetSDK.h" Include "PlayM4.h" #include <opencv2\opencv.hpp> #include "cv.h" #include "highgui.h" #include <time.h>
Define Usecolor 1 using namespace std;

using namespace Std;
--------------------------------------------int Ipicnum=0;//set Channel NO.
LONG Nport=-1;


HWND Hwnd=null;
   void Yv12toyuv (char *outyuv, char *inyv12, int width, int height,int widthstep) {int col,row;
   unsigned int y,u,v;
   int tmp;

  int idx;

   printf ("widthstep=%d.\n", widthstep);
      For (row=0 row 


The image can finally be captured in real time and transformed into an image format that OPENCV can handle.

A lot of information was searched in the process, but there was no place to elaborate, but eventually it was solved.

Additional instructions: If you end up with image processing rather than just displaying the captured images like I do, the following statements are not needed.       #if usecolor cvreleaseimage (&PIMGYCRCB);   Cvreleaseimage (&PIMG);   #else cvreleaseimage (&PIMG); #endif

PostScript: Although this function is implemented, how to combine with my image processing functions. I was thinking of using a chain queue, two threads. Chain Queue Code please look here.


The purpose of writing these two posts is to allow developers in the exploration process to take fewer detours, save time, and sincerely hope that this article can help you.


because I have graduated, the project has already been a knot, on hand no longer have the hardware equipment to debug, so for everyone encountered problems, I basically also have no answer, very sorry. If you are in the development of the Hai Kang Wei video camera in the process of what problems can go with Haikang customer service to communicate, if you are in the area of customer service can not contact, please contact the headquarters of Hangzhou customer service.

Finally, I apologize for the long time that we have been ignoring the questions that have been raised. Thank you for your support.


**************************************************************************************

Reprint please indicate the source: http://blog.csdn.net/wanghuiqi2008/article/details/31410509

**************************************************************************************




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.