开发者

How do I grab an image retrieved from a camera via web browser?

开发者 https://www.devze.com 2023-04-10 05:13 出处:网络
I have an IP camera that hands me a snapshot of what it is seeing when I enter a specific url which the manual provides. The manual also states that the http response is:

I have an IP camera that hands me a snapshot of what it is seeing when I enter a specific url which the manual provides. The manual also states that the http response is:

HTTP Code: 200 OK
Content-Type: image/jpeg
Content-Length: <image size>
Body:<JPEG image data>

Looking at the 开发者_如何转开发page on Firefox, I can see nothing but the image. I cannot even view its page source. I am hoping this indicates a very simple format to grab with C++.

What I want to do is to write a C++ program that autograbs images from this camera at some time interval (and perhaps even do stuff on the image while it's at it).

What do I need to know to make this happen?

(Note that I have to use C++ EDIT: and linux )


The easiest solution is probably curl. It's even got an example which lacks just the for (;;) { grab(); sleep(60000); } loop.


Provided that you mention "I have to use C++", if Windows is in question then you can use WinHTTP API. You create session and connection to the IP camera web server, then you send HTTP request with URL to get JPEG snapshot, and read back your JPEG image data.


That HTTP statement is an image its self. Except the image data is encoded, and the image has a few textual headers above it. Otherwise it is the equivelent of an image found in a local image file. To grab the file, open a connection to the server, read in the contents and interpret the HTTP request. [It'll tell you about bad requests, the size of the image, etc]

For information on how to grab the resource see this question.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号