| Version 5 (modified by , 21 months ago) ( diff ) |
|---|
IP Cameras
The 825gen2 includes the wget and curl command line utility and the curl libraries.
Most IP cameras provide a URL that can be used to obtain a still image such as a jpeg format file. The wget command line utility may be used to obtain the image such as:
wget 10.1.3.25:/cgi-bin/viewer/video.jpg?resolution=640x480 -O /tmp/img.jpg
This could be performed from a system call in an app. A better approach is to use the curl library. Following is an example:
#include "cardinal825.h"
#include <curl/curl.h>
size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream)
{
size_t written = fwrite(ptr, size, nmemb, stream);
return written;
}
void CaptureImage(int tktNum, const char* code)
{
char imgfilepath[120];
CURL *curl;
FILE *fp;
CURLcode res;
DEBUG_MSG("%s tktNum %d code [%s]\n", __FUNCTION__, tktNum, code);
curl = curl_easy_init();
if(curl) {
sprintf_s(imgfilepath, _imgfilefmt, tktNum, code);
fp = fopen(imgfilepath, "wb");
curl_easy_setopt(curl, CURLOPT_URL, /*CAMERA_SNAP_URL*/ _cameraSnapURL);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
res = curl_easy_perform(curl);
if(res != CURLE_OK) {
DEBUG_MSG("curl_easy_perform error %d\n", res);
}
curl_easy_cleanup(curl);
fclose(fp);
} else {
DEBUG_MSG("curl_easy_init returned NULL\n");
}
}
Note:
See TracWiki
for help on using the wiki.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/cardinal.gif)