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) && defined(VISP_HAVE_THREADS)
45 #include <condition_variable>
48 #include <ST/CaptureSession.h>
50 #if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_COMMON)
51 #include <pcl/common/common_headers.h>
54 #include <visp3/core/vpCameraParameters.h>
55 #include <visp3/core/vpImage.h>
210 #ifndef DOXYGEN_SHOULD_SKIP_THIS
211 struct SessionDelegate : ST::CaptureSessionDelegate
213 std::mutex m_sampleLock;
214 std::condition_variable cv_sampleLock;
216 ST::ColorFrame m_visibleFrame;
217 ST::DepthFrame m_depthFrame;
218 ST::InfraredFrame m_infraredFrame;
219 ST::AccelerometerEvent m_accelerometerEvent;
220 ST::GyroscopeEvent m_gyroscopeEvent;
221 ST::StructureCoreCameraType m_cameraType;
222 ST::CaptureSessionUSBVersion m_USBVersion;
223 std::string m_serialNumber;
225 ~SessionDelegate() { }
227 void captureSessionEventDidOccur(ST::CaptureSession *session, ST::CaptureSessionEventId event) VP_OVERRIDE
230 case ST::CaptureSessionEventId::Booting:
232 case ST::CaptureSessionEventId::Connected:
233 printf(
"Starting streams...\n");
234 session->startStreaming();
240 m_USBVersion = session->USBVersion();
241 m_serialNumber = session->sensorInfo().serialNumber;
242 m_cameraType = session->getCameraType();
244 case ST::CaptureSessionEventId::Disconnected:
246 case ST::CaptureSessionEventId::Error:
250 printf(
"Capture session event unhandled\n");
254 void captureSessionDidOutputSample(ST::CaptureSession *,
const ST::CaptureSessionSample &sample) VP_OVERRIDE
257 std::lock_guard<std::mutex> u(m_sampleLock);
260 if (sample.visibleFrame.isValid())
261 m_visibleFrame = sample.visibleFrame;
263 if (sample.depthFrame.isValid())
264 m_depthFrame = sample.depthFrame;
266 if (sample.infraredFrame.isValid())
267 m_infraredFrame = sample.infraredFrame;
269 if (sample.type == ST::CaptureSessionSample::Type::AccelerometerEvent)
270 m_accelerometerEvent = sample.accelerometerEvent;
272 if (sample.type == ST::CaptureSessionSample::Type::GyroscopeEvent)
273 m_gyroscopeEvent = sample.gyroscopeEvent;
277 cv_sampleLock.notify_one();
291 } vpOccipitalStructureStream;
297 void acquire(
vpImage<vpRGBa> &rgb,
bool undistorted =
false,
double *ts =
nullptr);
300 vpColVector *gyroscope_data =
nullptr,
bool undistorted =
false,
double *ts =
nullptr);
302 vpColVector *gyroscope_data =
nullptr,
bool undistorted =
false,
double *ts =
nullptr);
304 void acquire(
unsigned char *
const data_image,
unsigned char *
const data_depth,
305 std::vector<vpColVector> *
const data_pointCloud =
nullptr,
unsigned char *
const data_infrared =
nullptr,
307 double *ts =
nullptr);
309 #if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_COMMON)
310 void acquire(
unsigned char *
const data_image,
unsigned char *
const data_depth,
311 std::vector<vpColVector> *
const data_pointCloud, pcl::PointCloud<pcl::PointXYZ>::Ptr &pointcloud,
312 unsigned char *
const data_infrared =
nullptr,
vpColVector *acceleration_data =
nullptr,
313 vpColVector *gyroscope_data =
nullptr,
bool undistorted =
true,
double *ts =
nullptr);
314 void acquire(
unsigned char *
const data_image,
unsigned char *
const data_depth,
315 std::vector<vpColVector> *
const data_pointCloud, pcl::PointCloud<pcl::PointXYZRGB>::Ptr &pointcloud,
316 unsigned char *
const data_infrared =
nullptr,
vpColVector *acceleration_data =
nullptr,
317 vpColVector *gyroscope_data =
nullptr,
bool undistorted =
true,
double *ts =
nullptr);
320 void getIMUVelocity(
vpColVector *imu_vel,
double *ts);
321 void getIMUAcceleration(
vpColVector *imu_acc,
double *ts);
324 bool open(
const ST::CaptureSessionSettings &settings);
330 ST::StructureCoreCameraType
getCameraType()
const {
return m_delegate.m_cameraType; }
332 ST::CaptureSessionUSBVersion
getUSBVersion()
const {
return m_delegate.m_USBVersion; }
337 unsigned int getWidth(vpOccipitalStructureStream stream_type);
338 unsigned int getHeight(vpOccipitalStructureStream stream_type);
341 float getDepth(
int x,
int y);
343 vpPoint unprojectPoint(
int row,
int col);
345 vpHomogeneousMatrix getTransform(
const vpOccipitalStructureStream from,
const vpOccipitalStructureStream to);
347 ST::Intrinsics getIntrinsics(
const vpOccipitalStructureStream stream_type)
const;
350 const vpOccipitalStructureStream stream_type,
353 void saveDepthImageAsPointCloudMesh(std::string &filename);
365 void getPointcloud(std::vector<vpColVector> &pointcloud);
366 #if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_COMMON)
367 void getPointcloud(pcl::PointCloud<pcl::PointXYZ>::Ptr &pointcloud);
368 void getColoredPointcloud(pcl::PointCloud<pcl::PointXYZRGB>::Ptr &pointcloud);
Generic class defining intrinsic camera parameters.
vpCameraParametersProjType
@ perspectiveProjWithoutDistortion
Perspective projection without distortion model.
Implementation of column vector and the associated operations.
error that can be emitted by ViSP classes.
Implementation of an homogeneous matrix and operations on such kind of matrices.
ST::CaptureSessionUSBVersion getUSBVersion() const
ST::StructureCoreCameraType getCameraType() const
vpCameraParameters m_depth_camera_parameters
ST::CaptureSession & getCaptureSession()
ST::CaptureSession m_captureSession
float m_invalidDepthValue
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)