-
Notifications
You must be signed in to change notification settings - Fork 0
/
camera.h
executable file
·68 lines (55 loc) · 2.35 KB
/
camera.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
#pragma once
#include "mmalincludes.h"
#include "cameracontrol.h"
class CCamera;
class CCameraOutput
{
public:
int Width;
int Height;
MMAL_COMPONENT_T* ResizerComponent;
MMAL_CONNECTION_T* Connection;
MMAL_BUFFER_HEADER_T* LockedBuffer;
MMAL_POOL_T* BufferPool;
MMAL_QUEUE_T* OutputQueue;
MMAL_PORT_T* BufferPort;
CCameraOutput();
~CCameraOutput();
bool Init(int width, int height, MMAL_COMPONENT_T* input_component, int input_port_idx, bool do_argb_conversion);
void Release();
void OnVideoBufferCallback(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer);
static void VideoBufferCallback(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer);
int ReadFrame(void* buffer, int buffer_size);
bool BeginReadFrame(const void* &out_buffer, int& out_buffer_size);
void EndReadFrame();
MMAL_POOL_T* EnablePortCallbackAndCreateBufferPool(MMAL_PORT_T* port, MMAL_PORT_BH_CB_T cb, int buffer_count);
MMAL_COMPONENT_T* CreateResizeComponentAndSetupPorts(MMAL_PORT_T* video_output_port, bool do_argb_conversion);
};
class CCamera
{
public:
int ReadFrame(int level, void* buffer, int buffer_size);
bool BeginReadFrame(int level, const void* &out_buffer, int& out_buffer_size);
void EndReadFrame(int level);
private:
CCamera();
~CCamera();
bool Init(int width, int height, int framerate, int num_levels, bool do_argb_conversion, int awbmode = 1, int flipv = 0, int fliph = 0);
void Release();
MMAL_COMPONENT_T* CreateCameraComponentAndSetupPorts();
MMAL_COMPONENT_T* CreateSplitterComponentAndSetupPorts(MMAL_PORT_T* video_ouput_port);
void OnCameraControlCallback(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer);
static void CameraControlCallback(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer);
int Width;
int Height;
int FrameRate;
RASPICAM_CAMERA_PARAMETERS CameraParameters;
MMAL_COMPONENT_T* CameraComponent;
MMAL_COMPONENT_T* SplitterComponent;
MMAL_CONNECTION_T* VidToSplitConn;
CCameraOutput* Outputs[4];
friend CCamera* StartCamera(int width, int height, int framerate, int num_levels, bool do_argb_conversion, int awbmode, int flipv, int fliph);
friend void StopCamera();
};
CCamera* StartCamera(int width, int height, int framerate, int num_levels, bool do_argb_conversion=true, int awbmode = 1, int flipv = 0, int fliph = 0);
void StopCamera();