39#ifndef _vpOccipitalStructure_h_
40#define _vpOccipitalStructure_h_
42#include <visp3/core/vpConfig.h>
44#if defined(VISP_HAVE_OCCIPITAL_STRUCTURE) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
45#include <condition_variable>
48#include <ST/CaptureSession.h>
51#include <pcl/common/common_headers.h>
54#include <visp3/core/vpCameraParameters.h>
55#include <visp3/core/vpImage.h>
201#ifndef DOXYGEN_SHOULD_SKIP_THIS
202struct SessionDelegate : ST::CaptureSessionDelegate
204 std::mutex m_sampleLock;
205 std::condition_variable cv_sampleLock;
207 ST::ColorFrame m_visibleFrame;
208 ST::DepthFrame m_depthFrame;
209 ST::InfraredFrame m_infraredFrame;
210 ST::AccelerometerEvent m_accelerometerEvent;
211 ST::GyroscopeEvent m_gyroscopeEvent;
212 ST::StructureCoreCameraType m_cameraType;
213 ST::CaptureSessionUSBVersion m_USBVersion;
214 std::string m_serialNumber;
216 ~SessionDelegate() { }
218 void captureSessionEventDidOccur(ST::CaptureSession *session, ST::CaptureSessionEventId event)
override
221 case ST::CaptureSessionEventId::Booting:
223 case ST::CaptureSessionEventId::Connected:
224 printf(
"Starting streams...\n");
225 session->startStreaming();
231 m_USBVersion = session->USBVersion();
232 m_serialNumber = session->sensorInfo().serialNumber;
233 m_cameraType = session->getCameraType();
235 case ST::CaptureSessionEventId::Disconnected:
237 case ST::CaptureSessionEventId::Error:
241 printf(
"Capture session event unhandled\n");
245 void captureSessionDidOutputSample(ST::CaptureSession *,
const ST::CaptureSessionSample &sample)
override
248 std::lock_guard<std::mutex> u(m_sampleLock);
251 if (sample.visibleFrame.isValid())
252 m_visibleFrame = sample.visibleFrame;
254 if (sample.depthFrame.isValid())
255 m_depthFrame = sample.depthFrame;
257 if (sample.infraredFrame.isValid())
258 m_infraredFrame = sample.infraredFrame;
260 if (sample.type == ST::CaptureSessionSample::Type::AccelerometerEvent)
261 m_accelerometerEvent = sample.accelerometerEvent;
263 if (sample.type == ST::CaptureSessionSample::Type::GyroscopeEvent)
264 m_gyroscopeEvent = sample.gyroscopeEvent;
268 cv_sampleLock.notify_one();
282 } vpOccipitalStructureStream;
284 vpOccipitalStructure();
285 ~vpOccipitalStructure();
287 void acquire(vpImage<unsigned char> &gray,
bool undistorted =
false,
double *ts = NULL);
288 void acquire(vpImage<vpRGBa> &rgb,
bool undistorted =
false,
double *ts = NULL);
290 void acquire(vpImage<vpRGBa> *rgb, vpImage<vpRGBa> *depth, vpColVector *acceleration_data = NULL,
291 vpColVector *gyroscope_data = NULL,
bool undistorted =
false,
double *ts = NULL);
292 void acquire(vpImage<unsigned char> *gray, vpImage<vpRGBa> *depth, vpColVector *acceleration_data = NULL,
293 vpColVector *gyroscope_data = NULL,
bool undistorted =
false,
double *ts = NULL);
295 void acquire(
unsigned char *
const data_image,
unsigned char *
const data_depth,
296 std::vector<vpColVector> *
const data_pointCloud = NULL,
unsigned char *
const data_infrared = NULL,
297 vpColVector *acceleration_data = NULL, vpColVector *gyroscope_data = NULL,
bool undistorted =
true,
301 void acquire(
unsigned char *
const data_image,
unsigned char *
const data_depth,
302 std::vector<vpColVector> *
const data_pointCloud, pcl::PointCloud<pcl::PointXYZ>::Ptr &pointcloud,
303 unsigned char *
const data_infrared = NULL, vpColVector *acceleration_data = NULL,
304 vpColVector *gyroscope_data = NULL,
bool undistorted =
true,
double *ts = NULL);
305 void acquire(
unsigned char *
const data_image,
unsigned char *
const data_depth,
306 std::vector<vpColVector> *
const data_pointCloud, pcl::PointCloud<pcl::PointXYZRGB>::Ptr &pointcloud,
307 unsigned char *
const data_infrared = NULL, vpColVector *acceleration_data = NULL,
308 vpColVector *gyroscope_data = NULL,
bool undistorted =
true,
double *ts = NULL);
311 void getIMUVelocity(vpColVector *imu_vel,
double *ts);
312 void getIMUAcceleration(vpColVector *imu_acc,
double *ts);
313 void getIMUData(vpColVector *imu_vel, vpColVector *imu_acc,
double *ts = NULL);
315 bool open(
const ST::CaptureSessionSettings &settings);
321 ST::StructureCoreCameraType getCameraType()
const {
return m_delegate.m_cameraType; }
323 ST::CaptureSessionUSBVersion getUSBVersion()
const {
return m_delegate.m_USBVersion; }
324 std::string getSerialNumber()
const {
return m_delegate.m_serialNumber; }
325 ST::CaptureSession &getCaptureSession() {
return m_captureSession; }
326 ST::CaptureSessionSettings &getCaptureSessionSettings() {
return m_captureSessionSettings; }
328 unsigned int getWidth(vpOccipitalStructureStream stream_type);
329 unsigned int getHeight(vpOccipitalStructureStream stream_type);
332 float getDepth(
int x,
int y);
334 vpPoint unprojectPoint(
int row,
int col);
336 vpHomogeneousMatrix getTransform(
const vpOccipitalStructureStream from,
const vpOccipitalStructureStream to);
338 ST::Intrinsics getIntrinsics(
const vpOccipitalStructureStream stream_type)
const;
340 vpCameraParameters getCameraParameters(
341 const vpOccipitalStructureStream stream_type,
344 void saveDepthImageAsPointCloudMesh(std::string &filename);
348 float m_invalidDepthValue;
351 ST::CaptureSession m_captureSession;
352 ST::CaptureSessionSettings m_captureSessionSettings;
353 SessionDelegate m_delegate;
354 vpCameraParameters m_visible_camera_parameters, m_depth_camera_parameters;
356 void getPointcloud(std::vector<vpColVector> &pointcloud);
358 void getPointcloud(pcl::PointCloud<pcl::PointXYZ>::Ptr &pointcloud);
359 void getColoredPointcloud(pcl::PointCloud<pcl::PointXYZRGB>::Ptr &pointcloud);
vpCameraParametersProjType
@ perspectiveProjWithoutDistortion
Perspective projection without distortion model.
error that can be emitted by ViSP classes.
VISP_EXPORT int wait(double t0, double t)