ONVIF的抓图

    IPC抓拍是个很重要的功能,比如在报警视频联动中需要一张实时的图片,很多SDK不提供抓拍功能,而通过预览抓图,得到的图片已不具有实时性,哪如何得到实时的图片呢?
    现在的IPC基本上都支持ONVIF协议,ONVIF协议除了提供RTSP的URL外,其实也给出了抓拍的URL,从Media的GetSnapshotUri获取,如下:
Description:
A client uses the GetSnapshotUri command to obtain a JPEG snapshot from the device. The returned URI shall remain valid indefinitely even if the profile is changed. The ValidUntilConnect, ValidUntilReboot and Timeout Parameter shall be set accordingly (ValidUntilConnect=false, ValidUntilReboot=false, timeout=PT0S). The URI can be used for acquiring a JPEG image through a HTTP GET operation. The image encoding will always be JPEG regardless of the encoding setting in the media profile. The Jpeg settings (like resolution or quality) may be taken from the profile if suitable. The provided image will be updated automatically and independent from calls to

GetSnapshotUri.

Output:[GetSnapshotUriResponse]
■MediaUri [MediaUri]
■Uri [anyURI]
Stable Uri to be used for requesting the media stream
■InvalidAfterConnect [boolean]
Indicates if the Uri is only valid until the connection is established. The value shall be set to "false".
■InvalidAfterReboot [boolean]
Indicates if the Uri is invalid after a reboot of the device. The value shall be set to "false".
■Timeout [duration]
Duration how long the Uri is valid. This parameter shall be set to PT0S to indicate that this stream URI is indefinitely valid even if the profile changes
    比如:我从测试相机获得的抓拍URL为:http://172.16.200.24/cgi-bin/jpg/image.cgi
    那如何通过这个地址获得图片呢,其实描述中已经提到,“The URI can be used for acquiring a JPEG image through a HTTP GET operation”,也就是通过HTTP的GET方式获得JPEG图片。
    首先配置一路子码流为MJPEG,如:配3路码率,主码流为H264,子码流为H264和MJPEG;在浏览器上输入得到的抓图URL“http://172.16.200.24/cgi-bin/jpg/image.cgi”,这时会显示出图片,刷新,图片会变化。
    那如何通过C++得到图片呢?MFC里有CInternetSession,CHttpConnection,CHttpFile这些类提供通过HTTP获得数据,其实底层还是调用InternetOpen等WinInet函数,代码详见:http://download.csdn.net/detail/evsqiezi/7027629

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

山西茄子

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值