Changes between Version 2 and Version 3 of Docs/825gen2/Dev/Networking/IPCameras


Ignore:
Timestamp:
02/16/24 09:53:47 (9 months ago)
Author:
Don Wilson
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Docs/825gen2/Dev/Networking/IPCameras

    v2 v3  
    88wget 10.1.3.25:/cgi-bin/viewer/video.jpg?resolution=640x480 -O /tmp/img.jpg
    99}}}
     10
     11This could be performed from a system call in an app. A better approach is to use the curl library.
     12
     13{{{
     14
     15#include "cardinal825.h"
     16#include <curl/curl.h>
     17
     18
     19size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream)
     20{
     21        size_t written = fwrite(ptr, size, nmemb, stream);
     22        return written;
     23}
     24
     25void CaptureImage(int tktNum, const char* code)
     26{
     27        char imgfilepath[120];
     28        CURL *curl;
     29        FILE *fp;
     30        CURLcode res;
     31
     32        DEBUG_MSG("%s tktNum %d code [%s]\n", __FUNCTION__, tktNum, code);
     33
     34        curl = curl_easy_init();
     35        if(curl) {
     36                sprintf_s(imgfilepath, _imgfilefmt, tktNum, code);
     37                fp = fopen(imgfilepath, "wb");
     38                curl_easy_setopt(curl, CURLOPT_URL, /*CAMERA_SNAP_URL*/ _cameraSnapURL);
     39                curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
     40                curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
     41                res = curl_easy_perform(curl);
     42                if(res != CURLE_OK) {
     43                        DEBUG_MSG("curl_easy_perform error %d\n", res);
     44                }
     45
     46                curl_easy_cleanup(curl);
     47                fclose(fp);
     48
     49        } else {
     50                DEBUG_MSG("curl_easy_init returned NULL\n");
     51        }
     52}
     53
     54}}}