This commit is contained in:
bmy
2024-07-01 01:30:45 +08:00
parent 4b33e55c57
commit 564fd4439f
3 changed files with 25 additions and 12 deletions

View File

@@ -70,6 +70,7 @@ void capture::run(void)
*cap >> frame; *cap >> frame;
if (frame.empty()) if (frame.empty())
{ {
// TODO 尝试返回缓存帧,并重新启动 capture
log_error("empty frame"); log_error("empty frame");
break; break;
} }
@@ -79,14 +80,15 @@ void capture::run(void)
{ {
frame = frame.clone().reshape(1, frame.total()); frame = frame.clone().reshape(1, frame.total());
} }
// 中心翻转处理
if (flip) if (flip)
{ {
cv::flip(frame, frame, -1); 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<uchar> std::vector<uchar>
@@ -112,6 +114,8 @@ void capture::run(void)
cv::waitKey(1); cv::waitKey(1);
// usleep(20000); // usleep(20000);
} }
log_error("capture exit");
} }
bool capture::is_open(void) bool capture::is_open(void)

View File

@@ -1,10 +1,10 @@
[server] [server]
server_0_index = 6 server_0_index = 10
server_0_port = 5555 server_0_port = 5555
server_1_index = 7 server_1_index = 15
server_1_port = 5556 server_1_port = 5556
server_2_index = 4 server_2_index = 20
server_2_port = 5557 server_2_port = 5557

21
main.cc
View File

@@ -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_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_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_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_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 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 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(); cap0.start();
cap1.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) // while (true)
// { // {
// cap >> frame; // cap >> frame;