I am doing rotate operation on camera using CURL library.
Here is what I've done so far:
#include <iostream> // For std::cerr
#include <string> // For std::string,getline(),c_str()
#include <curl/curl.h> // For curl library functions like curl_easy_setopt,curl_easy_perform etc.
class camera_image_rotate {
CURL *curl = curl_easy_init();
std::string ipaddress,username,password,url;
int rotation;
CURLcode res;
public:
camera_image_rotate(int x) : rotation(x) {
std::cout<<"Enter ip address: ";
getline(std::cin,ipaddress);
std::cout<<"Enter username: ";
getline(std::cin,username);
username+=":";
std::cout<<username<<'\n';
std::cout<<"Enter password: ";
getline(std::cin,password);
password+="@";
std::cout<<password<<'\n';
ipaddress+="/axis-cgi/jpg/image.cgi?rotation=";
ipaddress+=std::to_string(rotation);
std::cout<<ipaddress<<'\n';
url=username+password+ipaddress;
}
void rotate() {
if(curl) {
res=curl_easy_setopt(curl,CURLOPT_URL,url.c_str());
res=curl_easy_perform(curl);
if(res!=CURLE_OK)
std::cerr<<"Oops, Invalid IP";
}
else {
std::cerr<<"Something went wrong";
}
}
~camera_image_rotate() {
if(res==CURLE_OK)
curl_easy_cleanup(curl);
}
};
int main() {
camera_image_rotate s(90);
s.rotate();
}
Now, the problem I am facing is that when I execute this program it tries to print the rotated image on console so I am getting some completely unreadable output. So, I want to redirect the output of this program to either *.jpg or *.png file. How do I achieve that ? I've referred documentation about CURL on their official site but I didn't find anything useful.
I am using ubuntu OS & clang++ 3.8.0 compiler.