-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrearcamera.h
133 lines (105 loc) · 2.65 KB
/
rearcamera.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#ifndef REARCAMERA_H_
#define REARCAMERA_H_
#include <stdint.h>
#include <inttypes.h>
#include <sys/inotify.h>
#include <sys/poll.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <math.h>
#include <fcntl.h>
#include <utils/misc.h>
#include <signal.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <cutils/atomic.h>
#include <cutils/properties.h>
#include <androidfw/AssetManager.h>
#include <binder/IPCThreadState.h>
#include <utils/Errors.h>
#include <utils/SystemClock.h>
#include <android-base/properties.h>
#include "android-base/macros.h"
#include <ui/PixelFormat.h>
#include <ui/Rect.h>
#include <ui/Region.h>
#include <ui/DisplayInfo.h>
#include <gui/ISurfaceComposer.h>
#include <gui/Surface.h>
#include <gui/SurfaceComposerClient.h>
#include <algorithm>
#include <glm.hpp>
#include <gtc/matrix_transform.hpp>
#include <gtc/type_ptr.hpp>
#include <hidl/HidlTransportSupport.h>
#include <png.h>
#include "helper.h"
#include "shader.h"
#include "videocapture.h"
#include "sem.h"
#include "dataVehicleListener.h"
namespace android
{
class Surface;
class SurfaceComposerClient;
class SurfaceControl;
} // namespace android
class RearCamera
{
public:
RearCamera();
~RearCamera();
bool initEverything();
void printAll();
private:
//full setup
bool initShadersProgram();
bool initSurface();
bool initSurfaceConfigs();
void initAllTexturesFromPng();
void checkGlError(const char *);
bool loadPngFromPath(const std::string &, const std::string &);
void forwardFrame(v4l2_buffer *, unsigned char *);
void createCameraTexture(const int, const int);
void printTexture(const std::string &, GLfloat, GLfloat, glm::ivec2, glm::vec3);
void refreshCamera();
bool subscribeToVHal(sp<IVehicle>, sp<IVehicleCallback>, VehicleProperty);
bool getGearFromHal(sp<IVehicle> &);
void clearAll();
void startCapture();
void stopCapture();
void notifyGear(bool);
struct Texture
{
std::string name;
std::string path;
GLuint TextureID;
glm::ivec2 Size;
};
private:
android::sp<android::SurfaceComposerClient> mSession;
android::sp<android::SurfaceControl> mFlingerSurfaceControl;
android::sp<android::Surface> mFlingerSurface;
EGLDisplay mDisplay;
EGLDisplay mContext;
EGLDisplay mSharedContext;
EGLDisplay mSurface;
int mSurfaceWidth;
int mSurfaceHeight;
std::map<std::string, Texture> mTextures;
VideoCapture mVideoCapture;
GLuint mProgram;
GLint mColorShaderHandle;
GLint mProjectionShaderHandle;
GLint mTextShaderHandle;
GLuint cameraTexY;
GLuint cameraTexU;
GLuint cameraTexV;
GLuint VBO;
GLuint VAO;
Sem mSem;
android::sp<DataVehicleListener> mGearListener;
bool mShouldRefresh = false;
};
#endif // REARCAMERA_H_