Capturing frames from Hikvision IP camera

I'm having problems capturing frames from a remote IP camera. My employer wants this to be done in C # .NET (for Windows), and if possible use a lightweight solution, i.e. not use any huge framework.

The DS-2CD2632F-I device model that we currently have connected to my local network and the web interface of the camera is working fine.

I've already tried several popular frameworks, for example. AForge, EmguCV, OzekiSDK, and Directshow.NET, but none of them seem to work. In particular, the OzekiSDK (apparently recommended by Hikvision?) Can't get a video stream from the camera, even if I'm just using sample projects that just show a black screen and throw a "Blank camera image" exception if I try to capture a frame.

The web interface of the camera is working correctly, and even VLC Player can successfully play the stream from the camera using the link rtsp: // ( rtsp://my_ip:554//Streaming/Channels/1

), without asking for a username and password.

I was thinking about using libvlcnet, but I'm not sure if this is a viable solution.

Do you have any recommendations?

+3


source to share


2 answers


Ok, so I think I figured it out. I'll post a solution here in case anyone needs it in the future. I found out that there is a url for this particular type of camera that simply returns the current frame from the camera as a JPEG image that looks like this: http://IP_ADDRESS:PORT/Streaming/channels/1/picture?snapShotImageType=JPEG

Since my employer should only be able to grab one frame from the camera whenever he wants, and he doesn't need to stream the video, I just wrote an application that copies this JPEG from this URL using an Async Web-request:



private Bitmap loadedBitmap;
...
private void requestFrame()
{    
 string cameraUrl = @"http://192.168.0.1XX:80/Streaming/channels/1/picture?snapShotImageType=JPEG";
 var request = System.Net.HttpWebRequest.Create(cameraUrl);   
 request.Credentials = new NetworkCredential(cameraLogin, cameraPassword);
 request.Proxy = null;
 request.BeginGetResponse(new AsyncCallback(finishRequestFrame), request);
}

void finishRequestFrame(IAsyncResult result)
{
 HttpWebResponse response = (result.AsyncState as HttpWebRequest).EndGetResponse(result) as HttpWebResponse;
 Stream responseStream = response.GetResponseStream();

 using (Bitmap frame = new Bitmap(responseStream)) {
  if (frame != null) {
   loadedBitmap = (Bitmap) frame.Clone();                        
  }
 }
}
...
requestFrame(); // call the function

      

+5


source


good post !! but do you know how i can live live? I want to put a live stream in a picture box



0


source







All Articles