diff --git a/capture.cc b/capture.cc index 09a6ffd..63d3653 100644 --- a/capture.cc +++ b/capture.cc @@ -70,6 +70,7 @@ void capture::run(void) *cap >> frame; if (frame.empty()) { + // TODO 尝试返回缓存帧,并重新启动 capture log_error("empty frame"); break; } @@ -79,14 +80,15 @@ void capture::run(void) { frame = frame.clone().reshape(1, frame.total()); } + + // 中心翻转处理 if (flip) { cv::flip(frame, frame, -1); - // cv::flip(frame, frame, 1); } - cv::cvtColor(frame, dst, cv::COLOR_BGR2RGB); - // cv::imshow(zmq_bind_addr, frame); + // 将图像转换为 rgb + cv::cvtColor(frame, dst, cv::COLOR_BGR2RGB); // 将帧编码后发送 std::vector @@ -112,6 +114,8 @@ void capture::run(void) cv::waitKey(1); // usleep(20000); } + + log_error("capture exit"); } bool capture::is_open(void) diff --git a/config.toml b/config.toml index dc565e6..d895206 100644 --- a/config.toml +++ b/config.toml @@ -1,10 +1,10 @@ [server] -server_0_index = 6 +server_0_index = 10 server_0_port = 5555 -server_1_index = 7 +server_1_index = 15 server_1_port = 5556 -server_2_index = 4 +server_2_index = 20 server_2_port = 5557 diff --git a/main.cc b/main.cc index d4869ee..5fbd6a1 100644 --- a/main.cc +++ b/main.cc @@ -41,23 +41,32 @@ int main(int argc, char **argv) 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"); - toml_datum_t server_2_index = toml_int_in(server, "server_2_index"); + // toml_datum_t server_2_index = toml_int_in(server, "server_2_index"); 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"); - toml_datum_t server_2_port = toml_int_in(server, "server_2_port"); + // toml_datum_t server_2_port = toml_int_in(server, "server_2_port"); capture cap0(server_0_index.u.i, server_0_port.u.i); capture cap1(server_1_index.u.i, server_1_port.u.i, 320, 240, 60, true); - capture cap2(server_2_index.u.i, server_2_port.u.i); + // capture cap2(server_2_index.u.i, server_2_port.u.i); cap0.start(); cap1.start(); - cap2.start(); + // cap2.start(); - while (1) + if (cap0.is_open()) { - usleep(1); + cap0.thread->join(); } + if (cap1.is_open()) + { + cap1.thread->join(); + } + // if (cap2.is_open()) + // { + // cap2.thread->join(); + // } + // while (true) // { // cap >> frame;