-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathV4L2Camera.h
executable file
·100 lines (72 loc) · 1.87 KB
/
V4L2Camera.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Author: Niels Keeman <nielskeeman@gmail.com>
*
*/
#ifndef _V4L2CAMERA_H
#define _V4L2CAMERA_H
#define NB_BUFFER 3
#define PROPERTY_VALUE_MAX 10
#define IMG_WIDTH 640
#define IMG_HEIGHT 480
#include <linux/videodev2.h>
#include "Thread.h"
struct buffer {
void * start;
size_t length;
};
struct vdIn {
struct v4l2_capability cap;
struct v4l2_fmtdesc FmtDesc;
struct v4l2_format format;
struct v4l2_buffer buf;
struct v4l2_requestbuffers rb;
void *mem[NB_BUFFER];
bool isStreaming;
int width;
int height;
int formatIn;
int framesizeIn;
};
typedef void (*ThreadFunc_t)();
class CameraThread : public Thread{
public:
CameraThread(ThreadFunc_t p_func):task(p_func){
start();}
virtual ~CameraThread(){}
virtual void run();
private:
ThreadFunc_t task;
};
class V4L2Camera {
public:
V4L2Camera();
~V4L2Camera();
int Open (const char *device);
void Close ();
int Init ();
void Uninit ();
int StartStreaming ();
int StopStreaming ();
void GrabPreviewFrame ();
char *GrabRawFrame();
void ProcessRawFrameDone();
//sp<IMemory> GrabJpegFrame ();
friend void getFrameThread(V4L2Camera mobject);
int getUVCData();
void start();
int setParameters(const int width, const int height, const int pixelformat);
int tryParameters(const int width, const int height, const int pixelformat);
char *getDeviceName();
struct vdIn *videoIn;
Thread *thread_get;
private:
int fd;
int nQueued;
int nDequeued;
};
#endif