c# - Grabbing frames from a Hikvision IP-camera -
i'm having problems grabbing frames remote ip-camera. employer wants done in c# .net (for windows) , if possible use light-weight solution, i.e. not using huge frameworks.
the device model ds-2cd2632f-i, connected lan , camera's web-interface works fine.
i tried out several popular frameworks, e.g. aforge, emgucv, ozekisdk , directshow.net, none of them seem working. particularly ozekisdk (apparently, recommended hikvision?) isn't able video stream camera, if use of sample projects provided, shows black screen , throws "empty camera object" exception if try grab frame.
the camera's web-interface works correctly , vlc player manages play stream camera via rtsp:// link (rtsp://my_ip:554//streaming/channels/1
), without asking login , password.
i thought using libvlcnet, i'm not sure it's viable solution.
do have recommendations?
ok, think figured out. i'll post solution here, in case needs in future. found out, particular type of camera there url, returns current frame camera jpeg picture, looks this: http://ip_address:port/streaming/channels/1/picture?snapshotimagetype=jpeg
since employer needs able grab 1 frame camera whenever wants , doesn't need stream video itself, wrote application copies jpeg url using 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 httpwebrequest).endgetresponse(result) httpwebresponse; stream responsestream = response.getresponsestream(); using (bitmap frame = new bitmap(responsestream)) { if (frame != null) { loadedbitmap = (bitmap) frame.clone(); } } } ... requestframe(); // call function
Comments
Post a Comment