ViSP-2.8.0/0000775000175000017500000000000012173700531012535 5ustar fspindlefspindleViSP-2.8.0/ChangeLog0000664000175000017500000010511512173503303014310 0ustar fspindlefspindle ViSP Visual Servoing Platform Resume of the change log Copyright Projet Lagadic / IRISA-INRIA Rennes, 2005-2013 http://www.irisa.fr/lagadic ViSP 2.8.0 (released July 24th, 2013) - New features . New camera calibration tool: example/camera_calibration.cpp - Improvements . vpV4l2Grabber and vp1394CMUGrabber does no more require a call to open(I). . In vp1394CMUGrabber new getters/setters for the framerate, shutter, gain. It is now possible to change the settings in the acquisition loop. . An exceptions is throwned when moving-edges are not initialized (vpMeTracker, vpMeLine, vpMeEllipse) . In model-based trackers, improve face visibility test using Ogre ray tracing when faces are concave or not oriented counter clockwise. . Still in model-based trackers, add functionalities to use clipping planes. . ViSP can now be used with pkg-config . New fonctions in vp1394TwoGrabber to turn auto shutter and auto gain on. Also new getter for auto shutter and auto gain min/max values. . Support Visual Studio 2012 (MSVC11) . Introduce C++ visibility support as described here http://gcc.gnu.org/wiki/Visibility . Better support of image formats: *.tiff, *.jpeg, *.bmp, *.pbm, ... - Examples . Introduction of tutorials as minimalist line by line illustrated examples. - Bug fixed . [15404] Segfault in vpMbTracker derived classes around Coin SoDB::init() and SoDB::finish() usage . [15410] Robot wireframe simulator hangs . [15422] Build issues with ffmpeg 1.0.1 third party . [15475] Segfault in cv::Mat(BGR) to vpImage(grey) conversion . [15522] Visibility tests issues in Model-Based Tracker using Ogre3D . [15566] Bad mask orientation when using model-based tracker with cylinders . [15587] visp-config conflicts with multiarch support on Debian . [15623] Possible ViSP-2.7.0 bugs detected by cppcheck . [15644] crash with vpRobotWireFrameSimulator::initScene() . [15679] vpDot and vpDot2 copy operator are incomplete . [15680] Bad pixel to meter conversion in vpFeatureLuminance . [15697] False positive exception in vpDisplay when vpDisplay::close() is used . [15730] ViSP-third-party.txt is installed in a wrong location . [15896] Ogre Boost components miss Boost.Filesystem . [15895] ViSP does not compile on FreeBSD (amd64 / i386) ---------------------------------------------- ViSP 2.7.0 (released February 11th, 2013) - New features - New vpViper650 and vpRobotViper650 classes to interface Inria's new Adept Viper s650 robot. - New robot simulators; vpSimulatorCamera, vpSimulatorPioneer, vpSimulatorPioneerPan - New model-based tracker using KLT points: vpMbKltTracker. - New hybrid model-based tracker using moving edges and KLT points: vpMbEdgeKltTracker - Improvements - Add visp-config.1 man page. - To respect Debian guidelines, remove duplicate ABI version. Library name was set to libvisp.a or libvisp.so.2.7.0 rather than libvisp-2.a or libvisp-2.so.2.7.0 - Fix typos detected by lintian - Add support for multiarch. Multiarch is the ability for a library to be installed concurrently for differents architectures (such as i386 and amd64 for instance). In practice, the changes removes the assumption made that libraries are installed in $INSTALL_PREFIX/lib and binaries in $INSTALL_PREFIX/bin. - In vp1394TwoGrabber that allows to grab images from firewire cameras, cameras are powered off when the grabber is closed. - MinGW is now supported but since MinGW currently doesn't support tls __declspec(thread) with vpDisplayGDI it is possible to open only one display. - To better organise the code, robot simulators inherit from vpRobotSimulator class. Introduction of a new vpRobotWireFrameSimulator class as a base class of robot simulated using the wireframe display capabilities. - VRML loader (based on Coin3D) now reads transform nodes and hierarchical scenes. - If Ogre3D is used, model-based trackers use now RayCasting to improve faces visibility test. - Compatibility with iOS 6 and Fedora 18 - Examples - New model-based tracker examples to show how to use the KLT and hybrid tracker. See in example/tracking mbtEdgeKltTracking.cpp and mbtKltTracking.cpp - Bug fixed - [14646] ViSP doesn't build on Windows with MinGW - [14651] Build error arround vpMatrix::pseudoInverse() with OpenCV 2.1.0 - [14661] Build error when GDI is not detected or turned off - [14818] Build error when only GTK display device is available - [14862] Lagrange pose estimation cannot handle planar objects with points in plane oX=d or oY=d - [14863] vpPose::poseRansac() can fail during Lagrange pose estimation - [14993] Segfault in mbtTracker example when only the cube is tracked - [15049] In vpFeatureSegment, bad interaction matrix associated to alpha angle - [15110] Segfault in ffmpeg video reader - [15291] Under Windows, the end of an image is not displayed ---------------------------------------------- ViSP 2.6.2 (released July 15, 2012) - New features - New vp1394CMUGrabber class that allows firewire frame acquisition under Windows using CMU 1394 Digital Camera 3rd party library. Thanks to Lucas Lopes Lemos and Guillaume Laurent from FEMTO-ST, AS2M departement, Besancon, France for this contribution. - New vpPioneer, vpPioneerPan, vpRobotPioneer classes to control Pioneer mobile robots using Aria 3rd party library. - New vpFeatureSegment class to consider a segment as a visual servoing feature. Normalized and non normalized features are considered. - New vpFeatureMomentArea class to consider moment area as a visual feature. - Introduction of new functionalities in vpIoTools to parse text config files - Introduction of YARP to ViSP image converters in vpImageConvert - New vpClient and vpServer classes for a multiclients TCP network. - New vpPoseFeatures class for pose computation from any visual features. To be able to consider other user defined features the compiler should be compatible with C++ 11 standart. - Improvements - Introduce a new Denavit Hartenberg representation of the Biclops head in vpBiclops. - Compatibility with g++ 4.7 and OpenCV 2.3.1, 2.4.0, 2.4.1 - Remove warning detected with Visual C++ /Wall flag - Use CMake native package finder for zlib, png, jpeg, coin3d, gtk2 and doxygen 3rd party libraries detection. If detection fails, we use our own package finder. - Under Windows, changes done to add "d" suffix to the library name when build in debug (libvisp-2d.lib and libvisp-2d.dll). Install stage copy libvisp-2[d].lib in $CMAKE_INSTALL_PREFIX/lib and libvisp-2[d].dll in $CMAKE_INSTALL_PREFIX/bin. - Use OpenMP to optimize the execution of the moments computation. - Possibility to compute the covariance matrix during pose estimation (vpPose and vpPoseFeatures) and model-based tracking (vpMbTracker). - All initClick() now have a non-blocking equivalent as initFromPoints(), or initFromPose(), etc. - Most of the classes that had a display() method now have the equivalent display in static function (display's externalisation). - Ransac is now improved for either pose computation or point matching. - Examples - New example plot3d.cpp to show how to plot 3D curves - New example movePioneer.cpp to illustrate Pioneer velocity control. - New example sonarPioneerReader.cpp to illustrate Pioneer sonar device usage. - New examples servoPioneerPoint2DDepth.cpp, servoPioneerPoint2DDepthWithoutVpServo.cpp and servoPioneerPanSegment3D.cpp to show how to control the pioneer mobile robot by IBVS. - New example grab1394CMU.cpp to show how to acquire images with the CMU 1394 library. - Bug fixed - [13536] Division by zero in vpMeLine - [13548] ViSP-2.6.1 produces several warnings with g++ 4.4.3, a const is missing in vpMbtDistanceLine.h - [13575] ViSP sporadic segmentation fault in vpMeLine - [13625] trackMeNurbs example produce an assertion failed with MSVC: "list iterator not incrementable" - [13626] testXmlParser produre a Debug assertion failed with MSVC - [13678] Cannot build all the examples if no display capability is available - [13679] GDI not detected on Windows 7 (64 bit) with Visual C++ Express 2010 - [13689] Memory leaks in jpeg reader: vpImageIo::readJPEG() - [13690] Memory leaks in NURBS tracker - [13843] In vpPolygon, isInside() may produce a segfault and getArea() or getCenter() give bad results - [13850] visp-config.bat produces a non compatible msvc 2010 output format - [13955] vpBasicFeature::error() is not virtual - [13963] Under Windows, vpDisplay::getClickUp() doesn't work - [14081] Error in vpThetaUVector when angles are near 180 deg +/- epsilon - [14082] Segmentation fault in model based tracking when tracking only cylinders - [14474] Fix race condition in vpXmlParser. - [14481] testFeatureSegment can lead to an exception. - [14587] Ogre media directory OGRE_MEDIA_DIR not set in Ubuntu 12.04 - [14588] vpConfig.h doesn't match with the install directory ---------------------------------------------- ViSP 2.6.1 (released October 20th, 2011) - New features - Introduction of Lapack support used for the SVD decomposition in vpMatrix - Introduction of vpAROgre that enables augmented reality applications based on Ogre 3D. Some examples are provided in examples/ogre-simulator - Add cylinder's tracking in the model-based tracker. - Reintroduce OpenCV 2.0.0 support lost in ViSP 2.6.0 - Introduction of vpKinect, a wrapper of libfreenect to support the Kinect device - Introduction of vpMoment and vpFeatureMoment classes to be able to consider 2D image moments as visual feature in visual servoing - Improvements - For firewire cameras framegrabbing with vp1394TwoGrabber, it is now possible to select a specific camera with its GUID by using setCamera() - All the specific Xml parser (vpMbtXmlParser, vpXmlParserCamera) inherit now from vpXmlParser - Memory leaks suppression in vpWireFrameSimulator, vpMe, vpXmlParser, vpMbtXmlParser, vpXmlParserCamera, vpMbTracker, vpFeatureLuminance, vpRobotSimulator, vpFFMPEG, vpBSpline - It is now possible to grab images from an usb webcam with the vpV4l2Grabber class that is based on the video 4 linux 2 driver. - When it was possible without braking the backward compatibilty std::list was introduced instead of vpList. Some of the functions that use vpList are now deprecated. - Better detection of image or video file types when used in vpImageIo, vpVideoReader and vpVideoWriter - Build - Set the build type by default to release - Improve the usage of debug versus release third-party libraries - Deprecated - vpAdaptativeGain is deprecated. Use vpAdaptiveGain instead. - vp1394Grabber is deprecated. Use vp1394TwoGrabber instead. - Most of the methods that use vpList are deprecated. Use std::list instead - vpTwistMatrix deprecated in ViSP-1.6.0 was removed. - Examples: - New example grabOpenCV-2.cpp to show how to use the OpenCV cv::VideoCapture class. This example shows how to acquire an image with cv::VideoCapture, how to transform this image in ViSP format and how to display it. - New examples to illustrate the usage of the Ogre simulator through vpAROgre class. - New example to illustrate the usage of the Kinect through vpKinect class. - New examples to illustrate the usage of 2D image moments. - Bug fixed - [11110] On OSX vpDisplayOpenCV does not display images since OpenCV 2.1.0 - [11147] Coin not installed, cannot read VRML files - [11473] vpImageTools::flip() come out error when deal with vpImage with vpRGBa type - [11529] ViSP / OpenCV(2.2.0) incompatibility - [11563] segfault in vpVideoReader - [11617] selecting a subset of features is not taken into account in vpServo - [11916] Build issues with GTK2 on ubuntu 10.10 (fatal error: gdk-pixbuf/gdk-pixbuf.h) - [11924] svdNr fails on some matrices where svdGsl succeeds - [11942] Build issues with GSL on OSX due to 32/64 bits architecture - [11943] Build issues with libjpeg on OSX due to 32/64 bits architecture - [11944] Build issues with libpng on OSX due to 32/64 bits architecture - [11981] vpV4l2Grabber class based on video 4 linux 2 is not able to grab images from an usb webcam - [12329] Bad font problem when opening vpPlot example - [12334] Under windows, link errors when some 3rd party libs are not build in the same build configuration as ViSP - [12499] servoSimu4Points: World point disposition does not match camera - [12591] Seg fault when using setCleanPreviousImage() from vpImageSimulator - [12739] Problem initialising a vpMeEllipse - [13014] Bug in vpCalibration::calibVVSMulti() jacobian - [13015] vpFFMPEG compatibility issue with ffmpeg-0.8 release - [13449] "LIBJPEG_BUILD_TEST - Failed" message in CMake for Visual 2010 - [13467] CreateWindow windows API does not correctly register class. ---------------------------------------------- ViSP 2.6.0 (released September 23rd, 2010) - License: Change the open source license from QPL to GPL v2 - New Features - Introduction of a new wireframe simulator. See vpWireFrameSimulator class. - Introduction of a new model-based tracker that allows to track an object based on its 3D model. See vpMbEdgeTracker class. - New vpForceTwistMatrix class that allows to transfer a force/torque skew from one frame to another. - New vpVelocityTwistMatrix class that allows to transfer a velocity skew from one frame to an other. The vpTwistMatrix class that does the same work previously is from now deprecated. - New vpRobotCycab class to communicate with the Cycab car-like mobile robot at Inria. - New generic vpRobotSimulator class to create robot simulators. - New vpSimulatorViper850 class which simulates the viper850 robot. - New vpSimulatorAfma6 class which simulates the Afma 6dof robot. - New vpPlanarObjectDetector class to detect a planar surface based on the Ferns Classifier. - New vpSickLDMRS class, a UNIX driver to get measures from a Sick LD-MRS laser scanner. - New vpPlot class that was recoded to suppress the XPlotter dependency. This class aims real time drawing of 2D or 3D graphics under Linux, OSX and Windows. - Third party library dependencies - OpenCV 1.1 and 2.0 are no more supported. ViSP requires at least OpenCV 2.1. - libplotter is no longer required. - Itifg8 is no longer supported. - Improvements - Copy constructors were added to better support stl lists and vectors. - In firewire framegrabbing using vp1394TwoGrabber based on libdc1394-2.x, add possibility to change during the execution the shutter, the gain, the brightness, ... (see documentation for more details) . new setIsoTransmissionSpeed(), setAutoShutter() methods - In vpThetaUVector addition of &operator=() method to initialise all the angles to the same value - In vpHomogeneousMatrix addition of . eye() method to set the transformation as identity . extract(vpThetaUVector &) to extract the rotation as a Theta U vector - In vpRobotViper850 add openGripper() and closeGripper() functions to control the Schunk two fingers electric gripper (available only at Inria). - In vpRotationVector and vpTranslationVector introduction of set() method that allows initialization from 3 doubles - Documentation improvements - Deprecated . Some deprecated classes were removed: vpItifg8Grabber, vpEulerVector, vpSubPixel, vpRA . Deprecated functions since ViSP 2.4.4 where also removed - Examples: - New example calibrateTsai.cpp to show how to use the vpCalibration class to estimate the hand to eye transformation. - New examples to illustrate the usage of the new wire-frame simulators - Bug fixed - [9476] Memory leak in vpImageIo::readPNG() functions. - [9505] Problem with the DirectShow grabber : can't be initialised. - [9516] Problem in the getValue methods in the vpImage class. - [9746] The displayPoint method of the vpDisplayOpenCV class doesn't work. - [10472] Bug in the visual features: can't select the good feature. - [10647] Delay in displaying image overlays - [10687] The GDI display is not detected with Visual Studio 2010 - [10696] [CMake] VISP_DIR path conflict - [10697] CMake standard output vars - [10719] Compilation error in vpPlot - [10723] Compilation error in vpFFMPEG.cpp - [10748] PThread and Win32 Conflict - [10928] vpPlane: rayIntersection from 2 points - [10985] In vpPlot, 2D curve plotting starts with point (0,0) and not with the first specified point. ---------------------------------------------- ViSP 2.4.4 (released January 8th, 2010) - Features removed - vpMePath has been removed. ---------------------------------------------- ViSP 2.4.4-rc1 (released December 21th, 2009) - New Features - During CMake configuration, when a third-party library is detected, it is now possible to turn off the default usage of the library. - Warning during the build if deprecated functions are used - For the Irisa's Afma6 robot addition of a new vacuum tool (vpAfma6). - New vpImagePoint class for image point coordinates. - New vpPlot class that enables real time drawing of graphics under Unix. - Ability to use other colors than the predefined ones with the rewriting of the vpColor class and modifications in display functionalities. - New vpKalmanFilter and vpLinearKalmanFilterInstantiation classes with velocity and acceleration state models. - New vpFeatureTranslation: ctc* - New USE_COIN_SIMULATOR option during CMake configuration to enable or disable simulation capabilities based on Coin3D suite. - New vpViper, vpViper850 and vpRobotViper850 classes to provide an interface for Inria's Adept Viper 850 robot. - New vpBSpline and vpNurbs classes to manipulate 2D BSpline and 2D Nurbs (Non Uniform Rational BSpline). - New vpMeNurbs class to track object edges. - New vpFFMPEG class to interface the FFmpeg library. - New vpVideoReader and vpVideoWriter classes to manipulate easily the video files and the image sequences. - Improvements - In firewire framegrabbing using vp1394TwoGrabber based on libdc1394-2.x, bus reset can be switched off in the constructor. There are also improvements in the acquisition using acquire(vpImage &I, ...) by removing the color coding format request and by support of the RAW8 and RAW16 video format. New dequeue() functions were also introduced to make possible to separate the ring buffer dequeuing and enqueuing. This behavior is for example useful when image processing needs to be introduced between the dequeuing and enqueuing stages. It may also useful to synchronise the image acquisition with an other sensor. New setPanControl() function was introduced to set the PAN register 0x884 to control single or multiple image transmission from stereo vision cameras like the PointGrey Bumblebee. - vpDot2: The tracking is restarted in vpDot2::track() if a dot is found but is not valid. - In vpDisplay, new getKeyboardEvent() functionality to handle key events and new getPointerMotionEvent() functionality to handle mouse pointer motion event. - Optimization of the vpMatrix class. - Examples: - New examples in examples/servo-viper850 to show how to use the linear Kalman filter to compensate the tracking error due to the motion of a target. - New examples in examples/servo-viper850 to show how to use the secondary task to avoid joint limits. - New plotting example in example/tools/plot.cpp - In grab1394Two.cpp example, addition of [-r] new option to reset the bus. - New examples to show how to build a 3D visual servoing without using the vpServo and vpFeature classes: servoSimu3D_cMcd_CamVelocityWithoutVpServo.cpp and servoSimu3D_cdMc_CamVelocityWithoutVpServo.cpp - Bug fixed - [7638] Memory leak in all vpFeature... classes was reopened - [7888] vpV4l2Grabber cannot acquire an image from an analog camera on Ubuntu 8.04 Hardy Heron - [7994] vpMeLine : initialization problem for horizontal lines - [8001] Coin and SoQt are not detected during CMake configuration under Fedora 10 - [8032] Link error whith GSL while compiling HelloWorld.cpp on OSX - [8225] Bug in the multiplication of a twist matrix (6x6) by a matrix (6xn) - [8248] Compilation error under Windows MSCV8 if deprecated functions are not build - [8249] Compilation error under Windows MSCV8 when building ViSP as a shared library (DLL) - [8257] Bug in vp1394TwoGrabber::resetBus() - [8259] Segfault in vpDisplayX - [8389] vpKltOpencv : Bug in the copy constructor - [8493] Problem to build ViSP as a dynamic library under windows (Visual C++) - [8495] Segmentation fault during the execution of the example grabDirectShow - [8831] Possible bug when extracting axis/angle from theta/u vector ---------------------------------------------- ViSP 2.4.3 (released April 10th, 2009) - New Features - Add vpFeaturePointPolar corresponding the a 2D image point with polar coordinates visual feature. - Add vpFeatureTranslation for cto (camera to object translation feature) - Add vpDisplay::setWindowPosition() functionality - Bug fixed - [7281] Segfault when displaying a vpCylinder. - [7308] Rotation vector not initialized to zero by the default constructor - [7309] visp-config --cflags produces a bad output - [7342] Bug in vpRobotAfma6::setVelocity(vpRobot::CAMERA_FRAME, v) - [7494] Division by 0 in vpHomography - [7424] Coin3D version 3 not supported under Windows - [7613] vpSimulator::getInternalImage() function yields to an infinite loop. - [7607] vpDisplayGTK bad window positionning - [7638] Memory leak in all vpFeature... classes ---------------------------------------------- ViSP 2.4.3-rc2 (released January 29th, 2009) - Deprecated - Creation of a deprecated section in the online documentation that gives the list of classes or member function that are deprecated - vpOSXcfoxGrabber was removed, since the C+Fox third party library available at http://cfox.sourceforge.net/ was not updated since 2005. - vpIcCompGrabber was removed, since it uses a home made wrapper based on itifg-7.2.1 driver which is not maintained yet - Testing - Use of CDash insteed of Dart2. Dashboards are sent to http://cdash.irisa.fr/CDash/index.php?project=ViSP - Platform compatibility - Compatibility with g++ 4.3.0 coming with fedora 9 - New Features - Add visp-config.bat under Windows to get the list of include dirs, library dirs and libraries ViSP depends on. This may help users to build a Visual Studio project from scratch and where ViSP is used as a third party project - vpFeatureThetaU: Add cRcd feature, with ThetaU corresponding to the rotation the camera has to achieve to move from current frame to the desired one. - vpOpenCVGrabber: New framegrabber based on OpenCV third party library (useful for USB cameras). - vp1394TwoGrabber: Get the timestamp associated to the grabbed image. - vpV4l2Grabber: Get the timestamp associated to the grabbed image. - vpRobotAfma6 and vpAfma6: Modifications to be compatible with the new low level Adept controller provided by Cerebellum Automation. - vpRobotAfma4 and vpAfma4: Modifications to be compatible with the new low level Adept controller provided by Cerebellum Automation. New vpServolens class to control the Servolens lens attached to the camera fixed on the Afma4 end-effector. - Examples: - New examples in example/manual described in ViSP guide under preparation. - example/servo-simu/servoSimu3DCamVelocity2.cpp - Documentation - Creation of a deprecated section. - Classes are now grouped in doxygen modules to help learning ViSP. - Introduction of new sample examples in the online documentation - Bug fixed - [5370] DirectShow and Visual Studio 9 2008 Express - [5371] Warnings on Visual Studio 9 2008 - [5375] Compilation error in calibrate2dGrid.cpp - [5398] display cylinder - [5438] window sizes with Coin - [5496] Compilation error in example/framegrabber/grab1394.cpp - [5508] Bug in vpImageConvert::YUV420ToRGB - [5527] Bug in vpImageTools::changeLUT() - [5539] Unhandle exception with multi vpDisplayGDI / D3D instances - [5596] Multiplying a vpRotationMatrix with a vpColVector ? - [5642] warning in vphomographyvvs.cpp with Visual C++ 2003 .Net - [5993] vpImage BI - [6330] Segfault in vpSimulator with Coin + SoXt - [6336] DLT Homography on 4 points - [6484] Bug in vpCalibration::calibrationTsai for eye-to-hand calibration - [6590] vpDisplayGDI cannot handle numerous displays (windows) - [6619] Problem vpMeLine : compute of delta - [6743] Bug in vpDisplayOpenCV::displayRectangle() - [6744] Bug in vpDisplayOpenCV - [6962] vpMeLine : problem of tracking - [7034] vpMeLine : Bug when a strip is tracked - [7126] problem with vpMatrix::eigenValuesByLU() ---------------------------------------------- ViSP 2.4.2 (released March 27th, 2008) - New classes - vpCalibration : calibration toolkit for intrinsic and extrinsic parameters of perspective camera. - vpXmlParserCamera : Parser xml to read and save camera parameters from vpCameraParameters class. - vpHinkley : Hinkley's cumulative sum test computation. - vpMePath : Tracking of a white curve by using line and parabola tracker. - vpKeyboard : Gets a key from the keyboard without waiting for the enter key. - vpParallelPort : Parallel port management under unix. - vpRingLight : Irisa's ring light controller. - vpKltOpencv : Interface for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented with opencv. - New Features - Bug fix and improvement - vpCameraParameters : support for radial distortion camera model. - vpAfma6 : Add a getCameraParameters functionnality - vpSimulator : either SoWin or SoQt or SoXt is needed to use vpSimulator class. - vpDot: setMaxDotSize(double percentage) replace setNbMaxPoint(double nb) to be less image size dependent. The maximal dot size is set by default to 0.25% (quarter image size). setGrayLevelPrecision(double grayLevelPrecision) has been added for a better management of gray dots detection. - vpDot2: Changes in searchDotsInArea() : The algorithm search now in the bounding boxes of the bad dots. Bug fixed : we could fall in an infinite loop. Split accuracy private variable into grayLevelPrecision and sizePrecision. The gray level min and max are well calculated for white and black dots. Add setEllipsoidShapePrecision() to turn on/off and modify the test related of the geometry of the shape - vpDisplayX : better management of endianness - vpDisplayGTK, vpDisplayGDI, vpDisplayD3D, vpDisplayX : To actually display drawings on the screen, a vpDisplay::flush(I) is needed. Use it with parsimony : it is time consuming. - vpDisplayGTK, vpDisplayGDI, vpDisplayD3D : The behavior of the following methods change to be similar to vpDisplayX: . getClick(..., button) : The button used to click is now an output . getClickUp(..., button) : The button used to click is now an output Moreover, in vpDisplayGDI, vpDisplayD3D middle button is now managed - vpDisplayGTK, vpDisplayGDI, vpDisplayD3D : The usage of display->init(vpImage, int, int); returned a segmentation fault : bug fixed - vpDisplayD3D : we couldn't re-use a display after the call of the function close(vpImage). We had a black image : bug fixed. - vpDisplay : changes in displayRectangle():an option parameter fill has been had to precise if the displayed rectangle is filled or not. - vpColor : Add orange color. - vpServo : To fix bug #3528 you should explicitly call vpServo::kill() in your programs. Otherwise an exception vpServoException::notKilledProperly is launched by vpServo::~vpServo() destructor. - vpMatrix : Change Infinity Norm and Euclidian Norm formula to match with the standard matrix norms definitions. Change determinant formula for 3x3 matrices to match with the standard determinant definition. - vpImageConvert : Add IplImage to vpImage and vpImage to IplImage conversion tool. Add MONO16 to grey (MONO8) conversion tool. - vp1394TwoGrabber : Supports libdc1394-2.0.0-rc7 and libdc1394-2.0.1 MONO16 color coding is supported - Testing and examples: - example/calibration/calibrate2dGrid.cpp was added - example/tracking/trackKltOpencv.cpp was added - example/light/ringLight.cpp was added - example/tools/parallelPort.cpp was added - test/video-device/testClick.cpp was added - test/video-device/testVideoDevice.cpp was added - test/visual-feature/testFeature.cpp was added - test/image/testCreateSubImage.cpp was added - test/camera/testCameraParametersConversion.cpp was added - Documentation improvement - vpRobust::MEstimator() - vpRobotAfma6: example usage of getPosition() was updated - vpDisplayGDI is included in the doxygen documentation ---------------------------------------------- ViSP 2.4.1 (released May 16th, 2007) - New classes - vpRect class for rectangle manipulations, display - vpHistogram,vpHistogramPeak and vpHistogramValey classes to handle gray level image histogram - vpSubPixel for sub-pixel manipulations - vpMouseButton for mouse click identification - New Features - MinGW supported - ViSP as a third party library in an other project. It is now possible to use ViSP as a third party project without installing ViSP by make install. ViSP can now be used directly from the build dir, or from the install dir, or from a package (NSIS, ...) - vpRobotCamera It is now possible to add a sampling time so that the behavior of this simulated camera is quite realistic. This sampling time is set by default to 40 ms. - vpExponentialMap A sampling time was introduced. - Bug fix and improvement - vpImage: getWidth() and getHeight() replace getCols() and getRows() which are now obsolete. - More restrictive types in vpImage, vpDisplay..., and vp...Grabber classes: const are added, unsigned int replace int for pixel manipulations and image or display size. - In vpDisplay classes: . vpMouseButton::vpMouseButtonType was introduced to handle mouse clicks . vpColor::vpColorType was introduced to handle colors to display - Simulator functionality based on Coin usage is now available under windows. It allows the use of vpSimulator class under this platform. - Compatibility with Windows platform. - Reference documentation improvement - cfox and std namespace were removed. To use cout you need to call std::cout, std::endl, std::cin ... ---------------------------------------------- ViSP 2.4.0 (released February 6th, 2007) - New Feature - add new framegrabber interface for itifg8 driver from Coreco Imaging Technology (http://sourceforge.net/projects/itifg) Tested with AM-STD COMP framegrabber board on 2.4 and 2.6 linux kernel (see vpItifg8Grabber). - add new framegrabber interface and test for firewire 1394 cameras using libdc1394-2.x. Need a newer version than libdc1394-2.0.0-rc4. Tested with the svn version of libdc1394-2 and Marlin F033C and F131B cameras (see vp1394TwoGrabber). Format 7 is supported in vp1394TwoGrabber. vp1394Grabber will be obsolete soon. - Bug fix and improvement - tests and examples - Video For Linux Two grabber (see vpV4l2Grabber) - memory leaks suppression - works fully under windows - doxygen documentation ---------------------------------------------- ViSP 2.2.0 (released August 25th, 2006) - Build - To increase the code portability, especially under windows), all the build process is now based on CMake (see http://www.cmake.org). - Supported platforms: Linux, Mac OSX, SunOS: g++ 2.95.3, 2.96, 3.3.x, 3.4.x, 4.1.0) Windows: MSVC7 (2003.NET), MSVC8 (2005) - Suppression of autotools support (configure) - Allows shared library building (.so and .dll) - New Feature - add control for Traclabs biclops pan-tilt head - add control for Directed Perception ptu-46 pan-tilt head - add vpDisplayGTK display under Windows - add vpDirectShowGrabber framegrabber under Windows - add vpDisplayGDI display under windows - Bug fix and improvement - vp1394Grabber settings (format, mode, framerate, shutter, gain) - vpDot (Moment computation) - some fixes in vpDisplayGTK ---------------------------------------------- ViSP 2.1.1 (released January 6th, 2006) - New examples - create an example directory - add vpDotExample.cpp - add vpDot2Example.cpp - add vpPoseExample.cpp - add 2D0.5.VisualServoingSimulation.cpp - New Feature - add this ChangleLog file - add a vpDisplayGTK class with the GTK2+ window system - new member function in vpDisplay (_uv) - add function getInteractionMatrix() in vpGenericFeature - Specification modifications - change the vpDot and vpDot2 specifications - supress demo directory - Bug fix and improvement - add a runtime warning when vpGenericFeature is not correctly used - comment in english in vpDisplayX - suppress a trace in vpPoseVirtualVisualServoing.cpp - directory.mk : add -p option to mkdir - improve XP compatibility - in vp1394Grabber, latency and memory leaks suppression - WWW - add an image sequence to download on the www site cube.tar.gz --------------------------------------- ViSP 2.1.0 (released October, 24th 2005) ViSP-2.8.0/example/0000775000175000017500000000000012173700526014174 5ustar fspindlefspindleViSP-2.8.0/example/servo-cycab/0000775000175000017500000000000012173700526016411 5ustar fspindlefspindleViSP-2.8.0/example/servo-cycab/servoCycabBasic.cpp0000664000175000017500000000521512072022352022152 0ustar fspindlefspindle/**************************************************************************** * * $Id: servoCycabBasic.cpp 4056 2013-01-05 13:04:42Z fspindle $ * * This file is part of the ViSP software. * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. * * This software is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * ("GPL") version 2 as published by the Free Software Foundation. * See the file LICENSE.txt at the root directory of this source * distribution for additional information about the GNU GPL. * * For using ViSP with software that can not be combined with the GNU * GPL, please contact INRIA about acquiring a ViSP Professional * Edition License. * * See http://www.irisa.fr/lagadic/visp/visp.html for more information. * * This software was developed at: * INRIA Rennes - Bretagne Atlantique * Campus Universitaire de Beaulieu * 35042 Rennes Cedex * France * http://www.irisa.fr/lagadic * * If you have questions regarding the use of this file, please contact * INRIA at visp@inria.fr * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * * Description: * Send a command to the car-like Cycab mobile robot. * * Authors: * Fabien Spindler * *****************************************************************************/ /*! \example servoCycabBasic.cpp Send a command to the car-like Cycab mobile robot. */ #include "visp/vpConfig.h" #include "visp/vpRobotCycab.h" #include "visp/vpMath.h" #include #ifdef VISP_HAVE_CYCAB int main() { try { double v = 0.1, phi = vpMath::rad(0); double x, y; double x_min=2000, x_max=0, y_min=2000, y_max=0; vpRobotCycab robot; std::cout << "Send the command v: " << v << " m/s and phi: " << vpMath::deg(phi) << " deg" << std::endl; while (true) { robot.setCommand(v, phi); robot.getJoystickPosition(x, y); //std::cout << "x: " << x << " y: " << y << std::endl; if (x < x_min) x_min = x; if (y < y_min) y_min = y; if (x > x_max) x_max = x; if (y > y_max) y_max = y; std::cout << "x_min: " << x_min << " x_max: " << x_max << " y_min: " << y_min << " y_max: " << y_max << std::endl; usleep(10000); } } catch(...) { std::cerr << "An exception was catched" << std::endl; return 1; } return 0; } #else // VISP_HAVE_CYCAB int main() { std::cout << "Sorry, you don't have access to the Cycab car-like mobile robot." << std::endl; } #endif // VISP_HAVE_CYCAB ViSP-2.8.0/example/servo-cycab/servoCycab.cpp0000664000175000017500000001073212072022352021210 0ustar fspindlefspindle/**************************************************************************** * * $Id: servoCycab.cpp 4056 2013-01-05 13:04:42Z fspindle $ * * This file is part of the ViSP software. * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. * * This software is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * ("GPL") version 2 as published by the Free Software Foundation. * See the file LICENSE.txt at the root directory of this source * distribution for additional information about the GNU GPL. * * For using ViSP with software that can not be combined with the GNU * GPL, please contact INRIA about acquiring a ViSP Professional * Edition License. * * See http://www.irisa.fr/lagadic/visp/visp.html for more information. * * This software was developed at: * INRIA Rennes - Bretagne Atlantique * Campus Universitaire de Beaulieu * 35042 Rennes Cedex * France * http://www.irisa.fr/lagadic * * If you have questions regarding the use of this file, please contact * INRIA at visp@inria.fr * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * * Description: * Send a command to the car-like Cycab mobile robot. * * Authors: * Fabien Spindler * *****************************************************************************/ /*! \example servoCycab.cpp Send a command to the car-like Cycab mobile robot. */ #include #include #include // std::fabs #include // numeric_limits #include #include #include #include #include using namespace std; #ifdef VISP_HAVE_CYCAB #include #include #include vpRobotCycab *cycab = NULL; bool bFinish = false; bool end = false; // The first CTRL-C stop properly the car by decreasing the velocity // and the steering angle, the second CTRL-C ends the execution void sighdl(int n) { printf("Received signal %d\n",n); bFinish=true; end = true; } #define MAXV 1.5 // velocity in m/S #define MAXPHI 20.0 // front steering angle in deg #define MAX_ACC_V 6 // m/s^2 #define MAX_VEL_PHI 4 // rad/s int main() { double v, phi; // Command to send double vm, phim; // Measures int kv,kphi; cycab = new vpRobotCycab(); kv = kphi = 1; v = 0.0; phi = 0.0; signal(SIGINT,sighdl); signal(SIGTERM,sighdl); signal(SIGPIPE,sighdl); double t0 = vpTime::measureTimeMs(); double t1 = vpTime::measureTimeMs(); double tprev; bool ctrc = false; double timestamp; while (!end) { tprev = t1; t1 = vpTime::measureTimeMs(); // Measures the velocity and the front steering angle from odometry cycab->getOdometry(vm, phim, timestamp); // measured values from odometry printf("State: t=%.1f s v=%f m/s and phi=%f deg\n\t", (timestamp-t0)/1000, vm, vpMath::deg(phim)); // Compute the command to apply to the car if (1) { v+=kv*0.002;if (fabs(v)>=MAXV) kv = -1 * kv; phi+=kphi*0.002;if (fabs(phi)>= vpMath::rad(MAXPHI)) kphi = -1 * kphi; } else { v=0.1;phi=0; } // Check is CTRL-C is requested if (bFinish) { // we stop the Cycab by decreasing the velocity and the steering // angle to zero std::cout << "Cycab stop requested" << std::endl; // Velocity decrease to zero double sign_v = 0; //if (vm != 0.) if (std::fabs(vm) > std::numeric_limits::epsilon()) sign_v = fabs(vm)/vm; v = vm - MAX_ACC_V*(t1-tprev)/1000*sign_v; if (fabs(v) < 0.1) v = 0; // Steering decrease to zero double sign_phi = 0; //if (phim != 0.) if (std::fabs(phim) > std::numeric_limits::epsilon()) sign_phi = fabs(phim)/phim; phi = phim - MAX_VEL_PHI*(t1-tprev)/1000*sign_phi; if (fabs(phi) < vpMath::rad(5)) phi = 0; // printf("stop requested: vm %f v %f phim %f phi %f sign_phi %f\n", // vm, v, phim, phi, sign_phi); //v = 0; //phi = 0; } // Send the command printf("Send : v %f m/s and phi %f deg\n", v, vpMath::deg(phi)); cycab->setCommand(v, phi); vpTime::wait(10); if (end && (!ctrc)) { end = false; ctrc=true;} } std::cout << "The end" << std::endl; return 0; } #else // VISP_HAVE_CYCAB int main() { cout << "Sorry no acces to the cycab" << endl; } #endif //VISP_HAVE_CYCAB ViSP-2.8.0/example/servo-cycab/CMakeLists.txt0000664000175000017500000000367112072022352021150 0ustar fspindlefspindle############################################################################# # # $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ # # This file is part of the ViSP software. # Copyright (C) 2005 - 2013 by INRIA. All rights reserved. # # This software is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # ("GPL") version 2 as published by the Free Software Foundation. # See the file LICENSE.txt at the root directory of this source # distribution for additional information about the GNU GPL. # # For using ViSP with software that can not be combined with the GNU # GPL, please contact INRIA about acquiring a ViSP Professional # Edition License. # # See http://www.irisa.fr/lagadic/visp/visp.html for more information. # # This software was developed at: # INRIA Rennes - Bretagne Atlantique # Campus Universitaire de Beaulieu # 35042 Rennes Cedex # France # http://www.irisa.fr/lagadic # # If you have questions regarding the use of this file, please contact # INRIA at visp@inria.fr # # This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE # WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # Description: # ViSP configuration file. # # Authors: # Fabien Spindler # ############################################################################# # SOURCE variable corresponds to the list of all the sources to build binaries. # The generate binary comes by removing the .cpp extension to # the source name. # # If you want to add/remove a source, modify here SET (SOURCE servoCycab.cpp servoCycabBasic.cpp ) # rule for binary build FOREACH(source ${SOURCE}) # Compute the name of the binary to create GET_FILENAME_COMPONENT(binary ${source} NAME_WE) # From source compile the binary and add link rules ADD_EXECUTABLE(${binary} ${source}) TARGET_LINK_LIBRARIES(${binary} ${VISP_INTERN_LIBRARY} ${VISP_EXTERN_LIBRARIES}) ENDFOREACH(source) ViSP-2.8.0/example/moments/0000775000175000017500000000000012173700525015655 5ustar fspindlefspindleViSP-2.8.0/example/moments/image/0000775000175000017500000000000012173700525016737 5ustar fspindlefspindleViSP-2.8.0/example/moments/image/servoMomentImage.cpp0000664000175000017500000003307712072022352022727 0ustar fspindlefspindle/**************************************************************************** * * $Id: servoMomentImage.cpp 4056 2013-01-05 13:04:42Z fspindle $ * * This file is part of the ViSP software. * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. * * This software is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * ("GPL") version 2 as published by the Free Software Foundation. * See the file LICENSE.txt at the root directory of this source * distribution for additional information about the GNU GPL. * * For using ViSP with software that can not be combined with the GNU * GPL, please contact INRIA about acquiring a ViSP Professional * Edition License. * * See http://www.irisa.fr/lagadic/visp/visp.html for more information. * * This software was developed at: * INRIA Rennes - Bretagne Atlantique * Campus Universitaire de Beaulieu * 35042 Rennes Cedex * France * http://www.irisa.fr/lagadic * * If you have questions regarding the use of this file, please contact * INRIA at visp@inria.fr * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * * Description: * Example of visual servoing with moments using an image as object * container * * Authors: * Filip Novotny * Manikandan.B *****************************************************************************/ /*! \example servoMomentImage.cpp Example of moment-based visual servoing with Images */ #define PRINT_CONDITION_NUMBER #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //setup robot parameters void paramRobot(); //update moment objects and interface void refreshScene(vpMomentObject &obj); //initialize scene in the interface void initScene(); //initialize the moment features void initFeatures(); void init(vpHomogeneousMatrix& cMo, vpHomogeneousMatrix& cdMo); void execute(unsigned int nbIter); //launch the simulation void setInteractionMatrixType(vpServo::vpServoIteractionMatrixType type); double error(); void _planeToABC(vpPlane& pl, double& A,double& B, double& C); void paramRobot(); #if !defined(WIN32) && !defined(VISP_HAVE_PTHREAD) // Robot simulator used in this example is not available int main() { std::cout << "Can't run this example since vpSimulatorAfma6 capability is not available." << std::endl; std::cout << "You should install pthread third-party library." << std::endl; } // No display available #elif !defined(VISP_HAVE_X11) && !defined(VISP_HAVE_OPENCV) && !defined(VISP_HAVE_GDI) && !defined(VISP_HAVE_D3D9) && !defined(VISP_HAVE_GTK) int main() { std::cout << "Can't run this example since no display capability is available." << std::endl; std::cout << "You should install one of the following third-party library: X11, OpenCV, GDI, GTK." << std::endl; } #else void init_visp_plot(vpPlot& ); int main() { //intial pose vpHomogeneousMatrix cMo(-0.1,-0.1,1.5,-vpMath::rad(20),-vpMath::rad(20),-vpMath::rad(30)); //Desired pose vpHomogeneousMatrix cdMo(vpHomogeneousMatrix(0.0,-0.0,1.0,vpMath::rad(0),vpMath::rad(0),-vpMath::rad(0))); //init the simulation init(cMo,cdMo); execute(1500); return 0; } //init the right display #if defined VISP_HAVE_X11 vpDisplayX displayInt; #elif defined VISP_HAVE_OPENCV vpDisplayOpenCV displayInt; #elif defined VISP_HAVE_GDI vpDisplayGDI displayInt; #elif defined VISP_HAVE_D3D9 vpDisplayD3D displayInt; #elif defined VISP_HAVE_GTK vpDisplayGTK displayInt; #endif //start and destination positioning matrices vpHomogeneousMatrix cMo; vpHomogeneousMatrix cdMo; vpRobotCamera robot;//robot used in this simulation vpImage Iint(480,640, 0);//internal image used for interface display vpServo task; //servoing task vpCameraParameters cam;//robot camera parameters double _error; //current error vpImageSimulator imsim;//image simulator used to simulate the perspective-projection camera //several images used in the simulation vpImage cur_img(480,640, 0); vpImage src_img(480,640, 0); vpImage dst_img(480,640, 0); vpImage start_img(480,640, 0); vpServo::vpServoIteractionMatrixType interaction_type; //current or desired //source and destination objects for moment manipulation vpMomentObject src(6); vpMomentObject dst(6); //moment sets and their corresponding features vpMomentCommon *moments; vpMomentCommon *momentsDes; vpFeatureMomentCommon *featureMoments; vpFeatureMomentCommon *featureMomentsDes; using namespace std; void initScene(){ vpColVector X[4]; for (int i = 0; i < 4; i++) X[i].resize(3); X[0][0] = -0.2; X[0][1] = -0.1; X[0][2] = 0; X[1][0] = 0.2; X[1][1] = -0.1; X[1][2] = 0; X[2][0] = 0.2; X[2][1] = 0.1; X[2][2] = 0; X[3][0] = -0.2; X[3][1] = 0.1; X[3][2] = 0; //init source and destination images vpImage tmp_img(480,640,255); vpImage tmp_start_img(480,640,vpRGBa(255,0,0)); vpImageSimulator imsim_start; imsim_start.setInterpolationType(vpImageSimulator::BILINEAR_INTERPOLATION) ; imsim_start.init(tmp_start_img, X); imsim_start.setCameraPosition(cdMo); imsim_start.getImage(start_img,cam); imsim.setInterpolationType(vpImageSimulator::BILINEAR_INTERPOLATION) ; imsim.init(tmp_img, X); imsim.setCameraPosition(cMo); imsim.getImage(src_img,cam); src.setType(vpMomentObject::DENSE_FULL_OBJECT); src.fromImage(src_img,128,cam); dst.setType(vpMomentObject::DENSE_FULL_OBJECT); imsim.setCameraPosition(cdMo); imsim.getImage(dst_img,cam); dst.fromImage(dst_img,128,cam); } void refreshScene(vpMomentObject &obj){ cur_img = 0; imsim.setCameraPosition(cMo); imsim.getImage(cur_img,cam); obj.fromImage(cur_img,128,cam); } void init(vpHomogeneousMatrix& _cMo, vpHomogeneousMatrix& _cdMo) { cMo = _cMo; //init source matrix cdMo = _cdMo; //init destination matrix interaction_type = vpServo::CURRENT;//use interaction matrix for current position displayInt.init(Iint,700,0, "Visual servoing with moments") ; paramRobot(); //set up robot parameters task.setServo(vpServo::EYEINHAND_CAMERA); initScene(); //initialize graphical scene (for interface) initFeatures();//initialize moment features } void initFeatures(){ //A,B,C parameters of source and destination plane double A; double B; double C; double Ad; double Bd; double Cd; //init main object: using moments up to order 5 //Initializing values from regular plane (with ax+by+cz=d convention) vpPlane pl; pl.setABCD(0,0,1.0,0); pl.changeFrame(cMo); _planeToABC(pl,A,B,C); pl.setABCD(0,0,1.0,0); pl.changeFrame(cdMo); _planeToABC(pl,Ad,Bd,Cd); //extracting initial position (actually we only care about Zdst) vpTranslationVector vec; cdMo.extract(vec); ///////////////////////////// initializing moments and features ///////////////////////////////// //don't need to be specific, vpMomentCommon automatically loads Xg,Yg,An,Ci,Cj,Alpha moments moments = new vpMomentCommon(vpMomentCommon ::getSurface(dst),vpMomentCommon::getMu3(dst),vpMomentCommon::getAlpha(dst), vec[2]); momentsDes = new vpMomentCommon(vpMomentCommon::getSurface(dst),vpMomentCommon::getMu3(dst),vpMomentCommon::getAlpha(dst),vec[2]); //same thing with common features featureMoments = new vpFeatureMomentCommon(*moments); featureMomentsDes = new vpFeatureMomentCommon(*momentsDes); moments->updateAll(src); momentsDes->updateAll(dst); featureMoments->updateAll(A,B,C); featureMomentsDes->updateAll(Ad,Bd,Cd); //setup the interaction type task.setInteractionMatrixType(interaction_type) ; //////////////////////////////////add useful features to task////////////////////////////// task.addFeature(featureMoments->getFeatureGravityNormalized(),featureMomentsDes->getFeatureGravityNormalized()); task.addFeature(featureMoments->getFeatureAn(),featureMomentsDes->getFeatureAn()); //the moments are different in case of a symmetric object task.addFeature(featureMoments->getFeatureCInvariant(),featureMomentsDes->getFeatureCInvariant(),(1 << 10) | (1 << 11)); task.addFeature(featureMoments->getFeatureAlpha(),featureMomentsDes->getFeatureAlpha()); task.setLambda(1.); } void execute(unsigned int nbIter){ vpPlot ViSP_plot; init_visp_plot(ViSP_plot); // Initialize plot object //init main object: using moments up to order 6 vpMomentObject obj(6); //setting object type (disrete, continuous[form polygon]) obj.setType(vpMomentObject::DENSE_FULL_OBJECT); vpTRACE("Display task information " ) ; task.print() ; vpDisplay::display(Iint); vpDisplay::flush(Iint); unsigned int iter=0; double t=0; robot.setPosition(cMo); float sampling_time = 0.010f; // Sampling period in seconds robot.setSamplingTime(sampling_time); // For plotting vpPoseVector currentpose; vpColVector err_features; ///////////////////SIMULATION LOOP///////////////////////////// while(iter++updateAll(obj); //and update our features. Do it in that order. Features need to use the information computed by moments featureMoments->updateAll(A,B,C); //some graphics again imsim.setCameraPosition(cMo); Iint = start_img; imsim.getImage(Iint,cam); vpDisplay::display(Iint) ; vpDisplay::flush(Iint); if (iter == 1) vpDisplay::getClick(Iint) ; v = task.computeControlLaw() ; //pilot robot using position control. The displacement is t*v with t=10ms step //robot.setPosition(vpRobot::CAMERA_FRAME,0.01*v); err_features = task.error; std::cout<<" || s - s* || = "<(singularvals.getMaxValue()/singularvals.getMinValue()); std::cout<<"Condition Number: "<::epsilon()){ std::cout << "Invalid position:" << std::endl; std::cout << cMo << std::endl; std::cout << "Cannot put plane in the form 1/Z=Ax+By+C." << std::endl; throw vpException(vpException::divideByZeroError,"invalid position!"); } A=-pl.getA()/pl.getD(); B=-pl.getB()/pl.getD(); C=-pl.getC()/pl.getD(); } void paramRobot(){ cam = vpCameraParameters(640,480,320,240); } void init_visp_plot(vpPlot& ViSP_plot) { /* ------------------------------------- * Initialize ViSP Plotting * ------------------------------------- */ const unsigned int NbGraphs = 3; // No. of graphs const unsigned int NbCurves_in_graph[NbGraphs] = {6,6,6}; // Curves in each graph ViSP_plot.init(NbGraphs , 800, 800, 10, 10, "Visual Servoing results..."); vpColor Colors[6] = {\ // Colour for s1, s2, s3, in 1st plot vpColor::red, vpColor::green, vpColor::blue, \ vpColor::orange, vpColor::cyan,vpColor::purple }; for (unsigned int p = 0; p #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //setup robot parameters void paramRobot(); //update moment objects and interface void refreshScene(vpMomentObject &obj); //initialize scene in the interface void initScene(); //initialize the moment features void initFeatures(); void init(vpHomogeneousMatrix& cMo, vpHomogeneousMatrix& cdMo); void execute(unsigned int nbIter); //launch the simulation void setInteractionMatrixType(vpServo::vpServoIteractionMatrixType type); double error(); void _planeToABC(vpPlane& pl, double& A,double& B, double& C); void paramRobot(); #if !defined(WIN32) && !defined(VISP_HAVE_PTHREAD) // Robot simulator used in this example is not available int main() { std::cout << "Can't run this example since vpSimulatorAfma6 capability is not available." << std::endl; std::cout << "You should install pthread third-party library." << std::endl; } // No display available #elif !defined(VISP_HAVE_X11) && !defined(VISP_HAVE_OPENCV) && !defined(VISP_HAVE_GDI) && !defined(VISP_HAVE_D3D9) && !defined(VISP_HAVE_GTK) int main() { std::cout << "Can't run this example since no display capability is available." << std::endl; std::cout << "You should install one of the following third-party library: X11, OpenCV, GDI, GTK." << std::endl; } #else int main(){ //intial pose vpHomogeneousMatrix cMo(-0.1,-0.1,1.5,-vpMath::rad(20),-vpMath::rad(20),-vpMath::rad(30)); //Desired pose vpHomogeneousMatrix cdMo(vpHomogeneousMatrix(0.0,0.0,1.0,vpMath::rad(0),vpMath::rad(0),-vpMath::rad(0))); //init and run the simulation init(cMo,cdMo); execute(1500); return 0; } //init the right display #if defined VISP_HAVE_X11 vpDisplayX displayInt; #elif defined VISP_HAVE_OPENCV vpDisplayOpenCV displayInt; #elif defined VISP_HAVE_GDI vpDisplayGDI displayInt; #elif defined VISP_HAVE_D3D9 vpDisplayD3D displayInt; #elif defined VISP_HAVE_GTK vpDisplayGTK displayInt; #endif //start and destination positioning matrices vpHomogeneousMatrix cMo; vpHomogeneousMatrix cdMo; vpSimulatorAfma6 robot(false);//robot used in this simulation vpImage Iint(480,640, 255);//internal image used for interface display vpServo task; //servoing task vpCameraParameters cam;//robot camera parameters double _error; //current error vpServo::vpServoIteractionMatrixType interaction_type; //current or desired vpImageSimulator imsim;//image simulator used to simulate the perspective-projection camera //source and destination objects for moment manipulation vpMomentObject src(6); vpMomentObject dst(6); //moment sets and their corresponding features vpMomentCommon *moments; vpMomentCommon *momentsDes; vpFeatureMomentCommon *featureMoments; vpFeatureMomentCommon *featureMomentsDes; using namespace std; void initScene(){ vector src_pts; vector dst_pts; double x[5] = { 0.2, 0.2,-0.2,-0.2, 0.2 }; double y[5] = {-0.1, 0.1, 0.1,-0.1,-0.1 }; int nbpoints = 4; for (int i = 0 ; i < nbpoints ; i++){ vpPoint p; p.setWorldCoordinates(x[i],y[i],0.0); p.track(cMo) ; src_pts.push_back(p); } src.setType(vpMomentObject::DENSE_POLYGON); src.fromVector(src_pts); for (int i = 0 ; i < nbpoints ; i++){ vpPoint p; p.setWorldCoordinates(x[i],y[i],0.0); p.track(cdMo) ; dst_pts.push_back(p); } dst.setType(vpMomentObject::DENSE_POLYGON); dst.fromVector(dst_pts); } void refreshScene(vpMomentObject &obj){ double x[5] = { 0.2, 0.2,-0.2,-0.2, 0.2 }; double y[5] = {-0.1, 0.1, 0.1,-0.1,-0.1 }; int nbpoints = 5; vector cur_pts; for (int i = 0 ; i < nbpoints ; i++){ vpPoint p; p.setWorldCoordinates(x[i],y[i],0.0); p.track(cMo) ; cur_pts.push_back(p); } obj.fromVector(cur_pts); } void init(vpHomogeneousMatrix& _cMo, vpHomogeneousMatrix& _cdMo) { cMo = _cMo; cdMo = _cdMo; interaction_type = vpServo::CURRENT; displayInt.init(Iint,700,0, "Visual servoing with moments") ; paramRobot(); //set up robot parameters task.setServo(vpServo::EYEINHAND_CAMERA); initScene(); //initialize graphical scene (for interface) initFeatures();//initialize moment features } void initFeatures(){ //A,B,C parameters of source and destination plane double A; double B; double C; double Ad; double Bd; double Cd; //init main object: using moments up to order 6 //Initializing values from regular plane (with ax+by+cz=d convention) vpPlane pl; pl.setABCD(0,0,1.0,0); pl.changeFrame(cMo); _planeToABC(pl,A,B,C); pl.setABCD(0,0,1.0,0); pl.changeFrame(cdMo); _planeToABC(pl,Ad,Bd,Cd); //extracting initial position (actually we only care about Zdst) vpTranslationVector vec; cdMo.extract(vec); ///////////////////////////// initializing moments and features ///////////////////////////////// //don't need to be specific, vpMomentCommon automatically loads Xg,Yg,An,Ci,Cj,Alpha moments moments = new vpMomentCommon(vpMomentCommon ::getSurface(dst),vpMomentCommon::getMu3(dst),vpMomentCommon::getAlpha(dst), vec[2]); momentsDes = new vpMomentCommon(vpMomentCommon::getSurface(dst),vpMomentCommon::getMu3(dst),vpMomentCommon::getAlpha(dst),vec[2]); //same thing with common features featureMoments = new vpFeatureMomentCommon(*moments); featureMomentsDes = new vpFeatureMomentCommon(*momentsDes); moments->updateAll(src); momentsDes->updateAll(dst); featureMoments->updateAll(A,B,C); featureMomentsDes->updateAll(Ad,Bd,Cd); //setup the interaction type task.setInteractionMatrixType(interaction_type) ; //////////////////////////////////add useful features to task////////////////////////////// task.addFeature(featureMoments->getFeatureGravityNormalized(),featureMomentsDes->getFeatureGravityNormalized()); task.addFeature(featureMoments->getFeatureAn(),featureMomentsDes->getFeatureAn()); //the moments are different in case of a symmetric object task.addFeature(featureMoments->getFeatureCInvariant(),featureMomentsDes->getFeatureCInvariant(),(1 << 10) | (1 << 11)); task.addFeature(featureMoments->getFeatureAlpha(),featureMomentsDes->getFeatureAlpha()); task.setLambda(0.4) ; } void execute(unsigned int nbIter){ //init main object: using moments up to order 5 vpMomentObject obj(6); //setting object type (disrete, continuous[form polygon]) obj.setType(vpMomentObject::DENSE_POLYGON); vpTRACE("Display task information " ) ; task.print() ; vpDisplay::display(Iint); robot.getInternalView(Iint); vpDisplay::flush(Iint); unsigned int iter=0; double t=0; ///////////////////SIMULATION LOOP///////////////////////////// while(iter++updateAll(obj); //and update our features. Do it in that order. Features need to use the information computed by moments featureMoments->updateAll(A,B,C); vpDisplay::display(Iint) ; robot.getInternalView(Iint); vpDisplay::flush(Iint); if (iter == 1) vpDisplay::getClick(Iint) ; v = task.computeControlLaw() ; //pilot robot using position control. The displacement is t*v with t=10ms step robot.setPosition(vpRobot::CAMERA_FRAME,0.01*v); vpTime::wait(t,10); _error = ( task.getError() ).sumSquare(); } task.kill(); vpTRACE("\n\nClick in the internal view window to end..."); vpDisplay::getClick(Iint) ; delete moments; delete momentsDes; delete featureMoments; delete featureMomentsDes; } void setInteractionMatrixType(vpServo::vpServoIteractionMatrixType type){interaction_type=type;} double error(){return _error;} void removeJointLimits(vpSimulatorAfma6& robot){ vpColVector limMin(6); vpColVector limMax(6); limMin[0] = vpMath::rad(-3600); limMin[1] = vpMath::rad(-3600); limMin[2] = vpMath::rad(-3600); limMin[3] = vpMath::rad(-3600); limMin[4] = vpMath::rad(-3600); limMin[5] = vpMath::rad(-3600); limMax[0] = vpMath::rad(3600); limMax[1] = vpMath::rad(3600); limMax[2] = vpMath::rad(3600); limMax[3] = vpMath::rad(3600); limMax[4] = vpMath::rad(3600); limMax[5] = vpMath::rad(3600); robot.setJointLimit(limMin,limMax); } void _planeToABC(vpPlane& pl, double& A,double& B, double& C){ if(fabs(pl.getD())::epsilon()){ std::cout << "Invalid position:" << std::endl; std::cout << cMo << std::endl; std::cout << "Cannot put plane in the form 1/Z=Ax+By+C." << std::endl; throw vpException(vpException::divideByZeroError,"invalid position!"); } A=-pl.getA()/pl.getD(); B=-pl.getB()/pl.getD(); C=-pl.getC()/pl.getD(); } void paramRobot(){ /*Initialise the robot and especially the camera*/ robot.init(vpAfma6::TOOL_CCMOP, vpCameraParameters::perspectiveProjWithoutDistortion); robot.setCurrentViewColor(vpColor(150,150,150)); robot.setDesiredViewColor(vpColor(200,200,200)); robot.setRobotState(vpRobot::STATE_POSITION_CONTROL); removeJointLimits(robot); robot.initScene(vpWireFrameSimulator::RECTANGLE, vpWireFrameSimulator::D_STANDARD); /*Initialise the position of the object relative to the pose of the robot's camera*/ robot.initialiseObjectRelativeToCamera(cMo); /*Set the desired position (for the displaypart)*/ robot.setDesiredCameraPosition(cdMo); robot.getCameraParameters(cam,Iint); } #endif ViSP-2.8.0/example/moments/polygon/CMakeLists.txt0000664000175000017500000000344612072022352022104 0ustar fspindlefspindle############################################################################# # # $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ # # This file is part of the ViSP software. # Copyright (C) 2005 - 2013 by INRIA. All rights reserved. # # This software is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # ("GPL") version 2 as published by the Free Software Foundation. # See the file LICENSE.txt at the root directory of this source # distribution for additional information about the GNU GPL. # # For using ViSP with software that can not be combined with the GNU # GPL, please contact INRIA about acquiring a ViSP Professional # Edition License. # # See http://www.irisa.fr/lagadic/visp/visp.html for more information. # # This software was developed at: # INRIA Rennes - Bretagne Atlantique # Campus Universitaire de Beaulieu # 35042 Rennes Cedex # France # http://www.irisa.fr/lagadic # # If you have questions regarding the use of this file, please contact # INRIA at visp@inria.fr # # This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE # WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # Description: # ViSP overall configuration file. # # Authors: # Filip Novotny # ############################################################################# # All source and headers in local directory are added to the project before # the exacutable is formed. FILE(GLOB SOURCE "*.cpp") FILE(GLOB HEADERS "*.h") LIST(APPEND FILES ${SOURCE}) LIST(APPEND FILES ${HEADERS}) ADD_EXECUTABLE(servoMomentsPolygon ${FILES}) TARGET_LINK_LIBRARIES(servoMomentsPolygon ${VISP_INTERN_LIBRARY} ${VISP_EXTERN_LIBRARIES}) SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "core*;*~;gmon.out;DartTestfile.txt" ) ViSP-2.8.0/example/moments/points/0000775000175000017500000000000012173700525017171 5ustar fspindlefspindleViSP-2.8.0/example/moments/points/servoMomentPoints.cpp0000664000175000017500000002733712072022352023415 0ustar fspindlefspindle/**************************************************************************** * * $Id: servoMomentPoints.cpp 4056 2013-01-05 13:04:42Z fspindle $ * * This file is part of the ViSP software. * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. * * This software is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * ("GPL") version 2 as published by the Free Software Foundation. * See the file LICENSE.txt at the root directory of this source * distribution for additional information about the GNU GPL. * * For using ViSP with software that can not be combined with the GNU * GPL, please contact INRIA about acquiring a ViSP Professional * Edition License. * * See http://www.irisa.fr/lagadic/visp/visp.html for more information. * * This software was developed at: * INRIA Rennes - Bretagne Atlantique * Campus Universitaire de Beaulieu * 35042 Rennes Cedex * France * http://www.irisa.fr/lagadic * * If you have questions regarding the use of this file, please contact * INRIA at visp@inria.fr * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * * Description: * Example of visual servoing with moments using discrete points as object * container * * Authors: * Filip Novotny * *****************************************************************************/ /*! \example servoMomentPoints.cpp Example of moment-based visual servoing with Images */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //setup robot parameters void paramRobot(); //update moment objects and interface void refreshScene(vpMomentObject &obj); //initialize scene in the interface void initScene(); //initialize the moment features void initFeatures(); void init(vpHomogeneousMatrix& cMo, vpHomogeneousMatrix& cdMo); void execute(unsigned int nbIter); //launch the simulation void setInteractionMatrixType(vpServo::vpServoIteractionMatrixType type); double error(); void _planeToABC(vpPlane& pl, double& A,double& B, double& C); void paramRobot(); #if !defined(WIN32) && !defined(VISP_HAVE_PTHREAD) // Robot simulator used in this example is not available int main() { std::cout << "Can't run this example since vpSimulatorAfma6 capability is not available." << std::endl; std::cout << "You should install pthread third-party library." << std::endl; } // No display available #elif !defined(VISP_HAVE_X11) && !defined(VISP_HAVE_OPENCV) && !defined(VISP_HAVE_GDI) && !defined(VISP_HAVE_D3D9) && !defined(VISP_HAVE_GTK) int main() { std::cout << "Can't run this example since no display capability is available." << std::endl; std::cout << "You should install one of the following third-party library: X11, OpenCV, GDI, GTK." << std::endl; } #else int main(){ //intial pose vpHomogeneousMatrix cMo(0.05,0.1,1.5,vpMath::rad(30),vpMath::rad(20),-vpMath::rad(15)); //Desired pose vpHomogeneousMatrix cdMo(vpHomogeneousMatrix(0.0,0.0,1.0,vpMath::rad(0),vpMath::rad(0),vpMath::rad(0))); //init and run the simulation init(cMo,cdMo); execute(1500); return 0; } //init the right display #if defined VISP_HAVE_X11 vpDisplayX displayInt; #elif defined VISP_HAVE_OPENCV vpDisplayOpenCV displayInt; #elif defined VISP_HAVE_GDI vpDisplayGDI displayInt; #elif defined VISP_HAVE_D3D9 vpDisplayD3D displayInt; #elif defined VISP_HAVE_GTK vpDisplayGTK displayInt; #endif //start and destination positioning matrices vpHomogeneousMatrix cMo; vpHomogeneousMatrix cdMo; vpSimulatorAfma6 robot(false);//robot used in this simulation vpImage Iint(480,640, 255);//internal image used for interface display vpServo::vpServoIteractionMatrixType interaction_type; //current or desired vpServo task; //servoing task vpCameraParameters cam;//robot camera parameters double _error; //current error vpImageSimulator imsim;//image simulator used to simulate the perspective-projection camera //moment sets and their corresponding features vpMomentCommon *moments; vpMomentCommon *momentsDes; vpFeatureMomentCommon *featureMoments; vpFeatureMomentCommon *featureMomentsDes; //source and destination objects for moment manipulation vpMomentObject src(6); vpMomentObject dst(6); using namespace std; void initScene(){ vector src_pts; vector dst_pts; double x[8] = { 1,3, 4,-1 ,-3,-2,-1,1}; double y[8] = { 0,1, 4, 4, -2,-2, 1,0}; int nbpoints = 8; for (int i = 0 ; i < nbpoints ; i++){ vpPoint p; p.setWorldCoordinates(x[i]/20,y[i]/20,0.0); p.track(cMo) ; src_pts.push_back(p); } src.setType(vpMomentObject::DISCRETE); src.fromVector(src_pts); for (int i = 0 ; i < nbpoints ; i++){ vpPoint p; p.setWorldCoordinates(x[i]/20,y[i]/20,0.0); p.track(cdMo) ; dst_pts.push_back(p); } dst.setType(vpMomentObject::DISCRETE); dst.fromVector(dst_pts); } void initFeatures(){ //A,B,C parameters of source and destination plane double A; double B; double C; double Ad; double Bd; double Cd; //init main object: using moments up to order 6 //Initializing values from regular plane (with ax+by+cz=d convention) vpPlane pl; pl.setABCD(0,0,1.0,0); pl.changeFrame(cMo); _planeToABC(pl,A,B,C); pl.setABCD(0,0,1.0,0); pl.changeFrame(cdMo); _planeToABC(pl,Ad,Bd,Cd); //extracting initial position (actually we only care about Zdst) vpTranslationVector vec; cdMo.extract(vec); ///////////////////////////// initializing moments and features ///////////////////////////////// //don't need to be specific, vpMomentCommon automatically loads Xg,Yg,An,Ci,Cj,Alpha moments moments = new vpMomentCommon(vpMomentCommon ::getSurface(dst),vpMomentCommon::getMu3(dst),vpMomentCommon::getAlpha(dst), vec[2]); momentsDes = new vpMomentCommon(vpMomentCommon::getSurface(dst),vpMomentCommon::getMu3(dst),vpMomentCommon::getAlpha(dst),vec[2]); //same thing with common features featureMoments = new vpFeatureMomentCommon(*moments); featureMomentsDes = new vpFeatureMomentCommon(*momentsDes); moments->updateAll(src); momentsDes->updateAll(dst); featureMoments->updateAll(A,B,C); featureMomentsDes->updateAll(Ad,Bd,Cd); //setup the interaction type task.setInteractionMatrixType(interaction_type) ; //////////////////////////////////add useful features to task////////////////////////////// task.addFeature(featureMoments->getFeatureGravityNormalized(),featureMomentsDes->getFeatureGravityNormalized()); task.addFeature(featureMoments->getFeatureAn(),featureMomentsDes->getFeatureAn()); task.addFeature(featureMoments->getFeatureCInvariant(),featureMomentsDes->getFeatureCInvariant(),(1 << 3) | (1 << 5)); task.addFeature(featureMoments->getFeatureAlpha(),featureMomentsDes->getFeatureAlpha()); task.setLambda(1.) ; } void refreshScene(vpMomentObject &obj){ //double x[8] = { 0.05,0.15, 0.2,-0.05 ,-0.15,-0.1,-0.05,0.05}; //double y[8] = { 0,0.05, 0.2, 0.2, -0.1,-0.1, 0.05,0}; double x[8] = { 1,3, 4,-1 ,-3,-2,-1,1}; double y[8] = { 0,1, 4, 4, -2,-2, 1,0}; int nbpoints = 8; vector cur_pts; for (int i = 0 ; i < nbpoints ; i++){ vpPoint p; p.setWorldCoordinates(x[i]/20,y[i]/20,0.0); p.track(cMo) ; cur_pts.push_back(p); } obj.fromVector(cur_pts); } void init(vpHomogeneousMatrix& _cMo, vpHomogeneousMatrix& _cdMo) { cMo = _cMo; //init source matrix cdMo = _cdMo; //init destination matrix interaction_type = vpServo::CURRENT; //use interaction matrix for current position displayInt.init(Iint,700,0, "Visual servoing with moments") ; paramRobot(); //set up robot parameters task.setServo(vpServo::EYEINHAND_CAMERA); initScene(); //initialize graphical scene (for interface) initFeatures();//initialize moment features } void execute(unsigned int nbIter){ //init main object: using moments up to order 6 vpMomentObject obj(6); //setting object type (disrete, continuous[form polygon]) obj.setType(vpMomentObject::DISCRETE); vpTRACE("Display task information " ) ; task.print() ; vpDisplay::display(Iint); robot.getInternalView(Iint); vpDisplay::flush(Iint); unsigned int iter=0; ///////////////////SIMULATION LOOP///////////////////////////// while(iter++updateAll(obj); //and update our features. Do it in that order. Features need to use the information computed by moments featureMoments->updateAll(A,B,C); vpDisplay::display(Iint) ; robot.getInternalView(Iint); vpDisplay::flush(Iint); if (iter == 1) vpDisplay::getClick(Iint) ; v = task.computeControlLaw() ; //pilot robot using position control. The displacement is t*v with t=10ms step //robot.setPosition(vpRobot::CAMERA_FRAME,0.01*v); robot.setVelocity(vpRobot::CAMERA_FRAME,v); _error = ( task.getError() ).sumSquare(); } task.kill(); vpTRACE("\n\nClick in the internal view window to end..."); vpDisplay::getClick(Iint) ; delete moments; delete momentsDes; delete featureMoments; delete featureMomentsDes; } void removeJointLimits(vpSimulatorAfma6& robot){ vpColVector limMin(6); vpColVector limMax(6); limMin[0] = vpMath::rad(-3600); limMin[1] = vpMath::rad(-3600); limMin[2] = vpMath::rad(-3600); limMin[3] = vpMath::rad(-3600); limMin[4] = vpMath::rad(-3600); limMin[5] = vpMath::rad(-3600); limMax[0] = vpMath::rad(3600); limMax[1] = vpMath::rad(3600); limMax[2] = vpMath::rad(3600); limMax[3] = vpMath::rad(3600); limMax[4] = vpMath::rad(3600); limMax[5] = vpMath::rad(3600); robot.setJointLimit(limMin,limMax); robot.setMaxRotationVelocity(99999); robot.setMaxTranslationVelocity(999999); } void _planeToABC(vpPlane& pl, double& A,double& B, double& C){ if(fabs(pl.getD())::epsilon()){ std::cout << "Invalid position:" << std::endl; std::cout << cMo << std::endl; std::cout << "Cannot put plane in the form 1/Z=Ax+By+C." << std::endl; throw vpException(vpException::divideByZeroError,"invalid position!"); } A=-pl.getA()/pl.getD(); B=-pl.getB()/pl.getD(); C=-pl.getC()/pl.getD(); } void paramRobot(){ /*Initialise the robot and especially the camera*/ robot.init(vpAfma6::TOOL_CCMOP, vpCameraParameters::perspectiveProjWithoutDistortion); robot.setCurrentViewColor(vpColor(150,150,150)); robot.setDesiredViewColor(vpColor(200,200,200)); robot.setRobotState(vpRobot::STATE_VELOCITY_CONTROL); removeJointLimits(robot); robot.initScene(vpWireFrameSimulator::POINT_CLOUD, vpWireFrameSimulator::D_STANDARD); robot.setConstantSamplingTimeMode(true); /*Initialise the position of the object relative to the pose of the robot's camera*/ robot.initialiseObjectRelativeToCamera(cMo); /*Set the desired position (for the displaypart)*/ robot.setDesiredCameraPosition(cdMo); robot.getCameraParameters(cam,Iint); } void setInteractionMatrixType(vpServo::vpServoIteractionMatrixType type){interaction_type=type;} double error(){return _error;} #endif ViSP-2.8.0/example/moments/points/CMakeLists.txt0000664000175000017500000000344412072022352021727 0ustar fspindlefspindle############################################################################# # # $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ # # This file is part of the ViSP software. # Copyright (C) 2005 - 2013 by INRIA. All rights reserved. # # This software is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # ("GPL") version 2 as published by the Free Software Foundation. # See the file LICENSE.txt at the root directory of this source # distribution for additional information about the GNU GPL. # # For using ViSP with software that can not be combined with the GNU # GPL, please contact INRIA about acquiring a ViSP Professional # Edition License. # # See http://www.irisa.fr/lagadic/visp/visp.html for more information. # # This software was developed at: # INRIA Rennes - Bretagne Atlantique # Campus Universitaire de Beaulieu # 35042 Rennes Cedex # France # http://www.irisa.fr/lagadic # # If you have questions regarding the use of this file, please contact # INRIA at visp@inria.fr # # This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE # WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # Description: # ViSP overall configuration file. # # Authors: # Filip Novotny # ############################################################################# # All source and headers in local directory are added to the project before # the exacutable is formed. FILE(GLOB SOURCE "*.cpp") FILE(GLOB HEADERS "*.h") LIST(APPEND FILES ${SOURCE}) LIST(APPEND FILES ${HEADERS}) ADD_EXECUTABLE(servoMomentsPoints ${FILES}) TARGET_LINK_LIBRARIES(servoMomentsPoints ${VISP_INTERN_LIBRARY} ${VISP_EXTERN_LIBRARIES}) SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "core*;*~;gmon.out;DartTestfile.txt" ) ViSP-2.8.0/example/homography/0000775000175000017500000000000012173700526016351 5ustar fspindlefspindleViSP-2.8.0/example/homography/homographyHartleyDLT2DObject.cpp0000664000175000017500000001435512072022352024444 0ustar fspindlefspindle/**************************************************************************** * * $Id: homographyHartleyDLT2DObject.cpp 4056 2013-01-05 13:04:42Z fspindle $ * * This file is part of the ViSP software. * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. * * This software is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * ("GPL") version 2 as published by the Free Software Foundation. * See the file LICENSE.txt at the root directory of this source * distribution for additional information about the GNU GPL. * * For using ViSP with software that can not be combined with the GNU * GPL, please contact INRIA about acquiring a ViSP Professional * Edition License. * * See http://www.irisa.fr/lagadic/visp/visp.html for more information. * * This software was developed at: * INRIA Rennes - Bretagne Atlantique * Campus Universitaire de Beaulieu * 35042 Rennes Cedex * France * http://www.irisa.fr/lagadic * * If you have questions regarding the use of this file, please contact * INRIA at visp@inria.fr * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * * Description: * Example of the HartleyDLT homography estimation algorithm. * * Authors: * Eric Marchand * *****************************************************************************/ /*! \file homographyHartleyDLT2DObject.cpp \brief Example of the HartleyDLT homography estimation algorithm using vpHomography class. */ /*! \example homographyHartleyDLT2DObject.cpp Example of the HartleyDLT homography estimation algorithm using vpHomography class. */ #include #include #include #include #include #include #include #include #include #include #include // List of allowed command line options #define GETOPTARGS "h" #define L 0.1 #define nbpt 5 /*! Print the program options. \param name : Program name. \param badparam : Bad parameter name. */ void usage(const char *name, const char *badparam) { fprintf(stdout, "\n\ Test the HartleyDLT homography estimation algorithm.\n\ \n\ SYNOPSIS\n\ %s [-h]\n", name); fprintf(stdout, "\n\ OPTIONS: Default\n\ -h\n\ Print the help.\n"); if (badparam) { fprintf(stderr, "ERROR: \n" ); fprintf(stderr, "\nBad parameter [%s]\n", badparam); } } /*! Set the program options. \param argc : Command line number of parameters. \param argv : Array of command line parameters. \return false if the program has to be stopped, true otherwise. */ bool getOptions(int argc, const char **argv) { const char *optarg; int c; while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { switch (c) { case 'h': usage(argv[0], NULL); return false; break; default: usage(argv[0], optarg); return false; break; } } if ((c == 1) || (c == -1)) { // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; std::cerr << " Bad argument " << optarg << std::endl << std::endl; return false; } return true; } int main(int argc, const char ** argv) { // Read the command line options if (getOptions(argc, argv) == false) { exit (-1); } int i ; vpPoint P[nbpt] ; // Point to be tracked double xa[nbpt], ya[nbpt] ; double xb[nbpt], yb[nbpt] ; vpPoint aP[nbpt] ; // Point to be tracked vpPoint bP[nbpt] ; // Point to be tracked P[0].setWorldCoordinates(-L,-L, 0 ) ; P[1].setWorldCoordinates(2*L,-L, 0 ) ; P[2].setWorldCoordinates(L,L, 0 ) ; P[3].setWorldCoordinates(-L,3*L, 0 ) ; P[4].setWorldCoordinates(0,0, 0 ) ; /* P[5].setWorldCoordinates(10,20, 0 ) ; P[6].setWorldCoordinates(-10,12, 0 ) ; */ vpHomogeneousMatrix bMo(0,0,1, 0,0,0) ; vpHomogeneousMatrix aMb(1,0,0.0,vpMath::rad(10),0,vpMath::rad(40)) ; vpHomogeneousMatrix aMo =aMb*bMo ; for(i=0 ; i < nbpt ; i++) { P[i].project(aMo) ; aP[i] = P[i] ; xa[i] = P[i].get_x() ; ya[i] = P[i].get_y() ; } for(i=0 ; i < nbpt ; i++) { P[i].project(bMo) ; bP[i] = P[i] ; xb[i] = P[i].get_x() ; yb[i] = P[i].get_y() ; } std::cout << "-------------------------------" < #include #include #include #include #include #include #include #include #include #include #include // List of allowed command line options #define GETOPTARGS "h" #define L 0.1 #define nbpt 11 /*! Print the program options. \param name : Program name. \param badparam : Bad parameter name. */ void usage(const char *name, const char *badparam) { fprintf(stdout, "\n\ Test the Ransac homography estimation algorithm.\n\ \n\ SYNOPSIS\n\ %s [-h]\n", name); fprintf(stdout, "\n\ OPTIONS: Default\n\ -h\n\ Print the help.\n"); if (badparam) { fprintf(stderr, "ERROR: \n" ); fprintf(stderr, "\nBad parameter [%s]\n", badparam); } } /*! Set the program options. \param argc : Command line number of parameters. \param argv : Array of command line parameters. \return false if the program has to be stopped, true otherwise. */ bool getOptions(int argc, const char **argv) { const char *optarg; int c; while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { switch (c) { case 'h': usage(argv[0], NULL); return false; break; default: usage(argv[0], optarg); return false; break; } } if ((c == 1) || (c == -1)) { // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; std::cerr << " Bad argument " << optarg << std::endl << std::endl; return false; } return true; } int main(int argc, const char ** argv) { // Read the command line options if (getOptions(argc, argv) == false) { exit (-1); } int i ; vpPoint P[nbpt] ; // Point to be tracked double xa[nbpt], ya[nbpt] ; double xb[nbpt], yb[nbpt] ; vpPoint aP[nbpt] ; // Point to be tracked vpPoint bP[nbpt] ; // Point to be tracked P[0].setWorldCoordinates(-L,-L, 0 ) ; // inlier P[1].setWorldCoordinates(2*L,-L, 0 ) ; // inlier P[2].setWorldCoordinates(L,L, 0 ) ; // inlier P[3].setWorldCoordinates(-L,3*L, 0 ) ; // inlier P[4].setWorldCoordinates(0,0, L ) ; P[5].setWorldCoordinates(L,-2*L, L ) ; P[6].setWorldCoordinates(L,-4*L, 2*L ) ; P[7].setWorldCoordinates(-2*L,-L, -3*L ) ; P[8].setWorldCoordinates(-5*L,-5*L, 0 ) ; // inlier P[9].setWorldCoordinates(-2*L,+3*L, 4*L ) ; P[10].setWorldCoordinates(-2*L,-0.5*L, 0 ) ; /* P[5].setWorldCoordinates(10,20, 0 ) ; P[6].setWorldCoordinates(-10,12, 0 ) ; */ vpHomogeneousMatrix bMo(0,0,1, 0,0,0) ; vpHomogeneousMatrix aMb(0.1,0.1,0.1,vpMath::rad(10),0,vpMath::rad(40)) ; vpHomogeneousMatrix aMo =aMb*bMo ; for(i=0 ; i < nbpt ; i++) { P[i].project(aMo) ; aP[i] = P[i] ; xa[i] = P[i].get_x() ; ya[i] = P[i].get_y() ; } for(i=0 ; i < nbpt ; i++) { P[i].project(bMo) ; bP[i] = P[i] ; xb[i] = P[i].get_x() ; yb[i] = P[i].get_y() ; } std::cout << "-------------------------------" < #include #include #include #include #include #include #include #include #include #include // List of allowed command line options #define GETOPTARGS "h" #define L 0.1 #define nbpt 11 /*! Print the program options. \param name : Program name. \param badparam : Bad parameter name. */ void usage(const char *name, const char *badparam) { fprintf(stdout, "\n\ Test the HLM (Malis) homography estimation algorithm with a 3D object.\n\ \n\ SYNOPSIS\n\ %s [-h]\n", name); fprintf(stdout, "\n\ OPTIONS: Default\n\ -h\n\ Print the help.\n"); if (badparam) { fprintf(stderr, "ERROR: \n" ); fprintf(stderr, "\nBad parameter [%s]\n", badparam); } } /*! Set the program options. \param argc : Command line number of parameters. \param argv : Array of command line parameters. \return false if the program has to be stopped, true otherwise. */ bool getOptions(int argc, const char **argv) { const char *optarg; int c; while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { switch (c) { case 'h': usage(argv[0], NULL); return false; break; default: usage(argv[0], optarg); return false; break; } } if ((c == 1) || (c == -1)) { // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; std::cerr << " Bad argument " << optarg << std::endl << std::endl; return false; } return true; } int main(int argc, const char ** argv) { // Read the command line options if (getOptions(argc, argv) == false) { exit (-1); } int i ; vpPoint P[nbpt] ; // Point to be tracked double xa[nbpt], ya[nbpt] ; double xb[nbpt], yb[nbpt] ; vpPoint aP[nbpt] ; // Point to be tracked vpPoint bP[nbpt] ; // Point to be tracked P[0].setWorldCoordinates(-L,-L, 0 ) ; P[1].setWorldCoordinates(2*L,-L, 0 ) ; P[2].setWorldCoordinates(L,L, 0 ) ; P[3].setWorldCoordinates(-L,3*L, 0 ) ; P[4].setWorldCoordinates(0,0, L ) ; P[5].setWorldCoordinates(L,-2*L, L ) ; P[6].setWorldCoordinates(L,-4*L, 2*L ) ; P[7].setWorldCoordinates(-2*L,-L, -L ) ; P[8].setWorldCoordinates(-5*L,-5*L, L ) ; P[9].setWorldCoordinates(-2*L,+3*L, 2*L ) ; P[10].setWorldCoordinates(-2*L,-0.5*L, 2*L ) ; /* P[5].setWorldCoordinates(10,20, 0 ) ; P[6].setWorldCoordinates(-10,12, 0 ) ; */ vpHomogeneousMatrix bMo(0,0,1, 0,0,0) ; vpHomogeneousMatrix aMb(0.1,0.1,0.1,vpMath::rad(10),0,vpMath::rad(40)) ; vpHomogeneousMatrix aMo =aMb*bMo ; for(i=0 ; i < nbpt ; i++) { P[i].project(aMo) ; aP[i] = P[i] ; xa[i] = P[i].get_x() ; ya[i] = P[i].get_y() ; } for(i=0 ; i < nbpt ; i++) { P[i].project(bMo) ; bP[i] = P[i] ; xb[i] = P[i].get_x() ; yb[i] = P[i].get_y() ; } vpRotationMatrix aRb ; vpTranslationVector aTb ; vpColVector n ; std::cout << "-------------------------------" < #include #include #include #include #include #include #include #include #include #include // List of allowed command line options #define GETOPTARGS "h" #define L 0.1 #define nbpt 5 /*! Print the program options. \param name : Program name. \param badparam : Bad parameter name. */ void usage(const char *name, const char *badparam) { fprintf(stdout, "\n\ Test the HLM (Malis) homography estimation algorithm with a planar object.\n\ \n\ SYNOPSIS\n\ %s [-h]\n", name); fprintf(stdout, "\n\ OPTIONS: Default\n\ -h\n\ Print the help.\n"); if (badparam) { fprintf(stderr, "ERROR: \n" ); fprintf(stderr, "\nBad parameter [%s]\n", badparam); } } /*! Set the program options. \param argc : Command line number of parameters. \param argv : Array of command line parameters. \return false if the program has to be stopped, true otherwise. */ bool getOptions(int argc, const char **argv) { const char *optarg; int c; while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { switch (c) { case 'h': usage(argv[0], NULL); return false; break; default: usage(argv[0], optarg); return false; break; } } if ((c == 1) || (c == -1)) { // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; std::cerr << " Bad argument " << optarg << std::endl << std::endl; return false; } return true; } int main(int argc, const char ** argv) { // Read the command line options if (getOptions(argc, argv) == false) { exit (-1); } int i ; vpPoint P[nbpt] ; // Point to be tracked double xa[nbpt], ya[nbpt] ; double xb[nbpt], yb[nbpt] ; vpPoint aP[nbpt] ; // Point to be tracked vpPoint bP[nbpt] ; // Point to be tracked P[0].setWorldCoordinates(-L,-L, 0 ) ; P[1].setWorldCoordinates(2*L,-L, 0 ) ; P[2].setWorldCoordinates(L,L, 0 ) ; P[3].setWorldCoordinates(-L,3*L, 0 ) ; P[4].setWorldCoordinates(0,0, 0 ) ; /* P[5].setWorldCoordinates(10,20, 0 ) ; P[6].setWorldCoordinates(-10,12, 0 ) ; */ vpHomogeneousMatrix bMo(0,0,1, 0,0,0) ; vpHomogeneousMatrix aMb(1,0,0.0,vpMath::rad(10),0,vpMath::rad(40)) ; vpHomogeneousMatrix aMo =aMb*bMo ; for(i=0 ; i < nbpt ; i++) { P[i].project(aMo) ; aP[i] = P[i] ; xa[i] = P[i].get_x() ; ya[i] = P[i].get_y() ; } for(i=0 ; i < nbpt ; i++) { P[i].project(bMo) ; bP[i] = P[i] ; xb[i] = P[i].get_x() ; yb[i] = P[i].get_y() ; } std::cout << "-------------------------------" < laRb ; std::list laTb ; std::list lnb ; vpHomography::computeDisplacement(aHb,bP[0].get_x(),bP[0].get_y(), laRb, laTb, lnb) ; std::list::const_iterator it_laRb = laRb.begin(); std::list::const_iterator it_laTb = laTb.begin(); std::list::const_iterator it_lnb = lnb.begin(); int k =1 ; while (it_lnb != lnb.end()) { std::cout << "Solution " << k++ << std::endl ; aRb = *it_laRb; aTb = *it_laTb; n = *it_lnb; std::cout << "Rotation: aRb" < #include #ifdef VISP_HAVE_COIN_AND_GUI #include #include #include #include #include #include #include #include #include #include #include #include #define GETOPTARGS "di:h" #define SAVE 0 /*! Print the program options. \param name : Program name. \param badparam : Bad parameter name. \param ipath : Input image path. */ void usage(const char *name, const char *badparam, std::string ipath) { fprintf(stdout, "\n\ Simulation Servo 4points.\n\ \n\ SYNOPSIS\n\ %s [-i ] [-d] [-h]\n", name); fprintf(stdout, "\n\ OPTIONS: Default\n\ -i %s\n\ Set image input path.\n\ From this path read \"ViSP-images/iv/4points.iv\"\n\ cad model.\n\ Setting the VISP_INPUT_IMAGE_PATH environment\n\ variable produces the same behaviour than using\n\ this option.\n\ \n\ -d \n\ Disable the image display. This can be useful \n\ for automatic tests using crontab under Unix or \n\ using the task manager under Windows.\n\ \n\ -h\n\ Print the help.\n\n", ipath.c_str()); if (badparam) fprintf(stdout, "\nERROR: Bad parameter [%s]\n", badparam); } /*! Set the program options. \param argc : Command line number of parameters. \param argv : Array of command line parameters. \param ipath : Input image path. \param display : Set as true, activates the image display. This is the default configuration. When set to false, the display is disabled. This can be useful for automatic tests using crontab under Unix or using the task manager under Windows. \return false if the program has to be stopped, true otherwise. */ bool getOptions(int argc, const char **argv, std::string &ipath, bool &display) { const char *optarg; int c; while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { switch (c) { case 'i': ipath = optarg; break; case 'd': display = false; break; case 'h': usage(argv[0], NULL, ipath); return false; break; default: usage(argv[0], optarg, ipath); return false; break; } } if ((c == 1) || (c == -1)) { // standalone param or error usage(argv[0], NULL, ipath); std::cerr << "ERROR: " << std::endl; std::cerr << " Bad argument " << optarg << std::endl << std::endl; return false; } return true; } static void *mainLoop (void *_simu) { vpSimulator *simu = (vpSimulator *)_simu ; simu->initMainApplication() ; for ( ; ; ) { int i ; vpServo task ; vpRobotCamera robot ; float sampling_time = 0.040f; // Sampling period in second robot.setSamplingTime(sampling_time); std::cout << std::endl ; std::cout << "-------------------------------------------------------" << std::endl ; std::cout << " Test program for vpServo " <setCameraPosition(cMo) ; simu->getCameraPosition(cMo) ; robot.setPosition(cMo) ; vpCameraParameters cam ; vpTRACE("sets the point coordinates in the world frame " ) ; vpPoint point[4] ; point[0].setWorldCoordinates(-0.1,-0.1,0) ; point[1].setWorldCoordinates(0.1,-0.1,0) ; point[2].setWorldCoordinates(0.1,0.1,0) ; point[3].setWorldCoordinates(-0.1,0.1,0) ; vpTRACE("project : computes the point coordinates in the camera frame and its 2D coordinates" ) ; for (i = 0 ; i < 4 ; i++) point[i].track(cMo) ; vpTRACE("sets the desired position of the point ") ; vpFeaturePoint p[4] ; for (i = 0 ; i < 4 ; i++) vpFeatureBuilder::create(p[i], point[i]) ; //retrieve x,y and Z of the vpPoint structure vpTRACE("sets the desired position of the point ") ; vpFeaturePoint pd[4] ; pd[0].buildFrom(-0.1,-0.1,1) ; pd[1].buildFrom(0.1,-0.1,1) ; pd[2].buildFrom(0.1,0.1,1) ; pd[3].buildFrom(-0.1,0.1,1) ; vpTRACE("define the task") ; vpTRACE("\t we want an eye-in-hand control law") ; vpTRACE("\t articular velocity are computed") ; task.setServo(vpServo::EYEINHAND_L_cVe_eJe) ; task.setInteractionMatrixType(vpServo::CURRENT) ; vpTRACE("Set the position of the camera in the end-effector frame ") ; vpHomogeneousMatrix cMe ; vpVelocityTwistMatrix cVe(cMe) ; task.set_cVe(cVe) ; vpTRACE("Set the Jacobian (expressed in the end-effector frame)") ; vpMatrix eJe ; robot.get_eJe(eJe) ; task.set_eJe(eJe) ; vpTRACE("\t we want to see a point on a point..") ; for (i = 0 ; i < 4 ; i++) task.addFeature(p[i],pd[i]) ; vpTRACE("\t set the gain") ; task.setLambda(1.0) ; vpTRACE("Display task information " ) ; task.print() ; vpTime::wait(1000); // Sleep 1s std::cout << "\nEnter a character to continue or CTRL-C to quit... " << std::endl ; { char a ; std::cin >> a ; } char name[FILENAME_MAX]; unsigned int iter=0 ; vpTRACE("\t loop") ; while(iter++ < 100) { double t = vpTime::measureTimeMs(); vpColVector v ; robot.get_eJe(eJe) ; task.set_eJe(eJe) ; robot.getPosition(cMo) ; for (i = 0 ; i < 4 ; i++) { point[i].track(cMo) ; vpFeatureBuilder::create(p[i],point[i]) ; } v = task.computeControlLaw() ; robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; //vpTime::wait(100) ; simu->setCameraPosition(cMo) ; if(SAVE==1) { sprintf(name,"/tmp/image.%04d.external.png",iter) ; std::cout << name << std::endl ; simu->write(name) ; sprintf(name,"/tmp/image.%04d.internal.png",iter) ; simu->write(name) ; } vpTime::wait(t, sampling_time * 1000); // Wait 40 ms } vpTRACE("Display task information " ) ; task.print() ; task.kill() ; std::cout << "\nEnter a character to continue..." <> a ; } } simu->closeMainApplication() ; void *a=NULL ; return a ; // return (void *); } int main(int argc, const char ** argv) { std::string env_ipath; std::string opt_ipath; std::string ipath; std::string filename; std::string username; bool opt_display = true; // Get the VISP_IMAGE_PATH environment variable value char *ptenv = getenv("VISP_INPUT_IMAGE_PATH"); if (ptenv != NULL) env_ipath = ptenv; // Set the default input path if (! env_ipath.empty()) ipath = env_ipath; // Read the command line options if (getOptions(argc, argv, opt_ipath, opt_display) == false) { exit (-1); } // Get the option values if (!opt_ipath.empty()) ipath = opt_ipath; // Compare ipath and env_ipath. If they differ, we take into account // the input path comming from the command line option if (!opt_ipath.empty() && !env_ipath.empty()) { if (ipath != env_ipath) { std::cout << std::endl << "WARNING: " << std::endl; std::cout << " Since -i " << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl << " we skip the environment variable." << std::endl; } } // Test if an input path is set if (opt_ipath.empty() && env_ipath.empty()){ usage(argv[0], NULL, ipath); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Use -i option or set VISP_INPUT_IMAGE_PATH " << std::endl << " environment variable to specify the location of the " << std::endl << " image path where test images are located." << std::endl << std::endl; exit(-1); } vpCameraParameters cam ; vpHomogeneousMatrix fMo ; fMo[2][3] = 0 ; if (opt_display) { vpSimulator simu ; simu.initInternalViewer(300, 300) ; simu.initExternalViewer(300, 300) ; vpTime::wait(1000) ; simu.setZoomFactor(1.0f) ; // Load the cad model filename = ipath + vpIoTools::path("/ViSP-images/iv/4points.iv"); simu.load(filename.c_str()) ; simu.setInternalCameraParameters(cam) ; simu.setExternalCameraParameters(cam) ; simu.initApplication(&mainLoop) ; simu.mainLoop() ; } } #else int main() { vpTRACE("You should install Coin3D and SoQT or SoWin or SoXt") ; } #endif ViSP-2.8.0/example/coin-simulator/simulateCircle2DCamVelocity.cpp0000664000175000017500000002534412072022352025140 0ustar fspindlefspindle/**************************************************************************** * * $Id: simulateCircle2DCamVelocity.cpp 4056 2013-01-05 13:04:42Z fspindle $ * * This file is part of the ViSP software. * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. * * This software is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * ("GPL") version 2 as published by the Free Software Foundation. * See the file LICENSE.txt at the root directory of this source * distribution for additional information about the GNU GPL. * * For using ViSP with software that can not be combined with the GNU * GPL, please contact INRIA about acquiring a ViSP Professional * Edition License. * * See http://www.irisa.fr/lagadic/visp/visp.html for more information. * * This software was developed at: * INRIA Rennes - Bretagne Atlantique * Campus Universitaire de Beaulieu * 35042 Rennes Cedex * France * http://www.irisa.fr/lagadic * * If you have questions regarding the use of this file, please contact * INRIA at visp@inria.fr * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * * Description: * Simulation of a visual servoing with visualization. * * Authors: * Eric Marchand * Fabien Spindler * *****************************************************************************/ /*! \file simulateCircle2DCamVelocity.cpp \brief Visual servoing experiment on a circle with a visualization from the camera and from an external view using vpSimulator. */ /*! \example simulateCircle2DCamVelocity.cpp Visual servoing experiment on a circle with a visualization from the camera and from an external view using vpSimulator. */ #include #include #ifdef VISP_HAVE_COIN_AND_GUI #include #include #include #include #include #include #include #include #include #include #include #include #include #define GETOPTARGS "cdi:h" #define SAVE 0 /*! Print the program options. \param name : Program name. \param badparam : Bad parameter name. \param ipath : Input image path. */ void usage(const char *name, const char *badparam, std::string ipath) { fprintf(stdout, "\n\ Simulation Servo Circle\n\ \n\ SYNOPSIS\n\ %s [-i ] [-d] [-h]\n", name); fprintf(stdout, "\n\ OPTIONS: Default\n\ -i %s\n\ Set image input path.\n\ From this path read \"ViSP-images/iv/4points.iv\"\n\ cad model.\n\ Setting the VISP_INPUT_IMAGE_PATH environment\n\ variable produces the same behaviour than using\n\ this option.\n\ \n\ -d \n\ Disable the image display. This can be useful \n\ for automatic tests using crontab under Unix or \n\ using the task manager under Windows.\n\ \n\ -h\n\ Print the help.\n\n", ipath.c_str()); if (badparam) fprintf(stdout, "\nERROR: Bad parameter [%s]\n", badparam); } /*! Set the program options. \param argc : Command line number of parameters. \param argv : Array of command line parameters. \param ipath : Input image path. \param display : Set as true, activates the image display. This is the default configuration. When set to false, the display is disabled. This can be useful for automatic tests using crontab under Unix or using the task manager under Windows. \return false if the program has to be stopped, true otherwise. */ bool getOptions(int argc, const char **argv, std::string &ipath, bool &display) { const char *optarg; int c; while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { switch (c) { case 'i': ipath = optarg; break; case 'd': display = false; break; case 'h': usage(argv[0], NULL, ipath); return false; break; default: usage(argv[0], optarg, ipath); return false; break; } } if ((c == 1) || (c == -1)) { // standalone param or error usage(argv[0], NULL, ipath); std::cerr << "ERROR: " << std::endl; std::cerr << " Bad argument " << optarg << std::endl << std::endl; return false; } return true; } static void *mainLoop (void *_simu) { vpSimulator *simu = (vpSimulator *)_simu ; simu->initMainApplication() ; vpPoseVector vcMo ; vcMo[0] = 0.3 ; vcMo[1] = 0.2 ; vcMo[2] = 3 ; vcMo[3] = 0 ; vcMo[4] = vpMath::rad(45) ; vcMo[5] = vpMath::rad(40) ; vpHomogeneousMatrix cMo(vcMo) ; ; vpHomogeneousMatrix cMod ; cMod[0][3] = 0 ; cMod[1][3] = 0 ; cMod[2][3] = 1 ; int it =0 ; unsigned int pos = 2 ; while (pos!=0) { vpServo task ; vpRobotCamera robot ; float sampling_time = 0.040f; // Sampling period in second robot.setSamplingTime(sampling_time); /* std::cout << std::endl ; std::cout << "-----------------------" << std::endl ; std::cout << " Test program for vpServo " <setCameraPosition(cMo) ; if (pos==1) cMod[2][3] = 0.32 ; vpTRACE("sets the circle coordinates in the world frame " ) ; vpCircle circle ; circle.setWorldCoordinates(0,0,1,0,0,0,0.1) ; vpTRACE("sets the desired position of the visual feature ") ; vpFeatureEllipse pd ; circle.track(cMod) ; vpFeatureBuilder::create(pd,circle) ; vpTRACE("project : computes the circle coordinates in the camera frame and its 2D coordinates" ) ; vpTRACE("sets the current position of the visual feature ") ; vpFeatureEllipse p ; circle.track(cMo) ; vpFeatureBuilder::create(p,circle) ; vpTRACE("define the task") ; vpTRACE("\t we want an eye-in-hand control law") ; vpTRACE("\t robot is controlled in the camera frame") ; task.setServo(vpServo::EYEINHAND_CAMERA) ; task.setInteractionMatrixType(vpServo::CURRENT) ; vpTRACE("\t we want to see a circle on a circle..") ; std::cout << std::endl ; task.addFeature(p,pd) ; vpTRACE("\t set the gain") ; task.setLambda(1.0) ; // if (pos==2) // task.setLambda(0.0251) ; // else // task.setLambda(0.0251) ; vpTRACE("Display task information " ) ; task.print() ; vpTime::wait(1000); // Sleep 1s std::cout << "\nEnter a character to continue... " <> a ; } unsigned int iter=0 ; vpTRACE("\t loop") ; unsigned int itermax ; if (pos==2) itermax = 75 ; else itermax = 100 ; char name[FILENAME_MAX] ; while(iter++setCameraPosition(cMo) ; if(SAVE==1) { sprintf(name,"/tmp/image.%04d.external.png",it) ; std::cout << "Save " << name << std::endl ; simu->write(name) ; sprintf(name,"/tmp/image.%04d.internal.png",iter) ; std::cout << "Save " << name << std::endl ; simu->write(name) ; it++ ; } // vpTRACE("\t\t || s - s* || ") ; // std::cout << ( task.getError() ).sumSquare() <closeMainApplication() ; void *a=NULL ; return a ; // return (void *); } int main(int argc, const char ** argv) { std::string env_ipath; std::string opt_ipath; std::string ipath; std::string filename; std::string username; bool opt_display = true; // Get the VISP_IMAGE_PATH environment variable value char *ptenv = getenv("VISP_INPUT_IMAGE_PATH"); if (ptenv != NULL) env_ipath = ptenv; // Set the default input path if (! env_ipath.empty()) ipath = env_ipath; // Read the command line options if (getOptions(argc, argv, opt_ipath, opt_display) == false) { exit (-1); } // Get the option values if (!opt_ipath.empty()) ipath = opt_ipath; // Compare ipath and env_ipath. If they differ, we take into account // the input path comming from the command line option if (!opt_ipath.empty() && !env_ipath.empty()) { if (ipath != env_ipath) { std::cout << std::endl << "WARNING: " << std::endl; std::cout << " Since -i " << " is different from VISP_INPUT_IMAGE_PATH=" << env_ipath << std::endl << " we skip the environment variable." << std::endl; } } // Test if an input path is set if (opt_ipath.empty() && env_ipath.empty()){ usage(argv[0], NULL, ipath); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Use -i option or set VISP_INPUT_IMAGE_PATH " << std::endl << " environment variable to specify the location of the " << std::endl << " image path where test images are located." << std::endl << std::endl; exit(-1); } vpCameraParameters cam ; vpHomogeneousMatrix fMo ; fMo[2][3] = 0 ; if (opt_display) { vpSimulator simu ; simu.initInternalViewer(300, 300) ; simu.initExternalViewer(300, 300) ; vpTime::wait(1000) ; simu.setZoomFactor(1.0f) ; simu.addAbsoluteFrame() ; // Load the cad model filename = ipath + vpIoTools::path("/ViSP-images/iv/circle.iv"); simu.load(filename.c_str(),fMo) ; simu.setInternalCameraParameters(cam) ; simu.initApplication(&mainLoop) ; simu.mainLoop() ; } } #else int main() { vpTRACE("You should install Coin3D and SoQT or SoWin or SoXt") ; } #endif ViSP-2.8.0/example/coin-simulator/CMakeLists.txt0000664000175000017500000000434012072022352021672 0ustar fspindlefspindle############################################################################# # # $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ # # This file is part of the ViSP software. # Copyright (C) 2005 - 2013 by INRIA. All rights reserved. # # This software is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # ("GPL") version 2 as published by the Free Software Foundation. # See the file LICENSE.txt at the root directory of this source # distribution for additional information about the GNU GPL. # # For using ViSP with software that can not be combined with the GNU # GPL, please contact INRIA about acquiring a ViSP Professional # Edition License. # # See http://www.irisa.fr/lagadic/visp/visp.html for more information. # # This software was developed at: # INRIA Rennes - Bretagne Atlantique # Campus Universitaire de Beaulieu # 35042 Rennes Cedex # France # http://www.irisa.fr/lagadic # # If you have questions regarding the use of this file, please contact # INRIA at visp@inria.fr # # This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE # WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # Description: # ViSP configuration file. # # Authors: # Fabien Spindler # ############################################################################# # SOURCE variable corresponds to the list of all the sources to build binaries. # The generate binary comes by removing the .cpp extension to # the source name. # # If you want to add/remove a source, modify here SET (SOURCE simulateFourPoints2DCartesianCamVelocity.cpp simulateFourPoints2DPolarCamVelocity.cpp simulateCircle2DCamVelocity.cpp ) # rule for binary build FOREACH(source ${SOURCE}) # Compute the name of the binary to create GET_FILENAME_COMPONENT(binary ${source} NAME_WE) # From source compile the binary and add link rules ADD_EXECUTABLE(${binary} ${source}) TARGET_LINK_LIBRARIES(${binary} ${VISP_INTERN_LIBRARY} ${VISP_EXTERN_LIBRARIES}) # Add test ADD_TEST(${binary} ${binary} ${OPTION_TO_DESACTIVE_DISPLAY}) ENDFOREACH(source) # customize clean target SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "core*;*~;gmon.out;DartTestfile.txt" ) ViSP-2.8.0/example/coin-simulator/simulateFourPoints2DPolarCamVelocity.cpp0000664000175000017500000003013112072022352027033 0ustar fspindlefspindle/**************************************************************************** * * $Id: simulateFourPoints2DPolarCamVelocity.cpp 4056 2013-01-05 13:04:42Z fspindle $ * * This file is part of the ViSP software. * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. * * This software is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * ("GPL") version 2 as published by the Free Software Foundation. * See the file LICENSE.txt at the root directory of this source * distribution for additional information about the GNU GPL. * * For using ViSP with software that can not be combined with the GNU * GPL, please contact INRIA about acquiring a ViSP Professional * Edition License. * * See http://www.irisa.fr/lagadic/visp/visp.html for more information. * * This software was developed at: * INRIA Rennes - Bretagne Atlantique * Campus Universitaire de Beaulieu * 35042 Rennes Cedex * France * http://www.irisa.fr/lagadic * * If you have questions regarding the use of this file, please contact * INRIA at visp@inria.fr * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * * Description: * Simulation of a visual servoing with visualization. * * Authors: * Eric Marchand * Fabien Spindler * *****************************************************************************/ /*! \example simulateFourPoints2DPolarCamVelocity.cpp \file simulateFourPoints2DPolarCamVelocity.cpp \brief Visual servoing experiment on 4 points with a visualization from the camera and from an external view using vpSimulator. Visual features are the polar coordinates \f$(\rho,\theta)\f$ of the four points. */ #include #include #ifdef VISP_HAVE_COIN_AND_GUI #include #include #include #include #include #include #include #include #include #include #include #include #define GETOPTARGS "di:h" #define SAVE 0 /*! Print the program options. \param name : Program name. \param badparam : Bad parameter name. \param ipath : Input image path. */ void usage(const char *name, const char *badparam, std::string ipath) { fprintf(stdout, "\n\ Simulation Servo 4points.\n\ \n\ SYNOPSIS\n\ %s [-i ] [-d] [-h]\n", name); fprintf(stdout, "\n\ OPTIONS: Default\n\ -i %s\n\ Set image input path.\n\ From this path read \"ViSP-images/iv/4points.iv\"\n\ cad model.\n\ Setting the VISP_INPUT_IMAGE_PATH environment\n\ variable produces the same behaviour than using\n\ this option.\n\ \n\ -d \n\ Disable the image display. This can be useful \n\ for automatic tests using crontab under Unix or \n\ using the task manager under Windows.\n\ \n\ -h\n\ Print the help.\n\n", ipath.c_str()); if (badparam) fprintf(stdout, "\nERROR: Bad parameter [%s]\n", badparam); } /*! Set the program options. \param argc : Command line number of parameters. \param argv : Array of command line parameters. \param ipath : Input image path. \param display : Set as true, activates the image display. This is the default configuration. When set to false, the display is disabled. This can be useful for automatic tests using crontab under Unix or using the task manager under Windows. \return false if the program has to be stopped, true otherwise. */ bool getOptions(int argc, const char **argv, std::string &ipath, bool &display) { const char *optarg; int c; while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { switch (c) { case 'i': ipath = optarg; break; case 'd': display = false; break; case 'h': usage(argv[0], NULL, ipath); return false; break; default: usage(argv[0], optarg, ipath); return false; break; } } if ((c == 1) || (c == -1)) { // standalone param or error usage(argv[0], NULL, ipath); std::cerr << "ERROR: " << std::endl; std::cerr << " Bad argument " << optarg << std::endl << std::endl; return false; } return true; } static void *mainLoop (void *_simu) { vpSimulator *simu = (vpSimulator *)_simu ; simu->initMainApplication() ; for ( ; ; ) { vpServo task ; vpRobotCamera robot ; float sampling_time = 0.040f; // Sampling period in second robot.setSamplingTime(sampling_time); std::cout << std::endl ; std::cout << "-------------------------------------------------------" << std::endl ; std::cout << " Test program for vpServo " <setCameraPosition(cMo) ; simu->getCameraPosition(cMo) ; robot.setPosition(cMo) ; vpCameraParameters cam ; vpTRACE("sets the point coordinates in the world frame " ) ; vpPoint point[4] ; point[0].setWorldCoordinates(-0.1,-0.1,0) ; point[1].setWorldCoordinates(0.1,-0.1,0) ; point[2].setWorldCoordinates(0.1,0.1,0) ; point[3].setWorldCoordinates(-0.1,0.1,0) ; vpTRACE("project : computes the point coordinates in the camera frame and its 2D coordinates" ) ; for (int i = 0 ; i < 4 ; i++) { point[i].changeFrame(cMo); // Compute point coordinates in the camera frame point[i].project(); // Compute desired point doordinates in the camera frame } vpTRACE("sets the desired position of the point ") ; vpFeaturePointPolar p[4] ; for (int i = 0 ; i < 4 ; i++) vpFeatureBuilder::create(p[i], point[i]) ; //retrieve x,y and Z of the vpPoint structure to build the polar coordinates std::cout << "s: \n"; for (int i=0; i < 4; i ++) { printf("[%d] rho %f theta %f Z %f\n", i, p[i].get_rho(), p[i].get_theta(), p[i].get_Z()); } vpTRACE("sets the desired position of the point ") ; vcMo[0] = 0 ; vcMo[1] = 0 ; vcMo[2] = 1 ; vcMo[3] = vpMath::rad(0); vcMo[4] = vpMath::rad(0); vcMo[5] = vpMath::rad(0); vpHomogeneousMatrix cMod(vcMo); vpFeaturePointPolar pd[4] ; vpPoint pointd[4]; // Desired position of the points pointd[0].setWorldCoordinates(-0.1,-0.1,0) ; pointd[1].setWorldCoordinates(0.1,-0.1,0) ; pointd[2].setWorldCoordinates(0.1,0.1,0) ; pointd[3].setWorldCoordinates(-0.1,0.1,0) ; for (int i=0; i < 4; i ++) { pointd[i].changeFrame(cMod); // Compute desired point doordinates in the camera frame pointd[i].project(); // Compute desired point doordinates in the camera frame vpFeatureBuilder::create(pd[i], pointd[i]) ; //retrieve x,y and Z of the vpPoint structure to build the polar coordinates } std::cout << "s*: \n"; for (int i=0; i < 4; i ++) { printf("[%d] rho %f theta %f Z %f\n", i, pd[i].get_rho(), pd[i].get_theta(), pd[i].get_Z()); } vpTRACE("define the task") ; vpTRACE("\t we want an eye-in-hand control law") ; vpTRACE("\t articular velocity are computed") ; task.setServo(vpServo::EYEINHAND_L_cVe_eJe) ; task.setInteractionMatrixType(vpServo::CURRENT) ; vpTRACE("Set the position of the camera in the end-effector frame ") ; vpHomogeneousMatrix cMe ; vpVelocityTwistMatrix cVe(cMe) ; task.set_cVe(cVe) ; vpTRACE("Set the Jacobian (expressed in the end-effector frame)") ; vpMatrix eJe ; robot.get_eJe(eJe) ; task.set_eJe(eJe) ; vpTRACE("\t we want to see a point on a point..") ; for (int i = 0 ; i < 4 ; i++) task.addFeature(p[i],pd[i]) ; vpTRACE("\t set the gain") ; task.setLambda(1.0) ; vpTRACE("Display task information " ) ; task.print() ; vpTime::wait(1000); // Sleep 1s std::cout << "\nEnter a character to continue or CTRL-C to quit... " << std::endl ; { char a ; std::cin >> a ; } char name[FILENAME_MAX]; unsigned int iter=0 ; vpTRACE("\t loop") ; while(iter++ < 300) { double t = vpTime::measureTimeMs(); vpColVector v ; robot.get_eJe(eJe) ; task.set_eJe(eJe) ; robot.getPosition(cMo) ; for (int i = 0 ; i < 4 ; i++) { point[i].track(cMo) ; vpFeatureBuilder::create(p[i],point[i]) ; } v = task.computeControlLaw() ; robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; //vpTime::wait(100) ; simu->setCameraPosition(cMo) ; if(SAVE==1) { sprintf(name,"/tmp/image.%04d.external.png",iter) ; std::cout << name << std::endl ; simu->write(name) ; sprintf(name,"/tmp/image.%04d.internal.png",iter) ; simu->write(name) ; } vpTime::wait(t, sampling_time * 1000); // Wait 40 ms } vpTRACE("Display task information " ) ; task.print() ; task.kill() ; std::cout << "cMo:\n" << cMo << std::endl; vpPoseVector pose(cMo); std::cout << "final pose:\n" << pose.t() << std::endl; std::cout << "\nEnter a character to continue..." <> a ; } } simu->closeMainApplication() ; void *a=NULL ; return a ; // return (void *); } int main(int argc, const char ** argv) { std::string env_ipath; std::string opt_ipath; std::string ipath; std::string filename; std::string username; bool opt_display = true; // Get the VISP_IMAGE_PATH environment variable value char *ptenv = getenv("VISP_INPUT_IMAGE_PATH"); if (ptenv != NULL) env_ipath = ptenv; // Set the default input path if (! env_ipath.empty()) ipath = env_ipath; // Read the command line options if (getOptions(argc, argv, opt_ipath, opt_display) == false) { exit (-1); } // Get the option values if (!opt_ipath.empty()) ipath = opt_ipath; // Compare ipath and env_ipath. If they differ, we take into account // the input path comming from the command line option if (!opt_ipath.empty() && !env_ipath.empty()) { if (ipath != env_ipath) { std::cout << std::endl << "WARNING: " << std::endl; std::cout << " Since -i " << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl << " we skip the environment variable." << std::endl; } } // Test if an input path is set if (opt_ipath.empty() && env_ipath.empty()){ usage(argv[0], NULL, ipath); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Use -i option or set VISP_INPUT_IMAGE_PATH " << std::endl << " environment variable to specify the location of the " << std::endl << " image path where test images are located." << std::endl << std::endl; exit(-1); } vpCameraParameters cam ; vpHomogeneousMatrix fMo ; fMo[2][3] = 0 ; if (opt_display) { vpSimulator simu ; simu.initInternalViewer(300, 300) ; simu.initExternalViewer(300, 300) ; vpTime::wait(1000) ; simu.setZoomFactor(1.0f) ; // Load the cad model filename = ipath + vpIoTools::path("/ViSP-images/iv/4points.iv"); simu.load(filename.c_str()) ; simu.setInternalCameraParameters(cam) ; simu.setExternalCameraParameters(cam) ; simu.initApplication(&mainLoop) ; simu.mainLoop() ; } } #else int main() { vpTRACE("You should install Coin3D and SoQT or SoWin or SoXt") ; } #endif ViSP-2.8.0/example/ogre-simulator/0000775000175000017500000000000012173700526017145 5ustar fspindlefspindleViSP-2.8.0/example/ogre-simulator/AROgre.cpp0000664000175000017500000005605212165544343021004 0ustar fspindlefspindle/**************************************************************************** * * $Id: AROgre.cpp 4305 2013-07-05 13:23:47Z fspindle $ * * This file is part of the ViSP software. * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. * * This software is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * ("GPL") version 2 as published by the Free Software Foundation. * See the file LICENSE.txt at the root directory of this source * distribution for additional information about the GNU GPL. * * For using ViSP with software that can not be combined with the GNU * GPL, please contact INRIA about acquiring a ViSP Professional * Edition License. * * See http://www.irisa.fr/lagadic/visp/visp.html for more information. * * This software was developed at: * INRIA Rennes - Bretagne Atlantique * Campus Universitaire de Beaulieu * 35042 Rennes Cedex * France * http://www.irisa.fr/lagadic * * If you have questions regarding the use of this file, please contact * INRIA at visp@inria.fr * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * * Description: * Implementation of a simple augmented reality application using the vpAROgre * class. * * Authors: * Bertrand Delabarre * *****************************************************************************/ /*! \example AROgre.cpp Example of augmented reality based on Ogre3D. */ #include #include //#if defined(VISP_HAVE_OGRE) && defined(VISP_HAVE_DISPLAY) #if defined(VISP_HAVE_OGRE) && (defined(VISP_HAVE_OPENCV) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9) || defined(VISP_HAVE_GTK)) #if defined(VISP_HAVE_X11) && ! defined(APPLE) // produce an error on OSX: ‘typedef int Cursor’ // /usr/X11R6/include/X11/X.h:108: error: ‘Cursor’ has a previous // declaration as ‘typedef XID Cursor’. That's why it should not be // used on APPLE platforms # include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include // List of allowed command line options #define GETOPTARGS "ci:p:h" /*! Print the program options. \param name : Program name. \param badparam : Bad parameter name. \param ipath : Input image path. \param ppath : Personal image path. */ void usage(const char *name, const char *badparam, std::string ipath, std::string ppath) { fprintf(stdout, "\n\ Test augmented reality using the vpAROgre class.\n\ \n\ SYNOPSIS\n\ %s [-i ] [-p ]\n\ [-c] [-h]\n", name); fprintf(stdout, "\n\ OPTIONS: Default\n\ -i %s\n\ Set image input path.\n\ From this path read images \n\ \"ViSP-images/mire-2/image.%%04d.pgm\". These \n\ images come from ViSP-images-x.y.z.tar.gz available \n\ on the ViSP website.\n\ Setting the VISP_INPUT_IMAGE_PATH environment\n\ variable produces the same behaviour than using\n\ this option.\n\ \n\ -p %s\n\ Specify a personal sequence containing images \n\ to process.\n\ By image sequence, we mean one file per image.\n\ The following image file formats PNM (PGM P5, PPM P6)\n\ are supported. The format is selected by analysing \n\ the filename extension.\n\ Example : \"/Temp/ViSP-images/cube/image.%%04d.pgm\"\n\ %%04d is for the image numbering.\n\ \n\ -c\n\ Disable the mouse click. Useful to automaze the \n\ execution of this program without humain intervention.\n\ \n\ -h\n\ Print the help.\n", ipath.c_str(), ppath.c_str()); if (badparam) fprintf(stdout, "\nERROR: Bad parameter [%s]\n", badparam); } /*! Set the program options. \param argc : Command line number of parameters. \param argv : Array of command line parameters. \param ipath : Input image path. \param ppath : Personal image path. \param click_allowed : Mouse click activation. \return false if the program has to be stopped, true otherwise. */ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &ppath, bool &click_allowed) { const char *optarg; int c; while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { switch (c) { case 'c': click_allowed = false; break; case 'i': ipath = optarg; break; case 'p': ppath = optarg; break; case 'h': usage(argv[0], NULL, ipath, ppath); return false; break; default: usage(argv[0], optarg, ipath, ppath); return false; break; } } if ((c == 1) || (c == -1)) { // standalone param or error usage(argv[0], NULL, ipath, ppath); std::cerr << "ERROR: " << std::endl; std::cerr << " Bad argument " << optarg << std::endl << std::endl; return false; } return true; } #ifndef DOXYGEN_SHOULD_SKIP_THIS class vpAROgreExample : public vpAROgre { public: // The constructor doesn't change here vpAROgreExample(const vpCameraParameters &mcam = vpCameraParameters(), unsigned int width = 640, unsigned int height = 480, const char *resourcePath=NULL) : vpAROgre(mcam, width, height){ // Direction vectors if (resourcePath) mResourcePath = resourcePath; std::cout << "mResourcePath: " << mResourcePath<< std::endl; vecDevant = Ogre::Vector3(0,-1,0); } protected : // Attributes // Vector to move Ogre::Vector3 vecDevant; // Animation attribute Ogre::AnimationState * mAnimationState; // The entity representing the robot Ogre::Entity* robot; // Our scene will just be a plane void createScene() { // Lumieres mSceneMgr->setAmbientLight(Ogre::ColourValue((float)0.6,(float)0.6,(float)0.6)); // Default value of lightning Ogre::Light * light = mSceneMgr->createLight(); light->setDiffuseColour(1.0,1.0,1.0); // scaled RGB values light->setSpecularColour(1.0,1.0,1.0); // scaled RGB values // Lumiere ponctuelle light->setPosition(-5, -5, 10); light->setType(Ogre::Light::LT_POINT); light->setAttenuation((Ogre::Real)100, (Ogre::Real)1.0, (Ogre::Real)0.045, (Ogre::Real)0.0075); //Ombres light->setCastShadows(true); // Create the Entity robot = mSceneMgr->createEntity("Robot", "robot.mesh"); // Attach robot to scene graph Ogre::SceneNode* RobotNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("Robot"); RobotNode->attachObject(robot); RobotNode->scale((Ogre::Real)0.001,(Ogre::Real)0.001,(Ogre::Real)0.001); RobotNode->pitch(Ogre::Degree(90)); RobotNode->yaw(Ogre::Degree(-90)); robot->setCastShadows(true); mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_MODULATIVE); // Add an animation // Set the good animation mAnimationState = robot->getAnimationState( "Idle" ); // Start over when finished mAnimationState->setLoop( true ); // Animation enabled mAnimationState->setEnabled( true ); // Add a ground Ogre::Plane plan; plan.d = 0; plan.normal = Ogre::Vector3::UNIT_Z; Ogre::MeshManager::getSingleton().createPlane("sol",Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plan, (Ogre::Real)0.22, (Ogre::Real)0.16, 10, 10, true, 1, 1, 1); Ogre::Entity* ent = mSceneMgr->createEntity("Entitesol", "sol"); Ogre::SceneNode* PlaneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("Entitesol"); PlaneNode->attachObject(ent); ent->setMaterialName("Examples/GrassFloor"); } bool customframeEnded(const Ogre::FrameEvent& evt) { // Update animation // To move, we add it the time since last frame mAnimationState->addTime( evt.timeSinceLastFrame ); return true; } #ifdef VISP_HAVE_OIS bool processInputEvent(const Ogre::FrameEvent& /*evt*/) { mKeyboard->capture(); Ogre::Matrix3 rotmy; double angle = -M_PI/8; if(mKeyboard->isKeyDown(OIS::KC_ESCAPE)) return false; // Event telling that we will have to move, setting the animation to "walk", if false, annimation goes to "Idle" bool event = false; // Check entries if(mKeyboard->isKeyDown(OIS::KC_Z) || mKeyboard->isKeyDown(OIS::KC_UP)){ mSceneMgr->getSceneNode("Robot")->setPosition(mSceneMgr->getSceneNode("Robot")->getPosition()+(Ogre::Real)0.003*vecDevant); event = true; } if(mKeyboard->isKeyDown(OIS::KC_S) || mKeyboard->isKeyDown(OIS::KC_DOWN)){ mSceneMgr->getSceneNode("Robot")->setPosition(mSceneMgr->getSceneNode("Robot")->getPosition()-(Ogre::Real)0.003*vecDevant); event = true; } if(mKeyboard->isKeyDown(OIS::KC_Q) || mKeyboard->isKeyDown(OIS::KC_LEFT)){ rotmy = Ogre::Matrix3((Ogre::Real)cos(-angle), (Ogre::Real)sin(-angle), 0, (Ogre::Real)(-sin(-angle)), (Ogre::Real)cos(-angle),0, 0,0,1); vecDevant=vecDevant*rotmy; mSceneMgr->getSceneNode("Robot")->yaw(Ogre::Radian((Ogre::Real)(-angle))); event = true; } if(mKeyboard->isKeyDown(OIS::KC_D) || mKeyboard->isKeyDown(OIS::KC_RIGHT)){ rotmy = Ogre::Matrix3((Ogre::Real)cos(angle), (Ogre::Real)sin(angle), 0, (Ogre::Real)(-sin(angle)), (Ogre::Real)cos(angle),0, 0,0,1); vecDevant=vecDevant*rotmy; mSceneMgr->getSceneNode("Robot")->yaw(Ogre::Radian((Ogre::Real)angle)); event = true; } // Play the right animation if(event){ mAnimationState = robot->getAnimationState("Walk"); } else mAnimationState = robot->getAnimationState( "Idle" ); // Start over when finished mAnimationState->setLoop( true ); // Animation enabled mAnimationState->setEnabled( true ); return true; } #endif }; /*! This function computes a pose from four black points. Here to keep dimensions coherency you will need those four dots to be situated at (-7,6,0),(7,6,0),(7,-6,0),(-7,-6,0) (unit = cm) in your real world */ void computeInitialPose(vpCameraParameters *mcam, vpImage &I, vpPose * mPose, vpDot2 *md, vpImagePoint *mcog, vpHomogeneousMatrix *cmo, vpPoint *mP, const bool &opt_click_allowed) { // --------------------------------------------------- // Code inspired from ViSP example of camera pose // ---------------------------------------------------- bool opt_display = true; #if defined(VISP_HAVE_X11) && ! defined(APPLE) // produce an error on OSX: ‘typedef int Cursor’ // /usr/X11R6/include/X11/X.h:108: error: ‘Cursor’ has a previous // declaration as ‘typedef XID Cursor’. That's why it should not be // used on APPLE platforms vpDisplayX display; #elif defined VISP_HAVE_GTK vpDisplayGTK display; #elif defined VISP_HAVE_GDI vpDisplayGDI display; #elif defined VISP_HAVE_OPENCV vpDisplayOpenCV display; #elif defined VISP_HAVE_D3D9 vpDisplayD3D display; #endif for (unsigned int i=0 ; i < 4 ; i++) { if (opt_display) { md[i].setGraphics(true) ; } else { md[i].setGraphics(false) ; } } if (opt_display) { try{ // Display size is automatically defined by the image (I) size display.init(I,100,100,"Preliminary Pose Calculation"); // display the image // The image class has a member that specify a pointer toward // the display that has been initialized in the display declaration // therefore is is no longuer necessary to make a reference to the // display variable. vpDisplay::display(I) ; //Flush the display vpDisplay::flush(I) ; } catch(...) { vpERROR_TRACE("Error while displaying the image") ; return ; } } std::cout<<"************************************************************************************"<clearPoint() ; // we set the 3D points coordinates (in meter !) in the object/world frame double l=0.06 ; double L=0.07 ; mP[0].setWorldCoordinates(-L,-l, 0 ) ; // (X,Y,Z) mP[1].setWorldCoordinates(L,-l, 0 ) ; mP[2].setWorldCoordinates(L,l, 0 ) ; mP[3].setWorldCoordinates(-L,l, 0 ) ; // pixel-> meter conversion for (unsigned int i=0 ; i < 4 ; i++) { // u[i]. v[i] are expressed in pixel // conversion in meter is achieved using // x = (u-u0)/px // y = (v-v0)/py // where px, py, u0, v0 are the intrinsic camera parameters double x=0, y=0; vpPixelMeterConversion::convertPoint(*mcam, mcog[i], x,y) ; mP[i].set_x(x) ; mP[i].set_y(y) ; } // The pose structure is build, we put in the point list the set of point // here both 2D and 3D world coordinates are known for (unsigned int i=0 ; i < 4 ; i++) { mPose->addPoint(mP[i]) ; // and added to the pose computation point list } // compute the initial pose using Dementhon method followed by a non linear // minimisation method // Pose by Lagrange it provides an initialization of the pose mPose->computePose(vpPose::LAGRANGE, *cmo) ; // the pose is now refined using the virtual visual servoing approach // Warning: cMo needs to be initialized otherwise it may diverge mPose->computePose(vpPose::VIRTUAL_VS, *cmo) ; // Display breifly just to have a glimpse a the ViSP pose // while(cpt<500){ if( opt_display ){ // Display the computed pose mPose->display(I,*cmo,*mcam, 0.05, vpColor::red) ; vpDisplay::flush(I) ; vpTime::wait(800); } } #endif int main(int argc, const char **argv) { std::string env_ipath; std::string opt_ipath; std::string ipath; std::string opt_ppath; std::string dirname; std::string filename; bool opt_click_allowed = true; // Get the VISP_IMAGE_PATH environment variable value char *ptenv = getenv("VISP_INPUT_IMAGE_PATH"); if (ptenv != NULL) env_ipath = ptenv; // Set the default input path if (! env_ipath.empty()) ipath = env_ipath; // Read the command line options if (getOptions(argc, argv, opt_ipath, opt_ppath, opt_click_allowed) == false) { exit (-1); } // Get the option values if (!opt_ipath.empty()) ipath = opt_ipath; // Compare ipath and env_ipath. If they differ, we take into account // the input path comming from the command line option if (!opt_ipath.empty() && !env_ipath.empty() && opt_ppath.empty()) { if (ipath != env_ipath) { std::cout << std::endl << "WARNING: " << std::endl; std::cout << " Since -i " << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl << " we skip the environment variable." << std::endl; } } // Test if an input path is set if (opt_ipath.empty() && env_ipath.empty() && opt_ppath.empty() ){ usage(argv[0], NULL, ipath, opt_ppath); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Use -i option or set VISP_INPUT_IMAGE_PATH " << std::endl << " environment variable to specify the location of the " << std::endl << " image path where test images are located." << std::endl << " Use -p option if you want to "< Idisplay; // Grey level image to track points vpImage I; // RGBa image to get background vpImage IC; // Matrix representing camera parameters vpHomogeneousMatrix cmo; // Variables used for pose computation purposes vpPose mPose; vpDot2 md[4]; vpImagePoint mcog[4]; vpPoint mP[4]; // CameraParameters we got from calibration // Keep u0 and v0 as center of the screen vpCameraParameters mcam; // Read the PGM image named "filename" on the disk, and put the // bitmap into the image structure I. I is initialized to the // correct size // // exception readPGM may throw various exception if, for example, // the file does not exist, or if the memory cannot be allocated try{ vpCTRACE << "Load: " << filename << std::endl; grabber.open(Idisplay); grabber.acquire(Idisplay); vpCameraParameters mcamTmp(592,570,grabber.getWidth()/2,grabber.getHeight()/2); // Compute the initial pose of the camera computeInitialPose(&mcamTmp, Idisplay, &mPose, md, mcog, &cmo, mP, opt_click_allowed); // Close the framegrabber grabber.close(); // Associate the grabber to the RGBa image grabber.open(IC); mcam.init(mcamTmp); } catch(...) { // an exception is thrown if an exception from readPGM has been caught // here this will result in the end of the program // Note that another error message has been printed from readPGM // to give more information about the error std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Cannot read " << filename << std::endl; std::cerr << " Check your -i " << ipath << " option " << std::endl << " or VISP_INPUT_IMAGE_PATH environment variable." << std::endl; exit(-1); } // Create a vpRAOgre object with color background vpAROgreExample ogre(mcam, (unsigned int)grabber.getWidth(), (unsigned int)grabber.getHeight()); // Initialize it ogre.init(IC); try { double t0 = vpTime::measureTimeMs(); // Rendering loop while(ogre.continueRendering() && !grabber.end()){ // Acquire a frame grabber.acquire(IC); // Convert it to a grey level image for tracking purpose vpImageConvert::convert(IC,I); // Update pose calculation try{ // kill the point list mPose.clearPoint() ; // track the dot for (int i=0 ; i < 4 ; i++) { // track the point md[i].track(I, mcog[i]) ; md[i].setGrayLevelPrecision(0.90); // pixel->meter conversion { double x=0, y=0; vpPixelMeterConversion::convertPoint(mcam, mcog[i], x, y) ; mP[i].set_x(x) ; mP[i].set_y(y) ; } // and added to the pose computation point list mPose.addPoint(mP[i]) ; } // the pose structure has been updated // the pose is now updated using the virtual visual servoing approach // Dementhon or lagrange is no longuer necessary, pose at the // previous iteration is sufficient mPose.computePose(vpPose::VIRTUAL_VS, cmo); } catch(...){ vpERROR_TRACE("Error in tracking loop") ; return false; } // Display with ogre ogre.display(IC,cmo); // Wait so that the video does not go too fast double t1 = vpTime::measureTimeMs(); std::cout << "\r> " << 1000 / (t1 - t0) << " fps" ; t0 = t1; } // Close the grabber grabber.close(); } catch (Ogre::Exception& e) { std::cerr << "Exception:\n"; std::cerr << e.getFullDescription().c_str() << "\n"; return 1; } catch (...) { std::cerr << "Exception: " << "\n"; return 1; } return EXIT_SUCCESS; } #else // VISP_HAVE_OGRE && VISP_HAVE_DISPLAY int main() { std::cout << "You should install Ogre3D to run this example..." << std::endl; } #endif ViSP-2.8.0/example/ogre-simulator/AROgreBasic.cpp0000664000175000017500000004520212165544343021741 0ustar fspindlefspindle/**************************************************************************** * * $Id: AROgreBasic.cpp 4305 2013-07-05 13:23:47Z fspindle $ * * This file is part of the ViSP software. * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. * * This software is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * ("GPL") version 2 as published by the Free Software Foundation. * See the file LICENSE.txt at the root directory of this source * distribution for additional information about the GNU GPL. * * For using ViSP with software that can not be combined with the GNU * GPL, please contact INRIA about acquiring a ViSP Professional * Edition License. * * See http://www.irisa.fr/lagadic/visp/visp.html for more information. * * This software was developed at: * INRIA Rennes - Bretagne Atlantique * Campus Universitaire de Beaulieu * 35042 Rennes Cedex * France * http://www.irisa.fr/lagadic * * If you have questions regarding the use of this file, please contact * INRIA at visp@inria.fr * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * * Description: * Implementation of a simple augmented reality application using the vpAROgre * class. * * Authors: * Bertrand Delabarre * *****************************************************************************/ /*! \example AROgreBasic.cpp Very simple example of augmented reality based on Ogre3D. */ #include #include //#if defined(VISP_HAVE_OGRE) && defined(VISP_HAVE_DISPLAY) #if defined(VISP_HAVE_OGRE) && (defined(VISP_HAVE_OPENCV) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9) || defined(VISP_HAVE_GTK)) #if defined(VISP_HAVE_X11) && ! defined(APPLE) // produce an error on OSX: ‘typedef int Cursor’ // /usr/X11R6/include/X11/X.h:108: error: ‘Cursor’ has a previous // declaration as ‘typedef XID Cursor’. That's why it should not be // used on APPLE platforms # include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include // List of allowed command line options #define GETOPTARGS "ci:p:h" /*! Print the program options. \param name : Program name. \param badparam : Bad parameter name. \param ipath : Input image path. \param ppath : Personal image path. */ void usage(const char *name, const char *badparam, std::string ipath, std::string ppath) { fprintf(stdout, "\n\ Test augmented reality using the vpAROgre class.\n\ \n\ SYNOPSIS\n\ %s [-i ] [-p ]\n\ [-c] [-h]\n", name); fprintf(stdout, "\n\ OPTIONS: Default\n\ -i %s\n\ Set image input path.\n\ From this path read images \n\ \"ViSP-images/mire-2/image.%%04d.pgm\". These \n\ images come from ViSP-images-x.y.z.tar.gz available \n\ on the ViSP website.\n\ Setting the VISP_INPUT_IMAGE_PATH environment\n\ variable produces the same behaviour than using\n\ this option.\n\ \n\ -p %s\n\ Specify a personal sequence containing images \n\ to process.\n\ By image sequence, we mean one file per image.\n\ The following image file formats PNM (PGM P5, PPM P6)\n\ are supported. The format is selected by analysing \n\ the filename extension.\n\ Example : \"/Temp/ViSP-images/cube/image.%%04d.pgm\"\n\ %%04d is for the image numbering.\n\ \n\ -c\n\ Disable the mouse click. Useful to automaze the \n\ execution of this program without humain intervention.\n\ \n\ -h\n\ Print the help.\n", ipath.c_str(), ppath.c_str()); if (badparam) fprintf(stdout, "\nERROR: Bad parameter [%s]\n", badparam); } /*! Set the program options. \param argc : Command line number of parameters. \param argv : Array of command line parameters. \param ipath : Input image path. \param ppath : Personal image path. \param click_allowed : Mouse click activation. \return false if the program has to be stopped, true otherwise. */ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &ppath, bool &click_allowed) { const char *optarg; int c; while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { switch (c) { case 'c': click_allowed = false; break; case 'i': ipath = optarg; break; case 'p': ppath = optarg; break; case 'h': usage(argv[0], NULL, ipath, ppath); return false; break; default: usage(argv[0], optarg, ipath, ppath); return false; break; } } if ((c == 1) || (c == -1)) { // standalone param or error usage(argv[0], NULL, ipath, ppath); std::cerr << "ERROR: " << std::endl; std::cerr << " Bad argument " << optarg << std::endl << std::endl; return false; } return true; } /*! This function computes a pose from four black points. Here to keep dimensions coherency you will need those four dots to be situated at (-7,6,0),(7,6,0),(7,-6,0),(-7,-6,0) (unit = cm) in your real world */ void computeInitialPose(vpCameraParameters *mcam, vpImage &I, vpPose * mPose, vpDot2 *md, vpImagePoint *mcog, vpHomogeneousMatrix *cmo, vpPoint *mP, const bool &opt_click_allowed) { // --------------------------------------------------- // Code inspired from ViSP example of camera pose // ---------------------------------------------------- bool opt_display = true; #if defined(VISP_HAVE_X11) && ! defined(APPLE) // produce an error on OSX: ‘typedef int Cursor’ // /usr/X11R6/include/X11/X.h:108: error: ‘Cursor’ has a previous // declaration as ‘typedef XID Cursor’. That's why it should not be // used on APPLE platforms vpDisplayX display; #elif defined VISP_HAVE_GTK vpDisplayGTK display; #elif defined VISP_HAVE_GDI vpDisplayGDI display; #elif defined VISP_HAVE_OPENCV vpDisplayOpenCV display; #elif defined VISP_HAVE_D3D9 vpDisplayD3D display; #endif for (unsigned int i=0 ; i < 4 ; i++) { if (opt_display) { md[i].setGraphics(true) ; } else { md[i].setGraphics(false) ; } } if (opt_display) { try{ // Display size is automatically defined by the image (I) size display.init(I,100,100,"Preliminary Pose Calculation"); // display the image // The image class has a member that specify a pointer toward // the display that has been initialized in the display declaration // therefore is is no longuer necessary to make a reference to the // display variable. vpDisplay::display(I) ; //Flush the display vpDisplay::flush(I) ; } catch(...) { vpERROR_TRACE("Error while displaying the image") ; return ; } } std::cout<<"************************************************************************************"<clearPoint() ; // we set the 3D points coordinates (in meter !) in the object/world frame double l=0.06 ; double L=0.07 ; mP[0].setWorldCoordinates(-L,-l, 0 ) ; // (X,Y,Z) mP[1].setWorldCoordinates(L,-l, 0 ) ; mP[2].setWorldCoordinates(L,l, 0 ) ; mP[3].setWorldCoordinates(-L,l, 0 ) ; // pixel-> meter conversion for (unsigned int i=0 ; i < 4 ; i++) { // u[i]. v[i] are expressed in pixel // conversion in meter is achieved using // x = (u-u0)/px // y = (v-v0)/py // where px, py, u0, v0 are the intrinsic camera parameters double x=0, y=0; vpPixelMeterConversion::convertPoint(*mcam, mcog[i], x,y) ; mP[i].set_x(x) ; mP[i].set_y(y) ; } // The pose structure is build, we put in the point list the set of point // here both 2D and 3D world coordinates are known for (unsigned int i=0 ; i < 4 ; i++) { mPose->addPoint(mP[i]) ; // and added to the pose computation point list } // compute the initial pose using Dementhon method followed by a non linear // minimisation method // Pose by Lagrange it provides an initialization of the pose mPose->computePose(vpPose::LAGRANGE, *cmo) ; // the pose is now refined using the virtual visual servoing approach // Warning: cMo needs to be initialized otherwise it may diverge mPose->computePose(vpPose::VIRTUAL_VS, *cmo) ; // Display breifly just to have a glimpse a the ViSP pose // while(cpt<500){ if( opt_display ){ // Display the computed pose mPose->display(I,*cmo,*mcam, 0.05, vpColor::red) ; vpDisplay::flush(I) ; vpTime::wait(1000); } } int main(int argc, const char **argv) { std::string env_ipath; std::string opt_ipath; std::string ipath; std::string opt_ppath; std::string dirname; std::string filename; bool opt_click_allowed = true; // Get the VISP_IMAGE_PATH environment variable value char *ptenv = getenv("VISP_INPUT_IMAGE_PATH"); if (ptenv != NULL) env_ipath = ptenv; // Set the default input path if (! env_ipath.empty()) ipath = env_ipath; // Read the command line options if (getOptions(argc, argv, opt_ipath, opt_ppath, opt_click_allowed) == false) { exit (-1); } // Get the option values if (!opt_ipath.empty()) ipath = opt_ipath; // Compare ipath and env_ipath. If they differ, we take into account // the input path comming from the command line option if (!opt_ipath.empty() && !env_ipath.empty() && opt_ppath.empty()) { if (ipath != env_ipath) { std::cout << std::endl << "WARNING: " << std::endl; std::cout << " Since -i " << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl << " we skip the environment variable." << std::endl; } } // Test if an input path is set if (opt_ipath.empty() && env_ipath.empty() && opt_ppath.empty() ){ usage(argv[0], NULL, ipath, opt_ppath); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Use -i option or set VISP_INPUT_IMAGE_PATH " << std::endl << " environment variable to specify the location of the " << std::endl << " image path where test images are located." << std::endl << " Use -p option if you want to "< I ; // unsigned iter = 0; std::ostringstream s; // char cfilename[FILENAME_MAX]; if (opt_ppath.empty()){ // Set the path location of the image sequence dirname = ipath + vpIoTools::path("/ViSP-images/mire-2/"); // Build the name of the image file s.setf(std::ios::right, std::ios::adjustfield); s << "image.%04d.pgm"; filename = dirname + s.str(); } else { filename = opt_ppath; } //We will read a sequence of images vpVideoReader grabber; grabber.setFirstFrameIndex(1); grabber.setFileName(filename.c_str()); // Grey level image associated to a display in the initial pose computation vpImage Idisplay; // Grey level image to track points vpImage I; // RGBa image to get background vpImage IC; // Matrix representing camera parameters vpHomogeneousMatrix cmo; // Variables used for pose computation purposes vpPose mPose; vpDot2 md[4]; vpImagePoint mcog[4]; vpPoint mP[4]; // CameraParameters we got from calibration // Keep u0 and v0 as center of the screen vpCameraParameters mcam; // Read the PGM image named "filename" on the disk, and put the // bitmap into the image structure I. I is initialized to the // correct size // // exception readPGM may throw various exception if, for example, // the file does not exist, or if the memory cannot be allocated try{ vpCTRACE << "Load: " << filename << std::endl; grabber.open(Idisplay); grabber.acquire(Idisplay); vpCameraParameters mcamTmp(592,570,grabber.getWidth()/2,grabber.getHeight()/2); // Compute the initial pose of the camera computeInitialPose(&mcamTmp, Idisplay, &mPose, md, mcog, &cmo, mP, opt_click_allowed); // Close the framegrabber grabber.close(); // Associate the grabber to the RGBa image grabber.open(IC); mcam.init(mcamTmp); } catch(...) { // an exception is thrown if an exception from readPGM has been caught // here this will result in the end of the program // Note that another error message has been printed from readPGM // to give more information about the error std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Cannot read " << filename << std::endl; std::cerr << " Check your -i " << ipath << " option " << std::endl << " or VISP_INPUT_IMAGE_PATH environment variable." << std::endl; exit(-1); } // Create a vpRAOgre object with color background vpAROgre ogre(mcam, (unsigned int)grabber.getWidth(), (unsigned int)grabber.getHeight()); // Initialize it ogre.init(IC); ogre.load("Robot", "robot.mesh"); ogre.setScale("Robot", 0.001f,0.001f,0.001f); ogre.setRotation("Robot", vpRotationMatrix(vpRxyzVector(M_PI/2, -M_PI/2, 0))); try { // Rendering loop while(ogre.continueRendering() && !grabber.end()){ // Acquire a frame grabber.acquire(IC); // Convert it to a grey level image for tracking purpose vpImageConvert::convert(IC,I); // Update pose calculation try{ // kill the point list mPose.clearPoint() ; // track the dot for (int i=0 ; i < 4 ; i++) { // track the point md[i].track(I, mcog[i]) ; md[i].setGrayLevelPrecision(0.90); // pixel->meter conversion { double x=0, y=0; vpPixelMeterConversion::convertPoint(mcam, mcog[i], x, y) ; mP[i].set_x(x) ; mP[i].set_y(y) ; } // and added to the pose computation point list mPose.addPoint(mP[i]) ; } // the pose structure has been updated // the pose is now updated using the virtual visual servoing approach // Dementhon or lagrange is no longuer necessary, pose at the // previous iteration is sufficient mPose.computePose(vpPose::VIRTUAL_VS, cmo); } catch(...){ vpERROR_TRACE("Error in tracking loop") ; return false; } // Display with ogre ogre.display(IC,cmo); // Wait so that the video does not go too fast vpTime::wait(15); } // Close the grabber grabber.close(); } catch (Ogre::Exception& e) { std::cerr << "Exception:\n"; std::cerr << e.getFullDescription().c_str() << "\n"; return 1; } catch (...) { std::cerr << "Exception: " << "\n"; return 1; } return EXIT_SUCCESS; } #else // VISP_HAVE_OGRE && VISP_HAVE_DISPLAY int main() { std::cout << "You should install Ogre3D to run this example..." << std::endl; } #endif ViSP-2.8.0/example/ogre-simulator/CMakeLists.txt0000664000175000017500000000420512072022352021676 0ustar fspindlefspindle############################################################################# # # $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ # # This file is part of the ViSP software. # Copyright (C) 2005 - 2013 by INRIA. All rights reserved. # # This software is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # ("GPL") version 2 as published by the Free Software Foundation. # See the file LICENSE.txt at the root directory of this source # distribution for additional information about the GNU GPL. # # For using ViSP with software that can not be combined with the GNU # GPL, please contact INRIA about acquiring a ViSP Professional # Edition License. # # See http://www.irisa.fr/lagadic/visp/visp.html for more information. # # This software was developed at: # INRIA Rennes - Bretagne Atlantique # Campus Universitaire de Beaulieu # 35042 Rennes Cedex # France # http://www.irisa.fr/lagadic # # If you have questions regarding the use of this file, please contact # INRIA at visp@inria.fr # # This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE # WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # Description: # ViSP configuration file. # # Authors: # Fabien Spindler # ############################################################################# # SOURCE variable corresponds to the list of all the sources to build binaries. # The generate binary comes by removing the .cpp extension to # the source name. # # If you want to add/remove a source, modify here SET (SOURCE AROgre.cpp AROgreBasic.cpp ) # rule for binary build FOREACH(source ${SOURCE}) # Compute the name of the binary to create GET_FILENAME_COMPONENT(binary ${source} NAME_WE) # From source compile the binary and add link rules ADD_EXECUTABLE(${binary} ${source}) TARGET_LINK_LIBRARIES(${binary} ${VISP_INTERN_LIBRARY} ${VISP_EXTERN_LIBRARIES}) # Add test #ADD_TEST(${binary} ${binary} ${OPTION_TO_DESACTIVE_DISPLAY}) ENDFOREACH(source) # customize clean target SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "core*;*~;gmon.out;DartTestfile.txt" ) ViSP-2.8.0/example/math/0000775000175000017500000000000012173700525015124 5ustar fspindlefspindleViSP-2.8.0/example/math/BSpline.cpp0000664000175000017500000002023412072022352017156 0ustar fspindlefspindle/**************************************************************************** * * $Id: BSpline.cpp 4056 2013-01-05 13:04:42Z fspindle $ * * This file is part of the ViSP software. * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. * * This software is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * ("GPL") version 2 as published by the Free Software Foundation. * See the file LICENSE.txt at the root directory of this source * distribution for additional information about the GNU GPL. * * For using ViSP with software that can not be combined with the GNU * GPL, please contact INRIA about acquiring a ViSP Professional * Edition License. * * See http://www.irisa.fr/lagadic/visp/visp.html for more information. * * This software was developed at: * INRIA Rennes - Bretagne Atlantique * Campus Universitaire de Beaulieu * 35042 Rennes Cedex * France * http://www.irisa.fr/lagadic * * If you have questions regarding the use of this file, please contact * INRIA at visp@inria.fr * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * * Description: * Exemple of a B-Spline curve. * * Authors: * Nicolas Melchior * *****************************************************************************/ /*! \file BSpline.cpp \brief Describe a curve thanks to a BSpline. */ /*! \example BSpline.cpp Describe a curve thanks to a BSpline. */ #include #include #include #include #include #include #include #include #include #include // Should be after #include #include #include #include #include #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GTK) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV) || defined(VISP_HAVE_D3D9) // List of allowed command line options #define GETOPTARGS "cdh" /*! Print the program options. \param name : Program name. \param badparam : Bad parameter name. */ void usage(const char *name, const char *badparam) { fprintf(stdout, "\n\ Describe a curve thanks to a BSpline.\n\ \n\ SYNOPSIS\n\ %s [-c] [-d] [-h]\n", name); fprintf(stdout, "\n\ OPTIONS: Default\n\ -c\n\ Disable the mouse click. Useful to automaze the \n\ execution of this program without humain intervention.\n\ \n\ -d \n\ Turn off the display.\n\ \n\ -h\n\ Print the help.\n"); if (badparam) fprintf(stdout, "\nERROR: Bad parameter [%s]\n", badparam); } /*! Set the program options. \param argc : Command line number of parameters. \param argv : Array of command line parameters. \param click_allowed : Mouse click activation. \param display : Display activation. \return false if the program has to be stopped, true otherwise. */ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) { const char *optarg; int c; while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { switch (c) { case 'c': click_allowed = false; break; case 'd': display = false; break; case 'h': usage(argv[0], NULL); return false; break; default: usage(argv[0], optarg); return false; break; } } if ((c == 1) || (c == -1)) { // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; std::cerr << " Bad argument " << optarg << std::endl << std::endl; return false; } return true; } int main(int argc, const char ** argv) { bool opt_click_allowed = true; bool opt_display = true; // Read the command line options if (getOptions(argc, argv, opt_click_allowed, opt_display) == false) { exit (-1); } // Declare an image, this is a gray level image (unsigned char) // it size is not defined yet, it will be defined when the image will // read on the disk vpImage I(540,480); // We open a window using either X11, GTK or GDI. #if defined VISP_HAVE_X11 vpDisplayX display; #elif defined VISP_HAVE_GTK vpDisplayGTK display; #elif defined VISP_HAVE_GDI vpDisplayGDI display; #elif defined VISP_HAVE_OPENCV vpDisplayOpenCV display; #elif defined VISP_HAVE_D3D9 vpDisplayD3D display; #endif if (opt_display) { try{ // Display size is automatically defined by the image (I) size display.init(I, 100, 100,"Display image") ; vpDisplay::display(I) ; vpDisplay::flush(I) ; } catch(...) { vpERROR_TRACE("Error while displaying the image") ; exit(-1); } } vpBSpline bSpline; std::list knots; knots.push_back(0); knots.push_back(0); knots.push_back(0); knots.push_back(1); knots.push_back(2); knots.push_back(3); knots.push_back(4); knots.push_back(4); knots.push_back(5); knots.push_back(5); knots.push_back(5); std::list controlPoints; vpImagePoint pt; pt.set_ij(50,300); controlPoints.push_back(pt); pt.set_ij(100,130); controlPoints.push_back(pt); pt.set_ij(150,400); controlPoints.push_back(pt); pt.set_ij(200,370); controlPoints.push_back(pt); pt.set_ij(250,120); controlPoints.push_back(pt); pt.set_ij(300,250); controlPoints.push_back(pt); pt.set_ij(350,200); controlPoints.push_back(pt); pt.set_ij(400,300); controlPoints.push_back(pt); bSpline.set_p(2); bSpline.set_knots(knots); bSpline.set_controlPoints(controlPoints); std::cout << "The parameters are :" < knots_cur; bSpline.get_knots(knots_cur); unsigned int i_display=0; for(std::list::const_iterator it=knots_cur.begin(); it!=knots_cur.end(); ++it, ++i_display){ std::cout << i_display << " ---> " << *it << std::endl; } std::cout << "The control points are :" < controlPoints_cur; bSpline.get_controlPoints(controlPoints_cur); i_display=0; for(std::list::const_iterator it=controlPoints_cur.begin(); it!=controlPoints_cur.end(); ++it, ++i_display){ std::cout << i_display << " ---> " << *it << std::endl; } unsigned int i = bSpline.findSpan(5/2.0); std::cout << "The knot interval number for the value u = 5/2 is : " << i <::const_iterator it=controlPoints.begin(); it!= controlPoints.end(); ++it){ vpDisplay::displayCross(I, *it, 4, vpColor::green); } vpDisplay::flush(I) ; vpDisplay::getClick(I); } if (N != NULL) delete[] N; if (N2 != NULL) { for (unsigned int j = 0; j <= 2; j++) delete[] N2[j]; delete[] N2; } return 0; } #else int main() { std::cout << "This example requires a video device. " << std::endl << "You should install X11, GTK, OpenCV, GDI or Direct3D" << std::endl << "to be able to execute this example." << std::endl; return 0; } #endif ViSP-2.8.0/example/math/Nurbs.cpp0000664000175000017500000002451212072022352016716 0ustar fspindlefspindle/**************************************************************************** * * $Id: Nurbs.cpp 4056 2013-01-05 13:04:42Z fspindle $ * * This file is part of the ViSP software. * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. * * This software is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * ("GPL") version 2 as published by the Free Software Foundation. * See the file LICENSE.txt at the root directory of this source * distribution for additional information about the GNU GPL. * * For using ViSP with software that can not be combined with the GNU * GPL, please contact INRIA about acquiring a ViSP Professional * Edition License. * * See http://www.irisa.fr/lagadic/visp/visp.html for more information. * * This software was developed at: * INRIA Rennes - Bretagne Atlantique * Campus Universitaire de Beaulieu * 35042 Rennes Cedex * France * http://www.irisa.fr/lagadic * * If you have questions regarding the use of this file, please contact * INRIA at visp@inria.fr * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * * Description: * Exemple of a Nurbs curve. * * Authors: * Nicolas Melchior * *****************************************************************************/ /*! \file Nurbs.cpp \brief Describe a curve thanks to a Nurbs. */ /*! \example Nurbs.cpp Describe a curve thanks to a BSpline. */ #include #include #include #include #include #include #include #include // Should be after #include #include #include #include #include #include #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GTK) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV) || defined(VISP_HAVE_D3D9) // List of allowed command line options #define GETOPTARGS "cdh" /*! Print the program options. \param name : Program name. \param badparam : Bad parameter name. */ void usage(const char *name, const char *badparam) { fprintf(stdout, "\n\ Describe a curve thanks to a Nurbs.\n\ \n\ SYNOPSIS\n\ %s [-c] [-d] [-h]\n", name); fprintf(stdout, "\n\ OPTIONS: Default\n\ -c\n\ Disable the mouse click. Useful to automaze the \n\ execution of this program without humain intervention.\n\ \n\ -d \n\ Turn off the display.\n\ \n\ -h\n\ Print the help.\n"); if (badparam) fprintf(stdout, "\nERROR: Bad parameter [%s]\n", badparam); } /*! Set the program options. \param argc : Command line number of parameters. \param argv : Array of command line parameters. \param click_allowed : Mouse click activation. \param display : Display activation. \return false if the program has to be stopped, true otherwise. */ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) { const char *optarg; int c; while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { switch (c) { case 'c': click_allowed = false; break; case 'd': display = false; break; case 'h': usage(argv[0], NULL); return false; break; default: usage(argv[0], optarg); return false; break; } } if ((c == 1) || (c == -1)) { // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; std::cerr << " Bad argument " << optarg << std::endl << std::endl; return false; } return true; } int main(int argc, const char ** argv) { bool opt_click_allowed = true; bool opt_display = true; // Read the command line options if (getOptions(argc, argv, opt_click_allowed, opt_display) == false) { exit (-1); } // Declare an image, this is a gray level image (unsigned char) // it size is not defined yet, it will be defined when the image will // read on the disk vpImage I(540,480); vpImage I2(540,480); vpImage I3(540,480); // We open a window using either X11, GTK or GDI. #if defined VISP_HAVE_X11 vpDisplayX display[3]; #elif defined VISP_HAVE_GDI vpDisplayGDI display[3]; #elif defined VISP_HAVE_GTK vpDisplayGTK display[3]; #elif defined VISP_HAVE_OPENCV vpDisplayOpenCV display[3]; #endif if (opt_display) { try{ // Display size is automatically defined by the image (I) size display[0].init(I, 100, 100,"Points as control points") ; vpDisplay::display(I) ; vpDisplay::flush(I) ; } catch(...) { vpERROR_TRACE("Error while displaying the image") ; exit(-1); } } vpNurbs Nurbs; std::list knots; knots.push_back(0); knots.push_back(0); knots.push_back(0); knots.push_back(1); knots.push_back(2); knots.push_back(3); knots.push_back(4); knots.push_back(4); knots.push_back(5); knots.push_back(5); knots.push_back(5); std::list controlPoints; std::list weights; vpImagePoint pt; pt.set_ij(50,300); controlPoints.push_back(pt); weights.push_back(1); pt.set_ij(100,130); controlPoints.push_back(pt); weights.push_back(5); pt.set_ij(150,400); controlPoints.push_back(pt); weights.push_back(0.2); pt.set_ij(200,370); controlPoints.push_back(pt); weights.push_back(10); pt.set_ij(250,120); controlPoints.push_back(pt); weights.push_back(1); pt.set_ij(300,250); controlPoints.push_back(pt); weights.push_back(2); pt.set_ij(350,200); controlPoints.push_back(pt); weights.push_back(3); pt.set_ij(400,300); controlPoints.push_back(pt); weights.push_back(1); Nurbs.set_p(2); Nurbs.set_knots(knots); Nurbs.set_controlPoints(controlPoints); Nurbs.set_weights(weights); std::cout << "The parameters are :" < knots_cur; Nurbs.get_knots(knots_cur); unsigned int i_display=0; for(std::list::const_iterator it=knots_cur.begin(); it!=knots_cur.end(); ++it, ++i_display){ std::cout << i_display << " ---> " << *it << std::endl; } std::cout << "The control points are :" < controlPoints_cur; Nurbs.get_controlPoints(controlPoints_cur); i_display=0; for(std::list::const_iterator it=controlPoints_cur.begin(); it!=controlPoints_cur.end(); ++it, ++i_display){ std::cout << i_display << " ---> " << *it << std::endl; } std::cout << "The associated weights are :" < weights_cur; Nurbs.get_weights(weights_cur); i_display=0; for(std::list::const_iterator it=weights_cur.begin(); it!=weights_cur.end(); ++it, ++i_display){ std::cout << i_display << " ---> " << *it << std::endl; } unsigned int i = Nurbs.findSpan(5/2.0); std::cout << "The knot interval number for the value u = 5/2 is : " << i <::const_iterator it=controlPoints.begin(); it!=controlPoints.end(); ++it){ vpDisplay::displayCross(I, *it, 4, vpColor::green); } vpDisplay::flush(I) ; vpDisplay::getClick(I); } if (opt_display) { try{ // Display size is automatically defined by the image (I) size display[1].init(I2, 100, 100,"Points interpolation") ; vpDisplay::display(I2) ; vpDisplay::flush(I2) ; } catch(...) { vpERROR_TRACE("Error while displaying the image") ; exit(-1); } } Nurbs.globalCurveInterp(controlPoints); if (opt_display && opt_click_allowed) { double u = 0.0; vpImagePoint pt; while (u <= 1) { pt = Nurbs.computeCurvePoint(u); vpDisplay::displayCross(I2,pt,4,vpColor::red); u+=0.01; } for(std::list::const_iterator it=controlPoints.begin(); it!=controlPoints.end(); ++it){ vpDisplay::displayCross(I2, *it, 4, vpColor::green); } vpDisplay::flush(I2) ; vpDisplay::getClick(I2); } if (opt_display) { try{ // Display size is automatically defined by the image (I) size display[2].init(I3, 100, 100,"Points approximation") ; vpDisplay::display(I3) ; vpDisplay::flush(I3) ; } catch(...) { vpERROR_TRACE("Error while displaying the image") ; exit(-1); } } Nurbs.globalCurveApprox(controlPoints,5); if (opt_display && opt_click_allowed) { double u = 0.0; vpImagePoint pt; while (u <= 1) { pt = Nurbs.computeCurvePoint(u); vpDisplay::displayCross(I3,pt,4,vpColor::red); u+=0.01; } for(std::list::const_iterator it=controlPoints.begin(); it!=controlPoints.end(); ++it){ vpDisplay::displayCross(I3, *it, 4, vpColor::green); } vpDisplay::flush(I3) ; vpDisplay::getClick(I3); } if (N != NULL) delete[] N; if (N2 != NULL) { for (int j = 0; j <= 2; j++) delete[] N2[j]; delete[] N2; } return 0; } #else int main() { std::cout << "This example requires a video device. " << std::endl << "You should install X11, GTK, OpenCV, GDI or Direct3D" << std::endl << "to be able to execute this example." << std::endl; return 0; } #endif ViSP-2.8.0/example/math/exponentialMap.cpp0000664000175000017500000000713312072022352020611 0ustar fspindlefspindle/**************************************************************************** * * $Id: exponentialMap.cpp 4056 2013-01-05 13:04:42Z fspindle $ * * This file is part of the ViSP software. * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. * * This software is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * ("GPL") version 2 as published by the Free Software Foundation. * See the file LICENSE.txt at the root directory of this source * distribution for additional information about the GNU GPL. * * For using ViSP with software that can not be combined with the GNU * GPL, please contact INRIA about acquiring a ViSP Professional * Edition License. * * See http://www.irisa.fr/lagadic/visp/visp.html for more information. * * This software was developed at: * INRIA Rennes - Bretagne Atlantique * Campus Universitaire de Beaulieu * 35042 Rennes Cedex * France * http://www.irisa.fr/lagadic * * If you have questions regarding the use of this file, please contact * INRIA at visp@inria.fr * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * * Description: * Test some vpColVector functionalities. * * Authors: * Eric Marchand * *****************************************************************************/ /*! \example exponentialMap.cpp Test some vpExponentialMap functionalities. */ #include #include #include #include #include #include #include int main() { vpTranslationVector t; t[0] = 0.1; // t_x in m/s t[1] = 0.2f; // t_y in m/s t[2] = 0.f; // t_z in m/s vpRxyzVector rxyz; rxyz[0] = vpMath::rad(0.f); // r_x in rad/s rxyz[1] = vpMath::rad(0.f); // r_y in rad/s rxyz[2] = vpMath::rad(90.f); // r_z in rad/s // Build a ThetaU rotation vector from a Rxyz vector vpThetaUVector tu; tu.buildFrom(rxyz); vpColVector v(6); // Velocity vector [t, thetaU]^t v[0] = t[0]; // t_x v[1] = t[1]; // t_y v[2] = t[2]; // t_z v[3] = tu[0]; // ThetaU_x v[4] = tu[1]; // ThetaU_y v[5] = tu[2]; // ThetaU_z std::cout << "Considered velocity : \n" << v << std::endl; vpHomogeneousMatrix M; // Compute the displacement from the velocity applied during 1 second M = vpExponentialMap::direct(v); { // Extract translation from homogenous matrix vpTranslationVector dt; // translation displacement M.extract(dt); // Extract rotation from homogenous matrix vpRotationMatrix R; M.extract(R); vpRxyzVector drxyz(R); // rotational displacement std::cout << "Displacement if velocity is applied during 1 s : \n" << dt << " " << drxyz << std::endl; } // Compute the displacement from the velocity applied during 2 seconds M = vpExponentialMap::direct(v, 2.f); { // Extract translation from homogenous matrix vpTranslationVector dt; // translation displacement M.extract(dt); // Extract rotation from homogenous matrix vpRotationMatrix R; M.extract(R); vpRxyzVector drxyz(R); // rotational displacement std::cout << "Displacement if velocity is applied during 2 s : \n" << dt << " " << drxyz << std::endl; } // Compute the velocity from the displacement observed during 2 seconds v = vpExponentialMap::inverse(M, 2.f); std::cout << "Velocity from displacement observed during 2 s: \n" << v << std::endl; } ViSP-2.8.0/example/math/CMakeLists.txt0000664000175000017500000000423612072022352017662 0ustar fspindlefspindle############################################################################# # # $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ # # This file is part of the ViSP software. # Copyright (C) 2005 - 2013 by INRIA. All rights reserved. # # This software is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # ("GPL") version 2 as published by the Free Software Foundation. # See the file LICENSE.txt at the root directory of this source # distribution for additional information about the GNU GPL. # # For using ViSP with software that can not be combined with the GNU # GPL, please contact INRIA about acquiring a ViSP Professional # Edition License. # # See http://www.irisa.fr/lagadic/visp/visp.html for more information. # # This software was developed at: # INRIA Rennes - Bretagne Atlantique # Campus Universitaire de Beaulieu # 35042 Rennes Cedex # France # http://www.irisa.fr/lagadic # # If you have questions regarding the use of this file, please contact # INRIA at visp@inria.fr # # This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE # WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # Description: # ViSP overall configuration file. # # Authors: # Fabien Spindler # ############################################################################# # SOURCE variable corresponds to the list of all the sources to build binaries. # The generate binary comes by removing the .cpp extension to # the source name. # # If you want to add/remove a source, modify here SET (SOURCE exponentialMap.cpp BSpline.cpp Nurbs.cpp ) # rule for binary build FOREACH(source ${SOURCE}) # Compute the name of the binary to create GET_FILENAME_COMPONENT(binary ${source} NAME_WE) # From source compile the binary and add link rules ADD_EXECUTABLE(${binary} ${source}) TARGET_LINK_LIBRARIES(${binary} ${VISP_INTERN_LIBRARY} ${VISP_EXTERN_LIBRARIES}) # Add test ADD_TEST(${binary} ${binary} -c ${OPTION_TO_DESACTIVE_DISPLAY}) ENDFOREACH(source) # customize clean target SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "core*;*~;gmon.out;DartTestfile.txt" ) ViSP-2.8.0/example/image/0000775000175000017500000000000012173700525015255 5ustar fspindlefspindleViSP-2.8.0/example/image/imageDiskRW.cpp0000664000175000017500000002331712171732061020133 0ustar fspindlefspindle/**************************************************************************** * * $Id: imageDiskRW.cpp 4323 2013-07-18 09:24:01Z fspindle $ * * This file is part of the ViSP software. * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. * * This software is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * ("GPL") version 2 as published by the Free Software Foundation. * See the file LICENSE.txt at the root directory of this source * distribution for additional information about the GNU GPL. * * For using ViSP with software that can not be combined with the GNU * GPL, please contact INRIA about acquiring a ViSP Professional * Edition License. * * See http://www.irisa.fr/lagadic/visp/visp.html for more information. * * This software was developed at: * INRIA Rennes - Bretagne Atlantique * Campus Universitaire de Beaulieu * 35042 Rennes Cedex * France * http://www.irisa.fr/lagadic * * If you have questions regarding the use of this file, please contact * INRIA at visp@inria.fr * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * * Description: * Reading and writting images on the disk. * * Authors: * Eric Marchand * *****************************************************************************/ /*! \file imageDiskRW.cpp \brief reading and writting of PPM image using vpImageIo class. Example of exception handling the exception : read an image that does not exist write in a directory that does no exist */ /*! \example imageDiskRW.cpp Reading and writting of PPM image using vpImageIo class. Example of exception handling the exception : read an image that does not exist, write in a directory that does no exist */ #include #include #include #include #include #include #include // List of allowed command line options #define GETOPTARGS "i:o:h" /*! Print the program options. \param name : Program name. \param badparam : Bad parameter name. \param ipath : Input image path. \param opath : Output image path. \param user : Username. */ void usage(const char *name, const char *badparam, std::string ipath, std::string opath, std::string user) { fprintf(stdout, "\n\ Read and write PGM images on the disk. Also test exceptions.\n\ \n\ SYNOPSIS\n\ %s [-i ] [-o ]\n\ [-h]\n \ ", name); fprintf(stdout, "\n\ OPTIONS: Default\n\ -i %s\n\ Set image input path.\n\ From this path read \"ViSP-images/Klimt/Klimt.pgm\"\n\ image.\n\ Setting the VISP_INPUT_IMAGE_PATH environment\n\ variable produces the same behaviour than using\n\ this option.\n\ \n\ -o %s\n\ Set image output path.\n\ From this directory, creates the \"%s\"\n\ subdirectory depending on the username, where \n\ Klimt_grey.pgm output image is written.\n\ \n\ -h\n\ Print the help.\n\n", ipath.c_str(), opath.c_str(), user.c_str()); if (badparam) { fprintf(stderr, "ERROR: \n" ); fprintf(stderr, "\nBad parameter [%s]\n", badparam); } } /*! Set the program options. \param argc : Command line number of parameters. \param argv : Array of command line parameters. \param ipath : Input image path. \param opath : Output image path. \param user : Username. \return false if the program has to be stopped, true otherwise. */ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &opath, std::string user) { const char *optarg; int c; while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { switch (c) { case 'i': ipath = optarg; break; case 'o': opath = optarg; break; case 'h': usage(argv[0], NULL, ipath, opath, user); return false; break; default: usage(argv[0], optarg, ipath, opath, user); return false; break; } } if ((c == 1) || (c == -1)) { // standalone param or error usage(argv[0], NULL, ipath, opath, user); std::cerr << "ERROR: " << std::endl; std::cerr << " Bad argument " << optarg << std::endl << std::endl; return false; } return true; } int main(int argc, const char ** argv) { std::string env_ipath; std::string opt_ipath; std::string opt_opath; std::string ipath; std::string opath; std::string filename; std::string username; std::cout << "-------------------------------------------------------" << std::endl ; std::cout << " imageDiskRW.cpp" < " << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl << " we skip the environment variable." << std::endl; } } // Test if an input path is set if (opt_ipath.empty() && env_ipath.empty()){ usage(argv[0], NULL, ipath, opath, username); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Use -i option or set VISP_INPUT_IMAGE_PATH " << std::endl << " environment variable to specify the location of the " << std::endl << " image path where test images are located." << std::endl << std::endl; exit(-1); } ///////////////////////////////////////////////////////////////////// // First we wanted to have gray level image (8bits) // vpImage is a template class you can declare vpImage of ... everything... vpImage I ; // Although I is a gray level image you can read and write // color image. Obviously the color will be translated as a gray level filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); vpImageIo::read(I, filename); filename = dirname + vpIoTools::path("/IoPPM.Klimt_char.ppm"); vpImageIo::write(I, filename) ; // test io error // if the image you want to read on the disk does not exist // an exception is thrown try { //Try to load a non existing image filename = ipath + vpIoTools::path("/ViSP-images/image-that-does-not-exist.ppm"); vpImageIo::read(I,filename) ; } catch(vpImageException e) { vpERROR_TRACE("at main level"); std::cout << e << std::endl ; } // same thing if you to write in a directory that does not exist // or where you are not allowd to write. try { filename = dirname + vpIoTools::path("/directory-that-does-not-exist/Klimt.ppm"); vpImageIo::write(I,filename) ; } catch(vpImageException e) { vpERROR_TRACE("at main level"); std::cout << e << std::endl ; } std::cout << "----------------------------------------------------" << std::endl ; // Let's consider that the image is now a color image (32 bits RGBa) vpImage Irgba ; // read write unsigned char ppm image. // Load a color image from the disk filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); vpImageIo::read(Irgba, filename); // Write the content of the color image on the disk filename = dirname + vpIoTools::path("/IoPGM.Klimt_rgba.ppm"); vpImageIo::write(Irgba, filename) ; // test io error try { filename = ipath + vpIoTools::path("/ViSP-images/image-that-does-not-exist.ppm"); vpImageIo::read(Irgba,filename) ; } catch(vpImageException e) { vpERROR_TRACE("at main level"); std::cout << e << std::endl ; } // test io error try { filename = dirname + vpIoTools::path("/directory-that-does-not-exist/Klimt.ppm"); vpImageIo::write(Irgba,filename) ; } catch(vpImageException e) { vpERROR_TRACE("at main level"); std::cout << e << std::endl ; } } ViSP-2.8.0/example/image/CMakeLists.txt0000664000175000017500000000430312072022352020006 0ustar fspindlefspindle############################################################################# # # $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ # # This file is part of the ViSP software. # Copyright (C) 2005 - 2013 by INRIA. All rights reserved. # # This software is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # ("GPL") version 2 as published by the Free Software Foundation. # See the file LICENSE.txt at the root directory of this source # distribution for additional information about the GNU GPL. # # For using ViSP with software that can not be combined with the GNU # GPL, please contact INRIA about acquiring a ViSP Professional # Edition License. # # See http://www.irisa.fr/lagadic/visp/visp.html for more information. # # This software was developed at: # INRIA Rennes - Bretagne Atlantique # Campus Universitaire de Beaulieu # 35042 Rennes Cedex # France # http://www.irisa.fr/lagadic # # If you have questions regarding the use of this file, please contact # INRIA at visp@inria.fr # # This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE # WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # Description: # ViSP overall configuration file. # # Authors: # Fabien Spindler # ############################################################################# # SOURCE variable corresponds to the list of all the sources to build binaries. # The generate binary comes by removing the .cpp extension to # the source name. # # If you want to add/remove a source, modify here SET (SOURCE imageDiskRW.cpp ) # rule for binary build FOREACH(source ${SOURCE}) # Compute the name of the binary to create GET_FILENAME_COMPONENT(binary ${source} NAME_WE) # From source compile the binary and add link rules ADD_EXECUTABLE(${binary} ${source}) TARGET_LINK_LIBRARIES(${binary} ${VISP_INTERN_LIBRARY} ${VISP_EXTERN_LIBRARIES}) ENDFOREACH(source) # Add test # To run some of these tests don't forget to set VISP_INPUT_IMAGE_PATH # environment variable to the ViSP test sequences location. # To get these sequence download ViSP-images.tar.gz from # http://www.irisa.fr/lagadic/visp/visp.html ADD_TEST(imageDiskRW imageDiskRW) ViSP-2.8.0/example/parse-argv/0000775000175000017500000000000012173700526016243 5ustar fspindlefspindleViSP-2.8.0/example/parse-argv/parse-argv2.cpp0000664000175000017500000000525012072022352021072 0ustar fspindlefspindle/**************************************************************************** * * $Id: parse-argv2.cpp 4056 2013-01-05 13:04:42Z fspindle $ * * This file is part of the ViSP software. * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. * * This software is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * ("GPL") version 2 as published by the Free Software Foundation. * See the file LICENSE.txt at the root directory of this source * distribution for additional information about the GNU GPL. * * For using ViSP with software that can not be combined with the GNU * GPL, please contact INRIA about acquiring a ViSP Professional * Edition License. * * See http://www.irisa.fr/lagadic/visp/visp.html for more information. * * This software was developed at: * INRIA Rennes - Bretagne Atlantique * Campus Universitaire de Beaulieu * 35042 Rennes Cedex * France * http://www.irisa.fr/lagadic * * If you have questions regarding the use of this file, please contact * INRIA at visp@inria.fr * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * * Description: * Example of command line parsing. * * Author: * Fabien Spindler * *****************************************************************************/ /*! \file parse-argv2.cpp \brief Parsing command line arguments. */ /*! \example parse-argv2.cpp Example of command line parsing. */ #include #include #include #include #include int main(int argc, const char ** argv) { using ::std::cout; using ::std::endl; int i_val = 3; float f_val = 3.14f; double d_val = 3.1415; vpParseArgv::vpArgvInfo argTable[] = { {"-integer", vpParseArgv::ARGV_INT, (char*) NULL, (char *) &i_val, "An integer value."}, {"-float", vpParseArgv::ARGV_FLOAT, (char*) NULL, (char *) &f_val, "A float value."}, {"-double", vpParseArgv::ARGV_DOUBLE, (char*) NULL, (char *) &d_val, "A double value."}, {(char*) NULL, vpParseArgv::ARGV_END, (char*) NULL, (char*) NULL, (char*) NULL} } ; // Read the command line options if(vpParseArgv::parse(&argc, argv, argTable, 0)) { return (-1); } cout << "Your parameters: " << endl; cout << " Integer value: " << i_val << endl; cout << " Float value: " << f_val << endl; cout << " Double value: " << d_val << endl << endl; cout << "Call " << argv[0] << " -h to see how to change these parameters." << endl; return 0; } /* * Local variables: * c-basic-offset: 2 * End: */ ViSP-2.8.0/example/parse-argv/parse-argv1.cpp0000664000175000017500000001052712072022352021074 0ustar fspindlefspindle/**************************************************************************** * * $Id: parse-argv1.cpp 4056 2013-01-05 13:04:42Z fspindle $ * * This file is part of the ViSP software. * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. * * This software is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * ("GPL") version 2 as published by the Free Software Foundation. * See the file LICENSE.txt at the root directory of this source * distribution for additional information about the GNU GPL. * * For using ViSP with software that can not be combined with the GNU * GPL, please contact INRIA about acquiring a ViSP Professional * Edition License. * * See http://www.irisa.fr/lagadic/visp/visp.html for more information. * * This software was developed at: * INRIA Rennes - Bretagne Atlantique * Campus Universitaire de Beaulieu * 35042 Rennes Cedex * France * http://www.irisa.fr/lagadic * * If you have questions regarding the use of this file, please contact * INRIA at visp@inria.fr * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * * Description: * Example of command line parsing. * * Author: * Fabien Spindler * *****************************************************************************/ /*! \file parse-argv1.cpp \brief Parsing command line arguments. */ /*! \example parse-argv1.cpp Example of command line parsing. */ #include #include #include #include #include #include // List of allowed command line options #define GETOPTARGS "d:f:i:h" /*! Print the program options. \param name : Program name. \param badparam : Bad parameter name. \param i_val : An integer. \param f_val : A float. \param d_val : A double. */ void usage(const char *name, const char *badparam, int i_val, float f_val, double d_val) { fprintf(stdout, "\n\ Parsing command line arguments example.\n\ \n\ SYNOPSIS\n\ %s [-i ] [-f ] [-d [-h]\n\ ", name); fprintf(stdout, "\n\ OPTIONS: Default\n\ -i %d\n\ An integer value.\n\ \n\ -f %f\n\ A float value.\n\ \n\ -d %g\n\ A double value.\n\ \n\ -h\n\ Print the help.\n\n", i_val, f_val, d_val); if (badparam) { fprintf(stderr, "ERROR: \n" ); fprintf(stderr, "\nBad parameter [%s]\n", badparam); } } /*! Set the program options. \param argc : Command line number of parameters. \param argv : Array of command line parameters. \param i_val : An integer. \param f_val : A float. \param d_val : A double. \return false if the program has to be stopped, true otherwise. */ bool getOptions(int argc, const char **argv, int &i_val, float &f_val, double &d_val) { const char *optarg; int c; while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { switch (c) { case 'd': d_val = atof(optarg); break; case 'f': f_val = (float) atof(optarg); break; case 'i': i_val = atoi(optarg); break; case 'h': usage(argv[0], NULL, i_val, f_val, d_val); return false; break; default: usage(argv[0], optarg, i_val, f_val, d_val); return false; break; } } if ((c == 1) || (c == -1)) { // standalone param or error usage(argv[0], NULL, i_val, f_val, d_val); std::cerr << "ERROR: " << std::endl; std::cerr << " Bad argument " << optarg << std::endl << std::endl; return false; } return true; } int main(int argc, const char ** argv) { using ::std::cout; using ::std::endl; int i_val = 3; float f_val = 3.14f; double d_val = 3.1415; // Read the command line options if (getOptions(argc, argv, i_val, f_val, d_val) == false) { return (-1); } cout << "Your parameters: " << endl; cout << " Integer value: " << i_val << endl; cout << " Float value: " << f_val << endl; cout << " Double value: " << d_val << endl << endl; cout << "Call " << argv[0] << " -h to see how to change these parameters." << endl; return 0; } /* * Local variables: * c-basic-offset: 2 * End: */ ViSP-2.8.0/example/parse-argv/CMakeLists.txt0000664000175000017500000000415112072022352020774 0ustar fspindlefspindle############################################################################# # # $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ # # This file is part of the ViSP software. # Copyright (C) 2005 - 2013 by INRIA. All rights reserved. # # This software is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # ("GPL") version 2 as published by the Free Software Foundation. # See the file LICENSE.txt at the root directory of this source # distribution for additional information about the GNU GPL. # # For using ViSP with software that can not be combined with the GNU # GPL, please contact INRIA about acquiring a ViSP Professional # Edition License. # # See http://www.irisa.fr/lagadic/visp/visp.html for more information. # # This software was developed at: # INRIA Rennes - Bretagne Atlantique # Campus Universitaire de Beaulieu # 35042 Rennes Cedex # France # http://www.irisa.fr/lagadic # # If you have questions regarding the use of this file, please contact # INRIA at visp@inria.fr # # This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE # WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # Description: # ViSP configuration file. # # Authors: # Fabien Spindler # ############################################################################# # SOURCE variable corresponds to the list of all the sources to build binaries. # The generate binary comes by removing the .cpp extension to # the source name. # # If you want to add/remove a source, modify here SET (SOURCE parse-argv1.cpp parse-argv2.cpp ) # rule for binary build FOREACH(source ${SOURCE}) # Compute the name of the binary to create GET_FILENAME_COMPONENT(binary ${source} NAME_WE) # From source compile the binary and add link rules ADD_EXECUTABLE(${binary} ${source}) TARGET_LINK_LIBRARIES(${binary} ${VISP_INTERN_LIBRARY} ${VISP_EXTERN_LIBRARIES}) # Add test ADD_TEST(${binary} ${binary}) ENDFOREACH(source) # customize clean target SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "core*;*~;gmon.out;DartTestfile.txt" ) ViSP-2.8.0/example/device/0000775000175000017500000000000012173700526015433 5ustar fspindlefspindleViSP-2.8.0/example/device/light/0000775000175000017500000000000012173700526016542 5ustar fspindlefspindleViSP-2.8.0/example/device/light/ringLight.cpp0000664000175000017500000001335112072022352021170 0ustar fspindlefspindle/**************************************************************************** * * $Id: ringLight.cpp 4056 2013-01-05 13:04:42Z fspindle $ * * This file is part of the ViSP software. * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. * * This software is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * ("GPL") version 2 as published by the Free Software Foundation. * See the file LICENSE.txt at the root directory of this source * distribution for additional information about the GNU GPL. * * For using ViSP with software that can not be combined with the GNU * GPL, please contact INRIA about acquiring a ViSP Professional * Edition License. * * See http://www.irisa.fr/lagadic/visp/visp.html for more information. * * This software was developed at: * INRIA Rennes - Bretagne Atlantique * Campus Universitaire de Beaulieu * 35042 Rennes Cedex * France * http://www.irisa.fr/lagadic * * If you have questions regarding the use of this file, please contact * INRIA at visp@inria.fr * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * * Description: * Example of ring light control. * * Author: * Fabien Spindler * *****************************************************************************/ /*! \example ringLight.cpp Shows how to activates the ring light. */ #include #include #include // std::fabs #include // numeric_limits #if defined VISP_HAVE_PARPORT #include #include #include #include #include #include // List of allowed command line options #define GETOPTARGS "d:hn:ot:" /*! Print the program options. \param name : Program name. \param badparam : Bad parameter name. \param nsec : Time to wait in seconds \param nmsec : Pulse duration in ms */ void usage(const char *name, const char *badparam, int nsec, double nmsec) { fprintf(stdout, "\n\ Send a pulse to activate the ring light or turn on the ring light \n\ during %d s.\n\ \n\ By default, that means without parameters, send a pulse which duration\n\ is fixed by the harware. To control the duration of the pulse, use \n\ \"-t \" option. To turn on the light permanently, \n\ use \"-o -n ]\"\n \ \n\ SYNOPSIS\n\ %s [-o] [-n ] [-t ] [-h]\n\ ", nsec, name); fprintf(stdout, "\n\ OPTIONS: Default\n\ \n\ -o\n\ Turn the ring light on during %d s.\n\ If this option is not set, send a short pulse\n\ to activate the light.\n\ \n\ -t %%g : %g\n\ Pulse width in milli-second.\n\ Send a pulse which duration is fixed by this parameter.\n\ Without this option, the pulse width is fixed by the \n\ harware.\n\ \n\ -n %%d : %d\n\ Time in second while the ring light is turned on.\n\ This option is to make into realtion with option \"-o\".\n\ \n\ -h\n\ Print the help.\n\n", nsec, nmsec, nsec); if (badparam) { fprintf(stderr, "ERROR: \n" ); fprintf(stderr, "\nBad parameter [%s]\n", badparam); } } /*! Set the program options. \param argc : Command line number of parameters. \param argv : Array of command line parameters. \param on : When true, turn on the light during nsec seconds. \param nsec : Time to wait in seconds. \param nmsec : Pulse duration in milli-seconds. \return false if the program has to be stopped, true otherwise. */ bool getOptions(int argc, const char **argv, bool &on, int &nsec, double &nmsec) { const char *optarg; int c; while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { switch (c) { case 'n': nsec = atoi(optarg); break; case 'o': on = true; break; case 't': nmsec = atof(optarg); break; case 'h': usage(argv[0], NULL, nsec, nmsec); return false; break; default: usage(argv[0], optarg, nsec, nmsec); return false; break; } } if ((c == 1) || (c == -1)) { // standalone param or error usage(argv[0], NULL, nsec, nmsec); std::cerr << "ERROR: " << std::endl; std::cerr << " Bad argument " << optarg << std::endl << std::endl; return false; } return true; } /*! Send a data to the parallel port. */ int main(int argc, const char **argv) { bool on = false; int nsec = 5; // Time while the ring light is turned on double nmsec = 0; // Pulse duration // Read the command line options if (getOptions(argc, argv, on, nsec, nmsec) == false) { exit (-1); } try { vpRingLight light; //if (nmsec == 0.) if (std::fabs(nmsec) <= std::numeric_limits::epsilon()) light.pulse(); else light.pulse(nmsec); if (on) { printf("Turn on ring light\n"); light.on(); // Turn the ring light on vpTime::wait(nsec * 1000); // Wait 5 s light.off(); // and then turn the ring light off } else { printf("Send a pulse to activate the ring light\n"); light.pulse(); } } catch (vpParallelPortException e) { switch(e.getCode()) { case vpParallelPortException::opening: printf("Can't open the parallel port to access to the ring light device\n"); break; case vpParallelPortException::closing: printf("Can't close the parallel port\n"); break; } } catch(...) { printf("An error occurs...\n"); } return 0; } #else int main() { vpTRACE("Sorry, for the moment, vpRingLight class works only on unix..."); return 0; } #endif ViSP-2.8.0/example/device/light/CMakeLists.txt0000664000175000017500000000413612072022352021276 0ustar fspindlefspindle############################################################################# # # $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ # # This file is part of the ViSP software. # Copyright (C) 2005 - 2013 by INRIA. All rights reserved. # # This software is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # ("GPL") version 2 as published by the Free Software Foundation. # See the file LICENSE.txt at the root directory of this source # distribution for additional information about the GNU GPL. # # For using ViSP with software that can not be combined with the GNU # GPL, please contact INRIA about acquiring a ViSP Professional # Edition License. # # See http://www.irisa.fr/lagadic/visp/visp.html for more information. # # This software was developed at: # INRIA Rennes - Bretagne Atlantique # Campus Universitaire de Beaulieu # 35042 Rennes Cedex # France # http://www.irisa.fr/lagadic # # If you have questions regarding the use of this file, please contact # INRIA at visp@inria.fr # # This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE # WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # Description: # ViSP overall configuration file. # # Authors: # Fabien Spindler # ############################################################################# # SOURCE variable corresponds to the list of all the sources to build binaries. # The generate binary comes by removing the .cpp extension to # the source name. # # If you want to add/remove a source, modify here SET (SOURCE ringLight.cpp ) # rule for binary build FOREACH(source ${SOURCE}) # Compute the name of the binary to create GET_FILENAME_COMPONENT(binary ${source} NAME_WE) # From source compile the binary and add link rules ADD_EXECUTABLE(${binary} ${source}) TARGET_LINK_LIBRARIES(${binary} ${VISP_INTERN_LIBRARY} ${VISP_EXTERN_LIBRARIES}) # Add test #ADD_TEST(${binary} ${binary}) ENDFOREACH(source) # customize clean target SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "core*;*~;gmon.out;DartTestfile.txt" ) ViSP-2.8.0/example/device/framegrabber/0000775000175000017500000000000012173700526020052 5ustar fspindlefspindleViSP-2.8.0/example/device/framegrabber/grabDirectShowMulti.cpp0000664000175000017500000003256412171732061024507 0ustar fspindlefspindle/**************************************************************************** * * $Id: grabDirectShowMulti.cpp 4323 2013-07-18 09:24:01Z fspindle $ * * This file is part of the ViSP software. * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. * * This software is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * ("GPL") version 2 as published by the Free Software Foundation. * See the file LICENSE.txt at the root directory of this source * distribution for additional information about the GNU GPL. * * For using ViSP with software that can not be combined with the GNU * GPL, please contact INRIA about acquiring a ViSP Professional * Edition License. * * See http://www.irisa.fr/lagadic/visp/visp.html for more information. * * This software was developed at: * INRIA Rennes - Bretagne Atlantique * Campus Universitaire de Beaulieu * 35042 Rennes Cedex * France * http://www.irisa.fr/lagadic * * If you have questions regarding the use of this file, please contact * INRIA at visp@inria.fr * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Description: * Acquire images using DirectShow (under Windows only) and display it * using GTK or GDI. * * Authors: * Bruno Renier * Fabien Spindler * Anthony Saunier * *****************************************************************************/ #include #include /*! \file grabDirectShowMulti.cpp \brief Example of framegrabbing using vpDirectShowGrabber class. */ #include #include #include #if defined (VISP_HAVE_DIRECTSHOW) #if (defined (VISP_HAVE_GTK) || defined(VISP_HAVE_GDI)) #include #include #include #include #include #include #include // List of allowed command line options //#define GETOPTARGS "dhn:o:" #define GETOPTARGS "c:df:hmn:io:st:?" #define GRAB_COLOR /*! Print the program options. \param name : Program name. \param badparam : Bad parameter name. \param camera : Active camera identifier. \param nframes : Number of frames to acquire. \param opath : Image filename when saving. */ void usage(const char *name, const char *badparam, unsigned int camera, unsigned int &nframes, std::string &opath) { if (badparam) fprintf(stderr, "\nERREUR: Bad parameter [%s]\n", badparam); fprintf(stdout, "\n\ Acquire images using DirectShow (under Windows only) and display\n\ it using GTK or the windows GDI if GTK is not available.\n\ For a given camera, mediatype (or video mode) as well as framerate\n\ can be set.\n\ If more than one camera is connected, this example allows also to \n\ acquire images from all the cameras.\n\ \n\ SYNOPSIS\n\ %s [-t ] [-f ] \n\ [-c ] [-m] [-n ] [-i] [-s] [-d] \n\ [-o ] [-h]\n\ \n\ OPTIONS Default\n\ -t [%%u] \n\ MediaType (or video mode) to set for the active \n\ camera. Use -s option so see which are the supported \n\ Mediatypes. You can select the active camera \n\ using -c option.\n\ \n\ -f [%%d] \n\ Framerate to set for the active camera.\n\ You can select the active camera using -c option.\n", name); fprintf(stdout, "\n\ -c [%%u] %u\n\ Active camera identifier.\n\ Zero is for the first camera found on the bus.\n\ \n\ -m \n\ Flag to active multi camera acquisition. \n\ You need at least two cameras connected on the bus.\n\ \n\ -n [%%u] %u\n\ Number of frames to acquire.\n\ \n\ -i \n\ Flag to print camera information.\n\ \n\ -s \n\ Print camera settings capabilities such as MediaType \n\ and sizes available and exit.\n\ \n\ -d \n\ Flag to turn off image display.\n\ \n\ -o [%%s] \n\ Filename for image saving. \n\ Example: -o %s\n\ The first %%d is for the camera id, %%04d\n\ is for the image numbering.\n\ \n\ -h \n\ Print the help.\n\ \n", camera, nframes, opath.c_str()); exit(0); } /*! Set the program options. \param argc : Command line number of parameters. \param argv : Array of command line parameters. \param multi : Multi camera framegrabbing activation. \param camera : Active camera identifier. \param nframes : Number of frames to acquire. \param verbose_info : Camera information printing. \param verbose_settings : Camera settings printing. \param mediatype_is_set : New mediatype setting. \param mediatypeID : Mediatype setting. \param framerate_is_set : New framerate setting. \param framerate : Framerate setting. \param display : Display activation. \param save : Image saving activation. \param opath : Image filename when saving. */ void read_options(int argc, const char **argv, bool &multi, unsigned int &camera, unsigned int &nframes, bool &verbose_info, bool &verbose_settings, bool &mediatype_is_set, unsigned int &mediatypeID, bool &framerate_is_set, double &framerate, bool &display, bool &save, std::string &opath) { const char *optarg; int c; /* * Lecture des options. */ while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS,&optarg)) > 1) { switch (c) { case 'c': camera = atoi(optarg); break; case 'd': display = false; break; case 'f': framerate_is_set = true; framerate = atoi(optarg); break; case 'i': verbose_info = true; break; case 'm': multi = true; break; case 'n': nframes = atoi(optarg); break; case 'o': save = true; opath = optarg; break; case 's': verbose_settings = true; break; case 't': mediatype_is_set = true; mediatypeID = atoi(optarg); break; default: usage(argv[0], NULL, camera, nframes, opath); break; } } if ((c == 1) || (c == -1)) { // standalone param or error usage(argv[0], NULL, camera, nframes, opath); std::cerr << "ERROR: " << std::endl; std::cerr << " Bad argument " << optarg << std::endl << std::endl; } } /*! \example grabDirectShowMulti.cpp Example of framegrabbing using vpDirectShowGrabber class. Grab grey level images using DirectShow frame grabbing capabilities. Display the images using the GTK or GDI display. */ int main(int argc, const char ** argv) { try { unsigned int camera = 0; bool multi = false; bool verbose_info = false; bool verbose_settings = false; bool display = true; unsigned int nframes = 50; bool mediatype_is_set = false; unsigned int mediatypeID; bool framerate_is_set = false; double framerate; bool save = false; #ifdef GRAB_COLOR vpImage *I; std::string opath = "C:/temp/I%d-%04d.ppm"; #else vpImage *I; std::string opath = "C:/temp/I%d-%04d.pgm"; #endif #if defined VISP_HAVE_GDI vpDisplayGDI *d; #elif defined VISP_HAVE_GTK vpDisplayGTK *d; #endif read_options(argc, argv, multi, camera, nframes, verbose_info, verbose_settings, mediatype_is_set, mediatypeID, framerate_is_set, framerate, display, save, opath); // Number of cameras connected on the bus vpDirectShowGrabber *g; g = new vpDirectShowGrabber(); unsigned int ncameras = g->getDeviceNumber(); // Check the consistancy of the options if (multi) { // ckeck if two cameras are connected if (ncameras < 2) { std::cout << "You have only " << ncameras << " camera connected on the bus." << std::endl; std::cout << "It is not possible to active multi-camera acquisition." << std::endl; std::cout << "Disable -m command line option, or connect an other " << std::endl; std::cout << "cameras on the bus." << std::endl; g->close(); return(0); } } if (camera >= ncameras) { std::cout << "You have only " << ncameras; std::cout << " camera connected on the bus." << std::endl; std::cout << "It is not possible to select camera " << camera << std::endl; std::cout << "Check your -c command line option." << std::endl; g->close(); return(0); } if (multi) { camera = 0; // to over write a bad option usage //reinitialize the grabbers with the right number of devices (one grabber per device) delete g; g = new vpDirectShowGrabber[ncameras]; for(unsigned int i=0; i [ncameras]; #else I = new vpImage [ncameras]; #endif if (display) #ifdef VISP_HAVE_GDI d = new vpDisplayGDI [ncameras]; #else d = new vpDisplayGTK [ncameras]; #endif // If required modify camera settings if (mediatype_is_set) { g[0].setMediaType(mediatypeID); } else { // get The actual video mode mediatypeID = g[0].getMediaType(); } if (framerate_is_set) { for(unsigned int i=0; i." << std::endl << "----------------------------------------------------------" << std::endl; g[i].getStreamCapabilities(); } } return 0; } // Do a first acquisition to initialise the display for (unsigned int i=0; i < ncameras; i ++) { // Acquire the first image g[i].acquire(I[i]); unsigned int c; if (multi) c = i; else c = camera; std::cout << "Image size for camera " << c << " : width: " << I[i].getWidth() << " height: " << I[i].getHeight() << std::endl; if (display) { // Initialise the display char title[100]; sprintf(title, "Images captured by camera %u", c ); d[i].init(I[i], 100+i*50, 100+i*50, title) ; } } // Main loop for single or multi-camera acquisition and display std::cout << "Capture in process..." << std::endl; double tbegin=0, tend=0, tloop=0, ttotal=0; ttotal = 0; tbegin = vpTime::measureTimeMs(); for (unsigned i = 0; i < nframes; i++) { for (unsigned c = 0; c < ncameras; c++) { // Acquire an image g[c].acquire(I[c]); if (display) { // Display the last image acquired vpDisplay::display(I[c]); vpDisplay::flush(I[c]); } if (save) { char buf[FILENAME_MAX]; sprintf(buf, opath.c_str(), c, i); std::string filename(buf); std::cout << "Write: " << filename << std::endl; vpImageIo::write(I[c], filename); } } tend = vpTime::measureTimeMs(); tloop = tend - tbegin; tbegin = tend; std::cout << "loop time: " << tloop << " ms" << std::endl; ttotal += tloop; } std::cout << "Mean loop time: " << ttotal / nframes << " ms" << std::endl; std::cout << "Mean frequency: " << 1000./(ttotal / nframes) << " fps" << std::endl; // Release the framegrabber delete [] g; // Free memory delete [] I; if (display) delete [] d; } catch (...) { vpCERROR << "Failure: exit" << std::endl; } std::cout << " the end" << std::endl; } #else // (defined (VISP_HAVE_GTK) || defined(VISP_HAVE_GDI)) int main() { vpTRACE("GDI or GTK is not available...") ; } #endif // (defined (VISP_HAVE_GTK) || defined(VISP_HAVE_GDI)) #else // defined (VISP_HAVE_DIRECTSHOW) int main() { vpTRACE("DirectShow is not available...") ; } #endif // defined (VISP_HAVE_DIRECTSHOW) ViSP-2.8.0/example/device/framegrabber/grab1394CMU.cpp0000664000175000017500000001654012171732061022362 0ustar fspindlefspindle/**************************************************************************** * * $Id: grab1394CMU.cpp 4323 2013-07-18 09:24:01Z fspindle $ * * This file is part of the ViSP software. * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. * * This software is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * ("GPL") version 2 as published by the Free Software Foundation. * See the file LICENSE.txt at the root directory of this source * distribution for additional information about the GNU GPL. * * For using ViSP with software that can not be combined with the GNU * GPL, please contact INRIA about acquiring a ViSP Professional * Edition License. * * See http://www.irisa.fr/lagadic/visp/visp.html for more information. * * This software was developed at: * INRIA Rennes - Bretagne Atlantique * Campus Universitaire de Beaulieu * 35042 Rennes Cedex * France * http://www.irisa.fr/lagadic * * If you have questions regarding the use of this file, please contact * INRIA at visp@inria.fr * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * * Description: * Video capture example based on CMU 1394 Digital Camera SDK. * * Author: * Fabien Spindler * *****************************************************************************/ /*! \file grab1394CMU.cpp \brief Video capture example based on CMU 1394 Digital Camera SDK. */ #include #include #include #include #include #include #include #include #include #include #include #define GRAB_COLOR // List of allowed command line options #define GETOPTARGS "dhn:o:" /*! Print the program options. \param name : Program name. \param badparam : Bad parameter name. \param nframes : Number of frames to acquire. \param opath : Image filename when saving. */ void usage(const char *name, const char *badparam, unsigned &nframes, std::string &opath) { fprintf(stdout, "\n\ Acquire images using CMU 1394 Digital Camera SDK (available under Windows only) and display\n\ it using GDI or OpenCV if GDI is not available.\n\ \n\ SYNOPSIS\n\ %s [-d] [-n] [-o] [-h] \n", name); fprintf(stdout, "\n\ OPTIONS: Default\n\ -d \n\ Turn off the display.\n\ \n\ -n [%%u] %u\n\ Number of frames to acquire. \n\ \n\ -o [%%s] \n\ Filename for image saving. \n\ Example: -o %s\n\ The %%d is for the image numbering.\n\ \n\ -h \n\ Print the help.\n\ \n", nframes, opath.c_str()); if (badparam) { fprintf(stderr, "ERROR: \n" ); fprintf(stderr, "\nBad parameter [%s]\n", badparam); } } /*! Set the program options. Print the program options. \param argc : Command line number of parameters. \param argv : Array of command line parameters. \param display : Display activation. \param nframes : Number of frames to acquire. \param save : Image saving activation. \param opath : Image filename when saving. \return false if the program has to be stopped, true otherwise. */ bool getOptions(int argc, const char **argv, bool &display, unsigned int &nframes, bool &save, std::string &opath) { const char *optarg; int c; while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { switch (c) { case 'd': display = false; break; case 'n': nframes = (unsigned int)atoi(optarg); break; case 'o': save = true; opath = optarg; break; case 'h': usage(argv[0], NULL, nframes, opath); return false; break; default: usage(argv[0], optarg, nframes, opath); return false; break; } } if ((c == 1) || (c == -1)) { // standalone param or error usage(argv[0], NULL, nframes, opath); std::cerr << "ERROR: " << std::endl; std::cerr << " Bad argument " << optarg << std::endl << std::endl; return false; } return true; } /*! \example grab1394CMU.cpp Video capture example based on CMU 1394 Digital Camera SDK using vp1394CMUGrabber class. Display the images using the GDI or OpenCV display. */ #if defined(VISP_HAVE_CMU1394) int main(int argc, const char ** argv) { bool opt_display = true; unsigned nframes = 50; bool save = false; // Declare an image. It size is not defined yet. It will be defined when the // image will acquired the first time. #ifdef GRAB_COLOR vpImage I; // This is a color image (in RGBa format) #else vpImage I; // This is a B&W image #endif // Set default output image name for saving #ifdef GRAB_COLOR // Color images will be saved in PGM P6 format std::string opath = "C:/temp/I%04d.ppm"; #else // B&W images will be saved in PGM P5 format std::string opath = "C:/temp/I%04d.pgm"; #endif // Read the command line options if (getOptions(argc, argv, opt_display, nframes, save, opath) == false) { exit (-1); } // Create the grabber vp1394CMUGrabber g; unsigned short gain_min, gain_max; g.getGainMinMax(gain_min, gain_max); std::cout << "Gain range [" << gain_min << ", " << gain_max << "]" << std::endl; unsigned short shutter_min, shutter_max; g.getShutterMinMax(shutter_min, shutter_max); std::cout << "Shutter range [" << shutter_min << ", " << shutter_max << "]" << std::endl; g.setFramerate(4); // 30 fps std::cout << "Actual framerate: " << g.getFramerate() << std::endl; g.setVideoMode(0,0); g.acquire(I); std::cout << "Image size: width : " << I.getWidth() << " height: " << I.getHeight() << std::endl; #if (defined (VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV)) // Creates a display #if defined VISP_HAVE_OPENCV vpDisplayOpenCV display; #elif defined VISP_HAVE_GDI vpDisplayGDI display; #endif if (opt_display) { display.init(I,100,100,"DirectShow Framegrabber"); } #endif try { double tbegin=0, tend=0, tloop=0, ttotal=0; ttotal = 0; tbegin = vpTime::measureTimeMs(); // Loop for image acquisition and display for (unsigned i = 0; i < nframes; i++) { //Acquires an RGBa image g.acquire(I); #if (defined (VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV)) if (opt_display) { //Displays the grabbed rgba image vpDisplay::display(I); vpDisplay::flush(I); if (vpDisplay::getClick(I, false)) // A click to exit break; } #endif if (save) { char buf[FILENAME_MAX]; sprintf(buf, opath.c_str(), i); std::string filename(buf); std::cout << "Write: " << filename << std::endl; vpImageIo::write(I, filename); } tend = vpTime::measureTimeMs(); tloop = tend - tbegin; tbegin = tend; std::cout << "loop time: " << tloop << " ms" << std::endl; ttotal += tloop; } std::cout << "Mean loop time: " << ttotal / nframes << " ms" << std::endl; std::cout << "Mean frequency: " << 1000./(ttotal / nframes) << " fps" << std::endl; } catch(...) { std::cout << "Failure: exit" << std::endl; return(-1); } } #else int main() { std::cout << "This example requires CMU 1394 Digital Camera SDK. " << std::endl; return 0; } #endif ViSP-2.8.0/example/device/framegrabber/grab1394Two.cpp0000664000175000017500000005765612072022352022517 0ustar fspindlefspindle/**************************************************************************** * * $Id: grab1394Two.cpp 4056 2013-01-05 13:04:42Z fspindle $ * * This file is part of the ViSP software. * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. * * This software is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * ("GPL") version 2 as published by the Free Software Foundation. * See the file LICENSE.txt at the root directory of this source * distribution for additional information about the GNU GPL. * * For using ViSP with software that can not be combined with the GNU * GPL, please contact INRIA about acquiring a ViSP Professional * Edition License. * * See http://www.irisa.fr/lagadic/visp/visp.html for more information. * * This software was developed at: * INRIA Rennes - Bretagne Atlantique * Campus Universitaire de Beaulieu * 35042 Rennes Cedex * France * http://www.irisa.fr/lagadic * * If you have questions regarding the use of this file, please contact * INRIA at visp@inria.fr * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * * Description: * Firewire cameras video capture. * * Authors: * Fabien Spindler * *****************************************************************************/ /*! \file grab1394Two.cpp \brief Example of framegrabbing using vp1394TwoGrabber class. \warning This class needs at least libdc1394-2.0.0-rc4 and libraw1394-1.1.0. These libraries are available from http://sourceforge.net/projects/libdc1394 and http://sourceforge.net/projects/libraw1394 . vp1394TwoGrabber was tested with MF-033C and F-131B Marlin cameras. */ #include #include #include #include #include #include #include #if defined(VISP_HAVE_DC1394_2) #include #include #include #include #include #include #include #include #define GRAB_CxOLOR // List of allowed command line options #define GETOPTARGS "b:c:df:g:hH:L:mn:io:p:rsT:v:W:" #define DUAL_ACQ /*! Print the program options. \param name : Program name. \param badparam : Bad parameter name. \param camera : Active camera identifier. \param nframes : Number of frames to acquire. \param opath : Image filename when saving. \param roi_left, roi_top, roi_width, roi_height : Region of interest in format 7. \param ringbuffersize : Ring buffer size used for capture. \param panControl : Pan control value. */ void usage(const char *name, const char *badparam, unsigned int camera, const unsigned int &nframes, const std::string &opath, const unsigned int &roi_left, const unsigned int &roi_top, const unsigned int &roi_width, const unsigned int &roi_height, const unsigned int &ringbuffersize, const unsigned int &panControl) { if (badparam) fprintf(stderr, "\nERROR: Bad parameter [%s]\n", badparam); fprintf(stderr, "\n\ SYNOPSIS\n\ %s [-v