forked from dusty-nv/jetson-inference
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathgstCamera.h
70 lines (49 loc) · 1.36 KB
/
gstCamera.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
/*
* inference-101
*/
#ifndef __GSTREAMER_CAMERA_H__
#define __GSTREAMER_CAMERA_H__
#include <gst/gst.h>
#include <string>
#include "camera.h"
struct _GstAppSink;
class QWaitCondition;
class QMutex;
/**
* gstreamer CSI camera using nvcamerasrc
*/
class gstCamera : public camera
{
public:
static gstCamera* Create();
static gstCamera* Create(std::string pipeline, int height, int width);
gstCamera(int height, int width);
~gstCamera();
bool Open();
void Close();
// Capture YUV (NV12)
bool Capture( void** cpu, void** cuda, unsigned long timeout=ULONG_MAX );
private:
static void onEOS(_GstAppSink* sink, void* user_data);
static GstFlowReturn onPreroll(_GstAppSink* sink, void* user_data);
static GstFlowReturn onBuffer(_GstAppSink* sink, void* user_data);
gstCamera();
bool init(std::string pipeline);
bool buildLaunchStr(std::string pipeline);
void checkMsgBus();
void checkBuffer();
_GstBus* mBus;
_GstAppSink* mAppSink;
_GstElement* mPipeline;
std::string mLaunchStr;
static bool mOnboardCamera;
static const uint32_t NUM_RINGBUFFERS = 4;
void* mRingbufferCPU[NUM_RINGBUFFERS];
void* mRingbufferGPU[NUM_RINGBUFFERS];
QWaitCondition* mWaitEvent;
QMutex* mWaitMutex;
QMutex* mRingMutex;
uint32_t mLatestRingbuffer;
bool mLatestRetrieved;
};
#endif