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

别等时光非礼了梦想. 提交于 2019-12-11 03:28:28

问题


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 )


回答1:


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




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/7607492/how-do-i-grab-an-image-retrieved-from-a-camera-via-web-browser

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!