#pragma once #include #include #include #define LOG_TRACE(s) utils::to_log(LOG_LEVEL_DEBUG, s.c_str()) #define LOG_ERROR LOG_TRACE class gVideo { public: gVideo(); virtual ~gVideo(); bool is_open(); void close(); void open(int width, int height); void start(); void stop(); void grab(int color, bool bcrrect = false, int timeout = 1000, int flatpara = 0); bool hasframe(); virtual void *read_frame(int timeout, size_t& size, int& ind); // call add_v4l2_memory to put the buffer into the V4L2 queue again int add_v4l2_memory(int ind); int get_mem_count(void); void set_size(int width, int height); protected: bool wait(int msTimeout); virtual void stop_capturing(void); virtual void start_capturing(void); void uninit_device(void); virtual void init_mmap(void); virtual void init_device(void); void close_device(void); void open_device(void); struct buffer { void *start; size_t length; }; const int v4l_buffer_count = 5; int buf_size_ = 0; int v4l_width = 3100; int v4l_height = 3100; std::string dev_name; int fd; std::vector buffers; unsigned int n_buffers; std::mutex m_lock; volatile bool bStart; };