34#ifndef VP_OCCIPITAL_STRUCTURE_H
35#define VP_OCCIPITAL_STRUCTURE_H
37#include <visp3/core/vpConfig.h>
39#if defined(VISP_HAVE_OCCIPITAL_STRUCTURE) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) && defined(VISP_HAVE_THREADS)
40#include <condition_variable>
43#include <ST/CaptureSession.h>
45#if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_COMMON)
46#include <pcl/common/common_headers.h>
49#include <visp3/core/vpCameraParameters.h>
50#include <visp3/core/vpImage.h>
51#include <visp3/core/vpPoint.h>
206#ifndef DOXYGEN_SHOULD_SKIP_THIS
207 struct SessionDelegate : ST::CaptureSessionDelegate
209 std::mutex m_sampleLock;
210 std::condition_variable cv_sampleLock;
212 ST::ColorFrame m_visibleFrame;
213 ST::DepthFrame m_depthFrame;
214 ST::InfraredFrame m_infraredFrame;
215 ST::AccelerometerEvent m_accelerometerEvent;
216 ST::GyroscopeEvent m_gyroscopeEvent;
217 ST::StructureCoreCameraType m_cameraType;
218 ST::CaptureSessionUSBVersion m_USBVersion;
219 std::string m_serialNumber;
221 ~SessionDelegate() { }
223 void captureSessionEventDidOccur(ST::CaptureSession *session, ST::CaptureSessionEventId event) VP_OVERRIDE
226 case ST::CaptureSessionEventId::Booting:
228 case ST::CaptureSessionEventId::Connected:
229 printf(
"Starting streams...\n");
230 session->startStreaming();
236 m_USBVersion = session->USBVersion();
237 m_serialNumber = session->sensorInfo().serialNumber;
238 m_cameraType = session->getCameraType();
240 case ST::CaptureSessionEventId::Disconnected:
242 case ST::CaptureSessionEventId::Error:
246 printf(
"Capture session event unhandled\n");
250 void captureSessionDidOutputSample(ST::CaptureSession *,
const ST::CaptureSessionSample &sample) VP_OVERRIDE
253 std::lock_guard<std::mutex>
u(m_sampleLock);
256 if (sample.visibleFrame.isValid())
257 m_visibleFrame = sample.visibleFrame;
259 if (sample.depthFrame.isValid())
260 m_depthFrame = sample.depthFrame;
262 if (sample.infraredFrame.isValid())
263 m_infraredFrame = sample.infraredFrame;
265 if (sample.type == ST::CaptureSessionSample::Type::AccelerometerEvent)
266 m_accelerometerEvent = sample.accelerometerEvent;
268 if (sample.type == ST::CaptureSessionSample::Type::GyroscopeEvent)
269 m_gyroscopeEvent = sample.gyroscopeEvent;
273 cv_sampleLock.notify_one();
287 } vpOccipitalStructureStream;
293 void acquire(
vpImage<vpRGBa> &rgb,
bool undistorted =
false,
double *ts =
nullptr);
296 vpColVector *gyroscope_data =
nullptr,
bool undistorted =
false,
double *ts =
nullptr);
298 vpColVector *gyroscope_data =
nullptr,
bool undistorted =
false,
double *ts =
nullptr);
300 void acquire(
unsigned char *
const data_image,
unsigned char *
const data_depth,
301 std::vector<vpColVector> *
const data_pointCloud =
nullptr,
unsigned char *
const data_infrared =
nullptr,
303 double *ts =
nullptr);
305#if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_COMMON)
306 void acquire(
unsigned char *
const data_image,
unsigned char *
const data_depth,
307 std::vector<vpColVector> *
const data_pointCloud, pcl::PointCloud<pcl::PointXYZ>::Ptr &pointcloud,
308 unsigned char *
const data_infrared =
nullptr,
vpColVector *acceleration_data =
nullptr,
309 vpColVector *gyroscope_data =
nullptr,
bool undistorted =
true,
double *ts =
nullptr);
310 void acquire(
unsigned char *
const data_image,
unsigned char *
const data_depth,
311 std::vector<vpColVector> *
const data_pointCloud, pcl::PointCloud<pcl::PointXYZRGB>::Ptr &pointcloud,
312 unsigned char *
const data_infrared =
nullptr,
vpColVector *acceleration_data =
nullptr,
313 vpColVector *gyroscope_data =
nullptr,
bool undistorted =
true,
double *ts =
nullptr);
316 void getIMUVelocity(
vpColVector *imu_vel,
double *ts);
317 void getIMUAcceleration(
vpColVector *imu_acc,
double *ts);
320 bool open(
const ST::CaptureSessionSettings &settings);
333 unsigned int getWidth(vpOccipitalStructureStream stream_type);
334 unsigned int getHeight(vpOccipitalStructureStream stream_type);
337 float getDepth(
int x,
int y);
339 vpPoint unprojectPoint(
int row,
int col);
341 vpHomogeneousMatrix getTransform(
const vpOccipitalStructureStream from,
const vpOccipitalStructureStream to);
343 ST::Intrinsics getIntrinsics(
const vpOccipitalStructureStream stream_type)
const;
346 const vpOccipitalStructureStream stream_type,
349 void saveDepthImageAsPointCloudMesh(std::string &filename);
362#if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_COMMON)
363 void getPointcloud(pcl::PointCloud<pcl::PointXYZ>::Ptr &pointcloud);
Generic class defining intrinsic camera parameters.
vpCameraParametersProjType
@ perspectiveProjWithoutDistortion
Perspective projection without distortion model.
Implementation of column vector and the associated operations.
Implementation of an homogeneous matrix and operations on such kind of matrices.
Definition of the vpImage class member functions.
ST::CaptureSessionUSBVersion getUSBVersion() const
ST::StructureCoreCameraType getCameraType() const
vpCameraParameters m_visible_camera_parameters
vpCameraParameters m_depth_camera_parameters
ST::CaptureSession & getCaptureSession()
void getColoredPointcloud(pcl::PointCloud< pcl::PointXYZRGB >::Ptr &pointcloud)
ST::CaptureSession m_captureSession
float m_invalidDepthValue
void getPointcloud(std::vector< vpColVector > &pointcloud)
std::string getSerialNumber() const
ST::CaptureSessionSettings m_captureSessionSettings
SessionDelegate m_delegate
@ infrared
Infrared stream.
ST::CaptureSessionSettings & getCaptureSessionSettings()
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
VISP_EXPORT int wait(double t0, double t)