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/io/vpImageStorageWorker.h>
7 #include <visp3/sensor/vpOccipitalStructure.h>
9 void usage(
const char *argv[],
int error)
11 std::cout <<
"SYNOPSIS" << std::endl
12 <<
" " << argv[0] <<
" [--depth-fps <6|15|30|60>]"
13 <<
" [--depth-fps <6|15|30|60>]"
15 <<
" [--no-frame-sync]"
16 <<
" [--record <mode>]"
18 <<
" [--help] [-h]" << std::endl
20 std::cout <<
"DESCRIPTION" << std::endl
21 <<
" --visible-fps <6|15|30|60>" << std::endl
22 <<
" Visible camera (gray or color) frames per second." << std::endl
23 <<
" Default: 30." << std::endl
25 <<
" --depth-fps <6|15|30|60>" << std::endl
26 <<
" Depth camera frames per second." << std::endl
27 <<
" Default: 30." << std::endl
29 <<
" --sxga" << std::endl
30 <<
" If available, output 1280x960 high resolution depth array." << std::endl
32 <<
" --no-frame-sync" << std::endl
33 <<
" If available, disable frame synchronization." << std::endl
35 <<
" --record <mode>" << std::endl
36 <<
" Allowed values for mode are:" << std::endl
37 <<
" 0: record all the captures images (continuous mode)," << std::endl
38 <<
" 1: record only images selected by a user click (single shot mode)." << std::endl
39 <<
" Default mode: 0" << std::endl
41 <<
" --no-display" << std::endl
42 <<
" Disable displaying captured images." << std::endl
43 <<
" When used and sequence name specified, record mode is internally set to 1 (continuous mode)."
46 <<
" --help, -h" << std::endl
47 <<
" Print this helper message." << std::endl
49 std::cout <<
"USAGE" << std::endl
50 <<
" Example to visualize images:" << std::endl
51 <<
" " << argv[0] << std::endl
53 <<
" Example to record a sequence of images:" << std::endl
54 <<
" " << argv[0] <<
" --record 0" << std::endl
56 <<
" Example to record a sequence of images at different frame rates:" << std::endl
57 <<
" " << argv[0] <<
" --record 0 --depth-fps 15 --visible-fps 10 --no-frame-sync" << std::endl
59 <<
" Example to record single shot images:\n"
60 <<
" " << argv[0] <<
" --record 1" << std::endl
64 std::cout <<
"Error" << std::endl
66 <<
"Unsupported parameter " << argv[error] << std::endl;
73 int main(
int argc,
const char *argv[])
75 #if defined(VISP_HAVE_OCCIPITAL_STRUCTURE) && defined(VISP_HAVE_THREADS)
77 std::string opt_seqname_visible =
"visible-%04d.png", opt_seqname_depth =
"depth-%04d.png";
78 int opt_record_mode = 0;
79 int opt_depth_fps = 30, opt_visible_fps = opt_depth_fps;
80 bool opt_sxga =
false;
81 bool opt_frame_sync =
true;
82 bool opt_display =
true;
84 for (
int i = 1; i < argc; i++) {
85 if (std::string(argv[i]) ==
"--depth-fps") {
86 opt_depth_fps = std::atoi(argv[i + 1]);
89 else if (std::string(argv[i]) ==
"--visible-fps") {
90 opt_visible_fps = std::atoi(argv[i + 1]);
93 else if (std::string(argv[i]) ==
"--sxga") {
96 else if (std::string(argv[i]) ==
"--no-frame-sync") {
97 opt_frame_sync =
false;
99 else if (std::string(argv[i]) ==
"--record") {
100 opt_record_mode = std::atoi(argv[i + 1]);
103 else if (std::string(argv[i]) ==
"--no-display") {
106 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
120 std::cout <<
"Depth framerate : " << opt_depth_fps << std::endl;
121 std::cout <<
"Visible framerate: " << opt_visible_fps << std::endl;
122 std::cout <<
"Display : " << (opt_display ?
"enabled" :
"disabled") << std::endl;
124 std::string text_record_mode =
125 std::string(
"Record mode: ") + (opt_record_mode ? std::string(
"single") : std::string(
"continuous"));
127 std::cout << text_record_mode << std::endl;
128 std::cout <<
"Visible record name: " << opt_seqname_visible << std::endl;
129 std::cout <<
"Depth record name: " << opt_seqname_depth << std::endl;
138 if (opt_visible_fps < 2) {
142 ST::CaptureSessionSettings settings;
143 settings.source = ST::CaptureSessionSourceId::StructureCore;
144 settings.structureCore.visibleEnabled =
true;
145 settings.frameSyncEnabled = opt_frame_sync;
146 settings.structureCore.depthFramerate = opt_depth_fps;
147 settings.structureCore.visibleFramerate = opt_visible_fps;
149 settings.structureCore.depthResolution = ST::StructureCoreDepthResolution::SXGA;
150 settings.applyExpensiveCorrection =
true;
152 bool is_open = g.
open(settings);
161 vpDisplay *display_visible =
nullptr, *display_depth =
nullptr;
163 #if !(defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV))
164 std::cout <<
"No image viewer is available..." << std::endl;
170 display_visible =
new vpDisplayX(I_color, 10, 10,
"Visible image");
172 #elif defined(VISP_HAVE_GDI)
173 display_visible =
new vpDisplayGDI(I_color, 10, 10,
"Visible image");
175 #elif defined(HAVE_OPENCV_HIGHGUI)
176 display_visible =
new vpDisplayOpenCV(I_color, 10, 10,
"Visible image");
182 std::thread image_visible_storage_thread;
202 quit = image_queue_visible.record(I_color);
203 quit |= image_queue_depth.record(I_depth,
nullptr, image_queue_visible.getRecordingTrigger(),
true);
205 std::stringstream ss;
211 image_queue_visible.cancel();
212 image_queue_depth.cancel();
213 image_visible_storage_thread.join();
214 image_depth_storage_thread.join();
216 if (display_visible) {
217 delete display_visible;
220 delete display_depth;
225 std::cout <<
"Catch an exception: " << e << std::endl;
230 #if !(defined(VISP_HAVE_OCCIPITAL_STRUCTURE))
231 std::cout <<
"Install libStructure, configure and build ViSP again to use this example" << std::endl;
233 #if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
234 std::cout <<
"This tutorial should be built with c++11 support" << std::endl;
Display for windows using GDI (available on any windows 32 platform).
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
Class that defines generic functionalities for display.
static void display(const vpImage< unsigned char > &I)
static void flush(const vpImage< unsigned char > &I)
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
error that can be emitted by ViSP classes.
static void createDepthHistogram(const vpImage< uint16_t > &src_depth, vpImage< vpRGBa > &dest_rgba)
unsigned int getWidth() const
Type * bitmap
points toward the bitmap
unsigned int getHeight() const
unsigned int getHeight(vpOccipitalStructureStream stream_type)
void acquire(vpImage< unsigned char > &gray, bool undistorted=false, double *ts=nullptr)
unsigned int getWidth(vpOccipitalStructureStream stream_type)
bool open(const ST::CaptureSessionSettings &settings)
VISP_EXPORT int wait(double t0, double t)
VISP_EXPORT double measureTimeMs()