53 lines
1016 B
C
53 lines
1016 B
C
|
#pragma once
|
||
|
#include <string>
|
||
|
#include <vector>
|
||
|
#include <mutex>
|
||
|
|
||
|
#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);
|
||
|
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 v4l_width = 3100;
|
||
|
int v4l_height = 3100;
|
||
|
std::string dev_name;
|
||
|
int fd;
|
||
|
std::vector<buffer> buffers;
|
||
|
unsigned int n_buffers;
|
||
|
std::mutex m_lock;
|
||
|
volatile bool bStart;
|
||
|
};
|