2 #include <visp3/core/vpImage.h> 3 #include <visp3/gui/vpDisplayGDI.h> 4 #include <visp3/gui/vpDisplayOpenCV.h> 5 #include <visp3/gui/vpDisplayX.h> 6 #include <visp3/sensor/vpOccipitalStructure.h> 7 #include <visp3/io/vpImageStorageWorker.h> 12 int main(
int argc,
char **argv)
14 #if defined(VISP_HAVE_OCCIPITAL_STRUCTURE) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) 16 std::string opt_seqname_visible =
"visible-%04d.png", opt_seqname_depth =
"depth-%04d.png";
17 int opt_record_mode = 0;
18 int opt_depth_fps = 30, opt_visible_fps = opt_depth_fps;
20 bool frame_sync =
true;
22 for (
int i = 0; i < argc; i++) {
23 if (std::string(argv[i]) ==
"--record")
24 opt_record_mode = std::atoi(argv[i + 1]);
25 else if (std::string(argv[i]) ==
"--depth_fps")
26 opt_depth_fps = std::atoi(argv[i + 1]);
27 else if (std::string(argv[i]) ==
"--visible_fps")
28 opt_visible_fps = std::atoi(argv[i + 1]);
29 else if (std::string(argv[i]) ==
"--sxga")
31 else if (std::string(argv[i]) ==
"--no_frame_sync")
33 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
34 std::cout <<
"\nUsage: " << argv[0]
35 <<
" [--record <0: continuous | 1: single shot (default: 0)>]" 36 " [--depth_fps <depth_frames_per_seconds> (default: 30)]" 37 " [--visible_fps <visible_frames_per_seconds> (default: 30)]" 38 " [--sxga (if exists, output 1280x960 depth array)]" 39 " [--no_frame_sync (if exists, disable frame synchronization)]" 41 <<
"\nExample to visualize images:\n" 42 <<
" " << argv[0] <<
"\n" 43 <<
"\nExamples to record single shot images:\n" 44 <<
" " << argv[0] <<
" --record 1\n" 45 <<
"\nExamples to record a sequence of images:\n" 46 <<
" " << argv[0] <<
" --record 0\n" 47 <<
"\nExamples to record a sequence of images at different frame rates:\n" 48 <<
" " << argv[0] <<
" --record 0 --depth_fps 15 --visible_fps 10 --no_frame_sync\n" 54 std::cout <<
"Depth framerate : " << opt_depth_fps << std::endl;
55 std::cout <<
"Visible framerate : " << opt_visible_fps << std::endl;
57 std::string text_record_mode = std::string(
"Record mode: ") + (opt_record_mode ? std::string(
"single") :
std::string(
"continuous"));
59 std::cout << text_record_mode << std::endl;
60 std::cout <<
"Visible record name: " << opt_seqname_visible << std::endl;
61 std::cout <<
"Depth record name: " << opt_seqname_depth << std::endl;
70 if(opt_visible_fps < 2)
75 ST::CaptureSessionSettings settings;
76 settings.source = ST::CaptureSessionSourceId::StructureCore;
77 settings.structureCore.visibleEnabled =
true;
78 settings.frameSyncEnabled = frame_sync;
79 settings.structureCore.depthFramerate = opt_depth_fps;
80 settings.structureCore.visibleFramerate = opt_visible_fps;
82 settings.structureCore.depthResolution = ST::StructureCoreDepthResolution::SXGA;
83 settings.applyExpensiveCorrection =
true;
85 bool is_open = g.
open(settings);
94 #if defined(VISP_HAVE_X11) 96 display_visible.
init(I_color, 10, 10,
"Visible image");
98 display_depth.
init(I_depth, 10+I_color.
getWidth(), 10,
"Depth image");
99 #elif defined(VISP_HAVE_GDI) 101 display_visible.
init(I_color, 10, 10,
"Visible image");
103 display_depth.
init(I_depth, 10, 10,
"Depth image");
105 std::cout <<
"No viewer is installed..." << std::endl;
109 std::thread image_visible_storage_thread;
129 quit = image_queue_visible.record(I_color);
130 quit |= image_queue_depth.record(I_depth, NULL, image_queue_visible.getRecordingTrigger(),
true);
132 std::stringstream ss;
138 image_queue_visible.cancel();
139 image_queue_depth.cancel();
140 image_visible_storage_thread.join();
141 image_depth_storage_thread.join();
144 std::cout <<
"Catch an exception: " << e << std::endl;
149 #if !(defined(VISP_HAVE_OCCIPITAL_STRUCTURE)) 150 std::cout <<
"Install libStructure, configure and build ViSP again to use this example" << std::endl;
152 #if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11) 153 std::cout <<
"This turorial should be built with c++11 support" << std::endl;
void init(vpImage< unsigned char > &I, int win_x=-1, int win_y=-1, const std::string &win_title="")
VISP_EXPORT int wait(double t0, double t)
Type * bitmap
points toward the bitmap
Display for windows using GDI (available on any windows 32 platform).
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
unsigned int getWidth(vpOccipitalStructureStream stream_type)
error that can be emited by ViSP classes.
bool open(const ST::CaptureSessionSettings &settings)
static void flush(const vpImage< unsigned char > &I)
VISP_EXPORT double measureTimeMs()
void acquire(vpImage< unsigned char > &gray, bool undistorted=false, double *ts=NULL)
static void display(const vpImage< unsigned char > &I)
void init(unsigned int height, unsigned int width)
Set the size of the image.
unsigned int getHeight() const
unsigned int getHeight(vpOccipitalStructureStream stream_type)
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="")
unsigned int getWidth() const
static void createDepthHistogram(const vpImage< uint16_t > &src_depth, vpImage< vpRGBa > &dest_rgba)