23 #ifndef __GSTREAMER_CAMERA_H__ 24 #define __GSTREAMER_CAMERA_H__ 114 static gstCamera*
Create( uint32_t width, uint32_t height,
const char* camera=NULL );
171 bool Capture(
void** cpu,
void** cuda, uint64_t timeout=UINT64_MAX );
203 bool CaptureRGBA(
float** image, uint64_t timeout=UINT64_MAX,
bool zeroCopy=
false );
229 bool ConvertRGBA(
void* input,
float** output,
bool zeroCopy=
false );
234 inline uint32_t
GetWidth()
const {
return mWidth; }
257 inline uint32_t
GetSize()
const {
return mSize; }
270 static void onEOS(_GstAppSink* sink,
void* user_data);
271 static GstFlowReturn onPreroll(_GstAppSink* sink,
void* user_data);
272 static GstFlowReturn onBuffer(_GstAppSink* sink,
void* user_data);
278 bool parseCameraStr(
const char* camera );
284 _GstAppSink* mAppSink;
285 _GstElement* mPipeline;
288 std::string mLaunchStr;
289 std::string mCameraStr;
296 static const uint32_t NUM_RINGBUFFERS = 16;
298 void* mRingbufferCPU[NUM_RINGBUFFERS];
299 void* mRingbufferGPU[NUM_RINGBUFFERS];
305 uint32_t mLatestRGBA;
306 uint32_t mLatestRingbuffer;
307 bool mLatestRetrieved;
309 void* mRGBA[NUM_RINGBUFFERS];
314 inline bool csiCamera()
const {
return (mSensorCSI >= 0); }
Definition: gstCamera.h:43
uint32_t GetWidth() const
Return the width of the camera.
Definition: gstCamera.h:234
MIPI CSI and V4L2 camera capture using GStreamer and nvarguscamerasrc or v4l2src elements.
Definition: gstCamera.h:70
A lightweight mutual exclusion lock.
Definition: Mutex.h:35
Definition: gstCamera.h:44
bool CaptureRGBA(float **image, uint64_t timeout=UINT64_MAX, bool zeroCopy=false)
Capture the next image frame from the camera and convert it to float4 RGBA format, with pixel intensities ranging between 0.0 and 255.0.
uint32_t GetPixelDepth() const
Return the pixel bit depth of the camera (measured in bits).
Definition: gstCamera.h:246
static const uint32_t DefaultHeight
Default camera height, unless otherwise specified during Create()
Definition: gstCamera.h:267
~gstCamera()
Release the camera interface and resources.
const char * gstCameraSrcToString(gstCameraSrc src)
Stringize function to convert gstCameraSrc enum to text.
gstCameraSrc
Enumeration of camera input source methods.
Definition: gstCamera.h:41
void Close()
Stop streaming the camera.
bool IsStreaming() const
Check if the camera is streaming or not.
Definition: gstCamera.h:146
bool ConvertRGBA(void *input, float **output, bool zeroCopy=false)
Convert an image to float4 RGBA that was previously aquired with Capture().
Definition: gstCamera.h:45
static const uint32_t DefaultWidth
Default camera width, unless otherwise specified during Create()
Definition: gstCamera.h:262
uint32_t GetHeight() const
Return the height of the camera.
Definition: gstCamera.h:239
Event object for signalling other threads.
Definition: Event.h:33
uint32_t GetSize() const
Return the size (in bytes) of a camera frame from Capture().
Definition: gstCamera.h:257
static gstCamera * Create(const char *camera=NULL)
Create a MIPI CSI or V4L2 camera device.
bool Capture(void **cpu, void **cuda, uint64_t timeout=UINT64_MAX)
Capture the next image frame from the camera.
bool Open()
Begin streaming the camera.