2024-05-24 19:10:41 +08:00
|
|
|
#include <opencv2/opencv.hpp>
|
|
|
|
|
#include <zmq.hpp>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <cstring>
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include "logc/log.h"
|
|
|
|
|
#include "tomlc99/toml.h"
|
|
|
|
|
#include "capture.h"
|
|
|
|
|
|
2024-06-04 12:12:22 +08:00
|
|
|
#define config_file_path "config.toml"
|
2024-05-24 19:10:41 +08:00
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
|
{
|
|
|
|
|
FILE *fp;
|
|
|
|
|
char errbuf[200];
|
|
|
|
|
|
2024-06-04 12:23:09 +08:00
|
|
|
char config_path[200];
|
|
|
|
|
sprintf(config_path, "%s/%s", getcwd(NULL, 0), config_file_path);
|
2024-06-04 12:12:22 +08:00
|
|
|
log_info("load config from %s", config_path);
|
|
|
|
|
fp = fopen(config_path, "r");
|
2024-05-24 19:10:41 +08:00
|
|
|
if (!fp)
|
|
|
|
|
{
|
|
|
|
|
log_error("can not open conifg file");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
toml_table_t *conf = toml_parse_file(fp, errbuf, sizeof(errbuf));
|
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
|
|
if (!conf)
|
|
|
|
|
{
|
|
|
|
|
log_error("cannot parse - %s", errbuf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
toml_table_t *server = toml_table_in(conf, "server");
|
|
|
|
|
if (!server)
|
|
|
|
|
{
|
|
|
|
|
log_error("missing [server]");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
toml_datum_t server_0_index = toml_int_in(server, "server_0_index");
|
|
|
|
|
toml_datum_t server_1_index = toml_int_in(server, "server_1_index");
|
2024-07-01 01:30:45 +08:00
|
|
|
// toml_datum_t server_2_index = toml_int_in(server, "server_2_index");
|
2024-05-24 19:10:41 +08:00
|
|
|
toml_datum_t server_0_port = toml_int_in(server, "server_0_port");
|
|
|
|
|
toml_datum_t server_1_port = toml_int_in(server, "server_1_port");
|
2024-07-01 01:30:45 +08:00
|
|
|
// toml_datum_t server_2_port = toml_int_in(server, "server_2_port");
|
2024-05-24 19:10:41 +08:00
|
|
|
|
|
|
|
|
capture cap0(server_0_index.u.i, server_0_port.u.i);
|
2024-06-17 22:16:28 +08:00
|
|
|
capture cap1(server_1_index.u.i, server_1_port.u.i, 320, 240, 60, true);
|
2024-07-04 17:50:05 +08:00
|
|
|
// capture cap2(server_2_index.u.i, server_2_port.u.i, 640, 480);
|
2024-05-24 19:10:41 +08:00
|
|
|
|
|
|
|
|
cap0.start();
|
2024-05-27 16:00:05 +08:00
|
|
|
cap1.start();
|
2024-07-01 01:30:45 +08:00
|
|
|
// cap2.start();
|
2024-05-24 19:10:41 +08:00
|
|
|
|
2024-07-04 17:50:05 +08:00
|
|
|
cap1.thread_request->join();
|
|
|
|
|
|
2024-05-24 19:10:41 +08:00
|
|
|
return 0;
|
|
|
|
|
}
|