3 Star 1 Fork 2

zpfly/devices

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
demo_highspeed.cc 1.89 KB
一键复制 编辑 原始数据 按行查看 历史
Ming Wang 提交于 2023-05-17 11:34 . highspeed functions
#include "devices.h"
#include "highspeed/highspeed.h"
#include <fstream>
#include <string>
using namespace std;
#define OUT_INHIBIT(is, func) \
if (is) \
freopen("/dev/null", "w", stdout); \
func; \
if (is) \
freopen("/dev/tty", "w", stdout);
static bool neat = true;
int main(int argc, char *argv[])
{
int n;
char *buff;
for (int i = 1; i < argc; ++i) {
if ("--verbose" == string(argv[i]))
neat = false;
if ("-v" == string(argv[i]))
neat = false;
}
n = highspeed::getStatus();
cout << "Status : " << highspeed::statuses[n] << endl;
n = highspeed::init();
cout << endl << "Initialization : " << (n ? "failed" : "ok") << endl;
n = highspeed::getStatus();
cout << "Status : " << highspeed::statuses[n] << endl;
const char *path = DEFAULT_OUTPUT_IMAGE;
OUT_INHIBIT(neat, buff = highspeed::takePicture());
cout << "Take picture :" << path << endl;
ofstream out("/tmp/photo.jpg.b64", ios::out);
if (out.is_open()) {
out << buff << endl;
out.close();
}
delete buff;
OUT_INHIBIT(neat, n = highspeed::setColorStyle(2));
cout << "Set style of color : " << (n ? "failed" : "ok") << endl;
path = "/tmp/photo_bw.jpg";
OUT_INHIBIT(neat, buff = highspeed::takePicture(path));
cout << "Take picture : " << path << endl;
delete buff;
OUT_INHIBIT(neat, highspeed::setColorStyle(0));
OUT_INHIBIT(neat, n = highspeed::rotate(3));
cout << "rotate: " << (n ? "failed" : "ok") << endl;
path = "/tmp/photo_rotate.jpg";
OUT_INHIBIT(neat, buff = highspeed::takePicture(path));
cout << "Take picture : " << path << endl;
delete buff;
OUT_INHIBIT(neat, n = highspeed::close());
cout << "Close camera : " << (n ? "failed" : "ok") << endl;
n = highspeed::getStatus();
cout << "Status : " << highspeed::statuses[n] << endl;
return 0;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/zpflying/devices.git
git@gitee.com:zpflying/devices.git
zpflying
devices
devices
master

搜索帮助