feat: 增加图像翻转方法

This commit is contained in:
bmy
2024-06-17 22:16:28 +08:00
parent 463c6900df
commit 4b33e55c57
4 changed files with 13 additions and 6 deletions

View File

@@ -9,13 +9,14 @@
#include "logc/log.h" #include "logc/log.h"
#include <unistd.h> #include <unistd.h>
capture::capture(int camera_index, int zmq_port, int width_set, int height_set, int fps_set) capture::capture(int camera_index, int zmq_port, int width_set, int height_set, int fps_set, bool _flip)
{ {
index = camera_index; index = camera_index;
port = zmq_port; port = zmq_port;
width = width_set; width = width_set;
height = height_set; height = height_set;
fps = fps_set; fps = fps_set;
flip = _flip;
log_info("trying open camera %d", index); log_info("trying open camera %d", index);
@@ -78,7 +79,11 @@ void capture::run(void)
{ {
frame = frame.clone().reshape(1, frame.total()); 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::cvtColor(frame, dst, cv::COLOR_BGR2RGB);
// cv::imshow(zmq_bind_addr, frame); // cv::imshow(zmq_bind_addr, frame);

View File

@@ -15,14 +15,16 @@ public:
int height; int height;
int fps; int fps;
bool status = false; bool status = false;
bool flip = false;
char zmq_bind_addr[40] = "tcp://*:"; char zmq_bind_addr[40] = "tcp://*:";
std::thread *thread; std::thread *thread;
cv::VideoCapture *cap; cv::VideoCapture *cap;
cv::Mat frame; cv::Mat frame;
zmq::context_t *context; zmq::context_t *context;
zmq::socket_t *socket; zmq::socket_t *socket;
capture(int camera_index, int zmq_port, int width_set = 320, int height_set = 240, int fps_set = 20); capture(int camera_index, int zmq_port, int width_set = 320, int height_set = 240, int fps_set = 20, bool flip = false);
void start(void); void start(void);
void run(void); void run(void);
bool is_open(void); bool is_open(void);

View File

@@ -1,9 +1,9 @@
[server] [server]
server_0_index = 0 server_0_index = 6
server_0_port = 5555 server_0_port = 5555
server_1_index = 2 server_1_index = 7
server_1_port = 5556 server_1_port = 5556
server_2_index = 4 server_2_index = 4

View File

@@ -47,7 +47,7 @@ int main(int argc, char **argv)
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, 25); 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();