diff --git a/CMakeHeaderFileList.cmake b/CMakeHeaderFileList.cmake index 25ecc09d48ac17cb43f90da87c93d381da700a62..5c8d63033dddf02883925859eedbc2e871245cee 100644 --- a/CMakeHeaderFileList.cmake +++ b/CMakeHeaderFileList.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeHeaderFileList.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeHeaderFileList.cmake 4617 2014-01-25 10:13:21Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 @@ -71,7 +71,6 @@ SET (HEADER_EXCEPTION ) SET (HEADER_DEVICE_FRAMEGRABBER - device/framegrabber/1394/vp1394Grabber.h device/framegrabber/1394/vp1394TwoGrabber.h device/framegrabber/1394/vp1394CMUGrabber.h device/framegrabber/disk/vpDiskGrabber.h @@ -166,7 +165,6 @@ SET (HEADER_ROBOT robot/real-robot/biclops/vpBiclops.h robot/real-robot/biclops/vpRobotBiclopsController.h robot/real-robot/biclops/vpRobotBiclops.h - robot/real-robot/cycab/vpRobotCycab.h robot/real-robot/pioneer/vpUnicycle.h robot/real-robot/pioneer/vpPioneer.h robot/real-robot/pioneer/vpPioneerPan.h @@ -189,7 +187,6 @@ SET (HEADER_ROBOT ) SET (HEADER_SERVO - servo/vpAdaptativeGain.h servo/vpAdaptiveGain.h servo/vpServoData.h servo/vpServoDisplay.h @@ -265,7 +262,8 @@ SET (HEADER_TRACKING tracking/moving-edges/vpMeNurbs.h tracking/mbt/vpMbTracker.h - tracking/mbt/vpMbHiddenFaces.h + tracking/mbt/vpMbHiddenFaces.h + tracking/mbt/vpMbXmlParser.h tracking/mbt/edge/vpMbtDistanceLine.h tracking/mbt/edge/vpMbtPolygon.h tracking/mbt/edge/vpMbtMeLine.h @@ -273,11 +271,11 @@ SET (HEADER_TRACKING tracking/mbt/edge/vpMbtXmlParser.h tracking/mbt/edge/vpMbtDistanceCylinder.h tracking/mbt/hybrid/vpMbEdgeKltTracker.h + tracking/mbt/hybrid/vpMbtEdgeKltXmlParser.h tracking/mbt/klt/vpMbtKltPolygon.h tracking/mbt/klt/vpMbKltTracker.h tracking/mbt/klt/vpMbtKltXmlParser.h - tracking/moments/vpMomentObject.h tracking/moments/vpMomentAlpha.h tracking/moments/vpMomentBasic.h tracking/moments/vpMomentCentered.h @@ -290,6 +288,26 @@ SET (HEADER_TRACKING tracking/moments/vpMomentObject.h tracking/moments/vpMomentAreaNormalized.h tracking/moments/vpMomentArea.h + + tracking/template-tracker/vpTemplateTracker.h + tracking/template-tracker/ssd/vpTemplateTrackerSSD.h + tracking/template-tracker/ssd/vpTemplateTrackerSSDESM.h + tracking/template-tracker/ssd/vpTemplateTrackerSSDForwardAdditional.h + tracking/template-tracker/ssd/vpTemplateTrackerSSDForwardCompositional.h + tracking/template-tracker/ssd/vpTemplateTrackerSSDInverseCompositional.h + tracking/template-tracker/zncc/vpTemplateTrackerZNCC.h + tracking/template-tracker/zncc/vpTemplateTrackerZNCCForwardAdditional.h + tracking/template-tracker/zncc/vpTemplateTrackerZNCCInverseCompositional.h + tracking/template-tracker/tools/vpTemplateTrackerBSpline.h + tracking/template-tracker/tools/vpTemplateTrackerHeader.h + tracking/template-tracker/tools/vpTemplateTrackerZone.h + tracking/template-tracker/tools/vpTemplateTrackerTriangle.h + tracking/template-tracker/warp/vpTemplateTrackerWarp.h + tracking/template-tracker/warp/vpTemplateTrackerWarpAffine.h + tracking/template-tracker/warp/vpTemplateTrackerWarpHomography.h + tracking/template-tracker/warp/vpTemplateTrackerWarpHomographySL3.h + tracking/template-tracker/warp/vpTemplateTrackerWarpSRT.h + tracking/template-tracker/warp/vpTemplateTrackerWarpTranslation.h ) SET (HEADER_VIDEO @@ -322,26 +340,24 @@ SET (HEADER_VISUAL_FEATURE visual-feature/vpFeatureEllipse.h visual-feature/vpFeatureException.h visual-feature/vpFeatureLine.h + visual-feature/vpFeatureLuminance.h + visual-feature/vpFeatureMoment.h + visual-feature/vpFeatureMomentAlpha.h + visual-feature/vpFeatureMomentArea.h + visual-feature/vpFeatureMomentAreaNormalized.h + visual-feature/vpFeatureMomentBasic.h + visual-feature/vpFeatureMomentCentered.h + visual-feature/vpFeatureMomentCInvariant.h + visual-feature/vpFeatureMomentCommon.h + visual-feature/vpFeatureMomentDatabase.h + visual-feature/vpFeatureMomentGravityCenter.h + visual-feature/vpFeatureMomentGravityCenterNormalized.h visual-feature/vpFeaturePoint3D.h visual-feature/vpFeaturePoint.h visual-feature/vpFeaturePointPolar.h visual-feature/vpFeatureThetaU.h visual-feature/vpFeatureTranslation.h visual-feature/vpFeatureVanishingPoint.h - visual-feature/vpFeatureMoment.h - visual-feature/vpFeatureMomentDatabase.h - visual-feature/vpFeatureMomentCommon.h - visual-feature/vpFeatureMomentAlpha.h - visual-feature/vpFeatureMomentGravityCenter.h - visual-feature/vpFeatureMomentBasic.h - visual-feature/vpFeatureMomentGravityCenterNormalized.h - visual-feature/vpFeatureMomentCentered.h - visual-feature/vpFeatureMomentCInvariant.h - visual-feature/vpFeatureMomentCommon.h - visual-feature/vpFeatureMomentAreaNormalized.h - visual-feature/vpFeatureMomentArea.h - - visual-feature/vpFeatureLuminance.h visual-feature/vpFeatureSegment.h visual-feature/vpGenericFeature.h ) diff --git a/CMakeLists.txt b/CMakeLists.txt index f83aaf5ae2db903a698addb1a61485f2b424b404..9b44006e77cdf7f660539fe4597e9282afff5e4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4340 2013-07-23 20:11:12Z fspindle $ +# $Id: CMakeLists.txt 4678 2014-02-19 09:52:35Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 @@ -40,12 +40,12 @@ PROJECT(VISP C CXX) -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) #----------------------------------------------------------------------------- # VISP version number. An even minor number corresponds to releases. SET(VISP_VERSION_MAJOR "2") -SET(VISP_VERSION_MINOR "8") +SET(VISP_VERSION_MINOR "9") SET(VISP_VERSION_PATCH "0") SET(VISP_VERSION "${VISP_VERSION_MAJOR}.${VISP_VERSION_MINOR}.${VISP_VERSION_PATCH}") # Package revision number @@ -142,6 +142,20 @@ OPTION(BUILD_DEMOS "Build ViSP demos." ON) OPTION(BUILD_TUTORIAL "Build ViSP tutorial." ON) # Build deprecated functions as an option. OPTION(BUILD_DEPRECATED_FUNCTIONS "Build deprecated functionalities." ON) +# Debug and trace cflags +option(ACTIVATE_DEBUG_TRACE "Enable debug and trace printings" ON) + +if(ACTIVATE_DEBUG_TRACE) + list(APPEND VISP_DEFS "-DVP_TRACE") + list(APPEND VISP_DEFS "-DVP_DEBUG") +else() + string(REPLACE "-DVP_TRACE" "" " " VISP_DEFS "${VISP_DEFS}") + string(REPLACE "-DVP_DEBUG" "" " " VISP_DEFS "${VISP_DEFS}") +endif() + +if(MSVC) + option(BUILD_WITH_STATIC_CRT "Enables use of staticaly linked CRT for staticaly linked ViSP" ON) +endif() # Note that it is better to set MOMENTS_COMBINE_MATRICES to OFF OPTION(MOMENTS_COMBINE_MATRICES "Use linear combination of matrices instead of linear combination of moments to compute interaction matrices." OFF) @@ -164,17 +178,12 @@ ENDIF() IF (UNIX) - FIND_PACKAGE(DC1394) - IF(DC1394_2_FOUND) - OPTION(USE_DC1394_2 "Compile ViSP with the libdc1394.2 library" ON) - ELSE(DC1394_2_FOUND) - SET(USE_DC1394_2 OFF) - ENDIF(DC1394_2_FOUND) - IF(DC1394_1_FOUND) - OPTION(USE_DC1394_1 "Compile ViSP with the libdc1394.1 library" ON) - ELSE(DC1394_1_FOUND) - SET(USE_DC1394_1 OFF) - ENDIF(DC1394_1_FOUND) + find_package(DC1394) + if(DC1394_FOUND) + option(USE_DC1394 "Compile ViSP with the libdc1394.2 library" ON) + else() + set(USE_DC1394 OFF) + endif() FIND_PACKAGE(V4L2) IF(V4L2_FOUND) @@ -215,13 +224,6 @@ IF (UNIX) SET(USE_PTU46 OFF) ENDIF(PTU46_FOUND) - FIND_PACKAGE(CycabTk) - IF(CycabTk_FOUND) - OPTION(USE_CYCAB "Compile ViSP for Cycab car-like mobile robot at Irisa" OFF) - ELSE(CycabTk_FOUND) - SET(USE_CYCAB OFF) - ENDIF(CycabTk_FOUND) - ENDIF(UNIX) IF(WIN32) @@ -278,16 +280,15 @@ ELSE(LAPACK_FOUND) SET(USE_LAPACK OFF) ENDIF(LAPACK_FOUND) -IF(NOT USE_LAPACK) - FIND_PACKAGE(GSL) - IF(GSL_FOUND) - OPTION(USE_GSL "Compile ViSP with the GSL library" ON) - ELSE(GSL_FOUND) - SET(USE_GSL OFF) - ENDIF(GSL_FOUND) -ENDIF() +#IF(NOT USE_LAPACK) # line removed since the template tracker needs gsl + find_package(GSL) + if(GSL_FOUND) + option(USE_GSL "Compile ViSP with the GSL library" ON) + else() + set(USE_GSL OFF) + endif() +#ENDIF() -INCLUDE (${CMAKE_ROOT}/Modules/FindOpenGL.cmake) FIND_PACKAGE(OpenGL) FIND_PACKAGE(Coin3D) if (NOT COIN3D_FOUND) @@ -509,8 +510,7 @@ endif() #SET(USE_GTK2 ON) # For Linux/OSX/Windows display with gtk-2.x #SET(USE_DIRECT3D ON) # For Windows display #SET(USE_GDI ON) # For Windows display -#SET(USE_DC1394_1 ON) # For firewire grabber under Linux and OSX ? -#SET(USE_DC1394_2 ON) # For firewire grabber under Linux and OSX ? +#SET(USE_DC1394 ON) # For firewire grabber under Linux and OSX ? #SET(USE_V4L2 ON) # For Video 4 Linux 2 grabber under Linux #SET(USE_DIRECTSHOW ON) # For Windows direct show grabber #SET(USE_LIBJPEG ON) # For reading jpeg files @@ -594,8 +594,9 @@ ENDIF(NAS_FOUND) # Platform dependent #---------------------------------------------------------------------- IF(WIN32 AND NOT CYGWIN) - LIST(APPEND VISP_DEFS "-DWIN32") - LIST(APPEND VISP_DEFS "-DGX") # To support exceptions + if(BUILD_DEPRECATED_FUNCTIONS) + list(APPEND VISP_DEFS "-DWIN32") # only for compat with previous versions + endif() CHECK_LIBRARY_EXISTS("winmm.lib" getch "" HAVE_LIBWINMM) # for timeGetTime() IF(HAVE_LIBWINMM) #MESSAGE("have winmm.lib") @@ -616,26 +617,30 @@ IF(WIN32 AND NOT CYGWIN) if(HAVE_LIBWS2_32) #message("have ws2_32.lib") list(APPEND VISP_EXTERN_LIBRARIES "ws2_32.lib") - endif() + endif() endif() ENDIF(WIN32 AND NOT CYGWIN) -IF(UNIX) - LIST(APPEND VISP_DEFS "-DUNIX") - IF(APPLE) - LIST(APPEND VISP_DEFS "-DAPPLE") - ENDIF(APPLE) -ENDIF(UNIX) +if(UNIX) + if(BUILD_DEPRECATED_FUNCTIONS) + list(APPEND VISP_DEFS "-DUNIX") + if(APPLE) + list(APPEND VISP_DEFS "-DAPPLE") + endif() + if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS") + list(APPEND VISP_DEFS "-DSOLARIS") + endif() + endif() +endif() -IF(UNIX) - INCLUDE(TestBigEndian) +if(UNIX) + include(TestBigEndian) TEST_BIG_ENDIAN(BIGENDIAN) #SET(BIGENDIAN FALSE) -ENDIF() - -IF(BIGENDIAN) - LIST(APPEND VISP_DEFS "-DBIGENDIAN") -ENDIF(BIGENDIAN) + if(BIGENDIAN) + add_definitions("-DBIGENDIAN") + endif() +endif() #-------------------------------------------------------------------- # OpenMP @@ -685,15 +690,32 @@ ENDIF(USE_LAPACK) #-------------------------------------------------------------------- # X11 lib #-------------------------------------------------------------------- -SET(VISP_HAVE_X11_FOUND "no") # for ViSP-third-party.txt -IF(USE_X11) - MESSAGE(STATUS "X11 found") - SET(VISP_HAVE_X11 TRUE) # for header vpConfig.h - SET(VISP_HAVE_X11_FOUND "yes") # for ViSP-third-party.txt - LIST(APPEND VISP_EXTERN_INCLUDE_DIRS ${X11_INCLUDE_DIR}) - LIST(APPEND VISP_EXTERN_LIBRARIES ${X11_LIBRARIES} -lm) +set(VISP_HAVE_X11_FOUND "no") # for ViSP-third-party.txt +if(USE_X11) + message(STATUS "X11 found") + set(VISP_HAVE_X11 TRUE) # for header vpConfig.h + set(VISP_HAVE_X11_FOUND "yes") # for ViSP-third-party.txt + # try to found -lm requested on some platforms to link with X11 + list(APPEND VISP_EXTERN_INCLUDE_DIRS ${X11_INCLUDE_DIR}) + list(APPEND VISP_EXTERN_LIBRARIES ${X11_LIBRARIES}) + find_library(M_LIBRARY NAMES m) + mark_as_advanced(M_LIBRARY) + if(M_LIBRARY) + list(APPEND VISP_EXTERN_LIBRARIES ${M_LIBRARY}) + endif() #MESSAGE("X11: ${X11_LIBRARIES}") -ENDIF(USE_X11) +else() + # try to found -lsocket -lnsl requested for vpNetwork and vpSickLDMRS + find_library(SOCKET_LIBRARY NAMES socket) + find_library(NSL_LIBRARY NAMES nsl) + if (SOCKET_LIBRARY) + list(APPEND VISP_EXTERN_LIBRARIES ${SOCKET_LIBRARY}) + endif() + if (NSL_LIBRARY) + list(APPEND VISP_EXTERN_LIBRARIES ${NSL_LIBRARY}) + endif() + mark_as_advanced(SOCKET_LIBRARY NSL_LIBRARY) +endif() #-------------------------------------------------------------------- @@ -743,7 +765,7 @@ IF(USE_OGRE) if (Boost_FOUND) # Set up referencing of Boost - LIST(APPEND VISP_DEFS "-DBOOST_ALL_NO_LIB") + #LIST(APPEND VISP_DEFS "-DBOOST_ALL_NO_LIB") LIST(APPEND VISP_EXTERN_INCLUDE_DIRS ${Boost_INCLUDE_DIR}) LIST(APPEND VISP_EXTERN_LIBRARIES ${Boost_LIBRARIES}) endif() @@ -772,6 +794,19 @@ IF(USE_OGRE) SET(VISP_HAVE_OGRE_FOUND "yes") # for ViSP-third-party.txt SET(VISP_HAVE_OGRE TRUE) # for header vpConfig.h + # If Ogre media are not available we provide the minimal material to run the examples: + # - resources.cfg + # - plugins.cfg + # - media/materials/... + # - media/models/... + # + # We need to introduce OGRE_MEDIA_NOT_AVAILABLE to memorize when OGRE_MEDIA_DIR is not set. + # Because in that case, OGRE_MEDIA_DIR should be set first to VISP_HAVE_OGRE_RESOURCES_PATH + # (for the "make all" case) then to VISP_INSTALL_DIR_OGRE_RESOURCES (for the "make install" case) + if(NOT OGRE_MEDIA_DIR) + set(OGRE_MEDIA_NOT_AVAILABLE "TRUE") + endif() + # Try to search for an existing plugins.cfg file # Here we cannot use OGRE_PLUGIN_DIR_REL or OGRE_PLUGIN_DIR_DBG where # we may find an existing plugins.cfg file, since under Windows in these @@ -846,17 +881,34 @@ IF(USE_OGRE) NO_SYSTEM_ENVIRONMENT_PATH ) + # Here we copy all the minimal media files + # - media/materials/... + # - media/models/... + if(OGRE_MEDIA_NOT_AVAILABLE) + file(COPY data/ogre-simulator/media DESTINATION ${VISP_BINARY_DIR}/data/ogre-simulator) + endif() + + + # Here we create a resources.cfg if it was not found IF(NOT VISP_HAVE_OGRE_RESOURCES_PATH) # we create a resources.cfg file for vpAROgre.cpp # case 1: normal case + # If OGRE_MEDIA_DIR is not found, we set it to VISP_HAVE_OGRE_RESOURCES_PATH in order to use + # the minimal requested media to run the examples #-------------- SET(VISP_HAVE_OGRE_RESOURCES_PATH ${VISP_BINARY_DIR}/data/ogre-simulator) + if(OGRE_MEDIA_NOT_AVAILABLE) + set(OGRE_MEDIA_DIR ${VISP_HAVE_OGRE_RESOURCES_PATH}/media) + endif() + CONFIGURE_FILE( ${VISP_CMAKE_MODULE_PATH}/resources.cfg.in ${VISP_HAVE_OGRE_RESOURCES_PATH}/resources.cfg IMMEDIATE @ONLY) # case 2: install or packaging case + # If OGRE_MEDIA_DIR is not found, we set it to VISP_INSTALL_DIR_OGRE_RESOURCES in order to use + # the minimal requested media to run the examples #-------------- IF(UNIX) set(VISP_INSTALL_DIR_OGRE_RESOURCES "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/visp/data/ogre-simulator") @@ -864,23 +916,47 @@ IF(USE_OGRE) set(VISP_INSTALL_DIR_OGRE_RESOURCES "${CMAKE_INSTALL_PREFIX}/data/ogre-simulator") ENDIF() - # install rule for resources.cfg: - IF(UNIX) - INSTALL(FILES - ${VISP_HAVE_OGRE_RESOURCES_PATH}/resources.cfg + if(OGRE_MEDIA_NOT_AVAILABLE) + set(OGRE_MEDIA_DIR ${VISP_INSTALL_DIR_OGRE_RESOURCES}/media) + endif() + CONFIGURE_FILE( + ${VISP_CMAKE_MODULE_PATH}/resources.cfg.in + ${VISP_BINARY_DIR}/install/resources.cfg + IMMEDIATE @ONLY) + + # install rule for resources.cfg and Ogre media if they are not available: + if(UNIX) + install(FILES + ${VISP_BINARY_DIR}/install/resources.cfg DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/visp/data/ogre-simulator PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE COMPONENT libraries ) - ELSE() - INSTALL(FILES - ${VISP_HAVE_OGRE_RESOURCES_PATH}/resources.cfg + if(OGRE_MEDIA_NOT_AVAILABLE) + install(DIRECTORY + data/ogre-simulator/media + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/visp/data/ogre-simulator + FILE_PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE + COMPONENT libraries + ) + endif() + else() + install(FILES + ${VISP_BINARY_DIR}/install/resources.cfg DESTINATION data/ogre-simulator PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE COMPONENT libraries ) - ENDIF() - ENDIF() + if(OGRE_MEDIA_NOT_AVAILABLE) + install(DIRECTORY + data/ogre-simulator/media + DESTINATION data/ogre-simulator + FILE_PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE + COMPONENT libraries + ) + endif() + endif() + endif() MARK_AS_ADVANCED(VISP_HAVE_OGRE_PLUGINS_PATH) MARK_AS_ADVANCED(VISP_HAVE_OGRE_RESOURCES_PATH) @@ -914,9 +990,15 @@ IF(USE_COIN) IF(WIN32) LIST(APPEND VISP_DEFS "-DCOIN_DLL") ENDIF(WIN32) - LIST(APPEND VISP_EXTERN_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR}) - LIST(APPEND VISP_EXTERN_INCLUDE_DIRS ${COIN3D_INCLUDE_DIRS}) - LIST(APPEND VISP_EXTERN_LIBRARIES ${OPENGL_LIBRARIES}) + LIST(APPEND VISP_EXTERN_INCLUDE_DIRS ${COIN3D_INCLUDE_DIRS}) + # On OSX cmake 2.8 found OpenGL but OPENGL_INCLUDE_DIR was set to NOT_FOUND + # We add a test to be sure that the OPENGL vars exist. + if(OPENGL_INCLUDE_DIR) + list(APPEND VISP_EXTERN_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR}) + endif() + if(OPENGL_LIBRARIES) + list(APPEND VISP_EXTERN_LIBRARIES ${OPENGL_LIBRARIES}) + endif() #MESSAGE("COIN3D_INCLUDE_DIRS = ${COIN3D_INCLUDE_DIRS}") #MESSAGE("COIN3D_LIBRARIES = ${COIN3D_LIBRARIES}") @@ -1073,6 +1155,7 @@ IF(USE_LIBUSB_1) MESSAGE(STATUS "libusb-1.0 found") + LIST(APPEND VISP_EXTERN_INCLUDE_DIRS ${LIBUSB_1_INCLUDE_DIRS}) LIST(APPEND VISP_EXTERN_LIBRARIES ${LIBUSB_1_LIBRARIES}) ELSE() MESSAGE(STATUS "libusb-1.0 not found") @@ -1089,7 +1172,7 @@ IF(USE_LIBFREENECT AND USE_LIBUSB_1 AND USE_PTHREAD) # The material is found. Check if libfreenect is an old version include(CheckCXXSourceCompiles) SET(CMAKE_REQUIRED_LIBRARIES ${LIBFREENECT_LIBRARIES} ${PTHREAD_LIBRARIES} ${LIBUSB_1_LIBRARIES}) - SET(CMAKE_REQUIRED_INCLUDES ${LIBFREENECT_INCLUDE_DIRS} ${PTHREAD_INCLUDE_DIRS}) + SET(CMAKE_REQUIRED_INCLUDES ${LIBFREENECT_INCLUDE_DIRS} ${PTHREAD_INCLUDE_DIRS} ${LIBUSB_1_INCLUDE_DIRS}) CHECK_CXX_SOURCE_COMPILES(" #include <libfreenect.hpp> @@ -1168,21 +1251,100 @@ IF(USE_OPENCV) ENDIF(VISP_BUILD_SHARED_LIBS AND VISP_USE_MSVC) SET(VISP_HAVE_OPENCV TRUE) # for header vpConfig.h SET(VISP_HAVE_OPENCV_FOUND "yes") # for ViSP-third-party.txt - + # On win32 since OpenCV 2.4.7 we cannot use OpenCV_LIBS to set ViSP 3rd party libraries. + # Using OpenCV_LIBS works to build visp library, examples, demos and test thanks to the components, + # but not tutorials that are stand alone Cmake project that use ViSP as a 3rd party. + # To be clear OpenCV_LIBS contains opencv_core and not c:\...\opencv_core248.lib full path as requested + # to use ViSP. This was not the case with OpenCV 2.4.6. + # For the build of ViSP it works with OpenCV_LIBS: in that case thanks to opencv_core properties, CMake + # is able to find the real name and location of the libraries. + # But when ViSP is used as a 3rd party where it should import OpenCV libraries, it doesn't work with + # OpenCV_LIBS. + # The solution here is to get the real name of OpenCV libraries thanks to the properties and link + # with these names. + # An other way could be to include OpenCVConfig.cmake, but in that case, visp-config and visp.pc + # will be not able to give the names of OpenCV libraries when used without CMake. + #message("OpenCV_LIB_COMPONENTS: ${OpenCV_LIB_COMPONENTS}") + #message("OpenCV_LIBS: ${OpenCV_LIBS}") + if(WIN32 AND OpenCV_LIB_COMPONENTS AND OpenCV_VERSION AND OpenCV_VERSION VERSION_GREATER 2.4.6) + foreach(component_ ${OpenCV_LIB_COMPONENTS}) + #message("component: ${component_}") + if(VISP_BUILD_SHARED_LIBS) + get_target_property(component_property_opt_ ${component_} IMPORTED_IMPLIB_RELEASE) + get_target_property(component_property_dbg_ ${component_} IMPORTED_IMPLIB_DEBUG) + # particular case of opencv_ts that doesn't have an optimized implib + if(NOT component_property_opt_) + get_target_property(component_property_opt_ ${component_} IMPORTED_LOCATION_RELEASE) + endif() + # particular case of opencv_ts that doesn't have a debug implib + if(NOT component_property_dbg_) + get_target_property(component_property_dbg_ ${component_} IMPORTED_LOCATION_DEBUG) + endif() + else() + get_target_property(component_property_opt_ ${component_} IMPORTED_LOCATION_RELEASE) + get_target_property(component_property_dbg_ ${component_} IMPORTED_LOCATION_DEBUG) + endif() + get_target_property(component_property_3rdparty_opt_ ${component_} IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE) + get_target_property(component_property_3rdparty_dbg_ ${component_} IMPORTED_LINK_INTERFACE_LIBRARIES_DEBUG) + #message("component_property_opt_: ${component_property_opt_}") + #message("component_property_dbg_: ${component_property_dbg_}") + #message("component_property_3rdparty_opt_: ${component_property_3rdparty_opt_}") + #message("component_property_3rdparty_dbg_: ${component_property_3rdparty_dbg_}") + if(component_property_opt_) + list(APPEND VISP_EXTERN_LIBRARIES optimized ${component_property_opt_}) + endif() + if(component_property_dbg_) + list(APPEND VISP_EXTERN_LIBRARIES debug ${component_property_dbg_}) + endif() + #if(NOT component_property_opt_ AND NOT component_property_dbg_) + # message("No implib for component ${component_}") + #endif() + foreach(3rdparty_opt_ ${component_property_3rdparty_opt_}) + list(FIND OpenCV_LIB_COMPONENTS ${3rdparty_opt_} 3rdparty_is_opencv_component_) + if(3rdparty_is_opencv_component_ LESS 0) + #message("${3rdparty_opt_} is not an opencv component") + get_target_property(3rdparty_opt_location_ ${3rdparty_opt_} IMPORTED_LOCATION_RELEASE) + #message("3rdparty_opt_: ${3rdparty_opt_} location: ${3rdparty_opt_location_}") + if(3rdparty_opt_location_) + list(APPEND VISP_EXTERN_LIBRARIES optimized ${3rdparty_opt_location_}) + else() + list(APPEND VISP_EXTERN_LIBRARIES ${3rdparty_opt_}) # should be a system dependency + endif() + endif() + endforeach() + foreach(3rdparty_dbg_ ${component_property_3rdparty_dbg_}) + list(FIND OpenCV_LIB_COMPONENTS ${3rdparty_dbg_} 3rdparty_is_opencv_component_) + if(3rdparty_is_opencv_component_ LESS 0) + get_target_property(3rdparty_dbg_location_ ${3rdparty_dbg_} IMPORTED_LOCATION_DEBUG) + #message("3rdparty_dbg_: ${3rdparty_dbg_} location: ${3rdparty_dbg_location_}") + if(3rdparty_dbg_location_) + list(APPEND VISP_EXTERN_LIBRARIES debug ${3rdparty_dbg_location_}) + else() + list(APPEND VISP_EXTERN_LIBRARIES ${3rdparty_dbg_}) # should be a system dependency + endif() + endif() + endforeach() + endforeach() + else() + # this should be an old OpenCV version that doesn't have the previous behavior + list(APPEND VISP_EXTERN_LIBRARIES ${OpenCV_LIBS}) + endif() LIST(APPEND VISP_EXTERN_INCLUDE_DIRS ${OpenCV_INCLUDE_DIRS}) LIST(APPEND VISP_EXTERN_LINK_DIR ${OpenCV_LIB_DIR}) - LIST(APPEND VISP_EXTERN_LIBRARIES ${OpenCV_LIBS}) + #LIST(APPEND VISP_EXTERN_LIBRARIES ${OpenCV_LIBS}) #MESSAGE("OpenCV_INCLUDE_DIRS = ${OpenCV_INCLUDE_DIRS}") #MESSAGE("OpenCV_LIBS = ${OpenCV_LIBS}") #MESSAGE("OpenCV_LIB_DIR = ${OpenCV_LIB_DIR}") SET(VISP_HAVE_OPENCV_VERSION "(${OpenCV_VERSION_MAJOR}*65536 + ${OpenCV_VERSION_MINOR}*256 + ${OpenCV_VERSION_PATCH})") # for ViSP-third-party.txt #MESSAGE("VISP_HAVE_OPENCV_VERSION = ${VISP_HAVE_OPENCV_VERSION}") + #MESSAGE("VISP_EXTERN_LIBRARIES = ${VISP_EXTERN_LIBRARIES}") # additional check to see if opencv_nonfree module introduced in OpenCV 2.4 is available #message("OpenCV_VERSION = ${OpenCV_VERSION}") #message("OpenCV_NONFREE_FOUND: ${OPENCV_NONFREE_FOUND}") - if(${OpenCV_VERSION}) - if(${OpenCV_VERSION} VERSION_LESS "2.4.2") + if(OpenCV_VERSION) + if(OpenCV_VERSION VERSION_LESS "2.4.2") + message(STATUS "OpenCV nonfree found") set(VISP_HAVE_OPENCV_NONFREE TRUE) # for header vpConfig.h else() # Version is greater or equal to 2.4.0 if(OPENCV_NONFREE_FOUND) @@ -1193,6 +1355,7 @@ IF(USE_OPENCV) endif() endif() else() + message("OpenCV_VERSION is false") message(STATUS "OpenCV nonfree not found") endif() ELSE(OpenCV_FOUND) @@ -1372,63 +1535,43 @@ ENDIF(USE_FFMPEG) # Specific hardware : framegrabbers and cameras #---------------------------------------------------------------------- # default initialisation -SET(VISP_HAVE_DC1394_1_FOUND "no") # for ViSP-third-party.txt SET(VISP_HAVE_DC1394_2_FOUND "no") # for ViSP-third-party.txt SET(VISP_HAVE_V4L2_FOUND "no") # for ViSP-third-party.txt SET(VISP_HAVE_DIRECTSHOW_FOUND "no") # for ViSP-third-party.txt # library for firewire cameras -IF(USE_DC1394_1 OR USE_DC1394_2) +IF(USE_DC1394) #FIND_PACKAGE(DC1394) - IF(DC1394_FOUND) - SET(VISP_HAVE_DC1394 TRUE) # for header vpConfig.h - IF(DC1394_2_FOUND AND USE_DC1394_2) - MESSAGE(STATUS "libdc1394-2.x found") - SET(VISP_HAVE_DC1394_2 TRUE) # for header vpConfig.h - SET(VISP_HAVE_DC1394_2_FOUND "yes") # for ViSP-third-party.txt - IF(DC1394_CAMERA_ENUMERATE_FOUND) - SET(VISP_HAVE_DC1394_2_CAMERA_ENUMERATE TRUE) # for header vpConfig.h - ENDIF(DC1394_CAMERA_ENUMERATE_FOUND) - IF(DC1394_FIND_CAMERAS_FOUND) - SET(VISP_HAVE_DC1394_2_FIND_CAMERAS TRUE) # for header vpConfig.h - ENDIF(DC1394_FIND_CAMERAS_FOUND) - LIST(APPEND VISP_EXTERN_INCLUDE_DIRS ${DC1394_2_INCLUDE_DIRS}) - LIST(APPEND VISP_EXTERN_LIBRARIES ${DC1394_2_LIBRARY}) - - #MESSAGE("DBG VISP_HAVE_DC1394_2= ${VISP_HAVE_DC1394_2}") - ELSE(DC1394_2_FOUND AND USE_DC1394_2) - MESSAGE(STATUS "libdc1394-2.x not found") - SET(VISP_HAVE_DC1394_2_FOUND "no") # for ViSP-third-party.txt - ENDIF(DC1394_2_FOUND AND USE_DC1394_2) - - IF(DC1394_1_FOUND AND USE_DC1394_1) - MESSAGE(STATUS "libdc1394-1.x found") - SET(VISP_HAVE_DC1394_1 TRUE) # for header vpConfig.h - SET(VISP_HAVE_DC1394_1_FOUND "yes") # for ViSP-third-party.txt - #MESSAGE("DBG VISP_HAVE_DC1394_1= ${VISP_HAVE_DC1394_1}") - LIST(APPEND VISP_EXTERN_INCLUDE_DIRS ${DC1394_1_INCLUDE_DIRS}) - LIST(APPEND VISP_EXTERN_LIBRARIES ${DC1394_1_LIBRARY}) - ELSE(DC1394_1_FOUND AND USE_DC1394_1) - MESSAGE(STATUS "libdc1394-1.x not found") - SET(VISP_HAVE_DC1394_1_FOUND "no") # for ViSP-third-party.txt - ENDIF(DC1394_1_FOUND AND USE_DC1394_1) + if(DC1394_FOUND) + set(VISP_HAVE_DC1394 TRUE) # for header vpConfig.h + + MESSAGE(STATUS "libdc1394-2.x found") + SET(VISP_HAVE_DC1394_2 TRUE) # for header vpConfig.h + SET(VISP_HAVE_DC1394_2_FOUND "yes") # for ViSP-third-party.txt + IF(DC1394_CAMERA_ENUMERATE_FOUND) + SET(VISP_HAVE_DC1394_2_CAMERA_ENUMERATE TRUE) # for header vpConfig.h + ENDIF(DC1394_CAMERA_ENUMERATE_FOUND) + IF(DC1394_FIND_CAMERAS_FOUND) + SET(VISP_HAVE_DC1394_2_FIND_CAMERAS TRUE) # for header vpConfig.h + ENDIF(DC1394_FIND_CAMERAS_FOUND) + LIST(APPEND VISP_EXTERN_INCLUDE_DIRS ${DC1394_INCLUDE_DIRS}) + LIST(APPEND VISP_EXTERN_LIBRARIES ${DC1394_LIBRARY}) + + #MESSAGE("DBG VISP_HAVE_DC1394_2= ${VISP_HAVE_DC1394_2}") #MESSAGE("DBG DC1394_INCLUDE_DIRS=${DC1394_INCLUDE_DIRS}") - IF(APPLE) #SET(VISP_EXTERN_LIBRARIES ${VISP_EXTERN_LIBRARIES} IOkit "-framework Carbon") LIST(APPEND VISP_EXTERN_LIBRARIES "-framework IOkit -framework Carbon") ENDIF(APPLE) - #MESSAGE("DC1394_LIBRARIES = ${DC1394_LIBRARIES}") + #MESSAGE("DC1394_LIBRARIES = ${DC1394_LIBRARIES}") ELSE(DC1394_FOUND) - MESSAGE(STATUS "libdc1394-1.x not found") MESSAGE(STATUS "libdc1394-2.x not found") - SET(VISP_HAVE_DC1394_1_FOUND "no") # for ViSP-third-party.txt SET(VISP_HAVE_DC1394_2_FOUND "no") # for ViSP-third-party.txt #MESSAGE("Firewire dc1394 requested but not found. Turn off USE_DC1394!") # SET(USE_DC1394 OFF) ENDIF(DC1394_FOUND) -ENDIF(USE_DC1394_1 OR USE_DC1394_2) +ENDIF(USE_DC1394) # library for CMU1394 pan-tilt head IF(USE_CMU1394) @@ -1604,7 +1747,6 @@ SET(VISP_HAVE_PTU46_FOUND "no") # for ViSP-third-party.txt SET(VISP_HAVE_PIONEER_FOUND "no") # for ViSP-third-party.txt SET(VISP_HAVE_VIPER650_FOUND "no") # for ViSP-third-party.txt SET(VISP_HAVE_VIPER850_FOUND "no") # for ViSP-third-party.txt -SET(VISP_HAVE_CYCAB_FOUND "no") # for ViSP-third-party.txt # library for Irisa's Afma4 cylindrical robot IF(USE_AFMA4) @@ -1766,26 +1908,6 @@ IF(USE_PTU46) ENDIF(PTU46_FOUND) ENDIF(USE_PTU46) -# library for Cycab car-like mobile robot -IF(USE_CYCAB) - IF(CycabTk_FOUND) - IF(CycabTk_NEW_FOUND) - SET(VISP_HAVE_CYCABTK TRUE) # for header vpConfig.h - ENDIF(CycabTk_NEW_FOUND) - IF(CycabTk_OLD_FOUND) - SET(VISP_HAVE_CYCABTK_OLD TRUE) # for header vpConfig.h - ENDIF(CycabTk_OLD_FOUND) - SET(VISP_HAVE_CYCAB TRUE) # for header vpConfig.h - SET(VISP_HAVE_CYCAB_FOUND "yes") # for ViSP-third-party.txt - LIST(APPEND VISP_EXTERN_INCLUDE_DIRS ${CycabTk_INCLUDE_DIRS}) - LIST(APPEND VISP_EXTERN_LIBRARIES ${CycabTk_LIBRARIES}) - ELSE(CycabTk_FOUND) - MESSAGE(STATUS "Cycab interface not found") - MESSAGE("Cycab requested but not found. Turn off USE_CYCAB option!") - SET(VISP_HAVE_CYCAB_FOUND "no") # for ViSP-third-party.txt - ENDIF(CycabTk_FOUND) -ENDIF(USE_CYCAB) - # libraries for Pioneer mobile robots if(USE_ARIA) if(UNIX) @@ -1865,8 +1987,7 @@ ENDIF(DOXYGEN_FOUND) # warnings. To suppress it, we add the _CRT_SECURE_NO_DEPRECATE preprocessor # definition if(WIN32 AND MSVC) - #MESSAGE("Add -D_CRT_SECURE_NO_DEPRECATE ") - list(APPEND VISP_DEFS "-D_CRT_SECURE_NO_DEPRECATE") + add_definitions("-D_CRT_SECURE_NO_DEPRECATE") endif() #MESSAGE("Definitions: ${VISP_DEFS}") @@ -1874,7 +1995,7 @@ IF(VISP_DEFS) LIST(REMOVE_DUPLICATES VISP_DEFS) ENDIF(VISP_DEFS) #MESSAGE("Definitions without duplicates: ${VISP_DEFS}") -ADD_DEFINITIONS(${VISP_DEFS}) +add_definitions(${VISP_DEFS}) #---------------------------------------------------------------------- # Add intern and third party include dirs @@ -1896,6 +2017,14 @@ ENDIF(VISP_EXTERN_LINK_DIR) #MESSAGE("VISP_EXTERN_LINK_DIR without duplicates: ${VISP_EXTERN_LINK_DIR}") LINK_DIRECTORIES(${VISP_EXTERN_LINK_DIR}) +#---------------------------------------------------------------------- +# Use statically or dynamically linked CRT? +# Default: dynamic +#---------------------------------------------------------------------- +if(MSVC) + include(${VISP_CMAKE_MODULE_PATH}/VISPCRTLinkage.cmake) +endif(MSVC) + #---------------------------------------------------------------------- # Cleanify the libraries list #---------------------------------------------------------------------- @@ -1903,14 +2032,6 @@ IF(APPLE) LIST(REMOVE_DUPLICATES VISP_EXTERN_LIBRARIES) ENDIF() -#---------------------------------------------------------------------- -# Generate the package dependent visp-config shell script for projects which -# are not using CMake: -# Usage: -# visp-config --cflags ... -#---------------------------------------------------------------------- -INCLUDE(${VISP_CMAKE_MODULE_PATH}/GenerateConfigScript.cmake) - #---------------------------------------------------------------------- # add distclean target #---------------------------------------------------------------------- @@ -1943,29 +2064,13 @@ ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") #---------------------------------------------------------------------- -# Configure the file describing how to use ViSP. VISPConfig.cmake -# is the main file configuring a CMake package. -# . Exports build settings and dependencies for projects using ViSP as a -# third party project. -# . Create and install files for simple use of FIND_PACKAGE(VISP) -# by other cmakified "user" projects and libraries depending on ViSP. -# (see "Mastering CMake", pp.72) -# . To use ViSP in a third party project based on CMake: -# FIND_PACKAGE(VISP REQUIRED) -# IF(VISP_FOUND) -# INCLUDE(${VISP_USE_FILE}) -# ENDIF(VISP_FOUND) +# Configure the files that depend on the build <binary dir> or +# installation <install dir> usage. This is the case of: +# vpConfig.h #---------------------------------------------------------------------- -# Installation for ViSPConfig.cmake -# case 1: <binary dir>/ViSPConfig.cmake for use with make -# case 2: <install dir>/ViSPConfig.cmake for use with make install - -# case 1 +# case 1: when ViSP is build with make; files are used in <binary dir> #-------------- - -set(VISP_ROOT_DIR_CONFIGCMAKE "${VISP_BINARY_DIR}") -set(VISP_ROOT_DIR_CMAKE_CONFIGCMAKE "${VISP_BINARY_DIR}") set(VISP_ROOT_DIR_DATA_CONFIGCMAKE "${VISP_BINARY_DIR}") SET(VISP_SCENES_DIR ${VISP_ROOT_DIR_DATA_CONFIGCMAKE}/data/wireframe-simulator) @@ -1976,32 +2081,11 @@ CONFIGURE_FILE(${VISP_SOURCE_DIR}/include/vpConfig.h.cmake ${VISP_INCLUDE_DIR}/vpConfig.h ) -CONFIGURE_FILE( - ${VISP_CMAKE_MODULE_PATH}/VISPConfig.cmake.in - ${VISP_BINARY_DIR}/VISPConfig.cmake - IMMEDIATE @ONLY) - -# Just to copy ./CMakeModule/VISPUse.cmake.in <binary dir>/UseVISP.cmake -CONFIGURE_FILE( - ${VISP_CMAKE_MODULE_PATH}/VISPUse.cmake.in - ${VISP_BINARY_DIR}/VISPUse.cmake - IMMEDIATE @ONLY) - -# Generate the package dependent file include/visp/vpConfig.h -CONFIGURE_FILE(${VISP_SOURCE_DIR}/ViSP-third-party.txt.cmake - ${VISP_BINARY_DIR}/ViSP-third-party.txt -) - - -# case 2 +# case 2: when ViSP is build with make install; files are used in <install dir> #-------------- - -set(VISP_ROOT_DIR_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}") IF(UNIX) - set(VISP_ROOT_DIR_CMAKE_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/visp") set(VISP_ROOT_DIR_DATA_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/visp") ELSE() - set(VISP_ROOT_DIR_CMAKE_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}") set(VISP_ROOT_DIR_DATA_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}") ENDIF() @@ -2021,24 +2105,6 @@ CONFIGURE_FILE(${VISP_SOURCE_DIR}/include/vpConfig.h.cmake ${VISP_BINARY_DIR}/install/vpConfig.h ) -CONFIGURE_FILE( - ${VISP_CMAKE_MODULE_PATH}/VISPConfig.cmake.in - ${VISP_BINARY_DIR}/install/VISPConfig.cmake - IMMEDIATE @ONLY) - -# Just to copy ./CMakeModule/VISPUse.cmake.in in <install dir>/UseVISP.cmake -CONFIGURE_FILE( - ${VISP_CMAKE_MODULE_PATH}/VISPUse.cmake.in - ${VISP_BINARY_DIR}/install/VISPUse.cmake - IMMEDIATE @ONLY) - -# Export our build settings and library dependencies for use by the third party -# user projects -INCLUDE(${CMAKE_ROOT}/Modules/CMakeExportBuildSettings.cmake) -CMAKE_EXPORT_BUILD_SETTINGS( - ${VISP_BINARY_DIR}/install/VISPBuildSettings.cmake - ) - # Install vpConfig.h that may differ from the one in include/visp INSTALL(FILES ${VISP_BINARY_DIR}/install/vpConfig.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/visp @@ -2046,7 +2112,16 @@ INSTALL(FILES ${VISP_BINARY_DIR}/install/vpConfig.h COMPONENT headers ) +#---------------------------------------------------------------------- +# Generate the ViSP-third-party.txt information file +#---------------------------------------------------------------------- +CONFIGURE_FILE(${VISP_SOURCE_DIR}/ViSP-third-party.txt.cmake + ${VISP_BINARY_DIR}/ViSP-third-party.txt +) + +#---------------------------------------------------------------------- # Create and install visp-config.1.gz man page +#---------------------------------------------------------------------- if(UNIX) FIND_PROGRAM(GZIP gzip) file(MAKE_DIRECTORY ${VISP_BINARY_DIR}/doc/man/man1) @@ -2075,7 +2150,6 @@ IF(UNIX) INSTALL(FILES ${VISP_BINARY_DIR}/install/VISPUse.cmake ${VISP_BINARY_DIR}/install/VISPConfig.cmake - ${VISP_BINARY_DIR}/install/VISPBuildSettings.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/visp PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE COMPONENT libraries @@ -2100,7 +2174,6 @@ ELSE() INSTALL(FILES ${VISP_BINARY_DIR}/install/VISPUse.cmake ${VISP_BINARY_DIR}/install/VISPConfig.cmake - ${VISP_BINARY_DIR}/install/VISPBuildSettings.cmake DESTINATION . PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE COMPONENT libraries @@ -2146,26 +2219,99 @@ if (BUILD_PACKAGE) include (${VISP_SOURCE_DIR}/CMakeModules/CPackConfig.cmake) endif(BUILD_PACKAGE) +#---------------------------------------------------------------------- +# Propagation in src to build the library +#---------------------------------------------------------------------- +add_subdirectory(src) + +#---------------------------------------------------------------------- +# Configure the file describing how to use ViSP. VISPConfig.cmake +# is the main file configuring a CMake package. +# . Exports build settings and dependencies for projects using ViSP as a +# third party project. +# . Create and install files for simple use of FIND_PACKAGE(VISP) +# by other cmakified "user" projects and libraries depending on ViSP. +# (see "Mastering CMake", pp.72) +# . To use ViSP in a third party project based on CMake: +# FIND_PACKAGE(VISP REQUIRED) +# IF(VISP_FOUND) +# INCLUDE(${VISP_USE_FILE}) +# ENDIF(VISP_FOUND) +#---------------------------------------------------------------------- + +# Installation for ViSPConfig.cmake and VISPUse.cmake +# case 1: <binary dir>/ViSPConfig.cmake for use with make +# case 2: <install dir>/ViSPConfig.cmake for use with make install + +get_target_property(VISP_LIBNAME_DBG ${VISP_INTERN_LIBRARY} LOCATION_Debug) +get_target_property(VISP_LIBNAME_OPT ${VISP_INTERN_LIBRARY} LOCATION_Release) + +get_filename_component(VISP_LIBNAME_DBG "${VISP_LIBNAME_DBG}" NAME) +get_filename_component(VISP_LIBNAME_OPT "${VISP_LIBNAME_OPT}" NAME) + +#message("VISP_LIBNAME_DBG: ${VISP_LIBNAME_DBG}") +#message("VISP_LIBNAME_OPT: ${VISP_LIBNAME_OPT}") + +# case 1 +#-------------- +set(VISP_ROOT_DIR_CONFIGCMAKE "${VISP_BINARY_DIR}") +set(VISP_ROOT_DIR_CMAKE_CONFIGCMAKE "${VISP_BINARY_DIR}") +CONFIGURE_FILE( + ${VISP_CMAKE_MODULE_PATH}/VISPConfig.cmake.in + ${VISP_BINARY_DIR}/VISPConfig.cmake + IMMEDIATE @ONLY) + +# Just to copy ./CMakeModule/VISPUse.cmake.in <binary dir>/UseVISP.cmake +CONFIGURE_FILE( + ${VISP_CMAKE_MODULE_PATH}/VISPUse.cmake.in + ${VISP_BINARY_DIR}/VISPUse.cmake + IMMEDIATE @ONLY) + +# case 2 +#-------------- +set(VISP_ROOT_DIR_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}") +if(UNIX) + set(VISP_ROOT_DIR_CMAKE_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/visp") +else() + set(VISP_ROOT_DIR_CMAKE_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}") +endif() +CONFIGURE_FILE( + ${VISP_CMAKE_MODULE_PATH}/VISPConfig.cmake.in + ${VISP_BINARY_DIR}/install/VISPConfig.cmake + IMMEDIATE @ONLY) + +# Just to copy ./CMakeModule/VISPUse.cmake.in in <install dir>/UseVISP.cmake +CONFIGURE_FILE( + ${VISP_CMAKE_MODULE_PATH}/VISPUse.cmake.in + ${VISP_BINARY_DIR}/install/VISPUse.cmake + IMMEDIATE @ONLY) + +#---------------------------------------------------------------------- +# Generate the package dependent visp-config shell script for projects which +# are not using CMake: +# Usage: +# visp-config --cflags ... +#---------------------------------------------------------------------- +INCLUDE(${VISP_CMAKE_MODULE_PATH}/GenerateConfigScript.cmake) #---------------------------------------------------------------------- -# Propagation in sub dirs +# Propagation in sub dirs to build demo, example, test, tutorial #---------------------------------------------------------------------- -SUBDIRS(src) if(BUILD_DEMOS) - subdirs(demo) + add_subdirectory(demo) endif() if(BUILD_EXAMPLES) - subdirs(example) + add_subdirectory(example) endif() if(BUILD_TUTORIAL) set(VISP_DIR ${PROJECT_BINARY_DIR}) mark_as_advanced(VISP_DIR) mark_as_advanced(VISP_INCLUDE_DIRS) mark_as_advanced(VISP_LIBRARY_DIRS) - subdirs(tutorial) + add_subdirectory(tutorial) endif() -IF(BUILD_TESTING) +if(BUILD_TESTING) # # Test coverage specific code # @@ -2184,5 +2330,5 @@ IF(BUILD_TESTING) SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ftest-coverage -fprofile-arcs") ENDIF(BUILD_TEST_COVERAGE) - SUBDIRS(test) -ENDIF(BUILD_TESTING) + add_subdirectory(test) +endif(BUILD_TESTING) diff --git a/CMakeModules/AddExtraCompilationFlags.cmake b/CMakeModules/AddExtraCompilationFlags.cmake index f496f28c3f68dc439443479fdad658fcad7f6971..c75a69408173780fd15d3e62fb877e443609da69 100644 --- a/CMakeModules/AddExtraCompilationFlags.cmake +++ b/CMakeModules/AddExtraCompilationFlags.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: AddExtraCompilationFlags.cmake 4308 2013-07-08 08:47:09Z fspindle $ +# $Id: AddExtraCompilationFlags.cmake 4608 2014-01-21 16:37:58Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 @@ -146,6 +146,12 @@ MACRO(ADD_EXTRA_COMPILATION_FLAGS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") endif() + if(UNIX) + if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") + endif() + endif() + # Remove duplicates compilation flags separate_arguments(CMAKE_CXX_FLAGS) list(REMOVE_DUPLICATES CMAKE_CXX_FLAGS) diff --git a/CMakeModules/CPackConfig.cmake b/CMakeModules/CPackConfig.cmake index 85cf0c3e8648a4ee6dcd8b7f16fce892879fb7c9..cb4e00d1deed8cff98279d0bc9eb4762665f0231 100644 --- a/CMakeModules/CPackConfig.cmake +++ b/CMakeModules/CPackConfig.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CPackConfig.cmake 4335 2013-07-23 09:53:54Z fspindle $ +# $Id: CPackConfig.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/CPackConfigDeb.cmake b/CMakeModules/CPackConfigDeb.cmake index 729f71131bc736373cf59ff48c6de093ad85f9b0..b7aaa40063454bc10bd432cc10adbb0e9142b484 100644 --- a/CMakeModules/CPackConfigDeb.cmake +++ b/CMakeModules/CPackConfigDeb.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CPackConfigDeb.cmake 4132 2013-02-11 21:04:12Z fspindle $ +# $Id: CPackConfigDeb.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/CPackConfigNsis.cmake b/CMakeModules/CPackConfigNsis.cmake index dfd71e2fc7bdf7d99066d23475f5e7e842df0b1a..9ccb97cd6b280c26f3cc39d3e63bb9154b6c3350 100644 --- a/CMakeModules/CPackConfigNsis.cmake +++ b/CMakeModules/CPackConfigNsis.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CPackConfigNsis.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CPackConfigNsis.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/CPackConfigRpm.cmake b/CMakeModules/CPackConfigRpm.cmake index ca677cde6c604e863bff15800c6efef94292b269..92d7617064f346e5e489c50969ce26835b61af82 100644 --- a/CMakeModules/CPackConfigRpm.cmake +++ b/CMakeModules/CPackConfigRpm.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CPackConfigRpm.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CPackConfigRpm.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindARIA.cmake b/CMakeModules/FindARIA.cmake index 3de03f214f84dae658ca5a99053bd738994e0099..e3c32aa108f28f23e944c71f2e26bda6709c1bbe 100644 --- a/CMakeModules/FindARIA.cmake +++ b/CMakeModules/FindARIA.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindARIA.cmake 4288 2013-06-27 11:56:18Z fspindle $ +# $Id: FindARIA.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindBICLOPS.cmake b/CMakeModules/FindBICLOPS.cmake index 754b4827335521b0373c6a39f08e6756e430df52..c5fa981f26d2d7461835cdeb29552b772a64e671 100644 --- a/CMakeModules/FindBICLOPS.cmake +++ b/CMakeModules/FindBICLOPS.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindBICLOPS.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindBICLOPS.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindCALINUX.cmake b/CMakeModules/FindCALINUX.cmake index 617dcfbdafde4ffeef27ff791f3975fc93586bc1..19d58d05da42defb08c076b6511932209a309246 100644 --- a/CMakeModules/FindCALINUX.cmake +++ b/CMakeModules/FindCALINUX.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindCALINUX.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindCALINUX.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindCMU1394.cmake b/CMakeModules/FindCMU1394.cmake index 09a2cbffa08909d875ff549a2d7e8018da6a8d58..a01b813aa29f6c4e3fab31053b9a832433f7336d 100644 --- a/CMakeModules/FindCMU1394.cmake +++ b/CMakeModules/FindCMU1394.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindCMU1394.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindCMU1394.cmake 4603 2014-01-21 13:40:58Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 @@ -52,22 +52,40 @@ if(WIN32) ) #MESSAGE("DBG CMU1394_INCLUDE_DIR=${CMU1394_INCLUDE_DIR}") - FIND_LIBRARY(CMU1394_LIBRARY_DEBUG - NAMES 1394camerad - PATHS - $ENV{CMU1394_HOME}/lib - "C:/Program Files (x86)/CMU/1394Camera/lib" - "C:/Program Files/CMU/1394Camera/lib" - ) - #MESSAGE("DBG CMU1394_LIBRARY_DEBUG=${CMU1394_LIBRARY_DEBUG}") + if(CMAKE_CL_64) + FIND_LIBRARY(CMU1394_LIBRARY_DEBUG + NAMES 1394camerad + PATHS + $ENV{CMU1394_HOME}/lib64/x64 + "C:/Program Files (x86)/CMU/1394Camera/lib64/x64" + "C:/Program Files/CMU/1394Camera/lib64/x64" + ) - FIND_LIBRARY(CMU1394_LIBRARY_RELEASE - NAMES 1394camera - PATHS - $ENV{CMU1394_HOME}/lib - "C:/Program Files (x86)/CMU/1394Camera/lib" - "C:/Program Files/CMU/1394Camera/lib" - ) + FIND_LIBRARY(CMU1394_LIBRARY_RELEASE + NAMES 1394camera + PATHS + $ENV{CMU1394_HOME}/lib64/x64 + "C:/Program Files (x86)/CMU/1394Camera/lib64/x64" + "C:/Program Files/CMU/1394Camera/lib64/x64" + ) + else() + FIND_LIBRARY(CMU1394_LIBRARY_DEBUG + NAMES 1394camerad + PATHS + $ENV{CMU1394_HOME}/lib + "C:/Program Files (x86)/CMU/1394Camera/lib" + "C:/Program Files/CMU/1394Camera/lib" + ) + + FIND_LIBRARY(CMU1394_LIBRARY_RELEASE + NAMES 1394camera + PATHS + $ENV{CMU1394_HOME}/lib + "C:/Program Files (x86)/CMU/1394Camera/lib" + "C:/Program Files/CMU/1394Camera/lib" + ) + endif() + #MESSAGE("DBG CMU1394_LIBRARY_DEBUG=${CMU1394_LIBRARY_DEBUG}") #MESSAGE("DBG CMU1394_LIBRARY_RELEASE=${CMU1394_LIBRARY_RELEASE}") set(CMU1394_LIBRARIES "") diff --git a/CMakeModules/FindCPP11.cmake b/CMakeModules/FindCPP11.cmake index 4e45c223cc4fd0dc8af48dd05bb97da42163cd8e..69001799a57ec8763732a3e470c2d7916c2f1772 100644 --- a/CMakeModules/FindCPP11.cmake +++ b/CMakeModules/FindCPP11.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindCPP11.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindCPP11.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindCycabTk.cmake b/CMakeModules/FindCycabTk.cmake deleted file mode 100644 index 6eac6c5b88f9fd3f2be97194647761df8f5527d6..0000000000000000000000000000000000000000 --- a/CMakeModules/FindCycabTk.cmake +++ /dev/null @@ -1,146 +0,0 @@ -############################################################################# -# -# $Id: FindCycabTk.cmake 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: -# Try to find CycabTk toolkit to control the Cycab car-like mobile robot. -# Once run this will define: -# -# CycabTk_FOUND -# CycabTk_INCLUDE_DIRS -# CycabTk_LIBRARIES -# -# Additional var set when the new version of cycabtk exists (to use) -# CycabTk_NEW_FOUND -# CycabTk_NEW_INCLUDE_DIRS -# CycabTk_NEW_LIBRARIES -# -# Additional var set when the old version of cycabtk exists (obsolete) -# CycabTk_OLD_FOUND -# CycabTk_OLD_INCLUDE_DIRS -# CycabTk_OLD_LIBRARIES -# -# Authors: -# Fabien Spindler -# -############################################################################# - -# -# check first if the old version of cycabtk exists -# This old version is to use with the Syndex base low level control of the Cycab -# running on cycab-hf1 computer -# -FIND_PATH(CycabTk_OLD_INCLUDE_DIR EtherCycab/EtherCycab.hpp - $ENV{CycabTk_OLD_HOME}/include - $ENV{HOME}/soft/Cycab/third-party/cycabtk-old/cycabtk-old/include - /local/fspindle/soft/Cycab/third-party/cycabtk-old/cycabtk-old/include -) -#MESSAGE("DBG CycabTk_OLD_INCLUDE_DIR=${CycabTk_OLD_INCLUDE_DIR}") - -FIND_LIBRARY(CycabTk_OLD_LIBRARY - NAMES cycabtk - PATHS - $ENV{CycabTk_OLD_HOME}/lib - $ENV{HOME}/soft/Cycab/third-party/cycabtk-old/cycabtk-old/lib - /local/fspindle/soft/Cycab/third-party/cycabtk-old/cycabtk-old/lib -) -#MESSAGE("DBG CycabTk_OLD_LIBRARY=${CycabTk_OLD_LIBRARY}") - - -IF(CycabTk_OLD_INCLUDE_DIR AND CycabTk_OLD_LIBRARY) - SET(CycabTk_OLD_FOUND TRUE) - SET(CycabTk_OLD_INCLUDE_DIRS ${CycabTk_OLD_INCLUDE_DIR}) - SET(CycabTk_OLD_LIBRARIES ${CycabTk_OLD_LIBRARY}) -ELSE(CycabTk_OLD_INCLUDE_DIR AND CycabTk_OLD_LIBRARY) - SET(CycabTk_OLD_FOUND FALSE) -ENDIF(CycabTk_OLD_INCLUDE_DIR AND CycabTk_OLD_LIBRARY) - -# -# check secondly if the new version of cycabtk exists -# This new version is to use with the C base low level control of the Cycab -# throw the Peak CAN dongle -# -# --- Check library dependency -include(FindPkgConfig) - -set( Boost_USE_MULTITHREADED ON ) -find_package( Boost COMPONENTS serialization) - -FIND_LIBRARY(HUGR_LIBRARY - NAMES hugr - PATHS - /usr/lib - /usr/local/lib -) - -IF(Boost_SERIALIZATION_FOUND AND HUGR_LIBRARY) - SET(CycabTk_NEW_FOUND TRUE) - SET(CycabTk_NEW_LIBRARIES ${HUGR_LIBRARY} ${Boost_SERIALIZATION_LIBRARIES}) -ELSE(Boost_SERIALIZATION_FOUND AND HUGR_LIBRARY) - SET(CycabTk_NEW_FOUND FALSE) -ENDIF(Boost_SERIALIZATION_FOUND AND HUGR_LIBRARY) - -#MESSAGE("CycabTk new: ${CycabTk_NEW_FOUND} old: ${CycabTk_OLD_FOUND}") - -IF(CycabTk_NEW_FOUND AND CycabTk_OLD_FOUND) - OPTION(USE_CYCAB_WITH_OLD_CYCABTK "Use the old and obsolete CycabTk" FALSE) -ENDIF(CycabTk_NEW_FOUND AND CycabTk_OLD_FOUND) - -IF(USE_CYCAB_WITH_OLD_CYCABTK) - # either old or new cycabtk is detected - SET(CycabTk_FOUND TRUE) - SET(CycabTk_NEW_FOUND FALSE) - SET(CycabTk_INCLUDE_DIRS ${CycabTk_OLD_INCLUDE_DIRS}) - SET(CycabTk_LIBRARIES ${CycabTk_OLD_LIBRARIES}) -ELSE(USE_CYCAB_WITH_OLD_CYCABTK) - IF(CycabTk_NEW_FOUND) - SET(CycabTk_FOUND TRUE) - SET(CycabTk_OLD_FOUND FALSE) - SET(CycabTk_LIBRARIES ${CycabTk_NEW_LIBRARIES}) - ELSE(CycabTk_NEW_FOUND) - IF(CycabTk_OLD_FOUND) - SET(CycabTk_FOUND TRUE) - SET(CycabTk_INCLUDE_DIRS ${CycabTk_OLD_INCLUDE_DIRS}) - SET(CycabTk_LIBRARIES ${CycabTk_OLD_LIBRARIES}) - ENDIF(CycabTk_OLD_FOUND) - ENDIF(CycabTk_NEW_FOUND) -ENDIF(USE_CYCAB_WITH_OLD_CYCABTK) - -MARK_AS_ADVANCED( - CycabTk_INCLUDE_DIR - CycabTk_LIBRARIES - CycabTk_NEW_INCLUDE_DIR - CycabTk_NEW_LIBRARIES - CycabTk_OLD_INCLUDE_DIR - CycabTk_OLD_LIBRARY - CycabTk_OLD_LIBRARIES - HUGR_LIBRARY -) \ No newline at end of file diff --git a/CMakeModules/FindDC1394.cmake b/CMakeModules/FindDC1394.cmake index 797a754534984d71b968889cc30efcb9f7800577..01b4db77f9e374b8a286de9d60409aa7ea949e85 100644 --- a/CMakeModules/FindDC1394.cmake +++ b/CMakeModules/FindDC1394.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindDC1394.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindDC1394.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 @@ -36,15 +36,8 @@ # Once run this will define: # # DC1394_FOUND -# DC1394_1_FOUND -# DC1394_2_FOUND -# DC1394_VERSION # DC1394_INCLUDE_DIRS -# DC1394_1_INCLUDE_DIRS -# DC1394_2_INCLUDE_DIRS # DC1394_LIBRARIES -# DC1394_1_LIBRARY -# DC1394_2_LIBRARY # # The two defines below are only useful to compile with libdc1394-2.x. In # that case DC1394_VERSION=2. Since the libdc1394-2.x API is not stable, we @@ -64,53 +57,24 @@ IF(NOT UNIX) # MESSAGE("FindDC1394.cmake: libdc1394 only available for Unix.") SET(DC1394_FOUND FALSE) -ELSE(NOT UNIX) -# Search for libdc1394-1.x - - FIND_PATH(DC1394_1_INCLUDE_DIR libdc1394/dc1394_control.h - $ENV{DC1394_HOME}/include - $ENV{DC1394_DIR}/include - /usr/include ) -#MESSAGE("DBG DC1394_1_INCLUDE_DIR=${DC1394_1_INCLUDE_DIR}") - - FIND_LIBRARY(DC1394_1_LIBRARY - NAMES dc1394_control - PATHS - $ENV{DC1394_HOME}/lib - $ENV{DC1394_DIR}/lib - /usr/lib - ) -#MESSAGE("DBG DC1394_1_LIBRARY=${DC1394_LIBRARY}") - - IF(DC1394_1_LIBRARY AND DC1394_1_INCLUDE_DIR) - SET(DC1394_FOUND TRUE) - SET(DC1394_1_FOUND TRUE) - SET(DC1394_VERSION 1) - SET(DC1394_LIBRARIES ${DC1394_1_LIBRARY}) - SET(DC1394_1_INCLUDE_DIRS ${DC1394_1_INCLUDE_DIR}) - SET(DC1394_INCLUDE_DIRS ${DC1394_1_INCLUDE_DIRS}) - ELSE(DC1394_1_LIBRARY AND DC1394_1_INCLUDE_DIR) - SET(DC1394_FOUND FALSE) - SET(DC1394_1_FOUND FALSE) - ENDIF(DC1394_1_LIBRARY AND DC1394_1_INCLUDE_DIR) - +ELSE(NOT UNIX) # Search for libdc1394-2.x - FIND_PATH(DC1394_2_INCLUDE_DIR dc1394/control.h + FIND_PATH(DC1394_INCLUDE_DIR dc1394/control.h $ENV{DC1394_HOME}/include $ENV{DC1394_DIR}/include /usr/include ) - #MESSAGE("DBG DC1394_2_INCLUDE_DIR=${DC1394_2_INCLUDE_DIR}") + #MESSAGE("DBG DC1394_INCLUDE_DIR=${DC1394_INCLUDE_DIR}") - FIND_LIBRARY(DC1394_2_LIBRARY + FIND_LIBRARY(DC1394_LIBRARY NAMES dc1394 PATHS $ENV{DC1394_HOME}/lib $ENV{DC1394_DIR}/lib /usr/lib ) - #MESSAGE("DBG DC1394_2_LIBRARY=${DC1394_2_LIBRARY}") + #MESSAGE("DBG DC1394_LIBRARY=${DC1394_LIBRARY}") - IF(DC1394_2_LIBRARY AND DC1394_2_INCLUDE_DIR) + IF(DC1394_LIBRARY AND DC1394_INCLUDE_DIR) # Since the libdc1394-2.x API is not stable, try to compile a # sample code to determine if we have to use dc1394_find_cameras() or @@ -119,8 +83,8 @@ ELSE(NOT UNIX) include(CheckCXXSourceCompiles) - SET(CMAKE_REQUIRED_LIBRARIES ${DC1394_2_LIBRARY}) - SET(CMAKE_REQUIRED_INCLUDES ${DC1394_2_INCLUDE_DIR}) + SET(CMAKE_REQUIRED_LIBRARIES ${DC1394_LIBRARY}) + SET(CMAKE_REQUIRED_INCLUDES ${DC1394_INCLUDE_DIR}) CHECK_CXX_SOURCE_COMPILES(" #include <dc1394/control.h> @@ -153,28 +117,23 @@ ELSE(NOT UNIX) ENDIF(NOT DC1394_CAMERA_ENUMERATE_FOUND) IF(NOT DC1394_CAMERA_ENUMERATE_FOUND AND NOT DC1394_FIND_CAMERAS_FOUND) - SET(DC1394_2_FOUND FALSE) + SET(DC1394_FOUND FALSE) MESSAGE("libdc1394-2.x found but not compatible with ViSP...") ELSE(NOT DC1394_CAMERA_ENUMERATE_FOUND AND NOT DC1394_FIND_CAMERAS_FOUND) SET(DC1394_FOUND TRUE) - SET(DC1394_2_FOUND TRUE) ENDIF(NOT DC1394_CAMERA_ENUMERATE_FOUND AND NOT DC1394_FIND_CAMERAS_FOUND) - SET(DC1394_VERSION 2) - SET(DC1394_LIBRARIES ${DC1394_2_LIBRARY}) - SET(DC1394_2_INCLUDE_DIRS ${DC1394_2_INCLUDE_DIR}) - SET(DC1394_INCLUDE_DIRS ${DC1394_2_INCLUDE_DIRS}) - ENDIF(DC1394_2_LIBRARY AND DC1394_2_INCLUDE_DIR) + SET(DC1394_LIBRARIES ${DC1394_LIBRARY}) + SET(DC1394_INCLUDE_DIRS ${DC1394_INCLUDE_DIR}) + ENDIF(DC1394_LIBRARY AND DC1394_INCLUDE_DIR) ## -------------------------------- MARK_AS_ADVANCED( - DC1394_1_LIBRARY - DC1394_1_INCLUDE_DIR - DC1394_2_LIBRARY - DC1394_2_INCLUDE_DIR + DC1394_LIBRARY + DC1394_INCLUDE_DIR DC1394_INCLUDE_DIR DC1394_LIBRARIES DC1394_LIBRARY diff --git a/CMakeModules/FindDIRECT3D.cmake b/CMakeModules/FindDIRECT3D.cmake index f6bb4a4f8b2e58eaa515037f116991205ee8bf5a..18eb6a173ea0096faeaadbc7d42e24b1cb87f5f4 100755 --- a/CMakeModules/FindDIRECT3D.cmake +++ b/CMakeModules/FindDIRECT3D.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindDIRECT3D.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindDIRECT3D.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindDIRECTSHOW.cmake b/CMakeModules/FindDIRECTSHOW.cmake index 7d3d62602e83a4f77ee89f7d45c9970525a55072..95ecea8eacb0fb0fab8850a251c79d8eaaead042 100644 --- a/CMakeModules/FindDIRECTSHOW.cmake +++ b/CMakeModules/FindDIRECTSHOW.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindDIRECTSHOW.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindDIRECTSHOW.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindDL.cmake b/CMakeModules/FindDL.cmake index 62b5704672ae52c89631baee69fca5532c0ac28c..f62ab6b041f3c02d2e972fcb5f785341a7d470bb 100644 --- a/CMakeModules/FindDL.cmake +++ b/CMakeModules/FindDL.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindDL.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindDL.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindFFMPEG.cmake b/CMakeModules/FindFFMPEG.cmake index 017bfc35db169ef5ced5ab790ad2964061fed09b..9d6c9b325f25a7bee506aaebc097ff004b595bfe 100644 --- a/CMakeModules/FindFFMPEG.cmake +++ b/CMakeModules/FindFFMPEG.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindFFMPEG.cmake 4160 2013-03-12 08:34:49Z fspindle $ +# $Id: FindFFMPEG.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindGDI.cmake b/CMakeModules/FindGDI.cmake index c39a3e1c92335cd11d846a217063568da9e33461..4bb65bff4178b78bbddcabd42f88b995684771dc 100644 --- a/CMakeModules/FindGDI.cmake +++ b/CMakeModules/FindGDI.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindGDI.cmake 4293 2013-07-01 16:05:01Z fspindle $ +# $Id: FindGDI.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 @@ -107,6 +107,7 @@ IF(WIN32) "C:/Program Files/Microsoft SDKs/Windows/v7.0A/Lib" "C:/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Lib" "C:/Program Files (x86)/Microsoft SDKs/Windows/v7.1/Lib" + "C:/Program Files (x86)/Microsoft SDKs/Windows/v7.1A/Lib" "C:/Program Files/Microsoft Platform SDK/Lib" "C:/DXSDK/Include/Lib" "C:/Program Files/Microsoft SDKs/Windows/v6.0a/Lib" diff --git a/CMakeModules/FindGSL.cmake b/CMakeModules/FindGSL.cmake index 406888c77fd695dfc82400de4ab70d24b078b6de..adecf198b4a0d87cbc13ae05792af536d05864d5 100644 --- a/CMakeModules/FindGSL.cmake +++ b/CMakeModules/FindGSL.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindGSL.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindGSL.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindICONV.cmake b/CMakeModules/FindICONV.cmake index 23579cf161c627e4c91bc2669d634533a4dd52c9..b460dc7072e80b0919841b35a7ddea69959de2cf 100755 --- a/CMakeModules/FindICONV.cmake +++ b/CMakeModules/FindICONV.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindICONV.cmake 4160 2013-03-12 08:34:49Z fspindle $ +# $Id: FindICONV.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindIRISA.cmake b/CMakeModules/FindIRISA.cmake index fdb37f3377fd7e850032c7ee1aa250011491ade2..01f720993094d9d10579abdb71ea0fcec6c6a84b 100644 --- a/CMakeModules/FindIRISA.cmake +++ b/CMakeModules/FindIRISA.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindIRISA.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindIRISA.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindLAPACK_C.cmake b/CMakeModules/FindLAPACK_C.cmake index 5deff69bca3ed1ca1178654926f3d41a4ab84618..577944d749c73e69aed98db9dcb6f5e6f1c99c66 100644 --- a/CMakeModules/FindLAPACK_C.cmake +++ b/CMakeModules/FindLAPACK_C.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindLAPACK_C.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindLAPACK_C.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindLIBFREENECT.cmake b/CMakeModules/FindLIBFREENECT.cmake index 0ce94fb1d7cd7ba3f2dad950d4487fac9003a7c4..a73a38dcc68561cfedea7611d3c52a6fdf3be48c 100644 --- a/CMakeModules/FindLIBFREENECT.cmake +++ b/CMakeModules/FindLIBFREENECT.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindLIBFREENECT.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindLIBFREENECT.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindLIBUSB-1.cmake b/CMakeModules/FindLIBUSB-1.cmake index 79d57a4164a20e7c4b98005ffb79351e1f490d45..4a9432c0b9b5e744cd6b800240fea896eff90ed1 100644 --- a/CMakeModules/FindLIBUSB-1.cmake +++ b/CMakeModules/FindLIBUSB-1.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindLIBUSB-1.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindLIBUSB-1.cmake 4678 2014-02-19 09:52:35Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 @@ -35,6 +35,7 @@ # # LIBUSB_1_FOUND # LIBUSB_1_LIBRARIES +# LIBUSB_1_INCLUDE_DIRS # # Authors: # Celine Teuliere @@ -55,11 +56,18 @@ ELSE(WIN32) /usr/lib /usr/local/lib ) + FIND_PATH(LIBUSB_1_INCLUDE_DIR libusb.h + $ENV{LIBUSB_1_HOME}/include/libusb-1.0 + $ENV{LIBUSB_1_HOME}/build/include/libusb-1.0 + /usr/include/libusb-1.0 + /usr/local/include/libusb-1.0 + ) ENDIF(WIN32) ## -------------------------------- -IF(LIBUSB_1_LIBRARY) +IF(LIBUSB_1_LIBRARY AND LIBUSB_1_INCLUDE_DIR) + SET(LIBUSB_1_INCLUDE_DIRS ${LIBUSB_1_INCLUDE_DIR}) SET(LIBUSB_1_LIBRARIES ${LIBUSB_1_LIBRARY}) SET(LIBUSB_1_FOUND TRUE) ELSE() @@ -67,6 +75,8 @@ ELSE() ENDIF() MARK_AS_ADVANCED( + LIBUSB_1_INCLUDE_DIRS + LIBUSB_1_INCLUDE_DIR LIBUSB_1_LIBRARIES LIBUSB_1_LIBRARY ) diff --git a/CMakeModules/FindMyCoin3D.cmake b/CMakeModules/FindMyCoin3D.cmake index 60c5a28693c028a62cb9361cb6ee2407a3f49741..1cefd1610f2967ca1a308490c68b1244e84f5b81 100644 --- a/CMakeModules/FindMyCoin3D.cmake +++ b/CMakeModules/FindMyCoin3D.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindMyCoin3D.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindMyCoin3D.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindMyGTK2.cmake b/CMakeModules/FindMyGTK2.cmake index a6c95b05a4fce2a3400df7414614680668700bf2..674de22d44067d38bdf862df4f76dd9ddd3e5ba3 100644 --- a/CMakeModules/FindMyGTK2.cmake +++ b/CMakeModules/FindMyGTK2.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindMyGTK2.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindMyGTK2.cmake 4637 2014-02-04 09:48:33Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 @@ -69,7 +69,7 @@ IF(UNIX OR WIN32) /usr/lib/i386-linux-gnu/glib-2.0/include /usr/lib/x86_64-linux-gnu/glib-2.0/include /opt/gnome/lib/glib-2.0/include - "C:/GTK/lib/glib-2.0/include"glib + C:/GTK/lib/glib-2.0/include /sw/lib/glib-2.0/include ) @@ -78,7 +78,7 @@ IF(UNIX OR WIN32) $ENV{GTK2_HOME}/include/glib-2.0 /usr/include/glib-2.0 /opt/gnome/include/glib-2.0 - "C:/GTK/include/glib-2.0" + C:/GTK/include/glib-2.0 /sw/include/glib-2.0 ) @@ -87,7 +87,7 @@ IF(UNIX OR WIN32) $ENV{GTK2_HOME}/include/pango-1.0 /usr/include/pango-1.0 /opt/gnome/include/pango-1.0 - "C:/GTK/include/pango-1.0" + C:/GTK/include/pango-1.0 /sw/include/pango-1.0 ) @@ -96,7 +96,7 @@ IF(UNIX OR WIN32) $ENV{GTK2_HOME}/include/cairo /usr/include/cairo /opt/gnome/include/cairo - "C:/GTK/include/cairo" + C:/GTK/include/cairo /sw/include/cairo ) @@ -106,7 +106,7 @@ IF(UNIX OR WIN32) /usr/lib/gtk-2.0/include /usr/lib64/gtk-2.0/include /opt/gnome/lib/gtk-2.0/include - "C:/GTK/lib/gtk-2.0/include" + C:/GTK/lib/gtk-2.0/include /sw/lib/gtk-2.0/include /usr/lib/i386-linux-gnu/gtk-2.0/include /usr/lib/x86_64-linux-gnu/gtk-2.0/include @@ -117,7 +117,7 @@ IF(UNIX OR WIN32) $ENV{GTK2_HOME}/gdk-pixbuf-2.0 /usr/include/gdk-pixbuf-2.0 /usr/include/gtk-2.0 - "C:/GTK/include/gtk-2.0" + C:/GTK/include/gtk-2.0 /sw/include/gtk-2.0 ) @@ -128,7 +128,7 @@ IF(UNIX OR WIN32) $ENV{GTK2_HOME}/include/atk-1.0 /usr/include/atk-1.0 /opt/gnome/include/atk-1.0 - "C:/GTK/include/atk-1.0" + C:/GTK/include/atk-1.0 /sw/include/atk-1.0 ) @@ -141,7 +141,7 @@ IF(UNIX OR WIN32) /usr/openwin/lib /usr/X11R6/lib /opt/gnome/lib - "C:/GTK/lib" + C:/GTK/lib /sw/lib ) @@ -154,7 +154,7 @@ IF(UNIX OR WIN32) /usr/openwin/lib /usr/X11R6/lib /opt/gnome/lib - "C:/GTK/lib" + C:/GTK/lib /sw/lib ) @@ -167,7 +167,7 @@ IF(UNIX OR WIN32) /usr/openwin/lib /usr/X11R6/lib /opt/gnome/lib - "C:/GTK/lib" + C:/GTK/lib /sw/lib ) @@ -180,7 +180,7 @@ IF(UNIX OR WIN32) /usr/openwin/lib /usr/X11R6/lib /opt/gnome/lib - "C:/GTK/lib" + C:/GTK/lib /sw/lib ) @@ -193,7 +193,7 @@ IF(UNIX OR WIN32) /usr/openwin/lib /usr/X11R6/lib /opt/gnome/lib - "C:/GTK/lib" + C:/GTK/lib /sw/lib ) @@ -203,7 +203,7 @@ IF(UNIX OR WIN32) PATHS $ENV{GTK2_HOME}/lib /usr/lib /opt/gnome/lib - "C:/GTK/lib" + C:/GTK/lib /sw/lib ) diff --git a/CMakeModules/FindMyJPEG.cmake b/CMakeModules/FindMyJPEG.cmake index d62689708bb805ce030c47e2d757da23567110e8..5c4a8b62382c45fb7a3e3f9f3c09190b8b704144 100644 --- a/CMakeModules/FindMyJPEG.cmake +++ b/CMakeModules/FindMyJPEG.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindMyJPEG.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindMyJPEG.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindMyPNG.cmake b/CMakeModules/FindMyPNG.cmake index b23f1b9c14f1c9b96cfcaa7ba822694217e4f0ec..e27f2a9f669385ec47af04e3d22f7b6e05234470 100644 --- a/CMakeModules/FindMyPNG.cmake +++ b/CMakeModules/FindMyPNG.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindMyPNG.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindMyPNG.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindMyZLIB.cmake b/CMakeModules/FindMyZLIB.cmake index 8cc7163ab1aa8ccf8ef40b0bf868d7e60cdfc274..f3ccdbad7c6c4c760e0ebbb6a986934752417fed 100644 --- a/CMakeModules/FindMyZLIB.cmake +++ b/CMakeModules/FindMyZLIB.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindMyZLIB.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindMyZLIB.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindNAS.cmake b/CMakeModules/FindNAS.cmake index 71324eff0f749c4d9a4ce1508bb221b1d16f724f..4e927af45cde72f647a9de703d35d76bc677a991 100644 --- a/CMakeModules/FindNAS.cmake +++ b/CMakeModules/FindNAS.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindNAS.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindNAS.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindPARPORT.cmake b/CMakeModules/FindPARPORT.cmake index 58f414d86aad8f6f5a822045bbd28448ad609ebe..8450d1ebf136f54a05d43da178547d85f9d7bf4e 100644 --- a/CMakeModules/FindPARPORT.cmake +++ b/CMakeModules/FindPARPORT.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindPARPORT.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindPARPORT.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindPTHREAD.cmake b/CMakeModules/FindPTHREAD.cmake index 0627c6d0a441ff42cc711d47350fd856e80aa720..e6da44d71bbc6e0c49a9196a95064916069f08b8 100644 --- a/CMakeModules/FindPTHREAD.cmake +++ b/CMakeModules/FindPTHREAD.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindPTHREAD.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindPTHREAD.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindPTU46.cmake b/CMakeModules/FindPTU46.cmake index 9960f5d59414630c8d5d6b0f62c9a576e0e3050b..46fdae34b427fef83583be84088e76caf3e56018 100644 --- a/CMakeModules/FindPTU46.cmake +++ b/CMakeModules/FindPTU46.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindPTU46.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindPTU46.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindRAW1394.cmake b/CMakeModules/FindRAW1394.cmake index 1c7a7f754bd1a6bb776e5608dcfb7b6a2bd66880..db33295810f070768da6375e646b15af6d14d8f7 100644 --- a/CMakeModules/FindRAW1394.cmake +++ b/CMakeModules/FindRAW1394.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindRAW1394.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindRAW1394.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindRT.cmake b/CMakeModules/FindRT.cmake index 87d75694b686a413d2ea32b8b891cec861885de0..4554ea78f2e69195f471473578cf1eb1d7722d3a 100644 --- a/CMakeModules/FindRT.cmake +++ b/CMakeModules/FindRT.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindRT.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindRT.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindSOQT.cmake b/CMakeModules/FindSOQT.cmake index f52e23e45fb340ce0c6d5e83c16381440a58417e..ad7d73ca93c1bad1aa1aa6f4aa990af6f2ac6f4e 100644 --- a/CMakeModules/FindSOQT.cmake +++ b/CMakeModules/FindSOQT.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindSOQT.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindSOQT.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindSOWIN.cmake b/CMakeModules/FindSOWIN.cmake index 4c224c4da0b750527d318b31439c723754118968..632fb721711e0d69a531adc18f7e05a5d533401f 100644 --- a/CMakeModules/FindSOWIN.cmake +++ b/CMakeModules/FindSOWIN.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindSOWIN.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindSOWIN.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindSOXT.cmake b/CMakeModules/FindSOXT.cmake index d41d911aa1ad144f8958dcbe6135ba0b330d51ab..2d178304027951366a4d0783d1e55f0b40f031d5 100644 --- a/CMakeModules/FindSOXT.cmake +++ b/CMakeModules/FindSOXT.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindSOXT.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindSOXT.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindV4L2.cmake b/CMakeModules/FindV4L2.cmake index 884dd5c43a9cc12d0f62e45ae14f28e08fe956ef..fe068c3d40298119526aa5f7d7c4e855a6b2ba3c 100644 --- a/CMakeModules/FindV4L2.cmake +++ b/CMakeModules/FindV4L2.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindV4L2.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: FindV4L2.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/FindXML2.cmake b/CMakeModules/FindXML2.cmake index 1e0e73971a8328df49fcdd9142d98f5d71b9d9a7..abac264ccf7b205239189a150978af153ac59e3f 100755 --- a/CMakeModules/FindXML2.cmake +++ b/CMakeModules/FindXML2.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: FindXML2.cmake 4069 2013-01-21 14:28:56Z fspindle $ +# $Id: FindXML2.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/GenerateConfigScript.cmake b/CMakeModules/GenerateConfigScript.cmake index cb21dd3b528daf7fb2cdf7e67893fb162769222a..225899db0c741a3a3842dc859e142a494cef5c1f 100644 --- a/CMakeModules/GenerateConfigScript.cmake +++ b/CMakeModules/GenerateConfigScript.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: GenerateConfigScript.cmake 4209 2013-04-16 07:04:20Z fspindle $ +# $Id: GenerateConfigScript.cmake 4676 2014-02-17 22:08:37Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 @@ -67,8 +67,13 @@ IF (UNIX) #--------------------------------------------------------------------- # Updates VISP_CONFIG_CFLAGS #---------------------------------------------------------------------- - SET(VISP_CONFIG_CFLAGS ${VISP_OPENMP_FLAGS}) - LIST(APPEND VISP_CONFIG_CFLAGS "${VISP_DEFS}") + if(NOT ${VISP_OPENMP_FLAGS} STREQUAL "") + list(APPEND VISP_CONFIG_CFLAGS ${VISP_OPENMP_FLAGS}) + endif() + if(NOT ${VISP_CPP11_FLAGS} STREQUAL "") + list(APPEND VISP_CONFIG_CFLAGS ${VISP_CPP11_CFLAGS}) + endif() + list(APPEND VISP_CONFIG_CFLAGS "${VISP_DEFS}") FOREACH(INCDIR ${VISP_EXTERN_INCLUDE_DIRS}) LIST(APPEND VISP_CONFIG_CFLAGS "-I${INCDIR}") @@ -107,11 +112,11 @@ IF (UNIX) # Manage the lib path SET(VISP_CONFIG_SCRIPT_TMP_LDFLAGS) FOREACH(dir ${VISP_EXTERN_LINK_DIR}) - LIST(APPEND VISP_CONFIG_SCRIPT_TMP_LDFLAGS "-L${dir}") + LIST(APPEND VISP_CONFIG_SCRIPT_TMP_LDFLAGS "-L${dir}") ENDFOREACH(dir) #MESSAGE("VISP_EXTERN_LINK_DIR: ${VISP_EXTERN_LINK_DIR}") #MESSAGE("VISP_CONFIG_SCRIPT_TMP_LDFLAGS: ${VISP_CONFIG_SCRIPT_TMP_LDFLAGS}") - # convert semicolon-separated vector to space-separated string + # convert semicolon-separated vector to space-separated string FOREACH(val ${VISP_CONFIG_SCRIPT_TMP_LDFLAGS}) SET(VISP_CONFIG_LIBS "${VISP_CONFIG_LIBS} ${val}") ENDFOREACH(val) @@ -160,13 +165,8 @@ IF (UNIX) # prepend with ViSP own include dir set(VISP_CONFIG_CFLAGS_SCRIPT "-I$PREFIX/${CMAKE_INSTALL_INCLUDEDIR} ${VISP_CONFIG_CFLAGS}") - # prepend with ViSP own lib dir - SET(VISP_CONFIG_LIBS_SCRIPT "-L$PREFIX/${CMAKE_INSTALL_LIBDIR} -l${VISP_INTERN_LIBRARY} ${VISP_CONFIG_LIBS}") - IF(UNIX) - IF(NOT APPLE) - SET(VISP_CONFIG_LIBS_SCRIPT "-Wl,-rpath,$PREFIX/${CMAKE_INSTALL_LIBDIR} ${VISP_CONFIG_LIBS_SCRIPT}") - ENDIF(NOT APPLE) - ENDIF(UNIX) + # prepend with ViSP own lib and -L<lib dir> + SET(VISP_CONFIG_LIBS_SCRIPT "$PREFIX/${CMAKE_INSTALL_LIBDIR}/${VISP_LIBNAME_OPT} -L$PREFIX/${CMAKE_INSTALL_LIBDIR} ${VISP_CONFIG_LIBS}") SET(VISP_ECHO_NO_NEWLINE_CHARACTER "") SET(VISP_ECHO_NO_NEWLINE_OPTION "") @@ -196,13 +196,8 @@ IF (UNIX) # prepend with ViSP own include dir set(VISP_CONFIG_CFLAGS_PC "-I\${includedir} ${VISP_CONFIG_CFLAGS}") - # prepend with ViSP own lib dir - SET(VISP_CONFIG_LIBS_PC "-L\${libdir} -l${VISP_INTERN_LIBRARY} ${VISP_CONFIG_LIBS}") - IF(UNIX) - IF(NOT APPLE) - SET(VISP_CONFIG_LIBS_PC "-Wl,-rpath,\${libdir} ${VISP_CONFIG_LIBS_PC}") - ENDIF(NOT APPLE) - ENDIF(UNIX) + # prepend with ViSP own lib dir and append -L<lib dir> + SET(VISP_CONFIG_LIBS_PC "\${libdir}/${VISP_LIBNAME_OPT} ${VISP_CONFIG_LIBS} -L\${libdir}") CONFIGURE_FILE(${FILE_VISP_CONFIG_PC_INSTALL_IN} ${FILE_VISP_CONFIG_PC_INSTALL}) ELSE(UNIX) @@ -222,7 +217,14 @@ ELSE(UNIX) #--------------------------------------------------------------------- # Updates VISP_CONFIG_SCRIPT_DEF #---------------------------------------------------------------------- - SET(VISP_CONFIG_SCRIPT_DEFS "") + set(VISP_CONFIG_SCRIPT_DEFS "") + if(NOT ${VISP_OPENMP_FLAGS} STREQUAL "") + set(VISP_CONFIG_SCRIPT_DEFS "${VISP_OPENMP_FLAGS}") + endif() + if(NOT ${VISP_CPP11_FLAGS} STREQUAL "") + set(VISP_CONFIG_SCRIPT_DEFS "${VISP_CPP11_FLAGS}, ${VISP_CONFIG_SCRIPT_DEFS}") + endif() + FOREACH(def ${VISP_DEFS}) #MESSAGE("def to process: ${def}") IF("${def}" MATCHES "[-][D]+.") @@ -247,15 +249,6 @@ ELSE(UNIX) # MESSAGE(VISP_CONFIG_SCRIPT_INC ${VISP_CONFIG_SCRIPT_INC}) - #--------------------------------------------------------------------- - # Updates VISP_OPENMP_SUPPORT - #---------------------------------------------------------------------- - IF(VISP_OPENMP_FLAGS) - SET(VISP_OPENMP_SUPPORT "OpenMP support: Yes") - ELSE() - SET(VISP_OPENMP_SUPPORT "OpenMP support: No") - ENDIF() - #--------------------------------------------------------------------- # Updates VISP_CONFIG_SCRIPT_LIBDIR #---------------------------------------------------------------------- @@ -266,9 +259,9 @@ ELSE(UNIX) FOREACH(var ${VISP_EXTERN_LINK_DIR}) #MESSAGE("var to process: ${var}") IF("${var}" MATCHES "[-][L]+.") - #MESSAGE("${var} matches -L") + #MESSAGE("${var} matches -L") STRING(REGEX REPLACE "[-][L]" "" var ${var}) - #MESSAGE("new ${newvar} without -L") + #MESSAGE("new ${newvar} without -L") ENDIF("${var}" MATCHES "[-][L]+.") LIST(APPEND TMP_SCRIPT_LIBDIR ${var}) LIST(APPEND TMP_SCRIPT_LIBDIR "${var}\\$(ConfigurationName)") diff --git a/CMakeModules/OgreTools.cmake b/CMakeModules/OgreTools.cmake index 301b73778e5e9d8735857c0c9a124be76c56dfcf..6d8c458af0f28bebd2c7756ead20f3cabe20cdb9 100755 --- a/CMakeModules/OgreTools.cmake +++ b/CMakeModules/OgreTools.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: OgreTools.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: OgreTools.cmake 4588 2014-01-15 17:29:53Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 @@ -38,18 +38,72 @@ # ############################################################################# +######################################################### +# Find Ogre plugins +# +# This is a modified version of the macro provided with Ogre +# except that should be used only in a desparate way when the one original +# one doesn't detect anything +######################################################### + +macro(ogre_find_plugin_lib_visp PLUGIN) + # On Unix, the plugins might have no prefix + if (CMAKE_FIND_LIBRARY_PREFIXES) + set(TMP_CMAKE_LIB_PREFIX ${CMAKE_FIND_LIBRARY_PREFIXES}) + set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES} "") + endif() + + # strip RenderSystem_ or Plugin_ prefix from plugin name + string(REPLACE "RenderSystem_" "" PLUGIN_TEMP ${PLUGIN}) + string(REPLACE "Plugin_" "" PLUGIN_NAME ${PLUGIN_TEMP}) + + set(OGRE_PLUGIN_PATH_SUFFIXES + PlugIns PlugIns/${PLUGIN_NAME} Plugins Plugins/${PLUGIN_NAME} ${PLUGIN} + RenderSystems RenderSystems/${PLUGIN_NAME} ${ARGN}) + # find link libraries for plugins + set(OGRE_${PLUGIN}_LIBRARY_NAMES "${PLUGIN}${OGRE_LIB_SUFFIX}") + get_debug_names(OGRE_${PLUGIN}_LIBRARY_NAMES) + find_library(OGRE_${PLUGIN}_LIBRARY_REL NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES} + HINTS ${OGRE_LIBRARY_DIRS} ${OGRE_LIBRARY_DIRS}/OGRE ${OGRE_LIBRARY_DIRS}/OGRE-${OGRE_VERSION_MAJOR}.${OGRE_VERSION_MINOR}.${OGRE_VERSION_PATCH} + PATH_SUFFIXES "" OGRE opt release release/opt relwithdebinfo relwithdebinfo/opt minsizerel minsizerel/opt) + find_library(OGRE_${PLUGIN}_LIBRARY_DBG NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES_DBG} + HINTS ${OGRE_LIBRARY_DIRS} ${OGRE_LIBRARY_DIRS}/OGRE ${OGRE_LIBRARY_DIRS}/OGRE-${OGRE_VERSION_MAJOR}.${OGRE_VERSION_MINOR}.${OGRE_VERSION_PATCH} + PATH_SUFFIXES "" OGRE opt debug debug/opt) + make_library_set(OGRE_${PLUGIN}_LIBRARY) + + if (OGRE_${PLUGIN}_LIBRARY) + set(OGRE_${PLUGIN}_FOUND TRUE) + endif () + + mark_as_advanced(OGRE_${PLUGIN}_LIBRARY_REL OGRE_${PLUGIN}_LIBRARY_DBG OGRE_${PLUGIN}_LIBRARY_FWK) + +endmacro(ogre_find_plugin_lib_visp) + MACRO(CREATE_OGRE_PLUGIN_CONFIG_FILE) SET(VISP_HAVE_OGRE_PLUGINS_PATH ${VISP_BINARY_DIR}/data/ogre-simulator) # If OGRE_PLUGIN_DIR_REL and OGRE_PLUGIN_DIR_DBG are not defined we - # try to find these path manually + # try to find them manually IF(NOT OGRE_PLUGIN_DIR_REL AND NOT OGRE_PLUGIN_DIR_DBG) - IF(OGRE_RenderSystem_GL_LIBRARY_REL) + ogre_find_plugin_lib_visp(RenderSystem_Direct3D9) + ogre_find_plugin_lib_visp(RenderSystem_Direct3D10) + ogre_find_plugin_lib_visp(RenderSystem_Direct3D11) + ogre_find_plugin_lib_visp(RenderSystem_GL) + ogre_find_plugin_lib_visp(RenderSystem_GLES) + ogre_find_plugin_lib_visp(Plugin_ParticleFX) + ogre_find_plugin_lib_visp(Plugin_BSPSceneManager) + ogre_find_plugin_lib_visp(Plugin_CgProgramManager) + ogre_find_plugin_lib_visp(Plugin_PCZSceneManager) + ogre_find_plugin_lib_visp(Plugin_OctreeSceneManager) + ogre_find_plugin_lib_visp(Plugin_OctreeZone) + + + IF(OGRE_RenderSystem_GL_LIBRARY_REL) GET_FILENAME_COMPONENT(OGRE_PLUGIN_DIR_REL ${OGRE_RenderSystem_GL_LIBRARY_REL} PATH) - #message("set manually OGRE_PLUGIN_DIR_REL to ${OGRE_PLUGIN_DIR_REL}") + #message("set manually OGRE_PLUGIN_DIR_REL to ${OGRE_PLUGIN_DIR_REL}") ELSEIF(OGRE_RenderSystem_GL_LIBRARY_DBG) GET_FILENAME_COMPONENT(OGRE_PLUGIN_DIR_DBG ${OGRE_RenderSystem_GL_LIBRARY_DBG} PATH) - #message("set manually OGRE_PLUGIN_DIR_DBG to ${OGRE_PLUGIN_DIR_DBG}") + #message("set manually OGRE_PLUGIN_DIR_DBG to ${OGRE_PLUGIN_DIR_DBG}") ENDIF() ENDIF() diff --git a/CMakeModules/TargetDistclean.cmake b/CMakeModules/TargetDistclean.cmake index c46819a2237e8ce078bf439398b616b32f9784c9..9acff5dc542a0d0024e4e8266cbfe9d7a749e81f 100644 --- a/CMakeModules/TargetDistclean.cmake +++ b/CMakeModules/TargetDistclean.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: TargetDistclean.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: TargetDistclean.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/VISPCRTLinkage.cmake b/CMakeModules/VISPCRTLinkage.cmake new file mode 100644 index 0000000000000000000000000000000000000000..20675fa78f4fbd1648ed148905c50c1bc840124d --- /dev/null +++ b/CMakeModules/VISPCRTLinkage.cmake @@ -0,0 +1,44 @@ +if(NOT MSVC) + message(FATAL_ERROR "CRT options are available only for MSVC") +endif() + +if(NOT BUILD_SHARED_LIBS AND BUILD_WITH_STATIC_CRT) + foreach(flag_var + CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE + CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO + CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) + if(${flag_var} MATCHES "/MD") + string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") + endif() + if(${flag_var} MATCHES "/MDd") + string(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}") + endif() + endforeach(flag_var) + + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcrtd.lib") + set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib") + set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libcmtd.lib") +else() + foreach(flag_var + CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE + CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO + CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) + if(${flag_var} MATCHES "/MT") + string(REGEX REPLACE "/MT" "/MD" ${flag_var} "${${flag_var}}") + endif() + if(${flag_var} MATCHES "/MTd") + string(REGEX REPLACE "/MTd" "/MDd" ${flag_var} "${${flag_var}}") + endif() + endforeach(flag_var) +endif() + +if(NOT ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 2.8 AND NOT ${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} LESS 8.6) + include(ProcessorCount) + ProcessorCount(N) + if(NOT N EQUAL 0) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP${N} ") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP${N} ") + endif() +endif() diff --git a/CMakeModules/VISPConfig.cmake.in b/CMakeModules/VISPConfig.cmake.in index bb63a359090a135effc79aa8900c08bc2afe3ff0..15db8bbe042fdf442836846f4eee927291553d96 100644 --- a/CMakeModules/VISPConfig.cmake.in +++ b/CMakeModules/VISPConfig.cmake.in @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: VISPConfig.cmake.in 4221 2013-04-17 10:13:34Z fspindle $ +# $Id: VISPConfig.cmake.in 4616 2014-01-24 18:43:25Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 @@ -33,34 +33,37 @@ # Description: # CMake package config file for ViSP. # +# ** File generated automatically, do not modify ** +# # This file will define the following CMake variables: # VISP_ROOT_DIR : ViSP base directory location # VISP_INCLUDE_DIRS : ViSP and third-party headers location -# VISP_LIBRARY_DIRS : ViSP and third-party libraries location -# VISP_LIBRARY : ViSP library name -# VISP_LIBRARIES : ViSP and third-party libraries name -# VISP_DEFINITIONS : Defines required to build ViSP +# VISP_LIBRARY_DIRS : ViSP and third-party libraries location. Calling LINK_DIRECTORIES +# with this path is NOT needed under Unix. +# VISP_LIBNAME_DBG : ViSP library name when build in debug (libvisp.so, libvisp.a, vispd.dll, vispd.lib) +# VISP_LIBNAME_OPT : ViSP library name when build in release (libvisp.so, libvisp.a, visp.dll, visp.lib) # -# VISP_SOURCE_DIR : Location of ViSP source code +# VISP_LIBRARIES : ViSP and third-party libraries to link against. +# VISP_DEFINITIONS : Defines used to build ViSP. Calling ADD_DEFINITIONS with this +# variable is not needed. # -# VISP_VERSION_STRING : Full ViSP version, eg 2.6.1 +# VISP_VERSION_STRING : Full ViSP version, eg 2.9.0 # VISP_VERSION_MAJOR : Major version part of VISP_VERSION, eg 2. -# VISP_VERSION_MINOR : Minor version part of VISP_VERSION, eg 6. -# VISP_VERSION_PATCH : Patch version part of VISP_VERSION, eg 1. +# VISP_VERSION_MINOR : Minor version part of VISP_VERSION, eg 9. +# VISP_VERSION_PATCH : Patch version part of VISP_VERSION, eg 0. # # Typical usage in user project: -# FIND_PACKAGE(VISP) -# IF (VISP_FOUND) -# INCLUDE(${VISP_USE_FILE}) -# ENDIF (VISP_FOUND) +# find_package(VISP) +# add_definitions(${VISP_DEFINITIONS}) +# link_directories(${VISP_LIBRARY_DIRS}) +# include_directories(${VISP_INCLUDE_DIRS}) +# target_link_libraries(MY_TARGET_NAME ${VISP_LIBRARIES}) # # Authors: # Fabien Spindler # ############################################################################# -SET(VISP_LIBRARY "@VISP_INTERN_LIBRARY@") - # Set VISP_ROOT_DIR SET(VISP_ROOT_DIR "@VISP_ROOT_DIR_CONFIGCMAKE@") #MESSAGE("VISP_ROOT_DIR: ${VISP_ROOT_DIR}") @@ -93,6 +96,7 @@ ENDFOREACH(val ${VISP_EXTERN_INCLUDE_DIRS}) # Tells the user project where to find ViSP library SET(VISP_LIBRARY_DIRS "${VISP_ROOT_DIR}/@CMAKE_INSTALL_LIBDIR@" CACHE FILEPATH "Location of ViSP library") +#MESSAGE("VISP_LIBRARY_DIRS: ${VISP_LIBRARY_DIRS}") # Tells the user project where to find third party libraries used to # compile ViSP @@ -103,17 +107,22 @@ FOREACH(val ${VISP_EXTERN_LINK_DIR}) ENDFOREACH(val ${VISP_EXTERN_LINK_DIR}) #MESSAGE("VISP_LIBRARY_DIRS: ${VISP_LIBRARY_DIRS}") -# export source dir for doxygen eventually -SET(VISP_SOURCE_DIR "@VISP_SOURCE_DIR@") +# Set the full library name for debug and release +set(VISP_LIBNAME_DBG "@VISP_LIBNAME_DBG@") +set(VISP_LIBNAME_OPT "@VISP_LIBNAME_OPT@") # Tells the user project ViSP library name -SET(VISP_LIBRARIES debug "@VISP_INTERN_LIBRARY@@CMAKE_DEBUG_POSTFIX@" optimized "@VISP_INTERN_LIBRARY@") +if(UNIX) + set(VISP_LIBRARIES debug ${VISP_ROOT_DIR}/@CMAKE_INSTALL_LIBDIR@/${VISP_LIBNAME_DBG} optimized ${VISP_ROOT_DIR}/@CMAKE_INSTALL_LIBDIR@/${VISP_LIBNAME_OPT}) +else() + set(VISP_LIBRARIES debug "@VISP_INTERN_LIBRARY@@CMAKE_DEBUG_POSTFIX@" optimized "@VISP_INTERN_LIBRARY@") +endif() # Tells the user project libraries name used to build ViSP library SET(VISP_EXTERN_LIBRARIES "@VISP_EXTERN_LIBRARIES@") FOREACH(val ${VISP_EXTERN_LIBRARIES}) LIST(APPEND VISP_LIBRARIES "${val}") -ENDFOREACH(val ${VISP_EXTERN_LIBRARIES}) +ENDFOREACH() #MESSAGE("VISP_LIBRARIES: ${VISP_LIBRARIES}") # where to find the USE file to be used by user project @@ -129,10 +138,22 @@ IF(BUILD_TEST_COVERAGE) ENDIF(BUILD_TEST_COVERAGE) -# -# Remember VISP' third party libs configuration: -# +#---------------------------------------------------------------------- +# Add CXX flags used in ViSP that should be also used when ViSP is a 3rd party +#---------------------------------------------------------------------- +set(VISP_OPENMP_FLAGS "@VISP_OPENMP_FLAGS@") +if(VISP_OPENMP_FLAGS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${VISP_OPENMP_FLAGS}") +endif() +set(VISP_CPP11_FLAGS "@VISP_CPP11_FLAGS@") +if(VISP_CPP11_FLAGS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${VISP_CPP11_FLAGS}") +endif() + +#---------------------------------------------------------------------- +# Remember VISP' third party libs configuration: +#---------------------------------------------------------------------- SET(VISP_HAVE_X11 "@VISP_HAVE_X11@") SET(VISP_HAVE_PTHREAD "@VISP_HAVE_PTHREAD@") SET(VISP_HAVE_GTK "@VISP_HAVE_GTK@") @@ -157,7 +178,6 @@ SET(VISP_HAVE_QT "@VISP_HAVE_QT@") SET(VISP_HAVE_SOQT "@VISP_HAVE_SOQT@") SET(VISP_HAVE_SOWIN "@VISP_HAVE_SOWIN@") SET(VISP_HAVE_SOXT "@VISP_HAVE_SOXT@") -SET(VISP_HAVE_DC1394_1 "@VISP_HAVE_DC1394_1@") SET(VISP_HAVE_DC1394_2 "@VISP_HAVE_DC1394_2@") SET(VISP_HAVE_CMU1394 "@VISP_HAVE_CMU1394@") SET(VISP_HAVE_V4L2 "@VISP_HAVE_V4L2@") @@ -168,9 +188,6 @@ SET(VISP_HAVE_BICLOPS "@VISP_HAVE_BICLOPS@") SET(VISP_HAVE_PTU46 "@VISP_HAVE_PTU46@") SET(VISP_HAVE_VIPER650 "@VISP_HAVE_VIPER650@") SET(VISP_HAVE_VIPER850 "@VISP_HAVE_VIPER850@") -SET(VISP_HAVE_CYCAB "@VISP_HAVE_CYCAB@") -SET(VISP_HAVE_CYCABTK "@VISP_HAVE_CYCABTK@") -SET(VISP_HAVE_CYCABTK_OLD "@VISP_HAVE_CYCABTK_OLD@") SET(VISP_HAVE_PIONEER "@VISP_HAVE_PIONEER@") SET(VISP_HAVE_PARPORT "@VISP_HAVE_PARPORT@") SET(VISP_HAVE_XML2 "@VISP_HAVE_XML2@") @@ -181,3 +198,34 @@ SET(VISP_HAVE_YARP "@VISP_HAVE_YARP@") SET(VISP_HAVE_OPENMP "@VISP_HAVE_OPENMP@") SET(VISP_HAVE_ACCESS_TO_NAS "@VISP_HAVE_ACCESS_TO_NAS@") SET(VISP_HAVE_CPP11_COMPATIBILITY "@VISP_HAVE_CPP11_COMPATIBILITY@") + +#---------------------------------------------------------------------- +# Some useful macro to be able to build the tutorials along side ViSP +#---------------------------------------------------------------------- +# Create a target from the *.cpp file, link against ViSP libraries and add a dependency to ViSP library +# tu ensure that the library is build before this target. +macro(visp_add_target file_cpp) + get_filename_component(target ${file_cpp} NAME_WE) + include_directories(${VISP_INCLUDE_DIRS}) + if(VISP_LIBRARY_DIRS) + # should be called before add_executable() + link_directories(${VISP_LIBRARY_DIRS}) + endif() + add_executable(${target} ${file_cpp}) + target_link_libraries(${target} ${VISP_LIBRARIES}) + if(VISP_INTERN_LIBRARY) + add_dependencies(${target} ${VISP_INTERN_LIBRARY}) + endif() +endmacro() + +# Copy the data files to the same location than the target associated to the cpp files +macro(visp_copy_data file_cpp file_data) + get_filename_component(target ${file_cpp} NAME_WE) + get_target_property(target_location ${target} LOCATION) + get_filename_component(target_location "${target_location}" PATH) + add_custom_command( + TARGET ${target} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy "${file_data}" "${target_location}" + ) +endmacro() diff --git a/CMakeModules/VISPUse.cmake.in b/CMakeModules/VISPUse.cmake.in index 0d04dd8495a745655f60ff2992cc8a3413ff0137..aeeaa405564181411e33c3c3eee4b34af523433b 100644 --- a/CMakeModules/VISPUse.cmake.in +++ b/CMakeModules/VISPUse.cmake.in @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: VISPUse.cmake.in 4057 2013-01-05 13:10:29Z fspindle $ +# $Id: VISPUse.cmake.in 4616 2014-01-24 18:43:25Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 @@ -38,10 +38,6 @@ # ############################################################################# -# Add extra build flags to be able to consider especially for OpenMP -list(APPEND CMAKE_CXX_FLAGS "@VISP_OPENMP_FLAGS@") -list(APPEND CMAKE_CXX_FLAGS "@VISP_CPP11_FLAGS@") - # Remove duplicates compilation flags separate_arguments(CMAKE_CXX_FLAGS) list(REMOVE_DUPLICATES CMAKE_CXX_FLAGS) @@ -58,6 +54,5 @@ ADD_DEFINITIONS(${VISP_DEFINITIONS}) # Tell the compiler where to find ViSP's libraries # and the third party libraries we depend on LINK_DIRECTORIES(${VISP_LIBRARY_DIRS}) - LINK_LIBRARIES(${VISP_LIBRARIES}) diff --git a/CMakeModules/checkForItifg8Version.cpp b/CMakeModules/checkForItifg8Version.cpp deleted file mode 100644 index 8a96303c8a23a4caef18936cf0f50ab5f81c7188..0000000000000000000000000000000000000000 --- a/CMakeModules/checkForItifg8Version.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <stdlib.h> - -#include <itifgExt.h> -#include <libitifg.h> - - -int main() -{ - struct iti_setup_t setup; - char file_name[FILENAME_MAX]; - int error; - int version = 0; - - strcpy (file_name, ITI_PFS_PREFIX); - strcat (file_name, ITI_PFS_STRING); - - if ((error = iti_parse_info (file_name, &setup))) - { - switch (error) - { - case -ITI_EARG: - fprintf (stderr, "read_procfs: Wrong call argument\n" - "(file_name:%s, setup%p).\n", file_name, &setup); - exit (-1); - break; - case -ITI_EFMT: - fprintf (stderr, "read_procfs: Wrong data format (%s%s).\n", - ITI_PFS_PREFIX, ITI_PFS_STRING); - exit (-1); - break; - case -ITI_EENT: - fprintf (stderr, "read_procfs: File not found (%s%s).\n", - ITI_PFS_PREFIX, ITI_PFS_STRING); - exit (-1); - break; - case -ITI_ESYS: - fprintf (stderr, "read_procfs: Error while system call (%s).\n", - strerror (errno)); - exit (-1); - break; - default: - fprintf (stderr, "read_procfs: Error not specified!\n"); - exit (-1); - } - } -// fprintf (stderr, "Driver version %0x = %d: %d.%d.%d-%d.\n", -// setup.version, setup.version, -// (setup.version & 0xFF000000) >> 24, -// (setup.version & 0x00FF0000) >> 16, -// (setup.version & 0x0000FF00) >> 8, -// setup.version & 0x000000FF); - - int major = (setup.version & 0xFF000000) >> 24; - int minor = (setup.version & 0x00FF0000) >> 16; - - return (major*10 + minor); - -} diff --git a/CMakeModules/cmake_uninstall.cmake.in b/CMakeModules/cmake_uninstall.cmake.in index e788ba1d63b87fe1f239a070998195aceafd4d87..fb9072b671d2bdb00d0560539f6247c29976c411 100644 --- a/CMakeModules/cmake_uninstall.cmake.in +++ b/CMakeModules/cmake_uninstall.cmake.in @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: cmake_uninstall.cmake.in 4057 2013-01-05 13:10:29Z fspindle $ +# $Id: cmake_uninstall.cmake.in 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/CMakeModules/resources.cfg.in b/CMakeModules/resources.cfg.in index 759b13ad465d4bd33af6c33000af957a78ea79ef..64f2524579d1f88fbccbf6799e923fb487f2c3d3 100755 --- a/CMakeModules/resources.cfg.in +++ b/CMakeModules/resources.cfg.in @@ -1,11 +1,11 @@ # Resources required by the sample browser and most samples. [Essential] -Zip=@OGRE_MEDIA_DIR@/packs/SdkTrays.zip +#Zip=@OGRE_MEDIA_DIR@/packs/SdkTrays.zip # Resource locations to be added to the default path [General] FileSystem=@OGRE_MEDIA_DIR@ -FileSystem=@OGRE_MEDIA_DIR@/materials/programs +#FileSystem=@OGRE_MEDIA_DIR@/materials/programs FileSystem=@OGRE_MEDIA_DIR@/materials/scripts FileSystem=@OGRE_MEDIA_DIR@/materials/textures FileSystem=@OGRE_MEDIA_DIR@/models diff --git a/CMakeModules/visp-config.bat.in b/CMakeModules/visp-config.bat.in index d75e3b1c091bdab18078e4f1cf2a27846def4e45..62209e74f1b365a2a328ea14effd10b0def22c93 100755 --- a/CMakeModules/visp-config.bat.in +++ b/CMakeModules/visp-config.bat.in @@ -1,9 +1,9 @@ @rem ############################################################################# @rem # -@rem # $Id: visp-config.bat.in 4057 2013-01-05 13:10:29Z fspindle $ +@rem # $Id: visp-config.bat.in 4574 2014-01-09 08:48:51Z fspindle $ @rem # @rem # This file is part of the ViSP software. -@rem # Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +@rem # Copyright (C) 2005 - 2014 by INRIA. All rights reserved. @rem # @rem # This software is free software; you can redistribute it and/or @rem # modify it under the terms of the GNU General Public License @@ -106,7 +106,7 @@ for %%a in (%*) do ( if "%%a" == "--version" ( echo ViSP %VERSION% Visual Servoing Platform echo. - echo Copyright 2005 - 2013 Inria. All rights reserved. + echo Copyright 2005 - 2014 Inria. All rights reserved. goto END ) if "%%a" == "--dumpversion" ( @@ -118,7 +118,7 @@ for %%a in (%*) do ( :USAGE echo ViSP %VERSION% (Visual Servoing Platform) -echo Copyright (C) 2005 - 2013 Inria. All rights reserved. +echo Copyright (C) 2005 - 2014 Inria. All rights reserved. echo. echo Usage: %0 [--prefix] [--def] [--include] [--openmp] [--libpath] echo [--libs-debug] [--libs-optimized] [--version] [--dumpversion] [--help] diff --git a/CMakeModules/visp-config.in b/CMakeModules/visp-config.in index 7d39279afa5219820cd7cd03c81c2bc97af637e7..317c434b233e9ee72aa848473aafe3284bd8f4dc 100755 --- a/CMakeModules/visp-config.in +++ b/CMakeModules/visp-config.in @@ -2,10 +2,10 @@ ############################################################################# # -# $Id: visp-config.in 4203 2013-04-08 16:56:12Z fspindle $ +# $Id: visp-config.in 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 @@ -61,7 +61,7 @@ usage() cat <<EOF ViSP $VERSION (Visual Servoing Platform) -Copyright (C) 2005 - 2013 Inria. All rights reserved. +Copyright (C) 2005 - 2014 Inria. All rights reserved. Usage: $0 [--prefix] [--cflags] [--libs] [--version] [--dumpversion] [--help] @@ -91,7 +91,7 @@ for arg in $@; do --version) echo "ViSP $VERSION (Visual Servoing Platform)" echo "" - echo "Copyright (C) 2005 - 2013 Inria. All rights reserved.";; + echo "Copyright (C) 2005 - 2014 Inria. All rights reserved.";; --dumpversion) echo $NO_NEWLINE_OPTION "$VERSION$NO_NEWLINE_CHARACTER";; *) usage; exit -1 ;; esac; diff --git a/CMakeModules/visp-config.install.in b/CMakeModules/visp-config.install.in index e797f269b7774e5d661c2014d257fe618f45cfbf..0376f5772dfaedb57bec78400f86b7ce9afc77ac 100755 --- a/CMakeModules/visp-config.install.in +++ b/CMakeModules/visp-config.install.in @@ -5,7 +5,7 @@ # $Id: visp-config.in 4057 2013-01-05 13:10:29Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 @@ -48,20 +48,20 @@ relpath=`(cd $relpath/..; pwd)` PREFIX=$relpath -CFLAGS="${VISP_CONFIG_CFLAGS_SCRIPT}" +#CFLAGS="${VISP_CONFIG_CFLAGS_SCRIPT}" -LIBS="${VISP_CONFIG_LIBS_SCRIPT}" +#LIBS="${VISP_CONFIG_LIBS_SCRIPT}" -VERSION="${VISP_VERSION}" +#VERSION="${VISP_VERSION}" -#CFLAGS_CMD=`pkg-config --cflags visp` -#CFLAGS=$CFLAGS_CMD +CFLAGS_CMD=`pkg-config --cflags visp` +CFLAGS=$CFLAGS_CMD -#LIBS_CMD=`pkg-config --libs visp` -#LIBS=$LIBS_CMD +LIBS_CMD=`pkg-config --libs visp` +LIBS=$LIBS_CMD -#VERSION_CMD=`pkg-config --modversion visp` -#VERSION=$VERSION_CMD +VERSION_CMD=`pkg-config --modversion visp` +VERSION=$VERSION_CMD NO_NEWLINE_CHARACTER="${VISP_ECHO_NO_NEWLINE_CHARACTER}" NO_NEWLINE_OPTION="${VISP_ECHO_NO_NEWLINE_OPTION}" @@ -71,7 +71,7 @@ usage() cat <<EOF ViSP $VERSION (Visual Servoing Platform) -Copyright (C) 2005 - 2013 Inria. All rights reserved. +Copyright (C) 2005 - 2014 Inria. All rights reserved. Usage: $0 [--prefix] [--cflags] [--libs] [--version] [--dumpversion] [--help] @@ -101,7 +101,7 @@ for arg in $@; do --version) echo "ViSP $VERSION (Visual Servoing Platform)" echo "" - echo "Copyright (C) 2005 - 2013 Inria. All rights reserved.";; + echo "Copyright (C) 2005 - 2014 Inria. All rights reserved.";; --dumpversion) echo $NO_NEWLINE_OPTION "$VERSION$NO_NEWLINE_CHARACTER";; *) usage; exit -1 ;; esac; diff --git a/CMakeModules/visp.pc.in b/CMakeModules/visp.pc.in index 93ab39cf8b30ec9964d63dd61d6e338c4baa07c2..4594265e00382b6e78d5b5a3288dcb5e4f069ffc 100644 --- a/CMakeModules/visp.pc.in +++ b/CMakeModules/visp.pc.in @@ -7,7 +7,7 @@ includedir=@includedir@ Name: ViSP Description: Visual Servoing Platform -URL: http://www.irisa.fr/lagadic/visp +URL: http://team.inria.fr/lagadic/visp Version: ${VISP_VERSION} Libs: ${VISP_CONFIG_LIBS_PC} diff --git a/CMakeSourceFileList.cmake b/CMakeSourceFileList.cmake index b8e8a55ecdefaf3692c192cdc15132be1867bd4c..c7734ee463f14816a8c55884658c53d4a75ef214 100644 --- a/CMakeSourceFileList.cmake +++ b/CMakeSourceFileList.cmake @@ -3,7 +3,7 @@ # $Id: CMakeSourceFileList.cmake,v 1.29 2008-12-17 14:45:01 fspindle Exp $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 @@ -81,9 +81,6 @@ SET (SRC_DEVICE_FRAMEGRABBER device/framegrabber/disk/vpDiskGrabber.cpp ) -IF(VISP_HAVE_DC1394_1) - LIST(APPEND SRC_DEVICE_FRAMEGRABBER device/framegrabber/1394/vp1394Grabber.cpp) -ENDIF() IF(VISP_HAVE_DC1394_2) LIST(APPEND SRC_DEVICE_FRAMEGRABBER device/framegrabber/1394/vp1394TwoGrabber.cpp) ENDIF() @@ -216,9 +213,6 @@ IF(VISP_HAVE_BICLOPS) LIST(APPEND SRC_ROBOT robot/real-robot/biclops/vpRobotBiclopsController.cpp) LIST(APPEND SRC_ROBOT robot/real-robot/biclops/vpRobotBiclops.cpp) ENDIF() -IF(VISP_HAVE_CYCAB) - LIST(APPEND SRC_ROBOT robot/real-robot/cycab/vpRobotCycab.cpp) -ENDIF() IF(VISP_HAVE_PTU46) LIST(APPEND SRC_ROBOT robot/real-robot/ptu46/vpRobotPtu46.cpp) ENDIF() @@ -233,7 +227,6 @@ IF(VISP_HAVE_VIPER850) ENDIF() SET (SRC_SERVO - servo/vpAdaptativeGain.cpp servo/vpAdaptiveGain.cpp servo/vpServo.cpp servo/vpServoData.cpp @@ -343,12 +336,33 @@ SET (SRC_TRACKING tracking/moments/vpMomentGravityCenter.cpp tracking/moments/vpMomentGravityCenterNormalized.cpp tracking/moments/vpMomentObject.cpp + + tracking/template-tracker/vpTemplateTracker.cpp + tracking/template-tracker/ssd/vpTemplateTrackerSSD.cpp + tracking/template-tracker/ssd/vpTemplateTrackerSSDESM.cpp + tracking/template-tracker/ssd/vpTemplateTrackerSSDForwardAdditional.cpp + tracking/template-tracker/ssd/vpTemplateTrackerSSDForwardCompositional.cpp + tracking/template-tracker/ssd/vpTemplateTrackerSSDInverseCompositional.cpp + tracking/template-tracker/zncc/vpTemplateTrackerZNCC.cpp + tracking/template-tracker/zncc/vpTemplateTrackerZNCCForwardAdditional.cpp + tracking/template-tracker/zncc/vpTemplateTrackerZNCCInverseCompositional.cpp + tracking/template-tracker/tools/vpTemplateTrackerBSpline.cpp + tracking/template-tracker/tools/vpTemplateTrackerZone.cpp + tracking/template-tracker/tools/vpTemplateTrackerTriangle.cpp + tracking/template-tracker/warp/vpTemplateTrackerWarp.cpp + tracking/template-tracker/warp/vpTemplateTrackerWarpAffine.cpp + tracking/template-tracker/warp/vpTemplateTrackerWarpHomography.cpp + tracking/template-tracker/warp/vpTemplateTrackerWarpHomographySL3.cpp + tracking/template-tracker/warp/vpTemplateTrackerWarpSRT.cpp + tracking/template-tracker/warp/vpTemplateTrackerWarpTranslation.cpp ) -IF(VISP_HAVE_XML2) - LIST(APPEND SRC_TRACKING tracking/mbt/edge/vpMbtXmlParser.cpp) - LIST(APPEND SRC_TRACKING tracking/mbt/klt/vpMbtKltXmlParser.cpp) -ENDIF() +if(VISP_HAVE_XML2) + list(APPEND SRC_TRACKING tracking/mbt/vpMbXmlParser.cpp) + list(APPEND SRC_TRACKING tracking/mbt/edge/vpMbtXmlParser.cpp) + list(APPEND SRC_TRACKING tracking/mbt/klt/vpMbtKltXmlParser.cpp) + list(APPEND SRC_TRACKING tracking/mbt/hybrid/vpMbtEdgeKltXmlParser.cpp) +endif() IF(VISP_HAVE_OPENCV) LIST(APPEND SRC_TRACKING tracking/klt/vpKltOpencv.cpp) diff --git a/CTestConfig.cmake b/CTestConfig.cmake index 1a01ddb6ae67d6283af3cdad7a70b46ad27aa9b1..5496d5485b57b76b5f11d571af62dfc81fc867bc 100644 --- a/CTestConfig.cmake +++ b/CTestConfig.cmake @@ -3,7 +3,7 @@ # $Id: CTestConfig.cmake,v 1.9 2008-12-11 13:19:44 fspindle Exp $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 @@ -72,6 +72,8 @@ elseif(MSVC10) set(BUILDNAME "${BUILDNAME}-msvc10") elseif(MSVC11) set(BUILDNAME "${BUILDNAME}-msvc11") +elseif(MSVC12) + set(BUILDNAME "${BUILDNAME}-msvc12") elseif(MSVC) set(BUILDNAME "${BUILDNAME}-msvc") elseif(BORLAND) @@ -141,10 +143,6 @@ endif() IF(VISP_HAVE_DC1394_2) SET(BUILDNAME "${BUILDNAME}-dc1394.2") ENDIF(VISP_HAVE_DC1394_2) -# Firewire dc1394-1.x -IF(VISP_HAVE_DC1394_1) - SET(BUILDNAME "${BUILDNAME}-dc1394.1") -ENDIF(VISP_HAVE_DC1394_1) # Video 4 linux 2 (V4L2) IF(VISP_HAVE_V4L2) SET(BUILDNAME "${BUILDNAME}-v4l2") diff --git a/ChangeLog b/ChangeLog index 5a19e429a68ef8d49976c0bcbc858b4313985e92..259376ef56cb0d3f8ab842f0ba3e34a5f968eb8e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,10 +2,57 @@ Visual Servoing Platform Resume of the change log - Copyright Projet Lagadic / IRISA-INRIA Rennes, 2005-2013 - http://www.irisa.fr/lagadic + Copyright Projet Lagadic / IRISA-INRIA Rennes, 2005 - 2014 + http://team.inria.fr/lagadic +ViSP 2.9.0 (released February 18th, 2014) + - New features + . Introduction of a new template tracker using SSD (vpTemplateTrackerSSD + classes) or ZNCC (vpTemplateTrackerZNCC classes). These trackers are able + to estimate 2D transformations such as translation, SRT (scale, rotation + and translation), affine and homography. A video + illustrating this tracker capabilities is available on: + http://team.inria.fr/lagadic/visp/computer-vision.html + . In vpServo introduction of a new controller able to ensure continuous + sequencing + - Improvements + . Add missing const to member functions and arguments passed by reference. + . Introduction of a new option BUILD_WITH_STATIC_CRT that allows to set + /MT (default) or /MD msvc build option + . Compatibility with mingw, msvc11 (2012), msvc12 (2013) + and open solaris 11 + . Trace and debug can now be enabled/disabled using CMake + ACTIVATE_DEBUG_TRACE option + . Fix errors detected by Covery Scan static code analyser + . Fix warnings detected with Gnu g++ -Weffc++ -Wshadow compiler flags + . Improve a lot of classes + - New examples + . New example that shows how to use the template tracker + . A lot of new sample code provided in tutorial folder + - New tutorials + . Installation from source on Linux Fedora + . Image filtering + . Template tracking + . Homography estimation from points + . Keypoint matching + . How to boost your visual servo control law + . Debug and trace printings + - Bug fixed + . [16263] libopencv_nonfree for Surf not detected by CMake. + . [16307] vpVideoReader::setLastFrameIndex() doesn't work. + . [16371] No convergence in SVDcmp + . [16465] FTBFS on armhf, ppc, s390: Errors while running CTest + . [16696] Build with OpenCV fails with msvc (/MT conflicts with /MD) + . [16781] Unable to open .pgm saved with Matlab imwrite + . [16823] Problems with camera calibration code + . [16889] Link error with CMU 1394 on win x64 arch + . [16895] undefined reference to `vpGaussRand::gaussianDraw()' + . [16919] Unable to link with OpenCV 2.4.8 under Windows + . [16924] MinGW: unable to build ViSP as a shared library + . [16928] vpVideoReader is unable to find the number of the first image + from a generic sequence of images +---------------------------------------------- ViSP 2.8.0 (released July 24th, 2013) - New features . New camera calibration tool: example/camera_calibration.cpp diff --git a/INSTALL.txt b/INSTALL.txt index e5d7bb24e3176fb3816fd22711b53e58e1547441..f39d4f03891e6dafe5c70757faa11b6612c3067b 100644 --- a/INSTALL.txt +++ b/INSTALL.txt @@ -1,7 +1,7 @@ ViSP-2.7.0 Visual Servoing Platform - Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + Copyright (C) 2005 - 2014 by INRIA. All rights reserved. www: http://www.irisa.fr/lagadic diff --git a/README.txt b/README.txt index 39ca54d415303f365dd0a09c6cfaccf05e36afd6..dbe8a69613a385b746453c0b825cd774b34537c4 100644 --- a/README.txt +++ b/README.txt @@ -1,7 +1,7 @@ ViSP-2.7.0 Visual Servoing Platform - Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + Copyright (C) 2005 - 2014 by INRIA. All rights reserved. www: http://www.irisa.fr/lagadic diff --git a/ViSP-third-party.txt.cmake b/ViSP-third-party.txt.cmake index 7bcfbfb89840d86c3b3419c38fde112a8f68aa00..3b539d6a130bbc00b33a0d58fbf3a2c24e3edc73 100644 --- a/ViSP-third-party.txt.cmake +++ b/ViSP-third-party.txt.cmake @@ -25,15 +25,13 @@ Robots Pioneer : ${VISP_HAVE_PIONEER_FOUND} Viper S650 : ${VISP_HAVE_VIPER650_FOUND} Viper S850 : ${VISP_HAVE_VIPER850_FOUND} - Cycab : ${VISP_HAVE_CYCAB_FOUND} -Video devices (display) +Video devices (display) X11 : ${VISP_HAVE_X11_FOUND} GTK : ${VISP_HAVE_GTK_FOUND} OpenCV : ${VISP_HAVE_OPENCV_FOUND} GDI : ${VISP_HAVE_GDI_FOUND} Direct3D : ${VISP_HAVE_D3D9_FOUND} Framegrabbers - Firewire libdc1394-1.x : ${VISP_HAVE_DC1394_1_FOUND} Firewire libdc1394-2.x : ${VISP_HAVE_DC1394_2_FOUND} Video For Linux Two : ${VISP_HAVE_V4L2_FOUND} DirectShow : ${VISP_HAVE_DIRECTSHOW_FOUND} diff --git a/data/ogre-simulator/media/materials/scripts/Examples.material b/data/ogre-simulator/media/materials/scripts/Examples.material new file mode 100644 index 0000000000000000000000000000000000000000..306da3ee015b3f7b9316bc41bbb456ca5d5ca4a6 --- /dev/null +++ b/data/ogre-simulator/media/materials/scripts/Examples.material @@ -0,0 +1,33 @@ + + +material Examples/Robot +{ + // Software blending technique + technique + { + pass + { + + texture_unit + { + texture r2skin.jpg + } + } + } +} + +material Examples/GrassFloor +{ + technique + { + pass + { + texture_unit + { + texture grass_1024.jpg + } + } + } +} + + diff --git a/data/ogre-simulator/media/materials/textures/grass_1024.jpg b/data/ogre-simulator/media/materials/textures/grass_1024.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e65691b3ade1d22b29624f885015865c6d3aa4b6 Binary files /dev/null and b/data/ogre-simulator/media/materials/textures/grass_1024.jpg differ diff --git a/data/ogre-simulator/media/materials/textures/r2skin.jpg b/data/ogre-simulator/media/materials/textures/r2skin.jpg new file mode 100644 index 0000000000000000000000000000000000000000..3e83a1246c0ee2f665e7b6df2ee92313e7ad2681 Binary files /dev/null and b/data/ogre-simulator/media/materials/textures/r2skin.jpg differ diff --git a/data/ogre-simulator/media/models/robot.mesh b/data/ogre-simulator/media/models/robot.mesh new file mode 100644 index 0000000000000000000000000000000000000000..a191498e89d75db3c3509f56abdbd03af7bc002e Binary files /dev/null and b/data/ogre-simulator/media/models/robot.mesh differ diff --git a/data/ogre-simulator/media/models/robot.skeleton b/data/ogre-simulator/media/models/robot.skeleton new file mode 100644 index 0000000000000000000000000000000000000000..0aa8bde538159fee69f9f86311d4191f0821bf9b Binary files /dev/null and b/data/ogre-simulator/media/models/robot.skeleton differ diff --git a/demo/CMakeLists.txt b/demo/CMakeLists.txt index 9793b560ad0c1f5ce9771ed8ec5a58dda1f1a5c6..b5531f130819f2ba2be080226bf9e5973e2a75b0 100644 --- a/demo/CMakeLists.txt +++ b/demo/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/demo/wireframe-simulator/CMakeLists.txt b/demo/wireframe-simulator/CMakeLists.txt index 2455aded1e09b30a756e37d992a96b233dd95237..4fa6ebe6ed693bf5549b32e92ba86e247533bc26 100644 --- a/demo/wireframe-simulator/CMakeLists.txt +++ b/demo/wireframe-simulator/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/demo/wireframe-simulator/servoSimu4Points.cpp b/demo/wireframe-simulator/servoSimu4Points.cpp index 7436e7d401edcd29843d3b22b39fa7e37bbb6fe5..cfb205078a4b9e7af9715c43917bf3505f7bdd44 100644 --- a/demo/wireframe-simulator/servoSimu4Points.cpp +++ b/demo/wireframe-simulator/servoSimu4Points.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoSimu4Points.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: servoSimu4Points.cpp 4659 2014-02-09 14:11:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -71,6 +71,9 @@ #ifdef VISP_HAVE_DISPLAY +void usage(const char *name, std::string ipath, const char *badparam); +bool getOptions(int argc, const char **argv, std::string &ipath, bool &display); + /*! Print the program options. @@ -132,17 +135,17 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv, std::string &ipath, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { - case 'i': ipath = optarg; break; + case 'i': ipath = optarg_; break; case 'd': display = false; break; case 'h': usage(argv[0],ipath, NULL); return false; break; default: - usage(argv[0],ipath, optarg); + usage(argv[0],ipath, optarg_); return false; break; } } @@ -151,7 +154,7 @@ bool getOptions(int argc, const char **argv, std::string &ipath, bool &display) // standalone param or error usage(argv[0], ipath, NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -162,36 +165,35 @@ bool getOptions(int argc, const char **argv, std::string &ipath, bool &display) int main(int argc, const char ** argv) { - bool opt_display = true; - std::string opt_ipath; - std::string env_ipath; - std::string ipath ; - std::string filename; - - // Read the command line options - if (getOptions(argc, argv, opt_ipath, opt_display) == false) { - exit (-1); - } - - vpImage<vpRGBa> Iint(480,640,255); - vpImage<vpRGBa> Iext1(480,640,255); - vpImage<vpRGBa> Iext2(480,640,255); + try { + bool opt_display = true; + std::string opt_ipath; + std::string env_ipath; + std::string ipath ; + std::string filename; + + // Read the command line options + if (getOptions(argc, argv, opt_ipath, opt_display) == false) { + exit (-1); + } + + vpImage<vpRGBa> Iint(480,640,255); + vpImage<vpRGBa> Iext1(480,640,255); + vpImage<vpRGBa> Iext2(480,640,255); #if defined VISP_HAVE_X11 - vpDisplayX display[3]; + vpDisplayX display[3]; #elif defined VISP_HAVE_OPENCV - vpDisplayOpenCV display[3]; + vpDisplayOpenCV display[3]; #elif defined VISP_HAVE_GDI - vpDisplayGDI display[3]; + vpDisplayGDI display[3]; #elif defined VISP_HAVE_D3D9 - vpDisplayD3D display[3]; + vpDisplayD3D display[3]; #elif defined VISP_HAVE_GTK - vpDisplayGTK display[3]; + vpDisplayGTK display[3]; #endif - - if (opt_display) - { - try + + if (opt_display) { // Display size is automatically defined by the image (I) size display[0].init(Iint, 100, 100,"The internal view") ; @@ -207,236 +209,146 @@ main(int argc, const char ** argv) vpDisplay::display(Iext2); vpDisplay::flush(Iext2); } - catch(...) - { - vpERROR_TRACE("Error while displaying the image") ; - exit(-1); - } - } - vpServo task; - vpSimulatorCamera robot ; - float sampling_time = 0.040f; // Sampling period in second - robot.setSamplingTime(sampling_time); - - // Since the task gain lambda is very high, we need to increase default max velocities - robot.setMaxTranslationVelocity(10); - robot.setMaxRotationVelocity(vpMath::rad(180)); - - // Set initial position of the object in the camera frame - vpHomogeneousMatrix cMo(0,0.1,2.0,vpMath::rad(35),vpMath::rad(25),0); - // Set desired position of the object in the camera frame - vpHomogeneousMatrix cdMo(0.0,0.0,1.0,vpMath::rad(0),vpMath::rad(0),vpMath::rad(0)); - // Set initial position of the object in the world frame - vpHomogeneousMatrix wMo(0.0,0.0,0.2,0,0,0); - // Position of the camera in the world frame - vpHomogeneousMatrix wMc, cMw; - wMc = wMo * cMo.inverse(); - cMw = wMc.inverse(); - - //The four point used as visual features - vpPoint point[4] ; - point[0].setWorldCoordinates(-0.1,-0.1,0) ; - point[3].setWorldCoordinates(-0.1,0.1,0) ; - point[2].setWorldCoordinates(0.1,0.1,0) ; - point[1].setWorldCoordinates(0.1,-0.1,0) ; - - // Projection of the points - for (int i = 0 ; i < 4 ; i++) - point[i].track(cMo); - - //Set the current visual feature - vpFeaturePoint p[4]; - for (int i = 0 ; i < 4 ; i++) - vpFeatureBuilder::create(p[i], point[i]); - - // Projection of the points - for (int i = 0 ; i < 4 ; i++) - point[i].track(cdMo); - - vpFeaturePoint pd[4]; - for (int i = 0 ; i < 4 ; i++) - vpFeatureBuilder::create(pd[i], point[i]); - - task.setServo(vpServo::EYEINHAND_L_cVe_eJe); - task.setInteractionMatrixType(vpServo::DESIRED); - - vpHomogeneousMatrix cMe; // Identity - vpVelocityTwistMatrix cVe(cMe); - task.set_cVe(cVe); - - vpMatrix eJe; - robot.get_eJe(eJe); - task.set_eJe(eJe); - - for (int i = 0 ; i < 4 ; i++) - task.addFeature(p[i],pd[i]) ; - - task.setLambda(10); - - std::list<vpImageSimulator> list; - vpImageSimulator imsim; - - vpColVector X[4]; - for (int i = 0; i < 4; i++) X[i].resize(3); - X[0][0] = -0.2; - X[0][1] = -0.2; - X[0][2] = 0; - - X[1][0] = 0.2; - X[1][1] = -0.2; - X[1][2] = 0; - - X[2][0] = 0.2; - X[2][1] = 0.2; - X[2][2] = 0; - - X[3][0] = -0.2; - X[3][1] = 0.2; - X[3][2] = 0; - - char *ptenv = getenv("VISP_INPUT_IMAGE_PATH"); - if (ptenv != NULL) - env_ipath = ptenv; - - if (! env_ipath.empty()) - ipath = env_ipath; - - if (!opt_ipath.empty()) - ipath = opt_ipath; - - filename = ipath + vpIoTools::path("/ViSP-images/mire/mire.pgm"); - - try - { - imsim.init(filename.c_str(), X); - } - catch(...) - { - vpTRACE("You need the ViSP data "); - task.kill(); - return 1; - } - - list.push_back(imsim); - - vpWireFrameSimulator sim; - - // Set the scene - sim.initScene(vpWireFrameSimulator::PLATE, vpWireFrameSimulator::D_STANDARD,list); - - // Initialize simulator frames - sim.set_fMo( wMo ); // Position of the object in the world reference frame - sim.setCameraPositionRelObj(cMo) ; // initial position of the camera - sim.setDesiredCameraPosition(cdMo); // desired position of the camera - - // Set the External camera position - vpHomogeneousMatrix camMf(vpHomogeneousMatrix(0.0,0,3.5,vpMath::rad(0),vpMath::rad(30),0)); - sim.setExternalCameraPosition(camMf); - - //Computes the position of a camera which is fixed in the object frame - vpHomogeneousMatrix camoMf(0,0.0,1.5,0,vpMath::rad(140),0); - camoMf = camoMf*(sim.get_fMo().inverse()); - - //Set the parameters of the cameras (internal and external) - vpCameraParameters camera(1000,1000,320,240); - sim.setInternalCameraParameters(camera); - sim.setExternalCameraParameters(camera); - - int stop = 10; - - if (opt_display) - { - stop = 2500; - - //Get the internal and external views - sim.getInternalImage(Iint); - sim.getExternalImage(Iext1); - sim.getExternalImage(Iext2, camoMf); - - //Display the object frame (current and desired position) - vpDisplay::displayFrame(Iint,cMo,camera,0.2,vpColor::none); - vpDisplay::displayFrame(Iint,cdMo,camera,0.2,vpColor::none); - - //Display the object frame the world reference frame and the camera frame - vpDisplay::displayFrame(Iext1,camMf*sim.get_fMo()*cMo.inverse(),camera,0.2,vpColor::none); - vpDisplay::displayFrame(Iext1,camMf*sim.get_fMo(),camera,0.2,vpColor::none); - vpDisplay::displayFrame(Iext1,camMf,camera,0.2,vpColor::none); - - //Display the world reference frame and the object frame - vpDisplay::displayFrame(Iext2,camoMf,camera,0.2,vpColor::none); - vpDisplay::displayFrame(Iext2,camoMf*sim.get_fMo(),camera,0.05,vpColor::none); - - vpDisplay::flush(Iint); - vpDisplay::flush(Iext1); - vpDisplay::flush(Iext2); - - std::cout << "Click on a display" << std::endl; - while (!vpDisplay::getClick(Iint,false) && !vpDisplay::getClick(Iext1,false) && !vpDisplay::getClick(Iext2,false)){}; - } + vpServo task; + vpSimulatorCamera robot ; + float sampling_time = 0.040f; // Sampling period in second + robot.setSamplingTime(sampling_time); + + // Since the task gain lambda is very high, we need to increase default max velocities + robot.setMaxTranslationVelocity(10); + robot.setMaxRotationVelocity(vpMath::rad(180)); + + // Set initial position of the object in the camera frame + vpHomogeneousMatrix cMo(0,0.1,2.0,vpMath::rad(35),vpMath::rad(25),0); + // Set desired position of the object in the camera frame + vpHomogeneousMatrix cdMo(0.0,0.0,1.0,vpMath::rad(0),vpMath::rad(0),vpMath::rad(0)); + // Set initial position of the object in the world frame + vpHomogeneousMatrix wMo(0.0,0.0,0.2,0,0,0); + // Position of the camera in the world frame + vpHomogeneousMatrix wMc, cMw; + wMc = wMo * cMo.inverse(); + cMw = wMc.inverse(); + + //The four point used as visual features + vpPoint point[4] ; + point[0].setWorldCoordinates(-0.1,-0.1,0) ; + point[3].setWorldCoordinates(-0.1,0.1,0) ; + point[2].setWorldCoordinates(0.1,0.1,0) ; + point[1].setWorldCoordinates(0.1,-0.1,0) ; + + // Projection of the points + for (int i = 0 ; i < 4 ; i++) + point[i].track(cMo); - robot.setPosition( wMc ); - //Print the task - task.print() ; + //Set the current visual feature + vpFeaturePoint p[4]; + for (int i = 0 ; i < 4 ; i++) + vpFeatureBuilder::create(p[i], point[i]); - int iter = 0; - vpColVector v ; + // Projection of the points + for (int i = 0 ; i < 4 ; i++) + point[i].track(cdMo); - while(iter++ < stop) - { - if (opt_display) - { - vpDisplay::display(Iint) ; - vpDisplay::display(Iext1) ; - vpDisplay::display(Iext2) ; - } + vpFeaturePoint pd[4]; + for (int i = 0 ; i < 4 ; i++) + vpFeatureBuilder::create(pd[i], point[i]); + + task.setServo(vpServo::EYEINHAND_L_cVe_eJe); + task.setInteractionMatrixType(vpServo::DESIRED); - double t = vpTime::measureTimeMs(); + vpHomogeneousMatrix cMe; // Identity + vpVelocityTwistMatrix cVe(cMe); + task.set_cVe(cVe); - robot.get_eJe(eJe) ; - task.set_eJe(eJe) ; + vpMatrix eJe; + robot.get_eJe(eJe); + task.set_eJe(eJe); - robot.getPosition(wMc) ; - cMo = wMc.inverse() * wMo; for (int i = 0 ; i < 4 ; i++) - { - point[i].track(cMo) ; - vpFeatureBuilder::create(p[i],point[i]) ; - } + task.addFeature(p[i],pd[i]) ; + + task.setLambda(10); - v = task.computeControlLaw() ; - robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; - - //Compute the movement of the object around the world reference frame. - vpHomogeneousMatrix a(0, 0, 0.2, 0, 0, 0); - vpHomogeneousMatrix b(0, 0, 0, vpMath::rad(1.5*iter), 0, 0); - vpHomogeneousMatrix c(0, 0, 0, 0, vpMath::rad(2.5*iter), 0); + std::list<vpImageSimulator> list; + vpImageSimulator imsim; - // Move the object in the world frame - wMo = b*c*a; + vpColVector X[4]; + for (int i = 0; i < 4; i++) X[i].resize(3); + X[0][0] = -0.2; + X[0][1] = -0.2; + X[0][2] = 0; - sim.set_fMo( wMo ); //Move the object in the simulator - sim.setCameraPositionRelObj(cMo); + X[1][0] = 0.2; + X[1][1] = -0.2; + X[1][2] = 0; - //Compute the position of the external view which is fixed in the object frame - camoMf.buildFrom(0,0.0,1.5,0,vpMath::rad(150),0); + X[2][0] = 0.2; + X[2][1] = 0.2; + X[2][2] = 0; + + X[3][0] = -0.2; + X[3][1] = 0.2; + X[3][2] = 0; + + char *ptenv = getenv("VISP_INPUT_IMAGE_PATH"); + if (ptenv != NULL) + env_ipath = ptenv; + + if (! env_ipath.empty()) + ipath = env_ipath; + + if (!opt_ipath.empty()) + ipath = opt_ipath; + + filename = ipath + vpIoTools::path("/ViSP-images/mire/mire.pgm"); + + imsim.init(filename.c_str(), X); + + list.push_back(imsim); + + vpWireFrameSimulator sim; + + // Set the scene + sim.initScene(vpWireFrameSimulator::PLATE, vpWireFrameSimulator::D_STANDARD,list); + + // Initialize simulator frames + sim.set_fMo( wMo ); // Position of the object in the world reference frame + sim.setCameraPositionRelObj(cMo) ; // initial position of the camera + sim.setDesiredCameraPosition(cdMo); // desired position of the camera + + // Set the External camera position + vpHomogeneousMatrix camMf(vpHomogeneousMatrix(0.0,0,3.5,vpMath::rad(0),vpMath::rad(30),0)); + sim.setExternalCameraPosition(camMf); + + //Computes the position of a camera which is fixed in the object frame + vpHomogeneousMatrix camoMf(0,0.0,1.5,0,vpMath::rad(140),0); camoMf = camoMf*(sim.get_fMo().inverse()); + //Set the parameters of the cameras (internal and external) + vpCameraParameters camera(1000,1000,320,240); + sim.setInternalCameraParameters(camera); + sim.setExternalCameraParameters(camera); + + int stop = 10; + if (opt_display) { + stop = 2500; + //Get the internal and external views sim.getInternalImage(Iint); sim.getExternalImage(Iext1); - sim.getExternalImage(Iext2,camoMf); + sim.getExternalImage(Iext2, camoMf); //Display the object frame (current and desired position) vpDisplay::displayFrame(Iint,cMo,camera,0.2,vpColor::none); vpDisplay::displayFrame(Iint,cdMo,camera,0.2,vpColor::none); - //Display the camera frame, the object frame the world reference frame - vpDisplay::displayFrame(Iext1,sim.getExternalCameraPosition()*sim.get_fMo()*cMo.inverse(),camera,0.2,vpColor::none); - vpDisplay::displayFrame(Iext1,sim.getExternalCameraPosition()*sim.get_fMo(),camera,0.2,vpColor::none); - vpDisplay::displayFrame(Iext1,sim.getExternalCameraPosition(),camera,0.2,vpColor::none); + //Display the object frame the world reference frame and the camera frame + vpDisplay::displayFrame(Iext1,camMf*sim.get_fMo()*cMo.inverse(),camera,0.2,vpColor::none); + vpDisplay::displayFrame(Iext1,camMf*sim.get_fMo(),camera,0.2,vpColor::none); + vpDisplay::displayFrame(Iext1,camMf,camera,0.2,vpColor::none); //Display the world reference frame and the object frame vpDisplay::displayFrame(Iext2,camoMf,camera,0.2,vpColor::none); @@ -445,17 +357,97 @@ main(int argc, const char ** argv) vpDisplay::flush(Iint); vpDisplay::flush(Iext1); vpDisplay::flush(Iext2); + + std::cout << "Click on a display" << std::endl; + while (!vpDisplay::getClick(Iint,false) && !vpDisplay::getClick(Iext1,false) && !vpDisplay::getClick(Iext2,false)){}; } - vpTime::wait(t, sampling_time * 1000); // Wait 40 ms + robot.setPosition( wMc ); + //Print the task + task.print() ; - std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; - } + int iter = 0; + vpColVector v ; - task.print() ; - task.kill() ; + while(iter++ < stop) + { + if (opt_display) + { + vpDisplay::display(Iint) ; + vpDisplay::display(Iext1) ; + vpDisplay::display(Iext2) ; + } + + double t = vpTime::measureTimeMs(); + + robot.get_eJe(eJe) ; + task.set_eJe(eJe) ; + + robot.getPosition(wMc) ; + cMo = wMc.inverse() * wMo; + 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) ; + + //Compute the movement of the object around the world reference frame. + vpHomogeneousMatrix a(0, 0, 0.2, 0, 0, 0); + vpHomogeneousMatrix b(0, 0, 0, vpMath::rad(1.5*iter), 0, 0); + vpHomogeneousMatrix c(0, 0, 0, 0, vpMath::rad(2.5*iter), 0); + + // Move the object in the world frame + wMo = b*c*a; + + sim.set_fMo( wMo ); //Move the object in the simulator + sim.setCameraPositionRelObj(cMo); + + //Compute the position of the external view which is fixed in the object frame + camoMf.buildFrom(0,0.0,1.5,0,vpMath::rad(150),0); + camoMf = camoMf*(sim.get_fMo().inverse()); + + if (opt_display) + { + //Get the internal and external views + sim.getInternalImage(Iint); + sim.getExternalImage(Iext1); + sim.getExternalImage(Iext2,camoMf); + + //Display the object frame (current and desired position) + vpDisplay::displayFrame(Iint,cMo,camera,0.2,vpColor::none); + vpDisplay::displayFrame(Iint,cdMo,camera,0.2,vpColor::none); + + //Display the camera frame, the object frame the world reference frame + vpDisplay::displayFrame(Iext1,sim.getExternalCameraPosition()*sim.get_fMo()*cMo.inverse(),camera,0.2,vpColor::none); + vpDisplay::displayFrame(Iext1,sim.getExternalCameraPosition()*sim.get_fMo(),camera,0.2,vpColor::none); + vpDisplay::displayFrame(Iext1,sim.getExternalCameraPosition(),camera,0.2,vpColor::none); + + //Display the world reference frame and the object frame + vpDisplay::displayFrame(Iext2,camoMf,camera,0.2,vpColor::none); + vpDisplay::displayFrame(Iext2,camoMf*sim.get_fMo(),camera,0.05,vpColor::none); + + vpDisplay::flush(Iint); + vpDisplay::flush(Iext1); + vpDisplay::flush(Iext2); + } + + vpTime::wait(t, sampling_time * 1000); // Wait 40 ms + + std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; + } + + task.print() ; + task.kill() ; - return 0; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } #else int diff --git a/demo/wireframe-simulator/servoSimuCylinder.cpp b/demo/wireframe-simulator/servoSimuCylinder.cpp index 0dc0fa0181e9274b54fe376fbb7fad193513f322..6e3fd3522514d3c2f1d7557ec01776e2ac65d61b 100644 --- a/demo/wireframe-simulator/servoSimuCylinder.cpp +++ b/demo/wireframe-simulator/servoSimuCylinder.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoSimuCylinder.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: servoSimuCylinder.cpp 4659 2014-02-09 14:11:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -71,6 +71,8 @@ #define GETOPTARGS "dh" #ifdef VISP_HAVE_DISPLAY +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv, bool &display); /*! @@ -126,16 +128,16 @@ OPTIONS: \n\ */ bool getOptions(int argc, const char **argv, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'd': display = false; break; case 'h': usage(argv[0], NULL); return false; break; default: - usage(argv[0], optarg); + usage(argv[0], optarg_); return false; break; } } @@ -144,7 +146,7 @@ bool getOptions(int argc, const char **argv, bool &display) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -155,31 +157,30 @@ bool getOptions(int argc, const char **argv, bool &display) int main(int argc, const char ** argv) { - bool opt_display = true; - - // Read the command line options - if (getOptions(argc, argv, opt_display) == false) { - exit (-1); - } - - vpImage<vpRGBa> Iint(480,640,255); - vpImage<vpRGBa> Iext(480,640,255); + try { + bool opt_display = true; + + // Read the command line options + if (getOptions(argc, argv, opt_display) == false) { + exit (-1); + } + + vpImage<vpRGBa> Iint(480,640,255); + vpImage<vpRGBa> Iext(480,640,255); #if defined VISP_HAVE_X11 - vpDisplayX display[2]; + vpDisplayX display[2]; #elif defined VISP_HAVE_OPENCV - vpDisplayOpenCV display[2]; + vpDisplayOpenCV display[2]; #elif defined VISP_HAVE_GDI - vpDisplayGDI display[2]; + vpDisplayGDI display[2]; #elif defined VISP_HAVE_D3D9 - vpDisplayD3D display[2]; + vpDisplayD3D display[2]; #elif defined VISP_HAVE_GTK - vpDisplayGTK display[2]; + vpDisplayGTK display[2]; #endif - - if (opt_display) - { - try + + if (opt_display) { // Display size is automatically defined by the image (I) size display[0].init(Iint, 100, 100,"The internal view") ; @@ -191,197 +192,82 @@ main(int argc, const char ** argv) vpDisplay::display(Iext); vpDisplay::flush(Iext); } - catch(...) - { - vpERROR_TRACE("Error while displaying the image") ; - exit(-1); - } - } - vpServo task; - vpRobotCamera robot ; - float sampling_time = 0.040f; // Sampling period in second - robot.setSamplingTime(sampling_time); - - // Set initial position of the object in the camera frame - vpHomogeneousMatrix cMo(0,0.1,0.3,vpMath::rad(35),vpMath::rad(25),vpMath::rad(75)); - // Set desired position of the object in the camera frame - vpHomogeneousMatrix cdMo(0.0,0.0,0.5,vpMath::rad(90),vpMath::rad(0),vpMath::rad(0)); - // Set initial position of the object in the world frame - vpHomogeneousMatrix wMo(0.0,0.0,0,0,0,0); - // Position of the camera in the world frame - vpHomogeneousMatrix wMc, cMw; - wMc = wMo * cMo.inverse(); - cMw = wMc.inverse(); - - // Create a cylinder - vpCylinder cylinder(0,0,1,0,0,0,0.1); - - // Projection of the cylinder - cylinder.track(cMo); - - //Set the current visual feature - vpFeatureLine l[2]; - vpFeatureBuilder::create(l[0], cylinder, vpCylinder::line1); - vpFeatureBuilder::create(l[1], cylinder, vpCylinder::line2); - - // Projection of the cylinder - cylinder.track(cdMo); - - vpFeatureLine ld[2]; - vpFeatureBuilder::create(ld[0], cylinder, vpCylinder::line1); - vpFeatureBuilder::create(ld[1], cylinder, vpCylinder::line2); - - task.setServo(vpServo::EYEINHAND_L_cVe_eJe); - task.setInteractionMatrixType(vpServo::DESIRED); - - vpHomogeneousMatrix cMe; - vpVelocityTwistMatrix cVe(cMe); - task.set_cVe(cVe); - - vpMatrix eJe; - robot.get_eJe(eJe); - task.set_eJe(eJe); - - for (int i = 0 ; i < 2 ; i++) - task.addFeature(l[i],ld[i]) ; - - task.setLambda(1); - - vpWireFrameSimulator sim; - - // Set the scene - sim.initScene(vpWireFrameSimulator::CYLINDER, vpWireFrameSimulator::D_STANDARD); - - // Initialize simulator frames - sim.set_fMo( wMo ); // Position of the object in the world reference frame - sim.setCameraPositionRelObj(cMo) ; // initial position of the camera - sim.setDesiredCameraPosition(cdMo); // desired position of the camera - - // Set the External camera position - vpHomogeneousMatrix camMf(vpHomogeneousMatrix(0.0,0,3.5,vpMath::rad(0),vpMath::rad(30),0)); - sim.setExternalCameraPosition(camMf); - - // Set the parameters of the cameras (internal and external) - vpCameraParameters camera(1000,1000,320,240); - sim.setInternalCameraParameters(camera); - sim.setExternalCameraParameters(camera); - - int stop = 10; - - if (opt_display) - { - stop = 2500; + vpServo task; + vpRobotCamera robot ; + float sampling_time = 0.040f; // Sampling period in second + robot.setSamplingTime(sampling_time); + + // Set initial position of the object in the camera frame + vpHomogeneousMatrix cMo(0,0.1,0.3,vpMath::rad(35),vpMath::rad(25),vpMath::rad(75)); + // Set desired position of the object in the camera frame + vpHomogeneousMatrix cdMo(0.0,0.0,0.5,vpMath::rad(90),vpMath::rad(0),vpMath::rad(0)); + // Set initial position of the object in the world frame + vpHomogeneousMatrix wMo(0.0,0.0,0,0,0,0); + // Position of the camera in the world frame + vpHomogeneousMatrix wMc, cMw; + wMc = wMo * cMo.inverse(); + cMw = wMc.inverse(); + + // Create a cylinder + vpCylinder cylinder(0,0,1,0,0,0,0.1); + + // Projection of the cylinder + cylinder.track(cMo); + + //Set the current visual feature + vpFeatureLine l[2]; + vpFeatureBuilder::create(l[0], cylinder, vpCylinder::line1); + vpFeatureBuilder::create(l[1], cylinder, vpCylinder::line2); - //Get the internal and external views - sim.getInternalImage(Iint); - sim.getExternalImage(Iext); + // Projection of the cylinder + cylinder.track(cdMo); - //Display the object frame (current and desired position) - vpDisplay::displayFrame(Iint,cMo,camera,0.2,vpColor::none); - vpDisplay::displayFrame(Iint,cdMo,camera,0.2,vpColor::none); + vpFeatureLine ld[2]; + vpFeatureBuilder::create(ld[0], cylinder, vpCylinder::line1); + vpFeatureBuilder::create(ld[1], cylinder, vpCylinder::line2); - //Display the object frame the world reference frame and the camera frame - vpDisplay::displayFrame(Iext,camMf*sim.get_fMo()*cMo.inverse(),camera,0.2,vpColor::none); - vpDisplay::displayFrame(Iext,camMf*sim.get_fMo(),camera,0.2,vpColor::none); - vpDisplay::displayFrame(Iext,camMf,camera,0.2,vpColor::none); - - vpDisplay::flush(Iint); - vpDisplay::flush(Iext); - - std::cout << "Click on a display" << std::endl; - while (!vpDisplay::getClick(Iint,false) && !vpDisplay::getClick(Iext,false)){}; - } - - robot.setPosition( cMw ); - - //Print the task - task.print(); - - int iter = 0; - vpColVector v ; - - //Set the secondary task parameters - vpColVector e1(6) ; e1 = 0 ; - vpColVector e2(6) ; e2 = 0 ; - vpColVector proj_e1 ; - vpColVector proj_e2 ; - iter = 0; - double rapport = 0; - double vitesse = 0.3; - int tempo = 600; - - while(iter++ < stop) - { - if (opt_display) - { - vpDisplay::display(Iint) ; - vpDisplay::display(Iext) ; - } + task.setServo(vpServo::EYEINHAND_L_cVe_eJe); + task.setInteractionMatrixType(vpServo::DESIRED); - double t = vpTime::measureTimeMs(); + vpHomogeneousMatrix cMe; + vpVelocityTwistMatrix cVe(cMe); + task.set_cVe(cVe); - robot.get_eJe(eJe) ; - task.set_eJe(eJe) ; + vpMatrix eJe; + robot.get_eJe(eJe); + task.set_eJe(eJe); - robot.getPosition(cMw) ; - cMo = cMw * wMo; + for (int i = 0 ; i < 2 ; i++) + task.addFeature(l[i],ld[i]) ; - cylinder.track(cMo) ; - vpFeatureBuilder::create(l[0], cylinder, vpCylinder::line1); - vpFeatureBuilder::create(l[1], cylinder, vpCylinder::line2); + task.setLambda(1); - v = task.computeControlLaw() ; - - //Compute the velocity with the secondary task - if ( iter%tempo < 200 && iter%tempo >= 0) - { - e2 = 0; - e1[0] = -fabs(vitesse) ; - proj_e1 = task.secondaryTask(e1); - rapport = -vitesse/proj_e1[0]; - proj_e1 *= rapport ; - v += proj_e1 ; - } + vpWireFrameSimulator sim; - if ( iter%tempo < 300 && iter%tempo >= 200) - { - e1 = 0; - e2[1] = -fabs(vitesse) ; - proj_e2 = task.secondaryTask(e2); - rapport = -vitesse/proj_e2[1]; - proj_e2 *= rapport ; - v += proj_e2 ; - } + // Set the scene + sim.initScene(vpWireFrameSimulator::CYLINDER, vpWireFrameSimulator::D_STANDARD); - if ( iter%tempo < 500 && iter%tempo >= 300) - { - e2 = 0; - e1[0] = -fabs(vitesse) ; - proj_e1 = task.secondaryTask(e1); - rapport = vitesse/proj_e1[0]; - proj_e1 *= rapport ; - v += proj_e1 ; - } + // Initialize simulator frames + sim.set_fMo( wMo ); // Position of the object in the world reference frame + sim.setCameraPositionRelObj(cMo) ; // initial position of the camera + sim.setDesiredCameraPosition(cdMo); // desired position of the camera - if ( iter%tempo < 600 && iter%tempo >= 500) - { - e1 = 0; - e2[1] = -fabs(vitesse) ; - proj_e2 = task.secondaryTask(e2); - rapport = vitesse/proj_e2[1]; - proj_e2 *= rapport ; - v += proj_e2 ; - } + // Set the External camera position + vpHomogeneousMatrix camMf(vpHomogeneousMatrix(0.0,0,3.5,vpMath::rad(0),vpMath::rad(30),0)); + sim.setExternalCameraPosition(camMf); - robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + // Set the parameters of the cameras (internal and external) + vpCameraParameters camera(1000,1000,320,240); + sim.setInternalCameraParameters(camera); + sim.setExternalCameraParameters(camera); - // Update the simulator frames - sim.set_fMo( wMo ); // This line is not really requested since the object doesn't move - sim.setCameraPositionRelObj( cMo ); + int stop = 10; if (opt_display) { + stop = 2500; + //Get the internal and external views sim.getInternalImage(Iint); sim.getExternalImage(Iext); @@ -391,23 +277,137 @@ main(int argc, const char ** argv) vpDisplay::displayFrame(Iint,cdMo,camera,0.2,vpColor::none); //Display the object frame the world reference frame and the camera frame - vpDisplay::displayFrame(Iext,sim.getExternalCameraPosition()*sim.get_fMo()*cMo.inverse(),camera,0.2,vpColor::none); - vpDisplay::displayFrame(Iext,sim.getExternalCameraPosition()*sim.get_fMo(),camera,0.2,vpColor::none); - vpDisplay::displayFrame(Iext,sim.getExternalCameraPosition(),camera,0.2,vpColor::none);; + vpDisplay::displayFrame(Iext,camMf*sim.get_fMo()*cMo.inverse(),camera,0.2,vpColor::none); + vpDisplay::displayFrame(Iext,camMf*sim.get_fMo(),camera,0.2,vpColor::none); + vpDisplay::displayFrame(Iext,camMf,camera,0.2,vpColor::none); vpDisplay::flush(Iint); vpDisplay::flush(Iext); + + std::cout << "Click on a display" << std::endl; + while (!vpDisplay::getClick(Iint,false) && !vpDisplay::getClick(Iext,false)){}; } - vpTime::wait(t, sampling_time * 1000); // Wait 40 ms + robot.setPosition( cMw ); - std::cout << "|| s - s* || = " << (task.getError() ).sumSquare() <<std::endl ; - } + //Print the task + task.print(); + + int iter = 0; + vpColVector v ; + + //Set the secondary task parameters + vpColVector e1(6) ; e1 = 0 ; + vpColVector e2(6) ; e2 = 0 ; + vpColVector proj_e1 ; + vpColVector proj_e2 ; + iter = 0; + double rapport = 0; + double vitesse = 0.3; + int tempo = 600; - task.print() ; - task.kill() ; + while(iter++ < stop) + { + if (opt_display) + { + vpDisplay::display(Iint) ; + vpDisplay::display(Iext) ; + } + + double t = vpTime::measureTimeMs(); + + robot.get_eJe(eJe) ; + task.set_eJe(eJe) ; + + robot.getPosition(cMw) ; + cMo = cMw * wMo; + + cylinder.track(cMo) ; + vpFeatureBuilder::create(l[0], cylinder, vpCylinder::line1); + vpFeatureBuilder::create(l[1], cylinder, vpCylinder::line2); + + v = task.computeControlLaw() ; + + //Compute the velocity with the secondary task + if ( iter%tempo < 200 && iter%tempo >= 0) + { + e2 = 0; + e1[0] = -fabs(vitesse) ; + proj_e1 = task.secondaryTask(e1); + rapport = -vitesse/proj_e1[0]; + proj_e1 *= rapport ; + v += proj_e1 ; + } + + if ( iter%tempo < 300 && iter%tempo >= 200) + { + e1 = 0; + e2[1] = -fabs(vitesse) ; + proj_e2 = task.secondaryTask(e2); + rapport = -vitesse/proj_e2[1]; + proj_e2 *= rapport ; + v += proj_e2 ; + } + + if ( iter%tempo < 500 && iter%tempo >= 300) + { + e2 = 0; + e1[0] = -fabs(vitesse) ; + proj_e1 = task.secondaryTask(e1); + rapport = vitesse/proj_e1[0]; + proj_e1 *= rapport ; + v += proj_e1 ; + } + + if ( iter%tempo < 600 && iter%tempo >= 500) + { + e1 = 0; + e2[1] = -fabs(vitesse) ; + proj_e2 = task.secondaryTask(e2); + rapport = vitesse/proj_e2[1]; + proj_e2 *= rapport ; + v += proj_e2 ; + } + + robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + + // Update the simulator frames + sim.set_fMo( wMo ); // This line is not really requested since the object doesn't move + sim.setCameraPositionRelObj( cMo ); + + if (opt_display) + { + //Get the internal and external views + sim.getInternalImage(Iint); + sim.getExternalImage(Iext); + + //Display the object frame (current and desired position) + vpDisplay::displayFrame(Iint,cMo,camera,0.2,vpColor::none); + vpDisplay::displayFrame(Iint,cdMo,camera,0.2,vpColor::none); + + //Display the object frame the world reference frame and the camera frame + vpDisplay::displayFrame(Iext,sim.getExternalCameraPosition()*sim.get_fMo()*cMo.inverse(),camera,0.2,vpColor::none); + vpDisplay::displayFrame(Iext,sim.getExternalCameraPosition()*sim.get_fMo(),camera,0.2,vpColor::none); + vpDisplay::displayFrame(Iext,sim.getExternalCameraPosition(),camera,0.2,vpColor::none);; + + vpDisplay::flush(Iint); + vpDisplay::flush(Iext); + } + + vpTime::wait(t, sampling_time * 1000); // Wait 40 ms + + std::cout << "|| s - s* || = " << (task.getError() ).sumSquare() <<std::endl ; + } + + task.print() ; + task.kill() ; - return 0; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } #else int diff --git a/demo/wireframe-simulator/servoSimuSphere.cpp b/demo/wireframe-simulator/servoSimuSphere.cpp index fce1d042d6d97bfb67dd815ec0e152e52760372e..b26af02a42ad1852e1ff42641f178f1b1acf1b1d 100644 --- a/demo/wireframe-simulator/servoSimuSphere.cpp +++ b/demo/wireframe-simulator/servoSimuSphere.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoSimuSphere.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: servoSimuSphere.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -74,6 +74,11 @@ #ifdef VISP_HAVE_DISPLAY +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv, bool &display); +void computeVisualFeatures(const vpSphere &sphere, vpGenericFeature &s); +void computeInteractionMatrix(const vpGenericFeature &s,const vpSphere &sphere, vpMatrix &L); + /*! Print the program options. @@ -119,16 +124,16 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'd': display = false; break; case 'h': usage(argv[0], NULL); return false; break; default: - usage(argv[0], optarg); + usage(argv[0], optarg_); return false; break; } } @@ -137,7 +142,7 @@ bool getOptions(int argc, const char **argv, bool &display) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -157,7 +162,7 @@ bool getOptions(int argc, const char **argv, bool &display) with h2 = (gx²+gy²)/(4*n20*gy²+4*n02*gx²-8n11gxgy) with n20,n02,n11 the second order moments of the sphere */ -void computeVisualFeatures(const vpSphere sphere, vpGenericFeature &s) +void computeVisualFeatures(const vpSphere &sphere, vpGenericFeature &s) { double gx = sphere.get_x(); double gy = sphere.get_y(); @@ -185,7 +190,7 @@ void computeVisualFeatures(const vpSphere sphere, vpGenericFeature &s) with I3 the 3x3 identity matrix with [s]x the skew matrix related to s */ -void computeInteractionMatrix(const vpGenericFeature s,const vpSphere sphere, vpMatrix &L) +void computeInteractionMatrix(const vpGenericFeature &s,const vpSphere &sphere, vpMatrix &L) { L = 0; L[0][0] = -1/sphere.getR(); @@ -208,32 +213,31 @@ void computeInteractionMatrix(const vpGenericFeature s,const vpSphere sphere, vp int main(int argc, const char ** argv) { - bool opt_display = true; - - // Read the command line options - if (getOptions(argc, argv, opt_display) == false) { - exit (-1); - } - - vpImage<vpRGBa> Iint(480,640,255); - vpImage<vpRGBa> Iext1(480,640,255); - vpImage<vpRGBa> Iext2(480,640,255); + try { + bool opt_display = true; + + // Read the command line options + if (getOptions(argc, argv, opt_display) == false) { + exit (-1); + } + + vpImage<vpRGBa> Iint(480,640,255); + vpImage<vpRGBa> Iext1(480,640,255); + vpImage<vpRGBa> Iext2(480,640,255); #if defined VISP_HAVE_X11 - vpDisplayX display[3]; + vpDisplayX display[3]; #elif defined VISP_HAVE_OPENCV - vpDisplayOpenCV display[3]; + vpDisplayOpenCV display[3]; #elif defined VISP_HAVE_GDI - vpDisplayGDI display[3]; + vpDisplayGDI display[3]; #elif defined VISP_HAVE_D3D9 - vpDisplayD3D display[3]; + vpDisplayD3D display[3]; #elif defined VISP_HAVE_GTK - vpDisplayGTK display[3]; + vpDisplayGTK display[3]; #endif - - if (opt_display) - { - try + + if (opt_display) { // Display size is automatically defined by the image (I) size display[0].init(Iint, 100, 100,"The internal view") ; @@ -249,162 +253,92 @@ main(int argc, const char ** argv) vpDisplay::display(Iext2); vpDisplay::flush(Iext2); } - catch(...) - { - vpERROR_TRACE("Error while displaying the image") ; - exit(-1); - } - } - vpServo task; - vpRobotCamera robot ; - float sampling_time = 0.040f; // Sampling period in second - robot.setSamplingTime(sampling_time); - - // Since the task gain lambda is very high, we need to increase default max velocities - robot.setMaxTranslationVelocity(10); - robot.setMaxRotationVelocity(vpMath::rad(180)); - - // Set initial position of the object in the camera frame - vpHomogeneousMatrix cMo(0,0.1,2.0,vpMath::rad(35),vpMath::rad(25),0); - // Set desired position of the object in the camera frame - vpHomogeneousMatrix cdMo(0.0,0.0,0.8,vpMath::rad(0),vpMath::rad(0),vpMath::rad(0)); - // Set initial position of the object in the world frame - vpHomogeneousMatrix wMo(0.0,0.0,0,0,0,0); - // Position of the camera in the world frame - vpHomogeneousMatrix wMc, cMw; - wMc = wMo * cMo.inverse(); - cMw = wMc.inverse(); - - robot.setPosition( cMw ); - - //The sphere - vpSphere sphere(0,0,0,0.15); - - // Projection of the sphere - sphere.track(cMo); + vpServo task; + vpRobotCamera robot ; + float sampling_time = 0.040f; // Sampling period in second + robot.setSamplingTime(sampling_time); - //Set the current visual feature - vpGenericFeature s(3); - computeVisualFeatures(sphere, s); - - // Projection of the points - sphere.track(cdMo); + // Since the task gain lambda is very high, we need to increase default max velocities + robot.setMaxTranslationVelocity(10); + robot.setMaxRotationVelocity(vpMath::rad(180)); - vpGenericFeature sd(3); - computeVisualFeatures(sphere, sd); - - vpMatrix L(3,6); - computeInteractionMatrix(sd,sphere,L); - sd.setInteractionMatrix(L); + // Set initial position of the object in the camera frame + vpHomogeneousMatrix cMo(0,0.1,2.0,vpMath::rad(35),vpMath::rad(25),0); + // Set desired position of the object in the camera frame + vpHomogeneousMatrix cdMo(0.0,0.0,0.8,vpMath::rad(0),vpMath::rad(0),vpMath::rad(0)); + // Set initial position of the object in the world frame + vpHomogeneousMatrix wMo(0.0,0.0,0,0,0,0); + // Position of the camera in the world frame + vpHomogeneousMatrix wMc, cMw; + wMc = wMo * cMo.inverse(); + cMw = wMc.inverse(); - task.setServo(vpServo::EYEINHAND_L_cVe_eJe); - task.setInteractionMatrixType(vpServo::DESIRED); - - vpHomogeneousMatrix cMe; - vpVelocityTwistMatrix cVe(cMe); - task.set_cVe(cVe); + robot.setPosition( cMw ); - vpMatrix eJe; - robot.get_eJe(eJe); - task.set_eJe(eJe); + //The sphere + vpSphere sphere(0,0,0,0.15); - task.addFeature(s,sd) ; - - task.setLambda(7); - - vpWireFrameSimulator sim; - - // Set the scene - sim.initScene(vpWireFrameSimulator::SPHERE, vpWireFrameSimulator::D_STANDARD); + // Projection of the sphere + sphere.track(cMo); - // Initialize simulator frames - sim.set_fMo( wMo ); // Position of the object in the world reference frame - sim.setCameraPositionRelObj(cMo) ; // initial position of the camera - sim.setDesiredCameraPosition(cdMo); // desired position of the camera - - // Set the External camera position - vpHomogeneousMatrix camMf(0.0,0,3.5,vpMath::rad(0),vpMath::rad(30),0); - sim.setExternalCameraPosition(camMf); - - // Computes the position of a camera which is fixed in the object frame - vpHomogeneousMatrix camoMf(0,0.0,2.5,0,vpMath::rad(140),0); - camoMf = camoMf*(sim.get_fMo().inverse()); - - // Set the parameters of the cameras (internal and external) - vpCameraParameters camera(1000,1000,320,240); - sim.setInternalCameraParameters(camera); - sim.setExternalCameraParameters(camera); - - int stop = 10; - - if (opt_display) - { - stop = 1000; - //Get the internal and external views - sim.getInternalImage(Iint); - sim.getExternalImage(Iext1); - sim.getExternalImage(Iext2,camoMf); - - //Display the object frame (current and desired position) - vpDisplay::displayFrame(Iint,cMo,camera,0.2,vpColor::none); - vpDisplay::displayFrame(Iint,cdMo,camera,0.2,vpColor::none); - - //Display the object frame the world reference frame and the camera frame - vpDisplay::displayFrame(Iext1,camMf*sim.get_fMo()*cMo.inverse(),camera,0.2,vpColor::none); - vpDisplay::displayFrame(Iext1,camMf*sim.get_fMo(),camera,0.2,vpColor::none); - vpDisplay::displayFrame(Iext1,camMf,camera,0.2,vpColor::none); - - //Display the world reference frame and the object frame - vpDisplay::displayFrame(Iext2,camoMf,camera,0.2,vpColor::none); - vpDisplay::displayFrame(Iext2,camoMf*sim.get_fMo(),camera,0.05,vpColor::none); - - vpDisplay::flush(Iint); - vpDisplay::flush(Iext1); - vpDisplay::flush(Iext2); + //Set the current visual feature + vpGenericFeature s(3); + computeVisualFeatures(sphere, s); - std::cout << "Click on a display" << std::endl; - while (!vpDisplay::getClick(Iint,false) && !vpDisplay::getClick(Iext1,false) && !vpDisplay::getClick(Iext2,false)){}; - } + // Projection of the points + sphere.track(cdMo); - //Print the task - task.print() ; + vpGenericFeature sd(3); + computeVisualFeatures(sphere, sd); - int iter = 0; - vpColVector v ; + vpMatrix L(3,6); + computeInteractionMatrix(sd,sphere,L); + sd.setInteractionMatrix(L); - while(iter++ < stop) - { - if (opt_display) - { - vpDisplay::display(Iint) ; - vpDisplay::display(Iext1) ; - vpDisplay::display(Iext2) ; - } + task.setServo(vpServo::EYEINHAND_L_cVe_eJe); + task.setInteractionMatrixType(vpServo::DESIRED); - double t = vpTime::measureTimeMs(); + vpHomogeneousMatrix cMe; + vpVelocityTwistMatrix cVe(cMe); + task.set_cVe(cVe); - robot.get_eJe(eJe) ; - task.set_eJe(eJe) ; + vpMatrix eJe; + robot.get_eJe(eJe); + task.set_eJe(eJe); - robot.getPosition(cMw) ; - cMo = cMw * wMo; + task.addFeature(s,sd) ; - sphere.track(cMo); + task.setLambda(7); - //Set the current visual feature - computeVisualFeatures(sphere, s); + vpWireFrameSimulator sim; + + // Set the scene + sim.initScene(vpWireFrameSimulator::SPHERE, vpWireFrameSimulator::D_STANDARD); + + // Initialize simulator frames + sim.set_fMo( wMo ); // Position of the object in the world reference frame + sim.setCameraPositionRelObj(cMo) ; // initial position of the camera + sim.setDesiredCameraPosition(cdMo); // desired position of the camera - v = task.computeControlLaw() ; - robot.setVelocity(vpRobot::CAMERA_FRAME, v); - sim.setCameraPositionRelObj(cMo); + // Set the External camera position + vpHomogeneousMatrix camMf(0.0,0,3.5,vpMath::rad(0),vpMath::rad(30),0); + sim.setExternalCameraPosition(camMf); - //Compute the position of the external view which is fixed in the object frame - camoMf.buildFrom(0,0.0,2.5,0,vpMath::rad(150),0); + // Computes the position of a camera which is fixed in the object frame + vpHomogeneousMatrix camoMf(0,0.0,2.5,0,vpMath::rad(140),0); camoMf = camoMf*(sim.get_fMo().inverse()); + // Set the parameters of the cameras (internal and external) + vpCameraParameters camera(1000,1000,320,240); + sim.setInternalCameraParameters(camera); + sim.setExternalCameraParameters(camera); + + int stop = 10; + if (opt_display) { + stop = 1000; //Get the internal and external views sim.getInternalImage(Iint); sim.getExternalImage(Iext1); @@ -414,10 +348,10 @@ main(int argc, const char ** argv) vpDisplay::displayFrame(Iint,cMo,camera,0.2,vpColor::none); vpDisplay::displayFrame(Iint,cdMo,camera,0.2,vpColor::none); - //Display the camera frame, the object frame the world reference frame - vpDisplay::displayFrame(Iext1,sim.getExternalCameraPosition()*sim.get_fMo()*cMo.inverse(),camera,0.2,vpColor::none); - vpDisplay::displayFrame(Iext1,sim.getExternalCameraPosition()*sim.get_fMo(),camera,0.2,vpColor::none); - vpDisplay::displayFrame(Iext1,sim.getExternalCameraPosition(),camera,0.2,vpColor::none); + //Display the object frame the world reference frame and the camera frame + vpDisplay::displayFrame(Iext1,camMf*sim.get_fMo()*cMo.inverse(),camera,0.2,vpColor::none); + vpDisplay::displayFrame(Iext1,camMf*sim.get_fMo(),camera,0.2,vpColor::none); + vpDisplay::displayFrame(Iext1,camMf,camera,0.2,vpColor::none); //Display the world reference frame and the object frame vpDisplay::displayFrame(Iext2,camoMf,camera,0.2,vpColor::none); @@ -426,17 +360,85 @@ main(int argc, const char ** argv) vpDisplay::flush(Iint); vpDisplay::flush(Iext1); vpDisplay::flush(Iext2); + + std::cout << "Click on a display" << std::endl; + while (!vpDisplay::getClick(Iint,false) && !vpDisplay::getClick(Iext1,false) && !vpDisplay::getClick(Iext2,false)){}; } - vpTime::wait(t, sampling_time * 1000); // Wait 40 ms + //Print the task + task.print() ; - std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; - } + int iter = 0; + vpColVector v ; + + while(iter++ < stop) + { + if (opt_display) + { + vpDisplay::display(Iint) ; + vpDisplay::display(Iext1) ; + vpDisplay::display(Iext2) ; + } + + double t = vpTime::measureTimeMs(); - task.print() ; - task.kill() ; + robot.get_eJe(eJe) ; + task.set_eJe(eJe) ; - return 0; + robot.getPosition(cMw) ; + cMo = cMw * wMo; + + sphere.track(cMo); + + //Set the current visual feature + computeVisualFeatures(sphere, s); + + v = task.computeControlLaw() ; + robot.setVelocity(vpRobot::CAMERA_FRAME, v); + sim.setCameraPositionRelObj(cMo); + + //Compute the position of the external view which is fixed in the object frame + camoMf.buildFrom(0,0.0,2.5,0,vpMath::rad(150),0); + camoMf = camoMf*(sim.get_fMo().inverse()); + + if (opt_display) + { + //Get the internal and external views + sim.getInternalImage(Iint); + sim.getExternalImage(Iext1); + sim.getExternalImage(Iext2,camoMf); + + //Display the object frame (current and desired position) + vpDisplay::displayFrame(Iint,cMo,camera,0.2,vpColor::none); + vpDisplay::displayFrame(Iint,cdMo,camera,0.2,vpColor::none); + + //Display the camera frame, the object frame the world reference frame + vpDisplay::displayFrame(Iext1,sim.getExternalCameraPosition()*sim.get_fMo()*cMo.inverse(),camera,0.2,vpColor::none); + vpDisplay::displayFrame(Iext1,sim.getExternalCameraPosition()*sim.get_fMo(),camera,0.2,vpColor::none); + vpDisplay::displayFrame(Iext1,sim.getExternalCameraPosition(),camera,0.2,vpColor::none); + + //Display the world reference frame and the object frame + vpDisplay::displayFrame(Iext2,camoMf,camera,0.2,vpColor::none); + vpDisplay::displayFrame(Iext2,camoMf*sim.get_fMo(),camera,0.05,vpColor::none); + + vpDisplay::flush(Iint); + vpDisplay::flush(Iext1); + vpDisplay::flush(Iext2); + } + + vpTime::wait(t, sampling_time * 1000); // Wait 40 ms + + std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; + } + + task.print() ; + task.kill() ; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } #else int diff --git a/distclean.sh b/distclean.sh index cf5bc40352f8c47cd1647d51903bbb50c48a8862..7e78704ec57c8f9aec2a9a5fed86972317434e82 100755 --- a/distclean.sh +++ b/distclean.sh @@ -4,7 +4,7 @@ # $Id: distclean.sh,v 1.3 2006-05-29 09:58:22 fspindle Exp $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/doc/biblio/references.bib b/doc/biblio/references.bib index dbd4e3e01f990ea835d698e5e829daf9aabdd024..02028dec0fbf0429b93a50744b85f221b3c7a86f 100644 --- a/doc/biblio/references.bib +++ b/doc/biblio/references.bib @@ -1,3 +1,16 @@ +@Article{Fischler81, + author = {Fischler, N. and Bolles, R.C.}, + title = {Random Sample Consensus: A Paradigm for Model + Fitting with Application to Image Analysis and + Automated Cartography}, + journal = {Communication of the ACM}, + year = 1981, + volume = 24, + number = 6, + pages = {381--395}, + month = jun +} + @Article{Tsai89a, author = {Tsai, R. and Lenz, R.}, title = {A New Technique for Fully Autonomous and Efficient @@ -73,6 +86,14 @@ x-advisor = {Chaumette, F.}, {http://www.irisa.fr/lagadic/pdf/1998_these_malis_transp.pdf} } +@inproceedings{Irani98a, + title = {Robust multi-sensor image alignment}, + author = {Irani, M. and Anandan, P.}, + booktitle = {IEEE Int. Conf. on Computer Vision, ICCV'98}, + pages = {959-966}, + address = {Bombay, India}, + year = 1998 +} @article{Malis00b, author = {Malis, E. and Chaumette, F. and Boudet, S.}, title = {2 1/2 {D} Visual Servoing with Respect to Unknown @@ -97,6 +118,13 @@ x-advisor = {Chaumette, F.}, keyword = {pose} } +@Book{Hartley01a, + author = { Hartley, R. and Zisserman,A.}, + title = { Multiple View Geometry in Computer Vision }, + publisher = {Cambridge University Press}, + year = 2001 +} + @InProceedings{Marchand02c, author = {Marchand, E. and Chaumette, F.}, title = {Virtual Visual Servoing: a framework for real-time @@ -111,6 +139,16 @@ x-advisor = {Chaumette, F.}, month = sep } +@Article{Baker04a, + author = {Baker, S. and Matthews, I.}, + title = { Lucas-kanade 20 years on: A unifying framework}, + journal = {Int. Journal of Computer Vision}, + year = 2004, + volume = 56, + number = 3, + pages = {221-255} +} + @Article{Chaumette04a, author = {Chaumette, F.}, title = {Image moments: a general and useful set of features @@ -240,4 +278,83 @@ x-advisor = {Chaumette, F.}, Address = {St Louis, USA}, Month = {October}, Year = {2009} -} \ No newline at end of file +} + +@article{Mansard07e, + Author = {Mansard, N. and Chaumette, F.}, + Title = {Task sequencing for high level sensor-based control}, + Journal = {IEEE Trans. on Robotics}, + Volume = { 23}, + Number = {1}, + Pages = {60--72}, + Month = {February}, + Year = {2007} +} + +@Article{Ozuysal10, + author = {Ozuysal, M. and Calonder, M. and Lepetit, V. and Fua, P.}, + title = {Fast keypoint recognition using random ferns}, + journal = {IEEE Trans. on Pattern Analysis and Machine Intelligence}, + year = 2010, + volume = 32, + number = 3, + pages = {448-461}, + month = {March} +} + +@techreport{Lepetit04c, + author = {Lepetit, V. and Fua, P.}, + title = {Towards Recognizing Feature Points using Classification Trees}, + institution = {EPFL}, + year = 2004, + type = {Technical Report}, + number = {IC/2004/74} +} + +@inproceedings{collewet:inria-00261398, + hal_id = {inria-00261398}, + url = {http://hal.inria.fr/inria-00261398}, + title = {Visual servoing set free from image processing}, + author = {Collewet, C. and Marchand, E. and Chaumette, F.}, + abstract = {This paper proposes a new way to achieve robotic tasks by visual servoing. Instead of using geometric features (points, straight lines, pose, homography, etc.) as it is usually done, we use directly the luminance of all pixels in the image. Since most of the classical control laws fail in this case, we turn the visual servoing problem into an optimization problem leading to a new control law. Experimental results validate the proposed approach and show its robustness regarding to approximated depths, non Lambertian objects and partial occlusions.}, + language = {English}, + affiliation = {LAGADIC - INRIA - IRISA}, + booktitle = {IEEE Int. Conf. on Robotics and Automation, ICRA'08}, + address = {Pasadena, United States}, + organization = {IEEE}, + audience = {international}, + year = {2008}, +} + +@InProceedings{Marchand96f, + Author = {Marchand, E. and Chaumette, F. and Rizzo, A.}, + Title = {Using the task function approach to avoid robot joint limits and kinematic singularities in visual servoing}, + BookTitle = {IEEE/RSJ Int. Conf. on Intelligent Robots and Systems, IROS'96}, + Volume = {3}, + Pages = {1083--1090}, + Address = {Osaka, Japan}, + Month = {November}, + Year = {1996} +} + +@article{Chaumette01c, + Author = {Chaumette, F. and Marchand, E.}, + Title = {A redundancy-based iterative approach for avoiding joint limits: Application to visual servoing}, + Journal = {IEEE Trans. on Robotics and Automation}, + Volume = {17}, + Number = {5}, + Pages = {719--730}, + Publisher = {IEEE}, + Month = {October}, + Year = {2001} +} + +@InProceedings{Collewet08c, + Author = {Collewet, C. and Marchand, E. and Chaumette, F.}, + Title = {Visual servoing set free from image processing}, + BookTitle = {IEEE Int. Conf. on Robotics and Automation, ICRA'08}, + Pages = {81--86}, + Address = {Pasadena, California}, + Month = {May}, + Year = {2008} +} diff --git a/doc/config-doxygen.in b/doc/config-doxygen.in index fe2037b3b8fc74b028db147616a59444bb23d6bd..92a583b5a83bd048b3d0b771cbf68586273812e6 100644 --- a/doc/config-doxygen.in +++ b/doc/config-doxygen.in @@ -1564,7 +1564,6 @@ PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS \ VISP_HAVE_SOQT \ VISP_HAVE_SOWIN \ VISP_HAVE_SOXT \ - VISP_HAVE_DC1394_1 \ VISP_HAVE_DC1394_2 \ VISP_HAVE_CMU1394 \ VISP_HAVE_V4L2 \ @@ -1575,7 +1574,6 @@ PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS \ VISP_HAVE_PTU46 \ VISP_HAVE_VIPER650 \ VISP_HAVE_VIPER850 \ - VISP_HAVE_CYCABTK \ VISP_HAVE_PIONEER \ VISP_HAVE_PARPORT \ VISP_HAVE_XML2 \ @@ -1592,7 +1590,8 @@ PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS \ WIN32 \ APPLE \ UNIX \ - VP_DEBUG + VP_DEBUG \ + VP_TRACE # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. diff --git a/doc/image/img-chessboard-01.png b/doc/image/img-chessboard-01.png index 721f13bc39532224768e958d8364fcf02897b600..4e92fd62c1a9c709e8da7d7e1c3c034a38db5612 100644 Binary files a/doc/image/img-chessboard-01.png and b/doc/image/img-chessboard-01.png differ diff --git a/doc/image/img-circles-grid-02.png b/doc/image/img-circles-grid-02.png index 684ef7567f32d2cb21f7b982911f2a6ce0c29275..44504e36409d294546396a8958e0bea55bd6f53e 100644 Binary files a/doc/image/img-circles-grid-02.png and b/doc/image/img-circles-grid-02.png differ diff --git a/doc/image/img-cmake-debug-trace.jpg b/doc/image/img-cmake-debug-trace.jpg new file mode 100644 index 0000000000000000000000000000000000000000..1ef2ed23df1d189dc71a4f3b6419df80d9fddbb8 Binary files /dev/null and b/doc/image/img-cmake-debug-trace.jpg differ diff --git a/doc/image/img-ibvs-control-law-adaptive.png b/doc/image/img-ibvs-control-law-adaptive.png new file mode 100644 index 0000000000000000000000000000000000000000..4dc71cd2f3abeedc8f3e4f796677d731ba4d1fff Binary files /dev/null and b/doc/image/img-ibvs-control-law-adaptive.png differ diff --git a/doc/image/img-ibvs-control-law-continuous-adaptive.png b/doc/image/img-ibvs-control-law-continuous-adaptive.png new file mode 100644 index 0000000000000000000000000000000000000000..a6e51e639c3de096d4c8400ac6617c495006cf77 Binary files /dev/null and b/doc/image/img-ibvs-control-law-continuous-adaptive.png differ diff --git a/doc/image/img-ibvs-control-law-exponential.png b/doc/image/img-ibvs-control-law-exponential.png new file mode 100644 index 0000000000000000000000000000000000000000..6b430e7e65bb9dff6fe52903f285492d35189861 Binary files /dev/null and b/doc/image/img-ibvs-control-law-exponential.png differ diff --git a/doc/image/img-lena-blured-default.png b/doc/image/img-lena-blured-default.png new file mode 100644 index 0000000000000000000000000000000000000000..1f83f88335aebb24e4f270d41e8e61c3adfc1ca6 Binary files /dev/null and b/doc/image/img-lena-blured-default.png differ diff --git a/doc/image/img-lena-blured-var2.png b/doc/image/img-lena-blured-var2.png new file mode 100644 index 0000000000000000000000000000000000000000..7f75fe53a0b56c9ccde27c8dd0495e3966c73d63 Binary files /dev/null and b/doc/image/img-lena-blured-var2.png differ diff --git a/doc/image/img-lena-canny.png b/doc/image/img-lena-canny.png new file mode 100644 index 0000000000000000000000000000000000000000..2ce75eba9043bf13065e11a9c6122894c2846bcb Binary files /dev/null and b/doc/image/img-lena-canny.png differ diff --git a/doc/image/img-lena-dIxy.png b/doc/image/img-lena-dIxy.png new file mode 100644 index 0000000000000000000000000000000000000000..b24bf0bdc48346306847bbe4ebe62d5f7c0af1f6 Binary files /dev/null and b/doc/image/img-lena-dIxy.png differ diff --git a/doc/image/img-lena-gray.png b/doc/image/img-lena-gray.png new file mode 100644 index 0000000000000000000000000000000000000000..696820dbe5758473bb422bac19bd390a3089fd8e Binary files /dev/null and b/doc/image/img-lena-gray.png differ diff --git a/doc/image/img-lena-pyr.png b/doc/image/img-lena-pyr.png new file mode 100644 index 0000000000000000000000000000000000000000..092de5137179bccf3caa7ae1185365e84b38a2a8 Binary files /dev/null and b/doc/image/img-lena-pyr.png differ diff --git a/doc/image/img-lena-sobel.png b/doc/image/img-lena-sobel.png new file mode 100644 index 0000000000000000000000000000000000000000..3672e0b875c2b16751c3289d9eb0746ea30bad45 Binary files /dev/null and b/doc/image/img-lena-sobel.png differ diff --git a/doc/image/img-template-tracker.jpg b/doc/image/img-template-tracker.jpg new file mode 100644 index 0000000000000000000000000000000000000000..0bf3caacb85f4010fccdadfc7e3ffd27b706b070 Binary files /dev/null and b/doc/image/img-template-tracker.jpg differ diff --git a/doc/image/initClickTemplateTracker.png b/doc/image/initClickTemplateTracker.png new file mode 100644 index 0000000000000000000000000000000000000000..2c1ee211e8c005c7055286c0e3fc3700258eb515 Binary files /dev/null and b/doc/image/initClickTemplateTracker.png differ diff --git a/doc/mainpage.doc.in b/doc/mainpage.doc.in index e012fb143cd69d7dce27b5c9c47280ac8cabd61b..66b493c546701a470ad2c9a6eae6dee10a1f2d84 100644 --- a/doc/mainpage.doc.in +++ b/doc/mainpage.doc.in @@ -8,11 +8,11 @@ <p>ViSP \cite Marchand05b is a modular C++ library that allows fast development of visual servoing applications. ViSP is developed and maintained by the Inria -<a href="http://www.irisa.fr/lagadic" target="_parent">Lagadic</a> team located at <a -href="http://www.inria.fr/rennes" target="_parent">Inria Rennes</a>.</p> +<a href="http://team.inria.fr/lagadic" target="_parent">Lagadic</a> team located at <a +href="http://www.inria.fr/en/centre/rennes" target="_parent">Inria Rennes</a>.</p> <p>ViSP official site is <a -href="http://www.irisa.fr/lagadic/visp/visp.html" target="_parent">http://www.irisa.fr/lagadic/visp/visp.html</a></p> +href="http://team.inria.fr/lagadic/visp" target="_parent">http://team.inria.fr/lagadic/visp</a></p> <p>If you have any problems or find any bugs, please report them at <a href="http://gforge.inria.fr/tracker/?group_id=397" target="_parent">http://gforge.inria.fr/tracker/?group_id=397</a>. If you may need help, please use the available forums <a href="http://gforge.inria.fr/forum/?group_id=397" target="_parent">http://gforge.inria.fr/forum/?group_id=397</a> or mailing lists <a href="http://gforge.inria.fr/mail/?group_id=397" target="_parent">http://gforge.inria.fr/mail/?group_id=397</a>.<p> @@ -22,7 +22,7 @@ It is also possible to contact ViSP main developers using: <a href="mailto:visp@ \section download_sec Download <p>From <a -href="http://www.irisa.fr/lagadic/visp/download.html" target="_parent">http://www.irisa.fr/lagadic/visp/download.html</a> +href="http://team.inria.fr/lagadic/visp/download.html" target="_parent">http://team.inria.fr/lagadic/visp/download.html</a> you can either download the latest stable release or the current development distribution using Subversion.</p> @@ -35,31 +35,61 @@ href="http://www.cmake.org" target="_parent">http://www.cmake.org</a>. Furthermo depending on your operation system and the capabilities (framegrabber, display, simulation, ...) you need, prior to install ViSP you may install third party libraries <a -href="http://www.irisa.fr/lagadic/visp/libraries.html" target="_parent">http://www.irisa.fr/lagadic/visp/libraries.html</a>.</p> +href="http://team.inria.fr/lagadic/visp/libraries.html" target="_parent">http://team.inria.fr/lagadic/visp/libraries.html</a>.</p> -<p>ViSP full installation procedure using CMake is explained in the getting started documents available from <a -href="http://www.irisa.fr/lagadic/visp/publication.html" target="_parent">http://www.irisa.fr/lagadic/visp/publication.html</a>.</p> +<p>ViSP full installation procedure using CMake is detailed in the \ref tuto_intro "introduction tutorials". Getting started documents in pdf are also available from <a +href="http://team.inria.fr/lagadic/visp/publication.html" target="_parent">http://team.inria.fr/lagadic/visp/publication.html</a>.</p> \section Tutorial_sec Tutorials -<p>Here after you will find a list of tutorials that shows the basic use of <a href="classes.html">ViSP classes</a> with a small first code. +<p>Here after you will find a list of tutorials that show the basic use of <a href="classes.html">ViSP classes</a> with a small first code. + +\subsection tuto_intro Introduction + - \ref tutorial-install-ubuntu <br>In this first tutorial you will learn how to install ViSP from source on Linux Ubuntu. +- \ref tutorial-install-fedora <br>In this other tutorial you will learn how to install ViSP from source on Linux Fedora. - \ref tutorial-install-win <br>In this tutorial you will learn how to install ViSP from source on Windows. - \ref tutorial-install-iOS <br>In this tutorial you will learn how to install ViSP from source on OSX for iOS project. - \ref tutorial-getting-started <br>This tutorial shows how to build a project that uses ViSP to read and display an image. - \ref tutorial-getting-started-iOS <br>This tutorial shows how to build a project that uses ViSP on iOS devices. + +\subsection tuto_image Image manipulation + - \ref tutorial-grabber <br>This tutorial shows how to acquire images from a camera. +- \ref tutorial-image-filtering <br>This tutorial shows how to filter an image with ViSP. +- \ref tutorial-simu-image <br>This tutorial shows how to project the image of a planar scene to a given camera position. + +\subsection tuto_calib Camera calibration + - \ref tutorial-calibration <br>This tutorial explains how to calibrate a camera. + +\subsection tuto_tracking Tracking + - \ref tutorial-tracking-blob <br>This tutorial introduces blob tracking and detection. - \ref tutorial-tracking-keypoint <br>This tutorial focuses on keypoint tracking using Kanade-Lucas-Tomasi feature tracker. - \ref tutorial-tracking-me <br>This tutorial focuses on line and ellipse tracking using moving-edges. - \ref tutorial-tracking-mb <br>This tutorial focuses on model-based trackers using either edges, keypoints or and hybrid scheme that uses edges and keypoints. -- \ref tutorial-simu-image <br>This tutorial shows how to project the image of a planar scene to a given camera position. +- \ref tutorial-tracking-tt <br>This tutorial focuses on template trackers based on image registration approaches. + +\subsection tuto_keypoint Keypoint + +- \ref tutorial-matching <br>This tutorial shows how to detect and match SURF keypoints. + +\subsection tuto_computer_vision Computer vision + - \ref tutorial-pose-estimation <br>This tutorial focuses on pose estimation from planar or non planar points. +- \ref tutorial-homography <br>Here we explain how to estimate an homography from couples of matched points. + +\subsection tuto_vs Visual servoing + - \ref tutorial-ibvs <br>This tutorial explains how to simulate an IBVS. - \ref tutorial-simu-robot-pioneer <br>This tutorial focuses on visual servoing simulation on a unicycle robot. The study case is a Pioneer P3-DX mobile robot equipped with a camera. -- \ref tutorial-plotter <br>This tutorial explains how to plot curves in real-time during a visual servo. +- \ref tutorial-boost-vs <br>This tutorial explains how to speed up the time to convergence of a visual servo. +\subsection tuto_tools Other tools + +- \ref tutorial-plotter <br>This tutorial explains how to plot curves in real-time during a visual servo. +- \ref tutorial-trace <br>This tutorial explains how to introduce trace in the code that could be enabled for debugging or disabled. \section Examples_sec Using ViSP @@ -75,7 +105,7 @@ scheme, ...</p> <p>ViSP library is an open source C++ library which is developed at <a href="http://www.inria.fr/en/centre/rennes">Inria</a> by <a href="http://team.inria.fr/lagadic/welcome-eng.html">Lagadic team</a>. If you enjoy using ViSP, you may contribute to the project in different ways. This will motivate us to continue the efforts. -- You can help VISP to be more widely known, by displaying a <a href="http://www.irisa.fr/lagadic/visp/documentation/visp-flyers.pdf">ViSP flyer</a> at work, in your lab or school. +- You can help VISP to be more widely known, by displaying a <a href="http://team.inria.fr/lagadic/visp/documentation/visp-flyers.pdf">ViSP flyer</a> at work, in your lab or school. - You can submit a <a href="https://gforge.inria.fr/tracker/?atid=1867&group_id=397&func=browse">bug report using the tracker</a>. - You can submit <a href="https://gforge.inria.fr/tracker/?func=browse&group_id=397&atid=1660">patches or new functionalities here</a>. - You can write new tutorials, new documentations or simply improve the existing documentation. @@ -94,23 +124,55 @@ scheme, ...</p> /*! \defgroup Tutorial ViSP tutorials + Here after you will find a list of tutorials that shows the basic use of <a href="classes.html">ViSP classes</a> with a small first code. + +\section tuto_intro Introduction + - \ref tutorial-install-ubuntu <br>In this first tutorial you will learn how to install ViSP from source on Linux Ubuntu. +- \ref tutorial-install-fedora <br>In this other tutorial you will learn how to install ViSP from source on Linux Fedora. - \ref tutorial-install-win <br>In this tutorial you will learn how to install ViSP from source on Windows. - \ref tutorial-install-iOS <br>In this tutorial you will learn how to install ViSP from source on OSX for iOS project. - \ref tutorial-getting-started <br>This tutorial shows how to build a project that uses ViSP to read and display an image. - \ref tutorial-getting-started-iOS <br>This tutorial shows how to build a project that uses ViSP on iOS devices. + +\section tuto_image Image manipulation + - \ref tutorial-grabber <br>This tutorial shows how to acquire images from a camera. +- \ref tutorial-image-filtering <br>This tutorial shows how to filter an image with ViSP. +- \ref tutorial-simu-image <br>This tutorial shows how to project the image of a planar scene to a given camera position. + +\section tuto_calib Camera calibration + - \ref tutorial-calibration <br>This tutorial explains how to calibrate a camera. -- \ref tutorial-tracking-blob <br>This tutorial focuses on blob tracking and detection. + +\section tuto_tracking Tracking + +- \ref tutorial-tracking-blob <br>This tutorial introduces blob tracking and detection. - \ref tutorial-tracking-keypoint <br>This tutorial focuses on keypoint tracking using Kanade-Lucas-Tomasi feature tracker. - \ref tutorial-tracking-me <br>This tutorial focuses on line and ellipse tracking using moving-edges. - \ref tutorial-tracking-mb <br>This tutorial focuses on model-based trackers using either edges, keypoints or and hybrid scheme that uses edges and keypoints. -- \ref tutorial-simu-image <br>This tutorial shows how to project the image of a planar scene to a given camera position. +- \ref tutorial-tracking-tt <br>This tutorial focuses on template trackers based on image registration approaches. + +\section tuto_keypoint Keypoint + +- \ref tutorial-matching <br>This tutorial shows how to detect and match SURF keypoints. + +\section tuto_computer_vision Computer vision + - \ref tutorial-pose-estimation <br>This tutorial focuses on pose estimation from planar or non planar points. +- \ref tutorial-homography <br>Here we explain how to estimate an homography from couples of matched points. + +\section tuto_vs Visual servoing + - \ref tutorial-ibvs <br>This tutorial explains how to simulate an IBVS. - \ref tutorial-simu-robot-pioneer <br>This tutorial focuses on visual servoing simulation on a unicycle robot. The study case is a Pioneer P3-DX mobile robot equipped with a camera. +- \ref tutorial-boost-vs <br>This tutorial explains how to speed up the time to convergence of a visual servo. + +\section tuto_tools Other tools + - \ref tutorial-plotter <br>This tutorial explains how to plot curves in real-time during a visual servo. +- \ref tutorial-trace <br>This tutorial explains how to introduce trace in the code that could be enabled for debugging or disabled. */ diff --git a/doc/tutorial-boost-vs.doc b/doc/tutorial-boost-vs.doc new file mode 100644 index 0000000000000000000000000000000000000000..647e1e9ef6d8652850cad64c37ec812470cc95ba --- /dev/null +++ b/doc/tutorial-boost-vs.doc @@ -0,0 +1,98 @@ +/** + +\page tutorial-boost-vs Tutorial: How to boost your visual servo control law +\tableofcontents + +\section intro Introduction + +This tutorial gives some hints to boost your visual servo control law in order to speed up the time to convergence. + +To illustrate this tutorial let us consider the example tutorial-ibvs-4pts-plotter.cpp introduced in \ref tutorial-ibvs. This example consider an image based visual servoing using four points as visual features. + +In the general case, considering \f$ \dot {\bf q} \f$ as the input velocities to the robot controller, the control laws provided in vpServo class lead to the following control law \f$ \dot {\bf q} = \pm \lambda {{\bf \widehat J}_e}^+ {\bf e}\f$ where the sign is negative for an eye in hand servo and positive for an eye to hand servo, \f$\lambda\f$ is a constant gain, \f$ {\bf \widehat J}_e\f$ is the task Jacobian and \f$\bf e \f$ is the error to regulate to zero. As described in \cite Chaumette06a, this control law ensure an exponential decoupled decrease of the error \f${\dot {\bf e}} = \pm \lambda {\bf e}\f$. + +This behavior is illustrated with the next figure, where we see the exponential decrease of the eight visual features (x and y for each point) and the corresponding six velocities that are applied to the robot controller. As a consequence, velocities are high when the error is important, and very low when the error is small near the convergence. At the beginning, we can also notice velocity discontinuities with velocities varying from zero to high values in one iteration. + +\image html img-ibvs-control-law-exponential.png "Convergence in 191 iterations with a constant gain." + +This behavior can be reproduced running tutorial-ibvs-4pts-plotter.cpp example. Here after we recall the important lines of code used to compute the control law: + +\code + vpServo task ; + task.setServo(vpServo::EYEINHAND_CAMERA); + task.setInteractionMatrixType(vpServo::CURRENT); + task.setLambda(0.5); // Set the constant gain value + for (unsigned int i = 0 ; i < 4 ; i++) { + ... + task.addFeature(p[i], pd[i]); // Add visual features to the task + } + while(1) { + for (unsigned int i = 0 ; i < 4 ; i++) { + ... + vpFeatureBuilder::create(p[i], point[i]); // Update the visual features used in the task + } + vpColVector v = task.computeControlLaw(); // Compute the control law + } +\endcode + + +\section adaptive_gain Using an adaptive gain + +As implemented in tutorial-ibvs-4pts-plotter-gain-adaptive.cpp it is possible to adapt the gain \f$ \lambda \f$ in order to depend on the infinity norm of the task Jacobian. The usage of an adaptive gain rather than a constant gain allows to reduce the convergence time. In that case the gain becomes: + + \f[ \lambda (x) = a * exp (-b*x) + c \f] + + where \f$ a \f$, \f$ b \f$ and \f$ c \f$ are constant parameters and \f$ x \f$ is the infinity norm of the task Jacobian to consider. + + The parameters \f$a,b,c\f$ are not set directly. They are computed from three other parameters + \f$\lambda(0), \lambda(\infty), {\dot \lambda}(0)\f$ that are more intuitive to tune: + \f[ a = \lambda(0) - \lambda(\infty) \f] + \f[ b = {\dot \lambda}(0) / a \f] + \f[ c = \lambda(\infty) \f] + + Here \f$ \lambda(0)\f$ represents the gain when \f$x=0\f$, \f$ \lambda(\infty)\f$ represents the gain when \f$x=\infty\f$ + and \f$ {\dot \lambda}(0)\f$ represents the slope of \f$\lambda(x)\f$ when \f$x=0\f$. + +The impact of the adaptive gain is illustrated in the next figure. During the servo, velocities applied to the controller are higher, especially when the visual error \f${\bf e}\f$ is small. But as in the previous section, using an adaptive gain doesn't insure continuous velocities especially at the first iteration. + +\image html img-ibvs-control-law-adaptive.png "Convergence in 91 iterations with an adaptive gain." + +This behavior can be reproduced running tutorial-ibvs-4pts-plotter-gain-adaptive.cpp example. Compared to the previous code given in \ref intro and available in tutorial-ibvs-4pts-plotter.cpp, here after we give the new lines of code that were introduced to use an adaptive gain: + +\code + vpAdaptiveGain lambda(4, 0.4, 30); // lambda(0)=4, lambda(oo)=0.4 and lambda_dot(0)=30 + task.setLambda(lambda); +\endcode + + +\section continuous_adaptive_gain Continuous sequencing + +As implemented in tutorial-ibvs-4pts-plotter-continuous-gain-adaptive.cpp it is also possible to ensure continuous sequencing to avoid velocity discontinuities. This behavior is achieved by introducing an additional term to the general form of the control law. This additional term comes from the task sequencing approach described in \cite Mansard07e equation (17). It allows to compute continuous velocities by avoiding abrupt changes in the command. + + The form of the control law considered here is the following: + + \f[ + {\bf \dot q} = \pm \lambda {{\bf \widehat J}_e}^+ {\bf e} \mp \lambda {{\bf \widehat J}_{e(0)}}^+ {{\bf e}(0)} \exp(-\mu t) + \f] + + where : + - \f${\bf \dot q}\f$ is the resulting continuous velocity command to apply to the robot controller. + - the sign of the control law depends on the eye in hand or eye to hand configuration. + - \f$\bf J\f$ is the Jacobian of the task. + - \f$\bf e = (s-s^*)\f$ is the error to regulate. + - \f$t\f$ is the time. + - \f$\mu\f$ is a gain. We recommend to set this value to 4. + - \f${\bf \widehat J}_{e(0)}^+ {\bf e}(0)\f$ is the value of \f${\bf \widehat J}_e^+ {\bf e}\f$ when \f$t=0\f$. + + +The effect of continuous sequencing is illustrated in the next figure where during the first iterations velocities are starting from zero. + +\image html img-ibvs-control-law-continuous-adaptive.png "Convergence in 98 iterations with an adaptive gain and continuous sequencing." + +This behavior can be reproduced running tutorial-ibvs-4pts-plotter-continuous-gain-adaptive.cpp example. Compared to the previous code given in \ref adaptive_gain and available in tutorial-ibvs-4pts-plotter-gain-adaptive.cpp, here after we give the new line of code that were introduced to ensure continuous sequencing: + +\code + vpColVector v = task.computeControlLaw(iter*robot.getSamplingTime()); +\endcode + +*/ diff --git a/doc/tutorial-calibration.doc b/doc/tutorial-calibration.doc index 16c33c6161837dbfa6913069bf6937b2df4e4e3a..4df3bee73f8eef5598b15bd2f971dc86e3cd0def 100644 --- a/doc/tutorial-calibration.doc +++ b/doc/tutorial-calibration.doc @@ -48,16 +48,16 @@ The source code of the calibration tool is available in \c camera_calibration.cp We will not describe in detail the source, but just mention that: - the image processing is performed using OpenCV; - the estimation of the parameters is done using a virtual visual servoing scheme; -- the calibration tool takes as input a configuration file that allows to precise the kind of pattern used in the images (chessboard or circle grid), and the location of the images used as input. If \c libjpeg and \c libpng 3rd party libraries are installed and detected during ViSP configuration, you may consider .pgm, .ppm, .jpg, .png images. Default configuration files are provided in \c example/calibration folder; +- the calibration tool takes as input a configuration file that allows to precise the kind of pattern used in the images (chessboard or circles grid), and the location of the images used as input. If \c libjpeg and \c libpng 3rd party libraries are installed and detected during ViSP configuration, you may consider .pgm, .ppm, .jpg, .png images. Default configuration files are provided in \c example/calibration folder; - the resulting parameters are saved in \c camera.xml file. \section calibration_chessboard Calibration from a chessboard -In this section we consider the OpenCV chessboard pattern that has a size of 9 by 6. Each square of the chessboard is 0.025 meters large. We took 5 images called \c chessboard-01.png, \c chessboard-02.png, \c chessboard-03.png, \c chessboard-04.png, \c chessboard-05.png. Hereafter we give an example of such an image. These images are located in \c /tmp folder. +In this section we consider the OpenCV chessboard pattern that has a size of 9 by 6. Each square of the chessboard is 0.025 meters large. We took 5 images called \c chessboard-01.png, \c chessboard-02.png, ..., \c chessboard-05.png. Hereafter we give an example of one of these images. \image html img-chessboard-01.png Snapshot example of the chessboard used to calibrate the camera. -Before starting the calibration we need to create a configuration file. We create \c /tmp/chessboard.cfg with the following content: +Before starting the calibration we need to create a configuration file. We create \c default-chessboard.cfg with the following content: \code # Number of inner corners per a item row and column. (square, circle) BoardSize_Width: 9 @@ -71,12 +71,17 @@ Square_Size: 0.025 Calibrate_Pattern: CHESSBOARD # The input image sequence to use for calibration -Input: /tmp/chessboard-%02d.png +Input: chessboard-%02d.png + +# Tempo in seconds between two images. If > 10 wait a click to continue +Tempo: 1 \endcode +\note The images and the configuration file used in this tutorial are available in ViSP source code and copied in the same folder than the \c camera_calibration binary. + To estimate the camera parameters, just enter in ViSP \c \<binary_dir\>/examples/calibration and run: \code -./camera_calibration /tmp/chessboard.cfg +./camera_calibration default-chessboard.cfg \endcode This command will produce the following output: @@ -85,41 +90,48 @@ grid width : 9 grid height: 6 square size: 0.025 pattern : CHESSBOARD -input seq : /tmp/chessboard-%02d.png -frame: 1 status: 1 -frame: 2 status: 1 -frame: 3 status: 1 -frame: 4 status: 1 -frame: 5 status: 1 - -Calibration without distortion in progress on 5 images... +input seq : chessboard-%02d.png +tempo : 1 +frame: 1, status: 1, image used as input data +frame: 2, status: 1, image used as input data +frame: 3, status: 1, image used as input data +frame: 4, status: 1, image used as input data +frame: 5, status: 1, image used as input data + +Calibration without distorsion in progress on 5 images... Camera parameters for perspective projection without distortion: - px = 547.3080992 py = 546.9825167 - u0 = 324.6299338 v0 = 229.9072033 + px = 278.5184659 py = 273.9720502 + u0 = 162.1161106 v0 = 113.1789595 -Global reprojection error: 2.632851934 +Global reprojection error: 0.2784261067 Camera parameters without distortion successfully saved in "camera.xml" -Calibration with distortion in progress on 5 images... +Calibration with distorsion in progress on 5 images... Camera parameters for perspective projection with distortion: - px = 582.7521622 py = 580.6586412 - u0 = 326.5736348 v0 = 214.9591392 - kud = -0.3372254753 - kdu = 0.4021511255 + px = 276.3370556 py = 271.9804892 + u0 = 162.3656808 v0 = 113.4484506 + kud = 0.02739893948 + kdu = -0.02719442967 -Global reprojection error: 0.6350883328 +Global reprojection error: 0.2602153289 Camera parameters without distortion successfully saved in "camera.xml" + +Estimated pose on input data 0: 0.1004079988 0.07228624926 0.2759094615 0.1622201484 -0.04594748279 -3.067523182 +Estimated pose on input data 1: 0.1126235389 0.09590025615 0.2967542475 0.5743609549 -0.1960511892 -2.915893698 +Estimated pose on input data 2: 0.09983133876 0.08044014071 0.2920209765 -0.02917708148 -0.6751719307 3.046437745 +Estimated pose on input data 3: 0.07481330068 0.0832284992 0.2825482261 -0.09487329058 -0.220597075 -2.747906623 +Estimated pose on input data 4: 0.08061439562 0.08765353523 0.2837166409 0.1009190234 -0.09325252997 -2.906079819 \endcode The resulting parameters are also saved in \c ./camera.xml file. -\section calibration_circle Calibration from a circle grid +\section calibration_circle Calibration from a circles grid -In this section we consider the ViSP symmetric circle grid pattern that has a size of 6 by 6. Each circle center of gravity is 0.034 meters distant from it's horizontal or vertical neighbor. We took 6 images called \c circles-02.pgm, \c circles-03.pgm, ..., \c circles-07.pgm. Hereafter we give an example of such an image. These images are located in \c /tmp folder. +In this section we consider the ViSP symmetric circles grid pattern that has a size of 6 by 6. Each circle center of gravity is 0.034 meters distant from it's horizontal or vertical neighbor. We took 5 images called \c circles-01.pgm, \c circles-02.pgm, ..., \c circles-05.pgm. Hereafter we give an example of such an image. \image html img-circles-grid-02.png Snapshot example of the symmetric circles grid used to calibrate the camera. -Before starting the calibration we need to create a configuration file. We create \c /tmp/circles-grid.cfg with the following content: +Before starting the calibration we need to create a configuration file. We create \c circles-grid.cfg with the following content: \code # Number of inner corners per a item row and column. (square, circle) BoardSize_Width: 6 @@ -133,12 +145,17 @@ Square_Size: 0.034 Calibrate_Pattern: CIRCLES_GRID # The input image sequence to use for calibration -Input: /tmp/circles-%02d.pgm +Input: circles-%02d.pgm + +# Tempo in seconds between two images. If > 10 wait a click to continue +Tempo: 1 \endcode +\note The images and the configuration file used in this tutorial are available in ViSP source code and copied in the same folder than the \c camera_calibration binary. + To estimate the camera parameters, just enter in ViSP \c \<binary_dir\>/examples/calibration and run: \code -./camera_calibration /tmp/circles-grid.cfg +./camera_calibration circles-grid.cfg \endcode This command will produce the following output: @@ -147,39 +164,41 @@ grid width : 6 grid height: 6 square size: 0.034 pattern : CIRCLES_GRID -input seq : /tmp/circles-%02d.pgm -frame: 2 status: 1 -frame: 3 status: 1 -frame: 4 status: 1 -frame: 5 status: 0 -frame: 6 status: 1 -frame: 7 status: 1 - -Calibration without distortion in progress on 6 images... +input seq : circles-%02d.png +tempo : 1 +frame: 1, status: 1, image used as input data +frame: 2, status: 1, image used as input data +frame: 3, status: 1, image used as input data +frame: 4, status: 1, image used as input data +frame: 5, status: 1, image used as input data + +Calibration without distorsion in progress on 5 images... Camera parameters for perspective projection without distortion: - px = 552.4774691 py = 544.8066862 - u0 = 308.732533 v0 = 245.8146982 + px = 276.7844987 py = 273.2284128 + u0 = 164.029061 v0 = 113.2926414 -Global reprojection error: 0.2888553796 +Global reprojection error: 0.3245572722 Camera parameters without distortion successfully saved in "camera.xml" -Calibration with distortion in progress on 6 images... +Calibration with distorsion in progress on 5 images... Camera parameters for perspective projection with distortion: - px = 550.9009948 py = 543.1425164 - u0 = 309.1726232 v0 = 245.7667949 - kud = 0.01091468479 - kdu = -0.01088523009 + px = 272.6576029 py = 268.9209423 + u0 = 163.3267494 v0 = 112.9548567 + kud = 0.03132515383 + kdu = -0.03098719022 -Global reprojection error: 0.2763660773 +Global reprojection error: 0.2985458516 Camera parameters without distortion successfully saved in "camera.xml" + +Estimated pose on input data 0: -0.08883802146 -0.07573082723 0.254649414 0.009277810667 -0.1162730223 -0.06217958144 +Estimated pose on input data 1: -0.03031929668 -0.07792577124 0.226777101 0.04390110018 -0.474640394 0.09584680839 +Estimated pose on input data 2: 0.02757364367 -0.08075508106 0.2416734821 0.2541005213 -0.469141926 0.5746851856 +Estimated pose on input data 3: -0.08528071 -0.0552184701 0.216359278 0.433944401 -0.01692119727 -0.01151973247 +Estimated pose on input data 4: -0.1104723502 -0.0854285443 0.2684946566 0.4130829919 0.1926077657 0.2736623762 \endcode The resulting parameters are also saved in \c ./camera.xml file. -Note here that the following line indicates that the 5th frame corresponding to the image \c circles-05.pgm was not used in the calibration process since the status of the image processing is false. -\code -frame: 5 status: 0 -\endcode \section calibration_undistort Distorsion removal diff --git a/doc/tutorial-getting-started.doc b/doc/tutorial-getting-started.doc index 4532c3efc7328217bfa363e43f96af3828a78002..e8bc1c9d00c8b3b976e04d8e95d63c3e92acdd33 100644 --- a/doc/tutorial-getting-started.doc +++ b/doc/tutorial-getting-started.doc @@ -86,13 +86,46 @@ The title of the display is then set to \c "My image". \section image_cmake Create a CMake file -Now you have to create your CMakeLists.txt file. It should look like this: +Now you have to create your \c CMakeLists.txt file. It should look like this: \code project(tutorial-image) cmake_minimum_required(VERSION 2.6) +find_package(VISP REQUIRED) +if(VISP_FOUND) + add_definitions(${VISP_DEFINITIONS}) + include_directories(${VISP_INCLUDE_DIRS}) + link_directories(${VISP_LIBRARY_DIRS}) + link_libraries(${VISP_LIBRARIES}) +endif(VISP_FOUND) + +add_executable(tutorial-viewer tutorial-viewer.cpp) +\endcode + +The \c find_package() CMake command searches for a \c VISPConfig.cmake file that will define the corresponding variables: +- \c VISP_ROOT_DIR : ViSP base directory location +- \c VISP_INCLUDE_DIRS : ViSP and third-party headers location +- \c VISP_LIBRARY_DIRS : ViSP and third-party libraries location +- \c VISP_LIBRARY : ViSP library name +- \c VISP_LIBRARIES : ViSP and third-party libraries name +- \c VISP_DEFINITIONS : Defines required to build with ViSP + +In the previous \c CMakeLists.txt file, it is also possible to remove the line that started with \c link_libraries() and to specifically link a binary with ViSP using: + +\code +... +add_executable(tutorial-viewer tutorial-viewer.cpp) +target_link_libraries(tutorial-viewer ${VISP_LIBRARIES}) +\endcode + +Note also that the previous \c CMakeLists.txt file can also be: +\code +project(tutorial-image) + +cmake_minimum_required(VERSION 2.6) + find_package(VISP REQUIRED) if(VISP_FOUND) include(${VISP_USE_FILE}) @@ -101,6 +134,19 @@ endif(VISP_FOUND) add_executable(tutorial-viewer tutorial-viewer.cpp) \endcode +where \c VISP_USE_FILE variable is set to the full path to \c VISPUse.cmake file that contains all the CMake material that allow to build your project with ViSP. In other terms, the line +\code + include(${VISP_USE_FILE}) +\endcode +will include the following lines to your \c CMakeFile.txt +\code + add_definitions(${VISP_DEFINITIONS}) + include_directories(${VISP_INCLUDE_DIRS}) + link_directories(${VISP_LIBRARY_DIRS}) + link_libraries(${VISP_LIBRARIES}) +\endcode + + \section image_unix On Unix-like systems \subsection image_unix_config Configure your project @@ -111,6 +157,31 @@ Proceed as with any other project using CMake: cmake . \endcode +By default \c cmake searches \c VISPConfig.cmake file in folders like \c /usr/share or \c /usr/local/share. If ViSP was not installed in \c /usr or \c /usr/local it is possible that you get the following error: +\code +CMake Error at CMakeLists.txt:5 (find_package): + Could not find module FindVISP.cmake or a configuration file for package + VISP. + + Adjust CMAKE_MODULE_PATH to find FindVISP.cmake or set VISP_DIR to the + directory containing a CMake configuration file for VISP. The file will + have one of the following names: + + VISPConfig.cmake + visp-config.cmake +\endcode + +To help \c cmake to find \c VISPConfig.cmake file, just set \c VISP_DIR environment variable and call \c cmake again: +\code +export VISP_DIR=/home/ViSP-install-folder +cmake . +\endcode +or run cmake with the additional VISP_DIR definition +\code +cmake -DVISP_DIR=/home/ViSP-install-folder . +\endcode + + \subsection image_unix_build Generate the executable Just run: @@ -180,5 +251,5 @@ We suppose from now, that you have created a folder (let say \c C:/ViSP/ViSP-sta \image html img-lena-win.jpg -You are now ready to see the next \ref tutorial-grabber. +You are now ready to see the \ref tutorial-grabber or \ref tutorial-image-filtering. */ diff --git a/doc/tutorial-homography.doc b/doc/tutorial-homography.doc new file mode 100644 index 0000000000000000000000000000000000000000..ba3cc60737e53995e8fed7620bbc3e165d0681f8 --- /dev/null +++ b/doc/tutorial-homography.doc @@ -0,0 +1,250 @@ +/** + +\page tutorial-homography Tutorial: Homography estimation from points + +\tableofcontents + +\section intro Introduction + +This tutorial shows how to estimate an homography from points. Two cases are considered in the next sections: +- points are matched without possible mismatches. In that case vpHomography::DLT() or vpHomography::HLM() are used to estimate the homography, +- points are matched with possible mismatches. In that case vpHomography::ransac() or vpHomography::robust() are used. + +\section homography Homography estimation + +Let us consider the following source code also available in tutorial-homography.cpp. To resume, we do the following: +- define four 3D points \c oP in an object frame, +- define an homogeneous transformation \c aMo from frame \c a to to the object frame \c o, +- define a similar homogeneous transformation \c bMo from frame \c b to to the object frame \c o, +- compute the coordinates of the four 3D points in the image plane \c a and \c b. These are the matched coordinates \c (xa,ya) and \c (xb,yb) that are then used to estimate the homography using either vpHomography::DLT() or vpHomography::HLM(). + +\include tutorial-matching-surf-homography.cpp + +Now we give a line by line explanation of the code: + +First we have to include the header of the vpHomography class. +\code +#include <visp/vpHomography.h> +\endcode + +In the main() function we first define the 3D coordinates of 4 points that are localized in the plane Z=0: +\code + double L = 0.1; + std::vector<vpPoint> oP(4); + oP[0].setWorldCoordinates( -L,-L, 0); + oP[1].setWorldCoordinates(2*L,-L, 0); + oP[2].setWorldCoordinates( L, 3*L, 0); + oP[3].setWorldCoordinates( -L, 4*L, 0); +\endcode + +Then we define the homogeneous transformations between frames \c a, \c b and object frame \c o: +\code + vpHomogeneousMatrix bMo(0.1, 0, 1, 0, vpMath::rad(15), 0); + vpHomogeneousMatrix aMb(0.2, -0.1, 0.1, vpMath::rad(-3), vpMath::rad(20), vpMath::rad(5)); + vpHomogeneousMatrix aMo = aMb*bMo; +\endcode + +From these transformations we compute the homogeneous coordinates of the points in the image plane \c a and \c b. For each point we have its coordinates \c (xa,ya) in frame \c a and \c (xb,yb) in frame \c b: +\code + std::vector<vpPoint> aP(4), bP(4); + std::vector<double> xa(4), ya(4), xb(4), yb(4); + for(int i=0 ; i < 4; i++) + { + oP[i].project(aMo); + xa[i] = oP[i].get_x(); + ya[i] = oP[i].get_y(); + oP[i].project(bMo); + xb[i] = oP[i].get_x(); + yb[i] = oP[i].get_y(); + } +\endcode + +We have now matched couples of coordinates of four points that are used to estimate an homography between image plane \c a and \c b. Two methods are available, either using the DLT (Direct Linear Transform) algorithm or the HLM algorithm. +\code + vpHomography aHb ; + + // Compute the homography using DLT + vpHomography::DLT(xb, yb, xa, ya, aHb, true); + std::cout << "Estimated homography using DLT:\n" << aHb/aHb[2][2] << std::endl; + + // Compute the homography using HLM + vpHomography::HLM(xb, yb, xa, ya, true, aHb); + std::cout << "Estimated homography using HLM:\n" << aHb/aHb[2][2] << std::endl; +\endcode + +\note Note that vpHomography::HLM() allows to consider points that are not coplanar. + +Once the homography is estimated, the vpHomography class allows to extract the 3D homogeneous transformation between frames \c a and \c b: +\code + vpRotationMatrix aRb; + vpTranslationVector atb; + vpColVector n; + aHb.computeDisplacement(aRb, atb, n); +\endcode + +Just for fun we print the values to this transformation using: +\code + std::cout << "\nEstimated displacement:" << std::endl; + std::cout << " atb: " << atb.t() << std::endl; + vpThetaUVector atub; + atub.buildFrom(aRb); + std::cout << " athetaub: "; + for(unsigned int i=0; i<3; i++) + std::cout << vpMath::deg(atub[i]) << " "; + std::cout << std::endl; + std::cout << " n: " << n.t() << std::endl; +\endcode + +This code lead to the following output: +\code +Estimated displacement: + atb: 0.2016519874 -0.1008259937 0.1008259937 + athetaub: -3 20 5 + n: 0.2588190451 -1.124100812e-14 0.9659258263 +\endcode +where we can see that the values for \c atb and \c athetaub are the one specified at the beginning of the source code during \c aMb initialization. + +After we show how to retrieve the coordinates in pixels of a point (here point [3]) in the corresponding images using camera parameters: +\code + vpImagePoint iPa, iPb; + vpCameraParameters cam; + vpMeterPixelConversion::convertPoint(cam, xb[3], yb[3], iPb); + vpMeterPixelConversion::convertPoint(cam, xa[3], ya[3], iPa); + + std::cout << " Ground truth: Point 3 in pixels in frame b: " << iPb << std::endl; + std::cout << " Ground truth: Point 3 in pixels in frame a: " << iPa << std::endl; +\endcode + +At the end, we show how to project a point with pixel coordinates from image \c b to image \c a using the homography: +\code + std::cout << "Estimation from homography: Point 3 in pixels in frame a: " + << vpHomography::project(cam, aHb, iPb) << std::endl; +\endcode + +This last part of the code produce the following output: +\code +Ground truth: Point 3 in pixels in frame b: 377.9450564, 193.9928711 +Ground truth: Point 3 in pixels in frame a: 353.8501593, 486.1851856 +Estimation from homography: Point 3 in pixels in frame a: 353.8501593, 486.1851856 +\endcode + + +\section ransac Ransac or robust homography estimation + +This section follows the \ref tutorial-matching. It explains how to exploit couples of matched points obtained using SURF detector in order to estimate an homography that allows to reject mismatched couples of points. The homography is then used to track a postcard from its initial position in the reference image. + + +Let us consider the following source code also available in tutorial-matching-surf-homography.cpp. + +\include tutorial-matching-surf-homography.cpp + +The command line allows to use either Ransac algorithm of a robust M-estimator approach: +\code +% ./tutorial-matching-surf-homography 0 // to run Ransac +% ./tutorial-matching-surf-homography 1 // to run the robust M-estimator +\endcode + +Here after is the resulting video. The left image represents the reference image. The right images correspond to the successive images of the input video. All the green lines extremities represent the points that are well matched and used in the homography estimation process. All the red lines represent couple of matched points that are rejected by the robust estimator. + +\htmlonly +<iframe width="560" height="315" src="http://www.youtube.com/embed/g-aEH5Chmsg" frameborder="0" allowfullscreen></iframe> +\endhtmlonly + +Now, let us explain the new lines that were introduced to estimate the homography. + +First we detect the command line arguments to be able later to user either Ransac or the robust M-estimator: +\code + int method = 0; + + if (argc > 1) + method = atoi(argv[1]); + + if (method == 0) + std::cout << "Uses Ransac to estimate the homography" << std::endl; + else + std::cout << "Uses a robust scheme to estimate the homography" << std::endl; +\endcode + +We also initialize the coordinates of the pixels in the reference image that correspond to the postcard corners. These coordinates were obtained after a user initial click. To simplify the code, we set directly the coordinates of the points: +\code + vpImagePoint corner_ref[4]; + corner_ref[0].set_ij(115, 64); + corner_ref[1].set_ij( 83, 253); + corner_ref[2].set_ij(282, 307); + corner_ref[3].set_ij(330, 72); +\endcode + +Using these coordinates, we display red lines around the postcard: +\code + for (unsigned int i=0; i<4; i++) { + vpDisplay::displayCross(Idisp, corner_ref[i], 12, vpColor::red); + } + vpDisplay::flush(Idisp); +\endcode + +We need also to define roughly the parameters of our camera: +\code + vpCameraParameters cam(840, 840, I.getWidth()/2, I.getHeight()/2); +\endcode + +For each new image, once points are matched using: +\code + unsigned int nbMatch = surf.matchPoint(I); +\endcode + +We allocate new containers useful for the homography estimation. The coordinates of the points in the reference image will be stored in \c (mPref_x, mPref_y), while the corresponding coordinates in the current image will be stored in \c (mPcur_x, mPcur_y). We also allocate \c inliers a vector of boolean that will indicate if a couple of point is an inlier or an outlier: +\code + std::vector<double> mPref_x(nbMatch), mPref_y(nbMatch); + std::vector<double> mPcur_x(nbMatch), mPcur_y(nbMatch); + std::vector<bool> inliers(nbMatch); +\endcode + +To estimate the homography we need first to convert the points from pixel to meters: +\code + vpPixelMeterConversion::convertPoint(cam, matched_ref, mPref_x[i], mPref_y[i]); + vpPixelMeterConversion::convertPoint(cam, matched_cur, mPcur_x[i], mPcur_y[i]); +\endcode + +We can now estimate the homography using either Ransac or the robust M-estimator approach: +\code + double residual; + if (method == 0) + vpHomography::ransac(mPref_x, mPref_y, mPcur_x, mPcur_y, curHref, inliers, residual, + mPref_x.size()/2, 2.0/cam.get_px(), true); + else + vpHomography::robust(mPref_x, mPref_y, mPcur_x, mPcur_y, curHref, inliers, residual, + 0.4, 4, true); +\endcode + +For Ransac we consider that at least 50 percent of the points should be inliers (\c mPref_x.size()/2) to reach a consensus and that a couple of point is stated as an inlier if the reprojection error is lower than 2 pixels (\c 2.0/cam.get_px()). + +Then using the homography, we project the coordinates of the postcard corners in the current image: +\code + vpImagePoint corner_ref[4], corner_cur[4]; + for (int i=0; i< 4; i++) { + corner_cur[i] = vpHomography::project(cam, curHref, corner_ref[i]); + } +\endcode + +We use these coordinates to draw blue lines arround the postcard: +\code + vpImagePoint offset(0, I.getWidth()); + for (int i=0; i< 4; i++) { + vpDisplay::displayLine(Idisp, + corner_cur[i] + offset, + corner_cur[(i+1)%4] + offset, + vpColor::blue, 3); + } +\endcode + +Since the homography estimation updates the status of the couples of matched points as inliers or outliers, between the matched points we are able to draw green lines when they are inliers, or red lines when they are outliers. +\code + for (unsigned int i = 0; i < nbMatch; i++) { + if(inliers[i] == true) + vpDisplay::displayLine(Idisp, iPref[i], iPcur[i] + offset, vpColor::green); + else + vpDisplay::displayLine(Idisp, iPref[i], iPcur[i] + offset, vpColor::red); + } +\endcode + +*/ diff --git a/doc/tutorial-ibvs.doc b/doc/tutorial-ibvs.doc index 694fd20c71719515fdf50cb1e0dcc7264aa820b9..be371d3c41281fed77098cf318deb12fd0bec95a 100644 --- a/doc/tutorial-ibvs.doc +++ b/doc/tutorial-ibvs.doc @@ -104,7 +104,7 @@ It is now time to define four visual features as points in the image-plane. To t Each feature is obtained by computing the position of the 3D points in the corresponding camera frame, and then by applying the perspective projection. Once current and desired features are created, they are added to the visual servo task. \code - for (int i = 0 ; i < 4 ; i++) { + for (unsigned int i = 0 ; i < 4 ; i++) { point[i].track(cdMo); vpFeatureBuilder::create(pd[i], point[i]); point[i].track(cMo); @@ -141,7 +141,7 @@ Now we can enter in the visual servo loop. When a velocity is applied to our fre The current visual features are then updated by projecting the 3D points in the image-plane associated to the new camera location \c cMo. \code - for (int i = 0 ; i < 4 ; i++) { + for (unsigned int i = 0 ; i < 4 ; i++) { point[i].track(cMo); vpFeatureBuilder::create(p[i], point[i]); } @@ -232,7 +232,7 @@ We create an instance of the vpProjectionDisplay class. This class is only avail \code #if defined(VISP_HAVE_DISPLAY) vpProjectionDisplay externalview; - for (int i = 0 ; i < 4 ; i++) + for (unsigned int i = 0 ; i < 4 ; i++) externalview.insert(point[i]) ; #endif \endcode @@ -354,7 +354,7 @@ To retrieve the simulated image that depends on the simulated camera position we The current visual features are computed using a vpDot2 blob tracker. Once four trackers are instantiated, we are waiting for a mouse click in each blob to initialize the tracker. Then we compute the current visual features \f$(x,y) \f$ from the camera parameters and the cog position of each blob. \code - for (int i = 0 ; i < 4 ; i++) { + for (unsigned int i = 0 ; i < 4 ; i++) { ... dot[i].setGraphics(true); dot[i].initTracking(I); @@ -372,7 +372,7 @@ In the visual servo loop, at each iteration we get a new image of the target. We track each blob and update the values of the current visual features as previously. \code - for (int i = 0 ; i < 4 ; i++) { + for (unsigned int i = 0 ; i < 4 ; i++) { dot[i].track(I); vpFeatureBuilder::create(p[i], cam, dot[i].getCog()); \endcode @@ -387,4 +387,5 @@ depends on \f$(x,y)\f$ but also on \f$Z\f$ the depth of the feature, we need to } \endcode +You are now ready to see the \ref tutorial-simu-robot-pioneer and \ref tutorial-boost-vs. */ diff --git a/doc/tutorial-image-filtering.doc b/doc/tutorial-image-filtering.doc new file mode 100644 index 0000000000000000000000000000000000000000..f7120c07445710fd3e48a67f8e21422d86b3d9e8 --- /dev/null +++ b/doc/tutorial-image-filtering.doc @@ -0,0 +1,152 @@ +/** + +\page tutorial-image-filtering Tutorial: Image filtering +\tableofcontents + +This tutorial supposes that you have followed the \ref tutorial-getting-started. + +\section intro Introduction + +In this tutorial you will learn how to use ViSP filtering functions implemented in vpImageFilter class. + +Let us consider the following source code that comes from tutorial-image-filter.cpp. + +\include tutorial-image-filter.cpp + +Once build, you should have \c tutorial-image-filter binary. It shows how to apply different filters on an input image. Here we will consider lena.pgm as input image. + +\image html img-lena-gray.png + +To see the resulting filtered images, just run: + +\code +./tutorial-image-filter lena.pgm +\endcode + +The following sections give a line by line explanation of the source code dedicated to image filtering capabilities. + +\section blur Gaussian blur + +Lena input image is read from disk and is stored in \c I which is a gray level image declared as + +\code +vpImage<unsigned char> I; +\endcode + +To apply a Gaussian blur to this image we first have to declare a resulting floating-point image \c F. Then the blurred image could be obtained using the default Gaussian filter: + +\code +vpImage<double> F; +vpImageFilter::gaussianBlur(I, F); +\endcode + +The resulting image is the following: + +\image html img-lena-blured-default.png + +It is also possible to specify the Gaussian filter kernel size and the Gaussian standard deviation (sigma) using: + +\code +vpImageFilter::gaussianBlur(I, F, 7, 2); // Kernel size: 7, sigma: 2 +\endcode + +We thus obtain the following image: + +\image html img-lena-blured-var2.png + +\section gradient Gradients computation + +To compute the gradients or the spatial derivative along X use: + +\code +vpImage<double> dIx; +vpImageFilter::getGradX(I, dIx); +\endcode + +Gradients along Y could be obtained using: + +\code +vpImage<double> dIy; +vpImageFilter::getGradY(I, dIy); +\endcode + +The resulting floating-point images \c dIx, \c dIy are the following: + +\image html img-lena-dIxy.png + +\section canny Canny edge detector + +Canny edge detector function is only available if ViSP was build with OpenCV 2.1 or higher. + +After the declaration of a new image container \c C, Canny edge detector is applied using: +\code +#if (VISP_HAVE_OPENCV_VERSION >= 0x020100) + vpImage<unsigned char> C; + vpImageFilter::canny(I, C, 5, 15, 3); +#endif +\endcode + +Where: +- 5: is the low threshold +- 15: is the high threshold set in the program as three times the lower threshold (following Canny’s recommendation) +- 3: is the size of the Sobel kernel used internally. + +The resulting image \c C is the following: + +\image html img-lena-canny.png + + +\section convolution Convolution + +To apply a convolution to an image, we first have to define a kernel. +For example, let us consider the 3x3 Sobel kernel defined in \c K. + + \f[ + {\bf K} = \begin{tabular}{|c|c|c|} + \hline + 1 & 0 & -1 \\ + \hline + 2 & 0 & -2 \\ + \hline + 1 & 0 & -1 \\ + \hline + \end{tabular} + \f] + + +\code + vpMatrix K(3,3); // Sobel kernel along x + K[0][0] = 1; K[0][1] = 0; K[0][2] = -1; + K[1][0] = 2; K[1][1] = 0; K[1][2] = -2; + K[2][0] = 1; K[2][1] = 0; K[2][2] = -1; +\endcode + +After the declaration of a new floating-point image \c Gx, the convolution is obtained using: +\code + vpImage<double> Gx; + vpImageFilter::filter(I, Gx, K); +\endcode + +The content of the filtered image \c Gx is the following. + +\image html img-lena-sobel.png + +\section pyramid Gaussian image pyramid + +To construct a pyramid of Gaussian filtered images as a vector of images implemented in \c pyr[] you may use: +\code + size_t nlevel = 3; + std::vector< vpImage<unsigned char> > pyr(nlevel); + pyr[0] = I; + for (size_t i=1; i < nlevel; i++) { + vpImageFilter::getGaussPyramidal(pyr[i-1], pyr[i]); + display(pyr[i], "Pyramid"); + } +\endcode + +The content of \c pyr[0], \c pyr[1], \c pyr[2] is the following: +\image html img-lena-pyr.png + +You are now ready to see the next \ref tutorial-tracking-blob. + +*/ diff --git a/doc/tutorial-install-fedora.doc b/doc/tutorial-install-fedora.doc new file mode 100644 index 0000000000000000000000000000000000000000..d61fce6404dbbc5a36e5e7a633b4f29668226a5e --- /dev/null +++ b/doc/tutorial-install-fedora.doc @@ -0,0 +1,227 @@ +/** + +\page tutorial-install-fedora Tutorial: Installation from source on Linux Fedora +\tableofcontents + +In this tutorial you will learn how to install ViSP from source on Linux Fedora. These steps have been tested for Fedora 18 (64 bit) distribution, but should work with any other distribution as well. + +Concerning ViSP installation, we provide also other tutorials +- \ref tutorial-install-ubuntu +- \ref tutorial-install-win +- \ref tutorial-install-iOS + +ViSP can also be installed on other platforms including OSX, CentOS, openSUZE (see <a href="http://www.irisa.fr/lagadic/visp/install.html">Install from source page</a>). + + +\section install_ubuntu_required Required packages + +- gcc 4.4.x or later. This can be installed with: +\code +su -c "yum install gcc-c++" +\endcode +- CMake 2.6 or higher that could be installed with: +\code +su -c "yum install cmake" +\endcode + + +ViSP is interfaced with several optional <a href="http://www.irisa.fr/lagadic/visp/libraries.html">third-party libraries</a>. The installation of the corresponding packages is described in \ref install_fedora_3rdparty section. + +\section install_fedora_get_source Getting ViSP source code + +There are different ways to get ViSP source code: + +- You can download the <a href="http://www.irisa.fr/lagadic/visp/download.html#latest">latest stable release</a> as a zip or a tarball. Once downloaded, uncompress the file using either +\code +tar xvzf ViSP-2.9.0.tar.gz +\endcode +or +\code +unzip ViSP-2.9.0.zip +\endcode + +- You can also download a more <a href="http://www.irisa.fr/lagadic/visp/download.html#snapshot">recent snapshot</a>. Once downloaded, uncompress the file using +\code +unzip ViSP-2.y.z-snapshot-2014.mm.dd.zip +\endcode +- Or you get the cutting-edge ViSP from Subversion repository. To this end you have first to install subversion +\code +su -c "yum install subversion" +\endcode +and then use the following command +\code +svn checkout svn://scm.gforge.inria.fr/svn/visp/trunk/ViSP ViSP-trunk +\endcode + +We suppose now that ViSP source is in a directory denoted \<source_dir\>, for example \c $HOME/ViSP-2.9.0 + +\section install_fedora_config Configuring ViSP from source + +- Create first a directory denoted \<binary_dir\> where you want to build ViSP. This directory will contain generated Makefiles, object files, and output libraries and binaries. +\code +cd $HOME; mkdir ViSP-build-release +\endcode + +- Enter the \<binary_dir\> and to configure the build type: +\code +cmake [<optional parameters>] <source_dir> +\endcode +For example: +\code +cd $HOME/ViSP-build-release +cmake -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_SHARED_LIBS=ON ../ViSP-2.9.0 +\endcode +A more versatile way to configure the build is to use \c ccmake, the CMake GUI: +\code +ccmake ../ViSP-2.9.0 +\endcode +The following image shows that this command allows to configure (just by pressing [c] key) the build in a more advanced way where some options could be easily turned On/Off. It allows also to see which are the 3rd party that will be used. +\image html img-ccmake-ubuntu.png Snapshot of the ccmake \c ../ViSP-2.9.0 command used to configure ViSP. + +- There is an other way to see which are the 3rd party that are found during the configuration stage and that will be used by ViSP during the build. To this end you can have a look to the text file named ViSP-third-party.txt and located in \<binary_dir\>. We provide hereafter an example of a possible content of this file: +\code + ViSP third-party libraries + +Below you will find the list of third party libraries used to +build ViSP on your computer. + +Mathematics: + Gnu Scientific Library : no + Lapack/blas : no +Simulator: + Ogre simulator : no + \- Ogre3D : no + \- OIS : no + Coin simulator : + \- Coin3D : no + \- SoWin : no + \- SoXt : no + \- SoQt : no + \- Qt4 : no + \- Qt3 : no +Robots + Afma6 : no + Afma4 : no + Biclops : no + Ptu46 : no + Pioneer : no + Viper S650 : no + Viper S850 : no + Cycab : no +Video devices (display) + X11 : no + GTK : no + OpenCV : no + GDI : no + Direct3D : no +Framegrabbers + Firewire libdc1394-1.x : no + Firewire libdc1394-2.x : no + Video For Linux Two : no + DirectShow : no + CMU 1394 Digital Camera SDK : no + OpenCV : no +Specific devices + Yarp : no + Kinect : no + \-libfreenect : no + \-libusb-1.0 : no + \-pthread : yes +Video and image Read/Write: + FFMPEG : no + libjpeg : no + libpng : no +Misc: + XML2 : no + pthread : yes + OpenMP : yes +Documentation: + Doxygen : no + Graphviz dot : no +ViSP built with C++11 features: no +\endcode +In our case, only \c pthread an OpenMP 3rd party are detected. + +\subsection install_fedora_3rdparty Optional 3rd party packages + +As mentioned previously, ViSP is interfaced with some 3rd party libraries. The <a href="http://www.irisa.fr/lagadic/visp/libraries.html">complete list is provided here</a>. We recommand to install the following: + +- OpenCV +\code +su -c "yum install opencv-devel" +\endcode +- libX11 to be able to open a window to display images +\code +su -c "yum install libX11-devel" +\endcode +- lapack and gsl to benefit from optimized mathematical capabilities +\code +su -c "yum install lapack-devel gsl-devel" +\endcode +- libdc1394 to grab images from firewire cameras +\code +su -c "yum install libdc1394-devel" +\endcode +- libv4l to grab images from usb or analogic cameras +\code +su -c "yum install libv4l-devel" +\endcode +- Coin, to be able to support vrml cad model used by the model-based trackers +\code +su -c "yum install Coin2-devel" +\endcode +- libxml2 to be able to configure the model-based trackers from xml files +\code +su -c "yum install libxml2-devel" +\endcode +- libjpeg, libpng to support jpeg and png images +\code +su -c "yum install libjpeg-devel libpng-devel" +\endcode +- ffmpeg, to be able to read or encode compressed video streams +\code +su -c "yum install ffmpeg-devel" +\endcode +- Ogre 3D if you want to do augmented reality or simulation +\code +su -c "yum install ogre-devel ogre-samples ois-devel" +\endcode + +Once installed, if you want that ViSP exploit the new 3rd party, you have to configure ViSP again. + +\code +ccmake ../ViSP-2.9.0 +\endcode +The following image shows now that all the previous optional 3rd party are detected. +\image html img-ccmake-ubuntu-all.png Snapshot of the ccmake \c ../ViSP-2.9.0 command used to configure ViSP after installation of optional 3rd party libraries. + +\subsection install_ubuntu_generate Generating Makefiles + +To generate the makefiles, just press [g] key in the ccmake gui. + +Now we can build ViSP. + +\section install_fedora_build Building ViSP from source + +- To build ViSP proceed with: +\code +make +\endcode + +- To install ViSP proceed with: +\code +sudo make install +\endcode + +- To build ViSP documentation, you have first to install Doxygen package: +\code +su -c "yum install doxygen graphviz" +\endcode +Then you can proceed with: +\code +make html-doc +\endcode + +You are now ready to see the next \ref tutorial-getting-started that will show you how to use ViSP as a 3rd party to build your own project. + +*/ diff --git a/doc/tutorial-install-iOS.doc b/doc/tutorial-install-iOS.doc index e327c6f3b849dbccec693ce98c4922adb14bd889..628258be6f85fb078e13dde3a47e314ce37af4dd 100644 --- a/doc/tutorial-install-iOS.doc +++ b/doc/tutorial-install-iOS.doc @@ -6,10 +6,11 @@ In this tutorial you will learn how to install ViSP from source on OSX in order to be able to compile and use it for iOS development. These steps have been tested for OSX 10.8.4 but should work with any other distribution as well. Concerning ViSP installation, we provide also other tutorials -- \ref tutorial-install-win - \ref tutorial-install-ubuntu +- \ref tutorial-install-fedora +- \ref tutorial-install-win -ViSP can also be installed on other platforms including OSX, Fedora, CentOS, openSUZE (see <a href="http://www.irisa.fr/lagadic/visp/install.html">Install from source page</a>). +ViSP can also be installed on other platforms including OSX, CentOS, openSUZE (see <a href="http://www.irisa.fr/lagadic/visp/install.html">Install from source page</a>). \section install_iOS_required Required software @@ -25,23 +26,23 @@ There are different ways to get ViSP source code: - You can download the <a href="http://www.irisa.fr/lagadic/visp/download.html#latest">latest stable release</a> as a zip or a tarball. Once downloaded, uncompress the file using either \code -tar xvzf ViSP-2.7.0.tar.gz +tar xvzf ViSP-2.9.0.tar.gz \endcode or \code -unzip ViSP-2.7.0.zip +unzip ViSP-2.9.0.zip \endcode - You can also download a more <a href="http://www.irisa.fr/lagadic/visp/download.html#snapshot">recent snapshot</a>. Once downloaded, uncompress the file using \code -unzip ViSP-2.7.1-snapshot-2013.05.02.zip +unzip ViSP-2.y.z-snapshot-2014.mm.dd.zip \endcode - Or you get the cutting-edge ViSP from Subversion repository. To this end you have first to install subversion and then use the following command \code svn checkout svn://scm.gforge.inria.fr/svn/visp/trunk/ViSP ViSP-trunk \endcode -We suppose now that ViSP source is in a directory denoted \<source_dir\>, for example \c $HOME/ViSP-2.7.0 +We suppose now that ViSP source is in a directory denoted \<source_dir\>, for example \c $HOME/ViSP-2.9.0 \section install_iOS_config Configuring ViSP from source diff --git a/doc/tutorial-install-ubuntu.doc b/doc/tutorial-install-ubuntu.doc index fa0a25e16a13a776eeacd5cc4a81e9d7370cd77f..c022a36c5a655d2801968c8bf45f8008811f61aa 100644 --- a/doc/tutorial-install-ubuntu.doc +++ b/doc/tutorial-install-ubuntu.doc @@ -6,10 +6,11 @@ In this tutorial you will learn how to install ViSP from source on Linux Ubuntu. These steps have been tested for Ubuntu 13.04 (64 bit) distribution, but should work with any other distribution as well. Concerning ViSP installation, we provide also other tutorials +- \ref tutorial-install-fedora - \ref tutorial-install-win - \ref tutorial-install-iOS -ViSP can also be installed on other platforms including OSX, Fedora, CentOS, openSUZE (see <a href="http://www.irisa.fr/lagadic/visp/install.html">Install from source page</a>). +ViSP can also be installed on other platforms including OSX, CentOS, openSUZE (see <a href="http://www.irisa.fr/lagadic/visp/install.html">Install from source page</a>). \section install_ubuntu_required Required packages @@ -32,16 +33,16 @@ There are different ways to get ViSP source code: - You can download the <a href="http://www.irisa.fr/lagadic/visp/download.html#latest">latest stable release</a> as a zip or a tarball. Once downloaded, uncompress the file using either \code -tar xvzf ViSP-2.7.0.tar.gz +tar xvzf ViSP-2.9.0.tar.gz \endcode or \code -unzip ViSP-2.7.0.zip +unzip ViSP-2.9.0.zip \endcode - You can also download a more <a href="http://www.irisa.fr/lagadic/visp/download.html#snapshot">recent snapshot</a>. Once downloaded, uncompress the file using \code -unzip ViSP-2.7.1-snapshot-2013.05.02.zip +unzip ViSP-2.y.z-snapshot-2014.mm.dd.zip \endcode - Or you get the cutting-edge ViSP from Subversion repository. To this end you have first to install subversion \code @@ -52,7 +53,7 @@ and then use the following command svn checkout svn://scm.gforge.inria.fr/svn/visp/trunk/ViSP ViSP-trunk \endcode -We suppose now that ViSP source is in a directory denoted \<source_dir\>, for example \c $HOME/ViSP-2.7.0 +We suppose now that ViSP source is in a directory denoted \<source_dir\>, for example \c $HOME/ViSP-2.9.0 \section install_ubuntu_config Configuring ViSP from source @@ -64,20 +65,20 @@ cd $HOME; mkdir ViSP-build-release - Enter the \<binary_dir\> and to configure the build type: \code cmake [<optional parameters>] <source_dir> -For example: \endcode +For example: \code cd $HOME/ViSP-build-release -cmake -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_SHARED_LIBS=ON ../ViSP-2.7.0 +cmake -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_SHARED_LIBS=ON ../ViSP-2.9.0 \endcode A more versatile way to configure the build is to use \c ccmake, the CMake GUI: \code -ccmake ../ViSP-2.7.0 +ccmake ../ViSP-2.9.0 \endcode The following image shows that this command allows to configure (just by pressing [c] key) the build in a more advanced way where some options could be easily turned On/Off. It allows also to see which are the 3rd party that will be used. -\image html img-ccmake-ubuntu.png Snapshot of the ccmake \c ../ViSP-2.7.0 command used to configure ViSP. +\image html img-ccmake-ubuntu.png Snapshot of the ccmake \c ../ViSP-2.9.0 command used to configure ViSP. -- There is an other way to see which are the 3rd party that are found during the configuration stage and that will be used by ViSP during the build. To this end you can have a look to the text file named ViSP-third-party.txt and located in \<binary_dir\>. We provide hereafter the content of this file: +- There is an other way to see which are the 3rd party that are found during the configuration stage and that will be used by ViSP during the build. To this end you can have a look to the text file named ViSP-third-party.txt and located in \<binary_dir\>. We provide hereafter an example of a possible content of this file: \code ViSP third-party libraries @@ -153,9 +154,9 @@ sudo apt-get install libopencv-dev \code sudo apt-get install libx11-dev \endcode -- liblapack to benefit from optimized mathematical capabilities +- lapack and GSL to benefit from optimized mathematical capabilities \code -sudo apt-get install liblapack-dev +sudo apt-get install liblapack-dev libgsl0-dev \endcode - libdc1394 to grab images from firewire cameras \code @@ -189,10 +190,10 @@ sudo apt-get install libogre-dev libois-dev Once installed, if you want that ViSP exploit the new 3rd party, you have to configure ViSP again. \code -ccmake ../ViSP-2.7.0 +ccmake ../ViSP-2.9.0 \endcode The following image shows now that all the previous optional 3rd party are detected. -\image html img-ccmake-ubuntu-all.png Snapshot of the ccmake \c ../ViSP-2.7.0 command used to configure ViSP after installation of optional 3rd party libraries. +\image html img-ccmake-ubuntu-all.png Snapshot of the ccmake \c ../ViSP-2.9.0 command used to configure ViSP after installation of optional 3rd party libraries. \subsection install_ubuntu_generate Generating Makefiles diff --git a/doc/tutorial-install-win.doc b/doc/tutorial-install-win.doc index 95e81bf98bf38bcc0b56367ff3e487c701b5fad2..7b7ee169efb2d1da29f2ac57e610b0e32c676238 100644 --- a/doc/tutorial-install-win.doc +++ b/doc/tutorial-install-win.doc @@ -7,9 +7,10 @@ In this tutorial you will learn how to install ViSP from source on Windows. Thes Concerning ViSP installation, we provide also other tutorials - \ref tutorial-install-ubuntu +- \ref tutorial-install-fedora - \ref tutorial-install-iOS -ViSP can also be installed on other platforms OSX, Fedora, CentOS, openSUZE (see <a href="http://www.irisa.fr/lagadic/visp/install.html">Install from source page</a>). +ViSP can also be installed on other platforms OSX, CentOS, openSUZE (see <a href="http://www.irisa.fr/lagadic/visp/install.html">Install from source page</a>). \section install_win_required Required packages @@ -26,11 +27,11 @@ There are different ways to get ViSP source code: - You can also download a more <a href="http://www.irisa.fr/lagadic/visp/download.html#snapshot">recent snapshot</a>. - Or you can get the cutting-edge ViSP from Subversion repository svn://scm.gforge.inria.fr/svn/visp/trunk/ViSP. -We suppose now that ViSP source is in a directory denoted \<source_dir\>, for example \c C:\\ViSP\\ViSP-2.7.1 +We suppose now that ViSP source is in a directory denoted \<source_dir\>, for example \c C:\\ViSP\\ViSP-2.9.0 \section install_win_config Configuring ViSP from source -The goal of the configuration step is now to use CMake to produce a Visual Studio C++ solution that will be located in \<binary_dir\>, for example \c C:\\ViSP\\ViSP-2.7.1-build. +The goal of the configuration step is now to use CMake to produce a Visual Studio C++ solution that will be located in \<binary_dir\>, for example \c C:\\ViSP\\ViSP-2.9.0-build. - Launch CMake (cmake-gui) and complete the \<source_dir\> and \<binary_dir\> locations as in the next image. @@ -40,7 +41,7 @@ The goal of the configuration step is now to use CMake to produce a Visual Studi \image html img-cmake-win-2.jpg -- Click on "Yes" to create the \c C:\\ViSP\\ViSP-2.7.1-build folder. +- Click on "Yes" to create the \c C:\\ViSP\\ViSP-2.9.0-build folder. - Select then your compiler, for example here Visual Studio 11 Win64, and click on "Finish" button. \image html img-cmake-win-msvc-version.jpg @@ -117,13 +118,13 @@ setx OPENCV_DIR C:\OpenCV\opencv\build \image html img-cmake-win-generate.jpg -- Once the generation is done, in \c C:/ViSP/ViSP-2.7.1-build folder you have the Visual Studio \c VISP.sln generated solution file. +- Once the generation is done, in \c C:/ViSP/ViSP-2.9.0-build folder you have the Visual Studio \c VISP.sln generated solution file. \image html img-cmake-win-solution.jpg \section install_win_build Building ViSP from source -- To build ViSP just double click on \c C:/ViSP/ViSP-2.7.1-build/VISP.sln solution file. This action will open ViSP project in Visual Studio C++. As shown in the next image, by default, Visual Studio position the solution configuration to \c Debug. +- To build ViSP just double click on \c C:/ViSP/ViSP-2.9.0-build/VISP.sln solution file. This action will open ViSP project in Visual Studio C++. As shown in the next image, by default, Visual Studio position the solution configuration to \c Debug. \image html img-msvc-1.jpg @@ -170,7 +171,7 @@ C:\ViSP\ViSP-install\bin; C:\OpenCV\opencv\build\x64\vc11\bin Some ViSP examples and tests require data set (images, models). These data set is provided as a compressed zip files. -- Download ViSP-images-2.7.0.zip from http://www.irisa.fr/lagadic/visp/download.html#dataDownloadForExample and uncompress it for example in \c C:/ViSP. +- Download ViSP-images-2.9.0.zip from http://www.irisa.fr/lagadic/visp/download.html#dataDownloadForExample and uncompress it for example in \c C:/ViSP. \image html img-ViSP-images.jpg diff --git a/doc/tutorial-matching.doc b/doc/tutorial-matching.doc new file mode 100644 index 0000000000000000000000000000000000000000..5becda59422d2636f84bc00ee5392d53c499c37e --- /dev/null +++ b/doc/tutorial-matching.doc @@ -0,0 +1,94 @@ +/** + +\page tutorial-matching Tutorial: Keypoint matching +\tableofcontents + +\section intro Introduction + +This tutorial focuses on SURF key points manipulation. You will learn how to detect SURF key points on a reference image considered here as the first image of an mpeg video. Then in the next images of the video, key points that match those detected in the reference image using SURF descriptor are displayed. + +\note We assume that you are familiar with video framegrabbing described in \ref tutorial-grabber and with the way to display an image in a window described in \ref tutorial-getting-started. + +\section surf SURF key points detection and matching + +Let us consider the following source code also available in tutorial-matching-surf.cpp. + +\include tutorial-matching-surf.cpp + +Here after is the resulting video. The left image represents the reference image. The right images correspond to the successive images of the input video. All the green lines extremities represent the points that are matched. + +\htmlonly +<iframe width="560" height="315" src="http://www.youtube.com/embed/sMbed_oYJgQ" frameborder="0" allowfullscreen></iframe> +\endhtmlonly + +Now, let us explain the lines dedicated to the SURF keypoint usage. + +First we have to include the header of the vpKeyPointSurf class that is a wrapper over OpenCV classes. +\code +#include <visp/vpKeyPointSurf.h> +\endcode + +Note that this class is only available if ViSP was build with OpenCV non free module. This is ensured by the check of VISP_HAVE_OPENCV_NONFREE macro. To grab the images from the mpeg video stream we need also that ViSP was build with ffmpeg 3rd party. That's why we check VISP_HAVE_FFMPEG macro definition: +\code +#if defined(VISP_HAVE_OPENCV_NONFREE) && defined(VISP_HAVE_FFMPEG) +\endcode + +Then we open the mpeg video stream and grab the first image of the video that is stored in \c I container. A Surf keypoint class is instantiated and keypoints are detected on the first image which is considered as the reference image: +\code + vpKeyPointSurf surf; + surf.buildReference(I); +\endcode + +The next lines are used to create image \c Idisp to render the matching results; left image for the reference image, right image for the current image that is processed: +\code + vpImage<unsigned char> Idisp; + Idisp.resize(I.getHeight(), 2*I.getWidth()); + Idisp.insert(I, vpImagePoint(0, 0)); + Idisp.insert(I, vpImagePoint(0, I.getWidth())); +\endcode + +Then a display using OpenCV is created and image \c Idisp is rendered: +\code + vpDisplayOpenCV d(Idisp, 0, 0, "Matching surf keypoints") ; + vpDisplay::display(Idisp); + vpDisplay::flush(Idisp); +\endcode + +We enter then in the \c while() loop where a new image is acquired from the video stream and inserted in the right part of image \c Idisp dedicated to rendering of the matching results. +\code + reader.acquire(I); + Idisp.insert(I, vpImagePoint(0, I.getWidth())); +\endcode + +We start the rendering by displaying the rendered image and by drawing a white vertical line to separate the reference image from the current one: +\code + vpDisplay::display(Idisp); + vpDisplay::displayLine(Idisp, vpImagePoint(0, I.getWidth()), vpImagePoint(I.getHeight(), I.getWidth()), vpColor::white, 2); +\endcode + +Keypoint matches between the reference image and the current image \c I are detected using: +\code + int nbMatch = surf.matchPoint(I); +\endcode + +Then we parse all the matches to retrieve the coordinates of the points in the reference image (in \c iPref variable) and in the current image (in \c iPcur variable): +\code + vpImagePoint iPref, iPcur; + for (int i = 0; i < nbMatch; i++) + { + surf.getMatchedPoints(i, iPref, iPcur); +\endcode + +Next we draw green lines between the matched points: +\code + vpDisplay::displayLine(Idisp, iPref, iPcur + vpImagePoint(0, I.getWidth()), vpColor::green); +\endcode + +At the end of the iteration, we flush all the previous display to the render window: +\code + vpDisplay::flush(Idisp); +\endcode + +You can now follow \ref tutorial-homography to see how to exploit couple of matched points in order to estimate an homography that allows to track the position of an object. + +*/ diff --git a/doc/tutorial-simu-robot-pioneer.doc b/doc/tutorial-simu-robot-pioneer.doc index 2d08a051a11407ca47ead1dc15e51e920a42f615..2ffcdec814305ee5a2c8387c19f898ecd4824aa7 100644 --- a/doc/tutorial-simu-robot-pioneer.doc +++ b/doc/tutorial-simu-robot-pioneer.doc @@ -233,4 +233,5 @@ The following control law is used: \end{array}\right] = -0.2 \left( {\bf L_{s} {^c}V_e {^e}J_e}\right)^{+} ({\bf s} - {\bf s}^*) \f] +You are now ready to see the next \ref tutorial-boost-vs. */ diff --git a/doc/tutorial-trace.doc b/doc/tutorial-trace.doc new file mode 100644 index 0000000000000000000000000000000000000000..0717f7fcc5b5cf0462c5c8c748455cfa6ce07d8d --- /dev/null +++ b/doc/tutorial-trace.doc @@ -0,0 +1,116 @@ +/** + +\page tutorial-trace Tutorial: Debug and trace printings +\tableofcontents + + +\section intro Introduction + +ViSP allows to introduce trace and debug printings that may help debugging. To this end ViSP provides C or C++ macros that allows to print messages to the standard output std::cout or to std::cerr. + +~~~ +|----------|-------|-------------------------------------|---------------------------------------| +| output | type | std::cout | std::cerr | +|----------|-------|-------------------------------------|---------------------------------------| +| C-like | trace | vpTRACE, vpTRACE(level) | vpERROR_TRACE, vpERROR_TRACE(level) | +| | trace | vpIN_FCT, vpOUT_FCT | | +| | debug | vpDEBUG_TRACE, vpDEBUG_TRACE(level) | vpDERROR_TRACE, vpDERROR_TRACE(level) | +|----------|-------|-------------------------------------|---------------------------------------| +| C++-like | trace | vpCTRACE | vpCERROR | +| | debug | vpCDEBUG(level) | | +|----------|-------|-------------------------------------|---------------------------------------| +~~~ + +\subsection trace Macros for trace + +Macro for tracing vpTRACE(), vpTRACE(level), vpERROR_TRACE(), vpERROR_TRACE(level), +vpIN_FCT() and vpOUT_FCT() +work like printf with carrier return at the end of the string, while +vpCTRACE() and vpCERROR() work like the C++ output streams std::cout +and std::cerr. All these macro print messages only if VP_TRACE macro is defined. + +\subsection debug Macros for debug + +Macros for debug vpDEBUG_TRACE(level) and vpDERROR_TRACE(level) +work like printf while vpCDEBUG(level) works like the C++ output stream std::cout. +These macro print messages only if VP_DEBUG macro is defined and +if the debug \e level is greater than the one defined in VP_DEBUG_MODE +macro. Moreover vpDEBUG_ENABLE(level) can be used to check if a given debug level is active; vpDEBUG_ENABLE(level) is +equal to 1 if the debug \e level is greater than the debug mode +VP_DEBUG_MODE, 0 else. + +\section visp Debug and trace usage in ViSP library + +In ViSP, before an exception is thrown, trace macro are widely used to inform the user that an error occur. This is redundant, since the same trace message in generally associated to the exception that is thrown. Since ViSP 2.9.0, during CMake configuration it is possible to disable debug and trace printings by turning \c ACTIVATE_DEBUG_TRACE cmake variable to \c OFF. + +- Using cmake command just run: +\code +%cmake -DACTIVATE_DEBUG_TRACE=OFF <path to ViSP source code> +\endcode + +- or using ccmake GUI as shown in the next snapshot: + +\image html img-cmake-debug-trace.jpg + +\note When \c ACTIVATE_DEBUG_TRACE is turned to \c ON (this is the default behavior in ViSP), we simply define VP_TRACE and VP_DEBUG macro using the compiler -D option. + +\section example Debug and trace usage in your own project + +If you develop a project that uses ViSP library as a 3rd party, there are different ways to benefit from debug and trace macro described previously. + +- If ViSP was build with debug and trace enabled using \c cmake \c ACTIVATE_DEBUG_TRACE=ON, debug and trace are also enabled in your development. +- If debug and trace were disabled in ViSP (\c ACTIVATE_DEBUG_TRACE=OFF), you can enable debug and trace in your own development either by defining \c VP_DEBUG and/or \c VP_TRACE macro in your code using +\code +#define VP_TRACE +#define VP_DEBUG + +#include <visp/vpDebug.h> +\endcode +either by modifying your \c CMakeLists.txt file by adding an option as in ViSP: +\code +option(ACTIVATE_DEBUG_TRACE "Enable debug and trace printings" ON) + +if(ACTIVATE_DEBUG_TRACE) + add_definitions("-DVP_DEBUG -DVP_TRACE") +endif() +\endcode + + +The following example also available in tutorial-trace.cpp shows how to use the previous macro. + +\includelineno tutorial-trace.cpp + +When ViSP library was built without debug and trace the previous example produces the output: +\code +%./tutorial-trace +Debug level 1 active: 0 +Debug level 2 active: 0 +Debug level 3 active: 0 +\endcode + +When ViSP is rather build with debug and trace the previous example produces the output: +\code +%./tutorial-trace +(L0) begin /tmp/tutorial-trace.cpp: main(#9) : main() +Debug level 1 active: 1 +Debug level 2 active: 1 +Debug level 3 active: 0 +(L0) /tmp/tutorial-trace.cpp: main(#17) : C-like trace +(L1) /tmp/tutorial-trace.cpp: main(#18) : C-like trace level 1 +(L0) !! /tmp/tutorial-trace.cpp: main(#20) : C-like error trace +(L1) !! /tmp/tutorial-trace.cpp: main(#21) : C-like error trace level 1 +(L0) /tmp/tutorial-trace.cpp: main(#24) : C-like debug trace +(L0) !! /tmp/tutorial-trace.cpp: main(#25) : C-like error trace +(L2) /tmp/tutorial-trace.cpp: main(#27) : C-like debug trace level 2 +(L2) !! /tmp/tutorial-trace.cpp: main(#28) : C-like error trace level 2 +(L0) /tmp/tutorial-trace.cpp: main(#31) : C++-like trace +(L0) !! /tmp/tutorial-trace.cpp: main(#32) : C++-like error trace +(L2) /tmp/tutorial-trace.cpp: main(#35) : C++-like debug trace level 2 +(L0) end /tmp/tutorial-trace.cpp: main(#37) : main() +\endcode + +In the previous printings: +- the number after "L" indicates the debug or trace level; example (L2) is for level 2. +- the number after "#" indicates the line of the code that produce the printing; example main(#37) means in function main() at line 37. +- the "!!" indicate that the printing is on std::cerr. Others are on std::cout. +*/ diff --git a/doc/tutorial-tracking-mb.doc b/doc/tutorial-tracking-mb.doc index 351cda1646b58b4eb307fc5d0c8750b6bc98f773..974a6c8602c188957b455b516f191989f3e2ca55 100644 --- a/doc/tutorial-tracking-mb.doc +++ b/doc/tutorial-tracking-mb.doc @@ -82,6 +82,13 @@ The content of the xml file is the following: <px>839.21470</px> <py>839.44555</py> </camera> + <face> + <angle_appear>70</angle_appear> + <angle_disappear>80</angle_disappear> + <near_clipping>0.1</near_clipping> + <far_clipping>100</far_clipping> + <fov_clipping>1</fov_clipping> + </face> </conf> \endcode @@ -99,40 +106,44 @@ The content of the xml file is the following: tracker.setMovingEdge(me); cam.initPersProjWithoutDistortion(839, 839, 325, 243); tracker.setCameraParameters(cam); + tracker.setAngleAppear( vpMath::rad(70) ); + tracker.setAngleDisappear( vpMath::rad(80) ); + tracker.setNearClippingDistance(0.1); + tracker.setFarClippingDistance(100.0); + tracker.setClipping(tracker.getClipping() | vpMbtPolygon::FOV_CLIPPING); \endcode -The display in the image window of additional drawings in overlay such as the moving edges positions, is then enabled by: +An important setting concerns the visibility test that is used to determine if a face is visible. Note that moving-edges are tracked only on visible faces. Two different visibility tests are implemented; with or without Ogre ray tracing. The default test is the one without Ogre. The function vpMbEdgeTracker::setOgreVisibilityTest() allow to select which test is to use. + +Let us now highlight how the visibility test works. As illustrated in the following figure, the angle \f$ \alpha \f$ between the normal of the face and the line going from the camera to the center of gravity of the face is used to determine if the face is visible. If we consider two parameters; the angle to determine if a face is appearing \f$ \alpha_{appear} \f$, and the angle to determine if the face is disappearing \f$ \alpha_{disappear} \f$, a face will be considered as visible if \f$ \alpha \leq \alpha_{disappear} \f$. We consider also that a new face is appearing if \f$ \alpha \geq \alpha_{appear} \f$. These two parameters can be set either in the xml file: \code - tracker.setDisplayFeatures(true); +<conf> + ... + <face> + <angle_appear>70</angle_appear> + <angle_disappear>80</angle_disappear> + </face> \endcode - -An important setting concerns the visibility test that is used to determine if a face is visible. Note that moving-edges are tracked only on visible faces. Two different visibility tests are implemented; with or without Ogre ray tracing. With the next line, we disable Ogre visibility test. - +or in the code: \code - tracker.setOgreVisibilityTest(false); + tracker.setAngleAppear( vpMath::rad(70) ); + tracker.setAngleDisappear( vpMath::rad(80) ); \endcode -As illustrated in the following figure, the angle \f$ \alpha \f$ between the normal of the face and the line going from the camera to the center of gravity of the face is then used to determine if the face is visible. +\note When these two angle parameters are not set, their default values set to 89 degrees are used. \image html img-tracker-mb-visibility.jpg Principle of the visibility test used to determine if a face is visible. -- When Ogre visibility test is disabled, the algorithm that computes the normal of the face is very simple. It makes the assumption that faces are convex and oriented counter clockwise. Faces are considered as visible if \f$ \alpha < 90\f$ degrees. When only moving-edges are used (nor keypoints) and when the object to track is simple like a single box, we suggest as here to disable Ogre visibility test. It will help the tracker to detect as soon as possible new faces when only one face is currently tracked. -- When Ogre visibility test is enabled, the algorithm used to determine the visibility of a face is the same than previously except that once visible faces are detected thanks to their normal, we add an other test to reject faces that are partially occluded by an other one. This additional test is performed using Ogre ray-tracing capability. Note also that two additional parameters need to be introduced; the angle to determine if a face is appearing, and the angle to determine if the face is disappearing. +- When Ogre visibility test is disabled (we recall that this is the default behavior), the algorithm that computes the normal of the face is very simple. It makes the assumption that faces are convex and oriented counter clockwise. Here the face is considered as appearing if \f$ \alpha < 70\f$ degrees, and disappearing if \f$ \alpha > 80\f$ degrees. When only moving-edges are used (nor keypoints) and when the object to track is simple like a single box, we suggest as here to disable Ogre visibility test. \code - tracker.setOgreVisibilityTest(true); - tracker.setAngleAppear(70); - tracker.setAngleDisappear(80); + tracker.setOgreVisibilityTest(false); // Default behavior \endcode -It is also possible to introduce these two parameters in the xml file. It should be modified by adding the following lines: + +- When Ogre visibility test is enabled, the algorithm used to determine the visibility of a face is the same than previously except that once visible faces are detected thanks to their normal, we add an other test to reject faces that are partially occluded by an other one. This additional test is performed using Ogre ray-tracing capability. \code -<conf> - ... - <face> - <angle_appear>70</angle_appear> - <angle_disappear>80</angle_disappear> - </face> + tracker.setOgreVisibilityTest(true); \endcode -Here the face is considered as appearing if \f$ \alpha < 70\f$ degrees, and disappearing if \f$ \alpha > 80\f$ degrees. + Additionally to the visibility test described above, it is also possible to use clipping. Firstly, the algorithm removes the faces that are not visibles, according to the visibility test used, then it will also remove the faces or parts of the faces that are out of the clipping planes. As illustrated in the following figure, different clipping planes can be enabled. @@ -165,14 +176,14 @@ For the Near and Far clipping it is quite different. Indeed, thoses planes requi tracker.setClipping(vpMbtPolygon::NEAR_CLIPPING | vpMbtPolygon::FAR_CLIPPING); \endcode -Or specify the distances in meters, which will automatically activate the clipping for thoses planes: +or the user can specify the distances in meters, which will automatically activate the clipping for thoses planes: \code tracker.setNearClippingDistance(0.1); tracker.setFarClippingDistance(100.0); \endcode -It is also possible to enable them in the xml file. It should be modified by adding the following lines: +It is also possible to enable them in the xml file. This is done with the following lines: \code <conf> @@ -187,19 +198,32 @@ It is also possible to enable them in the xml file. It should be modified by add Here for simplicity, the user just has the possibility to either activate all the FOV clipping planes or none of them (fov_clipping requires a boolean). -Now we are ready to load the cad model of the object in cao format with: +\note When clipping parameters are not set in the xml file, nor in the code, clipping is not used. Usually clipping is not helpfull when the oject to track is simple. + +Now we are ready to load the cad model of the object. ViSP supports cad model in cao format or in vrml format. The cao format is a particular format only supported by ViSP. It doesn't require an additional 3rd party rather then vrml format that require Coin 3rd party. We load the cad model in cao format with: \code tracker.loadModel("teabox.cao"); \endcode -The file \c teabox.cao describes first the vertexes of the box, then the edges that corresponds to the faces. A more complete description of this file is provided in \ref tracking_mb_cao (\ref tracking_mb_cao_face). The next figure gives the index of the vertices that are defined in \c teabox.cao. +The file \c teabox.cao describes first the vertices of the box, then the edges that corresponds to the faces. A more complete description of this file is provided in \ref tracking_mb_cao (\ref tracking_mb_cao_face). The next figure gives the index of the vertices that are defined in \c teabox.cao. + +To load the cad model in vrml the user has to replace the previous line by the following: +\code + tracker.loadModel("teabox.wrl"); +\endcode +As for the cao format, \c teabox.wrl describes first the vertices of the box, then the edges that corresponds to the faces. A more complete description of this file is provided in \ref tracking_mb_wrl. \image html img-teabox-cao.jpg Index of the vertices used to model the tea box in cao format. -Four vertices with their 3D coordinates are then used to initialize the tracker: +Once the model of the object to track is loaded, with the next line the display in the image window of additional drawings in overlay such as the moving edges positions, is then enabled by: +\code + tracker.setDisplayFeatures(true); +\endcode + +Now we have to initialize the tracker. With the next line we choose to use a user interaction. As explained later, the user has to match in the image four vertices with their 3D coordinates. Matched 2D and 3D coordinates are then used to compute an initial pose used to initialize the tracker: \code tracker.initClick(I, "teabox.init"); \endcode -The content of \c teabox.init file is provided hereafter: +The content of \c teabox.init file that defines 3D coordinates of some points of the model used during user intialization is provided hereafter: \includelineno teabox.init @@ -267,10 +291,6 @@ The \c teabox.xml file used here contains the following: \code <?xml version="1.0"?> <conf> - <face> - <angle_appear>70</angle_appear> - <angle_disappear>80</angle_disappear> - </face> <klt> <mask_border>5</mask_border> <max_features>300</max_features> @@ -287,6 +307,13 @@ The \c teabox.xml file used here contains the following: <px>839.21470</px> <py>839.44555</py> </camera> + <face> + <angle_appear>70</angle_appear> + <angle_disappear>80</angle_disappear> + <near_clipping>0.1</near_clipping> + <far_clipping>100</far_clipping> + <fov_clipping>1</fov_clipping> + </face> </conf> \endcode - The second one consists in initializing the parameters directly in the source code: @@ -311,7 +338,7 @@ Note also that in this example we model the tea box with triangles: \code tracker.loadModel("teabox-triangle.cao"); \endcode -The file \c teabox-triangle.cao describes first the vertexes of the box, then the triangular faces. A more complete description of this file is provided in \ref tracking_mb_cao (\ref tracking_mb_cao_triangle). +The file \c teabox-triangle.cao describes first the vertices of the box, then the triangular faces. A more complete description of this file is provided in \ref tracking_mb_cao (\ref tracking_mb_cao_triangle). Note that this is the only tracker for which lines of the model are not necessary edges of the object. @@ -351,10 +378,6 @@ We provide just hereafter the content of the \c teabox.xml file: <step>4</step> <nb_sample>250</nb_sample> </sample> - <face> - <angle_appear>70</angle_appear> - <angle_disappear>80</angle_disappear> - </face> <klt> <mask_border>5</mask_border> <max_features>300</max_features> @@ -371,6 +394,13 @@ We provide just hereafter the content of the \c teabox.xml file: <px>839.21470</px> <py>839.44555</py> </camera> + <face> + <angle_appear>70</angle_appear> + <angle_disappear>80</angle_disappear> + <near_clipping>0.1</near_clipping> + <far_clipping>100</far_clipping> + <fov_clipping>1</fov_clipping> + </face> </conf> \endcode @@ -398,7 +428,7 @@ We make the choice to describe the faces of the box from the 3D points that corr - line 11: Number of single lines of the model. Sometimes, it could be useful to track a single line that doesn't lead to a face. - line 12: Deprecated parameter that should always be set to 0. - line 13: The number of faces defined by a set of points. Here our tea box has 6 faces. Thus, next 6 lines describe each face from the 3D points defined previously line 3 to 10. -- line 14: First face defined by 4 points, respectively vertices 0,1,2,3. The orientation of the face is counter clockwise by going from vertex 0 to vertex 1, than 2 and 3. This fixes the orientation of the normal of the face going outside the object. +- line 14: First face defined by 4 points, respectively vertices 0,1,2,3. The orientation of the face is counter clockwise by going from vertex 0 to vertex 1, then 2 and 3. This fixes the orientation of the normal of the face going outside the object. - line 15: Second face also defined by 4 points, respectively vertices 1,6,5,2 to have a counter clockwise orientation. - line 16 to 19: The four other faces of the box. - line 20: Number of cylinders describing the model. Since we model a simple box, the number of cylinders is 0. @@ -416,5 +446,26 @@ This file describes the model of the tea box corresponding to the next image: Until line 12, the content of this file is similar to the one described in \ref tracking_mb_cao_face. Line 13 we specify that the model contains 12 faces. Each face is then described as a triangle. +\section tracking_mb_wrl CAD model in vrml format + +ViSP support vrml format only if Coin 3rd party is installed. This format allows to describe the CAD model of an object using a text file with extension \c .wrl. + +\subsection tracking_mb_vrml_face teabox.wrl example + +The content of the teabox.wrl file used in the \ref tracking_mb_edges is given hereafter. This content is to make into relation with teabox.cao described in \ref tracking_mb_cao_face. + +\includelineno teabox.wrl + +This file describes the model of the tea box corresponding to the next image: + +\image html img-teabox-cao.jpg Index of the vertices used to model the tea box in vrml format. + +We provide now a line by line description of the file where the faces of the box are defined from the vertices: +- line 1 to 10: Header of the \c .wrl file. +- line 13 to 20: 3D coordinates of the 8 tea box vertices. +- line 34 to 29: Each line describe a face. In this example, a face is defined by 4 vertices. For example, the first face join vertices 0,1,2,3. The orientation of the face is counter clockwise by going from vertex 0 to vertex 1, then 2 and 3. This fixes the orientation of the normal of the face going outside the object. + +You are now ready to see the next \ref tutorial-tracking-tt. + */ diff --git a/doc/tutorial-tracking-me.doc b/doc/tutorial-tracking-me.doc index cde4ac392bed427570a7fcde758d525933a215a0..33c35d0394e262554a71db0752843cc68cbc0c68 100644 --- a/doc/tutorial-tracking-me.doc +++ b/doc/tutorial-tracking-me.doc @@ -72,7 +72,7 @@ We then open the connection with the grabber and acquire an image in \c I. To be able to display image \c I and the tracking results in overlay in a window, we create a display instance. \code -#if defined UNIX +#if defined(VISP_HAVE_X11) vpDisplayX d(I, 0, 0, "Camera view"); #else vpDisplayGDI d(I, 0, 0, "Camera view"); diff --git a/doc/tutorial-tracking-tt.doc b/doc/tutorial-tracking-tt.doc new file mode 100644 index 0000000000000000000000000000000000000000..c48d6ba5774961796ea8952f56a596c0d7b36814 --- /dev/null +++ b/doc/tutorial-tracking-tt.doc @@ -0,0 +1,223 @@ +/** + +\page tutorial-tracking-tt Tutorial: Template tracking +\tableofcontents + +With ViSP it is possible to track a template using image registration algorithms. Contrary to the common approaches based on visual features, this method allows to be much more robust to scene variations. + +In the following sections, we consider the tracking of a pattern. To simplify the source code, the tracking is performed on a single image. The extension to a sequence of images or to images acquired from a camera is easy. To this end see \ref tutorial-grabber. + +\section tracking_tt Track the painting + +The following example that comes from tutorial-template-tracker.cpp allows to track a template using vpTemplateTrackerSSDInverseCompositional class. +Let us denote that "SSDInverseCompositional" refers to the similarity function used for the image registration. In ViSP, we have implemented, for now, two different similarity functions: the "Sum of Square Differences" (vpTemplateTrackerSSD classes \cite Baker04a) and the "Zero-mean Normalized Cross Correlation" (vpTemplateTrackerZNCC classes \cite Irani98a). Both methods can be used in different ways: Inverse Compositional, Forward Compositional, Forward Additional, or ESM. + +\include tutorial-template-tracker.cpp + +The video below shows the result of the template tracking. + +\htmlonly +<iframe width="420" height="315" src="http://www.youtube.com/embed/hniUcaUSVBM" frameborder="0" allowfullscreen></iframe> +\endhtmlonly + +Hereafter is the description of the new lines introduced in this example. + +\code +#include <visp/vpTemplateTrackerSSDInverseCompositional.h> +#include <visp/vpTemplateTrackerWarpHomography.h> +\endcode + +Here we include the header of the vpTemplateTrackerSSDInverseCompositional class that allows to track the template. Actually, the tracker estimates the displacement of the template in the current image according to its initial pose. The computed displacement can be represented by multiple transformations, also called warps (vpTemplateTrackerWarp classes). In this example, we include the header vpTemplateTrackerWarpHomography class to define the possible transformation of the template as an homography. + +\code +vpTemplateTrackerWarpHomography warp; +vpTemplateTrackerSSDInverseCompositional tracker(&warp); +\endcode + +Once the tracker is created with the desired warp, parameters can be tuned to be more consistent with the expected behavior. + +\code +tracker.setSampling(2,2); // Will consider only one pixel from two along rows and columns + // to create the reference template +tracker.setLambda(0.001); // Gain used in the optimization loop +tracker.setIterationMax(200); // Maximum number of iterations for the optimization loop +tracker.setPyramidal(2, 1); // First and last level of the pyramid +\endcode + +The last step of the initialization is to select the template that will be tracked during the sequence. + +\code +tracker.initClick(I); +\endcode + +The vpTemplateTracker classes proposed in ViSP offer you the possibility to defined your template as multiple planar triangles. When calling vpTemplateTracker::initClick(I), you will have to specify the triangles that define the template. + +\image html initClickTemplateTracker.png Initialization of the template without Delaunay triangulation. + +Let us denote that those triangles don't have to be spatially tied up. However, if you want to track a simple image as in this example, you should initialize the template as on the figure above. Left clicks on zero, one and two points create the green triangle. Left clicks on three, four and right click on five point create the red triangle and ends the initialization. +If ViSP is build with OpenCV, we also provide an initialization with automatic triangulation using Delaunay. To use it, you just have to call vpTemplateTracker::initClick(I, true). Then by left clicking on zero, one, two, four and right clicking on five it initializes the tracker as on the image above. + +Next, in the infinite while loop, after displaying the next image, we track the object on a new image I. + +\code +tracker.track(I); +\endcode + +If you need to get the parameters of the current transformation of the template, it can be done by calling: + +\code +vpColVector p = tracker.getp(); +\endcode + +For further information about the warping parameters, see the following section of \ref warp_tt. Next line is used to display the template using red lines and according to the computed transformation from the last call to track. + +\code +tracker.display(I, vpColor::red); +\endcode + +\subsection warp_tt Warping classes + +In the example presented above, we focused on the vpTemplateTrackerWarpHomography warping class which is the most generic transformation available in ViSP for the template trackers. However, if you know that the template you want to track is constrained, other warps might be more suitable. + +\b vpTemplateTrackerWarpTranslation + +\f$w({\bf x},{\bf p}) = {\bf x} + {\bf t}\f$ with the following estimated parameters \f$ {\bf p} = (t_x, t_y)\f$ + +This class is the most simple transformation available for the template trackers. It only considers translation on two-axis (x-axis and y-axis). + +\b vpTemplateTrackerWarpSRT + +\f$w({\bf x},{\bf p}) = (1+s){\bf Rx} + {\bf t}\f$ with \f${\bf p} = (s, \theta, t_x, t_y)\f$ + +The SRT warp considers a scale factor, a rotation on z-axis and a 2D translation as in vpTemplateTrackerWarpTranslation. + +\b vpTemplateTrackerWarpAffine + + +\f$ w({\bf x},{\bf p}) = {\bf Ax} + {\bf t}\f$ with \f${\bf A} = \left( \begin{array}{cc} + 1+a_0 & a_2 \\ + a_1 & 1+a_3 + \end{array} \right)\f$, \f${\bf t} = \left( \begin{array}{c} + t_x \\ + t_y + \end{array} \right)\f$ and the estimated parameters \f${\bf p} = (a_0 ... a_3, t_x, t_y)\f$ + +The template transformation can also be defined as an affine transformation. This warping function preserves points, straight lines, and planes. + +\b vpTemplateTrackerWarpHomography + +\f$w({\bf x},{\bf p}) = {\bf Hx}\f$ with \f$ {\bf H}=\left( \begin{array}{ccc} + 1 + p_0 & p_3 & p_6 \\ + p_1 & 1+p_4 & p_7 \\ + p_2 & p_5 & 1.0 + \end{array} \right) \f$ and the estimated parameters \f${\bf p} = (p_0 ... p_7)\f$ + +As remind, the vpTemplateTrackerWarpHomography estimates the eight parameters of the homography matrix \f$ {\bf H}\f$. + +\b vpTemplateTrackerWarpHomographySL3 + +\f$w({\bf x},{\bf p}) = {\bf Hx}\f$ with \f${\bf p} = (p_0 ... p_7)\f$ + +The vpTemplateTrackerWarpHomographySL3 warp works exactly the same as the vpTemplateTrackerWarpHomography warp. The only difference is that here, the parameters of the homography are estimated in the SL3 reference frame. + +\subsection tune_tt How to tune the tracker + +When you want to obtain a perfect pose estimation, it is often time-consuming. However, by tuning the tracker, you can find a good compromise between speed and efficiency. Basically, what will make the difference is the size of the reference template. The more pixels it contains, the more time-consuming it will be. Fortunately, the solutions to avoid this problem are multiple. First of all lets come back on the vpTemplateTracker::setSampling() function. + +\code +tracker.setSampling(4,4); // Will consider only one pixel from four along rows and columns + // to create the reference template. +\endcode + +In the example above, we decided to consider only one pixel from 16 (4 by 4) to create the reference template. Obviously, by increasing those values it will consider much less pixels, which unfortunately decrease the efficiency, but the tracking phase will be much faster. + +The tracking phase relies on an iterative algorithm minimizing a cost function. What does it mean? It means this algorithm has, at some point, to stop! Once again, you have the possibility to reduce the number of iterations of the algorithm by taking the risk to fall in a local minimum. + +\code +tracker.setIterationMax(50); // Maximum number of iterations for the optimization loop. +\endcode + +If this is still not enough for you, let's remember that all of our trackers can be used in a pyramidal way. By reducing the number of levels considered by the algorithm, you will consider, once again, much less pixels and be faster. + +\code +tracker.setPyramidal(3, 2); // First and last level of the pyramid +\endcode +Note here that when vpTemplateTracker::setPyramidal() function is not used, the pyramidal approach to speed up the algorithm is not used. + +Let us denote that if you're using vpTemplateTrackerSSDInverseCompositional or vpTemplateTrackerZNCCInverseCompositional, you also have another interesting option to speed up your tracking phase. + +\code +tracker.setUseTemplateSelect(true); +\endcode + +This function will force the tracker to only consider, in the reference template, the pixels that have an high gradient value. This is another solution to limit the number of considered pixels. + +As well as vpTemplateTrackerSSDInverseCompositional::setUseTemplateSelect() or vpTemplateTrackerZNCCInverseCompositional::setUseTemplateSelect(), another function, only available in vpTemplateTrackerSSDInverseCompositional and vpTemplateTrackerZNCCInverseCompositional is: + +\code +tracker.setThresholdRMS(1e-6); +\endcode + +By increasing this root mean square threshold value, the algorithm will reduce its number of iterations which should also speed up the tracking phase. This function should be used wisely with the vpTemplateTracker::setIterationMax() function. + +\subsection points_tt How to get the points of the template + +The previous code provided in tutorial-template-tracker.cpp can be modified to get the coordinates of the corners of the triangles that define the zone to track. To this end, as shown in the next lines, before the while loop we first define a reference zone and the corresponding warped zone. Then in the loop, we update the warped zone using the parameters of the warping model that is estimated by the tracker. From the warped zone, we extract all the triangles, and then for each triangles, we get the corners coordinates. + +\code + // Instantiate and get the reference zone + vpTemplateTrackerZone zone_ref = tracker.getZoneRef(); + // Instantiate a warped zone + vpTemplateTrackerZone zone_warped; + + while(!g.end()){ + g.acquire(I); + vpDisplay::display(I); + tracker.track(I); + + tracker.display(I, vpColor::red); + + // Get the estimated parameters + vpColVector p = tracker.getp(); + + // Update the warped zone given the tracker estimated parameters + warp.warpZone(zone_ref, p, zone_warped); + + // Parse all the triangles that describe the zone + for (int i=0; i < zone_warped.getNbTriangle(); i++) { + vpTemplateTrackerTriangle triangle; + // Get a triangle + zone_warped.getTriangle(i, triangle); + std::vector<vpImagePoint> corners; + // Get the 3 triangle corners + triangle.getCorners( corners ); + + // From here, each corner triangle is available in + // corners[0], corners[1] and corners[2] + + // Display a green cross over each corner + for(unsigned int j=0; j<corners.size(); j++) + vpDisplay::displayCross(I, corners[j], 15, vpColor::green, 2); + } + vpDisplay::displayRectangle(I, zone_warped.getBoundingBox(), vpColor::orange); +\endcode + +With the last line, we also sho how to get and display an orange rectangle that corresponds to the bounding box of all the triangles that define the zone. + +The resulting drawings introduced previously are shown in the next image. Here we initialize the tracker with 2 triangles that are not connex. + +\image html img-template-tracker.jpg + + +\section tracking_tt_example More examples + +The templateTracker.cpp source code provided in the example/tracking folder allows to test all the template tracker classes that derive from vpTemplateTracker as well as all the warping classes that derive from vpTemplateTrackerWarp. + +Once build, in a terminal just run: + +\code +./templateTracker -h +\endcode + +to see which are the command lines options. +*/ diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index e75ea1a18d46361baa9ab8588c6db589b08271f5..f8bda5945b7521c2e7ba85d90032a57437fb1f04 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 @@ -64,7 +64,6 @@ SET (SRC_SUBDIRS servo-afma4 servo-afma6 servo-biclops - servo-cycab servo-pioneer servo-ptu46 servo-viper650 @@ -72,7 +71,7 @@ SET (SRC_SUBDIRS tools tracking video - wireframe-simulator + wireframe-simulator ) # Build process propagation in the sub directories diff --git a/example/calibration/CMakeLists.txt b/example/calibration/CMakeLists.txt index b634146a7b0ac195d9636c4b03ff2698682c959d..95ba217dda9dff89e1f3a305c963b6de2516c6e7 100644 --- a/example/calibration/CMakeLists.txt +++ b/example/calibration/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4277 2013-06-25 13:09:01Z fspindle $ +# $Id: CMakeLists.txt 4598 2014-01-20 17:07:30Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 @@ -65,3 +65,25 @@ ENDFOREACH(source) # of acquired images ADD_TEST(calibrateTsai calibrateTsai) +# copy the data +get_target_property(target_location camera_calibration LOCATION) +get_filename_component(target_location "${target_location}" PATH) +list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/default-chessboard.cfg" ) +list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/default-circles.cfg" ) +list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/chessboard-01.png" ) +list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/chessboard-02.png" ) +list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/chessboard-03.png" ) +list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/chessboard-04.png" ) +list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/chessboard-05.png" ) +list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/circles-01.png" ) +list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/circles-02.png" ) +list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/circles-03.png" ) +list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/circles-04.png" ) +list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/circles-05.png" ) +foreach(data ${data2copy}) + add_custom_command( + TARGET camera_calibration + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy "${data}" "${target_location}" + ) +endforeach() diff --git a/example/calibration/calibrateTsai.cpp b/example/calibration/calibrateTsai.cpp index 9d053053dd61914221b47279185f4adae46b23e0..77b299d2bbc49fec65095099bdd4b24c87d71bf4 100644 --- a/example/calibration/calibrateTsai.cpp +++ b/example/calibration/calibrateTsai.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: calibrateTsai.cpp 4273 2013-06-25 12:33:27Z fspindle $ + * $Id: calibrateTsai.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -58,85 +58,86 @@ int main() { - // We want to calibrate the hand to eye extrinsic camera parameters from 6 couple of poses: cMo and wMe - const int N = 6; - // Input: six couple of poses used as input in the calibration proces - std::vector<vpHomogeneousMatrix> cMo(N) ; // eye (camera) to object transformation. The object frame is attached to the calibrartion grid - std::vector<vpHomogeneousMatrix> wMe(N) ; // world to hand (end-effector) transformation - // Output: Result of the calibration - vpHomogeneousMatrix eMc; // hand (end-effector) to eye (camera) transformation + try { + // We want to calibrate the hand to eye extrinsic camera parameters from 6 couple of poses: cMo and wMe + const unsigned int N = 6; + // Input: six couple of poses used as input in the calibration proces + std::vector<vpHomogeneousMatrix> cMo(N) ; // eye (camera) to object transformation. The object frame is attached to the calibrartion grid + std::vector<vpHomogeneousMatrix> wMe(N) ; // world to hand (end-effector) transformation + // Output: Result of the calibration + vpHomogeneousMatrix eMc; // hand (end-effector) to eye (camera) transformation - // Initialize an eMc transformation used to produce the simulated input transformations cMo and wMe - vpTranslationVector etc(0.1, 0.2, 0.3); - vpThetaUVector erc; - erc[0] = vpMath::rad(10); // 10 deg - erc[1] = vpMath::rad(-10); // -10 deg - erc[2] = vpMath::rad(25); // 25 deg + // Initialize an eMc transformation used to produce the simulated input transformations cMo and wMe + vpTranslationVector etc(0.1, 0.2, 0.3); + vpThetaUVector erc; + erc[0] = vpMath::rad(10); // 10 deg + erc[1] = vpMath::rad(-10); // -10 deg + erc[2] = vpMath::rad(25); // 25 deg - eMc.buildFrom(etc, erc); - std::cout << "Simulated hand to eye transformation: eMc " << std::endl ; - std::cout << eMc << std::endl ; - std::cout << "Theta U rotation: " << vpMath::deg(erc[0]) << " " << vpMath::deg(erc[1]) << " " << vpMath::deg(erc[2]) << std::endl; + eMc.buildFrom(etc, erc); + std::cout << "Simulated hand to eye transformation: eMc " << std::endl ; + std::cout << eMc << std::endl ; + std::cout << "Theta U rotation: " << vpMath::deg(erc[0]) << " " << vpMath::deg(erc[1]) << " " << vpMath::deg(erc[2]) << std::endl; - vpColVector v_c(6) ; // camera velocity used to produce 6 simulated poses - for (int i=0 ; i < N ; i++) - { - v_c = 0 ; - if (i==0) { - // Initialize first poses - cMo[0].buildFrom(0, 0, 0.5, 0, 0, 0); // z=0.5 m - wMe[0].buildFrom(0, 0, 0, 0, 0, 0); // Id - } - else if (i==1) - v_c[3] = M_PI/8 ; - else if (i==2) - v_c[4] = M_PI/8 ; - else if (i==3) - v_c[5] = M_PI/10 ; - else if (i==4) - v_c[0] = 0.5 ; - else if (i==5) - v_c[1] = 0.8 ; + vpColVector v_c(6) ; // camera velocity used to produce 6 simulated poses + for (unsigned int i=0 ; i < N ; i++) + { + v_c = 0 ; + if (i==0) { + // Initialize first poses + cMo[0].buildFrom(0, 0, 0.5, 0, 0, 0); // z=0.5 m + wMe[0].buildFrom(0, 0, 0, 0, 0, 0); // Id + } + else if (i==1) + v_c[3] = M_PI/8 ; + else if (i==2) + v_c[4] = M_PI/8 ; + else if (i==3) + v_c[5] = M_PI/10 ; + else if (i==4) + v_c[0] = 0.5 ; + else if (i==5) + v_c[1] = 0.8 ; - vpHomogeneousMatrix cMc; // camera displacement - cMc = vpExponentialMap::direct(v_c) ; // Compute the camera displacement due to the velocity applied to the camera - if (i > 0) { - // From the camera displacement cMc, compute the wMe and cMo matrices - cMo[i] = cMc.inverse() * cMo[i-1]; - wMe[i] = wMe[i-1] * eMc * cMc * eMc.inverse(); + vpHomogeneousMatrix cMc; // camera displacement + cMc = vpExponentialMap::direct(v_c) ; // Compute the camera displacement due to the velocity applied to the camera + if (i > 0) { + // From the camera displacement cMc, compute the wMe and cMo matrices + cMo[i] = cMc.inverse() * cMo[i-1]; + wMe[i] = wMe[i-1] * eMc * cMc * eMc.inverse(); + } } - } - if (0) { - for (int i=0 ; i < N ; i++) { - vpHomogeneousMatrix wMo; - wMo = wMe[i] * eMc * cMo[i]; - std::cout << std::endl << "wMo[" << i << "] " << std::endl ; - std::cout << wMo << std::endl ; - std::cout << "cMo[" << i << "] " << std::endl ; - std::cout << cMo[i] << std::endl ; - std::cout << "wMe[" << i << "] " << std::endl ; - std::cout << wMe[i] << std::endl ; + if (0) { + for (unsigned int i=0 ; i < N ; i++) { + vpHomogeneousMatrix wMo; + wMo = wMe[i] * eMc * cMo[i]; + std::cout << std::endl << "wMo[" << i << "] " << std::endl ; + std::cout << wMo << std::endl ; + std::cout << "cMo[" << i << "] " << std::endl ; + std::cout << cMo[i] << std::endl ; + std::cout << "wMe[" << i << "] " << std::endl ; + std::cout << wMe[i] << std::endl ; + } } - } - // Reset the eMc matrix to eye - eMc.eye(); + // Reset the eMc matrix to eye + eMc.eye(); - // Compute the eMc hand to eye transformation from six poses - // - cMo[6]: camera to object poses as six homogeneous transformations - // - wMe[6]: world to hand (end-effector) poses as six homogeneous transformations - vpCalibration::calibrationTsai(cMo, wMe, eMc) ; + // Compute the eMc hand to eye transformation from six poses + // - cMo[6]: camera to object poses as six homogeneous transformations + // - wMe[6]: world to hand (end-effector) poses as six homogeneous transformations + vpCalibration::calibrationTsai(cMo, wMe, eMc) ; - std::cout << std::endl << "Output: hand to eye calibration result: eMc estimated " << std::endl ; - std::cout << eMc << std::endl ; - eMc.extract(erc); - std::cout << "Theta U rotation: " << vpMath::deg(erc[0]) << " " << vpMath::deg(erc[1]) << " " << vpMath::deg(erc[2]) << std::endl; - return 0 ; + std::cout << std::endl << "Output: hand to eye calibration result: eMc estimated " << std::endl ; + std::cout << eMc << std::endl ; + eMc.extract(erc); + std::cout << "Theta U rotation: " << vpMath::deg(erc[0]) << " " << vpMath::deg(erc[1]) << " " << vpMath::deg(erc[2]) << std::endl; + return 0 ; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1 ; + } } -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ diff --git a/example/calibration/camera_calibration.cpp b/example/calibration/camera_calibration.cpp index 701a77e594585fca7db0aa1b3fa98228c37cf48c..dff886311122aba01e9d3370d795cf1a46b3cd76 100644 --- a/example/calibration/camera_calibration.cpp +++ b/example/calibration/camera_calibration.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: camera_calibration.cpp 4286 2013-06-26 20:28:16Z fspindle $ + * $Id: camera_calibration.cpp 4663 2014-02-14 10:32:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -61,10 +61,19 @@ #include <visp/vpVideoReader.h> #include <visp/vpXmlParserCamera.h> +#ifndef DOXYGEN_SHOULD_SKIP_THIS + class Settings { public: - Settings() : goodInput(false) {} + Settings() { + boardSize = cv::Size(0, 0); + calibrationPattern = UNDEFINED; + squareSize = 0.025f; + goodInput = false; + tempo = 1.f; + + } enum Pattern { UNDEFINED, CHESSBOARD, CIRCLES_GRID}; bool read(const std::string &filename) // Read the parameters @@ -77,12 +86,14 @@ public: vpIoTools::readConfigVar("Square_Size:", squareSize); vpIoTools::readConfigVar("Calibrate_Pattern:", patternToUse); vpIoTools::readConfigVar("Input:", input); + vpIoTools::readConfigVar("Tempo:", tempo); std::cout << "grid width : " << boardSize.width << std::endl; std::cout << "grid height: " << boardSize.height << std::endl; std::cout << "square size: " << squareSize << std::endl; std::cout << "pattern : " << patternToUse << std::endl; std::cout << "input seq : " << input << std::endl; + std::cout << "tempo : " << tempo << std::endl; interprate(); return true; } @@ -102,8 +113,8 @@ public: goodInput = false; calibrationPattern = UNDEFINED; - if (!patternToUse.compare("CHESSBOARD")) calibrationPattern = CHESSBOARD; - if (!patternToUse.compare("CIRCLES_GRID")) calibrationPattern = CIRCLES_GRID; + if (patternToUse.compare("CHESSBOARD") == 0) calibrationPattern = CHESSBOARD; + else if (patternToUse.compare("CIRCLES_GRID") == 0) calibrationPattern = CIRCLES_GRID; if (calibrationPattern == UNDEFINED) { std::cerr << " Inexistent camera calibration mode: " << patternToUse << std::endl; goodInput = false; @@ -115,172 +126,206 @@ public: Pattern calibrationPattern;// One of the Chessboard, circles, or asymmetric circle pattern float squareSize; // The size of a square in your defined unit (point, millimeter,etc). std::string input; // The input image sequence + float tempo; // Tempo in seconds between two images. If > 10 wait a click to continue bool goodInput; private: std::string patternToUse; }; +#endif int main(int argc, const char ** argv) { - std::string outputFileName = "camera.xml"; - - Settings s; - const std::string inputSettingsFile = argc > 1 ? argv[1] : "default.cfg"; - if (! s.read(inputSettingsFile) ) { - std::cout << "Could not open the configuration file: \"" << inputSettingsFile << "\"" << std::endl; - std::cout << std::endl << "Usage: " << argv[0] << " <configuration file>.cfg" << std::endl; - return -1; - } + try { + std::string outputFileName = "camera.xml"; + + Settings s; + const std::string inputSettingsFile = argc > 1 ? argv[1] : "default.cfg"; + if (! s.read(inputSettingsFile) ) { + std::cout << "Could not open the configuration file: \"" << inputSettingsFile << "\"" << std::endl; + std::cout << std::endl << "Usage: " << argv[0] << " <configuration file>.cfg" << std::endl; + return -1; + } - if (! s.goodInput) - { - std::cout << "Invalid input detected. Application stopping. " << std::endl; - return -1; - } + if (! s.goodInput) + { + std::cout << "Invalid input detected. Application stopping. " << std::endl; + return -1; + } - // Start the calibration code - vpImage<unsigned char> I; - vpVideoReader reader; - reader.setFileName(s.input); - reader.open(I); + // Start the calibration code + vpImage<unsigned char> I; + vpVideoReader reader; + reader.setFileName(s.input); + reader.open(I); #ifdef VISP_HAVE_X11 - vpDisplayX d(I); + vpDisplayX d(I); #elif defined VISP_HAVE_GDI - vpDisplayGDI d(I); + vpDisplayGDI d(I); #elif defined VISP_HAVE_GTK - vpDisplayGTK d(I); + vpDisplayGTK d(I); #elif defined VISP_HAVE_OPENCV - vpDisplayOpenCV d(I); + vpDisplayOpenCV d(I); #endif - std::vector<vpPoint> model; - std::vector<vpCalibration> calibrator; - - for (int i=0; i< s.boardSize.height; i++) { - for (int j=0; j< s.boardSize.width; j++) { - vpPoint P; - P.setWorldCoordinates(j*s.squareSize, i*s.squareSize, 0); - model.push_back(P); - } - } - - long frame_index; - while(! reader.end()) { - frame_index = reader.getFrameIndex(); - reader.acquire(I); - vpDisplay::display(I); + std::vector<vpPoint> model; + std::vector<vpCalibration> calibrator; - cv::Mat cvI; - std::vector<cv::Point2f> pointBuf; - vpImageConvert::convert(I, cvI); - - bool found; - switch( s.calibrationPattern ) // Find feature points on the input format - { - case Settings::CHESSBOARD: - found = findChessboardCorners( cvI, s.boardSize, pointBuf, - CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FAST_CHECK | CV_CALIB_CB_NORMALIZE_IMAGE); - break; - case Settings::CIRCLES_GRID: - found = findCirclesGrid( cvI, s.boardSize, pointBuf, cv::CALIB_CB_SYMMETRIC_GRID ); - break; - default: - break; + for (int i=0; i< s.boardSize.height; i++) { + for (int j=0; j< s.boardSize.width; j++) { + vpPoint P; + P.setWorldCoordinates(j*s.squareSize, i*s.squareSize, 0); + model.push_back(P); + } } - std::cout << "frame: " << frame_index << " status: " << found << std::endl; - - if ( found) // If done with success, - { - std::vector<vpImagePoint> data; - - if (s.calibrationPattern == Settings::CHESSBOARD) { - // improve the found corners' coordinate accuracy for chessboard - cornerSubPix( cvI, pointBuf, cv::Size(11,11), - cv::Size(-1,-1), cv::TermCriteria( CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, 30, 0.1 )); + long frame_index; + while(! reader.end()) { + frame_index = reader.getFrameIndex(); + reader.acquire(I); + vpDisplay::display(I); + + cv::Mat cvI; + std::vector<cv::Point2f> pointBuf; + vpImageConvert::convert(I, cvI); + + bool found = false; + switch( s.calibrationPattern ) // Find feature points on the input format + { + case Settings::CHESSBOARD: + //std::cout << "Use chessboard " << std::endl; + found = findChessboardCorners( cvI, s.boardSize, pointBuf, + CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FAST_CHECK | CV_CALIB_CB_NORMALIZE_IMAGE); + break; + case Settings::CIRCLES_GRID: + //std::cout << "Use circle grid " << std::endl; + found = findCirclesGrid( cvI, s.boardSize, pointBuf, cv::CALIB_CB_SYMMETRIC_GRID ); + break; + case Settings::UNDEFINED: + default: + std::cout << "Unkown calibration grid " << std::endl; + break; } - char title[20]; sprintf(title, "image %ld", frame_index); - vpDisplay::setTitle(I, title); - for (unsigned int i=0; i < pointBuf.size(); i++) { - vpImagePoint ip(pointBuf[i].y, pointBuf[i].x); - data.push_back(ip); - vpDisplay::displayCross(I, ip, 10, vpColor::red); + std::cout << "frame: " << frame_index << ", status: " << found; + if (!found) + std::cout << ", image rejected" << std::endl; + else + std::cout << ", image used as input data" << std::endl; + + if ( found) // If done with success, + { + std::vector<vpImagePoint> data; + + if (s.calibrationPattern == Settings::CHESSBOARD) { + // improve the found corners' coordinate accuracy for chessboard + cornerSubPix( cvI, pointBuf, cv::Size(11,11), + cv::Size(-1,-1), cv::TermCriteria( CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, 30, 0.1 )); + } + char title[20]; sprintf(title, "image %ld", frame_index); + vpDisplay::setTitle(I, title); + for (unsigned int i=0; i < pointBuf.size(); i++) { + vpImagePoint ip(pointBuf[i].y, pointBuf[i].x); + data.push_back(ip); + vpDisplay::displayCross(I, ip, 10, vpColor::red); + } + + // Calibration on a single mono image + vpCalibration calib; + calib.setLambda(0.5); + calib.clearPoint(); + for (unsigned int i=0; i<model.size(); i++) { + calib.addPoint(model[i].get_oX(), model[i].get_oY(), model[i].get_oZ(), data[i]); + } + vpHomogeneousMatrix cMo; + vpCameraParameters cam; + + // Set (u0,v0) in the middle of the image + double px = cam.get_px(); + double py = cam.get_px(); + double u0 = I.getWidth()/2; + double v0 = I.getHeight()/2; + cam.initPersProjWithoutDistortion(px, py, u0, v0); + + if (calib.computeCalibration(vpCalibration::CALIB_VIRTUAL_VS, cMo, cam, false) == 0) { + //std::cout << "camera parameters: " << cam << std::endl; + calibrator.push_back(calib); + } } - // Calibration on a single mono image - vpCalibration calib; - calib.setLambda(0.5); - calib.clearPoint(); - for (unsigned int i=0; i<model.size(); i++) { - calib.addPoint(model[i].get_oX(), model[i].get_oY(), model[i].get_oZ(), data[i]); + if (found) + vpDisplay::displayCharString(I, 15, 15, "Image processing succeed", vpColor::green); + else + vpDisplay::displayCharString(I, 15, 15, "Image processing fails", vpColor::green); + + if (s.tempo > 10.f) { + vpDisplay::displayCharString(I, 35, 15, "A click to process the next image", vpColor::green); + vpDisplay::flush(I); + vpDisplay::getClick(I); } - vpHomogeneousMatrix cMo; - vpCameraParameters cam; - - // Set (u0,v0) in the middle of the image - double px = cam.get_px(); - double py = cam.get_px(); - double u0 = I.getWidth()/2; - double v0 = I.getHeight()/2; - cam.initPersProjWithoutDistortion(px, py, u0, v0); - - if (calib.computeCalibration(vpCalibration::CALIB_VIRTUAL_VS, cMo, cam, false) == 0) { - //std::cout << "camera parameters: " << cam << std::endl; - calibrator.push_back(calib); + else { + vpDisplay::flush(I); + vpTime::wait(s.tempo*1000); } } - vpDisplay::flush(I); - //vpDisplay::getClick(I); - } - - // Now we consider the multi image calibration - // Calibrate by a non linear method based on virtual visual servoing - if (calibrator.empty()) { - std::cerr << "Unable to calibrate. Image processing failed !" << std::endl; - return 0; - } + // Now we consider the multi image calibration + // Calibrate by a non linear method based on virtual visual servoing + if (calibrator.empty()) { + std::cerr << "Unable to calibrate. Image processing failed !" << std::endl; + return 0; + } - std::cout << "\nCalibration without distorsion in progress on " << calibrator.size() << " images..." << std::endl; - vpCameraParameters cam; - double error; - if (vpCalibration::computeCalibrationMulti(vpCalibration::CALIB_VIRTUAL_VS, calibrator, cam, error, false) == 0) { - std::cout << cam << std::endl; - std::cout << "Global reprojection error: " << error << std::endl; + std::cout << "\nCalibration without distorsion in progress on " << calibrator.size() << " images..." << std::endl; + vpCameraParameters cam; + double error; + if (vpCalibration::computeCalibrationMulti(vpCalibration::CALIB_VIRTUAL_VS, calibrator, cam, error, false) == 0) { + std::cout << cam << std::endl; + std::cout << "Global reprojection error: " << error << std::endl; #ifdef VISP_HAVE_XML2 - vpXmlParserCamera xml; + vpXmlParserCamera xml; - if(xml.save(cam, outputFileName.c_str(), "Camera", I.getWidth(), I.getHeight()) == vpXmlParserCamera::SEQUENCE_OK) - std::cout << "Camera parameters without distortion successfully saved in \"" << outputFileName << "\"" << std::endl; - else { - std::cout << "Failed to save the camera parameters without distortion in \"" << outputFileName << "\"" << std::endl; - std::cout << "A file with the same name exists. Remove it to be able to save the parameters..." << std::endl; - } + if(xml.save(cam, outputFileName.c_str(), "Camera", I.getWidth(), I.getHeight()) == vpXmlParserCamera::SEQUENCE_OK) + std::cout << "Camera parameters without distortion successfully saved in \"" << outputFileName << "\"" << std::endl; + else { + std::cout << "Failed to save the camera parameters without distortion in \"" << outputFileName << "\"" << std::endl; + std::cout << "A file with the same name exists. Remove it to be able to save the parameters..." << std::endl; + } #endif - } - else - std::cout << "Calibration without distortion failed." << std::endl; + } + else + std::cout << "Calibration without distortion failed." << std::endl; + + std::cout << "\nCalibration with distorsion in progress on " << calibrator.size() << " images..." << std::endl; + if (vpCalibration::computeCalibrationMulti(vpCalibration::CALIB_VIRTUAL_VS_DIST, calibrator, cam, error, false) == 0) { + std::cout << cam << std::endl; + std::cout << "Global reprojection error: " << error << std::endl; - std::cout << "\nCalibration with distorsion in progress on " << calibrator.size() << " images..." << std::endl; - if (vpCalibration::computeCalibrationMulti(vpCalibration::CALIB_VIRTUAL_VS_DIST, calibrator, cam, error, false) == 0) { - std::cout << cam << std::endl; - std::cout << "Global reprojection error: " << error << std::endl; #ifdef VISP_HAVE_XML2 - vpXmlParserCamera xml; + vpXmlParserCamera xml; - if(xml.save(cam, outputFileName.c_str(), "Camera", I.getWidth(), I.getHeight()) == vpXmlParserCamera::SEQUENCE_OK) - std::cout << "Camera parameters without distortion successfully saved in \"" << outputFileName << "\"" << std::endl; - else { - std::cout << "Failed to save the camera parameters without distortion in \"" << outputFileName << "\"" << std::endl; - std::cout << "A file with the same name exists. Remove it to be able to save the parameters..." << std::endl; - } + if(xml.save(cam, outputFileName.c_str(), "Camera", I.getWidth(), I.getHeight()) == vpXmlParserCamera::SEQUENCE_OK) + std::cout << "Camera parameters without distortion successfully saved in \"" << outputFileName << "\"" << std::endl; + else { + std::cout << "Failed to save the camera parameters without distortion in \"" << outputFileName << "\"" << std::endl; + std::cout << "A file with the same name exists. Remove it to be able to save the parameters..." << std::endl; + } #endif + std::cout << std::endl; + for (unsigned int i=0; i<calibrator.size(); i++) + std::cout << "Estimated pose on input data " << i << ": " << vpPoseVector(calibrator[i].cMo_dist).t() << std::endl; + + } + else + std::cout << "Calibration with distortion failed." << std::endl; + + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - else - std::cout << "Calibration with distortion failed." << std::endl; } #else int main() diff --git a/example/calibration/chessboard-01.png b/example/calibration/chessboard-01.png new file mode 100644 index 0000000000000000000000000000000000000000..4e92fd62c1a9c709e8da7d7e1c3c034a38db5612 Binary files /dev/null and b/example/calibration/chessboard-01.png differ diff --git a/example/calibration/chessboard-02.png b/example/calibration/chessboard-02.png new file mode 100644 index 0000000000000000000000000000000000000000..ab56b8e5dfb10c5c23b00ef7c5fd346b6a2dd2af Binary files /dev/null and b/example/calibration/chessboard-02.png differ diff --git a/example/calibration/chessboard-03.png b/example/calibration/chessboard-03.png new file mode 100644 index 0000000000000000000000000000000000000000..089bc3290052fb1ebcaa56b25e72d40459005278 Binary files /dev/null and b/example/calibration/chessboard-03.png differ diff --git a/example/calibration/chessboard-04.png b/example/calibration/chessboard-04.png new file mode 100644 index 0000000000000000000000000000000000000000..048515907dfc902e693bd1fd8afe9b6887ba0846 Binary files /dev/null and b/example/calibration/chessboard-04.png differ diff --git a/example/calibration/chessboard-05.png b/example/calibration/chessboard-05.png new file mode 100644 index 0000000000000000000000000000000000000000..efaa34ab37de9c43ea872990bed6b3cb533b06ff Binary files /dev/null and b/example/calibration/chessboard-05.png differ diff --git a/example/calibration/circles-01.png b/example/calibration/circles-01.png new file mode 100644 index 0000000000000000000000000000000000000000..a0340a054a6b07f730037f2e36c1dcf2b042e7ab Binary files /dev/null and b/example/calibration/circles-01.png differ diff --git a/example/calibration/circles-02.png b/example/calibration/circles-02.png new file mode 100644 index 0000000000000000000000000000000000000000..44504e36409d294546396a8958e0bea55bd6f53e Binary files /dev/null and b/example/calibration/circles-02.png differ diff --git a/example/calibration/circles-03.png b/example/calibration/circles-03.png new file mode 100644 index 0000000000000000000000000000000000000000..3a01fadaa4bb8c63f644c12b1b5a6fdf2c832c3b Binary files /dev/null and b/example/calibration/circles-03.png differ diff --git a/example/calibration/circles-04.png b/example/calibration/circles-04.png new file mode 100644 index 0000000000000000000000000000000000000000..48d0993e0da9e9822635d6c30ecbf82be79accdb Binary files /dev/null and b/example/calibration/circles-04.png differ diff --git a/example/calibration/circles-05.png b/example/calibration/circles-05.png new file mode 100644 index 0000000000000000000000000000000000000000..05fb8dcc42c36fa7cddf263b4263ca18cd6b3d75 Binary files /dev/null and b/example/calibration/circles-05.png differ diff --git a/example/calibration/default-chessboard.cfg b/example/calibration/default-chessboard.cfg index 4b040be211ac448a51ba75a592e59a51dec12556..9de6af08c8f737186d01441736b351a73eb928c2 100644 --- a/example/calibration/default-chessboard.cfg +++ b/example/calibration/default-chessboard.cfg @@ -11,3 +11,6 @@ Calibrate_Pattern: CHESSBOARD # The input image sequence to use for calibration Input: chessboard-%02d.png + +# Tempo in seconds between two images. If > 10 wait a click to continue +Tempo: 1 diff --git a/example/calibration/default-circles.cfg b/example/calibration/default-circles.cfg index 2c540baec36078d3ca6474da7cc7cfd92223b09e..bb68c64872a9d90a5096f36f2066e4ff10c759a6 100644 --- a/example/calibration/default-circles.cfg +++ b/example/calibration/default-circles.cfg @@ -10,4 +10,7 @@ Square_Size: 0.034 Calibrate_Pattern: CIRCLES_GRID # The input image sequence to use for calibration -Input: circle-grid-%02d.pgm +Input: circles-%02d.png + +# Tempo in seconds between two images. If > 10 wait a click to continue +Tempo: 1 diff --git a/example/coin-simulator/CMakeLists.txt b/example/coin-simulator/CMakeLists.txt index 3e619cc75e673fbe84ac0abdc7d1ee9d7f585153..1b5d93d94c229a10b82245f6dea431232fe2e7f8 100644 --- a/example/coin-simulator/CMakeLists.txt +++ b/example/coin-simulator/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/coin-simulator/simulateCircle2DCamVelocity.cpp b/example/coin-simulator/simulateCircle2DCamVelocity.cpp index 728c2e945b1aac5cdd5eca1025b91f1ead820f40..f56f20386117a69f3962a4ce8bca177a74f3549e 100644 --- a/example/coin-simulator/simulateCircle2DCamVelocity.cpp +++ b/example/coin-simulator/simulateCircle2DCamVelocity.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: simulateCircle2DCamVelocity.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: simulateCircle2DCamVelocity.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -189,8 +189,6 @@ void *mainLoop (void *_simu) unsigned int pos = 2 ; while (pos!=0) { - - vpServo task ; vpRobotCamera robot ; @@ -321,77 +319,84 @@ void *mainLoop (void *_simu) 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); - } + try { + 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 <visp image path=" << ipath << "> " - << " is different from VISP_INPUT_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + // 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 <visp image path=" << ipath << "> " + << " 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 <visp image path> 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); - } + // 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 <visp image path> 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 ; + vpCameraParameters cam ; + vpHomogeneousMatrix fMo ; fMo[2][3] = 0 ; - if (opt_display) { + if (opt_display) { - vpSimulator simu ; - simu.initInternalViewer(300, 300) ; - simu.initExternalViewer(300, 300) ; + vpSimulator simu ; + simu.initInternalViewer(300, 300) ; + simu.initExternalViewer(300, 300) ; - vpTime::wait(1000) ; - simu.setZoomFactor(1.0f) ; - simu.addAbsoluteFrame() ; + 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) ; + // Load the cad model + filename = ipath + vpIoTools::path("/ViSP-images/iv/circle.iv"); + simu.load(filename.c_str(),fMo) ; - simu.setInternalCameraParameters(cam) ; + simu.setInternalCameraParameters(cam) ; - simu.initApplication(&mainLoop) ; - simu.mainLoop() ; + simu.initApplication(&mainLoop) ; + simu.mainLoop() ; + } + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } } diff --git a/example/coin-simulator/simulateFourPoints2DCartesianCamVelocity.cpp b/example/coin-simulator/simulateFourPoints2DCartesianCamVelocity.cpp index 729a1844d0db166376c9754292231c1b36d9e3b0..9ececb271b8490f80b38b24a3af3df0b043b4a7b 100644 --- a/example/coin-simulator/simulateFourPoints2DCartesianCamVelocity.cpp +++ b/example/coin-simulator/simulateFourPoints2DCartesianCamVelocity.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: simulateFourPoints2DCartesianCamVelocity.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: simulateFourPoints2DCartesianCamVelocity.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -318,76 +318,83 @@ void *mainLoop (void *_simu) 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); - } + try { + 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 <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + // 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 <visp image path=" << ipath << "> " + << " 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 <visp image path> 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); - } + // 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 <visp image path> 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 ; + vpCameraParameters cam ; + vpHomogeneousMatrix fMo ; fMo[2][3] = 0 ; - if (opt_display) { - vpSimulator simu ; - simu.initInternalViewer(300, 300) ; - simu.initExternalViewer(300, 300) ; + if (opt_display) { + vpSimulator simu ; + simu.initInternalViewer(300, 300) ; + simu.initExternalViewer(300, 300) ; - vpTime::wait(1000) ; - simu.setZoomFactor(1.0f) ; + 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()) ; + // 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.setInternalCameraParameters(cam) ; + simu.setExternalCameraParameters(cam) ; + simu.initApplication(&mainLoop) ; - simu.mainLoop() ; + simu.mainLoop() ; + } + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } } diff --git a/example/coin-simulator/simulateFourPoints2DPolarCamVelocity.cpp b/example/coin-simulator/simulateFourPoints2DPolarCamVelocity.cpp index b891e707ed7511dd5a0184fcf22ede2153f0f4b5..8a5033ac1910b6826936bb1ddcc1b1900d6c5ff9 100644 --- a/example/coin-simulator/simulateFourPoints2DPolarCamVelocity.cpp +++ b/example/coin-simulator/simulateFourPoints2DPolarCamVelocity.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: simulateFourPoints2DPolarCamVelocity.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: simulateFourPoints2DPolarCamVelocity.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -345,76 +345,83 @@ void *mainLoop (void *_simu) 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); - } + try { + 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 <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + // 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 <visp image path=" << ipath << "> " + << " 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 <visp image path> 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); - } + // 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 <visp image path> 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 ; + vpCameraParameters cam ; + vpHomogeneousMatrix fMo ; fMo[2][3] = 0 ; - if (opt_display) { - vpSimulator simu ; - simu.initInternalViewer(300, 300) ; - simu.initExternalViewer(300, 300) ; + if (opt_display) { + vpSimulator simu ; + simu.initInternalViewer(300, 300) ; + simu.initExternalViewer(300, 300) ; - vpTime::wait(1000) ; - simu.setZoomFactor(1.0f) ; + 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()) ; + // 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.setInternalCameraParameters(cam) ; + simu.setExternalCameraParameters(cam) ; + simu.initApplication(&mainLoop) ; - simu.mainLoop() ; + simu.mainLoop() ; + } + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } } diff --git a/example/device/CMakeLists.txt b/example/device/CMakeLists.txt index 7a3d65cdb4f0ed2af6bce106305c3c8c1699e578..f4114f85b7170c78425e13f6cbb8994c2b2cbe33 100644 --- a/example/device/CMakeLists.txt +++ b/example/device/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/device/display/CMakeLists.txt b/example/device/display/CMakeLists.txt index 6c30fe5d8eb764760b41c523be63b69a3a1969f9..9c609bf1329bf8399b3ae06f5b104a156d8e644b 100644 --- a/example/device/display/CMakeLists.txt +++ b/example/device/display/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/device/display/displayD3D.cpp b/example/device/display/displayD3D.cpp index 375340aa0ba826bf3e31e4f84f27cf82e167ef43..a6e957771d9faa8268bb2e8a6d57d27cb12384b2 100755 --- a/example/device/display/displayD3D.cpp +++ b/example/device/display/displayD3D.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: displayD3D.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: displayD3D.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -180,255 +180,251 @@ bool getOptions(int argc, const char **argv, 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; - bool opt_click_allowed = true; - 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; - - // Set the default output path - opt_opath = "C:\\temp"; - - - // Get the user login name - vpIoTools::getUserName(username); - - // Read the command line options - if (getOptions(argc, argv, opt_ipath, opt_opath, - opt_click_allowed, username, opt_display) == false) { - exit (-1); - } - - // Get the option values - if (!opt_ipath.empty()) - ipath = opt_ipath; - if (!opt_opath.empty()) - opath = opt_opath; + try { + std::string env_ipath; + std::string opt_ipath; + std::string opt_opath; + std::string ipath; + std::string opath; + std::string filename; + std::string username; + bool opt_click_allowed = true; + 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; + + // Set the default output path + opt_opath = "C:\\temp"; + + + // Get the user login name + vpIoTools::getUserName(username); + + // Read the command line options + if (getOptions(argc, argv, opt_ipath, opt_opath, + opt_click_allowed, username, opt_display) == false) { + exit (-1); + } - // Append to the output path string, the login name of the user - std::string odirname = opath + vpIoTools::path("/") + username; + // Get the option values + if (!opt_ipath.empty()) + ipath = opt_ipath; + if (!opt_opath.empty()) + opath = opt_opath; + + // Append to the output path string, the login name of the user + std::string odirname = opath + vpIoTools::path("/") + username; + + // Test if the output path exist. If no try to create it + if (vpIoTools::checkDirectory(odirname) == false) { + try { + // Create the dirname + vpIoTools::makeDirectory(odirname); + } + catch (...) { + usage(argv[0], NULL, ipath, opath, username); + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Cannot create " << odirname << std::endl; + std::cerr << " Check your -o " << opath << " option " << std::endl; + exit(-1); + } + } - // Test if the output path exist. If no try to create it - if (vpIoTools::checkDirectory(odirname) == false) { - try { - // Create the dirname - vpIoTools::makeDirectory(odirname); + // 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 <visp image path=" << ipath << "> " + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; + } } - catch (...) { + + // 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 << " Cannot create " << odirname << std::endl; - std::cerr << " Check your -o " << opath << " option " << std::endl; + std::cerr << " Use -i <visp image path> 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); } - } - // 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 <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; - } - } + // Create a grey level image + vpImage<unsigned char> I ; + vpImagePoint ip, ip1, ip2; - // 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 <visp image path> 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); - } + // Load a grey image from the disk + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); + vpImageIo::read(I, filename) ; - // Create a grey level image - vpImage<unsigned char> I ; - vpImagePoint ip, ip1, ip2; + // For this grey level image, open a D3D display at position 100,100 + // in the screen, and with title "D3D display" + vpDisplayD3D display; - // Load a grey image from the disk - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); - try { - vpImageIo::read(I, filename) ; - } - catch (...) { - return -1; - } + if (opt_display) { + // We open a window using D3D. + // Its size is automatically defined by the image (I) size + display.init(I, 100, 100, "D3D display") ; - // For this grey level image, open a D3D display at position 100,100 - // in the screen, and with title "D3D display" - vpDisplayD3D display; + // Display the image + vpDisplay::display(I) ; - if (opt_display) { - // We open a window using D3D. - // Its size is automatically defined by the image (I) size - display.init(I, 100, 100, "D3D display") ; + // Display in overlay a red cross at position 10,10 in the + // image. The lines are 10 pixels long + ip.set_i( 100 ); + ip.set_j( 10 ); - // Display the image - vpDisplay::display(I) ; + vpDisplay::displayCross(I, ip, 20, vpColor::red) ; - // Display in overlay a red cross at position 10,10 in the - // image. The lines are 10 pixels long - ip.set_i( 100 ); - ip.set_j( 10 ); - - vpDisplay::displayCross(I, ip, 20, vpColor::red) ; + // Display in overlay horizontal red lines + for (unsigned i=0 ; i < I.getHeight() ; i+=20) { + ip1.set_i( i ); + ip1.set_j( 0 ); + ip2.set_i( i ); + ip2.set_j( I.getWidth() ); + vpDisplay::displayLine(I, ip1, ip2, vpColor::red) ; + } - // Display in overlay horizontal red lines - for (unsigned i=0 ; i < I.getHeight() ; i+=20) { - ip1.set_i( i ); - ip1.set_j( 0 ); - ip2.set_i( i ); - ip2.set_j( I.getWidth() ); - vpDisplay::displayLine(I, ip1, ip2, vpColor::red) ; - } + // Display a ligne in the diagonal + ip1.set_i( -10 ); + ip1.set_j( -10 ); + ip2.set_i( I.getHeight() + 10 ); + ip2.set_j( I.getWidth() + 10 ); - // Display a ligne in the diagonal - ip1.set_i( -10 ); - ip1.set_j( -10 ); - ip2.set_i( I.getHeight() + 10 ); - ip2.set_j( I.getWidth() + 10 ); - - vpDisplay::displayLine(I, ip1, ip2, vpColor::red) ; + vpDisplay::displayLine(I, ip1, ip2, vpColor::red) ; - // Display in overlay vertical green dot lines - for (unsigned i=0 ; i < I.getWidth() ; i+=20) { + // Display in overlay vertical green dot lines + for (unsigned i=0 ; i < I.getWidth() ; i+=20) { + ip1.set_i( 0 ); + ip1.set_j( i ); + ip2.set_i( I.getWidth() ); + ip2.set_j( i ); + vpDisplay::displayDotLine(I, ip1, ip2, vpColor::green) ; + } + + // Display a rectangle + ip.set_i( I.getHeight() - 45 ); + ip.set_j( -10 ); + vpDisplay::displayRectangle(I, ip, 60, 80, vpColor::orange) ; + + // Display in overlay a blue arrow ip1.set_i( 0 ); - ip1.set_j( i ); - ip2.set_i( I.getWidth() ); - ip2.set_j( i ); - vpDisplay::displayDotLine(I, ip1, ip2, vpColor::green) ; - } - - // Display a rectangle - ip.set_i( I.getHeight() - 45 ); - ip.set_j( -10 ); - vpDisplay::displayRectangle(I, ip, 60, 80, vpColor::orange) ; - - // Display in overlay a blue arrow - ip1.set_i( 0 ); - ip1.set_j( 0 ); - ip2.set_i( 100 ); - ip2.set_j( 100 ); - vpDisplay::displayArrow(I, ip1, ip2, vpColor::blue) ; - - // Display in overlay some circles. The position of the center is 200, 200 - // the radius is increased by 20 pixels for each circle - - for (unsigned int i=0 ; i < 100 ; i+=20) { - ip.set_i( 80 ); - ip.set_j( 80 ); - vpDisplay::displayCircle(I, ip, 20+i, vpColor::yellow) ; + ip1.set_j( 0 ); + ip2.set_i( 100 ); + ip2.set_j( 100 ); + vpDisplay::displayArrow(I, ip1, ip2, vpColor::blue) ; + + // Display in overlay some circles. The position of the center is 200, 200 + // the radius is increased by 20 pixels for each circle + + for (unsigned int i=0 ; i < 100 ; i+=20) { + ip.set_i( 80 ); + ip.set_j( 80 ); + vpDisplay::displayCircle(I, ip, 20+i, vpColor::yellow) ; + } + + ip.set_i( -10 ); + ip.set_j( 300 ); + vpDisplay::displayCircle(I, ip, 100,vpColor::yellow) ; + + // Display in overlay a yellow string + ip.set_i( 85 ); + ip.set_j( 100 ); + vpDisplay::displayCharString(I, ip, + "ViSP is a marvelous software", + vpColor::yellow) ; + //Flush the display + vpDisplay::flush(I); + + // Create a color image + vpImage<vpRGBa> Ioverlay ; + // Updates the color image with the original loaded image and the overlay + vpDisplay::getImage(I, Ioverlay) ; + + // Write the color image on the disk + filename = odirname + vpIoTools::path("/Klimt_grey.overlay.ppm"); + vpImageIo::write(Ioverlay, filename) ; + + // If click is allowed, wait for a mouse click to close the display + if (opt_click_allowed) { + std::cout << "\nA click to close the windows..." << std::endl; + // Wait for a blocking mouse click + vpDisplay::getClick(I) ; + } + + // Close the display + vpDisplay::close(I); } - ip.set_i( -10 ); - ip.set_j( 300 ); - vpDisplay::displayCircle(I, ip, 100,vpColor::yellow) ; - - // Display in overlay a yellow string - ip.set_i( 85 ); - ip.set_j( 100 ); - vpDisplay::displayCharString(I, ip, - "ViSP is a marvelous software", - vpColor::yellow) ; - //Flush the display - vpDisplay::flush(I); - // Create a color image - vpImage<vpRGBa> Ioverlay ; - // Updates the color image with the original loaded image and the overlay - vpDisplay::getImage(I, Ioverlay) ; - - // Write the color image on the disk - filename = odirname + vpIoTools::path("/Klimt_grey.overlay.ppm"); - vpImageIo::write(Ioverlay, filename) ; - - // If click is allowed, wait for a mouse click to close the display - if (opt_click_allowed) { - std::cout << "\nA click to close the windows..." << std::endl; - // Wait for a blocking mouse click - vpDisplay::getClick(I) ; - } - - // Close the display - vpDisplay::close(I); - } + vpImage<vpRGBa> Irgba ; - // Create a color image - vpImage<vpRGBa> Irgba ; - - // Load a grey image from the disk and convert it to a color image - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); - try { + // Load a grey image from the disk and convert it to a color image + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); vpImageIo::read(Irgba, filename) ; - } - catch (...) { - return -1; - } - // For this color image, open a D3D display at position 100,100 - // in the screen, and with title "D3D color display" - vpDisplayD3D displayRGBa; - - if (opt_display) { - // We open a window using D3D. - // Its size is automatically defined by the image (Irgba) size - displayRGBa.init(Irgba, 100, 100, "D3D color display"); - - // Display the color image - vpDisplay::display(Irgba) ; - vpDisplay::flush(Irgba) ; - - // If click is allowed, wait for a blocking mouse click to display a cross - // at the clicked pixel position - if (opt_click_allowed) { - std::cout << "\nA click to display a cross..." << std::endl; - // Blocking wait for a click. Get the position of the selected pixel - // (i correspond to the row and j to the column coordinates in the image) - vpDisplay::getClick(Irgba, ip); - // Display a red cross on the click pixel position - std::cout << "Cross position: " << ip << std::endl; - vpDisplay::displayCross(Irgba, ip, 15, vpColor::red); - } - else { - ip.set_i( 10 ); - ip.set_j( 20 ); - // Display a red cross at position i, j (i correspond to the row - // and j to the column coordinates in the image) - std::cout << "Cross position: " << ip << std::endl; - vpDisplay::displayCross(Irgba, ip, 15, vpColor::red); - - } - // Flush the display. Sometimes the display content is - // bufferized. Force to display the content that has been bufferized. - vpDisplay::flush(Irgba); - - // If click is allowed, wait for a blocking mouse click to exit. - if (opt_click_allowed) { - std::cout << "\nA click to exit the program..." << std::endl; - vpDisplay::getClick(Irgba) ; - std::cout << "Bye" << std::endl; + // For this color image, open a D3D display at position 100,100 + // in the screen, and with title "D3D color display" + vpDisplayD3D displayRGBa; + + if (opt_display) { + // We open a window using D3D. + // Its size is automatically defined by the image (Irgba) size + displayRGBa.init(Irgba, 100, 100, "D3D color display"); + + // Display the color image + vpDisplay::display(Irgba) ; + vpDisplay::flush(Irgba) ; + + // If click is allowed, wait for a blocking mouse click to display a cross + // at the clicked pixel position + if (opt_click_allowed) { + std::cout << "\nA click to display a cross..." << std::endl; + // Blocking wait for a click. Get the position of the selected pixel + // (i correspond to the row and j to the column coordinates in the image) + vpDisplay::getClick(Irgba, ip); + // Display a red cross on the click pixel position + std::cout << "Cross position: " << ip << std::endl; + vpDisplay::displayCross(Irgba, ip, 15, vpColor::red); + } + else { + ip.set_i( 10 ); + ip.set_j( 20 ); + // Display a red cross at position i, j (i correspond to the row + // and j to the column coordinates in the image) + std::cout << "Cross position: " << ip << std::endl; + vpDisplay::displayCross(Irgba, ip, 15, vpColor::red); + + } + // Flush the display. Sometimes the display content is + // bufferized. Force to display the content that has been bufferized. + vpDisplay::flush(Irgba); + + // If click is allowed, wait for a blocking mouse click to exit. + if (opt_click_allowed) { + std::cout << "\nA click to exit the program..." << std::endl; + vpDisplay::getClick(Irgba) ; + std::cout << "Bye" << std::endl; + } } } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } #else int diff --git a/example/device/display/displayGDI.cpp b/example/device/display/displayGDI.cpp index 3176cf0a1bf85e26fa318fdf2841fa9e30b11557..aa104abcff34f38feefdf13d980010806e0f772a 100755 --- a/example/device/display/displayGDI.cpp +++ b/example/device/display/displayGDI.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: displayGDI.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: displayGDI.cpp 4604 2014-01-21 14:15:23Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -50,7 +50,7 @@ #include <visp/vpDebug.h> #include <visp/vpConfig.h> -#if ( defined(WIN32) && defined(VISP_HAVE_GDI) ) +#if ( defined(_WIN32) && defined(VISP_HAVE_GDI) ) #include <visp/vpDisplayGDI.h> @@ -179,255 +179,250 @@ bool getOptions(int argc, const char **argv, 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; - bool opt_click_allowed = true; - 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; - - // Set the default output path - opt_opath = "C:\\temp"; - - - // Get the user login name - vpIoTools::getUserName(username); - - // Read the command line options - if (getOptions(argc, argv, opt_ipath, opt_opath, - opt_click_allowed, username, opt_display) == false) { - exit (-1); - } - - // Get the option values - if (!opt_ipath.empty()) - ipath = opt_ipath; - if (!opt_opath.empty()) - opath = opt_opath; + try { + std::string env_ipath; + std::string opt_ipath; + std::string opt_opath; + std::string ipath; + std::string opath; + std::string filename; + std::string username; + bool opt_click_allowed = true; + 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; + + // Set the default output path + opt_opath = "C:\\temp"; + + // Get the user login name + vpIoTools::getUserName(username); + + // Read the command line options + if (getOptions(argc, argv, opt_ipath, opt_opath, + opt_click_allowed, username, opt_display) == false) { + exit (-1); + } - // Append to the output path string, the login name of the user - std::string odirname = opath + vpIoTools::path("/") + username; + // Get the option values + if (!opt_ipath.empty()) + ipath = opt_ipath; + if (!opt_opath.empty()) + opath = opt_opath; + + // Append to the output path string, the login name of the user + std::string odirname = opath + vpIoTools::path("/") + username; + + // Test if the output path exist. If no try to create it + if (vpIoTools::checkDirectory(odirname) == false) { + try { + // Create the dirname + vpIoTools::makeDirectory(odirname); + } + catch (...) { + usage(argv[0], NULL, ipath, opath, username); + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Cannot create " << odirname << std::endl; + std::cerr << " Check your -o " << opath << " option " << std::endl; + exit(-1); + } + } - // Test if the output path exist. If no try to create it - if (vpIoTools::checkDirectory(odirname) == false) { - try { - // Create the dirname - vpIoTools::makeDirectory(odirname); + // 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 <visp image path=" << ipath << "> " + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; + } } - catch (...) { + + // 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 << " Cannot create " << odirname << std::endl; - std::cerr << " Check your -o " << opath << " option " << std::endl; + std::cerr << " Use -i <visp image path> 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); } - } - // 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 <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; - } - } + // Create a grey level image + vpImage<unsigned char> I ; + vpImagePoint ip, ip1, ip2; - // 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 <visp image path> 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); - } + // Load a grey image from the disk + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); + vpImageIo::read(I, filename) ; - // Create a grey level image - vpImage<unsigned char> I ; - vpImagePoint ip, ip1, ip2; + // For this grey level image, open a GDI display at position 100,100 + // in the screen, and with title "GDI display" + vpDisplayGDI display; - // Load a grey image from the disk - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); - try { - vpImageIo::read(I, filename) ; - } - catch (...) { - return -1; - } + if (opt_display) { + // We open a window using GDI. + // Its size is automatically defined by the image (I) size + display.init(I, 100, 100, "GDI display") ; - // For this grey level image, open a GDI display at position 100,100 - // in the screen, and with title "GDI display" - vpDisplayGDI display; + // Display the image + vpDisplay::display(I) ; - if (opt_display) { - // We open a window using GDI. - // Its size is automatically defined by the image (I) size - display.init(I, 100, 100, "GDI display") ; + // Display in overlay a red cross at position 10,10 in the + // image. The lines are 10 pixels long + ip.set_i( 100 ); + ip.set_j( 10 ); - // Display the image - vpDisplay::display(I) ; + vpDisplay::displayCross(I, ip, 20, vpColor::red) ; - // Display in overlay a red cross at position 10,10 in the - // image. The lines are 10 pixels long - ip.set_i( 100 ); - ip.set_j( 10 ); - - vpDisplay::displayCross(I, ip, 20, vpColor::red) ; + // Display in overlay horizontal red lines + for (unsigned i=0 ; i < I.getHeight() ; i+=20) { + ip1.set_i( i ); + ip1.set_j( 0 ); + ip2.set_i( i ); + ip2.set_j( I.getWidth() ); + vpDisplay::displayLine(I, ip1, ip2, vpColor::red) ; + } - // Display in overlay horizontal red lines - for (unsigned i=0 ; i < I.getHeight() ; i+=20) { - ip1.set_i( i ); - ip1.set_j( 0 ); - ip2.set_i( i ); - ip2.set_j( I.getWidth() ); - vpDisplay::displayLine(I, ip1, ip2, vpColor::red) ; - } + // Display a ligne in the diagonal + ip1.set_i( -10 ); + ip1.set_j( -10 ); + ip2.set_i( I.getHeight() + 10 ); + ip2.set_j( I.getWidth() + 10 ); - // Display a ligne in the diagonal - ip1.set_i( -10 ); - ip1.set_j( -10 ); - ip2.set_i( I.getHeight() + 10 ); - ip2.set_j( I.getWidth() + 10 ); - - vpDisplay::displayLine(I, ip1, ip2, vpColor::red) ; + vpDisplay::displayLine(I, ip1, ip2, vpColor::red) ; - // Display in overlay vertical green dot lines - for (unsigned i=0 ; i < I.getWidth() ; i+=20) { + // Display in overlay vertical green dot lines + for (unsigned i=0 ; i < I.getWidth() ; i+=20) { + ip1.set_i( 0 ); + ip1.set_j( i ); + ip2.set_i( I.getWidth() ); + ip2.set_j( i ); + vpDisplay::displayDotLine(I, ip1, ip2, vpColor::green) ; + } + + // Display a rectangle + ip.set_i( I.getHeight() - 45 ); + ip.set_j( -10 ); + vpDisplay::displayRectangle(I, ip, 60, 80, vpColor::orange) ; + + // Display in overlay a blue arrow ip1.set_i( 0 ); - ip1.set_j( i ); - ip2.set_i( I.getWidth() ); - ip2.set_j( i ); - vpDisplay::displayDotLine(I, ip1, ip2, vpColor::green) ; - } - - // Display a rectangle - ip.set_i( I.getHeight() - 45 ); - ip.set_j( -10 ); - vpDisplay::displayRectangle(I, ip, 60, 80, vpColor::orange) ; - - // Display in overlay a blue arrow - ip1.set_i( 0 ); - ip1.set_j( 0 ); - ip2.set_i( 100 ); - ip2.set_j( 100 ); - vpDisplay::displayArrow(I, ip1, ip2, vpColor::blue) ; - - // Display in overlay some circles. The position of the center is 200, 200 - // the radius is increased by 20 pixels for each circle - - for (unsigned int i=0 ; i < 100 ; i+=20) { - ip.set_i( 80 ); - ip.set_j( 80 ); - vpDisplay::displayCircle(I, ip, 20+i, vpColor::yellow) ; + ip1.set_j( 0 ); + ip2.set_i( 100 ); + ip2.set_j( 100 ); + vpDisplay::displayArrow(I, ip1, ip2, vpColor::blue) ; + + // Display in overlay some circles. The position of the center is 200, 200 + // the radius is increased by 20 pixels for each circle + + for (unsigned int i=0 ; i < 100 ; i+=20) { + ip.set_i( 80 ); + ip.set_j( 80 ); + vpDisplay::displayCircle(I, ip, 20+i, vpColor::yellow) ; + } + + ip.set_i( -10 ); + ip.set_j( 300 ); + vpDisplay::displayCircle(I, ip, 100,vpColor::yellow) ; + + // Display in overlay a yellow string + ip.set_i( 85 ); + ip.set_j( 100 ); + vpDisplay::displayCharString(I, ip, + "ViSP is a marvelous software", + vpColor::yellow) ; + //Flush the display + vpDisplay::flush(I); + + // Create a color image + vpImage<vpRGBa> Ioverlay ; + // Updates the color image with the original loaded image and the overlay + vpDisplay::getImage(I, Ioverlay) ; + + // Write the color image on the disk + filename = odirname + vpIoTools::path("/Klimt_grey.overlay.ppm"); + vpImageIo::write(Ioverlay, filename) ; + + // If click is allowed, wait for a mouse click to close the display + if (opt_click_allowed) { + std::cout << "\nA click to close the windows..." << std::endl; + // Wait for a blocking mouse click + vpDisplay::getClick(I) ; + } + + // Close the display + vpDisplay::close(I); } - ip.set_i( -10 ); - ip.set_j( 300 ); - vpDisplay::displayCircle(I, ip, 100,vpColor::yellow) ; - - // Display in overlay a yellow string - ip.set_i( 85 ); - ip.set_j( 100 ); - vpDisplay::displayCharString(I, ip, - "ViSP is a marvelous software", - vpColor::yellow) ; - //Flush the display - vpDisplay::flush(I); - // Create a color image - vpImage<vpRGBa> Ioverlay ; - // Updates the color image with the original loaded image and the overlay - vpDisplay::getImage(I, Ioverlay) ; - - // Write the color image on the disk - filename = odirname + vpIoTools::path("/Klimt_grey.overlay.ppm"); - vpImageIo::write(Ioverlay, filename) ; - - // If click is allowed, wait for a mouse click to close the display - if (opt_click_allowed) { - std::cout << "\nA click to close the windows..." << std::endl; - // Wait for a blocking mouse click - vpDisplay::getClick(I) ; - } - - // Close the display - vpDisplay::close(I); - } + vpImage<vpRGBa> Irgba ; - // Create a color image - vpImage<vpRGBa> Irgba ; - - // Load a grey image from the disk and convert it to a color image - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); - try { + // Load a grey image from the disk and convert it to a color image + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); vpImageIo::read(Irgba, filename) ; - } - catch (...) { - return -1; - } - // For this color image, open a GDI display at position 100,100 - // in the screen, and with title "GDI color display" - vpDisplayGDI displayRGBa; - - if (opt_display) { - // We open a window using GDI. - // Its size is automatically defined by the image (Irgba) size - displayRGBa.init(Irgba, 100, 100, "GDI color display"); - - // Display the color image - vpDisplay::display(Irgba) ; - vpDisplay::flush(Irgba) ; - - // If click is allowed, wait for a blocking mouse click to display a cross - // at the clicked pixel position - if (opt_click_allowed) { - std::cout << "\nA click to display a cross..." << std::endl; - // Blocking wait for a click. Get the position of the selected pixel - // (i correspond to the row and j to the column coordinates in the image) - vpDisplay::getClick(Irgba, ip); - // Display a red cross on the click pixel position - std::cout << "Cross position: " << ip << std::endl; - vpDisplay::displayCross(Irgba, ip, 15, vpColor::red); - } - else { - ip.set_i( 10 ); - ip.set_j( 20 ); - // Display a red cross at position i, j (i correspond to the row - // and j to the column coordinates in the image) - std::cout << "Cross position: " << ip << std::endl; - vpDisplay::displayCross(Irgba, ip, 15, vpColor::red); - - } - // Flush the display. Sometimes the display content is - // bufferized. Force to display the content that has been bufferized. - vpDisplay::flush(Irgba); - - // If click is allowed, wait for a blocking mouse click to exit. - if (opt_click_allowed) { - std::cout << "\nA click to exit the program..." << std::endl; - vpDisplay::getClick(Irgba) ; - std::cout << "Bye" << std::endl; + // For this color image, open a GDI display at position 100,100 + // in the screen, and with title "GDI color display" + vpDisplayGDI displayRGBa; + + if (opt_display) { + // We open a window using GDI. + // Its size is automatically defined by the image (Irgba) size + displayRGBa.init(Irgba, 100, 100, "GDI color display"); + + // Display the color image + vpDisplay::display(Irgba) ; + vpDisplay::flush(Irgba) ; + + // If click is allowed, wait for a blocking mouse click to display a cross + // at the clicked pixel position + if (opt_click_allowed) { + std::cout << "\nA click to display a cross..." << std::endl; + // Blocking wait for a click. Get the position of the selected pixel + // (i correspond to the row and j to the column coordinates in the image) + vpDisplay::getClick(Irgba, ip); + // Display a red cross on the click pixel position + std::cout << "Cross position: " << ip << std::endl; + vpDisplay::displayCross(Irgba, ip, 15, vpColor::red); + } + else { + ip.set_i( 10 ); + ip.set_j( 20 ); + // Display a red cross at position i, j (i correspond to the row + // and j to the column coordinates in the image) + std::cout << "Cross position: " << ip << std::endl; + vpDisplay::displayCross(Irgba, ip, 15, vpColor::red); + + } + // Flush the display. Sometimes the display content is + // bufferized. Force to display the content that has been bufferized. + vpDisplay::flush(Irgba); + + // If click is allowed, wait for a blocking mouse click to exit. + if (opt_click_allowed) { + std::cout << "\nA click to exit the program..." << std::endl; + vpDisplay::getClick(Irgba) ; + std::cout << "Bye" << std::endl; + } } } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } #else int diff --git a/example/device/display/displayGTK.cpp b/example/device/display/displayGTK.cpp index 83a13af1a0379ec778644a95c906389a8d77351b..db2208be67c2b323d50de3ab06ae46acb4920f5a 100644 --- a/example/device/display/displayGTK.cpp +++ b/example/device/display/displayGTK.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: displayGTK.cpp 4294 2013-07-01 16:05:49Z fspindle $ + * $Id: displayGTK.cpp 4604 2014-01-21 14:15:23Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -183,250 +183,252 @@ bool getOptions(int argc, const char **argv, 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; - bool opt_click_allowed = true; - 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; - - // Set the default output path -#ifdef UNIX - opt_opath = "/tmp"; -#elif WIN32 - opt_opath = "C:\\temp"; + try { + std::string env_ipath; + std::string opt_ipath; + std::string opt_opath; + std::string ipath; + std::string opath; + std::string filename; + std::string username; + bool opt_click_allowed = true; + 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; + + // Set the default output path +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX + opt_opath = "/tmp"; +#elif defined(_WIN32) + opt_opath = "C:\\temp"; #endif - // Get the user login name - vpIoTools::getUserName(username); - - // Read the command line options - if (getOptions(argc, argv, opt_ipath, opt_opath, - opt_click_allowed, username, opt_display) == false) { - exit (-1); - } + // Get the user login name + vpIoTools::getUserName(username); - // Get the option values - if (!opt_ipath.empty()) - ipath = opt_ipath; - if (!opt_opath.empty()) - opath = opt_opath; + // Read the command line options + if (getOptions(argc, argv, opt_ipath, opt_opath, + opt_click_allowed, username, opt_display) == false) { + exit (-1); + } - // Append to the output path string, the login name of the user - std::string odirname = opath + vpIoTools::path("/") + username; + // Get the option values + if (!opt_ipath.empty()) + ipath = opt_ipath; + if (!opt_opath.empty()) + opath = opt_opath; + + // Append to the output path string, the login name of the user + std::string odirname = opath + vpIoTools::path("/") + username; + + // Test if the output path exist. If no try to create it + if (vpIoTools::checkDirectory(odirname) == false) { + try { + // Create the dirname + vpIoTools::makeDirectory(odirname); + } + catch (...) { + usage(argv[0], NULL, ipath, opath, username); + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Cannot create " << odirname << std::endl; + std::cerr << " Check your -o " << opath << " option " << std::endl; + exit(-1); + } + } - // Test if the output path exist. If no try to create it - if (vpIoTools::checkDirectory(odirname) == false) { - try { - // Create the dirname - vpIoTools::makeDirectory(odirname); + // 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 <visp image path=" << ipath << "> " + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; + } } - catch (...) { + + // 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 << " Cannot create " << odirname << std::endl; - std::cerr << " Check your -o " << opath << " option " << std::endl; + std::cerr << " Use -i <visp image path> 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); } - } - // 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 <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; - } - } + // Create a grey level image + vpImage<unsigned char> I ; + vpImagePoint ip, ip1, ip2; - // 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 <visp image path> 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); - } + // Load a grey image from the disk + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.png"); + vpImageIo::read(I, filename) ; - // Create a grey level image - vpImage<unsigned char> I ; - vpImagePoint ip, ip1, ip2; + // Create a display using GTK + vpDisplayGTK display; - // Load a grey image from the disk - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.png"); - try { - vpImageIo::read(I, filename) ; - } - catch (...) { - return -1; - } + if (opt_display) { + // For this grey level image, open a GTK display at position 100,100 + // in the screen, and with title "GTK display" + display.init(I, 100, 100, "GTK display") ; - // Create a display using GTK - vpDisplayGTK display; + // Display the image + vpDisplay::display(I) ; - if (opt_display) { - // For this grey level image, open a GTK display at position 100,100 - // in the screen, and with title "GTK display" - display.init(I, 100, 100, "GTK display") ; + // Display in overlay a red cross at position 10,10 in the + // image. The lines are 10 pixels long + ip.set_i( 100 ); + ip.set_j( 10 ); - // Display the image - vpDisplay::display(I) ; + vpDisplay::displayCross(I, ip, 20, vpColor::red) ; - // Display in overlay a red cross at position 10,10 in the - // image. The lines are 10 pixels long - ip.set_i( 100 ); - ip.set_j( 10 ); - - vpDisplay::displayCross(I, ip, 20, vpColor::red) ; + // Display in overlay horizontal red lines + for (unsigned i=0 ; i < I.getHeight() ; i+=20) { + ip1.set_i( i ); + ip1.set_j( 0 ); + ip2.set_i( i ); + ip2.set_j( I.getWidth() ); + vpDisplay::displayLine(I, ip1, ip2, vpColor::red) ; + } - // Display in overlay horizontal red lines - for (unsigned i=0 ; i < I.getHeight() ; i+=20) { - ip1.set_i( i ); - ip1.set_j( 0 ); - ip2.set_i( i ); - ip2.set_j( I.getWidth() ); - vpDisplay::displayLine(I, ip1, ip2, vpColor::red) ; - } + // Display a ligne in the diagonal + ip1.set_i( -10 ); + ip1.set_j( -10 ); + ip2.set_i( I.getHeight() + 10 ); + ip2.set_j( I.getWidth() + 10 ); - // Display a ligne in the diagonal - ip1.set_i( -10 ); - ip1.set_j( -10 ); - ip2.set_i( I.getHeight() + 10 ); - ip2.set_j( I.getWidth() + 10 ); - - vpDisplay::displayLine(I, ip1, ip2, vpColor::red) ; + vpDisplay::displayLine(I, ip1, ip2, vpColor::red) ; - // Display in overlay vertical green dot lines - for (unsigned i=0 ; i < I.getWidth() ; i+=20) { + // Display in overlay vertical green dot lines + for (unsigned i=0 ; i < I.getWidth() ; i+=20) { + ip1.set_i( 0 ); + ip1.set_j( i ); + ip2.set_i( I.getWidth() ); + ip2.set_j( i ); + vpDisplay::displayDotLine(I, ip1, ip2, vpColor::green) ; + } + + // Display a rectangle + ip.set_i( I.getHeight() - 45 ); + ip.set_j( -10 ); + vpDisplay::displayRectangle(I, ip, 60, 80, vpColor::orange) ; + + // Display in overlay a blue arrow ip1.set_i( 0 ); - ip1.set_j( i ); - ip2.set_i( I.getWidth() ); - ip2.set_j( i ); - vpDisplay::displayDotLine(I, ip1, ip2, vpColor::green) ; - } - - // Display a rectangle - ip.set_i( I.getHeight() - 45 ); - ip.set_j( -10 ); - vpDisplay::displayRectangle(I, ip, 60, 80, vpColor::orange) ; - - // Display in overlay a blue arrow - ip1.set_i( 0 ); - ip1.set_j( 0 ); - ip2.set_i( 100 ); - ip2.set_j( 100 ); - vpDisplay::displayArrow(I, ip1, ip2, vpColor::blue) ; - - // Display in overlay some circles. The position of the center is 200, 200 - // the radius is increased by 20 pixels for each circle - - for (unsigned int i=0 ; i < 100 ; i+=20) { - ip.set_i( 80 ); - ip.set_j( 80 ); - vpDisplay::displayCircle(I, ip, 20+i, vpColor::yellow) ; + ip1.set_j( 0 ); + ip2.set_i( 100 ); + ip2.set_j( 100 ); + vpDisplay::displayArrow(I, ip1, ip2, vpColor::blue) ; + + // Display in overlay some circles. The position of the center is 200, 200 + // the radius is increased by 20 pixels for each circle + + for (unsigned int i=0 ; i < 100 ; i+=20) { + ip.set_i( 80 ); + ip.set_j( 80 ); + vpDisplay::displayCircle(I, ip, 20+i, vpColor::yellow) ; + } + + ip.set_i( -10 ); + ip.set_j( 300 ); + vpDisplay::displayCircle(I, ip, 100,vpColor::yellow) ; + + // Display in overlay a yellow string + ip.set_i( 85 ); + ip.set_j( 100 ); + //vpDisplay::setFont(I, "-*-courier 10 pitch-medium-r-normal-*-16-*-*-*-*-*-*-*"); + vpDisplay::displayCharString(I, ip, + "ViSP is a marvelous software", + vpColor::yellow) ; + //Flush the display + vpDisplay::flush(I); + + // Create a color image + vpImage<vpRGBa> Ioverlay ; + // Updates the color image with the original loaded image and the overlay + vpDisplay::getImage(I, Ioverlay) ; + + // Write the color image on the disk + filename = odirname + vpIoTools::path("/Klimt_grey.overlay.ppm"); + vpImageIo::write(Ioverlay, filename) ; + + // If click is allowed, wait for a mouse click to close the display + if (opt_click_allowed) { + std::cout << "\nA click to close the windows..." << std::endl; + // Wait for a blocking mouse click + vpDisplay::getClick(I) ; + } + + // Close the display + vpDisplay::close(I); } - ip.set_i( -10 ); - ip.set_j( 300 ); - vpDisplay::displayCircle(I, ip, 100,vpColor::yellow) ; - - // Display in overlay a yellow string - ip.set_i( 85 ); - ip.set_j( 100 ); - vpDisplay::displayCharString(I, ip, - "ViSP is a marvelous software", - vpColor::yellow) ; - //Flush the display - vpDisplay::flush(I); - // Create a color image - vpImage<vpRGBa> Ioverlay ; - // Updates the color image with the original loaded image and the overlay - vpDisplay::getImage(I, Ioverlay) ; - - // Write the color image on the disk - filename = odirname + vpIoTools::path("/Klimt_grey.overlay.ppm"); - vpImageIo::write(Ioverlay, filename) ; - - // If click is allowed, wait for a mouse click to close the display - if (opt_click_allowed) { - std::cout << "\nA click to close the windows..." << std::endl; - // Wait for a blocking mouse click - vpDisplay::getClick(I) ; + vpImage<vpRGBa> Irgba ; + + // Load a grey image from the disk and convert it to a color image + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); + vpImageIo::read(Irgba, filename) ; + + // Create a new GTK display + vpDisplayGTK displayRGBa; + + if (opt_display) { + // For this color image, open a GTK display at position 100,100 + // in the screen, and with title "GTK color display" + displayRGBa.init(Irgba, 100, 100, "GTK color display"); + + // Display the color image + vpDisplay::display(Irgba) ; + vpDisplay::flush(Irgba) ; + + // If click is allowed, wait for a blocking mouse click to display a cross + // at the clicked pixel position + if (opt_click_allowed) { + std::cout << "\nA click to display a cross..." << std::endl; + // Blocking wait for a click. Get the position of the selected pixel + // (i correspond to the row and j to the column coordinates in the image) + vpDisplay::getClick(Irgba, ip); + // Display a red cross on the click pixel position + std::cout << "Cross position: " << ip << std::endl; + vpDisplay::displayCross(Irgba, ip, 15, vpColor::red); + } + else { + ip.set_i( 10 ); + ip.set_j( 20 ); + // Display a red cross at position i, j (i correspond to the row + // and j to the column coordinates in the image) + std::cout << "Cross position: " << ip << std::endl; + vpDisplay::displayCross(Irgba, ip, 15, vpColor::red); + + } + // Flush the display. Sometimes the display content is + // bufferized. Force to display the content that has been bufferized. + vpDisplay::flush(Irgba); + + // If click is allowed, wait for a blocking mouse click to exit. + if (opt_click_allowed) { + std::cout << "\nA click to exit the program..." << std::endl; + vpDisplay::getClick(Irgba) ; + std::cout << "Bye" << std::endl; + } } - - // Close the display - vpDisplay::close(I); } - - // Create a color image - vpImage<vpRGBa> Irgba ; - - // Load a grey image from the disk and convert it to a color image - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); - vpImageIo::read(Irgba, filename) ; - - // Create a new GTK display - vpDisplayGTK displayRGBa; - - if (opt_display) { - // For this color image, open a GTK display at position 100,100 - // in the screen, and with title "GTK color display" - displayRGBa.init(Irgba, 100, 100, "GTK color display"); - - // Display the color image - vpDisplay::display(Irgba) ; - vpDisplay::flush(Irgba) ; - - // If click is allowed, wait for a blocking mouse click to display a cross - // at the clicked pixel position - if (opt_click_allowed) { - std::cout << "\nA click to display a cross..." << std::endl; - // Blocking wait for a click. Get the position of the selected pixel - // (i correspond to the row and j to the column coordinates in the image) - vpDisplay::getClick(Irgba, ip); - // Display a red cross on the click pixel position - std::cout << "Cross position: " << ip << std::endl; - vpDisplay::displayCross(Irgba, ip, 15, vpColor::red); - } - else { - ip.set_i( 10 ); - ip.set_j( 20 ); - // Display a red cross at position i, j (i correspond to the row - // and j to the column coordinates in the image) - std::cout << "Cross position: " << ip << std::endl; - vpDisplay::displayCross(Irgba, ip, 15, vpColor::red); - - } - // Flush the display. Sometimes the display content is - // bufferized. Force to display the content that has been bufferized. - vpDisplay::flush(Irgba); - - // If click is allowed, wait for a blocking mouse click to exit. - if (opt_click_allowed) { - std::cout << "\nA click to exit the program..." << std::endl; - vpDisplay::getClick(Irgba) ; - std::cout << "Bye" << std::endl; - } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } } #else @@ -437,4 +439,3 @@ main() } #endif - diff --git a/example/device/display/displayOpenCV.cpp b/example/device/display/displayOpenCV.cpp index 4512285a9b096126d94ad49cba6bd383fad23aa4..fcc27e3434057e0d451e95318b360e9f40106fcf 100644 --- a/example/device/display/displayOpenCV.cpp +++ b/example/device/display/displayOpenCV.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: displayOpenCV.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: displayOpenCV.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -72,6 +72,10 @@ // List of allowed command line options #define GETOPTARGS "cdi:o:p:h" +void usage(const char *name, const char *badparam, std::string ipath, std::string opath, std::string user); +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &opath, + bool &click_allowed, std::string user, bool &display); + /*! Print the program options. @@ -83,8 +87,7 @@ \param user : Username. */ -void usage(const char *name, const char *badparam, std::string ipath, - std::string opath, std::string user) +void usage(const char *name, const char *badparam, std::string ipath, std::string opath, std::string user) { fprintf(stdout, "\n\ Read an image on the disk, display it using OpenCV, display some\n\ @@ -150,23 +153,22 @@ OPTIONS: Default\n\ \return false if the program has to be stopped, true otherwise. */ -bool getOptions(int argc, const char **argv, - std::string &ipath, std::string &opath, bool &click_allowed, - std::string user, bool &display) +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &opath, + bool &click_allowed, std::string user, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; case 'd': display = false; break; - case 'i': ipath = optarg; break; - case 'o': opath = optarg; break; + 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; + usage(argv[0], optarg_, ipath, opath, user); return false; break; } } @@ -174,7 +176,7 @@ bool getOptions(int argc, const char **argv, // 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; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -184,257 +186,253 @@ bool getOptions(int argc, const char **argv, 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; - bool opt_click_allowed = true; - 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; - // std::cout << "env_ipath: " << env_ipath << std::endl; - - // Set the default input path - if (! env_ipath.empty()) - ipath = env_ipath; - - // Set the default output path -#ifdef UNIX - opt_opath = "/tmp"; -#elif WIN32 - opt_opath = "C:\\temp"; + try { + std::string env_ipath; + std::string opt_ipath; + std::string opt_opath; + std::string ipath; + std::string opath; + std::string filename; + std::string username; + bool opt_click_allowed = true; + 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; + // std::cout << "env_ipath: " << env_ipath << std::endl; + + // Set the default input path + if (! env_ipath.empty()) + ipath = env_ipath; + + // Set the default output path +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX + opt_opath = "/tmp"; +#elif defined(_WIN32) + opt_opath = "C:\\temp"; #endif - // Get the user login name - vpIoTools::getUserName(username); + // Get the user login name + vpIoTools::getUserName(username); - // Read the command line options - if (getOptions(argc, argv, opt_ipath, opt_opath, - opt_click_allowed, username, opt_display) == false) { - exit (-1); - } - - // Get the option values - if (!opt_ipath.empty()) - ipath = opt_ipath; - if (!opt_opath.empty()) - opath = opt_opath; + // Read the command line options + if (getOptions(argc, argv, opt_ipath, opt_opath, + opt_click_allowed, username, opt_display) == false) { + exit (-1); + } - // Append to the output path string, the login name of the user - std::string odirname = opath + vpIoTools::path("/") + username; + // Get the option values + if (!opt_ipath.empty()) + ipath = opt_ipath; + if (!opt_opath.empty()) + opath = opt_opath; + + // Append to the output path string, the login name of the user + std::string odirname = opath + vpIoTools::path("/") + username; + + // Test if the output path exist. If no try to create it + if (vpIoTools::checkDirectory(odirname) == false) { + try { + // Create the dirname + vpIoTools::makeDirectory(odirname); + } + catch (...) { + usage(argv[0], NULL, ipath, opath, username); + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Cannot create " << odirname << std::endl; + std::cerr << " Check your -o " << opath << " option " << std::endl; + exit(-1); + } + } - // Test if the output path exist. If no try to create it - if (vpIoTools::checkDirectory(odirname) == false) { - try { - // Create the dirname - vpIoTools::makeDirectory(odirname); + // 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 <visp image path=" << ipath << "> " + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; + } } - catch (...) { + + // 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 << " Cannot create " << odirname << std::endl; - std::cerr << " Check your -o " << opath << " option " << std::endl; + std::cerr << " Use -i <visp image path> 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); } - } - // 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 <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; - } - } + // Create a grey level image + vpImage<unsigned char> I ; + vpImagePoint ip, ip1, ip2; - // 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 <visp image path> 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); - } + // Load a grey image from the disk + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); + vpImageIo::read(I, filename) ; - // Create a grey level image - vpImage<unsigned char> I ; - vpImagePoint ip, ip1, ip2; + // Create a display using OpenCV + vpDisplayOpenCV display; - // Load a grey image from the disk - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); - try { - vpImageIo::read(I, filename) ; - } - catch (...) { - return -1; - } + if (opt_display) { + // For this grey level image, open a X11 display at position 100,100 + // in the screen, and with title "X11 display" + display.init(I, 100, 100, "OpenCV display") ; - // Create a display using OpenCV - vpDisplayOpenCV display; + // Display the image + vpDisplay::display(I) ; - if (opt_display) { - // For this grey level image, open a X11 display at position 100,100 - // in the screen, and with title "X11 display" - display.init(I, 100, 100, "OpenCV display") ; + // Display in overlay a red cross at position 10,10 in the + // image. The lines are 10 pixels long + ip.set_i( 100 ); + ip.set_j( 10 ); - // Display the image - vpDisplay::display(I) ; + vpDisplay::displayCross(I, ip, 20, vpColor::red) ; - // Display in overlay a red cross at position 10,10 in the - // image. The lines are 10 pixels long - ip.set_i( 100 ); - ip.set_j( 10 ); - - vpDisplay::displayCross(I, ip, 20, vpColor::red) ; + // Display in overlay horizontal red lines + for (unsigned i=0 ; i < I.getHeight() ; i+=20) { + ip1.set_i( i ); + ip1.set_j( 0 ); + ip2.set_i( i ); + ip2.set_j( I.getWidth() ); + vpDisplay::displayLine(I, ip1, ip2, vpColor::red) ; + } - // Display in overlay horizontal red lines - for (unsigned i=0 ; i < I.getHeight() ; i+=20) { - ip1.set_i( i ); - ip1.set_j( 0 ); - ip2.set_i( i ); - ip2.set_j( I.getWidth() ); - vpDisplay::displayLine(I, ip1, ip2, vpColor::red) ; - } + // Display a ligne in the diagonal + ip1.set_i( -10 ); + ip1.set_j( -10 ); + ip2.set_i( I.getHeight() + 10 ); + ip2.set_j( I.getWidth() + 10 ); - // Display a ligne in the diagonal - ip1.set_i( -10 ); - ip1.set_j( -10 ); - ip2.set_i( I.getHeight() + 10 ); - ip2.set_j( I.getWidth() + 10 ); - - vpDisplay::displayLine(I, ip1, ip2, vpColor::red) ; + vpDisplay::displayLine(I, ip1, ip2, vpColor::red) ; - // Display in overlay vertical green dot lines - for (unsigned i=0 ; i < I.getWidth() ; i+=20) { + // Display in overlay vertical green dot lines + for (unsigned i=0 ; i < I.getWidth() ; i+=20) { + ip1.set_i( 0 ); + ip1.set_j( i ); + ip2.set_i( I.getWidth() ); + ip2.set_j( i ); + vpDisplay::displayDotLine(I, ip1, ip2, vpColor::green) ; + } + + // Display a rectangle + ip.set_i( I.getHeight() - 45 ); + ip.set_j( -10 ); + vpDisplay::displayRectangle(I, ip, 60, 80, vpColor::orange) ; + + // Display in overlay a blue arrow ip1.set_i( 0 ); - ip1.set_j( i ); - ip2.set_i( I.getWidth() ); - ip2.set_j( i ); - vpDisplay::displayDotLine(I, ip1, ip2, vpColor::green) ; - } - - // Display a rectangle - ip.set_i( I.getHeight() - 45 ); - ip.set_j( -10 ); - vpDisplay::displayRectangle(I, ip, 60, 80, vpColor::orange) ; - - // Display in overlay a blue arrow - ip1.set_i( 0 ); - ip1.set_j( 0 ); - ip2.set_i( 100 ); - ip2.set_j( 100 ); - vpDisplay::displayArrow(I, ip1, ip2, vpColor::blue) ; - - // Display in overlay some circles. The position of the center is 200, 200 - // the radius is increased by 20 pixels for each circle - - for (unsigned int i=0 ; i < 100 ; i+=20) { - ip.set_i( 80 ); - ip.set_j( 80 ); - vpDisplay::displayCircle(I, ip, 20+i, vpColor::yellow) ; + ip1.set_j( 0 ); + ip2.set_i( 100 ); + ip2.set_j( 100 ); + vpDisplay::displayArrow(I, ip1, ip2, vpColor::blue) ; + + // Display in overlay some circles. The position of the center is 200, 200 + // the radius is increased by 20 pixels for each circle + + for (unsigned int i=0 ; i < 100 ; i+=20) { + ip.set_i( 80 ); + ip.set_j( 80 ); + vpDisplay::displayCircle(I, ip, 20+i, vpColor::yellow) ; + } + + ip.set_i( -10 ); + ip.set_j( 300 ); + vpDisplay::displayCircle(I, ip, 100,vpColor::yellow) ; + + // Display in overlay a yellow string + ip.set_i( 85 ); + ip.set_j( 100 ); + vpDisplay::displayCharString(I, ip, + "ViSP is a marvelous software", + vpColor::yellow) ; + //Flush the display + vpDisplay::flush(I); + + // Create a color image + vpImage<vpRGBa> Ioverlay ; + // Updates the color image with the original loaded image and the overlay + vpDisplay::getImage(I, Ioverlay) ; + + // Write the color image on the disk + filename = odirname + vpIoTools::path("/Klimt_grey.overlay.ppm"); + vpImageIo::write(Ioverlay, filename) ; + + // If click is allowed, wait for a mouse click to close the display + if (opt_click_allowed) { + std::cout << "\nA click to close the windows..." << std::endl; + // Wait for a blocking mouse click + vpDisplay::getClick(I) ; + } + + // Close the display + vpDisplay::close(I); } - ip.set_i( -10 ); - ip.set_j( 300 ); - vpDisplay::displayCircle(I, ip, 100,vpColor::yellow) ; - - // Display in overlay a yellow string - ip.set_i( 85 ); - ip.set_j( 100 ); - vpDisplay::displayCharString(I, ip, - "ViSP is a marvelous software", - vpColor::yellow) ; - //Flush the display - vpDisplay::flush(I); - // Create a color image - vpImage<vpRGBa> Ioverlay ; - // Updates the color image with the original loaded image and the overlay - vpDisplay::getImage(I, Ioverlay) ; - - // Write the color image on the disk - filename = odirname + vpIoTools::path("/Klimt_grey.overlay.ppm"); - vpImageIo::write(Ioverlay, filename) ; - - // If click is allowed, wait for a mouse click to close the display - if (opt_click_allowed) { - std::cout << "\nA click to close the windows..." << std::endl; - // Wait for a blocking mouse click - vpDisplay::getClick(I) ; - } - - // Close the display - vpDisplay::close(I); - } + vpImage<vpRGBa> Irgba ; - // Create a color image - vpImage<vpRGBa> Irgba ; - - // Load a grey image from the disk and convert it to a color image - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); - try { + // Load a grey image from the disk and convert it to a color image + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); vpImageIo::read(Irgba, filename) ; - } - catch (...) { - return -1; - } - // Create a new display - vpDisplayOpenCV displayRGBa; - - if (opt_display) { - // For this color image, open a display at position 100,100 - // in the screen, and with title "OpenCV color display" - displayRGBa.init(Irgba, 100, 100, "OpenCV color display"); - - // Display the color image - vpDisplay::display(Irgba) ; - vpDisplay::flush(Irgba) ; - - // If click is allowed, wait for a blocking mouse click to display a cross - // at the clicked pixel position - if (opt_click_allowed) { - std::cout << "\nA click to display a cross..." << std::endl; - // Blocking wait for a click. Get the position of the selected pixel - // (i correspond to the row and j to the column coordinates in the image) - vpDisplay::getClick(Irgba, ip); - // Display a red cross on the click pixel position - std::cout << "Cross position: " << ip << std::endl; - vpDisplay::displayCross(Irgba, ip, 15, vpColor::red); - } - else { - ip.set_i( 10 ); - ip.set_j( 20 ); - // Display a red cross at position i, j (i correspond to the row - // and j to the column coordinates in the image) - std::cout << "Cross position: " << ip << std::endl; - vpDisplay::displayCross(Irgba, ip, 15, vpColor::red); - - } - // Flush the display. Sometimes the display content is - // bufferized. Force to display the content that has been bufferized. - vpDisplay::flush(Irgba); - - // If click is allowed, wait for a blocking mouse click to exit. - if (opt_click_allowed) { - std::cout << "\nA click to exit the program..." << std::endl; - vpDisplay::getClick(Irgba) ; - std::cout << "Bye" << std::endl; + // Create a new display + vpDisplayOpenCV displayRGBa; + + if (opt_display) { + // For this color image, open a display at position 100,100 + // in the screen, and with title "OpenCV color display" + displayRGBa.init(Irgba, 100, 100, "OpenCV color display"); + + // Display the color image + vpDisplay::display(Irgba) ; + vpDisplay::flush(Irgba) ; + + // If click is allowed, wait for a blocking mouse click to display a cross + // at the clicked pixel position + if (opt_click_allowed) { + std::cout << "\nA click to display a cross..." << std::endl; + // Blocking wait for a click. Get the position of the selected pixel + // (i correspond to the row and j to the column coordinates in the image) + vpDisplay::getClick(Irgba, ip); + // Display a red cross on the click pixel position + std::cout << "Cross position: " << ip << std::endl; + vpDisplay::displayCross(Irgba, ip, 15, vpColor::red); + } + else { + ip.set_i( 10 ); + ip.set_j( 20 ); + // Display a red cross at position i, j (i correspond to the row + // and j to the column coordinates in the image) + std::cout << "Cross position: " << ip << std::endl; + vpDisplay::displayCross(Irgba, ip, 15, vpColor::red); + + } + // Flush the display. Sometimes the display content is + // bufferized. Force to display the content that has been bufferized. + vpDisplay::flush(Irgba); + + // If click is allowed, wait for a blocking mouse click to exit. + if (opt_click_allowed) { + std::cout << "\nA click to exit the program..." << std::endl; + vpDisplay::getClick(Irgba) ; + std::cout << "Bye" << std::endl; + } } } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } #else int diff --git a/example/device/display/displaySequence.cpp b/example/device/display/displaySequence.cpp index 9a5057a41cbfa06835112181ec065a2b3c2758e2..525332edc106e7b7fd9d93c5c5e127a6ef78ffaf 100644 --- a/example/device/display/displaySequence.cpp +++ b/example/device/display/displaySequence.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: displaySequence.cpp 4294 2013-07-01 16:05:49Z fspindle $ + * $Id: displaySequence.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -84,6 +84,11 @@ // List of allowed command line options #define GETOPTARGS "di:p:hf:n:s:w" +void usage(const char *name, const char *badparam, std::string ipath, std::string ppath, + unsigned first, unsigned nimages, unsigned step); +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &ppath, + unsigned &first, unsigned &nimages, unsigned &step, bool &display, bool &wait); + /*! Print the program options. @@ -98,7 +103,7 @@ */ void usage(const char *name, const char *badparam, std::string ipath, std::string ppath, - unsigned first, unsigned nimages, unsigned step) + unsigned first, unsigned nimages, unsigned step) { fprintf(stdout, "\n\ Read an image sequence from the disk and display it.\n\ @@ -180,26 +185,25 @@ SYNOPSIS\n\ */ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &ppath, - unsigned &first, unsigned &nimages, unsigned &step, - bool &display, bool &wait) + unsigned &first, unsigned &nimages, unsigned &step, bool &display, bool &wait) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'd': display = false; break; - case 'i': ipath = optarg; break; - case 'p': ppath = optarg; break; - case 'f': first = (unsigned) atoi(optarg); break; - case 'n': nimages = (unsigned) atoi(optarg); break; - case 's': step = (unsigned) atoi(optarg); break; + case 'i': ipath = optarg_; break; + case 'p': ppath = optarg_; break; + case 'f': first = (unsigned) atoi(optarg_); break; + case 'n': nimages = (unsigned) atoi(optarg_); break; + case 's': step = (unsigned) atoi(optarg_); break; case 'w': wait = true; break; case 'h': usage(argv[0], NULL, ipath, ppath, first, nimages, step); return false; break; default: - usage(argv[0], optarg, ipath, ppath, first, nimages, step); + usage(argv[0], optarg_, ipath, ppath, first, nimages, step); return false; break; } } @@ -208,7 +212,7 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &pp // standalone param or error usage(argv[0], NULL, ipath, ppath, first, nimages, step); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -218,140 +222,141 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &pp 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; - unsigned opt_first = 0; - unsigned opt_nimages = 80; - unsigned opt_step = 1; - bool opt_display = true; - bool opt_wait = false; - - // 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_first, opt_nimages, - opt_step, opt_display, opt_wait) == false) { - exit (-1); - } + try { + std::string env_ipath; + std::string opt_ipath; + std::string ipath; + std::string opt_ppath; + std::string dirname; + std::string filename; + unsigned opt_first = 0; + unsigned opt_nimages = 80; + unsigned opt_step = 1; + bool opt_display = true; + bool opt_wait = false; + + // 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_first, opt_nimages, + opt_step, opt_display, opt_wait) == false) { + exit (-1); + } - if ( ! opt_display ) - opt_wait = false; // turn off the waiting - - // 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 <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + if ( ! opt_display ) + opt_wait = false; // turn off the waiting + + // 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 <visp image path=" << ipath << "> " + << " 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, opt_first, opt_nimages, opt_step); - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Use -i <visp image path> 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 <personal image path> option if you want to "<<std::endl - << " use personal images." << std::endl - << std::endl; - - exit(-1); - } + // Test if an input path is set + if (opt_ipath.empty() && env_ipath.empty() && opt_ppath.empty() ){ + usage(argv[0], NULL, ipath, opt_ppath, opt_first, opt_nimages, opt_step); + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Use -i <visp image path> 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 <personal image path> option if you want to "<<std::endl + << " use personal images." << std::endl + << std::endl; - // 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<unsigned char> I ; + exit(-1); + } - unsigned iter = opt_first; - std::ostringstream s; - char cfilename[FILENAME_MAX]; + // 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<unsigned char> I ; - if (opt_ppath.empty()){ + unsigned iter = opt_first; + std::ostringstream s; + char cfilename[FILENAME_MAX]; + if (opt_ppath.empty()){ - // Warning : - // the image sequence is not provided with the ViSP package - // therefore the program will return you an error : - // !! vpImageIoPnm.cpp: readPGM(#210) :couldn't read file - // ViSP-images/cube/image.0001.pgm - // !! vpDotExample.cpp: main(#95) :Error while reading the image - // terminate called after throwing an instance of 'vpImageException' - // - // The sequence is available on the visp www site - // http://www.irisa.fr/lagadic/visp/visp.html - // in the download section. It is named "ViSP-images.tar.gz" - // Set the path location of the image sequence - dirname = ipath + vpIoTools::path("/ViSP-images/cube/"); + // Warning : + // the image sequence is not provided with the ViSP package + // therefore the program will return you an error : + // !! vpImageIoPnm.cpp: readPGM(#210) :couldn't read file + // ViSP-images/cube/image.0001.pgm + // !! vpDotExample.cpp: main(#95) :Error while reading the image + // terminate called after throwing an instance of 'vpImageException' + // + // The sequence is available on the visp www site + // http://www.irisa.fr/lagadic/visp/visp.html + // in the download section. It is named "ViSP-images.tar.gz" - // Build the name of the image file + // Set the path location of the image sequence + dirname = ipath + vpIoTools::path("/ViSP-images/cube/"); - s.setf(std::ios::right, std::ios::adjustfield); - s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; - filename = dirname + s.str(); - } - else { + // Build the name of the image file - sprintf(cfilename,opt_ppath.c_str(), iter) ; - filename = cfilename; - } - // 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{ - vpImageIo::read(I, filename) ; - } - catch(...) - { - // an exception is throwned if an exception from readPGM has been catched - // 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 your -p " << opt_ppath << " option " <<std::endl - << " or VISP_INPUT_IMAGE_PATH environment variable" - << std::endl; - exit(-1); - } + s.setf(std::ios::right, std::ios::adjustfield); + s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; + filename = dirname + s.str(); + } + else { + + sprintf(cfilename,opt_ppath.c_str(), iter) ; + filename = cfilename; + } + // 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{ + vpImageIo::read(I, filename) ; + } + catch(...) + { + // an exception is throwned if an exception from readPGM has been catched + // 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 your -p " << opt_ppath << " option " <<std::endl + << " or VISP_INPUT_IMAGE_PATH environment variable" + << std::endl; + exit(-1); + } #if defined VISP_HAVE_GTK - vpDisplayGTK display; + vpDisplayGTK display; #elif defined VISP_HAVE_X11 - vpDisplayX display; + vpDisplayX display; #elif defined VISP_HAVE_GDI - vpDisplayGDI display; + vpDisplayGDI display; #endif - if (opt_display) { - try { + if (opt_display) { + // We open a window using either X11 or GTK or GDI. // Its size is automatically defined by the image (I) size display.init(I, 100, 100,"Display...") ; @@ -364,17 +369,11 @@ main(int argc, const char ** argv) vpDisplay::display(I) ; vpDisplay::flush(I) ; } - catch(...) { - vpERROR_TRACE("Error while displaying the image") ; - exit(-1); - } - } - // double tms_1 = vpTime::measureTimeMs() ; - unsigned niter=0 ; - // this is the loop over the image sequence - while (iter < opt_first + opt_nimages*opt_step) { - try { + // double tms_1 = vpTime::measureTimeMs() ; + unsigned niter=0 ; + // this is the loop over the image sequence + while (iter < opt_first + opt_nimages*opt_step) { double tms = vpTime::measureTimeMs() ; // set the new image name @@ -409,16 +408,18 @@ main(int argc, const char ** argv) vpTime::wait(tms, 40) ; } niter++ ; + + iter += opt_step ; } - catch(...) { - exit(-1) ; - } - iter += opt_step ; + // double tms_2 = vpTime::measureTimeMs() ; + // double tms_total = tms_2 - tms_1 ; + // std::cout << "Total Time : "<< tms_total<<std::endl; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - // double tms_2 = vpTime::measureTimeMs() ; - // double tms_total = tms_2 - tms_1 ; - // std::cout << "Total Time : "<< tms_total<<std::endl; - } #else int diff --git a/example/device/display/displayX.cpp b/example/device/display/displayX.cpp index 2188a5ddd3e126c0be6edbd75445fb711ea08a04..c35e5c31ba9957cf597b1fe457d45a142595a03f 100644 --- a/example/device/display/displayX.cpp +++ b/example/device/display/displayX.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: displayX.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: displayX.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -73,6 +73,10 @@ // List of allowed command line options #define GETOPTARGS "cdi:o:p:h" +void usage(const char *name, const char *badparam, std::string ipath, std::string opath, std::string user); +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &opath, bool &click_allowed, + std::string user, bool &display); + /*! Print the program options. @@ -84,8 +88,7 @@ \param user : Username. */ -void usage(const char *name, const char *badparam, std::string ipath, - std::string opath, std::string user) +void usage(const char *name, const char *badparam, std::string ipath, std::string opath, std::string user) { fprintf(stdout, "\n\ Read an image on the disk, display it using X11, display some\n\ @@ -151,23 +154,22 @@ OPTIONS: Default\n\ \return false if the program has to be stopped, true otherwise. */ -bool getOptions(int argc, const char **argv, - std::string &ipath, std::string &opath, bool &click_allowed, +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &opath, bool &click_allowed, std::string user, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; case 'd': display = false; break; - case 'i': ipath = optarg; break; - case 'o': opath = optarg; break; + 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; + usage(argv[0], optarg_, ipath, opath, user); return false; break; } } @@ -175,7 +177,7 @@ bool getOptions(int argc, const char **argv, // 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; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -185,256 +187,253 @@ bool getOptions(int argc, const char **argv, 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; - bool opt_click_allowed = true; - 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; - // std::cout << "env_ipath: " << env_ipath << std::endl; - - // Set the default input path - if (! env_ipath.empty()) - ipath = env_ipath; - - // Set the default output path -#ifdef UNIX - opt_opath = "/tmp"; -#elif WIN32 - opt_opath = "C:\\temp"; + try { + std::string env_ipath; + std::string opt_ipath; + std::string opt_opath; + std::string ipath; + std::string opath; + std::string filename; + std::string username; + bool opt_click_allowed = true; + 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; + // std::cout << "env_ipath: " << env_ipath << std::endl; + + // Set the default input path + if (! env_ipath.empty()) + ipath = env_ipath; + + // Set the default output path +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX + opt_opath = "/tmp"; +#elif defined(_WIN32) + opt_opath = "C:\\temp"; #endif - // Get the user login name - vpIoTools::getUserName(username); + // Get the user login name + vpIoTools::getUserName(username); - // Read the command line options - if (getOptions(argc, argv, opt_ipath, opt_opath, - opt_click_allowed, username, opt_display) == false) { - exit (-1); - } - - // Get the option values - if (!opt_ipath.empty()) - ipath = opt_ipath; - if (!opt_opath.empty()) - opath = opt_opath; + // Read the command line options + if (getOptions(argc, argv, opt_ipath, opt_opath, + opt_click_allowed, username, opt_display) == false) { + exit (-1); + } - // Append to the output path string, the login name of the user - std::string odirname = opath + vpIoTools::path("/") + username; + // Get the option values + if (!opt_ipath.empty()) + ipath = opt_ipath; + if (!opt_opath.empty()) + opath = opt_opath; + + // Append to the output path string, the login name of the user + std::string odirname = opath + vpIoTools::path("/") + username; + + // Test if the output path exist. If no try to create it + if (vpIoTools::checkDirectory(odirname) == false) { + try { + // Create the dirname + vpIoTools::makeDirectory(odirname); + } + catch (...) { + usage(argv[0], NULL, ipath, opath, username); + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Cannot create " << odirname << std::endl; + std::cerr << " Check your -o " << opath << " option " << std::endl; + exit(-1); + } + } - // Test if the output path exist. If no try to create it - if (vpIoTools::checkDirectory(odirname) == false) { - try { - // Create the dirname - vpIoTools::makeDirectory(odirname); + // 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 <visp image path=" << ipath << "> " + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; + } } - catch (...) { + + // 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 << " Cannot create " << odirname << std::endl; - std::cerr << " Check your -o " << opath << " option " << std::endl; + std::cerr << " Use -i <visp image path> 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); } - } - // 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 <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; - } - } + // Create a grey level image + vpImage<unsigned char> I ; + vpImagePoint ip, ip1, ip2; - // 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 <visp image path> 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); - } + // Load a grey image from the disk + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); + vpImageIo::read(I, filename) ; - // Create a grey level image - vpImage<unsigned char> I ; - vpImagePoint ip, ip1, ip2; + // Create a display using X11 + vpDisplayX display; - // Load a grey image from the disk - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); - try { - vpImageIo::read(I, filename) ; - } - catch (...) { - return -1; - } + if (opt_display) { + // For this grey level image, open a X11 display at position 100,100 + // in the screen, and with title "X11 display" + display.init(I, 100, 100, "X11 display") ; - // Create a display using X11 - vpDisplayX display; + // Display the image + vpDisplay::display(I) ; - if (opt_display) { - // For this grey level image, open a X11 display at position 100,100 - // in the screen, and with title "X11 display" - display.init(I, 100, 100, "X11 display") ; + // Display in overlay a red cross at position 10,10 in the + // image. The lines are 10 pixels long + ip.set_i( 100 ); + ip.set_j( 10 ); - // Display the image - vpDisplay::display(I) ; + vpDisplay::displayCross(I, ip, 20, vpColor::red) ; - // Display in overlay a red cross at position 10,10 in the - // image. The lines are 10 pixels long - ip.set_i( 100 ); - ip.set_j( 10 ); - - vpDisplay::displayCross(I, ip, 20, vpColor::red) ; + // Display in overlay horizontal red lines + for (unsigned i=0 ; i < I.getHeight() ; i+=20) { + ip1.set_i( i ); + ip1.set_j( 0 ); + ip2.set_i( i ); + ip2.set_j( I.getWidth() ); + vpDisplay::displayLine(I, ip1, ip2, vpColor::red) ; + } - // Display in overlay horizontal red lines - for (unsigned i=0 ; i < I.getHeight() ; i+=20) { - ip1.set_i( i ); - ip1.set_j( 0 ); - ip2.set_i( i ); - ip2.set_j( I.getWidth() ); - vpDisplay::displayLine(I, ip1, ip2, vpColor::red) ; - } + // Display a ligne in the diagonal + ip1.set_i( -10 ); + ip1.set_j( -10 ); + ip2.set_i( I.getHeight() + 10 ); + ip2.set_j( I.getWidth() + 10 ); - // Display a ligne in the diagonal - ip1.set_i( -10 ); - ip1.set_j( -10 ); - ip2.set_i( I.getHeight() + 10 ); - ip2.set_j( I.getWidth() + 10 ); - - vpDisplay::displayLine(I, ip1, ip2, vpColor::red) ; + vpDisplay::displayLine(I, ip1, ip2, vpColor::red) ; - // Display in overlay vertical green dot lines - for (unsigned i=0 ; i < I.getWidth() ; i+=20) { + // Display in overlay vertical green dot lines + for (unsigned i=0 ; i < I.getWidth() ; i+=20) { + ip1.set_i( 0 ); + ip1.set_j( i ); + ip2.set_i( I.getWidth() ); + ip2.set_j( i ); + vpDisplay::displayDotLine(I, ip1, ip2, vpColor::green) ; + } + + // Display a rectangle + ip.set_i( I.getHeight() - 45 ); + ip.set_j( -10 ); + vpDisplay::displayRectangle(I, ip, 60, 80, vpColor::orange) ; + + // Display in overlay a blue arrow ip1.set_i( 0 ); - ip1.set_j( i ); - ip2.set_i( I.getWidth() ); - ip2.set_j( i ); - vpDisplay::displayDotLine(I, ip1, ip2, vpColor::green) ; - } - - // Display a rectangle - ip.set_i( I.getHeight() - 45 ); - ip.set_j( -10 ); - vpDisplay::displayRectangle(I, ip, 60, 80, vpColor::orange) ; - - // Display in overlay a blue arrow - ip1.set_i( 0 ); - ip1.set_j( 0 ); - ip2.set_i( 100 ); - ip2.set_j( 100 ); - vpDisplay::displayArrow(I, ip1, ip2, vpColor::blue) ; - - // Display in overlay some circles. The position of the center is 200, 200 - // the radius is increased by 20 pixels for each circle - - for (unsigned int i=0 ; i < 100 ; i+=20) { - ip.set_i( 80 ); - ip.set_j( 80 ); - vpDisplay::displayCircle(I, ip, 20+i, vpColor::yellow) ; + ip1.set_j( 0 ); + ip2.set_i( 100 ); + ip2.set_j( 100 ); + vpDisplay::displayArrow(I, ip1, ip2, vpColor::blue) ; + + // Display in overlay some circles. The position of the center is 200, 200 + // the radius is increased by 20 pixels for each circle + + for (unsigned int i=0 ; i < 100 ; i+=20) { + ip.set_i( 80 ); + ip.set_j( 80 ); + vpDisplay::displayCircle(I, ip, 20+i, vpColor::yellow) ; + } + + ip.set_i( -10 ); + ip.set_j( 300 ); + vpDisplay::displayCircle(I, ip, 100,vpColor::yellow) ; + + // Display in overlay a yellow string + ip.set_i( 85 ); + ip.set_j( 100 ); + vpDisplay::displayCharString(I, ip, + "ViSP is a marvelous software", + vpColor::yellow) ; + //Flush the display + vpDisplay::flush(I); + + // Create a color image + vpImage<vpRGBa> Ioverlay ; + // Updates the color image with the original loaded image and the overlay + vpDisplay::getImage(I, Ioverlay) ; + + // Write the color image on the disk + filename = odirname + vpIoTools::path("/Klimt_grey.overlay.ppm"); + vpImageIo::write(Ioverlay, filename) ; + + // If click is allowed, wait for a mouse click to close the display + if (opt_click_allowed) { + std::cout << "\nA click to close the windows..." << std::endl; + // Wait for a blocking mouse click + vpDisplay::getClick(I) ; + } + + // Close the display + vpDisplay::close(I); } - ip.set_i( -10 ); - ip.set_j( 300 ); - vpDisplay::displayCircle(I, ip, 100,vpColor::yellow) ; - - // Display in overlay a yellow string - ip.set_i( 85 ); - ip.set_j( 100 ); - vpDisplay::displayCharString(I, ip, - "ViSP is a marvelous software", - vpColor::yellow) ; - //Flush the display - vpDisplay::flush(I); - // Create a color image - vpImage<vpRGBa> Ioverlay ; - // Updates the color image with the original loaded image and the overlay - vpDisplay::getImage(I, Ioverlay) ; - - // Write the color image on the disk - filename = odirname + vpIoTools::path("/Klimt_grey.overlay.ppm"); - vpImageIo::write(Ioverlay, filename) ; - - // If click is allowed, wait for a mouse click to close the display - if (opt_click_allowed) { - std::cout << "\nA click to close the windows..." << std::endl; - // Wait for a blocking mouse click - vpDisplay::getClick(I) ; - } - - // Close the display - vpDisplay::close(I); - } + vpImage<vpRGBa> Irgba ; - // Create a color image - vpImage<vpRGBa> Irgba ; - - // Load a grey image from the disk and convert it to a color image - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); - try { + // Load a grey image from the disk and convert it to a color image + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); vpImageIo::read(Irgba, filename) ; - } - catch (...) { - return -1; - } - // Create a new display - vpDisplayX displayRGBa; - - if (opt_display) { - // For this color image, open a X11 display at position 100,100 - // in the screen, and with title "X11 color display" - displayRGBa.init(Irgba, 100, 100, "X11 color display"); - - // Display the color image - vpDisplay::display(Irgba) ; - vpDisplay::flush(Irgba) ; - - // If click is allowed, wait for a blocking mouse click to display a cross - // at the clicked pixel position - if (opt_click_allowed) { - std::cout << "\nA click to display a cross..." << std::endl; - // Blocking wait for a click. Get the position of the selected pixel - // (i correspond to the row and j to the column coordinates in the image) - vpDisplay::getClick(Irgba, ip); - // Display a red cross on the click pixel position - std::cout << "Cross position: " << ip << std::endl; - vpDisplay::displayCross(Irgba, ip, 15, vpColor::red); - } - else { - ip.set_i( 10 ); - ip.set_j( 20 ); - // Display a red cross at position i, j (i correspond to the row - // and j to the column coordinates in the image) - std::cout << "Cross position: " << ip << std::endl; - vpDisplay::displayCross(Irgba, ip, 15, vpColor::red); - - } - // Flush the display. Sometimes the display content is - // bufferized. Force to display the content that has been bufferized. - vpDisplay::flush(Irgba); - - // If click is allowed, wait for a blocking mouse click to exit. - if (opt_click_allowed) { - std::cout << "\nA click to exit the program..." << std::endl; - vpDisplay::getClick(Irgba) ; - std::cout << "Bye" << std::endl; + // Create a new display + vpDisplayX displayRGBa; + + if (opt_display) { + // For this color image, open a X11 display at position 100,100 + // in the screen, and with title "X11 color display" + displayRGBa.init(Irgba, 100, 100, "X11 color display"); + + // Display the color image + vpDisplay::display(Irgba) ; + vpDisplay::flush(Irgba) ; + + // If click is allowed, wait for a blocking mouse click to display a cross + // at the clicked pixel position + if (opt_click_allowed) { + std::cout << "\nA click to display a cross..." << std::endl; + // Blocking wait for a click. Get the position of the selected pixel + // (i correspond to the row and j to the column coordinates in the image) + vpDisplay::getClick(Irgba, ip); + // Display a red cross on the click pixel position + std::cout << "Cross position: " << ip << std::endl; + vpDisplay::displayCross(Irgba, ip, 15, vpColor::red); + } + else { + ip.set_i( 10 ); + ip.set_j( 20 ); + // Display a red cross at position i, j (i correspond to the row + // and j to the column coordinates in the image) + std::cout << "Cross position: " << ip << std::endl; + vpDisplay::displayCross(Irgba, ip, 15, vpColor::red); + + } + // Flush the display. Sometimes the display content is + // bufferized. Force to display the content that has been bufferized. + vpDisplay::flush(Irgba); + + // If click is allowed, wait for a blocking mouse click to exit. + if (opt_click_allowed) { + std::cout << "\nA click to exit the program..." << std::endl; + vpDisplay::getClick(Irgba) ; + std::cout << "Bye" << std::endl; + } } + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } } #else diff --git a/example/device/display/displayXMulti.cpp b/example/device/display/displayXMulti.cpp index b624901f48f0232c67df195bcc8766b7c21f98e3..b34340c075c78aca43b2c192fe1655e39868356e 100644 --- a/example/device/display/displayXMulti.cpp +++ b/example/device/display/displayXMulti.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: displayXMulti.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: displayXMulti.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -76,6 +76,10 @@ // List of allowed command line options #define GETOPTARGS "cdi:o:h" +void usage(const char *name, const char *badparam, std::string ipath, std::string opath, std::string user); +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &opath, bool &click_allowed, + std::string user, bool &display); + /*! Print the program options. @@ -151,23 +155,22 @@ OPTIONS: Default\n\ \return false if the program has to be stopped, true otherwise. */ -bool getOptions(int argc, const char **argv, - std::string &ipath, std::string &opath, bool &click_allowed, +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &opath, bool &click_allowed, std::string user, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; case 'd': display = false; break; - case 'i': ipath = optarg; break; - case 'o': opath = optarg; break; + 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; + usage(argv[0], optarg_, ipath, opath, user); return false; break; } } @@ -175,7 +178,7 @@ bool getOptions(int argc, const char **argv, // 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; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -185,221 +188,228 @@ bool getOptions(int argc, const char **argv, 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; - bool opt_click_allowed = true; - 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; - // std::cout << "env_ipath: " << env_ipath << std::endl; - - // Set the default input path - if (! env_ipath.empty()) - ipath = env_ipath; - - // Set the default output path -#ifdef UNIX - opt_opath = "/tmp"; -#elif WIN32 - opt_opath = "C:\\temp"; + try { + std::string env_ipath; + std::string opt_ipath; + std::string opt_opath; + std::string ipath; + std::string opath; + std::string filename; + std::string username; + bool opt_click_allowed = true; + 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; + // std::cout << "env_ipath: " << env_ipath << std::endl; + + // Set the default input path + if (! env_ipath.empty()) + ipath = env_ipath; + + // Set the default output path +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX + opt_opath = "/tmp"; +#elif defined(_WIN32) + opt_opath = "C:\\temp"; #endif - // Get the user login name - vpIoTools::getUserName(username); - - // Read the command line options - if (getOptions(argc, argv, opt_ipath, opt_opath, - opt_click_allowed, username, opt_display) == false) { - exit (-1); - } + // Get the user login name + vpIoTools::getUserName(username); - // Get the option values - if (!opt_ipath.empty()) - ipath = opt_ipath; - if (!opt_opath.empty()) - opath = opt_opath; + // Read the command line options + if (getOptions(argc, argv, opt_ipath, opt_opath, + opt_click_allowed, username, opt_display) == false) { + exit (-1); + } - // Append to the output path string, the login name of the user - std::string odirname = opath + vpIoTools::path("/") + username; + // Get the option values + if (!opt_ipath.empty()) + ipath = opt_ipath; + if (!opt_opath.empty()) + opath = opt_opath; + + // Append to the output path string, the login name of the user + std::string odirname = opath + vpIoTools::path("/") + username; + + // Test if the output path exist. If no try to create it + if (vpIoTools::checkDirectory(odirname) == false) { + try { + // Create the dirname + vpIoTools::makeDirectory(odirname); + } + catch (...) { + usage(argv[0], NULL, ipath, opath, username); + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Cannot create " << odirname << std::endl; + std::cerr << " Check your -o " << opath << " option " << std::endl; + exit(-1); + } + } - // Test if the output path exist. If no try to create it - if (vpIoTools::checkDirectory(odirname) == false) { - try { - // Create the dirname - vpIoTools::makeDirectory(odirname); + // 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 <visp image path=" << ipath << "> " + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; + } } - catch (...) { + + // 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 << " Cannot create " << odirname << std::endl; - std::cerr << " Check your -o " << opath << " option " << std::endl; + std::cerr << " Use -i <visp image path> 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); } - } - - // 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 <visp image path=" << ipath << "> " - << " 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 <visp image path> 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); - } - // Create two color images - vpImage<vpRGBa> I1, I2 ; - vpImagePoint ip, ip1, ip2; + // Create two color images + vpImage<vpRGBa> I1, I2 ; + vpImagePoint ip, ip1, ip2; - try { - // Load a grey image from the disk - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); - vpImageIo::read(I1, filename) ; - } - catch(...) - { - 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); - } - try { - // Load a color image from the disk - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); - vpImageIo::read(I2, filename) ; - } - catch(...) - { - 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); - } - - // For each image, open a X11 display - vpDisplayX display1; - vpDisplayX display2; - - if (opt_display) { - // Attach image 1 to display 1 - display1.init(I1, 0, 0,"X11 Display 1...") ; - // Attach image 2 to display 2 - display2.init(I2, 200, 200,"X11 Display 2...") ; - // Display the images - vpDisplay::display(I1) ; - vpDisplay::display(I2) ; - - // In the first display, display in overlay horizontal red lines - for (unsigned int i=0 ; i < I1.getHeight() ; i+=20) { - ip1.set_i( i ); - ip1.set_j( 0 ); - ip2.set_i( i ); - ip2.set_j( I1.getWidth() ); - vpDisplay::displayLine(I1, ip1, ip2, vpColor::red) ; - } - - // In the first display, display in overlay vertical green dot lines - for (unsigned int i=0 ; i < I1.getWidth() ; i+=20) { - ip1.set_i( 0 ); - ip1.set_j( i ); - ip2.set_i( I1.getWidth() ); - ip2.set_j( i ); - vpDisplay::displayDotLine(I1, ip1, ip2, vpColor::green) ; + try { + // Load a grey image from the disk + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); + vpImageIo::read(I1, filename) ; } - - // In the first display, display in overlay a blue arrow - ip1.set_i( 0 ); - ip1.set_j( 0 ); - ip2.set_i( 100 ); - ip2.set_j( 100 ); - vpDisplay::displayArrow(I1, ip1, ip2, vpColor::blue) ; - - // In the first display, display in overlay some circles. The - // position of the center is 200, 200 the radius is increased by 20 - // pixels for each circle - for (unsigned int i=0 ; i < 100 ; i+=20) { - ip.set_i( 200 ); - ip.set_j( 200 ); - vpDisplay::displayCircle(I1, ip, 20+i,vpColor::yellow) ; + catch(...) + { + 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); } - - // In the first display, display in overlay a yellow string - ip.set_i( 100 ); - ip.set_j( 100 ); - vpDisplay::displayCharString(I1, ip, - "ViSP is a marvelous software", - vpColor::blue) ; - - //Flush displays. The displays must be flushed to show the overlay. - //without this line, nothing will be displayed. - vpDisplay::flush(I1); - vpDisplay::flush(I2); - - // If click is allowed, wait for a blocking mouse click in the first - // display, to display a cross at the clicked pixel position - if (opt_click_allowed) { - std::cout << "\nA click in the first display to draw a cross..." << std::endl; - // Blocking wait for a click. Get the position of the selected pixel - // (i correspond to the row and j to the column coordinates in the image) - vpDisplay::getClick(I1, ip); - // Display a red cross on the click pixel position - std::cout << "Cross position: " << ip << std::endl; - vpDisplay::displayCross(I1, ip, 15,vpColor::red); - vpDisplay::flush(I1); + try { + // Load a color image from the disk + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); + vpImageIo::read(I2, filename) ; } - else { - ip.set_i( 50 ); - ip.set_j( 50 ); - // Display a red cross at position ip in the first display - std::cout << "Cross position: " << ip<< std::endl; - vpDisplay::displayCross(I1, ip, 15, vpColor::red); - vpDisplay::flush(I1); + catch(...) + { + 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 color image - vpImage<vpRGBa> Ioverlay ; - // Updates the color image with the original loaded image 1 and the overlay - vpDisplay::getImage(I1, Ioverlay) ; - - // Write the color image on the disk - filename = odirname + vpIoTools::path("/Klimt_grey.overlay.ppm"); - vpImageIo::write(Ioverlay, filename) ; - - // If click is allowed, wait for a mouse click to close the display - if (opt_click_allowed) { - std::cout << "\nA click in the second display to close the windows and exit..." << std::endl; - // Wait for a blocking mouse click - vpDisplay::getClick(I2) ; + // For each image, open a X11 display + vpDisplayX display1; + vpDisplayX display2; + + if (opt_display) { + // Attach image 1 to display 1 + display1.init(I1, 0, 0,"X11 Display 1...") ; + // Attach image 2 to display 2 + display2.init(I2, 200, 200,"X11 Display 2...") ; + // Display the images + vpDisplay::display(I1) ; + vpDisplay::display(I2) ; + + // In the first display, display in overlay horizontal red lines + for (unsigned int i=0 ; i < I1.getHeight() ; i+=20) { + ip1.set_i( i ); + ip1.set_j( 0 ); + ip2.set_i( i ); + ip2.set_j( I1.getWidth() ); + vpDisplay::displayLine(I1, ip1, ip2, vpColor::red) ; + } + + // In the first display, display in overlay vertical green dot lines + for (unsigned int i=0 ; i < I1.getWidth() ; i+=20) { + ip1.set_i( 0 ); + ip1.set_j( i ); + ip2.set_i( I1.getWidth() ); + ip2.set_j( i ); + vpDisplay::displayDotLine(I1, ip1, ip2, vpColor::green) ; + } + + // In the first display, display in overlay a blue arrow + ip1.set_i( 0 ); + ip1.set_j( 0 ); + ip2.set_i( 100 ); + ip2.set_j( 100 ); + vpDisplay::displayArrow(I1, ip1, ip2, vpColor::blue) ; + + // In the first display, display in overlay some circles. The + // position of the center is 200, 200 the radius is increased by 20 + // pixels for each circle + for (unsigned int i=0 ; i < 100 ; i+=20) { + ip.set_i( 200 ); + ip.set_j( 200 ); + vpDisplay::displayCircle(I1, ip, 20+i,vpColor::yellow) ; + } + + // In the first display, display in overlay a yellow string + ip.set_i( 100 ); + ip.set_j( 100 ); + vpDisplay::displayCharString(I1, ip, + "ViSP is a marvelous software", + vpColor::blue) ; + + //Flush displays. The displays must be flushed to show the overlay. + //without this line, nothing will be displayed. + vpDisplay::flush(I1); + vpDisplay::flush(I2); + + // If click is allowed, wait for a blocking mouse click in the first + // display, to display a cross at the clicked pixel position + if (opt_click_allowed) { + std::cout << "\nA click in the first display to draw a cross..." << std::endl; + // Blocking wait for a click. Get the position of the selected pixel + // (i correspond to the row and j to the column coordinates in the image) + vpDisplay::getClick(I1, ip); + // Display a red cross on the click pixel position + std::cout << "Cross position: " << ip << std::endl; + vpDisplay::displayCross(I1, ip, 15,vpColor::red); + vpDisplay::flush(I1); + } + else { + ip.set_i( 50 ); + ip.set_j( 50 ); + // Display a red cross at position ip in the first display + std::cout << "Cross position: " << ip<< std::endl; + vpDisplay::displayCross(I1, ip, 15, vpColor::red); + vpDisplay::flush(I1); + } + + // Create a color image + vpImage<vpRGBa> Ioverlay ; + // Updates the color image with the original loaded image 1 and the overlay + vpDisplay::getImage(I1, Ioverlay) ; + + // Write the color image on the disk + filename = odirname + vpIoTools::path("/Klimt_grey.overlay.ppm"); + vpImageIo::write(Ioverlay, filename) ; + + // If click is allowed, wait for a mouse click to close the display + if (opt_click_allowed) { + std::cout << "\nA click in the second display to close the windows and exit..." << std::endl; + // Wait for a blocking mouse click + vpDisplay::getClick(I2) ; + } } + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } } #else diff --git a/example/device/framegrabber/CMakeLists.txt b/example/device/framegrabber/CMakeLists.txt index 53c18727144126f1aaa6e2f75fa61c11c84a5ad2..48e78d67a57bd0dd1ec69c61a04818d8b5595fe1 100644 --- a/example/device/framegrabber/CMakeLists.txt +++ b/example/device/framegrabber/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/device/framegrabber/grab1394CMU.cpp b/example/device/framegrabber/grab1394CMU.cpp index 2f538ef92fce2cd9edec8af8930ffcbad812834e..fdca9c3efd2bd6bddb663a776bced4cdb93fae17 100644 --- a/example/device/framegrabber/grab1394CMU.cpp +++ b/example/device/framegrabber/grab1394CMU.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: grab1394CMU.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: grab1394CMU.cpp 4659 2014-02-09 14:11:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -64,6 +64,10 @@ // List of allowed command line options #define GETOPTARGS "dhn:o:" +void usage(const char *name, const char *badparam, unsigned &nframes, std::string &opath); +bool getOptions(int argc, const char **argv, bool &display, + unsigned int &nframes, bool &save, std::string &opath); + /*! Print the program options. @@ -123,21 +127,21 @@ OPTIONS: Default\n\ bool getOptions(int argc, const char **argv, bool &display, unsigned int &nframes, bool &save, std::string &opath) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'd': display = false; break; case 'n': - nframes = (unsigned int)atoi(optarg); break; + nframes = (unsigned int)atoi(optarg_); break; case 'o': save = true; - opath = optarg; break; + opath = optarg_; break; case 'h': usage(argv[0], NULL, nframes, opath); return false; break; default: - usage(argv[0], optarg, nframes, opath); + usage(argv[0], optarg_, nframes, opath); return false; break; } } @@ -146,7 +150,7 @@ bool getOptions(int argc, const char **argv, bool &display, // standalone param or error usage(argv[0], NULL, nframes, opath); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -255,10 +259,9 @@ main(int argc, const char ** argv) 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); + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } } #else diff --git a/example/device/framegrabber/grab1394Two.cpp b/example/device/framegrabber/grab1394Two.cpp index 6b1e28a181ae140e9611f86c349566203ff22d77..401e31d7c57d116f1656ef9396f96fab22cbc448 100644 --- a/example/device/framegrabber/grab1394Two.cpp +++ b/example/device/framegrabber/grab1394Two.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: grab1394Two.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: grab1394Two.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -78,10 +78,29 @@ // List of allowed command line options #define GETOPTARGS "b:c:df:g:hH:L:mn:io:p:rsT:v:W:" - - #define DUAL_ACQ +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); +void read_options(int argc, const char **argv, bool &multi, unsigned int &camera, + unsigned int &nframes, bool &verbose_info, + bool &verbose_settings, + bool &videomode_is_set, + vp1394TwoGrabber::vp1394TwoVideoModeType &videomode, + bool &framerate_is_set, + vp1394TwoGrabber::vp1394TwoFramerateType &framerate, + bool &colorcoding_is_set, + vp1394TwoGrabber::vp1394TwoColorCodingType &colorcoding, + bool &ringbuffersize_is_set, + unsigned int &ringbuffersize, + bool &display, bool &save, std::string &opath, + unsigned int &roi_left, unsigned int &roi_top, + unsigned int &roi_width, unsigned int &roi_height, + bool &reset, + unsigned int &panControl, bool & panControl_is_set); /*! @@ -277,41 +296,41 @@ void read_options(int argc, const char **argv, bool &multi, unsigned int &camera /* * Lecture des options. */ - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': - camera = (unsigned int)atoi(optarg); break; + camera = (unsigned int)atoi(optarg_); break; case 'd': display = false; break; case 'f': framerate_is_set = true; - framerate = (vp1394TwoGrabber::vp1394TwoFramerateType) atoi(optarg); + framerate = (vp1394TwoGrabber::vp1394TwoFramerateType) atoi(optarg_); break; case 'g': colorcoding_is_set = true; - colorcoding = (vp1394TwoGrabber::vp1394TwoColorCodingType) atoi(optarg); + colorcoding = (vp1394TwoGrabber::vp1394TwoColorCodingType) atoi(optarg_); break; case 'H': - roi_height = (unsigned int) atoi(optarg); break; + roi_height = (unsigned int) atoi(optarg_); break; case 'i': verbose_info = true; break; case 'L': - roi_left = (unsigned int) atoi(optarg); break; + roi_left = (unsigned int) atoi(optarg_); break; case 'm': multi = true; break; case 'n': - nframes = (unsigned int)atoi(optarg); break; + nframes = (unsigned int)atoi(optarg_); break; case 'o': save = true; - opath = optarg; break; + opath = optarg_; break; case 'b': ringbuffersize_is_set = true; - ringbuffersize = (unsigned int) atoi(optarg); break; + ringbuffersize = (unsigned int) atoi(optarg_); break; case 'p': - panControl = (unsigned int) atoi(optarg); + panControl = (unsigned int) atoi(optarg_); panControl_is_set = true; break; case 'r': @@ -319,13 +338,13 @@ void read_options(int argc, const char **argv, bool &multi, unsigned int &camera case 's': verbose_settings = true; break; case 'T': - roi_top = (unsigned int) atoi(optarg); break; + roi_top = (unsigned int) atoi(optarg_); break; case 'v': videomode_is_set = true; - videomode = (vp1394TwoGrabber::vp1394TwoVideoModeType) atoi(optarg); + videomode = (vp1394TwoGrabber::vp1394TwoVideoModeType) atoi(optarg_); break; case 'W': - roi_width = (unsigned int) atoi(optarg); break; + roi_width = (unsigned int) atoi(optarg_); break; case 'h': case '?': usage(argv[0], NULL, camera, nframes, opath, @@ -341,7 +360,7 @@ void read_options(int argc, const char **argv, bool &multi, unsigned int &camera usage(argv[0], NULL, camera, nframes, opath, roi_left, roi_top, roi_width, roi_height, ringbuffersize, panControl); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; exit(-1); } } @@ -488,10 +507,10 @@ main(int argc, const char ** argv) vp1394TwoGrabber::vp1394TwoVideoModeType supmode = *it_lmode; if (curmode == supmode) std::cout << " * " << vp1394TwoGrabber::videoMode2string(supmode) - << " (-v " << supmode << ")" << std::endl; + << " (-v " << (int)supmode << ")" << std::endl; else std::cout << " " << vp1394TwoGrabber::videoMode2string(supmode) - << " (-v " << supmode << ")" << std::endl; + << " (-v " << (int)supmode << ")" << std::endl; if (g.isVideoModeFormat7(supmode)){ // Format 7 video mode; no framerate setting, but color @@ -503,11 +522,11 @@ main(int argc, const char ** argv) if ( (curmode == supmode) && (supcoding == curcoding) ) std::cout << " * " << vp1394TwoGrabber::colorCoding2string(supcoding) - << " (-g " << supcoding << ")" << std::endl; + << " (-g " << (int)supcoding << ")" << std::endl; else std::cout << " " << vp1394TwoGrabber::colorCoding2string(supcoding) - << " (-g " << supcoding << ")" << std::endl; + << " (-g " << (int)supcoding << ")" << std::endl; } } else { @@ -519,11 +538,11 @@ main(int argc, const char ** argv) if ( (curmode == supmode) && (supfps == curfps) ) std::cout << " * " << vp1394TwoGrabber::framerate2string(supfps) - << " (-f " << supfps << ")" << std::endl; + << " (-f " << (int)supfps << ")" << std::endl; else std::cout << " " << vp1394TwoGrabber::framerate2string(supfps) - << " (-f " << supfps << ")" << std::endl; + << " (-f " << (int)supfps << ")" << std::endl; } } } @@ -695,12 +714,12 @@ main(int argc, const char ** argv) if (display) delete [] d; #endif + return 0; } - catch (...) { - vpCERROR << "Failure: exit" << std::endl; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - - std::cout << " the end" << std::endl; } #else int diff --git a/example/device/framegrabber/grabDirectShow.cpp b/example/device/framegrabber/grabDirectShow.cpp index 225e357c31e44986ee8b4fd680c3819b6a6149d1..cea7264c493eeea35ab1ab6f1fd77111a25bb262 100644 --- a/example/device/framegrabber/grabDirectShow.cpp +++ b/example/device/framegrabber/grabDirectShow.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: grabDirectShow.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: grabDirectShow.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -167,35 +167,34 @@ bool getOptions(int argc, const char **argv, bool &display, int main(int argc, const char ** argv) { - bool opt_display = true; - unsigned nframes = 50; - bool save = false; + try { + 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. + // 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<vpRGBa> I; // This is a color image (in RGBa format) + vpImage<vpRGBa> I; // This is a color image (in RGBa format) #else - vpImage<unsigned char> I; // This is a B&W image + vpImage<unsigned char> I; // This is a B&W image #endif - // Set default output image name for saving + // 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"; + // 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"; + // 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); - } - vpDirectShowGrabber* grabber = NULL; - try { + // Read the command line options + if (getOptions(argc, argv, opt_display, nframes, save, opath) == false) { + exit (-1); + } // Create the grabber - grabber = new vpDirectShowGrabber(); + vpDirectShowGrabber* grabber = new vpDirectShowGrabber(); //test if a camera is connected if(grabber->getDeviceNumber() == 0) @@ -209,29 +208,22 @@ main(int argc, const char ** argv) // Acquire an image grabber->acquire(I); - } - catch(...) - { - if (grabber !=NULL) delete grabber; - vpCTRACE << "Cannot acquire an image... " << std::endl ; - exit(-1); - } - std::cout << "Image size: width : " << I.getWidth() << " height: " - << I.getHeight() << std::endl; - // Creates a display + std::cout << "Image size: width : " << I.getWidth() << " height: " + << I.getHeight() << std::endl; + + // Creates a display #if defined VISP_HAVE_GTK - vpDisplayGTK display; + vpDisplayGTK display; #elif defined VISP_HAVE_GDI - vpDisplayGDI display; + vpDisplayGDI display; #endif - if (opt_display) { - display.init(I,100,100,"DirectShow Framegrabber"); - } + if (opt_display) { + display.init(I,100,100,"DirectShow Framegrabber"); + } - try { double tbegin=0, tend=0, tloop=0, ttotal=0; ttotal = 0; @@ -242,8 +234,8 @@ main(int argc, const char ** argv) grabber->acquire(I); if (opt_display) { - //Displays the grabbed rgba image - vpDisplay::display(I); + //Displays the grabbed rgba image + vpDisplay::display(I); vpDisplay::flush(I); } @@ -264,14 +256,12 @@ main(int argc, const char ** argv) std::cout << "Mean frequency: " << 1000./(ttotal / nframes) << " fps" << std::endl; // Release the framegrabber - if (grabber !=NULL) delete grabber; - + delete grabber; + return 0; } - catch(...) - { - vpCERROR << "Failure: exit" << std::endl; - if (grabber !=NULL) delete grabber; - return(-1); + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } } #else // (defined (VISP_HAVE_GTK) || defined(VISP_HAVE_GDI)) diff --git a/example/device/framegrabber/grabDirectShowMulti.cpp b/example/device/framegrabber/grabDirectShowMulti.cpp index dcebf89ff1764dc7422cc53c3d2d4fb91260a92b..312c80a655384d0e543d3af5bb7e5010ffa988c3 100644 --- a/example/device/framegrabber/grabDirectShowMulti.cpp +++ b/example/device/framegrabber/grabDirectShowMulti.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: grabDirectShowMulti.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: grabDirectShowMulti.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -455,12 +455,12 @@ main(int argc, const char ** argv) if (display) delete [] d; - } - catch (...) { - vpCERROR << "Failure: exit" << std::endl; - } - - std::cout << " the end" << std::endl; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } #else // (defined (VISP_HAVE_GTK) || defined(VISP_HAVE_GDI)) diff --git a/example/device/framegrabber/grabDisk.cpp b/example/device/framegrabber/grabDisk.cpp index 1ef12c91e05e891047a6dce3367f0164a0df7019..f70181d8c514b5b458c6efcc4b426592d3c0977f 100644 --- a/example/device/framegrabber/grabDisk.cpp +++ b/example/device/framegrabber/grabDisk.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: grabDisk.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: grabDisk.cpp 4659 2014-02-09 14:11:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -44,13 +44,13 @@ #include <visp/vpDebug.h> #include <visp/vpConfig.h> #include <stdlib.h> -#if (defined (VISP_HAVE_X11) || defined(VISP_HAVE_GTK)) +#if (defined (VISP_HAVE_X11) || defined(VISP_HAVE_GDI)) #include <visp/vpDiskGrabber.h> #include <visp/vpImage.h> #include <visp/vpDisplay.h> #include <visp/vpDisplayX.h> -#include <visp/vpDisplayGTK.h> +#include <visp/vpDisplayGDI.h> #include <visp/vpTime.h> #include <visp/vpParseArgv.h> @@ -66,6 +66,12 @@ // List of allowed command line options #define GETOPTARGS "b:de:f:i:hn:s:z:" +void usage(const char *name, const char *badparam, std::string ipath, std::string basename, + std::string ext, int first, unsigned int nimages, int step, unsigned int nzero); +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &basename, + std::string &ext, int &first, unsigned int &nimages, + int &step, unsigned int &nzero, bool &display); + /* Print the program options. @@ -82,8 +88,7 @@ */ void usage(const char *name, const char *badparam, std::string ipath, std::string basename, - std::string ext, int first, unsigned int nimages, int step, - unsigned int nzero) + std::string ext, int first, unsigned int nimages, int step, unsigned int nzero) { fprintf(stdout, "\n\ Read an image sequence from the disk. Display it using X11 or GTK.\n\ @@ -163,25 +168,24 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &ba std::string &ext, int &first, unsigned int &nimages, int &step, unsigned int &nzero, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { - case 'b': basename = optarg; break; + case 'b': basename = optarg_; break; case 'd': display = false; break; - case 'e': ext = optarg; break; - case 'f': first = atoi(optarg); break; - case 'i': ipath = optarg; break; - case 'n': nimages = (unsigned) atoi(optarg); break; - case 's': step = atoi(optarg); break; - case 'z': nzero = (unsigned) atoi(optarg); break; + case 'e': ext = optarg_; break; + case 'f': first = atoi(optarg_); break; + case 'i': ipath = optarg_; break; + case 'n': nimages = (unsigned) atoi(optarg_); break; + case 's': step = atoi(optarg_); break; + case 'z': nzero = (unsigned) atoi(optarg_); break; case 'h': usage(argv[0], NULL, ipath, basename, ext, first, nimages, step, nzero); return false; break; default: - usage(argv[0], optarg, ipath, basename, ext, first, nimages, - step, nzero); + usage(argv[0], optarg_, ipath, basename, ext, first, nimages, step, nzero); return false; break; } } @@ -190,7 +194,7 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &ba // standalone param or error usage(argv[0], NULL, ipath, basename, ext, first, nimages, step, nzero); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -207,112 +211,107 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &ba images. Each image corresponds to a PGM file. Display these images using X11 or GTK. */ -int -main(int argc, const char ** argv) +int main(int argc, const char ** argv) { - std::string env_ipath; - std::string opt_ipath; - std::string ipath; - std::string opt_basename = "ViSP-images/cube/image."; - std::string opt_ext = "pgm"; - bool opt_display = true; - - int opt_first = 5; - unsigned int opt_nimages = 70; - int opt_step = 1; - unsigned int opt_nzero = 4; - - // 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_basename, opt_ext, opt_first, - opt_nimages, opt_step, opt_nzero, opt_display) == false) { - exit (-1); - } + try { + std::string env_ipath; + std::string opt_ipath; + std::string ipath; + std::string opt_basename = "ViSP-images/cube/image."; + std::string opt_ext = "pgm"; + bool opt_display = true; + + int opt_first = 5; + unsigned int opt_nimages = 70; + int opt_step = 1; + unsigned int opt_nzero = 4; + + // 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_basename, opt_ext, opt_first, + opt_nimages, opt_step, opt_nzero, 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 <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + // 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 <visp image path=" << ipath << "> " + << " 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, opt_basename, opt_ext, opt_first, + // Test if an input path is set + if (opt_ipath.empty() && env_ipath.empty()){ + usage(argv[0], NULL, ipath, opt_basename, opt_ext, opt_first, opt_nimages, opt_step, opt_nzero); - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Use -i <visp image path> 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); - } + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Use -i <visp image path> 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); + } - // 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<unsigned char> I ; + // 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<unsigned char> I ; - // Declare a framegrabber able to read a sequence of successive - // images from the disk - vpDiskGrabber g; + // Declare a framegrabber able to read a sequence of successive + // images from the disk + vpDiskGrabber g; - // Set the path to the directory containing the sequence - g.setDirectory(ipath.c_str()); - // Set the image base name. The directory and the base name constitute - // the constant part of the full filename - g.setBaseName(opt_basename.c_str()); - // Set the step between two images of the sequence - g.setStep(opt_step); - // Set the number of digits to build the image number - g.setNumberOfZero(opt_nzero); - // Set the first frame number of the sequence - g.setImageNumber(opt_first); - // Set the image extension - g.setExtension(opt_ext.c_str()); + // Set the path to the directory containing the sequence + g.setDirectory(ipath.c_str()); + // Set the image base name. The directory and the base name constitute + // the constant part of the full filename + g.setBaseName(opt_basename.c_str()); + // Set the step between two images of the sequence + g.setStep(opt_step); + // Set the number of digits to build the image number + g.setNumberOfZero(opt_nzero); + // Set the first frame number of the sequence + g.setImageNumber(opt_first); + // Set the image extension + g.setExtension(opt_ext.c_str()); - // Open the framegrabber by loading the first image of the sequence - try { + // Open the framegrabber by loading the first image of the sequence g.open(I) ; - } - catch (...) { - vpERROR_TRACE("Cannot open the first image of the sequence... ") ; - exit(-1); - } - std::cout << "Image size: width : " << I.getWidth() << " height: " - << I.getHeight() << std::endl; + std::cout << "Image size: width : " << I.getWidth() << " height: " + << I.getHeight() << std::endl; - // We open a window using either X11 or GTK. - // Its size is automatically defined by the image (I) size -#if defined VISP_HAVE_X11 - vpDisplayX display; -#elif defined VISP_HAVE_GTK - vpDisplayGTK display; + // We open a window using either X11 or GDI. + // Its size is automatically defined by the image (I) size +#if defined(VISP_HAVE_X11) + vpDisplayX display(I); +#elif defined(VISP_HAVE_GDI) + vpDisplayGDI display(I); +#else + std::cout << "No image viewer is available..." << std::endl; #endif - if (opt_display) { - try { + if (opt_display) { display.init(I,100,100,"Disk Framegrabber"); // display the image @@ -323,16 +322,10 @@ main(int argc, const char ** argv) vpDisplay::display(I) ; vpDisplay::flush(I) ; } - catch(...) - { - vpERROR_TRACE("Cannot display the image ") ; - exit(-1); - } - } - unsigned cpt = 1; - // this is the loop over the image sequence - try { + unsigned cpt = 1; + // this is the loop over the image sequence + while(cpt ++ < opt_nimages) { double tms = vpTime::measureTimeMs(); @@ -347,11 +340,12 @@ main(int argc, const char ** argv) } // Synchronise the loop to 40 ms vpTime::wait(tms, 40) ; - } + return 0; } - catch(...) { - vpERROR_TRACE("Error during the framegrabbing..."); + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } } diff --git a/example/device/framegrabber/grabOpenCV-2.cpp b/example/device/framegrabber/grabOpenCV-2.cpp index c7d7e1e868000b893d664c1d02bd8197dbdfdea7..e6fca745eabf49d25f924b659fe1fa296fcd2ff5 100644 --- a/example/device/framegrabber/grabOpenCV-2.cpp +++ b/example/device/framegrabber/grabOpenCV-2.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: grabOpenCV-2.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: grabOpenCV-2.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -65,41 +65,47 @@ // 1 to dial with a second camera attached to the computer int main(int argc, char** argv) { - int device = 0; - if (argc > 1) - device = atoi(argv[1]); - - std::cout << "Use device: " << device << std::endl; - cv::VideoCapture cap(device); // open the default camera - cap.set(CV_CAP_PROP_FRAME_WIDTH, 640); - cap.set(CV_CAP_PROP_FRAME_HEIGHT, 480); - if(!cap.isOpened()) // check if we succeeded - return -1; - cv::Mat frame; - cap >> frame; // get a new frame from camera - - IplImage iplimage = frame; - std::cout << "Image size: " << iplimage.width << " " - << iplimage.height << std::endl; - - //vpImage<vpRGBa> I; // for color images - vpImage<unsigned char> I; // for gray images - vpImageConvert::convert(&iplimage, I); - vpDisplayOpenCV d(I); - - for(;;) { + try { + int device = 0; + if (argc > 1) + device = atoi(argv[1]); + + std::cout << "Use device: " << device << std::endl; + cv::VideoCapture cap(device); // open the default camera + cap.set(CV_CAP_PROP_FRAME_WIDTH, 640); + cap.set(CV_CAP_PROP_FRAME_HEIGHT, 480); + if(!cap.isOpened()) // check if we succeeded + return -1; + cv::Mat frame; cap >> frame; // get a new frame from camera - iplimage = frame; - // Convert the image in ViSP format and display it + IplImage iplimage = frame; + std::cout << "Image size: " << iplimage.width << " " + << iplimage.height << std::endl; + + //vpImage<vpRGBa> I; // for color images + vpImage<unsigned char> I; // for gray images vpImageConvert::convert(&iplimage, I); - vpDisplay::display(I); - vpDisplay::flush(I); - if (vpDisplay::getClick(I, false)) // a click to exit - break; + vpDisplayOpenCV d(I); + + for(;;) { + cap >> frame; // get a new frame from camera + iplimage = frame; + + // Convert the image in ViSP format and display it + vpImageConvert::convert(&iplimage, I); + vpDisplay::display(I); + vpDisplay::flush(I); + if (vpDisplay::getClick(I, false)) // a click to exit + break; + } + // the camera will be deinitialized automatically in VideoCapture destructor + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - // the camera will be deinitialized automatically in VideoCapture destructor - return 0; } #else diff --git a/example/device/framegrabber/grabOpenCV.cpp b/example/device/framegrabber/grabOpenCV.cpp index 012d5d4cc7a5cb0a7df634a8fef1bf9fca218554..2ca991e2d741d40855a15fc7254d5d347d75021f 100644 --- a/example/device/framegrabber/grabOpenCV.cpp +++ b/example/device/framegrabber/grabOpenCV.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: grabOpenCV.cpp 4088 2013-02-04 07:59:35Z fspindle $ + * $Id: grabOpenCV.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -63,6 +63,10 @@ // List of allowed command line options #define GETOPTARGS "dhn:o:D:" +void usage(const char *name, const char *badparam, unsigned int &nframes, std::string &opath); +bool getOptions(int argc, const char **argv, bool &display, + unsigned int &nframes, bool &save, std::string &opath, int &deviceType); + /*! Print the program options. @@ -126,33 +130,33 @@ OPTIONS: Default\n\ bool getOptions(int argc, const char **argv, bool &display, unsigned int &nframes, bool &save, std::string &opath, int &deviceType) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'd': display = false; break; case 'D': - if (strcmp( optarg ,"ANY") == 0 ) {deviceType = CV_CAP_ANY;} - else if ( strcmp( optarg ,"MIL") == 0) {deviceType = CV_CAP_MIL;} - else if ( strcmp( optarg ,"VFW") == 0) {deviceType = CV_CAP_VFW;} - else if ( strcmp( optarg ,"V4L") == 0) {deviceType = CV_CAP_V4L;} - else if ( strcmp( optarg ,"V4L2") == 0) {deviceType = CV_CAP_V4L2;} - else if ( strcmp( optarg ,"DC1394") == 0) {deviceType = CV_CAP_DC1394;} - else if ( strcmp( optarg ,"CMU1394") == 0) {deviceType = CV_CAP_CMU1394;} - else if ( strcmp( optarg ,"DSHOW") == 0) {deviceType = CV_CAP_DSHOW;} + if (strcmp( optarg_ ,"ANY") == 0 ) {deviceType = CV_CAP_ANY;} + else if ( strcmp( optarg_ ,"MIL") == 0) {deviceType = CV_CAP_MIL;} + else if ( strcmp( optarg_ ,"VFW") == 0) {deviceType = CV_CAP_VFW;} + else if ( strcmp( optarg_ ,"V4L") == 0) {deviceType = CV_CAP_V4L;} + else if ( strcmp( optarg_ ,"V4L2") == 0) {deviceType = CV_CAP_V4L2;} + else if ( strcmp( optarg_ ,"DC1394") == 0) {deviceType = CV_CAP_DC1394;} + else if ( strcmp( optarg_ ,"CMU1394") == 0) {deviceType = CV_CAP_CMU1394;} + else if ( strcmp( optarg_ ,"DSHOW") == 0) {deviceType = CV_CAP_DSHOW;} else {std::cout << "Unknown type of device" << std::endl; deviceType = 0;} break; case 'n': - nframes = (unsigned int)atoi(optarg); break; + nframes = (unsigned int)atoi(optarg_); break; case 'o': save = true; - opath = optarg; break; + opath = optarg_; break; case 'h': usage(argv[0], NULL, nframes, opath); return false; break; default: - usage(argv[0], optarg, nframes, opath); + usage(argv[0], optarg_, nframes, opath); return false; break; } } @@ -161,7 +165,7 @@ bool getOptions(int argc, const char **argv, bool &display, // standalone param or error usage(argv[0], NULL, nframes, opath); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -179,71 +183,71 @@ bool getOptions(int argc, const char **argv, bool &display, int main(int argc, const char ** argv) { - bool opt_display = true; - unsigned nframes = 50; - bool save = false; - int deviceType = CV_CAP_ANY; + try { + bool opt_display = true; + unsigned nframes = 50; + bool save = false; + int deviceType = CV_CAP_ANY; - // Declare an image. It size is not defined yet. It will be defined when the - // image will acquired the first time. + // 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<vpRGBa> I; // This is a color image (in RGBa format) + vpImage<vpRGBa> I; // This is a color image (in RGBa format) #else - vpImage<unsigned char> I; // This is a B&W image + vpImage<unsigned char> I; // This is a B&W image #endif - // Set default output image name for saving + // Set default output image name for saving #ifdef GRAB_COLOR - // Color images will be saved in PGM P6 format -# if defined(UNIX) - std::string opath = "/tmp/I%04d.ppm"; -# elif defined(WIN32) - std::string opath = "C:/temp/I%04d.ppm"; + // Color images will be saved in PGM P6 format +# if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX + std::string opath = "/tmp/I%04d.ppm"; +# elif defined(_WIN32) + std::string opath = "C:/temp/I%04d.ppm"; # endif #else - // B&W images will be saved in PGM P5 format -# if defined(UNIX) - std::string opath = "/tmp/I%04d.pgm"; -# elif defined(WIN32) - std::string opath = "C:/temp/I%04d.pgm"; + // B&W images will be saved in PGM P5 format +# if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX + std::string opath = "/tmp/I%04d.pgm"; +# elif defined(_WIN32) + std::string opath = "C:/temp/I%04d.pgm"; # endif #endif - // Read the command line options - if (getOptions(argc, argv, opt_display, nframes, save, opath, deviceType) == false) { - exit (-1); - } - // Create the grabber - vpOpenCVGrabber grabber ; - try { - // Set the type of device to detect. Here for example we expect to find a firewire camera. - grabber.setDeviceType(deviceType); + // Read the command line options + if (getOptions(argc, argv, opt_display, nframes, save, opath, deviceType) == false) { + exit (-1); + } + // Create the grabber + vpOpenCVGrabber grabber ; + try { + // Set the type of device to detect. Here for example we expect to find a firewire camera. + grabber.setDeviceType(deviceType); - // Initialize the grabber - grabber.open(I); + // Initialize the grabber + grabber.open(I); - // Acquire an image - grabber.acquire(I); - } - catch(...) - { - vpCTRACE << "Cannot acquire an image... " - << "Check if a camera is connected to your computer." - << std::endl ; - return 0; - } + // Acquire an image + grabber.acquire(I); + } + catch(...) + { + vpCTRACE << "Cannot acquire an image... " + << "Check if a camera is connected to your computer." + << std::endl ; + return 0; + } - std::cout << "Image size: width : " << I.getWidth() << " height: " - << I.getHeight() << std::endl; + std::cout << "Image size: width : " << I.getWidth() << " height: " + << I.getHeight() << std::endl; - // Creates a display - vpDisplayOpenCV display; + // Creates a display + vpDisplayOpenCV display; - if (opt_display) { - display.init(I,100,100,"OpenCV framegrabber"); - } + if (opt_display) { + display.init(I,100,100,"OpenCV framegrabber"); + } - try { double tbegin=0, tend=0, tloop=0, ttotal=0; ttotal = 0; @@ -275,11 +279,11 @@ main(int argc, const char ** argv) std::cout << "Mean loop time: " << ttotal / nframes << " ms" << std::endl; std::cout << "Mean frequency: " << 1000./(ttotal / nframes) << " fps" << std::endl; + return 0; } - catch(...) - { - vpCERROR << "Failure: exit" << std::endl; - return(-1); + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } } #else // defined (VISP_HAVE_OPENCV) diff --git a/example/device/framegrabber/grabV4l2.cpp b/example/device/framegrabber/grabV4l2.cpp index 3ed234a4dcf7b14ce44aa02a9256d2eba2eac310..51bbf5e20ac9173de3452509d7468caa923ab8c4 100644 --- a/example/device/framegrabber/grabV4l2.cpp +++ b/example/device/framegrabber/grabV4l2.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: grabV4l2.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: grabV4l2.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -235,39 +235,39 @@ bool getOptions(int argc, const char **argv, unsigned &fps, unsigned &input, int main(int argc, const char ** argv) { - unsigned int opt_fps = 25; - unsigned int opt_input = 0; - unsigned int opt_scale = 1; - vpV4l2Grabber::vpV4l2PixelFormatType opt_pixelformat = vpV4l2Grabber::V4L2_YUYV_FORMAT; - long opt_iter = 100; - bool opt_verbose = false; - bool opt_display = true; - char opt_device[20]; - bool opt_save = false; - sprintf(opt_device, "/dev/video0"); - // Default output path for image saving - std::string opt_opath = "/tmp/I%04d.ppm"; - - vpImage_type opt_image_type = color_image; - - // Read the command line options - if (getOptions(argc, argv, opt_fps, opt_input, opt_scale, opt_display, - opt_verbose, opt_iter, opt_device, - opt_pixelformat, opt_image_type, opt_save, opt_opath) == false) { - exit (-1); - } + try { + unsigned int opt_fps = 25; + unsigned int opt_input = 0; + unsigned int opt_scale = 1; + vpV4l2Grabber::vpV4l2PixelFormatType opt_pixelformat = vpV4l2Grabber::V4L2_YUYV_FORMAT; + long opt_iter = 100; + bool opt_verbose = false; + bool opt_display = true; + char opt_device[20]; + bool opt_save = false; + sprintf(opt_device, "/dev/video0"); + // Default output path for image saving + std::string opt_opath = "/tmp/I%04d.ppm"; + + vpImage_type opt_image_type = color_image; + + // Read the command line options + if (getOptions(argc, argv, opt_fps, opt_input, opt_scale, opt_display, + opt_verbose, opt_iter, opt_device, + opt_pixelformat, opt_image_type, opt_save, opt_opath) == false) { + exit (-1); + } - // Declare an image, this is a gray level image (unsigned char) and - // an other one that is a color image. There size is not defined - // yet. It will be defined when the image will acquired the first - // time. - vpImage<unsigned char> Ig ; // grey level image - vpImage<vpRGBa> Ic ; // color image + // Declare an image, this is a gray level image (unsigned char) and + // an other one that is a color image. There size is not defined + // yet. It will be defined when the image will acquired the first + // time. + vpImage<unsigned char> Ig ; // grey level image + vpImage<vpRGBa> Ic ; // color image - // Creates the grabber - vpV4l2Grabber g; + // Creates the grabber + vpV4l2Grabber g; - try{ // Initialize the grabber g.setVerboseMode(opt_verbose); g.setDevice(opt_device); @@ -294,28 +294,17 @@ main(int argc, const char ** argv) std::cout << "Color image size: width : " << Ic.getWidth() << " height: " << Ic.getHeight() << std::endl; } - } - catch (vpException e) { - std::cout << "Catched exception: " << e.getMessage() << std::endl; - return 0; - } - catch(...) - { - vpERROR_TRACE("Cannot acquire an image...") ; - return 0; - } - // We open a window using either X11 or GTK. - // Its size is automatically defined by the image (I) size + // We open a window using either X11 or GTK. + // Its size is automatically defined by the image (I) size #if defined VISP_HAVE_X11 - vpDisplayX display; + vpDisplayX display; #elif defined VISP_HAVE_GTK - vpDisplayGTK display; + vpDisplayGTK display; #endif - if (opt_display) { - try{ + if (opt_display) { // Display the image // The image class has a member that specify a pointer toward // the display that has been initialized in the display declaration @@ -331,18 +320,7 @@ main(int argc, const char ** argv) vpDisplay::display(Ic) ; vpDisplay::flush(Ic) ; } - } - catch (vpException e) { - std::cout << "Exception: " << e.getMessage() << std::endl; - } - catch(...) - { - vpERROR_TRACE("Error while displaying the image") ; - exit(-1); - } - } - try { // Acquisition loop long cpt = 1; while(cpt ++ < opt_iter) @@ -387,12 +365,12 @@ main(int argc, const char ** argv) } g.close(); + return 0; } - catch (vpException e) { - std::cout << "Exception: " << e.getMessage() << std::endl; - g.close(); + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - } #else int diff --git a/example/device/kinect/CMakeLists.txt b/example/device/kinect/CMakeLists.txt index 82b768410a3679bbe3d352fa305f7d728adaf637..3df40641df7b1227d03f2d835b8a8f3751cf4a60 100644 --- a/example/device/kinect/CMakeLists.txt +++ b/example/device/kinect/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/device/kinect/kinectAcquisition.cpp b/example/device/kinect/kinectAcquisition.cpp index 391bda7f93885d81e93fc9b4d7774587c4620832..695fdbfb58794545e414c27417e2cce78674072e 100644 --- a/example/device/kinect/kinectAcquisition.cpp +++ b/example/device/kinect/kinectAcquisition.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: kinectAcquisition.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: kinectAcquisition.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -64,62 +64,63 @@ #include <visp/vpTime.h> int main() { - // Init Kinect + try { + // Init Kinect #ifdef VISP_HAVE_LIBFREENECT_OLD - // This is the way to initialize Freenect with an old version of libfreenect packages under ubuntu lucid 10.04 - Freenect::Freenect<vpKinect> freenect; - vpKinect & kinect = freenect.createDevice(0); + // This is the way to initialize Freenect with an old version of libfreenect packages under ubuntu lucid 10.04 + Freenect::Freenect<vpKinect> freenect; + vpKinect & kinect = freenect.createDevice(0); #else - Freenect::Freenect freenect; - vpKinect & kinect = freenect.createDevice<vpKinect>(0); + Freenect::Freenect freenect; + vpKinect & kinect = freenect.createDevice<vpKinect>(0); #endif - // Set tilt angle in degrees - if (0) { - float angle = -3; - kinect.setTiltDegrees(angle); - } + // Set tilt angle in degrees + if (0) { + float angle = -3; + kinect.setTiltDegrees(angle); + } - // Init display + // Init display #if 1 - kinect.start(vpKinect::DMAP_MEDIUM_RES); // Start acquisition thread with a depth map resolution of 480x640 - vpImage<unsigned char> Idmap(480,640);//for medium resolution - vpImage<float> dmap(480,640);//for medium resolution + kinect.start(vpKinect::DMAP_MEDIUM_RES); // Start acquisition thread with a depth map resolution of 480x640 + vpImage<unsigned char> Idmap(480,640);//for medium resolution + vpImage<float> dmap(480,640);//for medium resolution #else - kinect.start(vpKinect::DMAP_LOW_RES); // Start acquisition thread with a depth map resolution of 240x320 (default resolution) - vpImage<unsigned char> Idmap(240,320);//for low resolution - vpImage<float> dmap(240,320);//for low resolution + kinect.start(vpKinect::DMAP_LOW_RES); // Start acquisition thread with a depth map resolution of 240x320 (default resolution) + vpImage<unsigned char> Idmap(240,320);//for low resolution + vpImage<float> dmap(240,320);//for low resolution #endif - vpImage<vpRGBa> Irgb(480,640),Iwarped(480,640); + vpImage<vpRGBa> Irgb(480,640),Iwarped(480,640); #if defined VISP_HAVE_X11 - vpDisplayX display, displayRgb, displayRgbWarped; + vpDisplayX display, displayRgb, displayRgbWarped; #elif defined VISP_HAVE_GTK - vpDisplayGTK display; - vpDisplayGTK displayRgb; - vpDisplayGTK displayRgbWarped; + vpDisplayGTK display; + vpDisplayGTK displayRgb; + vpDisplayGTK displayRgbWarped; #elif defined VISP_HAVE_OPENCV - vpDisplayOpenCV display; - vpDisplayOpenCV displayRgb; - vpDisplayOpenCV displayRgbWarped; + vpDisplayOpenCV display; + vpDisplayOpenCV displayRgb; + vpDisplayOpenCV displayRgbWarped; #elif defined VISP_HAVE_GDI - vpDisplayGDI display; - vpDisplayGDI displayRgb; - vpDisplayGDI displayRgbWarped; + vpDisplayGDI display; + vpDisplayGDI displayRgb; + vpDisplayGDI displayRgbWarped; #endif - display.init(Idmap, 100, 200,"Depth map"); - displayRgb.init(Irgb, 900, 200,"Color Image"); - displayRgbWarped.init(Iwarped,900,700,"Warped Color Image"); + display.init(Idmap, 100, 200,"Depth map"); + displayRgb.init(Irgb, 900, 200,"Color Image"); + displayRgbWarped.init(Iwarped,900,700,"Warped Color Image"); - // A click to stop acquisition - std::cout << "Click in one image to stop acquisition" << std::endl; + // A click to stop acquisition + std::cout << "Click in one image to stop acquisition" << std::endl; - while(!vpDisplay::getClick(Idmap,false) && !vpDisplay::getClick(Irgb,false)) - { - kinect.getDepthMap(dmap); - kinect.getDepthMap(dmap, Idmap); - kinect.getRGB(Irgb); + while(!vpDisplay::getClick(Idmap,false) && !vpDisplay::getClick(Irgb,false)) + { + kinect.getDepthMap(dmap); + kinect.getDepthMap(dmap, Idmap); + kinect.getRGB(Irgb); vpDisplay::display(Idmap); vpDisplay::flush(Idmap); @@ -128,12 +129,21 @@ int main() { //Warped RGB image: kinect.warpRGBFrame(Irgb,dmap, Iwarped); - vpDisplay::display(Iwarped); - vpDisplay::flush(Iwarped); - } - std::cout << "Stop acquisition" << std::endl; - kinect.stop(); // Stop acquisition thread - return 0; + vpDisplay::display(Iwarped); + vpDisplay::flush(Iwarped); + } + std::cout << "Stop acquisition" << std::endl; + kinect.stop(); // Stop acquisition thread + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } + catch(...) { + std::cout << "Catch an exception " << std::endl; + return 1; + } } #else diff --git a/example/device/laserscanner/CMakeLists.txt b/example/device/laserscanner/CMakeLists.txt index 192ea37e873cfe6143c86d50d24d2bf1c2002e32..4f8e78d6aa7d37ac6a3d72b6431fbcdcd186c367 100644 --- a/example/device/laserscanner/CMakeLists.txt +++ b/example/device/laserscanner/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/device/laserscanner/SickLDMRS-Acq.cpp b/example/device/laserscanner/SickLDMRS-Acq.cpp index bf81bbbd7bd2718165cb499b3631bf6663397c46..940a7ac0ceac60a0e81d816354257ec4d64d78b0 100644 --- a/example/device/laserscanner/SickLDMRS-Acq.cpp +++ b/example/device/laserscanner/SickLDMRS-Acq.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: SickLDMRS-Acq.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: SickLDMRS-Acq.cpp 4604 2014-01-21 14:15:23Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -55,28 +55,34 @@ #include <visp/vpParseArgv.h> -#if ( defined(UNIX) && ( ! defined(WIN32) ) ) +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) int main() { - vpSickLDMRS laser; - std::string ip = "131.254.12.119"; - - laser.setIpAddress(ip); - laser.setup(); - unsigned long int iter = 0; + try { + vpSickLDMRS laser; + std::string ip = "131.254.12.119"; - for ( ; ; ) { - double t1 = vpTime::measureTimeMs(); - vpLaserScan laserscan[4]; - if (laser.measure(laserscan) == false) - continue; - - iter ++; - std::cout << "iter: " << iter << " time: " - << vpTime::measureTimeMs() - t1 << " ms" << std::endl; + laser.setIpAddress(ip); + laser.setup(); + unsigned long int iter = 0; + + for ( ; ; ) { + double t1 = vpTime::measureTimeMs(); + vpLaserScan laserscan[4]; + if (laser.measure(laserscan) == false) + continue; + + iter ++; + std::cout << "iter: " << iter << " time: " + << vpTime::measureTimeMs() - t1 << " ms" << std::endl; + } + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - return 0; } #else // #ifdef UNIX diff --git a/example/device/laserscanner/SickLDMRS-Process.cpp b/example/device/laserscanner/SickLDMRS-Process.cpp index c4f43b9b0647d2964113fdac5823f6b38058349e..9a2ad7bad095330df3c1cfabf76c85d07eced7a1 100644 --- a/example/device/laserscanner/SickLDMRS-Process.cpp +++ b/example/device/laserscanner/SickLDMRS-Process.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: SickLDMRS-Process.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: SickLDMRS-Process.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -74,7 +74,7 @@ #include <visp/vp1394TwoGrabber.h> #include <visp/vpIoTools.h> -#if ( defined(UNIX) && ( ! defined(WIN32) ) ) && (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK)) +#if ( !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) ) && (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK)) static int save = 0; static int layerToDisplay = 0xF; // 0xF = 1111 => all the layers are selected @@ -85,6 +85,9 @@ pthread_mutex_t shm_mutex; #endif std::string output_path; +void *laser_display_and_save_loop(void *); +void *laser_acq_loop(void *); +void *camera_acq_and_display_loop(void *); void *laser_display_and_save_loop(void *) { @@ -307,60 +310,66 @@ void *camera_acq_and_display_loop(void *) int main(int argc, const char ** argv) { - output_path = "data"; - // Test if the output path directory exist. If no try to create it - if (vpIoTools::checkDirectory(output_path) == false) { - try { - // Create a directory with name "username" - vpIoTools::makeDirectory(output_path); + try { + output_path = "data"; + // Test if the output path directory exist. If no try to create it + if (vpIoTools::checkDirectory(output_path) == false) { + try { + // Create a directory with name "username" + vpIoTools::makeDirectory(output_path); + } + catch (...) { + std::cout << "Cannot create " << output_path << " directory" << std::endl; + return false; + } } - catch (...) { - std::cout << "Cannot create " << output_path << " directory" << std::endl; - return false; + + // Parse the command line to set the variables + vpParseArgv::vpArgvInfo argTable[] = + { + {"-layer", vpParseArgv::ARGV_INT, (char*) NULL, (char *) &layerToDisplay, + "The layer to display:\n" + "\t\t. 0x1 for layer 1.\n" + "\t\t. 0x2 for layer 2.\n" + "\t\t. 0x4 for layer 3.\n" + "\t\t. 0x8 for layer 4.\n" + "\t\tTo display all the layers you should set 0xF value." + }, + {"-save", vpParseArgv::ARGV_INT, (char*) NULL, (char *) &save, + "Turn to 1 in order to save data." + }, + {"-h", vpParseArgv::ARGV_HELP, (char*) NULL, (char *) NULL, + "Display one or more measured layers form a Sick LD-MRS laser scanner."}, + {(char*) NULL, vpParseArgv::ARGV_END, (char*) NULL, (char*) NULL, (char*) NULL} + } ; + + // Read the command line options + if(vpParseArgv::parse(&argc, argv, argTable, + vpParseArgv::ARGV_NO_LEFTOVERS | + vpParseArgv::ARGV_NO_ABBREV | + vpParseArgv::ARGV_NO_DEFAULTS)) { + return (false); } - } - // Parse the command line to set the variables - vpParseArgv::vpArgvInfo argTable[] = - { - {"-layer", vpParseArgv::ARGV_INT, (char*) NULL, (char *) &layerToDisplay, - "The layer to display:\n" - "\t\t. 0x1 for layer 1.\n" - "\t\t. 0x2 for layer 2.\n" - "\t\t. 0x4 for layer 3.\n" - "\t\t. 0x8 for layer 4.\n" - "\t\tTo display all the layers you should set 0xF value." - }, - {"-save", vpParseArgv::ARGV_INT, (char*) NULL, (char *) &save, - "Turn to 1 in order to save data." - }, - {"-h", vpParseArgv::ARGV_HELP, (char*) NULL, (char *) NULL, - "Display one or more measured layers form a Sick LD-MRS laser scanner."}, - {(char*) NULL, vpParseArgv::ARGV_END, (char*) NULL, (char*) NULL, (char*) NULL} - } ; - - // Read the command line options - if(vpParseArgv::parse(&argc, argv, argTable, - vpParseArgv::ARGV_NO_LEFTOVERS | - vpParseArgv::ARGV_NO_ABBREV | - vpParseArgv::ARGV_NO_DEFAULTS)) { - return (false); - } - - time_offset = vpTime::measureTimeSecond(); + time_offset = vpTime::measureTimeSecond(); #ifdef VISP_HAVE_PTHREAD - pthread_t thread_camera_acq; - pthread_t thread_laser_acq; - pthread_t thread_laser_display; - pthread_create(&thread_camera_acq, NULL, &camera_acq_and_display_loop, NULL); - pthread_create(&thread_laser_acq, NULL, &laser_acq_loop, NULL); - pthread_create(&thread_laser_display, NULL, &laser_display_and_save_loop, NULL); - pthread_join(thread_camera_acq, 0); - pthread_join(thread_laser_acq, 0); - pthread_join(thread_laser_display, 0); + pthread_t thread_camera_acq; + pthread_t thread_laser_acq; + pthread_t thread_laser_display; + pthread_create(&thread_camera_acq, NULL, &camera_acq_and_display_loop, NULL); + pthread_create(&thread_laser_acq, NULL, &laser_acq_loop, NULL); + pthread_create(&thread_laser_display, NULL, &laser_display_and_save_loop, NULL); + pthread_join(thread_camera_acq, 0); + pthread_join(thread_laser_acq, 0); + pthread_join(thread_laser_display, 0); #endif - return 0; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } #else // #ifdef UNIX and display diff --git a/example/device/light/CMakeLists.txt b/example/device/light/CMakeLists.txt index 52bbd0dbc03098052a534ac643abc8565a5e52ee..ca12b77565d39f73e26a5219d699463377d9ced2 100644 --- a/example/device/light/CMakeLists.txt +++ b/example/device/light/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/device/light/ringLight.cpp b/example/device/light/ringLight.cpp index f9307a2965d861ea740c490c43fb39a04644ca0f..324ea0388c0d7497292c3084f8f15272b18bef34 100644 --- a/example/device/light/ringLight.cpp +++ b/example/device/light/ringLight.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: ringLight.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: ringLight.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -166,15 +166,15 @@ bool getOptions(int argc, const char **argv, bool &on, int &nsec, double &nmsec) 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 { + 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); + } vpRingLight light; diff --git a/example/direct-visual-servoing/CMakeLists.txt b/example/direct-visual-servoing/CMakeLists.txt index 1df6f762f1ebc6031ea520bf91871282ce1068cc..f70cd77eea1df1107ea936d3e6e25e06ad7f45ec 100644 --- a/example/direct-visual-servoing/CMakeLists.txt +++ b/example/direct-visual-servoing/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/direct-visual-servoing/photometricVisualServoing.cpp b/example/direct-visual-servoing/photometricVisualServoing.cpp index 2027f6498ad6290bd0d7f25d4fca253b1dd98943..1686d88fbd22756a1918ed779b63eb40f0468403 100755 --- a/example/direct-visual-servoing/photometricVisualServoing.cpp +++ b/example/direct-visual-servoing/photometricVisualServoing.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: photometricVisualServoing.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: photometricVisualServoing.cpp 4664 2014-02-16 16:17:54Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -41,10 +41,7 @@ /*! \example photometricVisualServoing.cpp - Implemented from C. Collewet, E. Marchand, F. Chaumette. Visual - servoing set free from image processing. In IEEE Int. Conf. on - Robotics and Automation, ICRA'08, Pages 81-86, Pasadena, Californie, - Mai 2008. + Implemented from \cite Collewet08c. */ @@ -79,6 +76,10 @@ // List of allowed command line options #define GETOPTARGS "cdi:n:h" +void usage(const char *name, const char *badparam, std::string ipath, int niter); +bool getOptions(int argc, const char **argv, std::string &ipath, + bool &click_allowed, bool &display, int &niter); + /*! Print the program options. @@ -141,19 +142,19 @@ OPTIONS: Default\n\ bool getOptions(int argc, const char **argv, std::string &ipath, bool &click_allowed, bool &display, int &niter) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; case 'd': display = false; break; - case 'i': ipath = optarg; break; - case 'n': niter = atoi(optarg); break; + case 'i': ipath = optarg_; break; + case 'n': niter = atoi(optarg_); break; case 'h': usage(argv[0], NULL, ipath, niter); return false; break; default: - usage(argv[0], optarg, ipath, niter); + usage(argv[0], optarg_, ipath, niter); return false; break; } } @@ -162,7 +163,7 @@ bool getOptions(int argc, const char **argv, std::string &ipath, // standalone param or error usage(argv[0], NULL, ipath, niter); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -174,321 +175,328 @@ bool getOptions(int argc, const char **argv, std::string &ipath, int main(int argc, const char ** argv) { - std::string env_ipath; - std::string opt_ipath; - std::string ipath; - std::string filename; - bool opt_click_allowed = true; - bool opt_display = true; - int opt_niter = 400; - - // 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_click_allowed, - opt_display, opt_niter) == false) { - return (-1); - } + try { + std::string env_ipath; + std::string opt_ipath; + std::string ipath; + std::string filename; + bool opt_click_allowed = true; + bool opt_display = true; + int opt_niter = 400; + + // 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_click_allowed, + opt_display, opt_niter) == false) { + return (-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 <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + // 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 <visp image path=" << ipath << "> " + << " 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, opt_niter); - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Use -i <visp image path> 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); - } + // Test if an input path is set + if (opt_ipath.empty() && env_ipath.empty()){ + usage(argv[0], NULL, ipath, opt_niter); + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Use -i <visp image path> 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); + } + + vpImage<unsigned char> Itexture ; + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); + vpImageIo::read(Itexture,filename) ; + + vpColVector X[4]; + for (int i = 0; i < 4; i++) X[i].resize(3); + // Top left corner + X[0][0] = -0.3; + X[0][1] = -0.215; + X[0][2] = 0; + + // Top right corner + X[1][0] = 0.3; + X[1][1] = -0.215; + X[1][2] = 0; + + // Bottom right corner + X[2][0] = 0.3; + X[2][1] = 0.215; + X[2][2] = 0; + + //Bottom left corner + X[3][0] = -0.3; + X[3][1] = 0.215; + X[3][2] = 0; + + vpImageSimulator sim; + + sim.setInterpolationType(vpImageSimulator::BILINEAR_INTERPOLATION) ; + sim.init(Itexture, X); + + + - vpImage<unsigned char> Itexture ; - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); - vpImageIo::read(Itexture,filename) ; - - vpColVector X[4]; - for (int i = 0; i < 4; i++) X[i].resize(3); - // Top left corner - X[0][0] = -0.3; - X[0][1] = -0.215; - X[0][2] = 0; - - // Top right corner - X[1][0] = 0.3; - X[1][1] = -0.215; - X[1][2] = 0; - - // Bottom right corner - X[2][0] = 0.3; - X[2][1] = 0.215; - X[2][2] = 0; - - //Bottom left corner - X[3][0] = -0.3; - X[3][1] = 0.215; - X[3][2] = 0; - - vpImageSimulator sim; - - sim.setInterpolationType(vpImageSimulator::BILINEAR_INTERPOLATION) ; - sim.init(Itexture, X); - - - - - vpCameraParameters cam(870, 870, 160, 120); - - // ---------------------------------------------------------- - // Create the framegraber (here a simulated image) - vpImage<unsigned char> I(240,320,0) ; - vpImage<unsigned char> Id ; - - //camera desired position - vpHomogeneousMatrix cdMo ; - cdMo[2][3] = 1 ; - - //set the robot at the desired position - sim.setCameraPosition(cdMo) ; - sim.getImage(I,cam); // and aquire the image Id - Id = I ; - - - // display the image + vpCameraParameters cam(870, 870, 160, 120); + + // ---------------------------------------------------------- + // Create the framegraber (here a simulated image) + vpImage<unsigned char> I(240,320,0) ; + vpImage<unsigned char> Id ; + + //camera desired position + vpHomogeneousMatrix cdMo ; + cdMo[2][3] = 1 ; + + //set the robot at the desired position + sim.setCameraPosition(cdMo) ; + sim.getImage(I,cam); // and aquire the image Id + Id = I ; + + + // display the image #if defined VISP_HAVE_X11 - vpDisplayX d; + vpDisplayX d; #elif defined VISP_HAVE_GDI - vpDisplayGDI d; + vpDisplayGDI d; #elif defined VISP_HAVE_GTK - vpDisplayGTK d; + vpDisplayGTK d; #endif #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK) - if (opt_display) { - d.init(I, 20, 10, "Photometric visual servoing : s") ; - vpDisplay::display(I); - vpDisplay::flush(I); - } - if (opt_display && opt_click_allowed) { - std::cout << "Click in the image to continue..." << std::endl; - vpDisplay::getClick(I) ; - } + if (opt_display) { + d.init(I, 20, 10, "Photometric visual servoing : s") ; + vpDisplay::display(I); + vpDisplay::flush(I); + } + if (opt_display && opt_click_allowed) { + std::cout << "Click in the image to continue..." << std::endl; + vpDisplay::getClick(I) ; + } #endif - // ---------------------------------------------------------- - // position the robot at the initial position - // ---------------------------------------------------------- + // ---------------------------------------------------------- + // position the robot at the initial position + // ---------------------------------------------------------- + + //camera desired position + vpHomogeneousMatrix cMo ; + cMo.buildFrom(0,0,1.2,vpMath::rad(15),vpMath::rad(-5),vpMath::rad(20)); + + //set the robot at the desired position + sim.setCameraPosition(cMo) ; + I =0 ; + sim.getImage(I,cam); // and aquire the image Id - //camera desired position - vpHomogeneousMatrix cMo ; - cMo.buildFrom(0,0,1.2,vpMath::rad(15),vpMath::rad(-5),vpMath::rad(20)); - - //set the robot at the desired position - sim.setCameraPosition(cMo) ; - I =0 ; - sim.getImage(I,cam); // and aquire the image Id - #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK) - if (opt_display) { - vpDisplay::display(I) ; - vpDisplay::flush(I) ; - } - if (opt_display && opt_click_allowed) { - std::cout << "Click in the image to continue..." << std::endl; - vpDisplay::getClick(I) ; - } + if (opt_display) { + vpDisplay::display(I) ; + vpDisplay::flush(I) ; + } + if (opt_display && opt_click_allowed) { + std::cout << "Click in the image to continue..." << std::endl; + vpDisplay::getClick(I) ; + } #endif - vpImage<unsigned char> Idiff ; - Idiff = I ; + vpImage<unsigned char> Idiff ; + Idiff = I ; - vpImageTools::imageDifference(I,Id,Idiff) ; + vpImageTools::imageDifference(I,Id,Idiff) ; - // Affiche de l'image de difference + // Affiche de l'image de difference #if defined VISP_HAVE_X11 - vpDisplayX d1; + vpDisplayX d1; #elif defined VISP_HAVE_GDI - vpDisplayGDI d1; + vpDisplayGDI d1; #elif defined VISP_HAVE_GTK - vpDisplayGTK d1; + vpDisplayGTK d1; #endif #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK) - if (opt_display) { - d1.init(Idiff, 40+(int)I.getWidth(), 10, "photometric visual servoing : s-s* ") ; - vpDisplay::display(Idiff) ; - vpDisplay::flush(Idiff) ; - } + if (opt_display) { + d1.init(Idiff, 40+(int)I.getWidth(), 10, "photometric visual servoing : s-s* ") ; + vpDisplay::display(Idiff) ; + vpDisplay::flush(Idiff) ; + } #endif - // create the robot (here a simulated free flying camera) - vpRobotCamera robot ; - robot.setSamplingTime(0.04); - robot.setPosition(cMo) ; + // create the robot (here a simulated free flying camera) + vpRobotCamera robot ; + robot.setSamplingTime(0.04); + robot.setPosition(cMo) ; + + // ------------------------------------------------------ + // Visual feature, interaction matrix, error + // s, Ls, Lsd, Lt, Lp, etc + // ------------------------------------------------------ + + // current visual feature built from the image + // (actually, this is the image...) + vpFeatureLuminance sI ; + sI.init( I.getHeight(), I.getWidth(), Z) ; + sI.setCameraParameters(cam) ; + sI.buildFrom(I) ; + - // ------------------------------------------------------ - // Visual feature, interaction matrix, error - // s, Ls, Lsd, Lt, Lp, etc - // ------------------------------------------------------ + // desired visual feature built from the image + vpFeatureLuminance sId ; + sId.init(I.getHeight(), I.getWidth(), Z) ; + sId.setCameraParameters(cam) ; + sId.buildFrom(Id) ; - // current visual feature built from the image - // (actually, this is the image...) - vpFeatureLuminance sI ; - sI.init( I.getHeight(), I.getWidth(), Z) ; - sI.setCameraParameters(cam) ; - sI.buildFrom(I) ; - - // desired visual feature built from the image - vpFeatureLuminance sId ; - sId.init(I.getHeight(), I.getWidth(), Z) ; - sId.setCameraParameters(cam) ; - sId.buildFrom(Id) ; + // Matrice d'interaction, Hessien, erreur,... + vpMatrix Lsd; // matrice d'interaction a la position desiree + vpMatrix Hsd; // hessien a la position desiree + vpMatrix H ; // Hessien utilise pour le levenberg-Marquartd + vpColVector error ; // Erreur I-I* - - // Matrice d'interaction, Hessien, erreur,... - vpMatrix Lsd; // matrice d'interaction a la position desiree - vpMatrix Hsd; // hessien a la position desiree - vpMatrix H ; // Hessien utilise pour le levenberg-Marquartd - vpColVector error ; // Erreur I-I* + // Compute the interaction matrix + // link the variation of image intensity to camera motion - // Compute the interaction matrix - // link the variation of image intensity to camera motion + // here it is computed at the desired position + sId.interaction(Lsd) ; - // here it is computed at the desired position - sId.interaction(Lsd) ; - - // Compute the Hessian H = L^TL - Hsd = Lsd.AtA() ; + // Compute the Hessian H = L^TL + Hsd = Lsd.AtA() ; - // Compute the Hessian diagonal for the Levenberg-Marquartd - // optimization process - unsigned int n = 6 ; - vpMatrix diagHsd(n,n) ; - diagHsd.eye(n); - for(unsigned int i = 0 ; i < n ; i++) diagHsd[i][i] = Hsd[i][i]; + // Compute the Hessian diagonal for the Levenberg-Marquartd + // optimization process + unsigned int n = 6 ; + vpMatrix diagHsd(n,n) ; + diagHsd.eye(n); + for(unsigned int i = 0 ; i < n ; i++) diagHsd[i][i] = Hsd[i][i]; - // ------------------------------------------------------ - // Control law - double lambda ; //gain - vpColVector e ; - vpColVector v ; // camera velocity send to the robot + // ------------------------------------------------------ + // Control law + double lambda ; //gain + vpColVector e ; + vpColVector v ; // camera velocity send to the robot - // ---------------------------------------------------------- - // Minimisation + // ---------------------------------------------------------- + // Minimisation - double mu ; // mu = 0 : Gauss Newton ; mu != 0 : LM - double lambdaGN; + double mu ; // mu = 0 : Gauss Newton ; mu != 0 : LM + double lambdaGN; - mu = 0.01; - lambda = 30 ; - lambdaGN = 30; + mu = 0.01; + lambda = 30 ; + lambdaGN = 30; - // set a velocity control mode - robot.setRobotState(vpRobot::STATE_VELOCITY_CONTROL) ; + // set a velocity control mode + robot.setRobotState(vpRobot::STATE_VELOCITY_CONTROL) ; - // ---------------------------------------------------------- - int iter = 1; - int iterGN = 90 ; // swicth to Gauss Newton after iterGN iterations - - double normeError = 0; - do - { + // ---------------------------------------------------------- + int iter = 1; + int iterGN = 90 ; // swicth to Gauss Newton after iterGN iterations - std::cout << "--------------------------------------------" << iter++ << std::endl ; + double normeError = 0; + do + { + std::cout << "--------------------------------------------" << iter++ << std::endl ; - // Acquire the new image - sim.setCameraPosition(cMo) ; - sim.getImage(I,cam) ; + + // Acquire the new image + sim.setCameraPosition(cMo) ; + sim.getImage(I,cam) ; #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK) - if (opt_display) { - vpDisplay::display(I) ; - vpDisplay::flush(I) ; - } + if (opt_display) { + vpDisplay::display(I) ; + vpDisplay::flush(I) ; + } #endif - vpImageTools::imageDifference(I,Id,Idiff) ; + vpImageTools::imageDifference(I,Id,Idiff) ; #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_GTK) - if (opt_display) { - vpDisplay::display(Idiff) ; - vpDisplay::flush(Idiff) ; - } + if (opt_display) { + vpDisplay::display(Idiff) ; + vpDisplay::flush(Idiff) ; + } #endif - // Compute current visual feature - sI.buildFrom(I) ; + // Compute current visual feature + sI.buildFrom(I) ; - // compute current error - sI.error(sId,error) ; + // compute current error + sI.error(sId,error) ; - normeError = (error.sumSquare()); - std::cout << "|e| "<<normeError <<std::endl ; + normeError = (error.sumSquare()); + std::cout << "|e| "<<normeError <<std::endl ; - // double t = vpTime::measureTimeMs() ; + // double t = vpTime::measureTimeMs() ; - // ---------- Levenberg Marquardt method -------------- - { - if (iter > iterGN) + // ---------- Levenberg Marquardt method -------------- { - mu = 0.0001 ; - lambda = lambdaGN; + if (iter > iterGN) + { + mu = 0.0001 ; + lambda = lambdaGN; + } + + // Compute the levenberg Marquartd term + { + H = ((mu * diagHsd) + Hsd).inverseByLU(); + } + // compute the control law + e = H * Lsd.t() *error ; + + v = - lambda*e; } - // Compute the levenberg Marquartd term - { - H = ((mu * diagHsd) + Hsd).inverseByLU(); - } - // compute the control law - e = H * Lsd.t() *error ; + std::cout << "lambda = " << lambda << " mu = " << mu ; + std::cout << " |Tc| = " << sqrt(v.sumSquare()) << std::endl; - v = - lambda*e; - } + // send the robot velocity + robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + robot.getPosition(cMo) ; - std::cout << "lambda = " << lambda << " mu = " << mu ; - std::cout << " |Tc| = " << sqrt(v.sumSquare()) << std::endl; + } + while(normeError > 10000 && iter < opt_niter); - // send the robot velocity + v = 0 ; robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; - robot.getPosition(cMo) ; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - while(normeError > 10000 && iter < opt_niter); - - v = 0 ; - robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; - } diff --git a/example/homography/CMakeLists.txt b/example/homography/CMakeLists.txt index 39967e825c775f5b9dd839fca83f2a2dd00a50d2..06e81b36b267b2131405a06787b92e172e04354f 100644 --- a/example/homography/CMakeLists.txt +++ b/example/homography/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/homography/homographyHLM2DObject.cpp b/example/homography/homographyHLM2DObject.cpp index 34e62d4cd86dbe43ffee074928726c7e29c4028f..3966301a00e861d0e852f6019f2196b859b2f01c 100644 --- a/example/homography/homographyHLM2DObject.cpp +++ b/example/homography/homographyHLM2DObject.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: homographyHLM2DObject.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: homographyHLM2DObject.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -73,6 +73,9 @@ #define L 0.1 #define nbpt 5 +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); + /*! Print the program options. @@ -112,15 +115,15 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -129,7 +132,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -140,124 +143,79 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } - - int i ; + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } - vpPoint P[nbpt] ; // Point to be tracked - double xa[nbpt], ya[nbpt] ; - double xb[nbpt], yb[nbpt] ; + vpPoint P[nbpt] ; // Point to be tracked + std::vector<double> xa(nbpt), ya(nbpt) ; + std::vector<double> xb(nbpt), yb(nbpt) ; - vpPoint aP[nbpt] ; // Point to be tracked - vpPoint bP[nbpt] ; // Point to be tracked + 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[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() ; - } + 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(unsigned int 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 << "-------------------------------" <<std::endl ; - std::cout << "aMb "<<std::endl <<aMb << std::endl ; - std::cout << "-------------------------------" <<std::endl ; - vpHomography aHb ; - - vpHomography::HLM(nbpt,xb,yb,xa,ya,true, aHb) ; - - vpTRACE("aHb computed using the Malis paralax algorithm") ; - aHb /= aHb[2][2] ; - std::cout << std::endl << aHb<< std::endl ; - - vpRotationMatrix aRb ; - vpTranslationVector aTb ; - vpColVector n ; - - std::cout << "-------------------------------" <<std::endl ; - vpTRACE("extract R, T and n ") ; - aHb.computeDisplacement(aRb, aTb, n) ; - std::cout << "Rotation: aRb" <<std::endl ; - std::cout << aRb << std::endl ; - std::cout << "Translation: aTb" <<std::endl; - std::cout << (aTb).t() <<std::endl ; - std::cout << "Normal to the plane: n" <<std::endl; - std::cout << (n).t() <<std::endl ; - - - std::cout << "-------------------------------" <<std::endl ; - vpTRACE("Compare with built homography H = R + t/d ") ; - vpPlane bp(0,0,1,1) ; - vpHomography aHb_built(aMb,bp) ; - vpTRACE( "aHb built from the displacement ") ; - std::cout << std::endl <<aHb_built/aHb_built[2][2] << std::endl ; - - aHb_built.computeDisplacement(aRb, aTb, n) ; - std::cout << "Rotation: aRb" <<std::endl ; - std::cout << aRb << std::endl ; - std::cout << "Translation: aTb" <<std::endl; - std::cout << (aTb).t() <<std::endl ; - std::cout << "Normal to the plane: n" <<std::endl; - std::cout << (n).t() <<std::endl ; - - std::cout << "-------------------------------" <<std::endl ; - vpTRACE("test if ap = aHb bp") ; - - for(i=0 ; i < nbpt ; i++) - { - std::cout << "Point "<< i<< std::endl ; - vpPoint p ; - std::cout << "(" ; - std::cout << aP[i].get_x()/aP[i].get_w()<<", "<< aP[i].get_y()/aP[i].get_w() ; - std::cout <<") = (" ; - p = aHb*bP[i] ; - std::cout << p.get_x() /p.get_w()<<", "<< p.get_y()/ p.get_w() <<")"<<std::endl ; - } + for(unsigned int 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 << "-------------------------------" <<std::endl ; + std::cout << "aMb "<<std::endl <<aMb << std::endl ; + std::cout << "-------------------------------" <<std::endl ; + vpHomography aHb ; + + vpHomography::HLM(xb, yb, xa, ya, true, aHb) ; - std::cout << "-------------------------------" <<std::endl ; - vpTRACE("test displacement") ; + aHb /= aHb[2][2] ; + std::cout << "aHb computed using the Malis paralax algorithm: \n" << aHb<< std::endl ; - std::list<vpRotationMatrix> laRb ; - std::list<vpTranslationVector> laTb ; - std::list<vpColVector> lnb ; + vpRotationMatrix aRb ; + vpTranslationVector aTb ; + vpColVector n ; - vpHomography::computeDisplacement(aHb,bP[0].get_x(),bP[0].get_y(), - laRb, laTb, lnb) ; + std::cout << "-------------------------------" <<std::endl ; + std::cout << "extract R, T and n " << std::endl; + aHb.computeDisplacement(aRb, aTb, n) ; + std::cout << "Rotation: aRb" <<std::endl ; + std::cout << aRb << std::endl ; + std::cout << "Translation: aTb" <<std::endl; + std::cout << (aTb).t() <<std::endl ; + std::cout << "Normal to the plane: n" <<std::endl; + std::cout << (n).t() <<std::endl ; - std::list<vpRotationMatrix>::const_iterator it_laRb = laRb.begin(); - std::list<vpTranslationVector>::const_iterator it_laTb = laTb.begin(); - std::list<vpColVector>::const_iterator it_lnb = lnb.begin(); - int k =1 ; - while (it_lnb != lnb.end()) - { - std::cout << "Solution " << k++ << std::endl ; + std::cout << "-------------------------------" <<std::endl ; + std::cout << "Compare with built homography H = R + t/d " << std::endl ; + vpPlane bp(0,0,1,1) ; + vpHomography aHb_built(aMb,bp) ; + std::cout << "aHb built from the displacement " << std::endl ; + std::cout << std::endl <<aHb_built/aHb_built[2][2] << std::endl ; - aRb = *it_laRb; - aTb = *it_laTb; - n = *it_lnb; + aHb_built.computeDisplacement(aRb, aTb, n) ; std::cout << "Rotation: aRb" <<std::endl ; std::cout << aRb << std::endl ; std::cout << "Translation: aTb" <<std::endl; @@ -265,9 +223,57 @@ main(int argc, const char ** argv) std::cout << "Normal to the plane: n" <<std::endl; std::cout << (n).t() <<std::endl ; - ++ it_laRb; - ++ it_laTb; - ++ it_lnb; - } + std::cout << "-------------------------------" << std::endl ; + std::cout << "test if ap = aHb bp" << std::endl ; + + for(unsigned int i=0 ; i < nbpt ; i++) + { + std::cout << "Point "<< i<< std::endl ; + vpPoint p ; + std::cout << "(" ; + std::cout << aP[i].get_x()/aP[i].get_w()<<", "<< aP[i].get_y()/aP[i].get_w() ; + std::cout <<") = (" ; + p = aHb*bP[i] ; + std::cout << p.get_x() /p.get_w()<<", "<< p.get_y()/ p.get_w() <<")"<<std::endl ; + } + std::cout << "-------------------------------" <<std::endl ; + std::cout << "test displacement" << std::endl ; + + std::list<vpRotationMatrix> laRb ; + std::list<vpTranslationVector> laTb ; + std::list<vpColVector> lnb ; + + vpHomography::computeDisplacement(aHb,bP[0].get_x(),bP[0].get_y(), + laRb, laTb, lnb) ; + + std::list<vpRotationMatrix>::const_iterator it_laRb = laRb.begin(); + std::list<vpTranslationVector>::const_iterator it_laTb = laTb.begin(); + std::list<vpColVector>::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" <<std::endl ; + std::cout << aRb << std::endl ; + std::cout << "Translation: aTb" <<std::endl; + std::cout << (aTb).t() <<std::endl ; + std::cout << "Normal to the plane: n" <<std::endl; + std::cout << (n).t() <<std::endl ; + + ++ it_laRb; + ++ it_laTb; + ++ it_lnb; + } + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } diff --git a/example/homography/homographyHLM3DObject.cpp b/example/homography/homographyHLM3DObject.cpp index 03fd41bbdc0e72760ac1ee15e9945fbccd22f46e..ffe94ae719c325c7ef30f4cc42660dc5fea84dfc 100644 --- a/example/homography/homographyHLM3DObject.cpp +++ b/example/homography/homographyHLM3DObject.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: homographyHLM3DObject.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: homographyHLM3DObject.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -72,6 +72,9 @@ #define L 0.1 #define nbpt 11 +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); + /*! Print the program options. @@ -111,15 +114,15 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -128,7 +131,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -139,106 +142,105 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } + try { + // 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() ; - } + vpPoint P[nbpt] ; // Point to be tracked + std::vector<double> xa(nbpt), ya(nbpt) ; + std::vector<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 ) ; + + 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(unsigned int 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() ; - } + for(unsigned int 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 << "-------------------------------" <<std::endl ; - vpTRACE("Compare with built homography H = R + t/d n ") ; - vpPlane bp(0,0,1,1) ; - vpHomography aHb_built(aMb,bp) ; - vpTRACE( "aHb built from the displacement ") ; - std::cout << std::endl <<aHb_built/aHb_built[2][2] << std::endl ; - - aHb_built.computeDisplacement(aRb, aTb, n) ; - std::cout << "Rotation: aRb" <<std::endl ; - std::cout << aRb << std::endl ; - std::cout << "Translation: aTb" <<std::endl; - std::cout << (aTb).t() <<std::endl ; - std::cout << "Normal to the plane: n" <<std::endl; - std::cout << (n).t() <<std::endl ; - - std::cout << "-------------------------------" <<std::endl ; - std::cout << "aMb "<<std::endl <<aMb << std::endl ; - std::cout << "-------------------------------" <<std::endl ; - vpHomography aHb ; - - vpHomography::HLM(nbpt,xb,yb,xa,ya,false, aHb) ; - - vpTRACE("aHb computed using the Malis paralax algorithm") ; - aHb /= aHb[2][2] ; - std::cout << std::endl << aHb<< std::endl ; - - - std::cout << "-------------------------------" <<std::endl ; - vpTRACE("extract R, T and n ") ; - aHb.computeDisplacement(aRb, aTb, n) ; - std::cout << "Rotation: aRb" <<std::endl ; - std::cout << aRb << std::endl ; - std::cout << "Translation: aTb" <<std::endl; - std::cout << (aTb).t() <<std::endl ; - std::cout << "Normal to the plane: n" <<std::endl; - std::cout << (n).t() <<std::endl ; - - - std::cout << "-------------------------------" <<std::endl ; - vpTRACE("test if ap = aHb bp") ; - - for(i=0 ; i < nbpt ; i++) - { - std::cout << "Point "<< i<< std::endl ; - vpPoint p ; - std::cout << "(" ; - std::cout << aP[i].get_x()/aP[i].get_w()<<", "<< aP[i].get_y()/aP[i].get_w() ; - std::cout <<") = (" ; - p = aHb*bP[i] ; - std::cout << p.get_x() /p.get_w()<<", "<< p.get_y()/ p.get_w() <<")"<<std::endl ; - } + vpRotationMatrix aRb ; + vpTranslationVector aTb ; + vpColVector n ; + std::cout << "-------------------------------" << std::endl ; + std::cout << "Compare with built homography H = R + t/d n " << std::endl ; + vpPlane bp(0,0,1,1) ; + vpHomography aHb_built(aMb,bp) ; + std::cout << "aHb built from the displacement: \n" << aHb_built/aHb_built[2][2] << std::endl ; + + aHb_built.computeDisplacement(aRb, aTb, n) ; + std::cout << "Rotation: aRb" <<std::endl ; + std::cout << aRb << std::endl ; + std::cout << "Translation: aTb" <<std::endl; + std::cout << (aTb).t() <<std::endl ; + std::cout << "Normal to the plane: n" <<std::endl; + std::cout << (n).t() <<std::endl ; + + std::cout << "-------------------------------" <<std::endl ; + std::cout << "aMb "<<std::endl <<aMb << std::endl ; + std::cout << "-------------------------------" <<std::endl ; + vpHomography aHb ; + + vpHomography::HLM(xb, yb, xa, ya, false, aHb) ; + + std::cout << "aHb computed using the Malis paralax algorithm" << std::endl ; + aHb /= aHb[2][2] ; + std::cout << std::endl << aHb<< std::endl ; + + std::cout << "-------------------------------" <<std::endl ; + std::cout << "extract R, T and n " << std::endl ; + aHb.computeDisplacement(aRb, aTb, n) ; + std::cout << "Rotation: aRb" <<std::endl ; + std::cout << aRb << std::endl ; + std::cout << "Translation: aTb" <<std::endl; + std::cout << (aTb).t() <<std::endl ; + std::cout << "Normal to the plane: n" <<std::endl; + std::cout << (n).t() <<std::endl ; + + std::cout << "-------------------------------" <<std::endl ; + std::cout << "test if ap = aHb bp" << std::endl ; + + for(unsigned int i=0 ; i < nbpt ; i++) + { + std::cout << "Point "<< i<< std::endl ; + vpPoint p ; + std::cout << "(" ; + std::cout << aP[i].get_x()/aP[i].get_w()<<", "<< aP[i].get_y()/aP[i].get_w() ; + std::cout <<") = (" ; + p = aHb*bP[i] ; + std::cout << p.get_x() /p.get_w()<<", "<< p.get_y()/ p.get_w() <<")"<<std::endl ; + } + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } diff --git a/example/homography/homographyHartleyDLT2DObject.cpp b/example/homography/homographyHartleyDLT2DObject.cpp index 9ddd22960ab048778a180e8f69d47cbe6761156c..86561fd795e9814d73f287a2ca1c123f889027d0 100644 --- a/example/homography/homographyHartleyDLT2DObject.cpp +++ b/example/homography/homographyHartleyDLT2DObject.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: homographyHartleyDLT2DObject.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: homographyHartleyDLT2DObject.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -73,6 +73,9 @@ #define L 0.1 #define nbpt 5 +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); + /*! Print the program options. @@ -113,15 +116,15 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -130,7 +133,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -141,99 +144,102 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } - - int i ; + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } - vpPoint P[nbpt] ; // Point to be tracked - double xa[nbpt], ya[nbpt] ; - double xb[nbpt], yb[nbpt] ; + vpPoint P[nbpt] ; // Point to be tracked + std::vector<double> xa(nbpt), ya(nbpt), xb(nbpt), yb(nbpt); - vpPoint aP[nbpt] ; // Point to be tracked - vpPoint bP[nbpt] ; // Point to be tracked + 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[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() ; - } + 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(unsigned int 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() ; + for(unsigned int 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 << "-------------------------------" <<std::endl ; + std::cout << "aMb "<<std::endl <<aMb << std::endl ; + std::cout << "-------------------------------" <<std::endl ; + vpHomography aHb ; + + vpHomography::DLT(xb, yb, xa, ya, aHb, true) ; + + vpTRACE("aHb computed using the DLT algorithm") ; + aHb /= aHb[2][2] ; + std::cout << std::endl << aHb<< std::endl ; + + vpRotationMatrix aRb ; + vpTranslationVector aTb ; + vpColVector n ; + + std::cout << "-------------------------------" <<std::endl ; + vpTRACE("extract R, T and n ") ; + aHb.computeDisplacement(aRb, aTb, n) ; + std::cout << "Rotation: aRb" <<std::endl ; + std::cout << aRb << std::endl ; + std::cout << "Translation: aTb" <<std::endl; + std::cout << (aTb).t() <<std::endl ; + std::cout << "Normal to the plane: n" <<std::endl; + std::cout << (n).t() <<std::endl ; + + std::cout << "-------------------------------" <<std::endl ; + vpTRACE("Compare with built homoraphy H = R + t/d ") ; + vpPlane bp(0,0,1,1) ; + vpHomography aHb_built(aMb,bp) ; + vpTRACE( "aHb built from the displacement ") ; + std::cout << std::endl <<aHb_built/aHb_built[2][2] << std::endl ; + + aHb_built.computeDisplacement(aRb, aTb, n) ; + std::cout << "Rotation: aRb" <<std::endl ; + std::cout << aRb << std::endl ; + std::cout << "Translation: aTb" <<std::endl; + std::cout << (aTb).t() <<std::endl ; + std::cout << "Normal to the plane: n" <<std::endl; + std::cout << (n).t() <<std::endl ; + + std::cout << "-------------------------------" <<std::endl ; + vpTRACE("test if ap = aHb bp") ; + + for(unsigned int i=0 ; i < nbpt ; i++) + { + std::cout << "Point "<< i<< std::endl ; + vpPoint p ; + std::cout << "(" ; + std::cout << aP[i].get_x()/aP[i].get_w()<<", "<< aP[i].get_y()/aP[i].get_w() ; + std::cout <<") = (" ; + p = aHb*bP[i] ; + std::cout << p.get_x() /p.get_w()<<", "<< p.get_y()/ p.get_w() <<")"<<std::endl ; + } + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - std::cout << "-------------------------------" <<std::endl ; - std::cout << "aMb "<<std::endl <<aMb << std::endl ; - std::cout << "-------------------------------" <<std::endl ; - vpHomography aHb ; - - vpHomography::HartleyDLT(nbpt,xb,yb,xa,ya,aHb) ; - - vpTRACE("aHb computed using the DLT algorithm") ; - aHb /= aHb[2][2] ; - std::cout << std::endl << aHb<< std::endl ; - - vpRotationMatrix aRb ; - vpTranslationVector aTb ; - vpColVector n ; - - std::cout << "-------------------------------" <<std::endl ; - vpTRACE("extract R, T and n ") ; - aHb.computeDisplacement(aRb, aTb, n) ; - std::cout << "Rotation: aRb" <<std::endl ; - std::cout << aRb << std::endl ; - std::cout << "Translation: aTb" <<std::endl; - std::cout << (aTb).t() <<std::endl ; - std::cout << "Normal to the plane: n" <<std::endl; - std::cout << (n).t() <<std::endl ; - - - std::cout << "-------------------------------" <<std::endl ; - vpTRACE("Compare with built homoraphy H = R + t/d ") ; - vpPlane bp(0,0,1,1) ; - vpHomography aHb_built(aMb,bp) ; - vpTRACE( "aHb built from the displacement ") ; - std::cout << std::endl <<aHb_built/aHb_built[2][2] << std::endl ; - - aHb_built.computeDisplacement(aRb, aTb, n) ; - std::cout << "Rotation: aRb" <<std::endl ; - std::cout << aRb << std::endl ; - std::cout << "Translation: aTb" <<std::endl; - std::cout << (aTb).t() <<std::endl ; - std::cout << "Normal to the plane: n" <<std::endl; - std::cout << (n).t() <<std::endl ; - - std::cout << "-------------------------------" <<std::endl ; - vpTRACE("test if ap = aHb bp") ; - - for(i=0 ; i < nbpt ; i++) - { - std::cout << "Point "<< i<< std::endl ; - vpPoint p ; - std::cout << "(" ; - std::cout << aP[i].get_x()/aP[i].get_w()<<", "<< aP[i].get_y()/aP[i].get_w() ; - std::cout <<") = (" ; - p = aHb*bP[i] ; - std::cout << p.get_x() /p.get_w()<<", "<< p.get_y()/ p.get_w() <<")"<<std::endl ; - } } diff --git a/example/homography/homographyRansac2DObject.cpp b/example/homography/homographyRansac2DObject.cpp index 2fdb479c4958e927a115c116b0f7cf119ba93ecc..7e092a20e9b2805b0818b65435c2b8dbe18c4efc 100644 --- a/example/homography/homographyRansac2DObject.cpp +++ b/example/homography/homographyRansac2DObject.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: homographyRansac2DObject.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: homographyRansac2DObject.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -74,8 +74,8 @@ // List of allowed command line options #define GETOPTARGS "h" -#define L 0.1 -#define nbpt 11 +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); /*! @@ -115,15 +115,15 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -132,7 +132,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -143,76 +143,102 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } + try { + // 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() ; - } + double L=0.1; + unsigned int nbpt = 11; + + std::vector<vpPoint> P(nbpt); // Point to be tracked + std::vector<double> xa(nbpt), ya(nbpt), xb(nbpt), yb(nbpt); + + std::vector<vpPoint> aP(nbpt); // Point to be tracked + std::vector<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 ) ; // inlier + + std::vector<bool> inliers_ground_truth(nbpt, false); + inliers_ground_truth[0] = true; + inliers_ground_truth[1] = true; + inliers_ground_truth[2] = true; + inliers_ground_truth[3] = true; + inliers_ground_truth[8] = true; + inliers_ground_truth[10] = true; + + 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(unsigned int 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() ; + for(unsigned int 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 << "-------------------------------" <<std::endl ; + + vpRotationMatrix aRb ; + vpTranslationVector aTb ; + vpColVector n ; + std::cout << "Compare with built homography H = R + t/d n " << std::endl; + vpPlane bp(0,0,1,1) ; + vpHomography aHb_built(aMb,bp) ; + std::cout << "aHb built from the displacement: \n" << aHb_built/aHb_built[2][2] << std::endl ; + + aHb_built.computeDisplacement(aRb, aTb, n) ; + std::cout << "Rotation aRb: " <<std::endl ; + std::cout << aRb << std::endl ; + std::cout << "Translation: aTb" <<std::endl; + std::cout << (aTb).t() <<std::endl ; + std::cout << "Normal to the plane: n" <<std::endl; + std::cout << (n).t() <<std::endl ; + + std::cout << "-------------------------------" <<std::endl ; + vpHomography aHb; + std::vector<bool> inliers; + double residual; + // Suppose px=1000. Set the threshold to 2 pixels => 2/1000 + // In the data we have 6 inliers. We request that at least 6 are retrieved + vpHomography::ransac(xb, yb, xa, ya, aHb, inliers, residual, 6, 2./1000) ; + + std::cout << "aHb estimated using ransac:\n" << aHb << std::endl ; + std::cout << "Inliers indexes (should be 0,1,2,3,8,10): "; + for (unsigned int i=0; i< inliers.size(); i++) + if (inliers[i]) std::cout << i << ","; + std::cout << std::endl; + + if (inliers == inliers_ground_truth) { + std::cout << "Ransac estimation succeed" << std::endl; + return 0; + } + else { + std::cout << "Ransac estimation fails" << std::endl; + return 1; + } + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - std::cout << "-------------------------------" <<std::endl ; - - vpRotationMatrix aRb ; - vpTranslationVector aTb ; - vpColVector n ; - vpTRACE("Compare with built homography H = R + t/d n ") ; - vpPlane bp(0,0,1,1) ; - vpHomography aHb_built(aMb,bp) ; - vpTRACE( "aHb built from the displacement ") ; - std::cout << std::endl <<aHb_built/aHb_built[2][2] << std::endl ; - - aHb_built.computeDisplacement(aRb, aTb, n) ; - std::cout << "Rotation aRb: " <<std::endl ; - std::cout << aRb << std::endl ; - std::cout << "Translation: aTb" <<std::endl; - std::cout << (aTb).t() <<std::endl ; - std::cout << "Normal to the plane: n" <<std::endl; - std::cout << (n).t() <<std::endl ; - - std::cout << "-------------------------------" <<std::endl ; - vpTRACE(" ") ; - vpHomography aHb ; - vpHomography::ransac(nbpt,xb,yb,xa,ya, aHb) ; - - std::cout << aHb << std::endl ; } diff --git a/example/image/CMakeLists.txt b/example/image/CMakeLists.txt index 59e38c699c8cac94e4a90ca66a5ea148b34f99c4..fd85035fded25a492741b0e6e1b276c93482caf9 100644 --- a/example/image/CMakeLists.txt +++ b/example/image/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/image/imageDiskRW.cpp b/example/image/imageDiskRW.cpp index f153c6b0e20734941214746cee76849fab0dfafc..5d94c68cb59a933fc44455323a4a0781ad19e3f0 100644 --- a/example/image/imageDiskRW.cpp +++ b/example/image/imageDiskRW.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: imageDiskRW.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: imageDiskRW.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -69,6 +69,9 @@ // List of allowed command line options #define GETOPTARGS "i:o:h" +void usage(const char *name, const char *badparam, std::string ipath, std::string opath, std::string user); +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &opath, std::string user); + /*! Print the program options. @@ -127,20 +130,19 @@ OPTIONS: Default\n\ \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) +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &opath, std::string user) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { - case 'i': ipath = optarg; break; - case 'o': opath = optarg; break; + 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; + usage(argv[0], optarg_, ipath, opath, user); return false; break; } } @@ -148,7 +150,7 @@ bool getOptions(int argc, const char **argv, // 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; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -160,183 +162,179 @@ bool getOptions(int argc, const char **argv, 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" <<std::endl << std::endl ; - - std::cout << " reading and writting of PPM image" << std::endl ; - std::cout << " read an image that does not exist" << std::endl ; - std::cout << " write in a directory that does no exist" << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << std::endl ; - - - // 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; - - // Set the default output path -#if defined(UNIX) && !defined(WIN32) - opt_opath = "/tmp"; -#elif WIN32 - opt_opath = "C:\\temp"; + try { + 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" <<std::endl << std::endl ; + + std::cout << " reading and writting of PPM image" << std::endl ; + std::cout << " read an image that does not exist" << std::endl ; + std::cout << " write in a directory that does no exist" << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << std::endl ; + + + // 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; + + // Set the default output path +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX + opt_opath = "/tmp"; +#elif defined(_WIN32) + opt_opath = "C:\\temp"; #endif - // Get the user login name - vpIoTools::getUserName(username); - - // Read the command line options - if (getOptions(argc, argv, opt_ipath, opt_opath, username) == false) { - exit (-1); - } + // Get the user login name + vpIoTools::getUserName(username); - // Get the option values - if (!opt_ipath.empty()) - ipath = opt_ipath; - if (!opt_opath.empty()) - opath = opt_opath; + // Read the command line options + if (getOptions(argc, argv, opt_ipath, opt_opath, username) == false) { + exit (-1); + } - // Append to the output path string, the login name of the user - std::string dirname = opath + vpIoTools::path("/") + username; + // Get the option values + if (!opt_ipath.empty()) + ipath = opt_ipath; + if (!opt_opath.empty()) + opath = opt_opath; + + // Append to the output path string, the login name of the user + std::string dirname = opath + vpIoTools::path("/") + username; + + // Test if the output path exist. If no try to create it + if (vpIoTools::checkDirectory(dirname) == false) { + try { + // Create the dirname + vpIoTools::makeDirectory(dirname); + } + catch (...) { + usage(argv[0], NULL, ipath, opath, username); + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Cannot create " << dirname << std::endl; + std::cerr << " Check your -o " << opath << " option " << std::endl; + exit(-1); + } + } - // Test if the output path exist. If no try to create it - if (vpIoTools::checkDirectory(dirname) == false) { - try { - // Create the dirname - vpIoTools::makeDirectory(dirname); + // 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 <visp image path=" << ipath << "> " + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; + } } - catch (...) { + + // 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 << " Cannot create " << dirname << std::endl; - std::cerr << " Check your -o " << opath << " option " << std::endl; + std::cerr << " Use -i <visp image path> 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); } - } - // 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 <visp image path=" << ipath << "> " - << " 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 <visp image path> 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<unsigned char> 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 - // First we wanted to have gray level image (8bits) - // vpImage is a template class you can declare vpImage of ... everything... - vpImage<unsigned char> I ; + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); + vpImageIo::read(I, filename); - // 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 = dirname + vpIoTools::path("/IoPPM.Klimt_char.ppm"); + vpImageIo::write(I, filename) ; - 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 to load a non existing image + try { + filename = ipath + vpIoTools::path("/ViSP-images/image-that-does-not-exist.ppm"); + vpImageIo::read(I,filename) ; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + } - // 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"); + // 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(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + } - 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 ; - std::cout << "----------------------------------------------------" << std::endl ; + // Let's consider that the image is now a color image (32 bits RGBa) + vpImage<vpRGBa> Irgba ; - // Let's consider that the image is now a color image (32 bits RGBa) - vpImage<vpRGBa> Irgba ; + // read write unsigned char ppm image. - // 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); - // 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) ; - // 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(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + } - // 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) ; + } - // test io error - try - { - filename = dirname + vpIoTools::path("/directory-that-does-not-exist/Klimt.ppm"); - vpImageIo::write(Irgba,filename) ; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + } + return 0; } - catch(vpImageException e) - { - vpERROR_TRACE("at main level"); - std::cout << e << std::endl ; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } } diff --git a/example/key-point/CMakeLists.txt b/example/key-point/CMakeLists.txt index 45f66f3db89fb56cf16265722b498c54426c71dd..cbf8457808b092d63773f105de24bfbb18a41664 100644 --- a/example/key-point/CMakeLists.txt +++ b/example/key-point/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/key-point/fernClassifier.cpp b/example/key-point/fernClassifier.cpp index 7d2225154f7998e29a9cbbbae161d5033988ba4e..2f38f4bcb13fa289c310184f4e59582d5467dc2f 100644 --- a/example/key-point/fernClassifier.cpp +++ b/example/key-point/fernClassifier.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: fernClassifier.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: fernClassifier.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -73,6 +73,10 @@ #define GETOPTARGS "hlcdb:i:sp" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv, bool &isLearning, std::string& dataFile, bool& click_allowed, + bool& display, bool& displayPoints, bool& useSequence, std::string& ipath); + /*! Print the program options. @@ -145,24 +149,24 @@ OPTIONS: \n\ \return false if the program has to be stopped, true otherwise. */ -bool getOptions(int argc, const char **argv, - bool &isLearning, std::string& dataFile, bool& click_allowed, bool& display, bool& displayPoints, bool& useSequence, std::string& ipath) +bool getOptions(int argc, const char **argv, bool &isLearning, std::string& dataFile, bool& click_allowed, + bool& display, bool& displayPoints, bool& useSequence, std::string& ipath) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; case 'd': display = false; break; case 'l': isLearning = true; break; case 'h': usage(argv[0], NULL); return false; break; - case 'b': dataFile = optarg; break; + case 'b': dataFile = optarg_; break; case 'p': displayPoints = true; break; case 's': useSequence = false; break; - case 'i': ipath = optarg; break; + case 'i': ipath = optarg_; break; default: - usage(argv[0], optarg); + usage(argv[0], optarg_); return false; break; } } @@ -171,7 +175,7 @@ bool getOptions(int argc, const char **argv, // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -183,284 +187,289 @@ bool getOptions(int argc, const char **argv, int main(int argc, const char** argv) { - bool isLearning = false; - std::string dataFile("./dataFern"); - bool opt_click_allowed = true; - bool opt_display = true; - std::string objectName("object"); - bool displayPoints = false; - bool useSequence = true; - std::string opt_ipath; - std::string ipath; - std::string env_ipath; - std::string dirname; - std::string filename; - - - // 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; - } + try { + bool isLearning = false; + std::string dataFile("./dataFern"); + bool opt_click_allowed = true; + bool opt_display = true; + std::string objectName("object"); + bool displayPoints = false; + bool useSequence = true; + std::string opt_ipath; + std::string ipath; + std::string env_ipath; + std::string dirname; + std::string filename; + + // Get the VISP_IMAGE_PATH environment variable value + char *ptenv = getenv("VISP_INPUT_IMAGE_PATH"); + if (ptenv != NULL){ + env_ipath = ptenv; + } - // Read the command line options - if (getOptions(argc, argv, - isLearning, dataFile, opt_click_allowed, opt_display, displayPoints, useSequence, opt_ipath) == false) { - exit (-1); - } + // Set the default input path + if (! env_ipath.empty()){ + ipath = env_ipath; + } - // Get the option values - if (useSequence && !opt_ipath.empty()){ - ipath = opt_ipath; - } + // Read the command line options + if (getOptions(argc, argv, + isLearning, dataFile, opt_click_allowed, opt_display, displayPoints, useSequence, opt_ipath) == false) { + exit (-1); + } - // Compare ipath and env_ipath. If they differ, we take into account - // the input path comming from the command line option - if (useSequence && !opt_ipath.empty() && !env_ipath.empty()) { - if (ipath != env_ipath) { - std::cout << std::endl - << "WARNING: " << std::endl; - std::cout << " Since -i <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + // Get the option values + if (useSequence && !opt_ipath.empty()){ + ipath = opt_ipath; } - } - // Test if an input path is set - if (useSequence && opt_ipath.empty() && env_ipath.empty()){ - usage(argv[0], NULL); - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Use -i <visp image path> 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); - } + // Compare ipath and env_ipath. If they differ, we take into account + // the input path comming from the command line option + if (useSequence && !opt_ipath.empty() && !env_ipath.empty()) { + if (ipath != env_ipath) { + std::cout << std::endl + << "WARNING: " << std::endl; + std::cout << " Since -i <visp image path=" << ipath << "> " + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; + } + } - - // Declare two images, these are gray level images (unsigned char) - vpImage <unsigned char> I; - vpImage <unsigned char> Iref; - - - // Set the path location of the image sequence - dirname = ipath + vpIoTools::path("/ViSP-images/cube/"); - - // Build the name of the image file - unsigned iter = 0; // Image number - std::ostringstream s; - s.setf(std::ios::right, std::ios::adjustfield); - s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; - filename = dirname + s.str(); - - // 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{ - if(useSequence){ - vpCTRACE << "Load: " << filename << std::endl; - vpImageIo::read(Iref, filename) ; - I = Iref; + // Test if an input path is set + if (useSequence && opt_ipath.empty() && env_ipath.empty()){ + usage(argv[0], NULL); + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Use -i <visp image path> 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); } - } - catch(...) - { - // an exception is throwned if an exception from readPGM has been catched - // 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); - } - - // Declare a framegrabber - vpOpenCVGrabber g; - if(!useSequence){ + + // Declare two images, these are gray level images (unsigned char) + vpImage <unsigned char> I; + vpImage <unsigned char> Iref; + + + // Set the path location of the image sequence + dirname = ipath + vpIoTools::path("/ViSP-images/cube/"); + + // Build the name of the image file + unsigned iter = 0; // Image number + std::ostringstream s; + s.setf(std::ios::right, std::ios::adjustfield); + s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; + filename = dirname + s.str(); + + // 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{ - g.open(I); + if(useSequence){ + vpCTRACE << "Load: " << filename << std::endl; + vpImageIo::read(Iref, filename) ; + I = Iref; + } } - catch(...){ - std::cout << "problem to initialise the framegrabber" << std::endl; + catch(...) + { + // an exception is throwned if an exception from readPGM has been catched + // 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); } - g.acquire(I); - // initialise the reference image - g.acquire(Iref); - } + + + // Declare a framegrabber + vpOpenCVGrabber g; + if(!useSequence){ + try{ + g.open(I); + } + catch(...){ + std::cout << "problem to initialise the framegrabber" << std::endl; + exit(-1); + } + g.acquire(I); + // initialise the reference image + g.acquire(Iref); + } #if defined VISP_HAVE_X11 - vpDisplayX display; + vpDisplayX display; #elif defined VISP_HAVE_GTK - vpDisplayGTK display; + vpDisplayGTK display; #elif defined VISP_HAVE_GDI - vpDisplayGDI display; + vpDisplayGDI display; #endif - + #if defined VISP_HAVE_X11 - vpDisplayX displayRef; + vpDisplayX displayRef; #elif defined VISP_HAVE_GTK - vpDisplayGTK displayRef; + vpDisplayGTK displayRef; #elif defined VISP_HAVE_GDI - vpDisplayGDI displayRef; + vpDisplayGDI displayRef; #endif - // declare a planar object detector - vpFernClassifier fern; + // declare a planar object detector + vpFernClassifier fern; - if(isLearning){ - if(opt_display){ - displayRef.init(Iref, 100, 100, "Reference image") ; - vpDisplay::display(Iref); - vpDisplay::flush(Iref); - } - vpImagePoint corners[2]; - if (opt_display && opt_click_allowed){ - std::cout << "Click on the top left and the bottom right corners to define the reference plane" << std::endl; - for (int i=0 ; i < 2 ; i++){ - vpDisplay::getClick(Iref, corners[i]); - std::cout << corners[i] << std::endl; + if(isLearning){ + if(opt_display){ + displayRef.init(Iref, 100, 100, "Reference image") ; + vpDisplay::display(Iref); + vpDisplay::flush(Iref); + } + vpImagePoint corners[2]; + if (opt_display && opt_click_allowed){ + std::cout << "Click on the top left and the bottom right corners to define the reference plane" << std::endl; + for (int i=0 ; i < 2 ; i++){ + vpDisplay::getClick(Iref, corners[i]); + std::cout << corners[i] << std::endl; + } + } + else{ + corners[0].set_ij(1,1); + corners[1].set_ij(I.getHeight()-2,I.getWidth()-2); } - } - else{ - corners[0].set_ij(1,1); - corners[1].set_ij(I.getHeight()-2,I.getWidth()-2); - } - if (opt_display) { - //Display the rectangle which defines the part of the image where the reference points are computed. - vpDisplay::displayRectangle(Iref, corners[0], corners[1], vpColor::green); - vpDisplay::flush(Iref); - } + if (opt_display) { + //Display the rectangle which defines the part of the image where the reference points are computed. + vpDisplay::displayRectangle(Iref, corners[0], corners[1], vpColor::green); + vpDisplay::flush(Iref); + } - if (opt_click_allowed){ - std::cout << "Click on the image to continue" << std::endl; - vpDisplay::getClick(Iref); - } + if (opt_click_allowed){ + std::cout << "Click on the image to continue" << std::endl; + vpDisplay::getClick(Iref); + } - vpRect roi(corners[0], corners[1]); + vpRect roi(corners[0], corners[1]); - std::cout << "> train the classifier on the selected plane. (may take up to several minutes)." << std::endl; - if(opt_display) { - vpDisplay::display(Iref); - vpDisplay::flush(Iref); - } - - try{ - fern.buildReference(Iref, roi); - } - catch(vpException e){ - std::cout << e.getMessage() << std::endl; - } - catch(...){ - std::cout << "unknown error, line " << __LINE__ << std::endl; - } - try{ - fern.record(objectName, dataFile); - } - catch(vpException e){ - std::cout << e.getMessage() << std::endl; - } - catch(...){ - std::cout << "unknown error, line " << __LINE__ << std::endl; - } - std::cout << __LINE__ << std::endl; - } - else{ - if(!vpIoTools::checkFilename(dataFile)){ - vpERROR_TRACE("cannot load the database with the specified name. Has the object been learned with the -l option? "); - exit(-1); - } - try{ - // load a previously recorded file - fern.load(dataFile, objectName); - } - catch(...){ - vpERROR_TRACE("cannot load the database with the specified name. Has the object been learned with the -l option? "); - exit(-1); - } - } - - - if(opt_display){ - display.init(I, 110 + (int)Iref.getWidth(), 100, "Current image") ; - vpDisplay::display(I); - vpDisplay::flush(I); - } + std::cout << "> train the classifier on the selected plane. (may take up to several minutes)." << std::endl; + if(opt_display) { + vpDisplay::display(Iref); + vpDisplay::flush(Iref); + } - if (opt_display && opt_click_allowed){ - std::cout << "Click on the current image to continue" << std::endl; - vpDisplay::displayCharString (I, vpImagePoint(15,15), - (char*)"Click on the current image to continue", vpColor::red); - vpDisplay::flush(I); - vpDisplay::getClick(I); - } - - for ( ; ; ) { - // acquire a new image - if(useSequence){ - iter++; - if(iter >= 80){ - break; - } - s.str(""); - s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; - filename = dirname + s.str(); - // read the image - vpImageIo::read(I, filename); + try{ + fern.buildReference(Iref, roi); + } + catch(vpException e){ + std::cout << e.getMessage() << std::endl; + } + catch(...){ + std::cout << "unknown error, line " << __LINE__ << std::endl; + } + try{ + fern.record(objectName, dataFile); + } + catch(vpException e){ + std::cout << e.getMessage() << std::endl; + } + catch(...){ + std::cout << "unknown error, line " << __LINE__ << std::endl; + } + std::cout << __LINE__ << std::endl; } else{ - g.acquire(I); + if(!vpIoTools::checkFilename(dataFile)){ + vpERROR_TRACE("cannot load the database with the specified name. Has the object been learned with the -l option? "); + exit(-1); + } + try{ + // load a previously recorded file + fern.load(dataFile, objectName); + } + catch(...){ + vpERROR_TRACE("cannot load the database with the specified name. Has the object been learned with the -l option? "); + exit(-1); + } } - + + if(opt_display){ + display.init(I, 110 + (int)Iref.getWidth(), 100, "Current image") ; vpDisplay::display(I); - if(isLearning) - vpDisplay::display(Iref); - } - - double t0 = vpTime::measureTimeMs (); - // detection of the reference image - unsigned int nbpts; - try{ - nbpts = fern.matchPoint(I); - } - catch(vpException e){ - std::cout << e.getMessage() << std::endl; - return -1; - } - catch(...){ - std::cout << "unknown error line " << __LINE__ << std::endl; - return -1; + vpDisplay::flush(I); } - std::cout << "matching " << nbpts << " points : " << vpTime::measureTimeMs () - t0 << " ms" << std::endl; - - if(opt_display){ - fern.display(Iref, I, 7); + + if (opt_display && opt_click_allowed){ + std::cout << "Click on the current image to continue" << std::endl; + vpDisplay::displayCharString (I, vpImagePoint(15,15), + (char*)"Click on the current image to continue", vpColor::red); vpDisplay::flush(I); - if(isLearning) - vpDisplay::flush(Iref); - if(vpDisplay::getClick(I, false)){ - break; + vpDisplay::getClick(I); + } + + for ( ; ; ) { + // acquire a new image + if(useSequence){ + iter++; + if(iter >= 80){ + break; + } + s.str(""); + s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; + filename = dirname + s.str(); + // read the image + vpImageIo::read(I, filename); + } + else{ + g.acquire(I); + } + + if(opt_display){ + vpDisplay::display(I); + if(isLearning) + vpDisplay::display(Iref); + } + + double t0 = vpTime::measureTimeMs (); + // detection of the reference image + unsigned int nbpts; + try{ + nbpts = fern.matchPoint(I); + } + catch(vpException e){ + std::cout << e.getMessage() << std::endl; + return -1; + } + catch(...){ + std::cout << "unknown error line " << __LINE__ << std::endl; + return -1; + } + std::cout << "matching " << nbpts << " points : " << vpTime::measureTimeMs () - t0 << " ms" << std::endl; + + if(opt_display){ + fern.display(Iref, I, 7); + vpDisplay::flush(I); + if(isLearning) + vpDisplay::flush(Iref); + if(vpDisplay::getClick(I, false)){ + break; + } } } + + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - - return 0; } #else diff --git a/example/key-point/keyPointSurf.cpp b/example/key-point/keyPointSurf.cpp index b40a5c7f3e045572ac584e157e580c953b4b5a03..590c08864c9f9983e2e345c48d7214b197c280b1 100644 --- a/example/key-point/keyPointSurf.cpp +++ b/example/key-point/keyPointSurf.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: keyPointSurf.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: keyPointSurf.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -76,6 +76,9 @@ // List of allowed command line options #define GETOPTARGS "cdi:h" +void usage(const char *name, const char *badparam, std::string ipath); +bool getOptions(int argc, const char **argv, std::string &ipath, bool &click_allowed, bool &display); + /*! Print the program options. @@ -130,21 +133,20 @@ OPTIONS: Default\n\ \return false if the program has to be stopped, true otherwise. */ -bool getOptions(int argc, const char **argv, std::string &ipath, - bool &click_allowed, bool &display) +bool getOptions(int argc, const char **argv, std::string &ipath, bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; case 'd': display = false; break; - case 'i': ipath = optarg; break; + case 'i': ipath = optarg_; break; case 'h': usage(argv[0], NULL, ipath); return false; break; default: - usage(argv[0], optarg, ipath); + usage(argv[0], optarg_, ipath); return false; break; } } @@ -153,7 +155,7 @@ bool getOptions(int argc, const char **argv, std::string &ipath, // standalone param or error usage(argv[0], NULL, ipath); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -164,205 +166,211 @@ bool getOptions(int argc, const char **argv, std::string &ipath, int main(int argc, const char ** argv) { - std::string env_ipath; - std::string opt_ipath; - std::string ipath; - std::string dirname; - std::string filename; - bool opt_click_allowed = true; - 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_click_allowed, - opt_display) == false) { - exit (-1); - } + try { + std::string env_ipath; + std::string opt_ipath; + std::string ipath; + std::string dirname; + std::string filename; + bool opt_click_allowed = true; + 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_click_allowed, + 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 <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + // 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 <visp image path=" << ipath << "> " + << " 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 <visp image path> 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); - } + // 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 <visp image path> 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); + } - // 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<unsigned char> Iref ; - vpImage<unsigned char> Icur ; - - // Set the path location of the image sequence - dirname = ipath + vpIoTools::path("/ViSP-images/cube/"); - - // Build the name of the image file - unsigned iter = 0; // Image number - std::ostringstream s; - s.setf(std::ios::right, std::ios::adjustfield); - s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; - filename = dirname + s.str(); - - // 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; - - vpImageIo::read(Iref, filename) ; - } - catch(...) - { - // an exception is throwned if an exception from readPGM has been catched - // 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); - } + // 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<unsigned char> Iref ; + vpImage<unsigned char> Icur ; - // We open a window using either X11, GTK or GDI. -#if defined VISP_HAVE_X11 - vpDisplayX display[2]; -#elif defined VISP_HAVE_GTK - vpDisplayGTK display[2]; -#elif defined VISP_HAVE_GDI - vpDisplayGDI display[2]; -#endif + // Set the path location of the image sequence + dirname = ipath + vpIoTools::path("/ViSP-images/cube/"); - if (opt_display) { + // Build the name of the image file + unsigned int iter = 0; // Image number + std::ostringstream s; + s.setf(std::ios::right, std::ios::adjustfield); + s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; + filename = dirname + s.str(); + + // 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{ - // Display size is automatically defined by the image (I) size - display[0].init(Iref, 100, 100,"Display reference image") ; - vpDisplay::display(Iref) ; - vpDisplay::flush(Iref) ; + vpCTRACE << "Load: " << filename << std::endl; + + vpImageIo::read(Iref, filename) ; } catch(...) { - vpERROR_TRACE("Error while displaying the image") ; + // an exception is throwned if an exception from readPGM has been catched + // 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); } - } - vpImagePoint corners[2]; - if (opt_display && opt_click_allowed) - { - std::cout << "Click on the top left and the bottom right corners to define the part of the image where the reference points will be computed" << std::endl; - for (unsigned int i=0 ; i < 2 ; i++) - { - vpDisplay::getClick(Iref, corners[i]); - std::cout << corners[i] << std::endl; - } - } - else - { - corners[0].set_ij(156,209); - corners[1].set_ij(272,378); - } + // We open a window using either X11, GTK or GDI. +#if defined VISP_HAVE_X11 + vpDisplayX display[2]; +#elif defined VISP_HAVE_GTK + vpDisplayGTK display[2]; +#elif defined VISP_HAVE_GDI + vpDisplayGDI display[2]; +#endif - if (opt_display) - { - //Display the rectangle which defines the part of the image where the reference points are computed. - vpDisplay::displayRectangle(Iref, corners[0], corners[1], vpColor::green); - vpDisplay::flush(Iref); - } + if (opt_display) { + try{ + // Display size is automatically defined by the image (I) size + display[0].init(Iref, 100, 100,"Display reference image") ; + vpDisplay::display(Iref) ; + vpDisplay::flush(Iref) ; + } + catch(...) + { + vpERROR_TRACE("Error while displaying the image") ; + exit(-1); + } + } - if (opt_click_allowed) - { - std::cout << "Click on the image to continue" << std::endl; - vpDisplay::getClick(Iref); - } + vpImagePoint corners[2]; + if (opt_display && opt_click_allowed) + { + std::cout << "Click on the top left and the bottom right corners to define the part of the image where the reference points will be computed" << std::endl; + for (unsigned int i=0 ; i < 2 ; i++) + { + vpDisplay::getClick(Iref, corners[i]); + std::cout << corners[i] << std::endl; + } + } + else + { + corners[0].set_ij(156,209); + corners[1].set_ij(272,378); + } - vpKeyPointSurf surf; - // unsigned int nbrRef; - unsigned int height, width; - height = (unsigned int)(corners[1].get_i() - corners[0].get_i()); - width = (unsigned int)(corners[1].get_j() - corners[0].get_j()); + if (opt_display) + { + //Display the rectangle which defines the part of the image where the reference points are computed. + vpDisplay::displayRectangle(Iref, corners[0], corners[1], vpColor::green); + vpDisplay::flush(Iref); + } - //Computes the reference points - /* nbrRef = */ surf.buildReference(Iref, corners[0], height, width); + if (opt_click_allowed) + { + std::cout << "Click on the image to continue" << std::endl; + vpDisplay::getClick(Iref); + } - unsigned int nbrPair = 0; + vpKeyPointSurf surf; + // unsigned int nbrRef; + unsigned int height, width; + height = (unsigned int)(corners[1].get_i() - corners[0].get_i()); + width = (unsigned int)(corners[1].get_j() - corners[0].get_j()); - vpImageIo::read(Icur, filename); + //Computes the reference points + /* nbrRef = */ surf.buildReference(Iref, corners[0], height, width); - if (opt_display) { - try{ - // Display size is automatically defined by the image (I) size - display[1].init(Icur, (int)(100+Iref.getWidth()), 100,"Display current image") ; - vpDisplay::display(Icur) ; - vpDisplay::flush(Icur) ; - } - catch(...) - { - vpERROR_TRACE("Error while displaying the image") ; - exit(-1); - } - } + unsigned int nbrPair = 0; - for (int iter = 1 ; iter < 30 ; iter++) - { - std::cout <<"----------------------------------------------------------"<<std::endl; - // set the new image name - s.str(""); - s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; - filename = dirname + s.str(); - // read the image vpImageIo::read(Icur, filename); + if (opt_display) { - // Display the image - vpDisplay::display(Iref) ; - vpDisplay::display(Icur) ; + try{ + // Display size is automatically defined by the image (I) size + display[1].init(Icur, (int)(100+Iref.getWidth()), 100,"Display current image") ; + vpDisplay::display(Icur) ; + vpDisplay::flush(Icur) ; + } + catch(...) + { + vpERROR_TRACE("Error while displaying the image") ; + exit(-1); + } } - nbrPair = surf.matchPoint(Icur); - std::cout << "Number of matched point : " << nbrPair <<std::endl; - - if (opt_display) + for (iter = 1 ; iter < 30 ; iter++) { - // Display the matched features - surf.display(Iref, Icur, 7); - vpDisplay::displayRectangle(Iref, corners[0], corners[1], vpColor::red); - vpDisplay::flush(Iref) ; - vpDisplay::flush(Icur) ; + std::cout <<"----------------------------------------------------------"<<std::endl; + // set the new image name + s.str(""); + s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; + filename = dirname + s.str(); + // read the image + vpImageIo::read(Icur, filename); + if (opt_display) { + // Display the image + vpDisplay::display(Iref) ; + vpDisplay::display(Icur) ; + } + + nbrPair = surf.matchPoint(Icur); + std::cout << "Number of matched point : " << nbrPair <<std::endl; + + if (opt_display) + { + // Display the matched features + surf.display(Iref, Icur, 7); + vpDisplay::displayRectangle(Iref, corners[0], corners[1], vpColor::red); + vpDisplay::flush(Iref) ; + vpDisplay::flush(Icur) ; + } } + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } } diff --git a/example/key-point/planarObjectDetector.cpp b/example/key-point/planarObjectDetector.cpp index b6415a6b279af0976ed8c106618c65f032546058..0fe4499840b5ec57d5a67a2eb80ee8650d0269b1 100644 --- a/example/key-point/planarObjectDetector.cpp +++ b/example/key-point/planarObjectDetector.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: planarObjectDetector.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: planarObjectDetector.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -75,6 +75,10 @@ #define GETOPTARGS "hlcdb:i:sp" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv, bool &isLearning, std::string& dataFile, bool& click_allowed, + bool& display, bool& displayPoints, bool& useSequence, std::string& ipath); + /*! Print the program options. @@ -147,24 +151,24 @@ OPTIONS: \n\ \return false if the program has to be stopped, true otherwise. */ -bool getOptions(int argc, const char **argv, - bool &isLearning, std::string& dataFile, bool& click_allowed, bool& display, bool& displayPoints, bool& useSequence, std::string& ipath) +bool getOptions(int argc, const char **argv, bool &isLearning, std::string& dataFile, bool& click_allowed, + bool& display, bool& displayPoints, bool& useSequence, std::string& ipath) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; case 'd': display = false; break; case 'l': isLearning = true; break; case 'h': usage(argv[0], NULL); return false; break; - case 'b': dataFile = optarg; break; + case 'b': dataFile = optarg_; break; case 'p': displayPoints = true; break; case 's': useSequence = false; break; - case 'i': ipath = optarg; break; + case 'i': ipath = optarg_; break; default: - usage(argv[0], optarg); + usage(argv[0], optarg_); return false; break; } } @@ -173,7 +177,7 @@ bool getOptions(int argc, const char **argv, // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -185,273 +189,279 @@ bool getOptions(int argc, const char **argv, int main(int argc, const char** argv) { - bool isLearning = false; - std::string dataFile("./dataPlanar"); - bool opt_click_allowed = true; - bool opt_display = true; - std::string objectName("object"); - bool displayPoints = false; - bool useSequence = true; - std::string opt_ipath; - std::string ipath; - std::string env_ipath; - std::string dirname; - std::string filename; - - - // 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; - } + try { + bool isLearning = false; + std::string dataFile("./dataPlanar"); + bool opt_click_allowed = true; + bool opt_display = true; + std::string objectName("object"); + bool displayPoints = false; + bool useSequence = true; + std::string opt_ipath; + std::string ipath; + std::string env_ipath; + std::string dirname; + std::string filename; + + + // Get the VISP_IMAGE_PATH environment variable value + char *ptenv = getenv("VISP_INPUT_IMAGE_PATH"); + if (ptenv != NULL){ + env_ipath = ptenv; + } - // Read the command line options - if (getOptions(argc, argv, - isLearning, dataFile, opt_click_allowed, opt_display, displayPoints, useSequence, opt_ipath) == false) { - exit (-1); - } + // Set the default input path + if (! env_ipath.empty()){ + ipath = env_ipath; + } - // Get the option values - if (useSequence && !opt_ipath.empty()){ - ipath = opt_ipath; - } + // Read the command line options + if (getOptions(argc, argv, + isLearning, dataFile, opt_click_allowed, opt_display, displayPoints, useSequence, opt_ipath) == false) { + exit (-1); + } - // Compare ipath and env_ipath. If they differ, we take into account - // the input path comming from the command line option - if (useSequence && !opt_ipath.empty() && !env_ipath.empty()) { - if (ipath != env_ipath) { - std::cout << std::endl - << "WARNING: " << std::endl; - std::cout << " Since -i <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + // Get the option values + if (useSequence && !opt_ipath.empty()){ + ipath = opt_ipath; } - } - // Test if an input path is set - if (useSequence && opt_ipath.empty() && env_ipath.empty()){ - usage(argv[0], NULL); - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Use -i <visp image path> 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); - } + // Compare ipath and env_ipath. If they differ, we take into account + // the input path comming from the command line option + if (useSequence && !opt_ipath.empty() && !env_ipath.empty()) { + if (ipath != env_ipath) { + std::cout << std::endl + << "WARNING: " << std::endl; + std::cout << " Since -i <visp image path=" << ipath << "> " + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; + } + } - - // Declare two images, these are gray level images (unsigned char) - vpImage <unsigned char> I; - vpImage <unsigned char> Iref; - - - // Set the path location of the image sequence - dirname = ipath + vpIoTools::path("/ViSP-images/cube/"); - - // Build the name of the image file - unsigned iter = 0; // Image number - std::ostringstream s; - s.setf(std::ios::right, std::ios::adjustfield); - s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; - filename = dirname + s.str(); - - // 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{ - if(useSequence){ - vpCTRACE << "Load: " << filename << std::endl; - vpImageIo::read(Iref, filename) ; - I = Iref; + // Test if an input path is set + if (useSequence && opt_ipath.empty() && env_ipath.empty()){ + usage(argv[0], NULL); + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Use -i <visp image path> 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); } - } - catch(...) - { - // an exception is throwned if an exception from readPGM has been catched - // 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); - } - - // Declare a framegrabber - vpOpenCVGrabber g; - if(!useSequence){ + + // Declare two images, these are gray level images (unsigned char) + vpImage <unsigned char> I; + vpImage <unsigned char> Iref; + + + // Set the path location of the image sequence + dirname = ipath + vpIoTools::path("/ViSP-images/cube/"); + + // Build the name of the image file + unsigned iter = 0; // Image number + std::ostringstream s; + s.setf(std::ios::right, std::ios::adjustfield); + s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; + filename = dirname + s.str(); + + // 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{ - g.open(I); + if(useSequence){ + vpCTRACE << "Load: " << filename << std::endl; + vpImageIo::read(Iref, filename) ; + I = Iref; + } } - catch(...){ - std::cout << "problem to initialise the framegrabber" << std::endl; + catch(...) + { + // an exception is throwned if an exception from readPGM has been catched + // 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); } - - - g.acquire(I); - // initialise the reference image - g.acquire(Iref); - } + + + // Declare a framegrabber + vpOpenCVGrabber g; + if(!useSequence){ + try{ + g.open(I); + } + catch(...){ + std::cout << "problem to initialise the framegrabber" << std::endl; + exit(-1); + } + + + g.acquire(I); + // initialise the reference image + g.acquire(Iref); + } #if defined VISP_HAVE_X11 - vpDisplayX display; + vpDisplayX display; #elif defined VISP_HAVE_GTK - vpDisplayGTK display; + vpDisplayGTK display; #elif defined VISP_HAVE_GDI - vpDisplayGDI display; + vpDisplayGDI display; #endif - + #if defined VISP_HAVE_X11 - vpDisplayX displayRef; + vpDisplayX displayRef; #elif defined VISP_HAVE_GTK - vpDisplayGTK displayRef; + vpDisplayGTK displayRef; #elif defined VISP_HAVE_GDI - vpDisplayGDI displayRef; + vpDisplayGDI displayRef; #endif - // declare a planar object detector - vpPlanarObjectDetector planar; + // declare a planar object detector + vpPlanarObjectDetector planar; - vpImagePoint corners[2]; - if(isLearning){ - if(opt_display){ - displayRef.init(Iref, 100, 100, "Reference image") ; - vpDisplay::display(Iref); - vpDisplay::flush(Iref); - } - if (opt_display && opt_click_allowed){ - std::cout << "Click on the top left and the bottom right corners to define the reference plane" << std::endl; - for (int i=0 ; i < 2 ; i++){ - vpDisplay::getClick(Iref, corners[i]); - std::cout << corners[i] << std::endl; + vpImagePoint corners[2]; + if(isLearning){ + if(opt_display){ + displayRef.init(Iref, 100, 100, "Reference image") ; + vpDisplay::display(Iref); + vpDisplay::flush(Iref); + } + if (opt_display && opt_click_allowed){ + std::cout << "Click on the top left and the bottom right corners to define the reference plane" << std::endl; + for (int i=0 ; i < 2 ; i++){ + vpDisplay::getClick(Iref, corners[i]); + std::cout << corners[i] << std::endl; + } + } + else{ + corners[0].set_ij(50, I.getWidth()-100);// small ROI for the automated test + corners[1].set_ij(I.getHeight()-100, I.getWidth()-2); } - } - else{ - corners[0].set_ij(50, I.getWidth()-100);// small ROI for the automated test - corners[1].set_ij(I.getHeight()-100, I.getWidth()-2); - } - - if (opt_display) { - //Display the rectangle which defines the part of the image where the reference points are computed. - vpDisplay::displayRectangle(Iref, corners[0], corners[1], vpColor::green); - vpDisplay::flush(Iref); - } - - if (opt_click_allowed){ - std::cout << "Click on the image to continue" << std::endl; - vpDisplay::getClick(Iref); - } - vpRect roi(corners[0], corners[1]); + if (opt_display) { + //Display the rectangle which defines the part of the image where the reference points are computed. + vpDisplay::displayRectangle(Iref, corners[0], corners[1], vpColor::green); + vpDisplay::flush(Iref); + } - std::cout << "> train the classifier on the selected plane (may take up to several minutes)." << std::endl; - if(opt_display) { - vpDisplay::display(Iref); - vpDisplay::flush(Iref); - } - double t0 = vpTime::measureTimeMs (); - planar.buildReference(Iref, roi); - std::cout << "build reference in " << vpTime::measureTimeMs () - t0 << " ms" << std::endl; - t0 = vpTime::measureTimeMs (); - planar.recordDetector(objectName, dataFile); - std::cout << "record detector in " << vpTime::measureTimeMs () - t0 << " ms" << std::endl; - } - else{ - if(!vpIoTools::checkFilename(dataFile)){ - vpERROR_TRACE("cannot load the database with the specified name. Has the object been learned with the -l option? "); - exit(-1); - } - try{ - // load a previously recorded file - planar.load(dataFile, objectName); - } - catch(...){ - vpERROR_TRACE("cannot load the database with the specified name. Has the object been learned with the -l option? "); - exit(-1); - } - } + if (opt_click_allowed){ + std::cout << "Click on the image to continue" << std::endl; + vpDisplay::getClick(Iref); + } - if(opt_display){ - display.init(I, 110 + (int)Iref.getWidth(), 100, "Current image") ; - vpDisplay::display(I); - vpDisplay::flush(I); - } + vpRect roi(corners[0], corners[1]); - if (opt_display && opt_click_allowed){ - std::cout << "Click on the reference image to continue" << std::endl; - vpDisplay::displayCharString (Iref, vpImagePoint(15,15), - (char*)"Click on the reference image to continue", vpColor::red); - vpDisplay::flush(Iref); - vpDisplay::getClick(Iref); - } - - for ( ; ; ) { - // acquire a new image - if(useSequence){ - iter++; - if(iter >= 80){ - break; - } - s.str(""); - s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; - filename = dirname + s.str(); - // read the image - vpImageIo::read(I, filename); + std::cout << "> train the classifier on the selected plane (may take up to several minutes)." << std::endl; + if(opt_display) { + vpDisplay::display(Iref); + vpDisplay::flush(Iref); + } + double t0 = vpTime::measureTimeMs (); + planar.buildReference(Iref, roi); + std::cout << "build reference in " << vpTime::measureTimeMs () - t0 << " ms" << std::endl; + t0 = vpTime::measureTimeMs (); + planar.recordDetector(objectName, dataFile); + std::cout << "record detector in " << vpTime::measureTimeMs () - t0 << " ms" << std::endl; } else{ - g.acquire(I); + if(!vpIoTools::checkFilename(dataFile)){ + vpERROR_TRACE("cannot load the database with the specified name. Has the object been learned with the -l option? "); + exit(-1); + } + try{ + // load a previously recorded file + planar.load(dataFile, objectName); + } + catch(...){ + vpERROR_TRACE("cannot load the database with the specified name. Has the object been learned with the -l option? "); + exit(-1); + } } - + if(opt_display){ + display.init(I, 110 + (int)Iref.getWidth(), 100, "Current image") ; vpDisplay::display(I); + vpDisplay::flush(I); } - - double t0 = vpTime::measureTimeMs (); - // detection of the reference planar surface - bool isDetected = planar.matchPoint(I); - std::cout << "matching in " << vpTime::measureTimeMs () - t0 << " ms" << std::endl; - - if(isDetected){ - vpHomography H; - planar.getHomography(H); - std::cout << " > computed homography:" << std::endl << H << std::endl; + + if (opt_display && opt_click_allowed){ + std::cout << "Click on the reference image to continue" << std::endl; + vpDisplay::displayCharString (Iref, vpImagePoint(15,15), + (char*)"Click on the reference image to continue", vpColor::red); + vpDisplay::flush(Iref); + vpDisplay::getClick(Iref); + } + + for ( ; ; ) { + // acquire a new image + if(useSequence){ + iter++; + if(iter >= 80){ + break; + } + s.str(""); + s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; + filename = dirname + s.str(); + // read the image + vpImageIo::read(I, filename); + } + else{ + g.acquire(I); + } + if(opt_display){ - if(isLearning){ - vpDisplay::display(Iref); - vpDisplay::displayRectangle(Iref, corners[0], corners[1], vpColor::green); - planar.display(Iref, I, displayPoints); - vpDisplay::flush(Iref); - }else{ - planar.display(I, displayPoints); + vpDisplay::display(I); + } + + double t0 = vpTime::measureTimeMs (); + // detection of the reference planar surface + bool isDetected = planar.matchPoint(I); + std::cout << "matching in " << vpTime::measureTimeMs () - t0 << " ms" << std::endl; + + if(isDetected){ + vpHomography H; + planar.getHomography(H); + std::cout << " > computed homography:" << std::endl << H << std::endl; + if(opt_display){ + if(isLearning){ + vpDisplay::display(Iref); + vpDisplay::displayRectangle(Iref, corners[0], corners[1], vpColor::green); + planar.display(Iref, I, displayPoints); + vpDisplay::flush(Iref); + }else{ + planar.display(I, displayPoints); + } } } - } - else{ - std::cout << " > reference is not detected in the image" << std::endl; - } - if(opt_display){ - vpDisplay::flush(I); - if(vpDisplay::getClick(I, false)){ - break; + else{ + std::cout << " > reference is not detected in the image" << std::endl; + } + if(opt_display){ + vpDisplay::flush(I); + if(vpDisplay::getClick(I, false)){ + break; + } } } + + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - - return 0; } #else diff --git a/example/manual/CMakeLists.txt b/example/manual/CMakeLists.txt index 284927794cc1cd23f76d7f426f5e83197fa50410..d0a30429d0eb2832a037cfd52667ed547b3d978e 100644 --- a/example/manual/CMakeLists.txt +++ b/example/manual/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 @@ -47,7 +47,6 @@ SET (SOURCE geometric-features/manGeometricFeatures.cpp hello-world/CMake/HelloWorld.cpp image-manipulation/manDisplay.cpp - image-manipulation/manGrab1394-1.cpp image-manipulation/manGrab1394-2.cpp image-manipulation/manGrabDirectShow.cpp image-manipulation/manGrabDisk.cpp diff --git a/example/manual/geometric-features/manGeometricFeatures.cpp b/example/manual/geometric-features/manGeometricFeatures.cpp index 3a116f07921a73417fa2af663c7ad41beee6655d..c3b11bdca97d78219d0ab169f7baaea8fd7e0d75 100644 --- a/example/manual/geometric-features/manGeometricFeatures.cpp +++ b/example/manual/geometric-features/manGeometricFeatures.cpp @@ -1,10 +1,10 @@ /**************************************************************************** * - * $Id: manGeometricFeatures.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: manGeometricFeatures.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. - * + * Copyright (C) 2005 - 2014 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. @@ -12,11 +12,11 @@ * 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 + * 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 @@ -26,7 +26,7 @@ * * 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. * @@ -77,65 +77,70 @@ int main() { #ifdef VISP_HAVE_GTK - - std::cout << "ViSP geometric features display example" <<std::endl; - unsigned int height = 288; - unsigned int width = 384; - vpImage<unsigned char> I(height,width); - I = 255; // I is a white image - - // create a display window - vpDisplayGTK display; - // initialize a display attached to image I - display.init(I,100,100,"ViSP geometric features display"); - // camera parameters to digitalize the image plane - vpCameraParameters cam(600,600,width/2,height/2); // px,py,u0,v0 - - // pose of the camera with reference to the scene - vpTranslationVector t(0,0,1); - vpRxyzVector rxyz(-M_PI/4,0,0); - vpRotationMatrix R(rxyz); - vpHomogeneousMatrix cMo(t, R); - - // scene building, geometric features definition - vpPoint point; - point.setWorldCoordinates(0,0,0);// (X0=0,Y0=0,Z0=0) - vpLine line; - line.setWorldCoordinates(1,1,0,0,0,0,1,0); // planes:(X+Y=0)&(Z=0) - vpCylinder cylinder; - cylinder.setWorldCoordinates(1,-1,0,0,0,0,0.1); // alpha=1,beta=-1,gamma=0, - // X0=0,Y0=0,Z0=0,R=0.1 - vpCircle circle; - circle.setWorldCoordinates(0,0,1,0,0,0,0.1); // plane:(Z=0),X0=0,Y0=0,Z=0,R=0.1 - vpSphere sphere; - sphere.setWorldCoordinates(0,0,0,0.1); // X0=0,Y0=0,Z0=0,R=0.1 - - // change frame to be the camera frame and project features in the image plane - point.project(cMo); - line.project(cMo); - cylinder.project(cMo); - circle.project(cMo); - sphere.project(cMo); - - // display the scene - vpDisplay::display(I); // display I - // draw the projections of the 3D geometric features in the image plane. - point.display(I,cam,vpColor::black); // draw a black cross over I - line.display(I,cam,vpColor::blue); // draw a blue line over I - cylinder.display(I,cam,vpColor::red); // draw two red lines over I - circle.display(I,cam,vpColor::orange); // draw an orange ellipse over I - sphere.display(I,cam,vpColor::black); // draw a black ellipse over I - - vpDisplay::flush(I); // flush the display buffer - std::cout << "A click in the display to exit" << std::endl; - vpDisplay::getClick(I); // wait for a click in the display to exit - - // save the drawing - vpImage<vpRGBa> Ic; - vpDisplay::getImage(I,Ic); - std::cout << "ViSP creates \"./geometricFeatures.ppm\" B&W image "<< std::endl; - vpImageIo::write(Ic, "./geometricFeatures.ppm"); + try { + std::cout << "ViSP geometric features display example" <<std::endl; + unsigned int height = 288; + unsigned int width = 384; + vpImage<unsigned char> I(height,width); + I = 255; // I is a white image + + // create a display window + vpDisplayGTK display; + // initialize a display attached to image I + display.init(I,100,100,"ViSP geometric features display"); + // camera parameters to digitalize the image plane + vpCameraParameters cam(600,600,width/2,height/2); // px,py,u0,v0 + + // pose of the camera with reference to the scene + vpTranslationVector t(0,0,1); + vpRxyzVector rxyz(-M_PI/4,0,0); + vpRotationMatrix R(rxyz); + vpHomogeneousMatrix cMo(t, R); + + // scene building, geometric features definition + vpPoint point; + point.setWorldCoordinates(0,0,0);// (X0=0,Y0=0,Z0=0) + vpLine line; + line.setWorldCoordinates(1,1,0,0,0,0,1,0); // planes:(X+Y=0)&(Z=0) + vpCylinder cylinder; + cylinder.setWorldCoordinates(1,-1,0,0,0,0,0.1); // alpha=1,beta=-1,gamma=0, + // X0=0,Y0=0,Z0=0,R=0.1 + vpCircle circle; + circle.setWorldCoordinates(0,0,1,0,0,0,0.1); // plane:(Z=0),X0=0,Y0=0,Z=0,R=0.1 + vpSphere sphere; + sphere.setWorldCoordinates(0,0,0,0.1); // X0=0,Y0=0,Z0=0,R=0.1 + + // change frame to be the camera frame and project features in the image plane + point.project(cMo); + line.project(cMo); + cylinder.project(cMo); + circle.project(cMo); + sphere.project(cMo); + + // display the scene + vpDisplay::display(I); // display I + // draw the projections of the 3D geometric features in the image plane. + point.display(I,cam,vpColor::black); // draw a black cross over I + line.display(I,cam,vpColor::blue); // draw a blue line over I + cylinder.display(I,cam,vpColor::red); // draw two red lines over I + circle.display(I,cam,vpColor::orange); // draw an orange ellipse over I + sphere.display(I,cam,vpColor::black); // draw a black ellipse over I + + vpDisplay::flush(I); // flush the display buffer + std::cout << "A click in the display to exit" << std::endl; + vpDisplay::getClick(I); // wait for a click in the display to exit + + // save the drawing + vpImage<vpRGBa> Ic; + vpDisplay::getImage(I,Ic); + std::cout << "ViSP creates \"./geometricFeatures.ppm\" B&W image "<< std::endl; + vpImageIo::write(Ic, "./geometricFeatures.ppm"); + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } #endif - return 0; } diff --git a/example/manual/hello-world/Autotools/have_visp.m4 b/example/manual/hello-world/Autotools/have_visp.m4 index 3d99b63dad90dbadc3965c16f0f2fc126974b0ae..951eb3df63aa02ba5d18054d46aaaa9b7333e129 100644 --- a/example/manual/hello-world/Autotools/have_visp.m4 +++ b/example/manual/hello-world/Autotools/have_visp.m4 @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: have_visp.m4 4057 2013-01-05 13:10:29Z fspindle $ +# $Id: have_visp.m4 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/manual/hello-world/CMake/HelloWorld.cpp b/example/manual/hello-world/CMake/HelloWorld.cpp index 552bcb564865e7f0d1d7c80581e13b923f554d44..86acb033258a930e56f928db5984976f8623a737 100644 --- a/example/manual/hello-world/CMake/HelloWorld.cpp +++ b/example/manual/hello-world/CMake/HelloWorld.cpp @@ -6,18 +6,25 @@ int main() { - vpThetaUVector tu; + try { + vpThetaUVector tu; - // Construct a rotation matrix from the theta U angles - vpRotationMatrix R(vpMath::rad(0.),vpMath::rad(180)+100*std::numeric_limits<double>::epsilon(),0.); + // Construct a rotation matrix from the theta U angles + vpRotationMatrix R(vpMath::rad(0.),vpMath::rad(180)+100*std::numeric_limits<double>::epsilon(),0.); - // Extract the theta U angles from a rotation matrix - tu.buildFrom(R); + // Extract the theta U angles from a rotation matrix + tu.buildFrom(R); - // Since the rotation vector is 3 values column vector, the - // transpose operation produce a row vector. - vpRowVector tu_t = tu.t(); - - // Print the transpose row vector - std::cout << tu_t << std::endl; + // Since the rotation vector is 3 values column vector, the + // transpose operation produce a row vector. + vpRowVector tu_t = tu.t(); + + // Print the transpose row vector + std::cout << tu_t << std::endl; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } diff --git a/example/manual/image-manipulation/manDisplay.cpp b/example/manual/image-manipulation/manDisplay.cpp index 25fba953b8fa416646849ff24b37f305c8e91195..5261d74f54669630fcdc384583e9db820c3c5183 100644 --- a/example/manual/image-manipulation/manDisplay.cpp +++ b/example/manual/image-manipulation/manDisplay.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: manDisplay.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: manDisplay.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -55,96 +55,102 @@ int main() { - // Create a grey level image - vpImage<vpRGBa> I ; + try { + // Create a grey level image + vpImage<vpRGBa> I ; - // Create image points for pixel coordinates - vpImagePoint ip, ip1, ip2; + // Create image points for pixel coordinates + vpImagePoint ip, ip1, ip2; - // Load a grey image from the disk. Klimt.ppm image is part of the ViSP - // image data set available from http://www.irisa.fr/lagadic/visp/download.html - std::string filename = "./Klimt.ppm"; - vpImageIo::read(I, filename) ; + // Load a grey image from the disk. Klimt.ppm image is part of the ViSP + // image data set available from http://www.irisa.fr/lagadic/visp/download.html + std::string filename = "./Klimt.ppm"; + vpImageIo::read(I, filename) ; #ifdef VISP_HAVE_GTK - // Create a display using GTK - vpDisplayGTK display; - - // For this grey level image, open a GTK display at position 100,100 - // in the screen, and with title "GTK display" - display.init(I, 100, 100, "GTK display") ; - - // Display the image - vpDisplay::display(I) ; - - // Display in overlay a red cross at position 100,10 in the - // image. The lines are 20 pixels long - ip.set_i( 200 ); - ip.set_j( 200 ); - vpDisplay::displayCross(I, ip, 20, vpColor::red, 3) ; - - // Display in overlay a horizontal red line - ip1.set_i( 10 ); - ip1.set_j( 0 ); - ip2.set_i( 10 ); - ip2.set_j( I.getWidth() ); - vpDisplay::displayLine(I, ip1, ip2, vpColor::red, 3) ; - - // Display in overlay a vertical green dot line - ip1.set_i( 0 ); - ip1.set_j( 20 ); - ip2.set_i( I.getWidth() ); - ip2.set_j( 20 ); - vpDisplay::displayDotLine(I, ip1, ip2, vpColor::green, 3) ; - - // Display in overlay a blue arrow - ip1.set_i( 0 ); - ip1.set_j( 0 ); - ip2.set_i( 100 ); - ip2.set_j( 100 ); - vpDisplay::displayArrow(I, ip1, ip2, vpColor::blue, 8, 4, 3) ; - - // Display in overlay some circles. The position of the center is 200, 200 - // the radius is increased by 20 pixels for each circle - for (unsigned i=0 ; i < 5 ; i++) { + // Create a display using GTK + vpDisplayGTK display; + + // For this grey level image, open a GTK display at position 100,100 + // in the screen, and with title "GTK display" + display.init(I, 100, 100, "GTK display") ; + + // Display the image + vpDisplay::display(I) ; + + // Display in overlay a red cross at position 100,10 in the + // image. The lines are 20 pixels long ip.set_i( 200 ); ip.set_j( 200 ); - vpDisplay::displayCircle(I, ip, 20*i, vpColor::white, false, 3) ; - } - - // Display in overlay a rectangle. - // The position of the top left corner is 300, 200. - // The width is 200. The height is 100. - ip.set_i( 280 ); - ip.set_j( 150 ); - vpDisplay::displayRectangle(I, ip, 270, 30,vpColor::purple, false, 3) ; - - // Display in overlay a yellow string - ip.set_i( 300 ); - ip.set_j( 160 ); - vpDisplay::displayCharString(I, ip, - "ViSP is a marvelous software", - vpColor::black) ; - //Flush the display : without this line nothing will appear on the screen - vpDisplay::flush(I); - - // Create a color image - vpImage<vpRGBa> Ioverlay ; - // Updates the color image with the original loaded image and the overlay - vpDisplay::getImage(I, Ioverlay) ; - - // Write the color image on the disk - filename = "./Klimt.overlay.ppm"; - vpImageIo::write(Ioverlay, filename) ; - - // If click is allowed, wait for a mouse click to close the display - std::cout << "\nA click to close the windows..." << std::endl; - // Wait for a blocking mouse click - vpDisplay::getClick(I) ; - - // Close the display - vpDisplay::close(I); + vpDisplay::displayCross(I, ip, 20, vpColor::red, 3) ; + + // Display in overlay a horizontal red line + ip1.set_i( 10 ); + ip1.set_j( 0 ); + ip2.set_i( 10 ); + ip2.set_j( I.getWidth() ); + vpDisplay::displayLine(I, ip1, ip2, vpColor::red, 3) ; + + // Display in overlay a vertical green dot line + ip1.set_i( 0 ); + ip1.set_j( 20 ); + ip2.set_i( I.getWidth() ); + ip2.set_j( 20 ); + vpDisplay::displayDotLine(I, ip1, ip2, vpColor::green, 3) ; + + // Display in overlay a blue arrow + ip1.set_i( 0 ); + ip1.set_j( 0 ); + ip2.set_i( 100 ); + ip2.set_j( 100 ); + vpDisplay::displayArrow(I, ip1, ip2, vpColor::blue, 8, 4, 3) ; + + // Display in overlay some circles. The position of the center is 200, 200 + // the radius is increased by 20 pixels for each circle + for (unsigned i=0 ; i < 5 ; i++) { + ip.set_i( 200 ); + ip.set_j( 200 ); + vpDisplay::displayCircle(I, ip, 20*i, vpColor::white, false, 3) ; + } + + // Display in overlay a rectangle. + // The position of the top left corner is 300, 200. + // The width is 200. The height is 100. + ip.set_i( 280 ); + ip.set_j( 150 ); + vpDisplay::displayRectangle(I, ip, 270, 30,vpColor::purple, false, 3) ; + + // Display in overlay a yellow string + ip.set_i( 300 ); + ip.set_j( 160 ); + vpDisplay::displayCharString(I, ip, + "ViSP is a marvelous software", + vpColor::black) ; + //Flush the display : without this line nothing will appear on the screen + vpDisplay::flush(I); + + // Create a color image + vpImage<vpRGBa> Ioverlay ; + // Updates the color image with the original loaded image and the overlay + vpDisplay::getImage(I, Ioverlay) ; + + // Write the color image on the disk + filename = "./Klimt.overlay.ppm"; + vpImageIo::write(Ioverlay, filename) ; + + // If click is allowed, wait for a mouse click to close the display + std::cout << "\nA click to close the windows..." << std::endl; + // Wait for a blocking mouse click + vpDisplay::getClick(I) ; + + // Close the display + vpDisplay::close(I); #endif - return 0; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } diff --git a/example/manual/image-manipulation/manGrab1394-2.cpp b/example/manual/image-manipulation/manGrab1394-2.cpp index 7d4e4494de3b3a24bbee9e5faec91da6a156d7e2..81d2ce56b30abaa381b4194fd78dd5268c5e7120 100644 --- a/example/manual/image-manipulation/manGrab1394-2.cpp +++ b/example/manual/image-manipulation/manGrab1394-2.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: manGrab1394-2.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: manGrab1394-2.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -62,32 +62,37 @@ int main() { #ifdef VISP_HAVE_DC1394_2 + try { + unsigned int ncameras; // Number of cameras on the bus + vp1394TwoGrabber g; + g.getNumCameras(ncameras); + vpImage<unsigned char> *I = new vpImage<unsigned char> [ncameras]; - unsigned int ncameras; // Number of cameras on the bus - vp1394TwoGrabber g; - g.getNumCameras(ncameras); - vpImage<unsigned char> *I = new vpImage<unsigned char> [ncameras]; - - // If the first camera supports vpVIDEO_MODE_640x480_YUV422 video mode - g.setCamera(0); - g.setVideoMode(vp1394TwoGrabber::vpVIDEO_MODE_640x480_YUV422); - - // If all cameras support 30 fps acquisition - for (unsigned int camera=0; camera < ncameras; camera ++) { - g.setCamera(camera); - g.setFramerate(vp1394TwoGrabber::vpFRAMERATE_30); - } - - for ( ; ; ) { + // If the first camera supports vpVIDEO_MODE_640x480_YUV422 video mode + g.setCamera(0); + g.setVideoMode(vp1394TwoGrabber::vpVIDEO_MODE_640x480_YUV422); + + // If all cameras support 30 fps acquisition for (unsigned int camera=0; camera < ncameras; camera ++) { - // Acquire successively images from the different cameras g.setCamera(camera); - g.acquire(I[camera]); + g.setFramerate(vp1394TwoGrabber::vpFRAMERATE_30); } + + for ( ; ; ) { + for (unsigned int camera=0; camera < ncameras; camera ++) { + // Acquire successively images from the different cameras + g.setCamera(camera); + g.acquire(I[camera]); + } + } + delete [] I; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - delete [] I; #endif - return 0; } diff --git a/example/manual/image-manipulation/manGrabDirectShow.cpp b/example/manual/image-manipulation/manGrabDirectShow.cpp index e524cd2e69072e3e5806bd10e2195c5703058f7d..43f925ca4750b7b5677de9c9092f4b11fef8d290 100644 --- a/example/manual/image-manipulation/manGrabDirectShow.cpp +++ b/example/manual/image-manipulation/manGrabDirectShow.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: manGrabDirectShow.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: manGrabDirectShow.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -59,24 +59,31 @@ int main() { - vpImage<unsigned char> I; // Grey level image - + try { + vpImage<unsigned char> I; // Grey level image + #ifdef VISP_HAVE_DIRECTSHOW - vpDirectShowGrabber g; // Create the grabber - if(g.getDeviceNumber() == 0) //test if a camera is connected - { - g.close(); - return -1; - } - - g.open(); // Initialize the grabber - - g.setImageSize(640,480); // If the camera supports 640x480 image size - g.setFramerate(30); // If the camera supports 30fps framerate - - for ( ; ; ) - g.acquire(I); // Acquire an image + vpDirectShowGrabber g; // Create the grabber + if(g.getDeviceNumber() == 0) //test if a camera is connected + { + g.close(); + return -1; + } + + g.open(); // Initialize the grabber + + g.setImageSize(640,480); // If the camera supports 640x480 image size + g.setFramerate(30); // If the camera supports 30fps framerate + + for ( ; ; ) + g.acquire(I); // Acquire an image #endif - return 0; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } + } diff --git a/example/manual/image-manipulation/manGrabDisk.cpp b/example/manual/image-manipulation/manGrabDisk.cpp index c5ab19c38c02a20067706e82cedf57e0bfec9509..6bafc461e00ec2bb325a2a943551c80ed706f845 100644 --- a/example/manual/image-manipulation/manGrabDisk.cpp +++ b/example/manual/image-manipulation/manGrabDisk.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: manGrabDisk.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: manGrabDisk.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -59,36 +59,43 @@ int main() { - vpImage<unsigned char> I; // Grey level image + try { + vpImage<unsigned char> I; // Grey level image - // Declare a framegrabber able to read a sequence of successive - // images from the disk - vpDiskGrabber g; + // Declare a framegrabber able to read a sequence of successive + // images from the disk + vpDiskGrabber g; - // Set the path to the directory containing the sequence - g.setDirectory("/tmp"); - // Set the image base name. The directory and the base name constitute - // the constant part of the full filename - g.setBaseName("image"); - // Set the step between two images of the sequence - g.setStep(3); - // Set the number of digits to build the image number - g.setNumberOfZero(4); - // Set the first frame number of the sequence - g.setImageNumber(1); - // Set the file extension of the images of the sequence - g.setExtension("pgm"); + // Set the path to the directory containing the sequence + g.setDirectory("/tmp"); + // Set the image base name. The directory and the base name constitute + // the constant part of the full filename + g.setBaseName("image"); + // Set the step between two images of the sequence + g.setStep(3); + // Set the number of digits to build the image number + g.setNumberOfZero(4); + // Set the first frame number of the sequence + g.setImageNumber(1); + // Set the file extension of the images of the sequence + g.setExtension("pgm"); - // Open the framegrabber by loading the first image of the sequence - g.open(I) ; + // Open the framegrabber by loading the first image of the sequence + g.open(I) ; - // this is the loop over the image sequence - for(int cpt = 0; cpt < 100; cpt++) - { - // read the image and then increment the image counter so that the next - // call to acquire(I) will get the next image - g.acquire(I) ; - } + // this is the loop over the image sequence + for(int cpt = 0; cpt < 100; cpt++) + { + // read the image and then increment the image counter so that the next + // call to acquire(I) will get the next image + g.acquire(I) ; + } - return 0; + return 0; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } diff --git a/example/manual/image-manipulation/manGrabOpenCV.cpp b/example/manual/image-manipulation/manGrabOpenCV.cpp index 1bb26dd32efb99b27dcfd620633bfe247b98ef19..c2928ac0410bc4da86f30787404c05b5cc530b11 100644 --- a/example/manual/image-manipulation/manGrabOpenCV.cpp +++ b/example/manual/image-manipulation/manGrabOpenCV.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: manGrabOpenCV.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: manGrabOpenCV.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/example/manual/image-manipulation/manGrabV4l2.cpp b/example/manual/image-manipulation/manGrabV4l2.cpp index de32fd5d16de8821e80618aa959d61f35f1f974d..21910d57bd5dcd9a8c2efb16eef7b3346dbaf02a 100644 --- a/example/manual/image-manipulation/manGrabV4l2.cpp +++ b/example/manual/image-manipulation/manGrabV4l2.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: manGrabV4l2.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: manGrabV4l2.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -57,19 +57,24 @@ int main() { + try { + vpImage<unsigned char> I; // Grey level image - vpImage<unsigned char> I; // Grey level image - #ifdef VISP_HAVE_V4L2 - vpV4l2Grabber g; - g.setInput(2); // Input 2 on the board - g.setWidth(768); // Acquired images are 768 width - g.setHeight(576); // Acquired images are 576 height - g.setNBuffers(3); // 3 ring buffers to ensure real-time acquisition - g.open(I); // Open the grabber - for ( ; ; ) - g.acquire(I); // Acquire a 768x576 grey image + vpV4l2Grabber g; + g.setInput(2); // Input 2 on the board + g.setWidth(768); // Acquired images are 768 width + g.setHeight(576); // Acquired images are 576 height + g.setNBuffers(3); // 3 ring buffers to ensure real-time acquisition + g.open(I); // Open the grabber + for ( ; ; ) + g.acquire(I); // Acquire a 768x576 grey image #endif - return 0; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } diff --git a/example/manual/moments/manServoMomentsSimple.cpp b/example/manual/moments/manServoMomentsSimple.cpp index 7e684fb25b113f89f4a1f1183c2e396ce02a85d1..6cebf4154a0ffd2af9c979a4462e8f4bb4cceaa8 100644 --- a/example/manual/moments/manServoMomentsSimple.cpp +++ b/example/manual/moments/manServoMomentsSimple.cpp @@ -3,7 +3,7 @@ * $Id: servoMomentPolygon.cpp 3323 2011-09-13 15:23:56Z fnovotny $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -58,7 +58,11 @@ #include <limits> #include <iostream> //some console output //this function converts the plane defined by the cMo to 1/Z=Ax+By+C plane form -void cMoToABC(vpHomogeneousMatrix& cMo, double& A,double& B, double& C){ + +void cMoToABC(vpHomogeneousMatrix& cMo, double& A,double& B, double& C); + +void cMoToABC(vpHomogeneousMatrix& cMo, double& A,double& B, double& C) +{ vpPlane pl; pl.setABCD(0,0,1.0,0); pl.changeFrame(cMo); @@ -76,98 +80,102 @@ void cMoToABC(vpHomogeneousMatrix& cMo, double& A,double& B, double& C){ int main() { - double x[8] = { 1,3, 4,-1 ,-3,-2,-1,1}; - double y[8] = { 0,1, 4, 4, -2,-2, 1,0}; - double A,B,C,Ad,Bd,Cd; - - int nbpoints = 8; - std::vector<vpPoint> vec_p,vec_p_d; // vectors that contain the vertices of the contour polygon - - vpHomogeneousMatrix cMo(0.1,0.0,1.0,vpMath::rad(0),vpMath::rad(0),vpMath::rad(0)); - vpHomogeneousMatrix cdMo(vpHomogeneousMatrix(0.0,0.0,1.0,vpMath::rad(0),vpMath::rad(0),-vpMath::rad(0))); - - cMoToABC(cMo,A,B,C); - cMoToABC(cdMo,Ad,Bd,Cd); - // Define source and destination polygons - for (int i = 0 ; i < nbpoints ; i++){ - vpPoint p; - p.setWorldCoordinates(x[i],y[i],0.0); - p.track(cMo) ; - vec_p.push_back(p); - p.track(cdMo) ; - vec_p_d.push_back(p); + try { + double x[8] = { 1,3, 4,-1 ,-3,-2,-1,1}; + double y[8] = { 0,1, 4, 4, -2,-2, 1,0}; + double A,B,C,Ad,Bd,Cd; + + int nbpoints = 8; + std::vector<vpPoint> vec_p,vec_p_d; // vectors that contain the vertices of the contour polygon + + vpHomogeneousMatrix cMo(0.1,0.0,1.0,vpMath::rad(0),vpMath::rad(0),vpMath::rad(0)); + vpHomogeneousMatrix cdMo(vpHomogeneousMatrix(0.0,0.0,1.0,vpMath::rad(0),vpMath::rad(0),-vpMath::rad(0))); + + cMoToABC(cMo,A,B,C); + cMoToABC(cdMo,Ad,Bd,Cd); + // Define source and destination polygons + for (int i = 0 ; i < nbpoints ; i++){ + vpPoint p; + p.setWorldCoordinates(x[i],y[i],0.0); + p.track(cMo) ; + vec_p.push_back(p); + p.track(cdMo) ; + vec_p_d.push_back(p); + } + + vpMomentObject cur(6); // Create a source moment object with 6 as maximum order + cur.setType(vpMomentObject::DENSE_POLYGON); // The object is defined by a countour polygon + cur.fromVector(vec_p); // Init the dense object with the source polygon + + vpMomentObject dst(6); // Create a destination moment object with 6 as maximum order + dst.setType(vpMomentObject::DENSE_POLYGON); // The object is defined by a countour polygon + dst.fromVector(vec_p_d); // Init the dense object with the destination polygon + + //init classic moment primitives (for source) + vpMomentCommon mdb_cur(vpMomentCommon::getSurface(dst),vpMomentCommon::getMu3(dst),vpMomentCommon::getAlpha(dst)); //Init classic features + vpFeatureMomentCommon fmdb_cur(mdb_cur); + + ////init classic moment primitives (for destination) + vpMomentCommon mdb_dst(vpMomentCommon::getSurface(dst),vpMomentCommon::getMu3(dst),vpMomentCommon::getAlpha(dst)); //Init classic features + vpFeatureMomentCommon fmdb_dst(mdb_dst); + + //update+compute moment primitives from object (for destination) + mdb_dst.updateAll(dst); + //update+compute features (+interaction matrixes) from plane + fmdb_dst.updateAll(Ad,Bd,Cd); + + //define visual servoing task + vpServo task; + task.setServo(vpServo::EYEINHAND_CAMERA); + task.setInteractionMatrixType(vpServo::CURRENT); + task.setLambda(1) ; + + task.addFeature(fmdb_cur.getFeatureGravityNormalized(),fmdb_dst.getFeatureGravityNormalized()); + task.addFeature(fmdb_cur.getFeatureAn(),fmdb_dst.getFeatureAn()); + //the object is NOT symmetric + //select C4 and C6 + task.addFeature(fmdb_cur.getFeatureCInvariant(),fmdb_dst.getFeatureCInvariant(), + vpFeatureMomentCInvariant::selectC4() | vpFeatureMomentCInvariant::selectC6()); + task.addFeature(fmdb_cur.getFeatureAlpha(),fmdb_dst.getFeatureAlpha()); + + vpBasicFeature *al = new vpFeatureMomentAlpha(mdb_dst,0,0,1.); + al->init(); + al->error(*al); + //param robot + vpRobotCamera robot ; + float sampling_time = 0.010f; // Sampling period in seconds + robot.setSamplingTime(sampling_time); + robot.setPosition(cMo); + + do{ + robot.getPosition(cMo); + vec_p.clear(); + + for (int i = 0 ; i < nbpoints ; i++){ + vpPoint p; + p.setWorldCoordinates(x[i],y[i],0.0); + p.track(cMo) ; + vec_p.push_back(p); + } + cMoToABC(cMo,A,B,C); + + cur.fromVector(vec_p); + //update+compute moment primitives from object (for source) + mdb_cur.updateAll(cur); + //update+compute features (+interaction matrixes) from plane + fmdb_cur.updateAll(A,B,C); + + vpColVector v = task.computeControlLaw(); + task.print(); + robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + double t = vpTime::measureTimeMs(); + vpTime::wait(t, sampling_time * 1000); // Wait 10 ms + } while(( task.getError() ).sumSquare()>0.005); + std::cout << "final error=" << ( task.getError() ).sumSquare() << std::endl; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - - vpMomentObject cur(6); // Create a source moment object with 6 as maximum order - cur.setType(vpMomentObject::DENSE_POLYGON); // The object is defined by a countour polygon - cur.fromVector(vec_p); // Init the dense object with the source polygon - - vpMomentObject dst(6); // Create a destination moment object with 6 as maximum order - dst.setType(vpMomentObject::DENSE_POLYGON); // The object is defined by a countour polygon - dst.fromVector(vec_p_d); // Init the dense object with the destination polygon - - //init classic moment primitives (for source) - vpMomentCommon mdb_cur(vpMomentCommon::getSurface(dst),vpMomentCommon::getMu3(dst),vpMomentCommon::getAlpha(dst)); //Init classic features - vpFeatureMomentCommon fmdb_cur(mdb_cur); - - ////init classic moment primitives (for destination) - vpMomentCommon mdb_dst(vpMomentCommon::getSurface(dst),vpMomentCommon::getMu3(dst),vpMomentCommon::getAlpha(dst)); //Init classic features - vpFeatureMomentCommon fmdb_dst(mdb_dst); - - - //update+compute moment primitives from object (for destination) - mdb_dst.updateAll(dst); - //update+compute features (+interaction matrixes) from plane - fmdb_dst.updateAll(Ad,Bd,Cd); - - //define visual servoing task - vpServo task; - task.setServo(vpServo::EYEINHAND_CAMERA); - task.setInteractionMatrixType(vpServo::CURRENT); - task.setLambda(1) ; - - task.addFeature(fmdb_cur.getFeatureGravityNormalized(),fmdb_dst.getFeatureGravityNormalized()); - task.addFeature(fmdb_cur.getFeatureAn(),fmdb_dst.getFeatureAn()); - //the object is NOT symmetric - //select C4 and C6 - task.addFeature(fmdb_cur.getFeatureCInvariant(),fmdb_dst.getFeatureCInvariant(), - vpFeatureMomentCInvariant::selectC4() | vpFeatureMomentCInvariant::selectC6()); - task.addFeature(fmdb_cur.getFeatureAlpha(),fmdb_dst.getFeatureAlpha()); - - vpBasicFeature *al = new vpFeatureMomentAlpha(mdb_dst,0,0,1.); - al->init(); - al->error(*al); - //param robot - vpRobotCamera robot ; - float sampling_time = 0.010f; // Sampling period in seconds - robot.setSamplingTime(sampling_time); - robot.setPosition(cMo); - - do{ - robot.getPosition(cMo); - vec_p.clear(); - - for (int i = 0 ; i < nbpoints ; i++){ - vpPoint p; - p.setWorldCoordinates(x[i],y[i],0.0); - p.track(cMo) ; - vec_p.push_back(p); - } - cMoToABC(cMo,A,B,C); - - cur.fromVector(vec_p); - //update+compute moment primitives from object (for source) - mdb_cur.updateAll(cur); - //update+compute features (+interaction matrixes) from plane - fmdb_cur.updateAll(A,B,C); - - vpColVector v = task.computeControlLaw(); - task.print(); - robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; - double t = vpTime::measureTimeMs(); - vpTime::wait(t, sampling_time * 1000); // Wait 10 ms - }while(( task.getError() ).sumSquare()>0.005); - std::cout << "final error=" << ( task.getError() ).sumSquare() << std::endl; - - return 0; } diff --git a/example/manual/ogre/HelloWorldOgre.cpp b/example/manual/ogre/HelloWorldOgre.cpp index 5b58452d5a92345ca474933127b69369a0f33c63..bb07474f57668e5af100d6e0ca271b14cef3b540 100644 --- a/example/manual/ogre/HelloWorldOgre.cpp +++ b/example/manual/ogre/HelloWorldOgre.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: HelloWorldOgre.cpp 4111 2013-02-06 17:27:14Z fspindle $ + * $Id: HelloWorldOgre.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -57,89 +57,104 @@ int main() { + try { #if defined(VISP_HAVE_OGRE) #if defined(VISP_HAVE_V4L2) || defined(VISP_HAVE_DC1394_2) || defined(VISP_HAVE_DIRECTSHOW) || defined(VISP_HAVE_OPENCV) - // Now we try to find an available framegrabber + // Now we try to find an available framegrabber #if defined(VISP_HAVE_V4L2) - // Video for linux 2 grabber - vpV4l2Grabber grabber; + // Video for linux 2 grabber + vpV4l2Grabber grabber; #elif defined(VISP_HAVE_DC1394_2) - // libdc1394-2 - vp1394TwoGrabber grabber; + // libdc1394-2 + vp1394TwoGrabber grabber; #elif defined(VISP_HAVE_DIRECTSHOW) - // OpenCV to gather images - vpOpenCVGrabber grabber; + // OpenCV to gather images + vpDirectShowGrabber grabber; #elif defined(VISP_HAVE_OPENCV) - // OpenCV to gather images - vpOpenCVGrabber grabber; + // OpenCV to gather images + vpOpenCVGrabber grabber; #endif - // Image to stock gathered data - // Here we acquire a color image. The consequence will be that - // the background texture used in Ogre renderer will be also in color. - vpImage<vpRGBa> I; - // Open frame grabber - // Here we acquire an image from an available framegrabber to update - // the image size - grabber.open(I); + // Image to stock gathered data + // Here we acquire a color image. The consequence will be that + // the background texture used in Ogre renderer will be also in color. + vpImage<vpRGBa> I; + // Open frame grabber + // Here we acquire an image from an available framegrabber to update + // the image size + grabber.open(I); + grabber.acquire(I); - // Parameters of our camera - double px = 565; - double py = 565; - double u0 = grabber.getWidth() / 2; - double v0 = grabber.getHeight() / 2; - vpCameraParameters cam(px,py,u0,v0); - // The matrix with our pose - // Defines the pose of the object in the camera frame - vpHomogeneousMatrix cMo; + // Parameters of our camera + double px = 565; + double py = 565; + double u0 = grabber.getWidth() / 2; + double v0 = grabber.getHeight() / 2; + vpCameraParameters cam(px,py,u0,v0); + // The matrix with our pose + // Defines the pose of the object in the camera frame + vpHomogeneousMatrix cMo; - // Our object - // A simulator with the camera parameters defined above, - // a grey level background image and of the good size - vpAROgre ogre(cam, (unsigned int)grabber.getWidth(), (unsigned int)grabber.getHeight()); - // Initialisation - // Here we load the requested plugins specified in the "plugins.cfg" file - // and the resources specified in the "resources.cfg" file - // These two files can be found respectively in ViSP_HAVE_OGRE_PLUGINS_PATH - // and ViSP_HAVE_OGRE_RESOURCES_PATH folders - ogre.init(I); + // Our object + // A simulator with the camera parameters defined above, + // a grey level background image and of the good size + vpAROgre ogre(cam, (unsigned int)grabber.getWidth(), (unsigned int)grabber.getHeight()); + // Initialisation + // Here we load the requested plugins specified in the "plugins.cfg" file + // and the resources specified in the "resources.cfg" file + // These two files can be found respectively in ViSP_HAVE_OGRE_PLUGINS_PATH + // and ViSP_HAVE_OGRE_RESOURCES_PATH folders + ogre.init(I); - // Create a basic scene - // ----------------------------------- - // Loading things - // ----------------------------------- - // As you will see in section 5, our - // application knows locations where - // it can search for medias. - // Here we use a mesh included in - // the installation files : a robot. - // ----------------------------------- - // Here we load the "robot.mesh" model that is found thanks to the resources locations - // specified in the "resources.cfg" file - ogre.load("Robot", "robot.mesh"); - ogre.setPosition("Robot", vpTranslationVector(0, 0.05, 0.5)); - ogre.setScale("Robot", 0.001f,0.001f,0.001f); - ogre.setRotation("Robot", vpRotationMatrix(vpRxyzVector(M_PI, -M_PI/4, 0))); + // Create a basic scene + // ----------------------------------- + // Loading things + // ----------------------------------- + // As you will see in section 5, our + // application knows locations where + // it can search for medias. + // Here we use a mesh included in + // the installation files : a robot. + // ----------------------------------- + // Here we load the "robot.mesh" model that is found thanks to the resources locations + // specified in the "resources.cfg" file + ogre.load("Robot", "robot.mesh"); + ogre.setPosition("Robot", vpTranslationVector(-0.3, 0.2, 0)); + ogre.setScale("Robot", 0.001f,0.001f,0.001f); + ogre.setRotation("Robot", vpRotationMatrix(vpRxyzVector(M_PI, 0, 0))); + cMo[2][3] = 1.; // Z = 1 meter - // Rendering loop, ended with on escape - while(ogre.continueRendering()){ - // Image Acquisition - // Acquire a new image - grabber.acquire(I); - //Pose computation - // ... - // cMo updated - // Display the robot at the position specified by cMo with vpAROgre - ogre.display(I,cMo); - } - // Release video device - grabber.close(); + std::cout << "cMo:\n" << cMo << std::endl; + + // Rendering loop, ended with on escape + while(ogre.continueRendering()){ + // Image Acquisition + // Acquire a new image + grabber.acquire(I); + //Pose computation + // ... + // cMo updated + // Display the robot at the position specified by cMo with vpAROgre + ogre.display(I,cMo); + } + // Release video device + grabber.close(); #else - std::cout << "You need an available framegrabber to run this example" << std::endl; + std::cout << "You need an available framegrabber to run this example" << std::endl; #endif #else - std::cout << "You Ogre3D to run this example" << std::endl; + std::cout << "You need Ogre3D to run this example" << std::endl; #endif + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } + catch(...) { + std::cout << "Catch an exception " << std::endl; + return 1; + } } diff --git a/example/manual/ogre/HelloWorldOgreAdvanced.cpp b/example/manual/ogre/HelloWorldOgreAdvanced.cpp index 3ed4bc6c6c7ac52bbbd1dd5cdaeeff08bc705dcc..7bb57a4d929d39b89a8a456b075f04131201242e 100644 --- a/example/manual/ogre/HelloWorldOgreAdvanced.cpp +++ b/example/manual/ogre/HelloWorldOgreAdvanced.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: HelloWorldOgreAdvanced.cpp 4111 2013-02-06 17:27:14Z fspindle $ + * $Id: HelloWorldOgreAdvanced.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -70,6 +70,7 @@ public: unsigned int width = 640, unsigned int height = 480) : vpAROgre(cam, width, height) { + mAnimationState = NULL; } protected: @@ -79,9 +80,9 @@ protected: Ogre::Entity* robot = mSceneMgr->createEntity("Robot", "robot.mesh"); // Attach robot to scene graph Ogre::SceneNode* RobotNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("Robot"); - RobotNode->setPosition(0.0, 0.05f, 0.5); + RobotNode->setPosition((Ogre::Real)-0.3, (Ogre::Real)0.2, (Ogre::Real)0); RobotNode->attachObject(robot); - RobotNode->scale(0.001f,0.001f,0.001f); + RobotNode->scale((Ogre::Real)0.001,(Ogre::Real)0.001,(Ogre::Real)0.001); RobotNode->pitch(Ogre::Degree(180)); RobotNode->yaw(Ogre::Degree(-90)); @@ -108,63 +109,76 @@ protected: int main() { + try { #if defined(VISP_HAVE_OGRE) #if defined(VISP_HAVE_V4L2) || defined(VISP_HAVE_DC1394_2) || defined(VISP_HAVE_DIRECTSHOW) || defined(VISP_HAVE_OPENCV) - // Now we try to find an available framegrabber + // Now we try to find an available framegrabber #if defined(VISP_HAVE_V4L2) - // Video for linux 2 grabber - vpV4l2Grabber grabber; + // Video for linux 2 grabber + vpV4l2Grabber grabber; #elif defined(VISP_HAVE_DC1394_2) - // libdc1394-2 - vp1394TwoGrabber grabber; + // libdc1394-2 + vp1394TwoGrabber grabber; #elif defined(VISP_HAVE_DIRECTSHOW) - // OpenCV to gather images - vpOpenCVGrabber grabber; + // OpenCV to gather images + vpOpenCVGrabber grabber; #elif defined(VISP_HAVE_OPENCV) - // OpenCV to gather images - vpOpenCVGrabber grabber; + // OpenCV to gather images + vpOpenCVGrabber grabber; #endif - // Image to store gathered data - // Here we acquire a grey level image. The consequence will be that - // the background texture used in Ogre renderer will be also in grey - // level. - vpImage<unsigned char> I; - // Open frame grabber - // Here we acquire an image from an available framegrabber to update - // the image size - grabber.open(I); - // Parameters of our camera - double px = 565; - double py = 565; - double u0 = grabber.getWidth() / 2; - double v0 = grabber.getHeight() / 2; - vpCameraParameters cam(px,py,u0,v0); - // The matrix with our pose - vpHomogeneousMatrix cMo; - - // Our object - vpAROgreAdvanced ogre(cam, (unsigned int)grabber.getWidth(), (unsigned int)grabber.getHeight()); - // Initialisation - ogre.init(I); - - // Rendering loop - while(ogre.continueRendering()){ - // Image Acquisition + // Image to store gathered data + // Here we acquire a grey level image. The consequence will be that + // the background texture used in Ogre renderer will be also in grey + // level. + vpImage<unsigned char> I; + // Open frame grabber + // Here we acquire an image from an available framegrabber to update + // the image size + grabber.open(I); grabber.acquire(I); - // Pose computation - // ... - // cMo updated - // Display with vpAROgre - ogre.display(I, cMo); - } - // Release video device - grabber.close(); + // Parameters of our camera + double px = 565; + double py = 565; + double u0 = grabber.getWidth() / 2; + double v0 = grabber.getHeight() / 2; + vpCameraParameters cam(px,py,u0,v0); + // The matrix with our pose + vpHomogeneousMatrix cMo; + cMo[2][3] = 1.; // Z = 1 meter + + // Our object + vpAROgreAdvanced ogre(cam, (unsigned int)grabber.getWidth(), (unsigned int)grabber.getHeight()); + // Initialisation + ogre.init(I); + + // Rendering loop + while(ogre.continueRendering()){ + // Image Acquisition + grabber.acquire(I); + // Pose computation + // ... + // cMo updated + // Display with vpAROgre + ogre.display(I, cMo); + } + // Release video device + grabber.close(); #else - std::cout << "You need an available framegrabber to run this example" << std::endl; + std::cout << "You need an available framegrabber to run this example" << std::endl; #endif #else - std::cout << "You Ogre3D to run this example" << std::endl; + std::cout << "You need Ogre3D to run this example" << std::endl; #endif + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } + catch(...) { + std::cout << "Catch an exception " << std::endl; + return 1; + } } diff --git a/example/manual/simulation/manServo4PointsDisplay.cpp b/example/manual/simulation/manServo4PointsDisplay.cpp index fdd213ed3887682abc7ce5dd65616265df6a4d65..9028c79bd3c1ce942808514ff87f041b43eb3dec 100755 --- a/example/manual/simulation/manServo4PointsDisplay.cpp +++ b/example/manual/simulation/manServo4PointsDisplay.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: manServo4PointsDisplay.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: manServo4PointsDisplay.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -73,129 +73,135 @@ int main() { - ////////////////////////////////////////// - // sets the initial camera location - vpHomogeneousMatrix cMo(0.3,0.2,3, - vpMath::rad(0),vpMath::rad(0),vpMath::rad(40)) ; - - /////////////////////////////////// - // initialize the robot - vpRobotCamera robot ; - robot.setSamplingTime(0.04); // 40ms - robot.setPosition(cMo) ; - - //initialize the camera parameters - vpCameraParameters cam(800,800,240,180); - - //Image definition - unsigned int height = 360 ; - unsigned int width = 480 ; - vpImage<unsigned char> I(height,width); - - //Display initialization - vpDisplayGTK disp; - disp.init(I,100,100,"Simulation display"); - - //////////////////////////////////////// - // Desired visual features initialization - - // sets the points coordinates in the object frame (in meter) - 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) ; - - // sets the desired camera location - vpHomogeneousMatrix cMo_d(0,0,1,0,0,0) ; - - // computes the 3D point coordinates in the camera frame and its 2D coordinates - for (int i = 0 ; i < 4 ; i++) - point[i].project(cMo_d) ; - - // creates the associated features - vpFeaturePoint pd[4] ; - for (int i = 0 ; i < 4 ; i++) - vpFeatureBuilder::create(pd[i],point[i]) ; - - - /////////////////////////////////////// - // Current visual features initialization - - // computes the 3D point coordinates in the camera frame and its 2D coordinates - for (int i = 0 ; i < 4 ; i++) - point[i].project(cMo) ; - - // creates the associated features - vpFeaturePoint p[4] ; - for (int i = 0 ; i < 4 ; i++) - vpFeatureBuilder::create(p[i],point[i]) ; - - - ///////////////////////////////// - // Task defintion - vpServo task ; - // we want an eye-in-hand control law ; - task.setServo(vpServo::EYEINHAND_L_cVe_eJe) ; - task.setInteractionMatrixType(vpServo::DESIRED, vpServo::PSEUDO_INVERSE) ; - - // Set the position of the camera in the end-effector frame - vpHomogeneousMatrix cMe ; - vpVelocityTwistMatrix cVe(cMe) ; - task.set_cVe(cVe) ; - // Set the Jacobian (expressed in the end-effector frame) - vpMatrix eJe ; - robot.get_eJe(eJe) ; - task.set_eJe(eJe) ; - - // we want to see a point on a point - for (int i = 0 ; i < 4 ; i++) - task.addFeature(p[i],pd[i]) ; - // Set the gain - task.setLambda(1.0) ; - // Print the current information about the task - task.print(); - - - //////////////////////////////////////////////// - // The control loop - int k = 0; - while(k++ < 200){ - double t = vpTime::measureTimeMs(); - - // Display the image background - vpDisplay::display(I); - - // Update the current features + try { + ////////////////////////////////////////// + // sets the initial camera location + vpHomogeneousMatrix cMo(0.3,0.2,3, + vpMath::rad(0),vpMath::rad(0),vpMath::rad(40)) ; + + /////////////////////////////////// + // initialize the robot + vpRobotCamera robot ; + robot.setSamplingTime(0.04); // 40ms + robot.setPosition(cMo) ; + + //initialize the camera parameters + vpCameraParameters cam(800,800,240,180); + + //Image definition + unsigned int height = 360 ; + unsigned int width = 480 ; + vpImage<unsigned char> I(height,width); + + //Display initialization + vpDisplayGTK disp; + disp.init(I,100,100,"Simulation display"); + + //////////////////////////////////////// + // Desired visual features initialization + + // sets the points coordinates in the object frame (in meter) + 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) ; + + // sets the desired camera location + vpHomogeneousMatrix cMo_d(0,0,1,0,0,0) ; + + // computes the 3D point coordinates in the camera frame and its 2D coordinates + for (int i = 0 ; i < 4 ; i++) + point[i].project(cMo_d) ; + + // creates the associated features + vpFeaturePoint pd[4] ; + for (int i = 0 ; i < 4 ; i++) + vpFeatureBuilder::create(pd[i],point[i]) ; + + + /////////////////////////////////////// + // Current visual features initialization + + // computes the 3D point coordinates in the camera frame and its 2D coordinates for (int i = 0 ; i < 4 ; i++) - { point[i].project(cMo) ; + + // creates the associated features + vpFeaturePoint p[4] ; + for (int i = 0 ; i < 4 ; i++) vpFeatureBuilder::create(p[i],point[i]) ; - } - - // Display the task features (current and desired) - vpServoDisplay::display(task,cam,I); - vpDisplay::flush(I); - - // Update the robot Jacobian + + + ///////////////////////////////// + // Task defintion + vpServo task ; + // we want an eye-in-hand control law ; + task.setServo(vpServo::EYEINHAND_L_cVe_eJe) ; + task.setInteractionMatrixType(vpServo::DESIRED, vpServo::PSEUDO_INVERSE) ; + + // Set the position of the camera in the end-effector frame + vpHomogeneousMatrix cMe ; + vpVelocityTwistMatrix cVe(cMe) ; + task.set_cVe(cVe) ; + // Set the Jacobian (expressed in the end-effector frame) + vpMatrix eJe ; robot.get_eJe(eJe) ; task.set_eJe(eJe) ; - - // Compute the control law - vpColVector v = task.computeControlLaw() ; - - // Send the computed velocity to the robot and compute the new robot position - robot.setVelocity(vpRobot::ARTICULAR_FRAME, v) ; - robot.getPosition(cMo) ; - + + // we want to see a point on a point + for (int i = 0 ; i < 4 ; i++) + task.addFeature(p[i],pd[i]) ; + // Set the gain + task.setLambda(1.0) ; // Print the current information about the task task.print(); - - // Wait 40 ms - vpTime::wait(t,40); - } - task.kill(); - return 0; + + + //////////////////////////////////////////////// + // The control loop + int k = 0; + while(k++ < 200){ + double t = vpTime::measureTimeMs(); + + // Display the image background + vpDisplay::display(I); + + // Update the current features + for (int i = 0 ; i < 4 ; i++) + { + point[i].project(cMo) ; + vpFeatureBuilder::create(p[i],point[i]) ; + } + + // Display the task features (current and desired) + vpServoDisplay::display(task,cam,I); + vpDisplay::flush(I); + + // Update the robot Jacobian + robot.get_eJe(eJe) ; + task.set_eJe(eJe) ; + + // Compute the control law + vpColVector v = task.computeControlLaw() ; + + // Send the computed velocity to the robot and compute the new robot position + robot.setVelocity(vpRobot::ARTICULAR_FRAME, v) ; + robot.getPosition(cMo) ; + + // Print the current information about the task + task.print(); + + // Wait 40 ms + vpTime::wait(t,40); + } + task.kill(); + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } #else diff --git a/example/manual/simulation/manSimu4Dots.cpp b/example/manual/simulation/manSimu4Dots.cpp index c2df04d2ffc24301dc5430e5d39b341c1a109f80..e915971f142ed6b76cc8908b6e4d56000ce6e106 100755 --- a/example/manual/simulation/manSimu4Dots.cpp +++ b/example/manual/simulation/manSimu4Dots.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: manSimu4Dots.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: manSimu4Dots.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -255,28 +255,35 @@ void *mainLoop (void *_simu) int main() { - vpSimulator simu ; - - // Internal view initialization : view from the robot camera - simu.initInternalViewer(480, 360) ; - // External view initialization : view from an external camera - simu.initExternalViewer(300, 300) ; - - // Inernal camera paramters initialization - vpCameraParameters cam(800,800,240,180) ; - simu.setInternalCameraParameters(cam) ; - - vpTime::wait(500) ; - // Load the scene - std::cout << "Load : ./4Points.iv" << std::endl - << "This file should be in the working directory" << std::endl; - - simu.load("./4points.iv") ; - - // Run the main loop - simu.initApplication(&mainLoop) ; - // Run the simulator - simu.mainLoop() ; + try { + vpSimulator simu ; + + // Internal view initialization : view from the robot camera + simu.initInternalViewer(480, 360) ; + // External view initialization : view from an external camera + simu.initExternalViewer(300, 300) ; + + // Inernal camera paramters initialization + vpCameraParameters cam(800,800,240,180) ; + simu.setInternalCameraParameters(cam) ; + + vpTime::wait(500) ; + // Load the scene + std::cout << "Load : ./4Points.iv" << std::endl + << "This file should be in the working directory" << std::endl; + + simu.load("./4points.iv") ; + + // Run the main loop + simu.initApplication(&mainLoop) ; + // Run the simulator + simu.mainLoop() ; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } #else diff --git a/example/manual/simulation/manSimu4Points.cpp b/example/manual/simulation/manSimu4Points.cpp index 9a31ea4566f973e1aa1e012a61237d869a4eb1c6..4335ef8e7bf5fa92e82dfa314c0f57314297f3f3 100755 --- a/example/manual/simulation/manSimu4Points.cpp +++ b/example/manual/simulation/manSimu4Points.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: manSimu4Points.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: manSimu4Points.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -207,27 +207,34 @@ void *mainLoop (void *_simu) int main() { - vpSimulator simu ; - - // Internal view initialization : view from the robot camera - simu.initInternalViewer(480, 360) ; - // External view initialization : view from an external camera - simu.initExternalViewer(300, 300) ; - - // Inernal camera paramters initialization - vpCameraParameters cam(800,800,240,180) ; - simu.setInternalCameraParameters(cam) ; - - vpTime::wait(1000) ; - // Load the scene - std::cout << "Load : ./4Points.iv" << std::endl - << "This file should be in the working directory" << std::endl; - simu.load("./4points.iv") ; - - // Run the main loop - simu.initApplication(&mainLoop) ; - // Run the simulator - simu.mainLoop() ; + try { + vpSimulator simu ; + + // Internal view initialization : view from the robot camera + simu.initInternalViewer(480, 360) ; + // External view initialization : view from an external camera + simu.initExternalViewer(300, 300) ; + + // Inernal camera paramters initialization + vpCameraParameters cam(800,800,240,180) ; + simu.setInternalCameraParameters(cam) ; + + vpTime::wait(1000) ; + // Load the scene + std::cout << "Load : ./4Points.iv" << std::endl + << "This file should be in the working directory" << std::endl; + simu.load("./4points.iv") ; + + // Run the main loop + simu.initApplication(&mainLoop) ; + // Run the simulator + simu.mainLoop() ; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } #else diff --git a/example/math/BSpline.cpp b/example/math/BSpline.cpp index 10129045389e1ccb4302a61202ea8e3317f79183..00379d2f30c0f1dee068ca854669c13e5a8a48b7 100644 --- a/example/math/BSpline.cpp +++ b/example/math/BSpline.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: BSpline.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: BSpline.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -75,6 +75,9 @@ // List of allowed command line options #define GETOPTARGS "cdh" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display); + /*! Print the program options. @@ -122,9 +125,9 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; @@ -132,7 +135,7 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) case 'h': usage(argv[0], NULL); return false; break; default: - usage(argv[0], optarg); + usage(argv[0], optarg_); return false; break; } } @@ -141,7 +144,7 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -152,147 +155,145 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) 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); - } + try { + 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<unsigned char> I(540,480); + // 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<unsigned char> I(540,480); - // We open a window using either X11, GTK or GDI. + // We open a window using either X11, GTK or GDI. #if defined VISP_HAVE_X11 - vpDisplayX display; + vpDisplayX display; #elif defined VISP_HAVE_GTK - vpDisplayGTK display; + vpDisplayGTK display; #elif defined VISP_HAVE_GDI - vpDisplayGDI display; + vpDisplayGDI display; #elif defined VISP_HAVE_OPENCV - vpDisplayOpenCV display; + vpDisplayOpenCV display; #elif defined VISP_HAVE_D3D9 - vpDisplayD3D display; + vpDisplayD3D display; #endif - if (opt_display) { - try{ + if (opt_display) { // 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<double> 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<vpImagePoint> 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 :" <<std::endl; + std::cout << "p : " << bSpline.get_p() <<std::endl; + std::cout << "" <<std::endl; + std::cout << "The knot vector :" <<std::endl; + std::list<double> knots_cur; + bSpline.get_knots(knots_cur); + unsigned int i_display=0; + for(std::list<double>::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 :" <<std::endl; + std::list<vpImagePoint> controlPoints_cur; + bSpline.get_controlPoints(controlPoints_cur); + i_display=0; + for(std::list<vpImagePoint>::const_iterator it=controlPoints_cur.begin(); it!=controlPoints_cur.end(); ++it, ++i_display){ + std::cout << i_display << " ---> " << *it << std::endl; } - } - vpBSpline bSpline; - std::list<double> 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<vpImagePoint> 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 :" <<std::endl; - std::cout << "p : " << bSpline.get_p() <<std::endl; - std::cout << "" <<std::endl; - std::cout << "The knot vector :" <<std::endl; - std::list<double> knots_cur; - bSpline.get_knots(knots_cur); - unsigned int i_display=0; - for(std::list<double>::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 :" <<std::endl; - std::list<vpImagePoint> controlPoints_cur; - bSpline.get_controlPoints(controlPoints_cur); - i_display=0; - for(std::list<vpImagePoint>::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 <<std::endl; - unsigned int i = bSpline.findSpan(5/2.0); - std::cout << "The knot interval number for the value u = 5/2 is : " << i <<std::endl; - - vpBasisFunction *N = NULL; - N = bSpline.computeBasisFuns(5/2.0); - std::cout << "The nonvanishing basis functions N(u=5/2) are :" << std::endl; - for (unsigned int j = 0; j < bSpline.get_p()+1; j++) - std::cout << N[j].value << std::endl; - - vpBasisFunction **N2 = NULL; - N2 = bSpline.computeDersBasisFuns(5/2.0, 2); - std::cout << "The first derivatives of the basis functions N'(u=5/2) are :" << std::endl; - for (unsigned int j = 0; j < bSpline.get_p()+1; j++) - std::cout << N2[1][j].value << std::endl; - - std::cout << "The second derivatives of the basis functions N''(u=5/2) are :" << std::endl; - for (unsigned int j = 0; j < bSpline.get_p()+1; j++) - std::cout << N2[2][j].value << std::endl; - - if (opt_display && opt_click_allowed) - { - double u = 0.0; - vpImagePoint pt; - while (u <= 5) + vpBasisFunction *N = NULL; + N = bSpline.computeBasisFuns(5/2.0); + std::cout << "The nonvanishing basis functions N(u=5/2) are :" << std::endl; + for (unsigned int j = 0; j < bSpline.get_p()+1; j++) + std::cout << N[j].value << std::endl; + + vpBasisFunction **N2 = NULL; + N2 = bSpline.computeDersBasisFuns(5/2.0, 2); + std::cout << "The first derivatives of the basis functions N'(u=5/2) are :" << std::endl; + for (unsigned int j = 0; j < bSpline.get_p()+1; j++) + std::cout << N2[1][j].value << std::endl; + + std::cout << "The second derivatives of the basis functions N''(u=5/2) are :" << std::endl; + for (unsigned int j = 0; j < bSpline.get_p()+1; j++) + std::cout << N2[2][j].value << std::endl; + + if (opt_display && opt_click_allowed) { - pt = bSpline.computeCurvePoint(u); - vpDisplay::displayCross(I,pt,4,vpColor::red); - u+=0.01; + double u = 0.0; + while (u <= 5) + { + pt = bSpline.computeCurvePoint(u); + vpDisplay::displayCross(I,pt,4,vpColor::red); + u+=0.01; + } + for(std::list<vpImagePoint>::const_iterator it=controlPoints.begin(); it!= controlPoints.end(); ++it){ + vpDisplay::displayCross(I, *it, 4, vpColor::green); + } + vpDisplay::flush(I) ; + vpDisplay::getClick(I); } - for(std::list<vpImagePoint>::const_iterator it=controlPoints.begin(); it!= controlPoints.end(); ++it){ - vpDisplay::displayCross(I, *it, 4, vpColor::green); + + if (N != NULL) delete[] N; + if (N2 != NULL) + { + for (unsigned int j = 0; j <= 2; j++) + delete[] N2[j]; + delete[] N2; } - vpDisplay::flush(I) ; - vpDisplay::getClick(I); + + return 0; } - - if (N != NULL) delete[] N; - if (N2 != NULL) - { - for (unsigned int j = 0; j <= 2; j++) - delete[] N2[j]; - delete[] N2; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - - return 0; } #else diff --git a/example/math/CMakeLists.txt b/example/math/CMakeLists.txt index 5e08c60ba870975dc2782058c2e949a3e4faae9a..5c063667580ed9d9c146271f4cecb3889838ce51 100644 --- a/example/math/CMakeLists.txt +++ b/example/math/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/math/Nurbs.cpp b/example/math/Nurbs.cpp index 1423f43448c495424898e284e8b90d18e501ffd8..1bd00c58da491c34e9d6c12a872e9e561992f3b3 100644 --- a/example/math/Nurbs.cpp +++ b/example/math/Nurbs.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: Nurbs.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: Nurbs.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -73,6 +73,8 @@ // List of allowed command line options #define GETOPTARGS "cdh" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display); /*! @@ -121,9 +123,9 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; @@ -131,7 +133,7 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) case 'h': usage(argv[0], NULL); return false; break; default: - usage(argv[0], optarg); + usage(argv[0], optarg_); return false; break; } } @@ -140,7 +142,7 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -151,242 +153,238 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) 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); - } + try { + 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<unsigned char> I(540,480); - vpImage<unsigned char> I2(540,480); - vpImage<unsigned char> I3(540,480); + // 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<unsigned char> I(540,480); + vpImage<unsigned char> I2(540,480); + vpImage<unsigned char> I3(540,480); - // We open a window using either X11, GTK or GDI. + // We open a window using either X11, GTK or GDI. #if defined VISP_HAVE_X11 - vpDisplayX display[3]; + vpDisplayX display[3]; #elif defined VISP_HAVE_GDI - vpDisplayGDI display[3]; + vpDisplayGDI display[3]; #elif defined VISP_HAVE_GTK - vpDisplayGTK display[3]; + vpDisplayGTK display[3]; #elif defined VISP_HAVE_OPENCV - vpDisplayOpenCV display[3]; + vpDisplayOpenCV display[3]; #endif - if (opt_display) { - try{ + if (opt_display) { // 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) ; + } + vpNurbs Nurbs; + std::list<double> 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<vpImagePoint> controlPoints; + std::list<double> 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 :" <<std::endl; + std::cout << "p : " << Nurbs.get_p() <<std::endl; + std::cout << "" <<std::endl; + std::cout << "The knot vector :" <<std::endl; + std::list<double> knots_cur; + Nurbs.get_knots(knots_cur); + unsigned int i_display=0; + for(std::list<double>::const_iterator it=knots_cur.begin(); it!=knots_cur.end(); ++it, ++i_display){ + std::cout << i_display << " ---> " << *it << std::endl; } - catch(...) - { - vpERROR_TRACE("Error while displaying the image") ; - exit(-1); + std::cout << "The control points are :" <<std::endl; + std::list<vpImagePoint> controlPoints_cur; + Nurbs.get_controlPoints(controlPoints_cur); + i_display=0; + for(std::list<vpImagePoint>::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 :" <<std::endl; + std::list<double> weights_cur; + Nurbs.get_weights(weights_cur); + i_display=0; + for(std::list<double>::const_iterator it=weights_cur.begin(); it!=weights_cur.end(); ++it, ++i_display){ + std::cout << i_display << " ---> " << *it << std::endl; } - } - vpNurbs Nurbs; - std::list<double> 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<vpImagePoint> controlPoints; - std::list<double> 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 :" <<std::endl; - std::cout << "p : " << Nurbs.get_p() <<std::endl; - std::cout << "" <<std::endl; - std::cout << "The knot vector :" <<std::endl; - std::list<double> knots_cur; - Nurbs.get_knots(knots_cur); - unsigned int i_display=0; - for(std::list<double>::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 :" <<std::endl; - std::list<vpImagePoint> controlPoints_cur; - Nurbs.get_controlPoints(controlPoints_cur); - i_display=0; - for(std::list<vpImagePoint>::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 :" <<std::endl; - std::list<double> weights_cur; - Nurbs.get_weights(weights_cur); - i_display=0; - for(std::list<double>::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 <<std::endl; - unsigned int i = Nurbs.findSpan(5/2.0); - std::cout << "The knot interval number for the value u = 5/2 is : " << i <<std::endl; - - vpBasisFunction *N = NULL; - N = Nurbs.computeBasisFuns(5/2.0); - std::cout << "The nonvanishing basis functions N(u=5/2) are :" << std::endl; - for (unsigned int j = 0; j < Nurbs.get_p()+1; j++) - std::cout << N[j].value << std::endl; - - vpBasisFunction **N2 = NULL; - N2 = Nurbs.computeDersBasisFuns(5/2.0, 2); - std::cout << "The first derivatives of the basis functions N'(u=5/2) are :" << std::endl; - for (unsigned int j = 0; j < Nurbs.get_p()+1; j++) - std::cout << N2[1][j].value << std::endl; - - std::cout << "The second derivatives of the basis functions N''(u=5/2) are :" << std::endl; - for (unsigned int j = 0; j < Nurbs.get_p()+1; j++) - std::cout << N2[2][j].value << std::endl; - - if (opt_display && opt_click_allowed) - { - double u = 0.0; - vpImagePoint pt; - while (u <= 5) + vpBasisFunction *N = NULL; + N = Nurbs.computeBasisFuns(5/2.0); + std::cout << "The nonvanishing basis functions N(u=5/2) are :" << std::endl; + for (unsigned int j = 0; j < Nurbs.get_p()+1; j++) + std::cout << N[j].value << std::endl; + + vpBasisFunction **N2 = NULL; + N2 = Nurbs.computeDersBasisFuns(5/2.0, 2); + std::cout << "The first derivatives of the basis functions N'(u=5/2) are :" << std::endl; + for (unsigned int j = 0; j < Nurbs.get_p()+1; j++) + std::cout << N2[1][j].value << std::endl; + + std::cout << "The second derivatives of the basis functions N''(u=5/2) are :" << std::endl; + for (unsigned int j = 0; j < Nurbs.get_p()+1; j++) + std::cout << N2[2][j].value << std::endl; + + if (opt_display && opt_click_allowed) { - pt = Nurbs.computeCurvePoint(u); - vpDisplay::displayCross(I,pt,4,vpColor::red); - u+=0.01; + double u = 0.0; + while (u <= 5) + { + pt = Nurbs.computeCurvePoint(u); + vpDisplay::displayCross(I,pt,4,vpColor::red); + u+=0.01; + } + for(std::list<vpImagePoint>::const_iterator it=controlPoints.begin(); it!=controlPoints.end(); ++it){ + vpDisplay::displayCross(I, *it, 4, vpColor::green); + } + + vpDisplay::flush(I) ; + vpDisplay::getClick(I); } - for(std::list<vpImagePoint>::const_iterator it=controlPoints.begin(); it!=controlPoints.end(); ++it){ - vpDisplay::displayCross(I, *it, 4, vpColor::green); + + 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); + } } - 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) ; + Nurbs.globalCurveInterp(controlPoints); + + if (opt_display && opt_click_allowed) + { + double u = 0.0; + while (u <= 1) + { + pt = Nurbs.computeCurvePoint(u); + vpDisplay::displayCross(I2,pt,4,vpColor::red); + u+=0.01; + } + + for(std::list<vpImagePoint>::const_iterator it=controlPoints.begin(); it!=controlPoints.end(); ++it){ + vpDisplay::displayCross(I2, *it, 4, vpColor::green); + } vpDisplay::flush(I2) ; + vpDisplay::getClick(I2); } - catch(...) - { - vpERROR_TRACE("Error while displaying the image") ; - exit(-1); + + + 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.globalCurveInterp(controlPoints); - - if (opt_display && opt_click_allowed) - { - double u = 0.0; - vpImagePoint pt; - while (u <= 1) + + Nurbs.globalCurveApprox(controlPoints,5); + + if (opt_display && opt_click_allowed) { - pt = Nurbs.computeCurvePoint(u); - vpDisplay::displayCross(I2,pt,4,vpColor::red); - u+=0.01; - } + double u = 0.0; + while (u <= 1) + { + pt = Nurbs.computeCurvePoint(u); + vpDisplay::displayCross(I3,pt,4,vpColor::red); + u+=0.01; + } + + for(std::list<vpImagePoint>::const_iterator it=controlPoints.begin(); it!=controlPoints.end(); ++it){ + vpDisplay::displayCross(I3, *it, 4, vpColor::green); + } - for(std::list<vpImagePoint>::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; + vpDisplay::getClick(I3); } - for(std::list<vpImagePoint>::const_iterator it=controlPoints.begin(); it!=controlPoints.end(); ++it){ - vpDisplay::displayCross(I3, *it, 4, vpColor::green); + if (N != NULL) delete[] N; + if (N2 != NULL) + { + for (int j = 0; j <= 2; j++) + delete[] N2[j]; + delete[] N2; } - vpDisplay::flush(I3) ; - vpDisplay::getClick(I3); + return 0; + return 0; } - - if (N != NULL) delete[] N; - if (N2 != NULL) - { - for (int j = 0; j <= 2; j++) - delete[] N2[j]; - delete[] N2; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - - return 0; } #else int main() { - std::cout << "This example requires a video device. " + std::cout << "This example requires a video device. " << std::endl << "You should install X11, GTK, OpenCV, GDI or Direct3D" << std::endl diff --git a/example/math/exponentialMap.cpp b/example/math/exponentialMap.cpp index 5fe8cac163889f9da45b44ecc08cbb225a218652..2e627bc83e2e0dec2273a1f43b28bc4230784583 100644 --- a/example/math/exponentialMap.cpp +++ b/example/math/exponentialMap.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: exponentialMap.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: exponentialMap.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -58,72 +58,77 @@ 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; + try { + 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; + return 0; } - - // 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; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - - // 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; - } diff --git a/example/moments/image/CMakeLists.txt b/example/moments/image/CMakeLists.txt index 4cce0c6c85389adcdf348812254723cdb9212148..85a366b387f877f9de4260ad84ec2543d65ee039 100644 --- a/example/moments/image/CMakeLists.txt +++ b/example/moments/image/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/moments/image/servoMomentImage.cpp b/example/moments/image/servoMomentImage.cpp index 099c887ffacaef2f8400709e9f7dd02b3806cfc1..e6577d66fdbae4a4497c57d989ce126c9c23157a 100644 --- a/example/moments/image/servoMomentImage.cpp +++ b/example/moments/image/servoMomentImage.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoMomentImage.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: servoMomentImage.cpp 4670 2014-02-17 08:59:05Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -73,6 +73,22 @@ #include <visp/vpPoseVector.h> #include <visp/vpPlot.h> +#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 + //setup robot parameters void paramRobot(); @@ -87,38 +103,29 @@ 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 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))); + try { + //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); + //init the simulation + init(cMo,cdMo); - execute(1500); - return 0; + execute(1500); + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } @@ -243,11 +250,11 @@ void initFeatures(){ vpPlane pl; pl.setABCD(0,0,1.0,0); pl.changeFrame(cMo); - _planeToABC(pl,A,B,C); + planeToABC(pl,A,B,C); pl.setABCD(0,0,1.0,0); pl.changeFrame(cdMo); - _planeToABC(pl,Ad,Bd,Cd); + planeToABC(pl,Ad,Bd,Cd); //extracting initial position (actually we only care about Zdst) vpTranslationVector vec; @@ -255,8 +262,8 @@ void initFeatures(){ ///////////////////////////// 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]); + moments = new vpMomentCommon(vpMomentCommon ::getSurface(dst),vpMomentCommon::getMu3(dst),vpMomentCommon::getAlpha(dst), vec[2], true); + momentsDes = new vpMomentCommon(vpMomentCommon::getSurface(dst),vpMomentCommon::getMu3(dst),vpMomentCommon::getAlpha(dst),vec[2], true); //same thing with common features featureMoments = new vpFeatureMomentCommon(*moments); featureMomentsDes = new vpFeatureMomentCommon(*momentsDes); @@ -316,8 +323,8 @@ void execute(unsigned int nbIter){ vpPlane pl; double A,B,C; pl.setABCD(0,0,1.0,0); - pl.changeFrame(cMo); - _planeToABC(pl,A,B,C); + pl.changeFrame(cMo); + planeToABC(pl,A,B,C); //track points, draw points and add refresh our object refreshScene(obj); @@ -383,7 +390,7 @@ double error(){return _error;} -void _planeToABC(vpPlane& pl, double& A,double& B, double& C){ +void planeToABC(vpPlane& pl, double& A,double& B, double& C){ if(fabs(pl.getD())<std::numeric_limits<double>::epsilon()){ std::cout << "Invalid position:" << std::endl; std::cout << cMo << std::endl; diff --git a/example/moments/points/CMakeLists.txt b/example/moments/points/CMakeLists.txt index 4d1934669c6c45b3f3fbd4789d175073c742f0da..93b80d494861b849ead366c4bec88600c3fa9513 100644 --- a/example/moments/points/CMakeLists.txt +++ b/example/moments/points/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/moments/points/servoMomentPoints.cpp b/example/moments/points/servoMomentPoints.cpp index 015a674f91ace43c4f7b576c9241435d8197be22..b5e2bedd65bf6baeb28fd1eff274cd3fe2f40e04 100644 --- a/example/moments/points/servoMomentPoints.cpp +++ b/example/moments/points/servoMomentPoints.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoMomentPoints.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: servoMomentPoints.cpp 4673 2014-02-17 09:06:49Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -67,6 +67,23 @@ #include <visp/vpSimulatorAfma6.h> #include <visp/vpPlane.h> + +#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 + //setup robot parameters void paramRobot(); @@ -81,34 +98,26 @@ 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 planeToABC(vpPlane& pl, double& A,double& B, double& C); void paramRobot(); +void removeJointLimits(vpSimulatorAfma6& robot); -#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; + try { //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; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } //init the right display @@ -146,12 +155,10 @@ vpFeatureMomentCommon *featureMomentsDes; vpMomentObject src(6); vpMomentObject dst(6); -using namespace std; - void initScene(){ - vector<vpPoint> src_pts; - vector<vpPoint> dst_pts; + std::vector<vpPoint> src_pts; + std::vector<vpPoint> dst_pts; double x[8] = { 1,3, 4,-1 ,-3,-2,-1,1}; double y[8] = { 0,1, 4, 4, -2,-2, 1,0}; @@ -187,11 +194,11 @@ void initFeatures(){ vpPlane pl; pl.setABCD(0,0,1.0,0); pl.changeFrame(cMo); - _planeToABC(pl,A,B,C); + planeToABC(pl,A,B,C); pl.setABCD(0,0,1.0,0); pl.changeFrame(cdMo); - _planeToABC(pl,Ad,Bd,Cd); + planeToABC(pl,Ad,Bd,Cd); //extracting initial position (actually we only care about Zdst) vpTranslationVector vec; @@ -229,7 +236,7 @@ void refreshScene(vpMomentObject &obj){ 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<vpPoint> cur_pts; + std::vector<vpPoint> cur_pts; for (int i = 0 ; i < nbpoints ; i++){ vpPoint p; @@ -280,7 +287,7 @@ void execute(unsigned int nbIter){ double A,B,C; pl.setABCD(0,0,1.0,0); pl.changeFrame(cMo); - _planeToABC(pl,A,B,C); + planeToABC(pl,A,B,C); //track points, draw points and add refresh our object refreshScene(obj); @@ -316,7 +323,8 @@ void execute(unsigned int nbIter){ delete featureMomentsDes; } -void removeJointLimits(vpSimulatorAfma6& robot){ +void removeJointLimits(vpSimulatorAfma6& robot_) +{ vpColVector limMin(6); vpColVector limMax(6); limMin[0] = vpMath::rad(-3600); @@ -333,12 +341,12 @@ void removeJointLimits(vpSimulatorAfma6& robot){ limMax[4] = vpMath::rad(3600); limMax[5] = vpMath::rad(3600); - robot.setJointLimit(limMin,limMax); - robot.setMaxRotationVelocity(99999); - robot.setMaxTranslationVelocity(999999); + robot_.setJointLimit(limMin,limMax); + robot_.setMaxRotationVelocity(99999); + robot_.setMaxTranslationVelocity(999999); } -void _planeToABC(vpPlane& pl, double& A,double& B, double& C){ +void planeToABC(vpPlane& pl, double& A,double& B, double& C){ if(fabs(pl.getD())<std::numeric_limits<double>::epsilon()){ std::cout << "Invalid position:" << std::endl; std::cout << cMo << std::endl; diff --git a/example/moments/polygon/CMakeLists.txt b/example/moments/polygon/CMakeLists.txt index 904ebb5556faead290a5114186a6f12c19f6eab9..25661a2f534ef1c90e4bb3f5c5befc9f5b05e723 100644 --- a/example/moments/polygon/CMakeLists.txt +++ b/example/moments/polygon/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/moments/polygon/servoMomentPolygon.cpp b/example/moments/polygon/servoMomentPolygon.cpp index 1b6654d21e0a232bbdd7fc197a2944b681de9128..87cdedeb98b5da4ed706911fc92b39e4b84569ed 100644 --- a/example/moments/polygon/servoMomentPolygon.cpp +++ b/example/moments/polygon/servoMomentPolygon.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoMomentPolygon.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: servoMomentPolygon.cpp 4670 2014-02-17 08:59:05Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -66,6 +66,22 @@ #include <visp/vpSimulatorAfma6.h> #include <visp/vpPlane.h> +#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 + //setup robot parameters void paramRobot(); @@ -80,34 +96,26 @@ 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 planeToABC(vpPlane& pl, double& A,double& B, double& C); void paramRobot(); +void removeJointLimits(vpSimulatorAfma6& robot); -#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; + try { //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; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } //init the right display @@ -214,11 +222,11 @@ void initFeatures(){ vpPlane pl; pl.setABCD(0,0,1.0,0); pl.changeFrame(cMo); - _planeToABC(pl,A,B,C); + planeToABC(pl,A,B,C); pl.setABCD(0,0,1.0,0); pl.changeFrame(cdMo); - _planeToABC(pl,Ad,Bd,Cd); + planeToABC(pl,Ad,Bd,Cd); //extracting initial position (actually we only care about Zdst) vpTranslationVector vec; @@ -275,7 +283,7 @@ void execute(unsigned int nbIter){ double A,B,C; pl.setABCD(0,0,1.0,0); pl.changeFrame(cMo); - _planeToABC(pl,A,B,C); + planeToABC(pl,A,B,C); //track points, draw points and add refresh our object refreshScene(obj); @@ -313,7 +321,8 @@ void execute(unsigned int nbIter){ void setInteractionMatrixType(vpServo::vpServoIteractionMatrixType type){interaction_type=type;} double error(){return _error;} -void removeJointLimits(vpSimulatorAfma6& robot){ +void removeJointLimits(vpSimulatorAfma6& robot_) +{ vpColVector limMin(6); vpColVector limMax(6); limMin[0] = vpMath::rad(-3600); @@ -330,10 +339,10 @@ void removeJointLimits(vpSimulatorAfma6& robot){ limMax[4] = vpMath::rad(3600); limMax[5] = vpMath::rad(3600); - robot.setJointLimit(limMin,limMax); + robot_.setJointLimit(limMin,limMax); } -void _planeToABC(vpPlane& pl, double& A,double& B, double& C){ +void planeToABC(vpPlane& pl, double& A,double& B, double& C){ if(fabs(pl.getD())<std::numeric_limits<double>::epsilon()){ std::cout << "Invalid position:" << std::endl; std::cout << cMo << std::endl; diff --git a/example/ogre-simulator/AROgre.cpp b/example/ogre-simulator/AROgre.cpp index a0f4668fbb7bf0915de949171b8d2413642b0899..7476a4e3dfe5f103db7565718410fd8873844d5b 100644 --- a/example/ogre-simulator/AROgre.cpp +++ b/example/ogre-simulator/AROgre.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: AROgre.cpp 4305 2013-07-05 13:23:47Z fspindle $ + * $Id: AROgre.cpp 4604 2014-01-21 14:15:23Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -50,10 +50,11 @@ #include <visp/vpConfig.h> #include <iostream> -//#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_OGRE) && (defined(VISP_HAVE_OPENCV) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9) || defined(VISP_HAVE_GTK) || (defined(VISP_HAVE_X11) && ! defined(APPLE))) +#if defined(VISP_HAVE_OGRE) && (defined(VISP_HAVE_OPENCV) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9) || defined(VISP_HAVE_GTK) || (defined(VISP_HAVE_X11) && ! (defined(__APPLE__) && defined(__MACH__)))) -#if defined(VISP_HAVE_X11) && ! defined(APPLE) +//#if defined(VISP_HAVE_X11) && ! defined(APPLE) +#if defined(VISP_HAVE_X11) && ! (defined(__APPLE__) && defined(__MACH__)) // 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 @@ -190,6 +191,8 @@ public: if (resourcePath) mResourcePath = resourcePath; std::cout << "mResourcePath: " << mResourcePath<< std::endl; vecDevant = Ogre::Vector3(0,-1,0); + robot = NULL; + mAnimationState = NULL; } protected : @@ -312,7 +315,7 @@ protected : */ void computeInitialPose(vpCameraParameters *mcam, vpImage<unsigned char> &I, vpPose * mPose, vpDot2 *md, vpImagePoint *mcog, - vpHomogeneousMatrix *cmo, vpPoint *mP, + vpHomogeneousMatrix *cMo, vpPoint *mP, const bool &opt_click_allowed) { // --------------------------------------------------- @@ -320,7 +323,8 @@ void computeInitialPose(vpCameraParameters *mcam, vpImage<unsigned char> &I, // ---------------------------------------------------- bool opt_display = true; -#if defined(VISP_HAVE_X11) && ! defined(APPLE) +//#if defined(VISP_HAVE_X11) && ! defined(APPLE) +#if defined(VISP_HAVE_X11) && ! (defined(__APPLE__) && defined(__MACH__)) // 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 @@ -335,7 +339,6 @@ void computeInitialPose(vpCameraParameters *mcam, vpImage<unsigned char> &I, #elif defined VISP_HAVE_D3D9 vpDisplayD3D display; #endif - for (unsigned int i=0 ; i < 4 ; i++) { if (opt_display) { @@ -493,16 +496,16 @@ void computeInitialPose(vpCameraParameters *mcam, vpImage<unsigned char> &I, // minimisation method // Pose by Lagrange it provides an initialization of the pose - mPose->computePose(vpPose::LAGRANGE, *cmo) ; + 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) ; + 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) ; + mPose->display(I,*cMo,*mcam, 0.05, vpColor::red) ; vpDisplay::flush(I) ; vpTime::wait(800); } @@ -512,189 +515,181 @@ void computeInitialPose(vpCameraParameters *mcam, vpImage<unsigned char> &I, 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 <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + try { + 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); } - } - // 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 <visp image path> 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 <personal image path> option if you want to "<<std::endl - << " use personal images." << std::endl - << std::endl; - - 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 <visp image path=" << ipath << "> " + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; + } + } - std::ostringstream s; + // 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 <visp image path> 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 <personal image path> option if you want to "<<std::endl + << " use personal images." << std::endl + << std::endl; + + exit(-1); + } - if (opt_ppath.empty()){ - // Set the path location of the image sequence - dirname = ipath + vpIoTools::path("/ViSP-images/mire-2/"); + std::ostringstream s; - // Build the name of the image file + if (opt_ppath.empty()){ + // Set the path location of the image sequence + dirname = ipath + vpIoTools::path("/ViSP-images/mire-2/"); - s.setf(std::ios::right, std::ios::adjustfield); - s << "image.%04d.pgm"; - filename = dirname + s.str(); - } - else { - filename = opt_ppath; - } + // Build the name of the image file - //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<unsigned char> Idisplay; - // Grey level image to track points - vpImage<unsigned char> I; - // RGBa image to get background - vpImage<vpRGBa> 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(); + s.setf(std::ios::right, std::ios::adjustfield); + s << "image.%04d.pgm"; + filename = dirname + s.str(); + } + else { + filename = opt_ppath; + } - // 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); - } + //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<unsigned char> Idisplay; + // Grey level image to track points + vpImage<unsigned char> I; + // RGBa image to get background + vpImage<vpRGBa> 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); + // 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(); + double t0 = vpTime::measureTimeMs(); // Rendering loop - while(ogre.continueRendering() && !grabber.end()){ - // Acquire a frame + 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++) + + // 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 { - // 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]) ; + 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 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; + // 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); // Display with ogre - ogre.display(IC,cmo); + ogre.display(IC,cMo); // Wait so that the video does not go too fast double t1 = vpTime::measureTimeMs(); @@ -703,25 +698,22 @@ int main(int argc, const char **argv) } // Close the grabber grabber.close(); + + return 0; } - catch (Ogre::Exception& e) - { - std::cerr << "Exception:\n"; - std::cerr << e.getFullDescription().c_str() << "\n"; + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; return 1; } - catch (...) - { - std::cerr << "Exception: " << "\n"; + catch(...) { + std::cout << "Catch an exception " << std::endl; 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; + std::cout << "You should install Ogre3D or a display (GTK or OpenCV...) to run this example..." << std::endl; } #endif diff --git a/example/ogre-simulator/AROgreBasic.cpp b/example/ogre-simulator/AROgreBasic.cpp index d006bcd31996023cdba890ec91fa71f0b846f2af..4c0542680d5d9dd14011089e604df8465deefc2c 100644 --- a/example/ogre-simulator/AROgreBasic.cpp +++ b/example/ogre-simulator/AROgreBasic.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: AROgreBasic.cpp 4305 2013-07-05 13:23:47Z fspindle $ + * $Id: AROgreBasic.cpp 4604 2014-01-21 14:15:23Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -49,10 +49,12 @@ #include <visp/vpConfig.h> #include <iostream> -//#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) +//#if defined(VISP_HAVE_OGRE) && (defined(VISP_HAVE_OPENCV) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9) || defined(VISP_HAVE_GTK) || (defined(VISP_HAVE_X11) && ! defined(APPLE))) +#if defined(VISP_HAVE_OGRE) && (defined(VISP_HAVE_OPENCV) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9) || defined(VISP_HAVE_GTK) || (defined(VISP_HAVE_X11) && ! (defined(__APPLE__) && defined(__MACH__)))) + +//#if defined(VISP_HAVE_X11) && ! defined(APPLE) +#if defined(VISP_HAVE_X11) && ! (defined(__APPLE__) && defined(__MACH__)) // 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 @@ -179,7 +181,7 @@ bool getOptions(int argc, const char **argv, std::string &ipath, */ void computeInitialPose(vpCameraParameters *mcam, vpImage<unsigned char> &I, vpPose * mPose, vpDot2 *md, vpImagePoint *mcog, - vpHomogeneousMatrix *cmo, vpPoint *mP, + vpHomogeneousMatrix *cMo, vpPoint *mP, const bool &opt_click_allowed) { // --------------------------------------------------- @@ -187,7 +189,8 @@ void computeInitialPose(vpCameraParameters *mcam, vpImage<unsigned char> &I, // ---------------------------------------------------- bool opt_display = true; -#if defined(VISP_HAVE_X11) && ! defined(APPLE) +//#if defined(VISP_HAVE_X11) && ! defined(APPLE) +#if defined(VISP_HAVE_X11) && ! (defined(__APPLE__) && defined(__MACH__)) // 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 @@ -364,16 +367,16 @@ void computeInitialPose(vpCameraParameters *mcam, vpImage<unsigned char> &I, // minimisation method // Pose by Lagrange it provides an initialization of the pose - mPose->computePose(vpPose::LAGRANGE, *cmo) ; + 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) ; + 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) ; + mPose->display(I,*cMo,*mcam, 0.05, vpColor::red) ; vpDisplay::flush(I) ; vpTime::wait(1000); } @@ -382,222 +385,216 @@ void computeInitialPose(vpCameraParameters *mcam, vpImage<unsigned char> &I, 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); - } + try { + 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 <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + // 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 <visp image path=" << ipath << "> " + << " 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 <visp image path> 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 <personal image path> option if you want to "<<std::endl - << " use personal images." << std::endl - << std::endl; - - exit(-1); - } + // 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 <visp image path> 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 <personal image path> option if you want to "<<std::endl + << " use personal images." << std::endl + << std::endl; + + 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<unsigned char> I ; + // 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<unsigned char> I ; - // unsigned iter = 0; - std::ostringstream s; - // char cfilename[FILENAME_MAX]; + // 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/"); + 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 + // 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<unsigned char> Idisplay; - // Grey level image to track points - vpImage<unsigned char> I; - // RGBa image to get background - vpImage<vpRGBa> 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(); + s.setf(std::ios::right, std::ios::adjustfield); + s << "image.%04d.pgm"; + filename = dirname + s.str(); + } + else { + filename = opt_ppath; + } - // 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); - } + //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<unsigned char> Idisplay; + // Grey level image to track points + vpImage<unsigned char> I; + // RGBa image to get background + vpImage<vpRGBa> 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))); + // Create a vpRAOgre object with color background + vpAROgre ogre(mcam, grabber.getWidth(), 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))); + + // Add an optional point light source + Ogre::Light * light = ogre.getSceneManager()->createLight(); + light->setDiffuseColour(1, 1, 1); // scaled RGB values + light->setSpecularColour(1, 1, 1); // scaled RGB values + light->setPosition(-5, -5, 10); + light->setType(Ogre::Light::LT_POINT); - try - { // Rendering loop - while(ogre.continueRendering() && !grabber.end()){ + 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++) + + // 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 { - // 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]) ; + 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 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; + // 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); // Display with ogre - ogre.display(IC,cmo); + ogre.display(IC,cMo); // Wait so that the video does not go too fast vpTime::wait(15); } // Close the grabber grabber.close(); + return 0; } - catch (Ogre::Exception& e) - { - std::cerr << "Exception:\n"; - std::cerr << e.getFullDescription().c_str() << "\n"; + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; return 1; } - catch (...) - { - std::cerr << "Exception: " << "\n"; + catch(...) { + std::cout << "Catch an exception " << std::endl; 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; + std::cout << "You should install Ogre3D or a display (GTK or OpenCV...) to run this example..." << std::endl; } #endif diff --git a/example/ogre-simulator/CMakeLists.txt b/example/ogre-simulator/CMakeLists.txt index 518c2653af406a588183b8c30f1e1e4cdf85e35c..039f8bc76e223392b9d83aaf42b21b823bcb228d 100644 --- a/example/ogre-simulator/CMakeLists.txt +++ b/example/ogre-simulator/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/parse-argv/CMakeLists.txt b/example/parse-argv/CMakeLists.txt index 2dfe6617174721d6c11fd656aa5e97acdac73c7a..ce4c2596d0a200ab132b21a694cf8f004b35aa9c 100644 --- a/example/parse-argv/CMakeLists.txt +++ b/example/parse-argv/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/parse-argv/parse-argv1.cpp b/example/parse-argv/parse-argv1.cpp index 7953412abda64cfcf4d0a6f638db87620307bf33..2634975134135e27a624e9d1c1934d3c1bdb66a9 100644 --- a/example/parse-argv/parse-argv1.cpp +++ b/example/parse-argv/parse-argv1.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: parse-argv1.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: parse-argv1.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -63,6 +63,9 @@ // List of allowed command line options #define GETOPTARGS "d:f:i:h" +void usage(const char *name, const char *badparam, int i_val, float f_val, double d_val); +bool getOptions(int argc, const char **argv, int &i_val, float &f_val, double &d_val); + /*! Print the program options. @@ -118,18 +121,18 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv, int &i_val, float &f_val, double &d_val) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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 '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; + usage(argv[0], optarg_, i_val, f_val, d_val); return false; break; } } @@ -137,7 +140,7 @@ bool getOptions(int argc, const char **argv, int &i_val, float &f_val, double &d // 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; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -147,32 +150,30 @@ bool getOptions(int argc, const char **argv, int &i_val, float &f_val, double &d int main(int argc, const char ** argv) { - using ::std::cout; - using ::std::endl; + try { + using ::std::cout; + using ::std::endl; - int i_val = 3; - float f_val = 3.14f; - double d_val = 3.1415; + 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); - } + // 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; + 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; + return 0; + } + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; + } } - - - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ diff --git a/example/parse-argv/parse-argv2.cpp b/example/parse-argv/parse-argv2.cpp index 9d25532042dbfbfd6385e2b852d5128606876075..a81c2fe84ada552b228ab3aeb6009c7d5d0a0747 100644 --- a/example/parse-argv/parse-argv2.cpp +++ b/example/parse-argv/parse-argv2.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: parse-argv2.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: parse-argv2.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -63,37 +63,43 @@ 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); + try { + 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; + } + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + 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; } diff --git a/example/pose-estimation/CMakeLists.txt b/example/pose-estimation/CMakeLists.txt index d8ac10488114022d1c10651229a8a97fb427e2cc..0433c10257b683dcaac09e5c321b46c7fdb81574 100644 --- a/example/pose-estimation/CMakeLists.txt +++ b/example/pose-estimation/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/pose-estimation/poseVirtualVS.cpp b/example/pose-estimation/poseVirtualVS.cpp index 5226561e1bb76ae4705262a339b13c995ca0673b..69d2ee74d573d9866b3b20dd1fcb19f11b74a5eb 100644 --- a/example/pose-estimation/poseVirtualVS.cpp +++ b/example/pose-estimation/poseVirtualVS.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: poseVirtualVS.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: poseVirtualVS.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -89,6 +89,12 @@ // List of allowed command line options #define GETOPTARGS "cdi:p:hf:n:s:" +void usage(const char *name, const char *badparam, std::string ipath, std::string ppath, + unsigned first, unsigned nimages, unsigned step); +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &ppath, + unsigned &first, unsigned &nimages, unsigned &step, + bool &click_allowed, bool &display); + /*! Print the program options. @@ -179,22 +185,22 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &pp unsigned &first, unsigned &nimages, unsigned &step, bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; case 'd': display = false; break; - case 'i': ipath = optarg; break; - case 'p': ppath = optarg; break; - case 'f': first = (unsigned) atoi(optarg); break; - case 'n': nimages = (unsigned) atoi(optarg); break; - case 's': step = (unsigned) atoi(optarg); break; + case 'i': ipath = optarg_; break; + case 'p': ppath = optarg_; break; + case 'f': first = (unsigned) atoi(optarg_); break; + case 'n': nimages = (unsigned) atoi(optarg_); break; + case 's': step = (unsigned) atoi(optarg_); break; case 'h': usage(argv[0], NULL, ipath, ppath, first, nimages, step); return false; break; default: - usage(argv[0], optarg, ipath, ppath, first, nimages, step); + usage(argv[0], optarg_, ipath, ppath, first, nimages, step); return false; break; } } @@ -203,7 +209,7 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &pp // standalone param or error usage(argv[0], NULL, ipath, ppath, first, nimages, step); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -216,177 +222,177 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &pp 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; - unsigned opt_first = 0; - unsigned opt_nimages = 80; - unsigned opt_step = 1; - bool opt_click_allowed = true; - bool opt_display = true; - - - int i ; - - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << " poseVirtualVS.cpp" <<std::endl << std::endl ; - - std::cout << " Example of dots tracking in an image sequence and pose computation" << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << std::endl ; - - // 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_first, opt_nimages, opt_step, opt_click_allowed, opt_display) == false) { - exit (-1); - } + try { + std::string env_ipath; + std::string opt_ipath; + std::string ipath; + std::string opt_ppath; + std::string dirname; + std::string filename; + unsigned opt_first = 0; + unsigned opt_nimages = 80; + unsigned opt_step = 1; + bool opt_click_allowed = true; + bool opt_display = true; + + + int i ; + + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << " poseVirtualVS.cpp" <<std::endl << std::endl ; + + std::cout << " Example of dots tracking in an image sequence and pose computation" << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << std::endl ; + + // 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_first, opt_nimages, opt_step, opt_click_allowed, 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() && opt_ppath.empty()) { - if (ipath != env_ipath) { - std::cout << std::endl - << "WARNING: " << std::endl; - std::cout << " Since -i <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + // 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() && opt_ppath.empty()) { + if (ipath != env_ipath) { + std::cout << std::endl + << "WARNING: " << std::endl; + std::cout << " Since -i <visp image path=" << ipath << "> " + << " 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, opt_first, opt_nimages, opt_step); + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Use -i <visp image path> 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 <personal image path> option if you want to "<< std::endl + << " use personal images" <<std::endl << std::endl; + exit(-1); } - } - // Test if an input path is set - if (opt_ipath.empty() && env_ipath.empty() && opt_ppath.empty()){ - usage(argv[0], NULL, ipath, opt_ppath, opt_first, opt_nimages, opt_step); - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Use -i <visp image path> 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 <personal image path> option if you want to "<< std::endl - << " use personal images" <<std::endl << std::endl; - 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<unsigned char> I ; + // 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<unsigned char> I ; - unsigned iter = opt_first ; - std::ostringstream s; - char cfilename[FILENAME_MAX]; + unsigned iter = opt_first ; + std::ostringstream s; + char cfilename[FILENAME_MAX]; - if (opt_ppath.empty()){ + if (opt_ppath.empty()){ - // Warning : - // the image sequence is not provided with the ViSP package - // therefore the program will return you an error : - // !! vpImageIoPnm.cpp: readPGM(#210) :couldn't read file /ViSP-images/cube/image.0001.pgm - // !! poseExample.cpp: main(#95) :Error while reading the image - // terminate called after throwing an instance of 'vpImageException' - // - // The sequence is available on the visp www site - // http://www.irisa.fr/lagadic/visp/visp.html - // in the download section. It is named "ViSP-images-x.y.z.tar.gz" + // Warning : + // the image sequence is not provided with the ViSP package + // therefore the program will return you an error : + // !! vpImageIoPnm.cpp: readPGM(#210) :couldn't read file /ViSP-images/cube/image.0001.pgm + // !! poseExample.cpp: main(#95) :Error while reading the image + // terminate called after throwing an instance of 'vpImageException' + // + // The sequence is available on the visp www site + // http://www.irisa.fr/lagadic/visp/visp.html + // in the download section. It is named "ViSP-images-x.y.z.tar.gz" - // directory name - dirname = ipath + vpIoTools::path("/ViSP-images/cube/"); + // directory name + dirname = ipath + vpIoTools::path("/ViSP-images/cube/"); - // Build the name of the image file + // Build the name of the image file - s.setf(std::ios::right, std::ios::adjustfield); - s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; - filename = dirname + s.str(); - } - else { + s.setf(std::ios::right, std::ios::adjustfield); + s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; + filename = dirname + s.str(); + } + else { - sprintf(cfilename, opt_ppath.c_str(), iter) ; - filename = cfilename; - } + sprintf(cfilename, opt_ppath.c_str(), iter) ; + filename = cfilename; + } - // define the vpDot structure, here 4 dots will tracked - vpDot d[4] ; + // define the vpDot structure, here 4 dots will tracked + vpDot d[4] ; - for (i=0 ; i < 4 ; i++) - { - // by using setGraphics, we request to see the all the pixel of the dot - // in green on the screen. - // It uses the overlay image plane. - // The default of this setting is that it is time consumming + for (i=0 ; i < 4 ; i++) + { + // by using setGraphics, we request to see the all the pixel of the dot + // in green on the screen. + // It uses the overlay image plane. + // The default of this setting is that it is time consumming - if (opt_display) { - d[i].setGraphics(true) ; - } - else { - d[i].setGraphics(false) ; + if (opt_display) { + d[i].setGraphics(true) ; + } + else { + d[i].setGraphics(false) ; + } } - } - // Read the PGM image named "s" 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{ - vpImageIo::read(I,filename) ; - } - catch(...) - { - // an exception is throwned if an exception from readPGM has been catched - // 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 - if (opt_ppath.empty()) { - 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; - } - else { - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Cannot read " << filename << std::endl; - std::cerr << " or your -p " << opt_ppath << " option " <<std::endl - << std::endl; + // Read the PGM image named "s" 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{ + vpImageIo::read(I,filename) ; } - exit(-1); + catch(...) + { + // an exception is throwned if an exception from readPGM has been catched + // 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 + if (opt_ppath.empty()) { + 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; + } + else { + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Cannot read " << filename << std::endl; + std::cerr << " or your -p " << opt_ppath << " option " <<std::endl + << std::endl; + } + exit(-1); - } + } - // We open a window using either the X11 or GTK or GDI window manager - // it will be located in 100,100 and titled "tracking using vpDot" - // its size is automatically defined by the image (I) size + // We open a window using either the X11 or GTK or GDI window manager + // it will be located in 100,100 and titled "tracking using vpDot" + // its size is automatically defined by the image (I) size #if defined VISP_HAVE_X11 - vpDisplayX display; + vpDisplayX display; #elif defined VISP_HAVE_GTK - vpDisplayGTK display; + vpDisplayGTK display; #elif defined VISP_HAVE_GDI - vpDisplayGDI display; + vpDisplayGDI display; #endif - if (opt_display) { - try{ + if (opt_display) { // Display size is automatically defined by the image (I) size display.init(I,100,100,"tracking using vpDot"); // display the image @@ -397,20 +403,12 @@ main(int argc, const char** argv) vpDisplay::display(I) ; //Flush the display vpDisplay::flush(I) ; - - } - catch(...) - { - vpERROR_TRACE("Error while displaying the image") ; - return(-1) ; } - } - vpImagePoint cog[4]; // Center of gravity of the dot - try{ + vpImagePoint cog[4]; // Center of gravity of the dot if (opt_display && opt_click_allowed) { // dot coordinates (u,v) = (column,row) - std::cout << "Click the four white dots on the object corner clockwise" + std::cout << "Click the four white dots on the object corner clockwise" << std::endl ; for (i=0 ; i < 4 ; i++) { @@ -460,116 +458,109 @@ main(int argc, const char** argv) d[3].track(I, cog[3]); vpDisplay::flush(I) ; } - } - catch(...) - { - vpERROR_TRACE("Error in tracking initialization ") ; - return(-1) ; - } - if (opt_display) - { + if (opt_display) + { + + // display a red cross (size 10) in the image at the dot center + // of gravity location + // + // WARNING + // in the vpDisplay class member's when pixel coordinates + // are considered the first element is the row index and the second + // is the column index: + // vpDisplay::displayCross(Image, row index, column index, size, color) + // therefore u and v are inverted wrt to the vpDot specification + // Alternatively, to avoid this problem another set of member have + // been defined in the vpDisplay class. + // If the method name is postfixe with _uv the specification is : + // vpDisplay::displayCross_uv(Image, column index, row index, size, color) - // display a red cross (size 10) in the image at the dot center - // of gravity location + for (i=0 ; i < 4 ; i++) + vpDisplay::displayCross(I, cog[i], 10, vpColor::red) ; + + // flush the X11 buffer + vpDisplay::flush(I) ; + } + + // -------------------------------------------------------- + // Now wil compute the pose // - // WARNING - // in the vpDisplay class member's when pixel coordinates - // are considered the first element is the row index and the second - // is the column index: - // vpDisplay::displayCross(Image, row index, column index, size, color) - // therefore u and v are inverted wrt to the vpDot specification - // Alternatively, to avoid this problem another set of member have - // been defined in the vpDisplay class. - // If the method name is postfixe with _uv the specification is : - // vpDisplay::displayCross_uv(Image, column index, row index, size, color) + // The pose will be contained in an homogeneous matrix cMo + vpHomogeneousMatrix cMo ; + + + // We need a structure that content both the 3D coordinates of the point + // in the object frame and the 2D coordinates of the point expressed in meter + // the vpPoint class is ok for that + vpPoint P[4] ; + + // The vpPose class mainly contents a list of vpPoint (that is (X,Y,Z, x, y) ) + vpPose pose ; + // the list of point is cleared (if that's not done before) + pose.clearPoint() ; + + // we set the 3D points coordinates (in meter !) in the object/world frame + double L=0.04 ; + P[0].setWorldCoordinates(-L,-L, 0 ) ; // (X,Y,Z) + P[1].setWorldCoordinates(L,-L, 0 ) ; + P[2].setWorldCoordinates(L,L, 0 ) ; + P[3].setWorldCoordinates(-L,L, 0 ) ; + + + // set the camera intrinsic parameters + // see more details about the model in vpCameraParameters + double px = 600 ; + double py = 600 ; + double u0 = 192 ; + double v0 = 144 ; + vpCameraParameters cam(px,py,u0,v0) ; + + // pixel-> meter conversion for (i=0 ; i < 4 ; i++) - vpDisplay::displayCross(I, cog[i], 10, vpColor::red) ; + { + // 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(cam, cog[i], x,y) ; + P[i].set_x(x) ; + P[i].set_y(y) ; + } - // flush the X11 buffer - vpDisplay::flush(I) ; - } - // -------------------------------------------------------- - // Now wil compute the pose - // - - // The pose will be contained in an homogeneous matrix cMo - vpHomogeneousMatrix cMo ; - - - // We need a structure that content both the 3D coordinates of the point - // in the object frame and the 2D coordinates of the point expressed in meter - // the vpPoint class is ok for that - vpPoint P[4] ; - - // The vpPose class mainly contents a list of vpPoint (that is (X,Y,Z, x, y) ) - vpPose pose ; - // the list of point is cleared (if that's not done before) - pose.clearPoint() ; - - // we set the 3D points coordinates (in meter !) in the object/world frame - double L=0.04 ; - P[0].setWorldCoordinates(-L,-L, 0 ) ; // (X,Y,Z) - P[1].setWorldCoordinates(L,-L, 0 ) ; - P[2].setWorldCoordinates(L,L, 0 ) ; - P[3].setWorldCoordinates(-L,L, 0 ) ; - - - // set the camera intrinsic parameters - // see more details about the model in vpCameraParameters - double px = 600 ; - double py = 600 ; - double u0 = 192 ; - double v0 = 144 ; - vpCameraParameters cam(px,py,u0,v0) ; - - // pixel-> meter conversion - for (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(cam, cog[i], x,y) ; - P[i].set_x(x) ; - P[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 (i=0 ; i < 4 ; i++) + { + pose.addPoint(P[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 + pose.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 + pose.computePose(vpPose::VIRTUAL_VS, cMo) ; + if( opt_display ){ + // display the compute pose + pose.display(I,cMo,cam, 0.05, vpColor::red) ; + vpDisplay::flush(I) ; + } - // 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 (i=0 ; i < 4 ; i++) - { - pose.addPoint(P[i]) ; // and added to the pose computation point list - } + // Covariance Matrix Computation + // Uncomment if you want to compute the covariance matrix. + // pose.setCovarianceComputation(true); //Important if you want tracker.getCovarianceMatrix() to work. - // compute the initial pose using Dementhon method followed by a non linear - // minimisation method - - // Pose by Lagrange it provides an initialization of the pose - pose.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 - pose.computePose(vpPose::VIRTUAL_VS, cMo) ; - if( opt_display ){ - // display the compute pose - pose.display(I,cMo,cam, 0.05, vpColor::red) ; - vpDisplay::flush(I) ; - } - - // Covariance Matrix Computation - // Uncomment if you want to compute the covariance matrix. - // pose.setCovarianceComputation(true); //Important if you want tracker.getCovarianceMatrix() to work. - - unsigned niter = 0; - // this is the loop over the image sequence - while (iter < opt_nimages) - { - try { + unsigned niter = 0; + // this is the loop over the image sequence + while (iter < opt_nimages) + { // set the new image name if (opt_ppath.empty()){ @@ -627,19 +618,21 @@ main(int argc, const char** argv) vpDisplay::flush(I) ; } - + // Covariance Matrix Display - // Uncomment if you want to print the covariance matrix. + // Uncomment if you want to print the covariance matrix. // Make sure pose.setCovarianceComputation(true) has been called (uncomment below). // std::cout << pose.getCovarianceMatrix() << std::endl << std::endl; - + niter++ ; + + iter += opt_step ; } - catch(...){ - vpERROR_TRACE("Error in tracking loop") ; - return(-1) ; - } - iter += opt_step ; + return 0; + } + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; } } #else diff --git a/example/robot-simulator/afma6/CMakeLists.txt b/example/robot-simulator/afma6/CMakeLists.txt index 01412494b384653871affc530fa8fdfbd47a635b..78d461387df97077bb271fa6cc871398e2333898 100644 --- a/example/robot-simulator/afma6/CMakeLists.txt +++ b/example/robot-simulator/afma6/CMakeLists.txt @@ -3,7 +3,7 @@ # $Id: CMakeLists.txt 2457 2010-01-07 10:41:18Z nmelchio $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/robot-simulator/afma6/servoSimuAfma6FourPoints2DCamVelocity.cpp b/example/robot-simulator/afma6/servoSimuAfma6FourPoints2DCamVelocity.cpp index 3845b4d3a5b7d16afb5f81790230055791c241cf..f4544d1829a211bffbbc884eb611d4b615ca1168 100644 --- a/example/robot-simulator/afma6/servoSimuAfma6FourPoints2DCamVelocity.cpp +++ b/example/robot-simulator/afma6/servoSimuAfma6FourPoints2DCamVelocity.cpp @@ -3,7 +3,7 @@ * $Id: servoSimuFourPoints2DPolarCamVelocityDisplay.cpp 2503 2010-02-16 18:55:01Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -60,7 +60,7 @@ #include <visp/vpDebug.h> #include <visp/vpConfig.h> -#if (defined(WIN32) || defined(VISP_HAVE_PTHREAD)) && (defined (VISP_HAVE_X11) || defined(VISP_HAVE_OPENCV) || defined(VISP_HAVE_GDI)) +#if (defined(_WIN32) || defined(VISP_HAVE_PTHREAD)) && (defined (VISP_HAVE_X11) || defined(VISP_HAVE_OPENCV) || defined(VISP_HAVE_GDI)) // We need to use threading capabilities. Thus on Unix-like // platforms, the libpthread third-party library need to be @@ -88,6 +88,9 @@ // List of allowed command line options #define GETOPTARGS "cdh" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display); + /*! Print the program options. @@ -137,9 +140,9 @@ Set the program options. */ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; @@ -147,7 +150,7 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) case 'h': usage(argv[0], NULL); return false; break; default: - usage(argv[0], optarg); + usage(argv[0], optarg_); return false; break; } } @@ -156,7 +159,7 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -166,192 +169,192 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) int main(int argc, const char ** argv) { - bool opt_click_allowed = true; - bool opt_display = true; + try { + 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); - } + // Read the command line options + if (getOptions(argc, argv, opt_click_allowed, opt_display) == false) { + exit (-1); + } - // We open two displays, one for the internal camera view, the other one for - // the external view, using either X11, GTK or GDI. + // We open two displays, one for the internal camera view, the other one for + // the external view, using either X11, GTK or GDI. #if defined VISP_HAVE_X11 - vpDisplayX displayInt; + vpDisplayX displayInt; #elif defined VISP_HAVE_GDI - vpDisplayGDI displayInt; + vpDisplayGDI displayInt; #elif defined VISP_HAVE_OPENCV - vpDisplayOpenCV displayInt; + vpDisplayOpenCV displayInt; #endif - vpImage<unsigned char> Iint(480, 640, 255); + vpImage<unsigned char> Iint(480, 640, 255); - if (opt_display) { - // open a display for the visualization - displayInt.init(Iint,700,0, "Internal view") ; - } + if (opt_display) { + // open a display for the visualization + displayInt.init(Iint,700,0, "Internal view") ; + } - int i; - vpServo task; - - std::cout << std::endl ; - std::cout << "----------------------------------------------" << std::endl ; - std::cout << " Test program for vpServo " <<std::endl ; - std::cout << " Eye-in-hand task control, articular velocity are computed" - << std::endl ; - std::cout << " Simulation " << std::endl ; - std::cout << " task : servo 4 points " << std::endl ; - std::cout << "----------------------------------------------" << std::endl ; - std::cout << std::endl ; - - // sets the initial camera location - vpHomogeneousMatrix cMo(-0.05,-0.05,0.7, - vpMath::rad(10), vpMath::rad(10), vpMath::rad(-30)); - - // sets the point coordinates in the object frame - vpPoint point[4] ; - point[0].setWorldCoordinates(-0.045,-0.045,0) ; - point[3].setWorldCoordinates(-0.045,0.045,0) ; - point[2].setWorldCoordinates(0.045,0.045,0) ; - point[1].setWorldCoordinates(0.045,-0.045,0) ; - - // computes the point coordinates in the camera frame and its 2D coordinates - for (i = 0 ; i < 4 ; i++) - point[i].track(cMo) ; - - // 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 - - // sets the desired position of the feature point s* - vpFeaturePoint pd[4] ; - - // Desired pose - vpHomogeneousMatrix cdMo(vpHomogeneousMatrix(0.0,0.0,0.8,vpMath::rad(0),vpMath::rad(0),vpMath::rad(0))); - - // Projection of the points - for (int i = 0 ; i < 4 ; i++) - point[i].track(cdMo); - - for (int i = 0 ; i < 4 ; i++) - vpFeatureBuilder::create(pd[i], point[i]); - - // define the task - // - we want an eye-in-hand control law - // - articular velocity are computed - task.setServo(vpServo::EYEINHAND_CAMERA); - task.setInteractionMatrixType(vpServo::DESIRED) ; - - // we want to see a point on a point - for (i = 0 ; i < 4 ; i++) - task.addFeature(p[i],pd[i]) ; - - // set the gain - task.setLambda(0.8) ; - - // Declaration of the robot - vpSimulatorAfma6 robot(opt_display); - - // Initialise the robot and especially the camera - robot.init(vpAfma6::TOOL_CCMOP, vpCameraParameters::perspectiveProjWithoutDistortion); - robot.setRobotState(vpRobot::STATE_VELOCITY_CONTROL); - - // Initialise the object for the display part*/ - robot.initScene(vpWireFrameSimulator::PLATE, 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); - - // Get the internal robot's camera parameters - vpCameraParameters cam; - robot.getCameraParameters(cam,Iint); - - if (opt_display) - { - //Get the internal view - vpDisplay::display(Iint); - robot.getInternalView(Iint); - vpDisplay::flush(Iint); - } + vpServo task; + + std::cout << std::endl ; + std::cout << "----------------------------------------------" << std::endl ; + std::cout << " Test program for vpServo " <<std::endl ; + std::cout << " Eye-in-hand task control, articular velocity are computed" + << std::endl ; + std::cout << " Simulation " << std::endl ; + std::cout << " task : servo 4 points " << std::endl ; + std::cout << "----------------------------------------------" << std::endl ; + std::cout << std::endl ; + + // sets the initial camera location + vpHomogeneousMatrix cMo(-0.05,-0.05,0.7, + vpMath::rad(10), vpMath::rad(10), vpMath::rad(-30)); + + // sets the point coordinates in the object frame + vpPoint point[4] ; + point[0].setWorldCoordinates(-0.045,-0.045,0) ; + point[3].setWorldCoordinates(-0.045,0.045,0) ; + point[2].setWorldCoordinates(0.045,0.045,0) ; + point[1].setWorldCoordinates(0.045,-0.045,0) ; + + // computes the point coordinates in the camera frame and its 2D coordinates + for (unsigned int i = 0 ; i < 4 ; i++) + point[i].track(cMo) ; - // Display task information - task.print() ; + // sets the desired position of the point + vpFeaturePoint p[4] ; + for (unsigned int i = 0 ; i < 4 ; i++) + vpFeatureBuilder::create(p[i],point[i]) ; //retrieve x,y and Z of the vpPoint structure - unsigned int iter=0 ; - vpTRACE("\t loop") ; - while(iter++<500) - { - std::cout << "---------------------------------------------" << iter <<std::endl ; - vpColVector v ; + // sets the desired position of the feature point s* + vpFeaturePoint pd[4] ; - // Get the Time at the beginning of the loop - double t = vpTime::measureTimeMs(); + // Desired pose + vpHomogeneousMatrix cdMo(vpHomogeneousMatrix(0.0,0.0,0.8,vpMath::rad(0),vpMath::rad(0),vpMath::rad(0))); - // Get the current pose of the camera - cMo = robot.get_cMo(); + // Projection of the points + for (unsigned int i = 0 ; i < 4 ; i++) + point[i].track(cdMo); - if (iter==1) { - std::cout <<"Initial robot position with respect to the object frame:\n"; - cMo.print(); - } + for (unsigned int i = 0 ; i < 4 ; i++) + vpFeatureBuilder::create(pd[i], point[i]); - // new point position - for (i = 0 ; i < 4 ; i++) - { - point[i].track(cMo) ; - // retrieve x,y and Z of the vpPoint structure - try { - vpFeatureBuilder::create(p[i],point[i]) ; - } - catch(...) - { - break; - } - } + // define the task + // - we want an eye-in-hand control law + // - articular velocity are computed + task.setServo(vpServo::EYEINHAND_CAMERA); + task.setInteractionMatrixType(vpServo::DESIRED) ; + + // we want to see a point on a point + for (unsigned int i = 0 ; i < 4 ; i++) + task.addFeature(p[i],pd[i]) ; + + // set the gain + task.setLambda(0.8) ; + + // Declaration of the robot + vpSimulatorAfma6 robot(opt_display); + + // Initialise the robot and especially the camera + robot.init(vpAfma6::TOOL_CCMOP, vpCameraParameters::perspectiveProjWithoutDistortion); + robot.setRobotState(vpRobot::STATE_VELOCITY_CONTROL); + + // Initialise the object for the display part*/ + robot.initScene(vpWireFrameSimulator::PLATE, 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); + + // Get the internal robot's camera parameters + vpCameraParameters cam; + robot.getCameraParameters(cam,Iint); if (opt_display) { - // Get the internal view and display it - vpDisplay::display(Iint) ; + //Get the internal view + vpDisplay::display(Iint); robot.getInternalView(Iint); vpDisplay::flush(Iint); } - if (opt_display && opt_click_allowed && iter == 1) + // Display task information + task.print() ; + + unsigned int iter=0 ; + vpTRACE("\t loop") ; + while(iter++<500) { - // suppressed for automate test - std::cout << "Click in the internal view window to continue..." << std::endl; - vpDisplay::getClick(Iint) ; - } + std::cout << "---------------------------------------------" << iter <<std::endl ; + vpColVector v ; - // compute the control law - v = task.computeControlLaw() ; + // Get the Time at the beginning of the loop + double t = vpTime::measureTimeMs(); - // send the camera velocity to the controller - robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + // Get the current pose of the camera + cMo = robot.get_cMo(); - std::cout << "|| s - s* || " << ( task.getError() ).sumSquare() <<std::endl ; + if (iter==1) { + std::cout <<"Initial robot position with respect to the object frame:\n"; + cMo.print(); + } - // The main loop has a duration of 10 ms at minimum - vpTime::wait(t,10); - } + // new point position + for (unsigned int i = 0 ; i < 4 ; i++) + { + point[i].track(cMo) ; + // retrieve x,y and Z of the vpPoint structure + vpFeatureBuilder::create(p[i],point[i]) ; + } + + if (opt_display) + { + // Get the internal view and display it + vpDisplay::display(Iint) ; + robot.getInternalView(Iint); + vpDisplay::flush(Iint); + } + + if (opt_display && opt_click_allowed && iter == 1) + { + // suppressed for automate test + std::cout << "Click in the internal view window to continue..." << std::endl; + vpDisplay::getClick(Iint) ; + } + + // compute the control law + v = task.computeControlLaw() ; + + // send the camera velocity to the controller + robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + + std::cout << "|| s - s* || " << ( task.getError() ).sumSquare() <<std::endl ; + + // The main loop has a duration of 10 ms at minimum + vpTime::wait(t,10); + } - // Display task information - task.print() ; - task.kill(); + // Display task information + task.print() ; + task.kill(); - std::cout <<"Final robot position with respect to the object frame:\n"; - cMo.print(); + std::cout <<"Final robot position with respect to the object frame:\n"; + cMo.print(); - if (opt_display && opt_click_allowed) - { - // suppressed for automate test - std::cout << "Click in the internal view window to end..." << std::endl; - vpDisplay::getClick(Iint) ; + if (opt_display && opt_click_allowed) + { + // suppressed for automate test + std::cout << "Click in the internal view window to end..." << std::endl; + vpDisplay::getClick(Iint) ; + } + return 0; + } + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; } } #else diff --git a/example/robot-simulator/camera/CMakeLists.txt b/example/robot-simulator/camera/CMakeLists.txt index 04b7afba7ad5ad8f8d23cff460408c86f5b1d068..5f94a5548ddf37d1ee7c31bf14479af8bc6e2f22 100644 --- a/example/robot-simulator/camera/CMakeLists.txt +++ b/example/robot-simulator/camera/CMakeLists.txt @@ -3,7 +3,7 @@ # $Id: CMakeLists.txt 2457 2010-01-07 10:41:18Z nmelchio $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/robot-simulator/camera/servoSimu3D_cMcd_CamVelocity.cpp b/example/robot-simulator/camera/servoSimu3D_cMcd_CamVelocity.cpp index 5057531a700647831f479697901edbbae20c8f47..2ee501accc927738e1ca50c2ccecf5d3f9be6ba0 100644 --- a/example/robot-simulator/camera/servoSimu3D_cMcd_CamVelocity.cpp +++ b/example/robot-simulator/camera/servoSimu3D_cMcd_CamVelocity.cpp @@ -3,7 +3,7 @@ * $Id: servoSimu3D_cMcd_CamVelocity.cpp 2457 2010-01-07 10:41:18Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -73,6 +73,9 @@ // List of allowed command line options #define GETOPTARGS "h" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); + /*! Print the program options. @@ -113,15 +116,15 @@ Set the program options. */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -130,7 +133,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -140,155 +143,162 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } - // Log file creation in /tmp/$USERNAME/log.dat - // This file contains by line: - // - the 6 computed camera velocities (m/s, rad/s) to achieve the task - // - the 6 values of s - s* - std::string username; - // Get the user login name - vpIoTools::getUserName(username); - - // Create a log filename to save velocities... - std::string logdirname; -#ifdef WIN32 - logdirname ="C:/temp/" + username; + // Log file creation in /tmp/$USERNAME/log.dat + // This file contains by line: + // - the 6 computed camera velocities (m/s, rad/s) to achieve the task + // - the 6 values of s - s* + std::string username; + // Get the user login name + vpIoTools::getUserName(username); + + // Create a log filename to save velocities... + std::string logdirname; +#if defined(_WIN32) + logdirname ="C:/temp/" + username; #else - logdirname ="/tmp/" + username; + logdirname ="/tmp/" + username; #endif - // Test if the output path exist. If no try to create it - if (vpIoTools::checkDirectory(logdirname) == false) { - try { - // Create the dirname - vpIoTools::makeDirectory(logdirname); - } - catch (...) { - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Cannot create " << logdirname << std::endl; - exit(-1); + // Test if the output path exist. If no try to create it + if (vpIoTools::checkDirectory(logdirname) == false) { + try { + // Create the dirname + vpIoTools::makeDirectory(logdirname); + } + catch (...) { + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Cannot create " << logdirname << std::endl; + exit(-1); + } } - } - std::string logfilename; - logfilename = logdirname + "/log.dat"; - - // Open the log file name - std::ofstream flog(logfilename.c_str()); - - vpServo task ; - vpSimulatorCamera robot ; - - std::cout << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << " Test program for vpServo " <<std::endl ; - std::cout << " Eye-in-hand task control, velocity computed in the camera frame" << std::endl ; - std::cout << " Simulation " << std::endl ; - std::cout << " task : 3D visual servoing " << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << std::endl ; - - // Sets the initial camera location - vpPoseVector c_r_o(// Translation tx,ty,tz - 0.1, 0.2, 2, - // ThetaU rotation - vpMath::rad(20), vpMath::rad(10), vpMath::rad(50) ) ; - - // From the camera pose build the corresponding homogeneous matrix - vpHomogeneousMatrix cMo(c_r_o) ; - - // Set the robot initial position - vpHomogeneousMatrix wMc, wMo; - robot.getPosition(wMc) ; - wMo = wMc * cMo; // Compute the position of the object in the world frame - - // Sets the desired camera location - vpPoseVector cd_r_o(// Translation tx,ty,tz - 0, 0, 1, - // ThetaU rotation - vpMath::rad(0),vpMath::rad(0),vpMath::rad(0)) ; - - // From the camera desired pose build the corresponding homogeneous matrix - vpHomogeneousMatrix cdMo(cd_r_o) ; - - // Compute the transformation from the initial camera position to the desired one - vpHomogeneousMatrix cMcd ; - cMcd = cMo*cdMo.inverse() ; - - // Build the 3D translation feature: ctc* - vpFeatureTranslation t(vpFeatureTranslation::cMcd) ; - t.buildFrom(cMcd) ; - - // Build the 3D rotation feature: thetaU_cRc* - vpFeatureThetaU tu(vpFeatureThetaU::cRcd); // current feature - tu.buildFrom(cMcd) ; - - // Sets the desired rotation (always zero !) since s is the - // rotation that the camera has to achieve. Here s* = (0, 0)^T - vpFeatureTranslation td(vpFeatureTranslation::cMcd) ; - vpFeatureThetaU tud(vpFeatureThetaU::cRcd); // desired feature - - // Define the task - // - we want an eye-in-hand control law - // - the robot is controlled in the camera frame - task.setServo(vpServo::EYEINHAND_CAMERA) ; - // - we use here the interaction matrix computed with the current - // features - task.setInteractionMatrixType(vpServo::CURRENT); - - // Add the current and desired visual features - task.addFeature(t,td) ; // 3D translation - task.addFeature(tu,tud) ; // 3D rotation theta u - - // - set the constant gain to 1.0 - task.setLambda(1) ; - - // Display task information - task.print() ; + std::string logfilename; + logfilename = logdirname + "/log.dat"; + + // Open the log file name + std::ofstream flog(logfilename.c_str()); + + vpServo task ; + vpSimulatorCamera robot ; + + std::cout << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << " Test program for vpServo " <<std::endl ; + std::cout << " Eye-in-hand task control, velocity computed in the camera frame" << std::endl ; + std::cout << " Simulation " << std::endl ; + std::cout << " task : 3D visual servoing " << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << std::endl ; + + // Sets the initial camera location + vpPoseVector c_r_o(// Translation tx,ty,tz + 0.1, 0.2, 2, + // ThetaU rotation + vpMath::rad(20), vpMath::rad(10), vpMath::rad(50) ) ; + + // From the camera pose build the corresponding homogeneous matrix + vpHomogeneousMatrix cMo(c_r_o) ; + + // Set the robot initial position + vpHomogeneousMatrix wMc, wMo; + robot.getPosition(wMc) ; + wMo = wMc * cMo; // Compute the position of the object in the world frame - unsigned int iter=0 ; - // Start the visual servoing loop. We stop the servo after 200 iterations - while(iter++ < 200) { - std::cout << "------------------------------------" << iter <<std::endl ; - vpColVector v ; + // Sets the desired camera location + vpPoseVector cd_r_o(// Translation tx,ty,tz + 0, 0, 1, + // ThetaU rotation + vpMath::rad(0),vpMath::rad(0),vpMath::rad(0)) ; - // get the robot position - robot.getPosition(wMc) ; - // Compute the position of the camera wrt the object frame - cMo = wMc.inverse() * wMo; + // From the camera desired pose build the corresponding homogeneous matrix + vpHomogeneousMatrix cdMo(cd_r_o) ; - // new displacement to achieve + // Compute the transformation from the initial camera position to the desired one + vpHomogeneousMatrix cMcd ; cMcd = cMo*cdMo.inverse() ; - // Update the current visual features + // Build the 3D translation feature: ctc* + vpFeatureTranslation t(vpFeatureTranslation::cMcd) ; t.buildFrom(cMcd) ; + + // Build the 3D rotation feature: thetaU_cRc* + vpFeatureThetaU tu(vpFeatureThetaU::cRcd); // current feature tu.buildFrom(cMcd) ; - // Compute the control law - v = task.computeControlLaw() ; + // Sets the desired rotation (always zero !) since s is the + // rotation that the camera has to achieve. Here s* = (0, 0)^T + vpFeatureTranslation td(vpFeatureTranslation::cMcd) ; + vpFeatureThetaU tud(vpFeatureThetaU::cRcd); // desired feature + + // Define the task + // - we want an eye-in-hand control law + // - the robot is controlled in the camera frame + task.setServo(vpServo::EYEINHAND_CAMERA) ; + // - we use here the interaction matrix computed with the current + // features + task.setInteractionMatrixType(vpServo::CURRENT); + + // Add the current and desired visual features + task.addFeature(t,td) ; // 3D translation + task.addFeature(tu,tud) ; // 3D rotation theta u + + // - set the constant gain to 1.0 + task.setLambda(1) ; // Display task information - if (iter==1) task.print() ; + task.print() ; - // Send the camera velocity to the controller - robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + unsigned int iter=0 ; + // Start the visual servoing loop. We stop the servo after 200 iterations + while(iter++ < 200) { + std::cout << "------------------------------------" << iter <<std::endl ; + vpColVector v ; - // Retrieve the error - std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; + // get the robot position + robot.getPosition(wMc) ; + // Compute the position of the camera wrt the object frame + cMo = wMc.inverse() * wMo; - // Save log - flog << v.t() << " " << ( task.getError() ).t() << std::endl; - } - // Display task information - task.print() ; + // new displacement to achieve + cMcd = cMo*cdMo.inverse() ; + + // Update the current visual features + t.buildFrom(cMcd) ; + tu.buildFrom(cMcd) ; + + // Compute the control law + v = task.computeControlLaw() ; + + // Display task information + if (iter==1) task.print() ; + + // Send the camera velocity to the controller + robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; - // Kill the task - task.kill(); + // Retrieve the error + std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; - // Close the log file - flog.close(); + // Save log + flog << v.t() << " " << ( task.getError() ).t() << std::endl; + } + // Display task information + task.print() ; + + // Kill the task + task.kill(); + + // Close the log file + flog.close(); + return 0; + } + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; + } } diff --git a/example/robot-simulator/camera/servoSimu3D_cMcd_CamVelocityWithoutVpServo.cpp b/example/robot-simulator/camera/servoSimu3D_cMcd_CamVelocityWithoutVpServo.cpp index 69518b944516ade71cfa725c657f6d33cf46f3e6..8b504499de04928b9d94b5656b88b8bbdcbde91a 100644 --- a/example/robot-simulator/camera/servoSimu3D_cMcd_CamVelocityWithoutVpServo.cpp +++ b/example/robot-simulator/camera/servoSimu3D_cMcd_CamVelocityWithoutVpServo.cpp @@ -3,7 +3,7 @@ * $Id: servoSimu3D_cMcd_CamVelocityWithoutVpServo.cpp 2457 2010-01-07 10:41:18Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -97,6 +97,9 @@ // List of allowed command line options #define GETOPTARGS "h" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); + /*! Print the program options. @@ -137,15 +140,15 @@ Set the program options. */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -154,7 +157,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -164,134 +167,141 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } - // Log file creation in /tmp/$USERNAME/log.dat - // This file contains by line: - // - the 6 computed camera velocities (m/s, rad/s) to achieve the task - // - the 6 values of s - s* - std::string username; - // Get the user login name - vpIoTools::getUserName(username); - - // Create a log filename to save velocities... - std::string logdirname; -#ifdef WIN32 - logdirname ="C:/temp/" + username; + // Log file creation in /tmp/$USERNAME/log.dat + // This file contains by line: + // - the 6 computed camera velocities (m/s, rad/s) to achieve the task + // - the 6 values of s - s* + std::string username; + // Get the user login name + vpIoTools::getUserName(username); + + // Create a log filename to save velocities... + std::string logdirname; +#if defined(_WIN32) + logdirname ="C:/temp/" + username; #else - logdirname ="/tmp/" + username; + logdirname ="/tmp/" + username; #endif - // Test if the output path exist. If no try to create it - if (vpIoTools::checkDirectory(logdirname) == false) { - try { - // Create the dirname - vpIoTools::makeDirectory(logdirname); + // Test if the output path exist. If no try to create it + if (vpIoTools::checkDirectory(logdirname) == false) { + try { + // Create the dirname + vpIoTools::makeDirectory(logdirname); + } + catch (...) { + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Cannot create " << logdirname << std::endl; + exit(-1); + } } - catch (...) { - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Cannot create " << logdirname << std::endl; - exit(-1); - } - } - std::string logfilename; - logfilename = logdirname + "/log.dat"; - - // Open the log file name - std::ofstream flog(logfilename.c_str()); - - vpSimulatorCamera robot ; - - std::cout << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << " Test program for vpServo " <<std::endl ; - std::cout << " Eye-in-hand task control, velocity computed in the camera frame" << std::endl ; - std::cout << " Simulation " << std::endl ; - std::cout << " task : 3D visual servoing " << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << std::endl ; - - // Sets the initial camera location - vpPoseVector c_r_o(// Translation tx,ty,tz - 0.1, 0.2, 2, - // ThetaU rotation - vpMath::rad(20), vpMath::rad(10), vpMath::rad(50) ) ; - - // From the camera pose build the corresponding homogeneous matrix - vpHomogeneousMatrix cMo(c_r_o) ; - - // Set the robot initial position - vpHomogeneousMatrix wMc, wMo; - robot.getPosition(wMc) ; - wMo = wMc * cMo; // Compute the position of the object in the world frame - - // Sets the desired camera location - vpPoseVector cd_r_o(// Translation tx,ty,tz - 0, 0, 1, - // ThetaU rotation - vpMath::rad(0),vpMath::rad(0),vpMath::rad(0)) ; - - // From the camera desired pose build the corresponding homogeneous matrix - vpHomogeneousMatrix cdMo(cd_r_o) ; - - vpHomogeneousMatrix cMcd; // Transformation between current and desired camera frame - vpRotationMatrix cRcd; // Rotation between current and desired camera frame - - // Set the constant gain of the servo - double lambda = 1; - - unsigned int iter=0 ; - // Start the visual servoing loop. We stop the servo after 200 iterations - while(iter++ < 200) { - std::cout << "------------------------------------" << iter <<std::endl ; - - // get the robot position + std::string logfilename; + logfilename = logdirname + "/log.dat"; + + // Open the log file name + std::ofstream flog(logfilename.c_str()); + + vpSimulatorCamera robot ; + + std::cout << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << " Test program for vpServo " <<std::endl ; + std::cout << " Eye-in-hand task control, velocity computed in the camera frame" << std::endl ; + std::cout << " Simulation " << std::endl ; + std::cout << " task : 3D visual servoing " << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << std::endl ; + + // Sets the initial camera location + vpPoseVector c_r_o(// Translation tx,ty,tz + 0.1, 0.2, 2, + // ThetaU rotation + vpMath::rad(20), vpMath::rad(10), vpMath::rad(50) ) ; + + // From the camera pose build the corresponding homogeneous matrix + vpHomogeneousMatrix cMo(c_r_o) ; + + // Set the robot initial position + vpHomogeneousMatrix wMc, wMo; robot.getPosition(wMc) ; - // Compute the position of the camera wrt the object frame - cMo = wMc.inverse() * wMo; - - // new displacement to achieve - cMcd = cMo*cdMo.inverse() ; - - // Extract the translation vector ctc* which is the current - // translational visual feature. - vpTranslationVector ctcd; - cMcd.extract(ctcd); - // Compute the current theta U visual feature - vpThetaUVector tu_cRcd(cMcd); - - // Create the identity matrix - vpMatrix I(3,3); - I.setIdentity(); - - // Compute the camera translational velocity - vpColVector v(3); - v = lambda * ( I - vpColVector::skew(tu_cRcd) ) * ctcd; - // Compute the camera rotational velocity - vpColVector w(3); - w = lambda * tu_cRcd; - - // Update the complete camera velocity vector - vpColVector velocity(6); - for (unsigned int i=0; i<3; i++) { - velocity[i] = v[i]; // Translational velocity - velocity[i+3] = w[i]; // Rotational velocity + wMo = wMc * cMo; // Compute the position of the object in the world frame + + // Sets the desired camera location + vpPoseVector cd_r_o(// Translation tx,ty,tz + 0, 0, 1, + // ThetaU rotation + vpMath::rad(0),vpMath::rad(0),vpMath::rad(0)) ; + + // From the camera desired pose build the corresponding homogeneous matrix + vpHomogeneousMatrix cdMo(cd_r_o) ; + + vpHomogeneousMatrix cMcd; // Transformation between current and desired camera frame + vpRotationMatrix cRcd; // Rotation between current and desired camera frame + + // Set the constant gain of the servo + double lambda = 1; + + unsigned int iter=0 ; + // Start the visual servoing loop. We stop the servo after 200 iterations + while(iter++ < 200) { + std::cout << "------------------------------------" << iter <<std::endl ; + + // get the robot position + robot.getPosition(wMc) ; + // Compute the position of the camera wrt the object frame + cMo = wMc.inverse() * wMo; + + // new displacement to achieve + cMcd = cMo*cdMo.inverse() ; + + // Extract the translation vector ctc* which is the current + // translational visual feature. + vpTranslationVector ctcd; + cMcd.extract(ctcd); + // Compute the current theta U visual feature + vpThetaUVector tu_cRcd(cMcd); + + // Create the identity matrix + vpMatrix I(3,3); + I.setIdentity(); + + // Compute the camera translational velocity + vpColVector v(3); + v = lambda * ( I - vpColVector::skew(tu_cRcd) ) * ctcd; + // Compute the camera rotational velocity + vpColVector w(3); + w = lambda * tu_cRcd; + + // Update the complete camera velocity vector + vpColVector velocity(6); + for (unsigned int i=0; i<3; i++) { + velocity[i] = v[i]; // Translational velocity + velocity[i+3] = w[i]; // Rotational velocity + } + + // Send the camera velocity to the controller + robot.setVelocity(vpRobot::CAMERA_FRAME, velocity) ; + + // Retrieve the error (s-s*) + std::cout << "|| s - s* || = " << ctcd.t() << " " << tu_cRcd.t() << std::endl; + + // Save log + flog << velocity.t() << " " << ctcd.t() << " " << tu_cRcd.t() << std::endl; } - // Send the camera velocity to the controller - robot.setVelocity(vpRobot::CAMERA_FRAME, velocity) ; - - // Retrieve the error (s-s*) - std::cout << "|| s - s* || = " << ctcd.t() << " " << tu_cRcd.t() << std::endl; - - // Save log - flog << velocity.t() << " " << ctcd.t() << " " << tu_cRcd.t() << std::endl; + // Close the log file + flog.close(); + return 0; + } + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; } - - // Close the log file - flog.close(); } diff --git a/example/robot-simulator/camera/servoSimu3D_cdMc_CamVelocity.cpp b/example/robot-simulator/camera/servoSimu3D_cdMc_CamVelocity.cpp index e5ad3cc133c6455bb8920e820a70be8506c4531a..0d2cd25d5b70c1e2e37f5fb70d468b16bb88dd54 100644 --- a/example/robot-simulator/camera/servoSimu3D_cdMc_CamVelocity.cpp +++ b/example/robot-simulator/camera/servoSimu3D_cdMc_CamVelocity.cpp @@ -3,7 +3,7 @@ * $Id: servoSimu3D_cdMc_CamVelocity.cpp 2457 2010-01-07 10:41:18Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -74,6 +74,9 @@ // List of allowed command line options #define GETOPTARGS "h" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); + /*! Print the program options. @@ -114,15 +117,15 @@ Set the program options. */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -131,7 +134,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -141,153 +144,160 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } - // Log file creation in /tmp/$USERNAME/log.dat - // This file contains by line: - // - the 6 computed camera velocities (m/s, rad/s) to achieve the task - // - the 6 values of s - s* - std::string username; - // Get the user login name - vpIoTools::getUserName(username); - - // Create a log filename to save velocities... - std::string logdirname; -#ifdef WIN32 - logdirname ="C:/temp/" + username; + // Log file creation in /tmp/$USERNAME/log.dat + // This file contains by line: + // - the 6 computed camera velocities (m/s, rad/s) to achieve the task + // - the 6 values of s - s* + std::string username; + // Get the user login name + vpIoTools::getUserName(username); + + // Create a log filename to save velocities... + std::string logdirname; +#if defined(_WIN32) + logdirname ="C:/temp/" + username; #else - logdirname ="/tmp/" + username; + logdirname ="/tmp/" + username; #endif - // Test if the output path exist. If no try to create it - if (vpIoTools::checkDirectory(logdirname) == false) { - try { - // Create the dirname - vpIoTools::makeDirectory(logdirname); - } - catch (...) { - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Cannot create " << logdirname << std::endl; - exit(-1); + // Test if the output path exist. If no try to create it + if (vpIoTools::checkDirectory(logdirname) == false) { + try { + // Create the dirname + vpIoTools::makeDirectory(logdirname); + } + catch (...) { + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Cannot create " << logdirname << std::endl; + exit(-1); + } } - } - std::string logfilename; - logfilename = logdirname + "/log.dat"; - - // Open the log file name - std::ofstream flog(logfilename.c_str()); - - vpServo task ; - vpSimulatorCamera robot ; - - std::cout << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << " Test program for vpServo " <<std::endl ; - std::cout << " Eye-in-hand task control, velocity computed in the camera frame" << std::endl ; - std::cout << " Simulation " << std::endl ; - std::cout << " task : 3D visual servoing " << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << std::endl ; - - - // Sets the initial camera location - vpPoseVector c_r_o(// Translation tx,ty,tz - 0.1, 0.2, 2, - // ThetaU rotation - vpMath::rad(20), vpMath::rad(10), vpMath::rad(50) ) ; - - // From the camera pose build the corresponding homogeneous matrix - vpHomogeneousMatrix cMo(c_r_o) ; - - // Set the robot initial position - vpHomogeneousMatrix wMc, wMo; - robot.getPosition(wMc) ; - wMo = wMc * cMo; // Compute the position of the object in the world frame - - // Sets the desired camera location - vpPoseVector cd_r_o(// Translation tx,ty,tz - 0, 0, 1, - // ThetaU rotation - vpMath::rad(0),vpMath::rad(0),vpMath::rad(0)) ; - // From the camera desired pose build the corresponding homogeneous matrix - vpHomogeneousMatrix cdMo(cd_r_o) ; - - // Compute the homogeneous transformation from the desired camera position to the initial one - vpHomogeneousMatrix cdMc ; - cdMc = cdMo*cMo.inverse() ; - - // Build the current visual features s = (c*tc, thetaU_c*Rc)^T - vpFeatureTranslation t(vpFeatureTranslation::cdMc) ; - vpFeatureThetaU tu(vpFeatureThetaU::cdRc); // current feature - t.buildFrom(cdMc) ; - tu.buildFrom(cdMc) ; - - // Sets the desired rotation (always zero !) since s is the - // rotation that the camera has to achieve. Here s* = (0, 0)^T - vpFeatureTranslation td(vpFeatureTranslation::cdMc) ; - vpFeatureThetaU tud(vpFeatureThetaU::cdRc); // desired feature - - // Define the task - // - we want an eye-in-hand control law - // - the robot is controlled in the camera frame - task.setServo(vpServo::EYEINHAND_CAMERA) ; - // - we use here the interaction matrix computed with the - // current features - task.setInteractionMatrixType(vpServo::CURRENT); - - // Add the current and desired visual features - task.addFeature(t,td) ; // 3D translation - task.addFeature(tu,tud) ; // 3D rotation - - // - set the constant gain to 1.0 - task.setLambda(1) ; - - // Display task information - task.print() ; - - unsigned int iter=0 ; - // Start the visual servoing loop. We stop the servo after 200 iterations - while(iter++ < 200) { - std::cout << "-----------------------------------" << iter <<std::endl ; - vpColVector v ; - - // get the robot position - robot.getPosition(wMc) ; - // Compute the position of the camera wrt the object frame - cMo = wMc.inverse() * wMo; + std::string logfilename; + logfilename = logdirname + "/log.dat"; + + // Open the log file name + std::ofstream flog(logfilename.c_str()); - // new displacement to achieve + vpServo task ; + vpSimulatorCamera robot ; + + std::cout << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << " Test program for vpServo " <<std::endl ; + std::cout << " Eye-in-hand task control, velocity computed in the camera frame" << std::endl ; + std::cout << " Simulation " << std::endl ; + std::cout << " task : 3D visual servoing " << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << std::endl ; + + + // Sets the initial camera location + vpPoseVector c_r_o(// Translation tx,ty,tz + 0.1, 0.2, 2, + // ThetaU rotation + vpMath::rad(20), vpMath::rad(10), vpMath::rad(50) ) ; + + // From the camera pose build the corresponding homogeneous matrix + vpHomogeneousMatrix cMo(c_r_o) ; + + // Set the robot initial position + vpHomogeneousMatrix wMc, wMo; + robot.getPosition(wMc) ; + wMo = wMc * cMo; // Compute the position of the object in the world frame + + // Sets the desired camera location + vpPoseVector cd_r_o(// Translation tx,ty,tz + 0, 0, 1, + // ThetaU rotation + vpMath::rad(0),vpMath::rad(0),vpMath::rad(0)) ; + // From the camera desired pose build the corresponding homogeneous matrix + vpHomogeneousMatrix cdMo(cd_r_o) ; + + // Compute the homogeneous transformation from the desired camera position to the initial one + vpHomogeneousMatrix cdMc ; cdMc = cdMo*cMo.inverse() ; - // Update the current visual features + // Build the current visual features s = (c*tc, thetaU_c*Rc)^T + vpFeatureTranslation t(vpFeatureTranslation::cdMc) ; + vpFeatureThetaU tu(vpFeatureThetaU::cdRc); // current feature t.buildFrom(cdMc) ; tu.buildFrom(cdMc) ; - // Compute the control law - v = task.computeControlLaw() ; + // Sets the desired rotation (always zero !) since s is the + // rotation that the camera has to achieve. Here s* = (0, 0)^T + vpFeatureTranslation td(vpFeatureTranslation::cdMc) ; + vpFeatureThetaU tud(vpFeatureThetaU::cdRc); // desired feature + + // Define the task + // - we want an eye-in-hand control law + // - the robot is controlled in the camera frame + task.setServo(vpServo::EYEINHAND_CAMERA) ; + // - we use here the interaction matrix computed with the + // current features + task.setInteractionMatrixType(vpServo::CURRENT); + + // Add the current and desired visual features + task.addFeature(t,td) ; // 3D translation + task.addFeature(tu,tud) ; // 3D rotation + + // - set the constant gain to 1.0 + task.setLambda(1) ; // Display task information - if (iter==1) task.print() ; + task.print() ; - // Send the camera velocity to the controller - robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + unsigned int iter=0 ; + // Start the visual servoing loop. We stop the servo after 200 iterations + while(iter++ < 200) { + std::cout << "-----------------------------------" << iter <<std::endl ; + vpColVector v ; - // Retrieve the error - std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; + // get the robot position + robot.getPosition(wMc) ; + // Compute the position of the camera wrt the object frame + cMo = wMc.inverse() * wMo; - // Save log - flog << v.t() << " " << ( task.getError() ).t() << std::endl; - } - // Display task information - task.print() ; + // new displacement to achieve + cdMc = cdMo*cMo.inverse() ; + + // Update the current visual features + t.buildFrom(cdMc) ; + tu.buildFrom(cdMc) ; + + // Compute the control law + v = task.computeControlLaw() ; + + // Display task information + if (iter==1) task.print() ; + + // Send the camera velocity to the controller + robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; - // Kill the task - task.kill(); + // Retrieve the error + std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; - // Close the log file - flog.close(); + // Save log + flog << v.t() << " " << ( task.getError() ).t() << std::endl; + } + // Display task information + task.print() ; + + // Kill the task + task.kill(); + + // Close the log file + flog.close(); + return 0; + } + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; + } } diff --git a/example/robot-simulator/camera/servoSimu3D_cdMc_CamVelocityWithoutVpServo.cpp b/example/robot-simulator/camera/servoSimu3D_cdMc_CamVelocityWithoutVpServo.cpp index f2ad91339a7e78f9695b6fb4dfd6c7be5975991d..0348c7564e61b823622a3b0826afab63f1404d13 100644 --- a/example/robot-simulator/camera/servoSimu3D_cdMc_CamVelocityWithoutVpServo.cpp +++ b/example/robot-simulator/camera/servoSimu3D_cdMc_CamVelocityWithoutVpServo.cpp @@ -3,7 +3,7 @@ * $Id: servoSimu3D_cdMc_CamVelocityWithoutVpServo.cpp 2457 2010-01-07 10:41:18Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -91,6 +91,9 @@ // List of allowed command line options #define GETOPTARGS "h" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); + /*! Print the program options. @@ -131,15 +134,15 @@ Set the program options. */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -148,7 +151,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -158,133 +161,140 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } - // Log file creation in /tmp/$USERNAME/log.dat - // This file contains by line: - // - the 6 computed camera velocities (m/s, rad/s) to achieve the task - // - the 6 values of s - s* - std::string username; - // Get the user login name - vpIoTools::getUserName(username); - - // Create a log filename to save velocities... - std::string logdirname; -#ifdef WIN32 - logdirname ="C:/temp/" + username; + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } + // Log file creation in /tmp/$USERNAME/log.dat + // This file contains by line: + // - the 6 computed camera velocities (m/s, rad/s) to achieve the task + // - the 6 values of s - s* + std::string username; + // Get the user login name + vpIoTools::getUserName(username); + + // Create a log filename to save velocities... + std::string logdirname; +#if defined(_WIN32) + logdirname ="C:/temp/" + username; #else - logdirname ="/tmp/" + username; + logdirname ="/tmp/" + username; #endif - // Test if the output path exist. If no try to create it - if (vpIoTools::checkDirectory(logdirname) == false) { - try { - // Create the dirname - vpIoTools::makeDirectory(logdirname); - } - catch (...) { - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Cannot create " << logdirname << std::endl; - exit(-1); - } - } - std::string logfilename; - logfilename = logdirname + "/log.dat"; - - // Open the log file name - std::ofstream flog(logfilename.c_str()); - - vpSimulatorCamera robot ; - - std::cout << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << " Test program without vpServo and vpFeature classes " <<std::endl ; - std::cout << " Eye-in-hand task control, velocity computed in the camera frame" << std::endl ; - std::cout << " Simulation " << std::endl ; - std::cout << " task : 3D visual servoing " << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << std::endl ; - - - // Sets the initial camera location - vpPoseVector c_r_o(// Translation tx,ty,tz - 0.1, 0.2, 2, - // ThetaU rotation - vpMath::rad(20), vpMath::rad(10), vpMath::rad(50) ) ; - - // From the camera pose build the corresponding homogeneous matrix - vpHomogeneousMatrix cMo(c_r_o) ; - - // Set the robot initial position - vpHomogeneousMatrix wMc, wMo; - robot.getPosition(wMc) ; - wMo = wMc * cMo; // Compute the position of the object in the world frame - - // Sets the desired camera location - vpPoseVector cd_r_o(// Translation tx,ty,tz - 0, 0, 1, - // ThetaU rotation - vpMath::rad(0),vpMath::rad(0),vpMath::rad(0)) ; - // From the camera desired pose build the corresponding homogeneous matrix - vpHomogeneousMatrix cdMo(cd_r_o) ; - - vpHomogeneousMatrix cdMc; // Transformation between desired and current camera frame - vpRotationMatrix cdRc; // Rotation between desired and current camera frame - vpRotationMatrix cRcd; // Rotation between current and desired camera frame - - // Set the constant gain of the servo - double lambda = 1; - - unsigned int iter=0 ; - // Start the visual servoing loop. We stop the servo after 200 iterations - while(iter++ < 200) { - std::cout << "-----------------------------------" << iter <<std::endl ; - - // get the robot position - robot.getPosition(wMc) ; - // Compute the position of the camera wrt the object frame - cMo = wMc.inverse() * wMo; - - // new displacement to achieve - cdMc = cdMo*cMo.inverse() ; - - // Extract the translation vector c*tc which is the current - // translational visual feature. - vpTranslationVector cdtc; - cdMc.extract(cdtc); - // Extract the rotation matrix c*Rc - cdMc.extract(cdRc); - // Compute the inverse rotation cRc* (in fact the transpose of c*Rc) - cRcd = cdRc.inverse(); - // Compute the current theta U visual feature - vpThetaUVector tu_cdRc(cdMc); - // Compute the camera translational velocity - vpColVector v(3); - v = -lambda * cRcd * cdtc; - // Compute the camera rotational velocity - vpColVector w(3); - w = -lambda * tu_cdRc; - - // Update the complete camera velocity vector - vpColVector velocity(6); - for (unsigned int i=0; i<3; i++) { - velocity[i] = v[i]; // Translational velocity - velocity[i+3] = w[i]; // Rotational velocity + // Test if the output path exist. If no try to create it + if (vpIoTools::checkDirectory(logdirname) == false) { + try { + // Create the dirname + vpIoTools::makeDirectory(logdirname); + } + catch (...) { + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Cannot create " << logdirname << std::endl; + exit(-1); + } } + std::string logfilename; + logfilename = logdirname + "/log.dat"; - // Send the camera velocity to the controller - robot.setVelocity(vpRobot::CAMERA_FRAME, velocity) ; + // Open the log file name + std::ofstream flog(logfilename.c_str()); - // Retrieve the error (s-s*) - std::cout << "|| s - s* || = " << cdtc.t() << " " << tu_cdRc.t() << std::endl; + vpSimulatorCamera robot ; - // Save log - flog << velocity.t() << " " << cdtc.t() << " " << tu_cdRc.t() << std::endl; + std::cout << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << " Test program without vpServo and vpFeature classes " <<std::endl ; + std::cout << " Eye-in-hand task control, velocity computed in the camera frame" << std::endl ; + std::cout << " Simulation " << std::endl ; + std::cout << " task : 3D visual servoing " << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << std::endl ; + + + // Sets the initial camera location + vpPoseVector c_r_o(// Translation tx,ty,tz + 0.1, 0.2, 2, + // ThetaU rotation + vpMath::rad(20), vpMath::rad(10), vpMath::rad(50) ) ; + + // From the camera pose build the corresponding homogeneous matrix + vpHomogeneousMatrix cMo(c_r_o) ; + + // Set the robot initial position + vpHomogeneousMatrix wMc, wMo; + robot.getPosition(wMc) ; + wMo = wMc * cMo; // Compute the position of the object in the world frame + + // Sets the desired camera location + vpPoseVector cd_r_o(// Translation tx,ty,tz + 0, 0, 1, + // ThetaU rotation + vpMath::rad(0),vpMath::rad(0),vpMath::rad(0)) ; + // From the camera desired pose build the corresponding homogeneous matrix + vpHomogeneousMatrix cdMo(cd_r_o) ; + + vpHomogeneousMatrix cdMc; // Transformation between desired and current camera frame + vpRotationMatrix cdRc; // Rotation between desired and current camera frame + vpRotationMatrix cRcd; // Rotation between current and desired camera frame + + // Set the constant gain of the servo + double lambda = 1; + + unsigned int iter=0 ; + // Start the visual servoing loop. We stop the servo after 200 iterations + while(iter++ < 200) { + std::cout << "-----------------------------------" << iter <<std::endl ; + + // get the robot position + robot.getPosition(wMc) ; + // Compute the position of the camera wrt the object frame + cMo = wMc.inverse() * wMo; + + // new displacement to achieve + cdMc = cdMo*cMo.inverse() ; + + // Extract the translation vector c*tc which is the current + // translational visual feature. + vpTranslationVector cdtc; + cdMc.extract(cdtc); + // Extract the rotation matrix c*Rc + cdMc.extract(cdRc); + // Compute the inverse rotation cRc* (in fact the transpose of c*Rc) + cRcd = cdRc.inverse(); + // Compute the current theta U visual feature + vpThetaUVector tu_cdRc(cdMc); + // Compute the camera translational velocity + vpColVector v(3); + v = -lambda * cRcd * cdtc; + // Compute the camera rotational velocity + vpColVector w(3); + w = -lambda * tu_cdRc; + + // Update the complete camera velocity vector + vpColVector velocity(6); + for (unsigned int i=0; i<3; i++) { + velocity[i] = v[i]; // Translational velocity + velocity[i+3] = w[i]; // Rotational velocity + } + + // Send the camera velocity to the controller + robot.setVelocity(vpRobot::CAMERA_FRAME, velocity) ; + + // Retrieve the error (s-s*) + std::cout << "|| s - s* || = " << cdtc.t() << " " << tu_cdRc.t() << std::endl; + + // Save log + flog << velocity.t() << " " << cdtc.t() << " " << tu_cdRc.t() << std::endl; + } + // Close the log file + flog.close(); + return 0; + } + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; } - // Close the log file - flog.close(); } diff --git a/example/robot-simulator/camera/servoSimuCircle2DCamVelocity.cpp b/example/robot-simulator/camera/servoSimuCircle2DCamVelocity.cpp index 9944fde20f5190e17f0d63d12674dacc0028b368..4b4b9c0bab9434b1ba1759df2b5aa36a26cd1ca7 100644 --- a/example/robot-simulator/camera/servoSimuCircle2DCamVelocity.cpp +++ b/example/robot-simulator/camera/servoSimuCircle2DCamVelocity.cpp @@ -4,7 +4,7 @@ * $Id: servoSimuCircle2DCamVelocity.cpp 2457 2010-01-07 10:41:18Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -73,6 +73,9 @@ // List of allowed command line options #define GETOPTARGS "h" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); + /*! Print the program options. @@ -113,15 +116,15 @@ Set the program options. */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -130,7 +133,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -140,96 +143,103 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } - - vpServo task ; - vpSimulatorCamera robot ; - - std::cout << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << " Test program for vpServo " <<std::endl ; - std::cout << " Simulation " << std::endl ; - std::cout << " task : servo a circle " << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << std::endl ; - - - // sets the initial camera location - vpHomogeneousMatrix cMo ; - cMo[0][3] = 0.1 ; - cMo[1][3] = 0.2 ; - cMo[2][3] = 2 ; - - vpHomogeneousMatrix wMc, wMo; - robot.getPosition(wMc) ; - wMo = wMc * cMo; // Compute the position of the object in the world frame - - vpHomogeneousMatrix cMod ; - cMod[0][3] = 0 ; - cMod[1][3] = 0 ; - cMod[2][3] = 1 ; - - // sets the circle coordinates in the world frame - vpCircle circle ; - circle.setWorldCoordinates(0,0,1,0,0,0,0.1) ; + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } - // sets the desired position of the visual feature - vpFeatureEllipse pd ; - circle.track(cMod) ; - vpFeatureBuilder::create(pd,circle) ; + vpServo task ; + vpSimulatorCamera robot ; - // project : computes the circle coordinates in the camera frame and its 2D coordinates + std::cout << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << " Test program for vpServo " <<std::endl ; + std::cout << " Simulation " << std::endl ; + std::cout << " task : servo a circle " << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << std::endl ; - // sets the current position of the visual feature - vpFeatureEllipse p ; - circle.track(cMo) ; - vpFeatureBuilder::create(p,circle) ; - // define the task - // - we want an eye-in-hand control law - // - robot is controlled in the camera frame - task.setServo(vpServo::EYEINHAND_CAMERA) ; + // sets the initial camera location + vpHomogeneousMatrix cMo ; + cMo[0][3] = 0.1 ; + cMo[1][3] = 0.2 ; + cMo[2][3] = 2 ; - // - we want to see a circle on a circle - std::cout << std::endl ; - task.addFeature(p,pd) ; + vpHomogeneousMatrix wMc, wMo; + robot.getPosition(wMc) ; + wMo = wMc * cMo; // Compute the position of the object in the world frame - // - set the gain - task.setLambda(1) ; + vpHomogeneousMatrix cMod ; + cMod[0][3] = 0 ; + cMod[1][3] = 0 ; + cMod[2][3] = 1 ; - // Display task information - task.print() ; + // sets the circle coordinates in the world frame + vpCircle circle ; + circle.setWorldCoordinates(0,0,1,0,0,0,0.1) ; - unsigned int iter=0 ; - // loop - while(iter++ < 500) - { - std::cout << "---------------------------------------------" << iter <<std::endl ; - vpColVector v ; + // sets the desired position of the visual feature + vpFeatureEllipse pd ; + circle.track(cMod) ; + vpFeatureBuilder::create(pd,circle) ; - // get the robot position - robot.getPosition(wMc) ; - // Compute the position of the camera wrt the object frame - cMo = wMc.inverse() * wMo; + // project : computes the circle coordinates in the camera frame and its 2D coordinates - // new circle position: retrieve x,y and Z of the vpCircle structure + // sets the current position of the visual feature + vpFeatureEllipse p ; circle.track(cMo) ; - vpFeatureBuilder::create(p,circle); - - // compute the control law - v = task.computeControlLaw() ; - std::cout << "task rank: " << task.getTaskRank() <<std::endl ; - // send the camera velocity to the controller - robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + vpFeatureBuilder::create(p,circle) ; + + // define the task + // - we want an eye-in-hand control law + // - robot is controlled in the camera frame + task.setServo(vpServo::EYEINHAND_CAMERA) ; + + // - we want to see a circle on a circle + std::cout << std::endl ; + task.addFeature(p,pd) ; + + // - set the gain + task.setLambda(1) ; + + // Display task information + task.print() ; + + unsigned int iter=0 ; + // loop + while(iter++ < 500) + { + std::cout << "---------------------------------------------" << iter <<std::endl ; + vpColVector v ; + + // get the robot position + robot.getPosition(wMc) ; + // Compute the position of the camera wrt the object frame + cMo = wMc.inverse() * wMo; + + // new circle position: retrieve x,y and Z of the vpCircle structure + circle.track(cMo) ; + vpFeatureBuilder::create(p,circle); + + // compute the control law + v = task.computeControlLaw() ; + std::cout << "task rank: " << task.getTaskRank() <<std::endl ; + // send the camera velocity to the controller + robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + + std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() << std::endl ; + } - std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() << std::endl ; + // Display task information + task.print() ; + task.kill(); + return 0; + } + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; } - - // Display task information - task.print() ; - task.kill(); } diff --git a/example/robot-simulator/camera/servoSimuCircle2DCamVelocityDisplay.cpp b/example/robot-simulator/camera/servoSimuCircle2DCamVelocityDisplay.cpp index 4c70e19549442b06dee372f37b7d599dafc7a9fa..4b8711fe96c343bee8dc8054ea1d6b43210056b1 100644 --- a/example/robot-simulator/camera/servoSimuCircle2DCamVelocityDisplay.cpp +++ b/example/robot-simulator/camera/servoSimuCircle2DCamVelocityDisplay.cpp @@ -4,7 +4,7 @@ * $Id: servoSimuCircle2DCamVelocityDisplay.cpp 2457 2010-01-07 10:41:18Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -78,6 +78,9 @@ // List of allowed command line options #define GETOPTARGS "cdh" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display); + /*! Print the program options. @@ -130,9 +133,9 @@ Set the program options. */ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; @@ -140,7 +143,7 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) case 'h': usage(argv[0], NULL); return false; break; default: - usage(argv[0], optarg); + usage(argv[0], optarg_); return false; break; } } @@ -149,7 +152,7 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -160,135 +163,141 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) int main(int argc, const char ** argv) { - bool opt_display = true; - bool opt_click_allowed = true; + try { + bool opt_display = true; + bool opt_click_allowed = true; - // Read the command line options - if (getOptions(argc, argv, opt_click_allowed, opt_display) == false) { - exit (-1); - } + // Read the command line options + if (getOptions(argc, argv, opt_click_allowed, opt_display) == false) { + exit (-1); + } - vpImage<unsigned char> I(512,512,0) ; + vpImage<unsigned char> I(512,512,0) ; - // We open a window using either X11, GTK or GDI. + // We open a window using either X11, GTK or GDI. #if defined VISP_HAVE_X11 - vpDisplayX display; + vpDisplayX display; #elif defined VISP_HAVE_GTK - vpDisplayGTK display; + vpDisplayGTK display; #elif defined VISP_HAVE_GDI - vpDisplayGDI display; + vpDisplayGDI display; #endif - if (opt_display) { - try{ - // Display size is automatically defined by the image (I) size - display.init(I, 100, 100,"Camera view...") ; - // 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) ; - vpDisplay::flush(I) ; - } - catch(...) - { - vpERROR_TRACE("Error while displaying the image") ; - exit(-1); + if (opt_display) { + try{ + // Display size is automatically defined by the image (I) size + display.init(I, 100, 100,"Camera view...") ; + // 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) ; + vpDisplay::flush(I) ; + } + catch(...) + { + vpERROR_TRACE("Error while displaying the image") ; + exit(-1); + } } - } - double px, py ; px = py = 600 ; - double u0, v0 ; u0 = v0 = 256 ; - - vpCameraParameters cam(px,py,u0,v0); - - vpServo task ; - vpSimulatorCamera robot ; - - // sets the initial camera location - vpHomogeneousMatrix cMo(0,0,1, - vpMath::rad(0), vpMath::rad(80), vpMath::rad(30)) ; - vpHomogeneousMatrix wMc, wMo; - robot.getPosition(wMc) ; - wMo = wMc * cMo; // Compute the position of the object in the world frame - - vpHomogeneousMatrix cMod(-0.1,-0.1,0.7, - vpMath::rad(40), vpMath::rad(10), vpMath::rad(30)) ; - - // sets the circle coordinates in the world frame - vpCircle circle ; - circle.setWorldCoordinates(0,0,1, - 0,0,0, - 0.1) ; - - // sets the desired position of the visual feature - vpFeatureEllipse pd ; - circle.track(cMod) ; - vpFeatureBuilder::create(pd,circle) ; - - // project : computes the circle coordinates in the camera frame and its 2D coordinates - // sets the current position of the visual feature - vpFeatureEllipse p ; - circle.track(cMo) ; - vpFeatureBuilder::create(p,circle) ; - - // define the task - // - we want an eye-in-hand control law - // - robot is controlled in the camera frame - task.setServo(vpServo::EYEINHAND_CAMERA) ; - task.setInteractionMatrixType(vpServo::DESIRED) ; - // - we want to see a circle on a circle - task.addFeature(p,pd) ; - // - set the gain - task.setLambda(1) ; - - // Display task information - task.print() ; - - unsigned int iter=0 ; - // loop - while(iter++ < 200) - { - std::cout << "---------------------------------------------" << iter <<std::endl ; - vpColVector v ; - - // get the robot position + double px, py ; px = py = 600 ; + double u0, v0 ; u0 = v0 = 256 ; + + vpCameraParameters cam(px,py,u0,v0); + + vpServo task ; + vpSimulatorCamera robot ; + + // sets the initial camera location + vpHomogeneousMatrix cMo(0,0,1, + vpMath::rad(0), vpMath::rad(80), vpMath::rad(30)) ; + vpHomogeneousMatrix wMc, wMo; robot.getPosition(wMc) ; - // Compute the position of the camera wrt the object frame - cMo = wMc.inverse() * wMo; + wMo = wMc * cMo; // Compute the position of the object in the world frame - // new circle position - // retrieve x,y and Z of the vpCircle structure - circle.track(cMo) ; - vpFeatureBuilder::create(p,circle); - circle.print() ; - p.print() ; + vpHomogeneousMatrix cMod(-0.1,-0.1,0.7, + vpMath::rad(40), vpMath::rad(10), vpMath::rad(30)) ; - if (opt_display) { - vpDisplay::display(I) ; - vpServoDisplay::display(task,cam,I) ; - vpDisplay::flush(I) ; - } + // sets the circle coordinates in the world frame + vpCircle circle ; + circle.setWorldCoordinates(0,0,1, + 0,0,0, + 0.1) ; - // compute the control law - v = task.computeControlLaw() ; - std::cout << "task rank: " << task.getTaskRank() <<std::endl ; - // send the camera velocity to the controller - robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + // sets the desired position of the visual feature + vpFeatureEllipse pd ; + circle.track(cMod) ; + vpFeatureBuilder::create(pd,circle) ; - std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; - } + // project : computes the circle coordinates in the camera frame and its 2D coordinates + // sets the current position of the visual feature + vpFeatureEllipse p ; + circle.track(cMo) ; + vpFeatureBuilder::create(p,circle) ; + + // define the task + // - we want an eye-in-hand control law + // - robot is controlled in the camera frame + task.setServo(vpServo::EYEINHAND_CAMERA) ; + task.setInteractionMatrixType(vpServo::DESIRED) ; + // - we want to see a circle on a circle + task.addFeature(p,pd) ; + // - set the gain + task.setLambda(1) ; + + // Display task information + task.print() ; + + unsigned int iter=0 ; + // loop + while(iter++ < 200) + { + std::cout << "---------------------------------------------" << iter <<std::endl ; + vpColVector v ; + + // get the robot position + robot.getPosition(wMc) ; + // Compute the position of the camera wrt the object frame + cMo = wMc.inverse() * wMo; + + // new circle position + // retrieve x,y and Z of the vpCircle structure + circle.track(cMo) ; + vpFeatureBuilder::create(p,circle); + circle.print() ; + p.print() ; + + if (opt_display) { + vpDisplay::display(I) ; + vpServoDisplay::display(task,cam,I) ; + vpDisplay::flush(I) ; + } + + // compute the control law + v = task.computeControlLaw() ; + std::cout << "task rank: " << task.getTaskRank() <<std::endl ; + // send the camera velocity to the controller + robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + + std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; + } - // Display task information - task.print() ; - task.kill(); + // Display task information + task.print() ; + task.kill(); - if (opt_display && opt_click_allowed) { - std::cout << "Click in the camera view window to end..." << std::endl; - vpDisplay::getClick(I) ; + if (opt_display && opt_click_allowed) { + std::cout << "Click in the camera view window to end..." << std::endl; + vpDisplay::getClick(I) ; + } + return 0; + } + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; } - } #else int diff --git a/example/robot-simulator/camera/servoSimuCylinder2DCamVelocityDisplay.cpp b/example/robot-simulator/camera/servoSimuCylinder2DCamVelocityDisplay.cpp index 2b3f4dec9c590fd7e3ef4dbab5f8fa23dad20e57..c954a04ff7cbc5a7bcd6b3a206ec1f021a9a1fc4 100644 --- a/example/robot-simulator/camera/servoSimuCylinder2DCamVelocityDisplay.cpp +++ b/example/robot-simulator/camera/servoSimuCylinder2DCamVelocityDisplay.cpp @@ -3,7 +3,7 @@ * $Id: servoSimuCylinder2DCamVelocityDisplay.cpp 2457 2010-01-07 10:41:18Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -77,6 +77,9 @@ // List of allowed command line options #define GETOPTARGS "cdh" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display); + /*! Print the program options. @@ -126,9 +129,9 @@ Set the program options. */ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; @@ -136,7 +139,7 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) case 'h': usage(argv[0], NULL); return false; break; default: - usage(argv[0], optarg); + usage(argv[0], optarg_); return false; break; } } @@ -145,7 +148,7 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -156,170 +159,177 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) int main(int argc, const char ** argv) { - bool opt_display = true; - bool opt_click_allowed = true; + try { + bool opt_display = true; + bool opt_click_allowed = true; - // Read the command line options - if (getOptions(argc, argv, opt_click_allowed, opt_display) == false) { - exit (-1); - } + // Read the command line options + if (getOptions(argc, argv, opt_click_allowed, opt_display) == false) { + exit (-1); + } - vpImage<unsigned char> I(512,512,255) ; + vpImage<unsigned char> I(512,512,255) ; - // We open a window using either X11, GTK or GDI. + // We open a window using either X11, GTK or GDI. #if defined VISP_HAVE_X11 - vpDisplayX display; + vpDisplayX display; #elif defined VISP_HAVE_GTK - vpDisplayGTK display; + vpDisplayGTK display; #elif defined VISP_HAVE_GDI - vpDisplayGDI display; + vpDisplayGDI display; #endif - if (opt_display) { - try{ - // Display size is automatically defined by the image (I) size - display.init(I, 100, 100,"Camera view...") ; - // 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) ; - vpDisplay::flush(I) ; - } - catch(...) - { - vpERROR_TRACE("Error while displaying the image") ; - exit(-1); + if (opt_display) { + try{ + // Display size is automatically defined by the image (I) size + display.init(I, 100, 100,"Camera view...") ; + // 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) ; + vpDisplay::flush(I) ; + } + catch(...) + { + vpERROR_TRACE("Error while displaying the image") ; + exit(-1); + } } - } - double px, py ; px = py = 600 ; - double u0, v0 ; u0 = v0 = 256 ; + double px, py ; px = py = 600 ; + double u0, v0 ; u0 = v0 = 256 ; - vpCameraParameters cam(px,py,u0,v0); + vpCameraParameters cam(px,py,u0,v0); - vpServo task ; - vpSimulatorCamera robot ; + vpServo task ; + vpSimulatorCamera robot ; - // sets the initial camera location - vpHomogeneousMatrix cMo(-0.2,0.1,2, - vpMath::rad(5), vpMath::rad(5), vpMath::rad(20)); + // sets the initial camera location + vpHomogeneousMatrix cMo(-0.2,0.1,2, + vpMath::rad(5), vpMath::rad(5), vpMath::rad(20)); - vpHomogeneousMatrix wMc, wMo; - robot.getPosition(wMc) ; - wMo = wMc * cMo; // Compute the position of the object in the world frame - - // sets the final camera location (for simulation purpose) - vpHomogeneousMatrix cMod(0,0,1, - vpMath::rad(-60), vpMath::rad(0), vpMath::rad(0)); - - // sets the cylinder coordinates in the world frame - vpCylinder cylinder(0,1,0, // direction - 0,0,0, // point of the axis - 0.1) ; // radius - - // sets the desired position of the visual feature - cylinder.track(cMod) ; - cylinder.print() ; - - vpFeatureLine ld[2] ; - int i ; - for(i=0 ; i < 2 ; i++) - vpFeatureBuilder::create(ld[i],cylinder,i) ; - - // computes the cylinder coordinates in the camera frame and its 2D coordinates - // sets the current position of the visual feature - cylinder.track(cMo) ; - cylinder.print() ; - - vpFeatureLine l[2] ; - for(i=0 ; i < 2 ; i++) - { - vpFeatureBuilder::create(l[i],cylinder,i) ; - l[i].print() ; - } - - // define the task - // - we want an eye-in-hand control law - // - robot is controlled in the camera frame - task.setServo(vpServo::EYEINHAND_CAMERA) ; - // task.setInteractionMatrixType(vpServo::CURRENT, vpServo::PSEUDO_INVERSE) ; - // it can also be interesting to test these possibilities - // task.setInteractionMatrixType(vpServo::MEAN, vpServo::PSEUDO_INVERSE) ; - task.setInteractionMatrixType(vpServo::DESIRED,vpServo::PSEUDO_INVERSE) ; - //task.setInteractionMatrixType(vpServo::DESIRED, vpServo::TRANSPOSE) ; - // task.setInteractionMatrixType(vpServo::CURRENT, vpServo::TRANSPOSE) ; - - // - we want to see 2 lines on 2 lines - task.addFeature(l[0],ld[0]) ; - task.addFeature(l[1],ld[1]) ; - - vpServoDisplay::display(task,cam,I) ; - vpDisplay::flush(I) ; - - // Display task information - task.print() ; - - if (opt_display && opt_click_allowed) { - std::cout << "\n\nClick in the camera view window to start..." << std::endl; - vpDisplay::getClick(I) ; - } + vpHomogeneousMatrix wMc, wMo; + robot.getPosition(wMc) ; + wMo = wMc * cMo; // Compute the position of the object in the world frame - // - set the gain - task.setLambda(1) ; + // sets the final camera location (for simulation purpose) + vpHomogeneousMatrix cMod(0,0,1, + vpMath::rad(-60), vpMath::rad(0), vpMath::rad(0)); - // Display task information - task.print() ; + // sets the cylinder coordinates in the world frame + vpCylinder cylinder(0,1,0, // direction + 0,0,0, // point of the axis + 0.1) ; // radius - unsigned int iter=0 ; - // loop - do - { - std::cout << "---------------------------------------------" << iter++ <<std::endl ; - vpColVector v ; + // sets the desired position of the visual feature + cylinder.track(cMod) ; + cylinder.print() ; - // get the robot position - robot.getPosition(wMc) ; - // Compute the position of the camera wrt the object frame - cMo = wMc.inverse() * wMo; + vpFeatureLine ld[2] ; + int i ; + for(i=0 ; i < 2 ; i++) + vpFeatureBuilder::create(ld[i],cylinder,i) ; - // new line position - // retrieve x,y and Z of the vpLine structure + // computes the cylinder coordinates in the camera frame and its 2D coordinates + // sets the current position of the visual feature cylinder.track(cMo) ; - // cylinder.print() ; + cylinder.print() ; + + vpFeatureLine l[2] ; for(i=0 ; i < 2 ; i++) { vpFeatureBuilder::create(l[i],cylinder,i) ; - // l[i].print() ; + l[i].print() ; } - if (opt_display) { - vpDisplay::display(I) ; - vpServoDisplay::display(task,cam,I) ; - vpDisplay::flush(I) ; + // define the task + // - we want an eye-in-hand control law + // - robot is controlled in the camera frame + task.setServo(vpServo::EYEINHAND_CAMERA) ; + // task.setInteractionMatrixType(vpServo::CURRENT, vpServo::PSEUDO_INVERSE) ; + // it can also be interesting to test these possibilities + // task.setInteractionMatrixType(vpServo::MEAN, vpServo::PSEUDO_INVERSE) ; + task.setInteractionMatrixType(vpServo::DESIRED,vpServo::PSEUDO_INVERSE) ; + //task.setInteractionMatrixType(vpServo::DESIRED, vpServo::TRANSPOSE) ; + // task.setInteractionMatrixType(vpServo::CURRENT, vpServo::TRANSPOSE) ; + + // - we want to see 2 lines on 2 lines + task.addFeature(l[0],ld[0]) ; + task.addFeature(l[1],ld[1]) ; + + vpServoDisplay::display(task,cam,I) ; + vpDisplay::flush(I) ; + + // Display task information + task.print() ; + + if (opt_display && opt_click_allowed) { + std::cout << "\n\nClick in the camera view window to start..." << std::endl; + vpDisplay::getClick(I) ; } - // compute the control law - v = task.computeControlLaw() ; + // - set the gain + task.setLambda(1) ; - // send the camera velocity to the controller - robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + // Display task information + task.print() ; - std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; ; + unsigned int iter=0 ; + // loop + do + { + std::cout << "---------------------------------------------" << iter++ <<std::endl ; + vpColVector v ; + + // get the robot position + robot.getPosition(wMc) ; + // Compute the position of the camera wrt the object frame + cMo = wMc.inverse() * wMo; + + // new line position + // retrieve x,y and Z of the vpLine structure + cylinder.track(cMo) ; + // cylinder.print() ; + for(i=0 ; i < 2 ; i++) + { + vpFeatureBuilder::create(l[i],cylinder,i) ; + // l[i].print() ; + } + + if (opt_display) { + vpDisplay::display(I) ; + vpServoDisplay::display(task,cam,I) ; + vpDisplay::flush(I) ; + } + + // compute the control law + v = task.computeControlLaw() ; + + // send the camera velocity to the controller + robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + + std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; ; + + // vpDisplay::getClick(I) ; + } + while(( task.getError() ).sumSquare() > 1e-9) ; - // vpDisplay::getClick(I) ; - } - while(( task.getError() ).sumSquare() > 1e-9) ; + if (opt_display && opt_click_allowed) { + std::cout << "\nClick in the camera view window to end..." << std::endl; + vpDisplay::getClick(I) ; + } - if (opt_display && opt_click_allowed) { - std::cout << "\nClick in the camera view window to end..." << std::endl; - vpDisplay::getClick(I) ; + // Display task information + task.print() ; + task.kill(); + return 0; + } + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; } - - // Display task information - task.print() ; - task.kill(); } #else diff --git a/example/robot-simulator/camera/servoSimuCylinder2DCamVelocityDisplaySecondaryTask.cpp b/example/robot-simulator/camera/servoSimuCylinder2DCamVelocityDisplaySecondaryTask.cpp index d98db77f22fc032edd51e5cf0eef850f24d7b79d..4efd20a724b4bcb9abb20df6445be3fd1df39e83 100644 --- a/example/robot-simulator/camera/servoSimuCylinder2DCamVelocityDisplaySecondaryTask.cpp +++ b/example/robot-simulator/camera/servoSimuCylinder2DCamVelocityDisplaySecondaryTask.cpp @@ -3,7 +3,7 @@ * $Id: servoSimuCylinder2DCamVelocityDisplaySecondaryTask.cpp 2457 2010-01-07 10:41:18Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -80,6 +80,8 @@ // List of allowed command line options #define GETOPTARGS "cdh" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display); /*! @@ -130,9 +132,9 @@ Set the program options. */ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; @@ -140,7 +142,7 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) case 'h': usage(argv[0], NULL); return false; break; default: - usage(argv[0], optarg); + usage(argv[0], optarg_); return false; break; } } @@ -149,7 +151,7 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -160,286 +162,293 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) int main(int argc, const char ** argv) { - bool opt_display = true; - bool opt_click_allowed = true; + try { + bool opt_display = true; + bool opt_click_allowed = true; - // Read the command line options - if (getOptions(argc, argv, opt_click_allowed, opt_display) == false) { - exit (-1); - } + // Read the command line options + if (getOptions(argc, argv, opt_click_allowed, opt_display) == false) { + exit (-1); + } - vpImage<unsigned char> Iint(512,512,0) ; - vpImage<unsigned char> Iext(512,512,0) ; + vpImage<unsigned char> Iint(512,512,0) ; + vpImage<unsigned char> Iext(512,512,0) ; - // We open a window using either X11, GTK or GDI. + // We open a window using either X11, GTK or GDI. #if defined VISP_HAVE_X11 - vpDisplayX displayInt; - vpDisplayX displayExt; + vpDisplayX displayInt; + vpDisplayX displayExt; #elif defined VISP_HAVE_GTK - vpDisplayGTK displayInt; - vpDisplayGTK displayExt; + vpDisplayGTK displayInt; + vpDisplayGTK displayExt; #elif defined VISP_HAVE_GDI - vpDisplayGDI displayInt; - vpDisplayGDI displayExt; + vpDisplayGDI displayInt; + vpDisplayGDI displayExt; #endif - if (opt_display) { - try{ - // Display size is automatically defined by the image (Iint) and (Iext) size - displayInt.init(Iint, 100, 100,"Internal view") ; - displayExt.init(Iext, (int)(130+Iint.getWidth()), 100, "External view") ; - // 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(Iint) ; - vpDisplay::display(Iext) ; - vpDisplay::flush(Iint) ; - vpDisplay::flush(Iext) ; - } - catch(...) - { - vpERROR_TRACE("Error while displaying the image") ; - exit(-1); + if (opt_display) { + try{ + // Display size is automatically defined by the image (Iint) and (Iext) size + displayInt.init(Iint, 100, 100,"Internal view") ; + displayExt.init(Iext, (int)(130+Iint.getWidth()), 100, "External view") ; + // 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(Iint) ; + vpDisplay::display(Iext) ; + vpDisplay::flush(Iint) ; + vpDisplay::flush(Iext) ; + } + catch(...) + { + vpERROR_TRACE("Error while displaying the image") ; + exit(-1); + } } - } - - vpProjectionDisplay externalview ; - - //Set the camera parameters - double px, py ; px = py = 600 ; - double u0, v0 ; u0 = v0 = 256 ; - - vpCameraParameters cam(px,py,u0,v0); - - vpServo task ; - vpSimulatorCamera robot ; - - // sets the initial camera location - vpHomogeneousMatrix cMo(-0.2,0.1,2, - vpMath::rad(5), vpMath::rad(5), vpMath::rad(20)); - vpHomogeneousMatrix wMc, wMo; - robot.getPosition(wMc) ; - wMo = wMc * cMo; // Compute the position of the object in the world frame + vpProjectionDisplay externalview ; - // sets the final camera location (for simulation purpose) - vpHomogeneousMatrix cMod(0,0,1, - vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); + //Set the camera parameters + double px, py ; px = py = 600 ; + double u0, v0 ; u0 = v0 = 256 ; - // sets the cylinder coordinates in the world frame - vpCylinder cylinder(0,1,0, // direction - 0,0,0, // point of the axis - 0.1) ; // radius + vpCameraParameters cam(px,py,u0,v0); - externalview.insert(cylinder) ; + vpServo task ; + vpSimulatorCamera robot ; - // sets the desired position of the visual feature - cylinder.track(cMod) ; - cylinder.print() ; + // sets the initial camera location + vpHomogeneousMatrix cMo(-0.2,0.1,2, + vpMath::rad(5), vpMath::rad(5), vpMath::rad(20)); - //Build the desired line features thanks to the cylinder and especially its paramaters in the image frame - vpFeatureLine ld[2] ; - int i ; - for(i=0 ; i < 2 ; i++) - vpFeatureBuilder::create(ld[i],cylinder,i) ; - - // computes the cylinder coordinates in the camera frame and its 2D coordinates - // sets the current position of the visual feature - cylinder.track(cMo) ; - cylinder.print() ; - - //Build the current line features thanks to the cylinder and especially its paramaters in the image frame - vpFeatureLine l[2] ; - for(i=0 ; i < 2 ; i++) - { - vpFeatureBuilder::create(l[i],cylinder,i) ; - l[i].print() ; - } - - // define the task - // - we want an eye-in-hand control law - // - robot is controlled in the camera frame - task.setServo(vpServo::EYEINHAND_CAMERA) ; - task.setInteractionMatrixType(vpServo::DESIRED,vpServo::PSEUDO_INVERSE) ; - // it can also be interesting to test these possibilities - // task.setInteractionMatrixType(vpServo::CURRENT,vpServo::PSEUDO_INVERSE) ; - // task.setInteractionMatrixType(vpServo::MEAN, vpServo::PSEUDO_INVERSE) ; - // task.setInteractionMatrixType(vpServo::CURRENT, vpServo::PSEUDO_INVERSE) ; - // task.setInteractionMatrixType(vpServo::DESIRED, vpServo::TRANSPOSE) ; - // task.setInteractionMatrixType(vpServo::CURRENT, vpServo::TRANSPOSE) ; - - // we want to see 2 lines on 2 lines - task.addFeature(l[0],ld[0]) ; - task.addFeature(l[1],ld[1]) ; - - // Set the point of view of the external view - vpHomogeneousMatrix cextMo(0,0,6, - vpMath::rad(40), vpMath::rad(10), vpMath::rad(60)) ; - - // Display the initial scene - vpServoDisplay::display(task,cam,Iint) ; - externalview.display(Iext,cextMo, cMo, cam, vpColor::red); - vpDisplay::flush(Iint) ; - vpDisplay::flush(Iext) ; - - // Display task information - task.print() ; - - if (opt_display && opt_click_allowed) { - std::cout << "\n\nClick in the internal camera view window to start..." << std::endl; - vpDisplay::getClick(Iint) ; - } - - // set the gain - task.setLambda(1) ; - - // Display task information - task.print() ; - - unsigned int iter=0 ; - // The first loop is needed to reach the desired position - do - { - std::cout << "---------------------------------------------" << iter++ <<std::endl ; - vpColVector v ; - - // get the robot position + vpHomogeneousMatrix wMc, wMo; robot.getPosition(wMc) ; - // Compute the position of the camera wrt the object frame - cMo = wMc.inverse() * wMo; + wMo = wMc * cMo; // Compute the position of the object in the world frame - // new line position - // retrieve x,y and Z of the vpLine structure - // Compute the parameters of the cylinder in the camera frame and in the image frame - cylinder.track(cMo) ; + // sets the final camera location (for simulation purpose) + vpHomogeneousMatrix cMod(0,0,1, + vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); - //Build the current line features thanks to the cylinder and especially its paramaters in the image frame - for(i=0 ; i < 2 ; i++) - { - vpFeatureBuilder::create(l[i],cylinder,i) ; - } + // sets the cylinder coordinates in the world frame + vpCylinder cylinder(0,1,0, // direction + 0,0,0, // point of the axis + 0.1) ; // radius - // Display the current scene - if (opt_display) { - vpDisplay::display(Iint) ; - vpDisplay::display(Iext) ; - vpServoDisplay::display(task,cam,Iint) ; - externalview.display(Iext,cextMo, cMo, cam, vpColor::red); - vpDisplay::flush(Iint); - vpDisplay::flush(Iext); - } + externalview.insert(cylinder) ; - // compute the control law - v = task.computeControlLaw() ; + // sets the desired position of the visual feature + cylinder.track(cMod) ; + cylinder.print() ; - // send the camera velocity to the controller - robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; - - std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; - } - while(( task.getError() ).sumSquare() > 1e-9) ; - - - // Second loop is to compute the control law while taking into account the secondary task. - // In this example the secondary task is cut in four steps. - // The first one consists in impose a movement of the robot along the x axis of the object frame with a velocity of 0.5. - // The second one consists in impose a movement of the robot along the y axis of the object frame with a velocity of 0.5. - // The third one consists in impose a movement of the robot along the x axis of the object frame with a velocity of -0.5. - // The last one consists in impose a movement of the robot along the y axis of the object frame with a velocity of -0.5. - // Each steps is made during 200 iterations. - vpColVector e1(6) ; e1 = 0 ; - vpColVector e2(6) ; e2 = 0 ; - vpColVector proj_e1 ; - vpColVector proj_e2 ; - iter = 0; - double rapport = 0; - double vitesse = 0.5; - unsigned int tempo = 800; - - while(iter < tempo) - { - vpColVector v ; - - robot.getPosition(wMc) ; - // Compute the position of the camera wrt the object frame - cMo = wMc.inverse() * wMo; + //Build the desired line features thanks to the cylinder and especially its paramaters in the image frame + vpFeatureLine ld[2] ; + int i ; + for(i=0 ; i < 2 ; i++) + vpFeatureBuilder::create(ld[i],cylinder,i) ; + // computes the cylinder coordinates in the camera frame and its 2D coordinates + // sets the current position of the visual feature cylinder.track(cMo) ; + cylinder.print() ; + //Build the current line features thanks to the cylinder and especially its paramaters in the image frame + vpFeatureLine l[2] ; for(i=0 ; i < 2 ; i++) { vpFeatureBuilder::create(l[i],cylinder,i) ; + l[i].print() ; } - if (opt_display) - { - vpDisplay::display(Iint) ; - vpDisplay::display(Iext) ; - vpServoDisplay::display(task,cam,Iint) ; - externalview.display(Iext,cextMo, cMo, cam, vpColor::red); - vpDisplay::flush(Iint); - vpDisplay::flush(Iext); + // define the task + // - we want an eye-in-hand control law + // - robot is controlled in the camera frame + task.setServo(vpServo::EYEINHAND_CAMERA) ; + task.setInteractionMatrixType(vpServo::DESIRED,vpServo::PSEUDO_INVERSE) ; + // it can also be interesting to test these possibilities + // task.setInteractionMatrixType(vpServo::CURRENT,vpServo::PSEUDO_INVERSE) ; + // task.setInteractionMatrixType(vpServo::MEAN, vpServo::PSEUDO_INVERSE) ; + // task.setInteractionMatrixType(vpServo::CURRENT, vpServo::PSEUDO_INVERSE) ; + // task.setInteractionMatrixType(vpServo::DESIRED, vpServo::TRANSPOSE) ; + // task.setInteractionMatrixType(vpServo::CURRENT, vpServo::TRANSPOSE) ; + + // we want to see 2 lines on 2 lines + task.addFeature(l[0],ld[0]) ; + task.addFeature(l[1],ld[1]) ; + + // Set the point of view of the external view + vpHomogeneousMatrix cextMo(0,0,6, + vpMath::rad(40), vpMath::rad(10), vpMath::rad(60)) ; + + // Display the initial scene + vpServoDisplay::display(task,cam,Iint) ; + externalview.display(Iext,cextMo, cMo, cam, vpColor::red); + vpDisplay::flush(Iint) ; + vpDisplay::flush(Iext) ; + + // Display task information + task.print() ; + + if (opt_display && opt_click_allowed) { + std::cout << "\n\nClick in the internal camera view window to start..." << std::endl; + vpDisplay::getClick(Iint) ; } - v = task.computeControlLaw() ; + // set the gain + task.setLambda(1) ; - if ( iter%tempo < 200 /*&& iter%tempo >= 0*/) - { - e2 = 0; - e1[0] = fabs(vitesse) ; - proj_e1 = task.secondaryTask(e1); - rapport = vitesse/proj_e1[0]; - proj_e1 *= rapport ; - v += proj_e1 ; - } + // Display task information + task.print() ; - if ( iter%tempo < 400 && iter%tempo >= 200) + unsigned int iter=0 ; + // The first loop is needed to reach the desired position + do { - e1 = 0; - e2[1] = fabs(vitesse) ; - proj_e2 = task.secondaryTask(e2); - rapport = vitesse/proj_e2[1]; - proj_e2 *= rapport ; - v += proj_e2 ; + std::cout << "---------------------------------------------" << iter++ <<std::endl ; + vpColVector v ; + + // get the robot position + robot.getPosition(wMc) ; + // Compute the position of the camera wrt the object frame + cMo = wMc.inverse() * wMo; + + // new line position + // retrieve x,y and Z of the vpLine structure + // Compute the parameters of the cylinder in the camera frame and in the image frame + cylinder.track(cMo) ; + + //Build the current line features thanks to the cylinder and especially its paramaters in the image frame + for(i=0 ; i < 2 ; i++) + { + vpFeatureBuilder::create(l[i],cylinder,i) ; + } + + // Display the current scene + if (opt_display) { + vpDisplay::display(Iint) ; + vpDisplay::display(Iext) ; + vpServoDisplay::display(task,cam,Iint) ; + externalview.display(Iext,cextMo, cMo, cam, vpColor::red); + vpDisplay::flush(Iint); + vpDisplay::flush(Iext); + } + + // compute the control law + v = task.computeControlLaw() ; + + // send the camera velocity to the controller + robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + + std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; } - - if ( iter%tempo < 600 && iter%tempo >= 400) + while(( task.getError() ).sumSquare() > 1e-9) ; + + + // Second loop is to compute the control law while taking into account the secondary task. + // In this example the secondary task is cut in four steps. + // The first one consists in impose a movement of the robot along the x axis of the object frame with a velocity of 0.5. + // The second one consists in impose a movement of the robot along the y axis of the object frame with a velocity of 0.5. + // The third one consists in impose a movement of the robot along the x axis of the object frame with a velocity of -0.5. + // The last one consists in impose a movement of the robot along the y axis of the object frame with a velocity of -0.5. + // Each steps is made during 200 iterations. + vpColVector e1(6) ; e1 = 0 ; + vpColVector e2(6) ; e2 = 0 ; + vpColVector proj_e1 ; + vpColVector proj_e2 ; + iter = 0; + double rapport = 0; + double vitesse = 0.5; + unsigned int tempo = 800; + + while(iter < tempo) { - e2 = 0; - e1[0] = -fabs(vitesse) ; - proj_e1 = task.secondaryTask(e1); - rapport = -vitesse/proj_e1[0]; - proj_e1 *= rapport ; - v += proj_e1 ; + vpColVector v ; + + robot.getPosition(wMc) ; + // Compute the position of the camera wrt the object frame + cMo = wMc.inverse() * wMo; + + cylinder.track(cMo) ; + + for(i=0 ; i < 2 ; i++) + { + vpFeatureBuilder::create(l[i],cylinder,i) ; + } + + if (opt_display) + { + vpDisplay::display(Iint) ; + vpDisplay::display(Iext) ; + vpServoDisplay::display(task,cam,Iint) ; + externalview.display(Iext,cextMo, cMo, cam, vpColor::red); + vpDisplay::flush(Iint); + vpDisplay::flush(Iext); + } + + v = task.computeControlLaw() ; + + if ( iter%tempo < 200 /*&& iter%tempo >= 0*/) + { + e2 = 0; + e1[0] = fabs(vitesse) ; + proj_e1 = task.secondaryTask(e1); + rapport = vitesse/proj_e1[0]; + proj_e1 *= rapport ; + v += proj_e1 ; + } + + if ( iter%tempo < 400 && iter%tempo >= 200) + { + e1 = 0; + e2[1] = fabs(vitesse) ; + proj_e2 = task.secondaryTask(e2); + rapport = vitesse/proj_e2[1]; + proj_e2 *= rapport ; + v += proj_e2 ; + } + + if ( iter%tempo < 600 && iter%tempo >= 400) + { + e2 = 0; + e1[0] = -fabs(vitesse) ; + proj_e1 = task.secondaryTask(e1); + rapport = -vitesse/proj_e1[0]; + proj_e1 *= rapport ; + v += proj_e1 ; + } + + if ( iter%tempo < 800 && iter%tempo >= 600) + { + e1 = 0; + e2[1] = -fabs(vitesse) ; + proj_e2 = task.secondaryTask(e2); + rapport = -vitesse/proj_e2[1]; + proj_e2 *= rapport ; + v += proj_e2 ; + } + + robot.setVelocity(vpRobot::CAMERA_FRAME, v); + + std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; + + iter++; } - if ( iter%tempo < 800 && iter%tempo >= 600) - { - e1 = 0; - e2[1] = -fabs(vitesse) ; - proj_e2 = task.secondaryTask(e2); - rapport = -vitesse/proj_e2[1]; - proj_e2 *= rapport ; - v += proj_e2 ; + if (opt_display && opt_click_allowed) { + std::cout << "\nClick in the internal camera view window to end..." << std::endl; + vpDisplay::getClick(Iint) ; } - robot.setVelocity(vpRobot::CAMERA_FRAME, v); - - std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; - - iter++; + // Display task information + task.print() ; + task.kill(); + return 0; } - - if (opt_display && opt_click_allowed) { - std::cout << "\nClick in the internal camera view window to end..." << std::endl; - vpDisplay::getClick(Iint) ; + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; } - - // Display task information - task.print() ; - task.kill(); } #else diff --git a/example/robot-simulator/camera/servoSimuFourPoints2DCamVelocity.cpp b/example/robot-simulator/camera/servoSimuFourPoints2DCamVelocity.cpp index ae20ae2e83064721e5907578948f66f979db0b10..7d750d955c3d71be4984e85d645a2c6175058273 100644 --- a/example/robot-simulator/camera/servoSimuFourPoints2DCamVelocity.cpp +++ b/example/robot-simulator/camera/servoSimuFourPoints2DCamVelocity.cpp @@ -3,7 +3,7 @@ * $Id: servoSimuFourPoints2DCamVelocity.cpp 2503 2010-02-16 18:55:01Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -69,6 +69,9 @@ // List of allowed command line options #define GETOPTARGS "h" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); + /*! Print the program options. @@ -113,15 +116,15 @@ Set the program options. */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -130,7 +133,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -140,127 +143,134 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } - int i ; - vpServo task ; - vpSimulatorCamera robot ; - - - std::cout << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << " Test program for vpServo " <<std::endl ; - std::cout << " Eye-in-hand task control, articular velocity are computed" << std::endl ; - std::cout << " Simulation " << std::endl ; - std::cout << " task : servo 4 points " << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << std::endl ; - - // sets the initial camera location with respect to the object - vpHomogeneousMatrix cMo ; - cMo[0][3] = 0.1 ; - cMo[1][3] = 0.2 ; - cMo[2][3] = 2 ; - - // Compute the position of the object in the world frame - vpHomogeneousMatrix wMc, wMo; - robot.getPosition(wMc) ; - wMo = wMc * cMo; - - // sets the point coordinates in the object frame - vpPoint point[4] ; - point[0].setWorldCoordinates(-1,-1,0) ; - point[1].setWorldCoordinates(1,-1,0) ; - point[2].setWorldCoordinates(1,1,0) ; - point[3].setWorldCoordinates(-1,1,0) ; - - // computes the point coordinates in the camera frame and its 2D coordinates - for (i = 0 ; i < 4 ; i++) - point[i].track(cMo) ; - - // 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 - - // 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) ; - - // define the task - // - we want an eye-in-hand control law - // - articular velocity are computed - task.setServo(vpServo::EYEINHAND_L_cVe_eJe) ; - task.setInteractionMatrixType(vpServo::MEAN) ; - - // Set the position of the camera in the end-effector frame - vpHomogeneousMatrix cMe ; - vpVelocityTwistMatrix cVe(cMe) ; - task.set_cVe(cVe) ; - - // Set the Jacobian (expressed in the end-effector frame) - vpMatrix eJe ; - robot.get_eJe(eJe) ; - task.set_eJe(eJe) ; - - // we want to see a point on a point - for (i = 0 ; i < 4 ; i++) - task.addFeature(p[i],pd[i]) ; - - // set the gain - task.setLambda(1) ; - - // Display task information - task.print() ; - - unsigned int iter=0 ; - // loop - while(iter++<1500) - { - std::cout << "---------------------------------------------" << iter <<std::endl ; - vpColVector v ; + int i ; + vpServo task ; + vpSimulatorCamera robot ; - // Set the Jacobian (expressed in the end-effector frame) - // since q is modified eJe is modified - robot.get_eJe(eJe) ; - task.set_eJe(eJe) ; - // get the robot position + std::cout << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << " Test program for vpServo " <<std::endl ; + std::cout << " Eye-in-hand task control, articular velocity are computed" << std::endl ; + std::cout << " Simulation " << std::endl ; + std::cout << " task : servo 4 points " << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << std::endl ; + + // sets the initial camera location with respect to the object + vpHomogeneousMatrix cMo ; + cMo[0][3] = 0.1 ; + cMo[1][3] = 0.2 ; + cMo[2][3] = 2 ; + + // Compute the position of the object in the world frame + vpHomogeneousMatrix wMc, wMo; robot.getPosition(wMc) ; - // Compute the position of the camera wrt the object frame - cMo = wMc.inverse() * wMo; + wMo = wMc * cMo; + + // sets the point coordinates in the object frame + vpPoint point[4] ; + point[0].setWorldCoordinates(-1,-1,0) ; + point[1].setWorldCoordinates(1,-1,0) ; + point[2].setWorldCoordinates(1,1,0) ; + point[3].setWorldCoordinates(-1,1,0) ; - // update new point position and corresponding features + // computes the point coordinates in the camera frame and its 2D coordinates for (i = 0 ; i < 4 ; i++) - { point[i].track(cMo) ; - //retrieve x,y and Z of the vpPoint structure - vpFeatureBuilder::create(p[i],point[i]) ; - } - // since vpServo::MEAN interaction matrix is used, we need also to update the desired features at each iteration + + // 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 + + // 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) ; - // compute the control law ") ; - v = task.computeControlLaw() ; + // define the task + // - we want an eye-in-hand control law + // - articular velocity are computed + task.setServo(vpServo::EYEINHAND_L_cVe_eJe) ; + task.setInteractionMatrixType(vpServo::MEAN) ; - // send the camera velocity to the controller ") ; - robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + // Set the position of the camera in the end-effector frame + vpHomogeneousMatrix cMe ; + vpVelocityTwistMatrix cVe(cMe) ; + task.set_cVe(cVe) ; - std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() << std::endl; - } + // Set the Jacobian (expressed in the end-effector frame) + vpMatrix eJe ; + robot.get_eJe(eJe) ; + task.set_eJe(eJe) ; + + // we want to see a point on a point + for (i = 0 ; i < 4 ; i++) + task.addFeature(p[i],pd[i]) ; - // Display task information - task.print() ; - task.kill(); + // set the gain + task.setLambda(1) ; + + // Display task information + task.print() ; + + unsigned int iter=0 ; + // loop + while(iter++<1500) + { + std::cout << "---------------------------------------------" << iter <<std::endl ; + vpColVector v ; + + // Set the Jacobian (expressed in the end-effector frame) + // since q is modified eJe is modified + robot.get_eJe(eJe) ; + task.set_eJe(eJe) ; + + // get the robot position + robot.getPosition(wMc) ; + // Compute the position of the camera wrt the object frame + cMo = wMc.inverse() * wMo; + + // update new point position and corresponding features + for (i = 0 ; i < 4 ; i++) + { + point[i].track(cMo) ; + //retrieve x,y and Z of the vpPoint structure + vpFeatureBuilder::create(p[i],point[i]) ; + } + // since vpServo::MEAN interaction matrix is used, we need also to update the desired features at each iteration + 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) ; + + // compute the control law ") ; + v = task.computeControlLaw() ; + + // send the camera velocity to the controller ") ; + robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + + std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() << std::endl; + } + + // Display task information + task.print() ; + task.kill(); + return 0; + } + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; + } } diff --git a/example/robot-simulator/camera/servoSimuFourPoints2DCamVelocityDisplay.cpp b/example/robot-simulator/camera/servoSimuFourPoints2DCamVelocityDisplay.cpp index 1c63a68f3f3be7fb181a9ba467599271981ec30b..fd2272a00291fd825085cdffd7865b26a7e91caf 100644 --- a/example/robot-simulator/camera/servoSimuFourPoints2DCamVelocityDisplay.cpp +++ b/example/robot-simulator/camera/servoSimuFourPoints2DCamVelocityDisplay.cpp @@ -3,7 +3,7 @@ * $Id: servoSimuFourPoints2DCamVelocityDisplay.cpp 2503 2010-02-16 18:55:01Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -81,6 +81,9 @@ // List of allowed command line options #define GETOPTARGS "cdh" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display); + /*! Print the program options. @@ -130,9 +133,9 @@ Set the program options. */ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; @@ -140,7 +143,7 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) case 'h': usage(argv[0], NULL); return false; break; default: - usage(argv[0], optarg); + usage(argv[0], optarg_); return false; break; } } @@ -149,7 +152,7 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -159,183 +162,189 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) int main(int argc, const char ** argv) { + try { + bool opt_click_allowed = true; + bool opt_display = true; - 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); - } + // Read the command line options + if (getOptions(argc, argv, opt_click_allowed, opt_display) == false) { + exit (-1); + } - // We open two displays, one for the internal camera view, the other one for - // the external view, using either X11, GTK or GDI. + // We open two displays, one for the internal camera view, the other one for + // the external view, using either X11, GTK or GDI. #if defined VISP_HAVE_X11 - vpDisplayX displayInt; - vpDisplayX displayExt; + vpDisplayX displayInt; + vpDisplayX displayExt; #elif defined VISP_HAVE_GTK - vpDisplayGTK displayInt; - vpDisplayGTK displayExt; + vpDisplayGTK displayInt; + vpDisplayGTK displayExt; #elif defined VISP_HAVE_GDI - vpDisplayGDI displayInt; - vpDisplayGDI displayExt; + vpDisplayGDI displayInt; + vpDisplayGDI displayExt; #endif - // open a display for the visualization + // open a display for the visualization - vpImage<unsigned char> Iint(300, 300, 0) ; - vpImage<unsigned char> Iext(300, 300, 0) ; + vpImage<unsigned char> Iint(300, 300, 0) ; + vpImage<unsigned char> Iext(300, 300, 0) ; - if (opt_display) { - displayInt.init(Iint,0,0, "Internal view") ; - displayExt.init(Iext,330,000, "External view") ; + if (opt_display) { + displayInt.init(Iint,0,0, "Internal view") ; + displayExt.init(Iext,330,000, "External view") ; - } - vpProjectionDisplay externalview ; - - double px, py ; px = py = 500 ; - double u0, v0 ; u0 = 150, v0 = 160 ; - - vpCameraParameters cam(px,py,u0,v0); - - int i ; - vpServo task ; - vpSimulatorCamera robot ; - - std::cout << std::endl ; - std::cout << "----------------------------------------------" << std::endl ; - std::cout << " Test program for vpServo " <<std::endl ; - std::cout << " Eye-in-hand task control, articular velocity are computed" - << std::endl ; - std::cout << " Simulation " << std::endl ; - std::cout << " task : servo 4 points " << std::endl ; - std::cout << "----------------------------------------------" << std::endl ; - std::cout << std::endl ; - - // sets the initial camera location - vpHomogeneousMatrix cMo(-0.1,-0.1,1, - vpMath::rad(40), vpMath::rad(10), vpMath::rad(60)) ; - - // Compute the position of the object in the world frame - vpHomogeneousMatrix wMc, wMo; - robot.getPosition(wMc) ; - wMo = wMc * cMo; - - vpHomogeneousMatrix cextMo(0,0,2, - 0,0,0) ;//vpMath::rad(40), vpMath::rad(10), vpMath::rad(60)) ; - - // sets the point coordinates in the object 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) ; - - for (i = 0 ; i < 4 ; i++) - externalview.insert(point[i]) ; - - // computes the point coordinates in the camera frame and its 2D coordinates - for (i = 0 ; i < 4 ; i++) - point[i].track(cMo) ; - - // 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 - - // sets the desired position of the feature point s* - 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) ; - - // define the task - // - we want an eye-in-hand control law - // - articular velocity are computed - task.setServo(vpServo::EYEINHAND_L_cVe_eJe) ; - task.setInteractionMatrixType(vpServo::MEAN) ; - - // Set the position of the camera in the end-effector frame ") ; - vpHomogeneousMatrix cMe ; - vpVelocityTwistMatrix cVe(cMe) ; - task.set_cVe(cVe) ; - - // Set the Jacobian (expressed in the end-effector frame) - vpMatrix eJe ; - robot.get_eJe(eJe) ; - task.set_eJe(eJe) ; - - // we want to see a point on a point - for (i = 0 ; i < 4 ; i++) - task.addFeature(p[i],pd[i]) ; - - // set the gain - task.setLambda(1) ; - - // Display task information " ) ; - task.print() ; - - unsigned int iter=0 ; - // loop - while(iter++<200) - { - std::cout << "---------------------------------------------" << iter <<std::endl ; - vpColVector v ; + } + vpProjectionDisplay externalview ; - // Set the Jacobian (expressed in the end-effector frame) - // since q is modified eJe is modified - robot.get_eJe(eJe) ; - task.set_eJe(eJe) ; + double px, py ; px = py = 500 ; + double u0, v0 ; u0 = 150, v0 = 160 ; - // get the robot position + vpCameraParameters cam(px,py,u0,v0); + + int i ; + vpServo task ; + vpSimulatorCamera robot ; + + std::cout << std::endl ; + std::cout << "----------------------------------------------" << std::endl ; + std::cout << " Test program for vpServo " <<std::endl ; + std::cout << " Eye-in-hand task control, articular velocity are computed" + << std::endl ; + std::cout << " Simulation " << std::endl ; + std::cout << " task : servo 4 points " << std::endl ; + std::cout << "----------------------------------------------" << std::endl ; + std::cout << std::endl ; + + // sets the initial camera location + vpHomogeneousMatrix cMo(-0.1,-0.1,1, + vpMath::rad(40), vpMath::rad(10), vpMath::rad(60)) ; + + // Compute the position of the object in the world frame + vpHomogeneousMatrix wMc, wMo; robot.getPosition(wMc) ; - // Compute the position of the camera wrt the object frame - cMo = wMc.inverse() * wMo; + wMo = wMc * cMo; + + vpHomogeneousMatrix cextMo(0,0,2, + 0,0,0) ;//vpMath::rad(40), vpMath::rad(10), vpMath::rad(60)) ; + + // sets the point coordinates in the object 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) ; - // update new point position and corresponding features for (i = 0 ; i < 4 ; i++) - { + externalview.insert(point[i]) ; + + // computes the point coordinates in the camera frame and its 2D coordinates + for (i = 0 ; i < 4 ; i++) point[i].track(cMo) ; - //retrieve x,y and Z of the vpPoint structure - vpFeatureBuilder::create(p[i],point[i]) ; - } - // since vpServo::MEAN interaction matrix is used, we need also to update the desired features at each iteration + + // 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 + + // sets the desired position of the feature point s* + 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) ; - if (opt_display) { - vpDisplay::display(Iint) ; - vpDisplay::display(Iext) ; - vpServoDisplay::display(task,cam,Iint) ; - externalview.display(Iext,cextMo, cMo, cam, vpColor::green) ; - vpDisplay::flush(Iint); - vpDisplay::flush(Iext); - } + // define the task + // - we want an eye-in-hand control law + // - articular velocity are computed + task.setServo(vpServo::EYEINHAND_L_cVe_eJe) ; + task.setInteractionMatrixType(vpServo::MEAN) ; - // compute the control law - v = task.computeControlLaw() ; + // Set the position of the camera in the end-effector frame ") ; + vpHomogeneousMatrix cMe ; + vpVelocityTwistMatrix cVe(cMe) ; + task.set_cVe(cVe) ; - // send the camera velocity to the controller - robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + // Set the Jacobian (expressed in the end-effector frame) + vpMatrix eJe ; + robot.get_eJe(eJe) ; + task.set_eJe(eJe) ; - std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; - } + // we want to see a point on a point + for (i = 0 ; i < 4 ; i++) + task.addFeature(p[i],pd[i]) ; + + // set the gain + task.setLambda(1) ; - // Display task information - task.print() ; - task.kill(); + // Display task information " ) ; + task.print() ; - std::cout <<"Final robot position with respect to the object frame:\n"; - cMo.print(); + unsigned int iter=0 ; + // loop + while(iter++<200) + { + std::cout << "---------------------------------------------" << iter <<std::endl ; + vpColVector v ; + + // Set the Jacobian (expressed in the end-effector frame) + // since q is modified eJe is modified + robot.get_eJe(eJe) ; + task.set_eJe(eJe) ; + + // get the robot position + robot.getPosition(wMc) ; + // Compute the position of the camera wrt the object frame + cMo = wMc.inverse() * wMo; + + // update new point position and corresponding features + for (i = 0 ; i < 4 ; i++) + { + point[i].track(cMo) ; + //retrieve x,y and Z of the vpPoint structure + vpFeatureBuilder::create(p[i],point[i]) ; + } + // since vpServo::MEAN interaction matrix is used, we need also to update the desired features at each iteration + 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) ; + + if (opt_display) { + vpDisplay::display(Iint) ; + vpDisplay::display(Iext) ; + vpServoDisplay::display(task,cam,Iint) ; + externalview.display(Iext,cextMo, cMo, cam, vpColor::green) ; + vpDisplay::flush(Iint); + vpDisplay::flush(Iext); + } + + // compute the control law + v = task.computeControlLaw() ; + + // send the camera velocity to the controller + robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + + std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; + } - if (opt_display && opt_click_allowed) { - // suppressed for automate test - std::cout << "\n\nClick in the internal view window to end..." << std::endl; - vpDisplay::getClick(Iint) ; + // Display task information + task.print() ; + task.kill(); + + std::cout <<"Final robot position with respect to the object frame:\n"; + cMo.print(); + + if (opt_display && opt_click_allowed) { + // suppressed for automate test + std::cout << "\n\nClick in the internal view window to end..." << std::endl; + vpDisplay::getClick(Iint) ; + } + return 0; + } + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; } } #else diff --git a/example/robot-simulator/camera/servoSimuFourPoints2DPolarCamVelocityDisplay.cpp b/example/robot-simulator/camera/servoSimuFourPoints2DPolarCamVelocityDisplay.cpp index a9858be89f98df9c623170db3bfaba9711526661..5ab53ca93d968018916a95b9127bda2eadf1cdf2 100644 --- a/example/robot-simulator/camera/servoSimuFourPoints2DPolarCamVelocityDisplay.cpp +++ b/example/robot-simulator/camera/servoSimuFourPoints2DPolarCamVelocityDisplay.cpp @@ -3,7 +3,7 @@ * $Id: servoSimuFourPoints2DPolarCamVelocityDisplay.cpp 2503 2010-02-16 18:55:01Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -86,6 +86,9 @@ // List of allowed command line options #define GETOPTARGS "cdh" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display); + /*! Print the program options. @@ -135,9 +138,9 @@ Set the program options. */ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; @@ -145,7 +148,7 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) case 'h': usage(argv[0], NULL); return false; break; default: - usage(argv[0], optarg); + usage(argv[0], optarg_); return false; break; } } @@ -154,7 +157,7 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -164,334 +167,340 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) int main(int argc, const char ** argv) { - - // Log file creation in /tmp/$USERNAME/log.dat - // This file contains by line: - // - the 6 computed camera velocities (m/s, rad/s) to achieve the task - // - the 6 mesured camera velocities (m/s, rad/s) - // - the 6 mesured joint positions (m, rad) - // - the 8 values of s - s* - std::string username; - // Get the user login name - vpIoTools::getUserName(username); - - // Create a log filename to save velocities... - std::string logdirname; -#ifdef WIN32 - logdirname ="C:/temp/" + username; + try { + // Log file creation in /tmp/$USERNAME/log.dat + // This file contains by line: + // - the 6 computed camera velocities (m/s, rad/s) to achieve the task + // - the 6 mesured camera velocities (m/s, rad/s) + // - the 6 mesured joint positions (m, rad) + // - the 8 values of s - s* + std::string username; + // Get the user login name + vpIoTools::getUserName(username); + + // Create a log filename to save velocities... + std::string logdirname; +#if defined(_WIN32) + logdirname ="C:/temp/" + username; #else - logdirname ="/tmp/" + username; + logdirname ="/tmp/" + username; #endif - // Test if the output path exist. If no try to create it - if (vpIoTools::checkDirectory(logdirname) == false) { - try { - // Create the dirname - vpIoTools::makeDirectory(logdirname); - } - catch (...) { - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Cannot create " << logdirname << std::endl; - exit(-1); + // Test if the output path exist. If no try to create it + if (vpIoTools::checkDirectory(logdirname) == false) { + try { + // Create the dirname + vpIoTools::makeDirectory(logdirname); + } + catch (...) { + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Cannot create " << logdirname << std::endl; + exit(-1); + } } - } - std::string logfilename; - logfilename = logdirname + "/log.dat"; + std::string logfilename; + logfilename = logdirname + "/log.dat"; - // Open the log file name - std::ofstream flog(logfilename.c_str()); + // Open the log file name + std::ofstream flog(logfilename.c_str()); - bool opt_click_allowed = true; - bool opt_display = true; + 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); - } + // Read the command line options + if (getOptions(argc, argv, opt_click_allowed, opt_display) == false) { + exit (-1); + } - // We open two displays, one for the internal camera view, the other one for - // the external view, using either X11, GTK or GDI. + // We open two displays, one for the internal camera view, the other one for + // the external view, using either X11, GTK or GDI. #if defined VISP_HAVE_X11 - vpDisplayX displayInt; - vpDisplayX displayExt; + vpDisplayX displayInt; + vpDisplayX displayExt; #elif defined VISP_HAVE_GTK - vpDisplayGTK displayInt; - vpDisplayGTK displayExt; + vpDisplayGTK displayInt; + vpDisplayGTK displayExt; #elif defined VISP_HAVE_GDI - vpDisplayGDI displayInt; - vpDisplayGDI displayExt; + vpDisplayGDI displayInt; + vpDisplayGDI displayExt; #endif - // open a display for the visualization + // open a display for the visualization - vpImage<unsigned char> Iint(300, 300, 0) ; - vpImage<unsigned char> Iext(300, 300, 0) ; + vpImage<unsigned char> Iint(300, 300, 0) ; + vpImage<unsigned char> Iext(300, 300, 0) ; - if (opt_display) { - displayInt.init(Iint,0,0, "Internal view") ; - displayExt.init(Iext,330,000, "External view") ; + if (opt_display) { + displayInt.init(Iint,0,0, "Internal view") ; + displayExt.init(Iext,330,000, "External view") ; - } - vpProjectionDisplay externalview ; + } + vpProjectionDisplay externalview ; - double px, py ; px = py = 500 ; - double u0, v0 ; u0 = 150, v0 = 160 ; + double px, py ; px = py = 500 ; + double u0, v0 ; u0 = 150, v0 = 160 ; - vpCameraParameters cam(px,py,u0,v0); + vpCameraParameters cam(px,py,u0,v0); - int i ; - vpServo task ; - vpSimulatorCamera robot ; + int i ; + vpServo task ; + vpSimulatorCamera robot ; - std::cout << std::endl ; - std::cout << "----------------------------------------------" << std::endl ; - std::cout << " Test program for vpServo " <<std::endl ; - std::cout << " Eye-in-hand task control, articular velocity are computed" - << std::endl ; - std::cout << " Simulation " << std::endl ; - std::cout << " task : servo 4 points " << std::endl ; - std::cout << "----------------------------------------------" << std::endl ; - std::cout << std::endl ; + std::cout << std::endl ; + std::cout << "----------------------------------------------" << std::endl ; + std::cout << " Test program for vpServo " <<std::endl ; + std::cout << " Eye-in-hand task control, articular velocity are computed" + << std::endl ; + std::cout << " Simulation " << std::endl ; + std::cout << " task : servo 4 points " << std::endl ; + std::cout << "----------------------------------------------" << std::endl ; + std::cout << std::endl ; - // #define TRANS_Z_PURE - // #define TRANS_X_PURE - // #define ROT_Z_PURE - // #define ROT_X_PURE + // #define TRANS_Z_PURE + // #define TRANS_X_PURE + // #define ROT_Z_PURE + // #define ROT_X_PURE #define COMPLEX - //#define PROBLEM + //#define PROBLEM #if defined(TRANS_Z_PURE) - // sets the initial camera location - vpHomogeneousMatrix cMo(0, 0, 3, - vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); - // sets the desired camera location - vpHomogeneousMatrix cMod(0, 0, 2, - vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); + // sets the initial camera location + vpHomogeneousMatrix cMo(0, 0, 3, + vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); + // sets the desired camera location + vpHomogeneousMatrix cMod(0, 0, 2, + vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); #elif defined(TRANS_X_PURE) - // sets the initial camera location - vpHomogeneousMatrix cMo(0.3, 0.3, 3, - vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); - // sets the desired camera location - vpHomogeneousMatrix cMod(0.5, 0.3, 3, - vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); + // sets the initial camera location + vpHomogeneousMatrix cMo(0.3, 0.3, 3, + vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); + // sets the desired camera location + vpHomogeneousMatrix cMod(0.5, 0.3, 3, + vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); #elif defined(ROT_Z_PURE) - // sets the initial camera location - vpHomogeneousMatrix cMo(0, 0, 3, - vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); - // sets the desired camera location - vpHomogeneousMatrix cMod(0, 0, 3, - vpMath::rad(0), vpMath::rad(0), vpMath::rad(180)); + // sets the initial camera location + vpHomogeneousMatrix cMo(0, 0, 3, + vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); + // sets the desired camera location + vpHomogeneousMatrix cMod(0, 0, 3, + vpMath::rad(0), vpMath::rad(0), vpMath::rad(180)); #elif defined(ROT_X_PURE) - // sets the initial camera location - vpHomogeneousMatrix cMo(0, 0, 3, - vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); - // sets the desired camera location - vpHomogeneousMatrix cMod(0, 0, 3, - vpMath::rad(45), vpMath::rad(0), vpMath::rad(0)); + // sets the initial camera location + vpHomogeneousMatrix cMo(0, 0, 3, + vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); + // sets the desired camera location + vpHomogeneousMatrix cMod(0, 0, 3, + vpMath::rad(45), vpMath::rad(0), vpMath::rad(0)); #elif defined(COMPLEX) - // sets the initial camera location - vpHomogeneousMatrix cMo(0.2, 0.2, 3, - vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); - // sets the desired camera location - vpHomogeneousMatrix cMod(0, 0, 2.5, - vpMath::rad(45), vpMath::rad(10), vpMath::rad(30)); + // sets the initial camera location + vpHomogeneousMatrix cMo(0.2, 0.2, 3, + vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); + // sets the desired camera location + vpHomogeneousMatrix cMod(0, 0, 2.5, + vpMath::rad(45), vpMath::rad(10), vpMath::rad(30)); #elif defined(PROBLEM) - // Bad behavior with an interaction matrix computed from the desired features - // sets the initial camera location - vpHomogeneousMatrix cMo(0.2, 0.2, 3, - vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); - // sets the desired camera location - vpHomogeneousMatrix cMod(0.4, 0.2, 3, - vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); + // Bad behavior with an interaction matrix computed from the desired features + // sets the initial camera location + vpHomogeneousMatrix cMo(0.2, 0.2, 3, + vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); + // sets the desired camera location + vpHomogeneousMatrix cMod(0.4, 0.2, 3, + vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); #endif - // Compute the position of the object in the world frame - vpHomogeneousMatrix wMc, wMo; - robot.getPosition(wMc) ; - wMo = wMc * cMo; - - vpHomogeneousMatrix cextMo(0,0,6, - vpMath::rad(40), vpMath::rad(10), vpMath::rad(60)) ; - - - // sets the point coordinates in the object frame - vpPoint point[4] ; - point[0].setWorldCoordinates(-0.25,-0.25,0) ; - point[1].setWorldCoordinates(0.25,-0.25,0) ; - point[2].setWorldCoordinates(0.25,0.25,0) ; - point[3].setWorldCoordinates(-0.25,0.25,0) ; - - - for (i = 0 ; i < 4 ; i++) - externalview.insert(point[i]) ; - - // sets the desired position of the feature point s*" - vpFeaturePointPolar pd[4] ; + // Compute the position of the object in the world frame + vpHomogeneousMatrix wMc, wMo; + robot.getPosition(wMc) ; + wMo = wMc * cMo; - // computes the point coordinates in the desired camera frame and - // its 2D coordinates - for (i = 0 ; i < 4 ; i++) { - point[i].track(cMod); - // Computes the polar coordinates from the image point - // cartesian coordinates - vpFeatureBuilder::create(pd[i],point[i]); - } + vpHomogeneousMatrix cextMo(0,0,6, + vpMath::rad(40), vpMath::rad(10), vpMath::rad(60)) ; - // computes the point coordinates in the camera frame and its 2D - // coordinates - for (i = 0 ; i < 4 ; i++) - point[i].track(cMo) ; + // sets the point coordinates in the object frame + vpPoint point[4] ; + point[0].setWorldCoordinates(-0.25,-0.25,0) ; + point[1].setWorldCoordinates(0.25,-0.25,0) ; + point[2].setWorldCoordinates(0.25,0.25,0) ; + point[3].setWorldCoordinates(-0.25,0.25,0) ; - // sets the desired position of the point - vpFeaturePointPolar p[4] ; - for (i = 0 ; i < 4 ; i++) { - // retrieve x,y and Z of the vpPoint structure to initialize the - // visual feature - vpFeatureBuilder::create(p[i], point[i]); - } - // Define the task; - // - we want an eye-in-hand control law - // - articular velocity are computed - task.setServo(vpServo::EYEINHAND_L_cVe_eJe) ; - // task.setInteractionMatrixType(vpServo::MEAN) ; - // task.setInteractionMatrixType(vpServo::DESIRED) ; - task.setInteractionMatrixType(vpServo::CURRENT) ; + for (i = 0 ; i < 4 ; i++) + externalview.insert(point[i]) ; + // sets the desired position of the feature point s*" + vpFeaturePointPolar pd[4] ; - // Set the position of the camera in the end-effector frame - vpHomogeneousMatrix cMe ; - vpVelocityTwistMatrix cVe(cMe) ; - task.set_cVe(cVe) ; - - // Set the Jacobian (expressed in the end-effector frame) - vpMatrix eJe ; - robot.get_eJe(eJe) ; - task.set_eJe(eJe) ; + // computes the point coordinates in the desired camera frame and + // its 2D coordinates + for (i = 0 ; i < 4 ; i++) { + point[i].track(cMod); + // Computes the polar coordinates from the image point + // cartesian coordinates + vpFeatureBuilder::create(pd[i],point[i]); + } - // we want to see a point on a point - for (i = 0 ; i < 4 ; i++) - task.addFeature(p[i],pd[i]) ; - // set the gain - task.setLambda(1) ; + // computes the point coordinates in the camera frame and its 2D + // coordinates + for (i = 0 ; i < 4 ; i++) + point[i].track(cMo) ; + // sets the desired position of the point + vpFeaturePointPolar p[4] ; + for (i = 0 ; i < 4 ; i++) { + // retrieve x,y and Z of the vpPoint structure to initialize the + // visual feature + vpFeatureBuilder::create(p[i], point[i]); + } - std::cout << "\nDisplay task information: " << std::endl; - task.print() ; + // Define the task; + // - we want an eye-in-hand control law + // - articular velocity are computed + task.setServo(vpServo::EYEINHAND_L_cVe_eJe) ; + // task.setInteractionMatrixType(vpServo::MEAN) ; + // task.setInteractionMatrixType(vpServo::DESIRED) ; + task.setInteractionMatrixType(vpServo::CURRENT) ; - unsigned int iter=0 ; - // loop - while(iter++ < 200) { - std::cout << "---------------------------------------------" - << iter <<std::endl ; - vpColVector v ; + // Set the position of the camera in the end-effector frame + vpHomogeneousMatrix cMe ; + vpVelocityTwistMatrix cVe(cMe) ; + task.set_cVe(cVe) ; // Set the Jacobian (expressed in the end-effector frame) - // Since q is modified eJe is modified + vpMatrix eJe ; robot.get_eJe(eJe) ; task.set_eJe(eJe) ; - // get the robot position - robot.getPosition(wMc) ; - // Compute the position of the camera wrt the object frame - cMo = wMc.inverse() * wMo; - - // Compute new point position - for (i = 0 ; i < 4 ; i++) { - point[i].track(cMo) ; - // retrieve x,y and Z of the vpPoint structure to compute the feature - vpFeatureBuilder::create(p[i],point[i]) ; - } - - if (opt_display) { - vpDisplay::display(Iint) ; - vpDisplay::display(Iext) ; + // we want to see a point on a point + for (i = 0 ; i < 4 ; i++) + task.addFeature(p[i],pd[i]) ; + + // set the gain + task.setLambda(1) ; + + + std::cout << "\nDisplay task information: " << std::endl; + task.print() ; + + unsigned int iter=0 ; + // loop + while(iter++ < 200) { + std::cout << "---------------------------------------------" + << iter <<std::endl ; + vpColVector v ; + + + // Set the Jacobian (expressed in the end-effector frame) + // Since q is modified eJe is modified + robot.get_eJe(eJe) ; + task.set_eJe(eJe) ; + + // get the robot position + robot.getPosition(wMc) ; + // Compute the position of the camera wrt the object frame + cMo = wMc.inverse() * wMo; + + // Compute new point position + for (i = 0 ; i < 4 ; i++) { + point[i].track(cMo) ; + // retrieve x,y and Z of the vpPoint structure to compute the feature + vpFeatureBuilder::create(p[i],point[i]) ; + } + + if (opt_display) { + vpDisplay::display(Iint) ; + vpDisplay::display(Iext) ; + + vpServoDisplay::display(task,cam,Iint) ; + externalview.display(Iext,cextMo, cMo, cam, vpColor::green); + vpDisplay::flush(Iint); + vpDisplay::flush(Iext); + } + + // Compute the control law + v = task.computeControlLaw() ; + + if (iter==1) { + std::cout << "Display task information: " << std::endl; + task.print() ; + } + + task.print(vpServo::FEATURE_CURRENT); + task.print(vpServo::FEATURE_DESIRED); + + // Send the camera velocity to the controller + robot.setVelocity(vpRobot::CAMERA_FRAME, v); + // Save velocities applied to the robot in the log file + // v[0], v[1], v[2] correspond to camera translation velocities in m/s + // v[3], v[4], v[5] correspond to camera rotation velocities in rad/s + flog << v[0] << " " << v[1] << " " << v[2] << " " + << v[3] << " " << v[4] << " " << v[5] << " "; + + std::cout << "v: " << v.t() << std::endl; + + std::cout << "|| s - s* || = "<< ( task.getError() ).sumSquare() << std::endl; + + // Save feature error (s-s*) for the 4 feature points. For each feature + // point, we have 2 errors (along x and y axis). This error is expressed + // in meters in the camera frame + flog << ( task.getError() ).t() << " ";// s-s* for point 4 + std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; + + // Save current visual feature s = (rho,theta) + for (i = 0 ; i < 4 ; i++) { + flog << p[i].get_rho() << " " << p[i].get_theta() << " "; + } + // Save current position of the points + for (i = 0 ; i < 4 ; i++) { + flog << point[i].get_x() << " " << point[i].get_y() << " "; + } + flog << std::endl; + + if (iter == 1) { + vpImagePoint ip; + ip.set_i( 10 ); + ip.set_j( 10 ); + + std::cout << "\nClick in the internal camera view to continue..." << std::endl; + vpDisplay::displayCharString(Iint, ip, + "A click to continue...",vpColor::red); + vpDisplay::flush(Iint); + vpDisplay::getClick(Iint); + } - vpServoDisplay::display(task,cam,Iint) ; - externalview.display(Iext,cextMo, cMo, cam, vpColor::green); - vpDisplay::flush(Iint); - vpDisplay::flush(Iext); } - // Compute the control law - v = task.computeControlLaw() ; - - if (iter==1) { - std::cout << "Display task information: " << std::endl; - task.print() ; - } - task.print(vpServo::FEATURE_CURRENT); - task.print(vpServo::FEATURE_DESIRED); + flog.close() ; // Close the log file - // Send the camera velocity to the controller - robot.setVelocity(vpRobot::CAMERA_FRAME, v); - // Save velocities applied to the robot in the log file - // v[0], v[1], v[2] correspond to camera translation velocities in m/s - // v[3], v[4], v[5] correspond to camera rotation velocities in rad/s - flog << v[0] << " " << v[1] << " " << v[2] << " " - << v[3] << " " << v[4] << " " << v[5] << " "; + // Display task information + task.print() ; - std::cout << "v: " << v.t() << std::endl; + // Kill the task + task.kill(); - std::cout << "|| s - s* || = "<< ( task.getError() ).sumSquare() << std::endl; + std::cout <<"Final robot position with respect to the object frame:\n"; + cMo.print(); - // Save feature error (s-s*) for the 4 feature points. For each feature - // point, we have 2 errors (along x and y axis). This error is expressed - // in meters in the camera frame - flog << ( task.getError() ).t() << " ";// s-s* for point 4 - std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; - - // Save current visual feature s = (rho,theta) - for (i = 0 ; i < 4 ; i++) { - flog << p[i].get_rho() << " " << p[i].get_theta() << " "; + if (opt_display && opt_click_allowed) { + // suppressed for automate test + std::cout << "\n\nClick in the internal view to end..." << std::endl; + vpDisplay::getClick(Iint) ; } - // Save current position of the points - for (i = 0 ; i < 4 ; i++) { - flog << point[i].get_x() << " " << point[i].get_y() << " "; - } - flog << std::endl; - - if (iter == 1) { - vpImagePoint ip; - ip.set_i( 10 ); - ip.set_j( 10 ); - - std::cout << "\nClick in the internal camera view to continue..." << std::endl; - vpDisplay::displayCharString(Iint, ip, - "A click to continue...",vpColor::red); - vpDisplay::flush(Iint); - vpDisplay::getClick(Iint); - } - + return 0; } - - - flog.close() ; // Close the log file - - // Display task information - task.print() ; - - // Kill the task - task.kill(); - - std::cout <<"Final robot position with respect to the object frame:\n"; - cMo.print(); - - if (opt_display && opt_click_allowed) { - // suppressed for automate test - std::cout << "\n\nClick in the internal view to end..." << std::endl; - vpDisplay::getClick(Iint) ; + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; } } #else diff --git a/example/robot-simulator/camera/servoSimuLine2DCamVelocityDisplay.cpp b/example/robot-simulator/camera/servoSimuLine2DCamVelocityDisplay.cpp index 888ca654497996e61590a7f8702826b77f46185b..00649106c4a2bdceb8f4099793d07bcd504244bd 100644 --- a/example/robot-simulator/camera/servoSimuLine2DCamVelocityDisplay.cpp +++ b/example/robot-simulator/camera/servoSimuLine2DCamVelocityDisplay.cpp @@ -4,7 +4,7 @@ * $Id: servoSimuLine2DCamVelocityDisplay.cpp 2457 2010-01-07 10:41:18Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -76,6 +76,9 @@ // List of allowed command line options #define GETOPTARGS "cdh" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display); + /*! Print the program options. @@ -126,9 +129,9 @@ Set the program options. */ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; @@ -136,7 +139,7 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) case 'h': usage(argv[0], NULL); return false; break; default: - usage(argv[0], optarg); + usage(argv[0], optarg_); return false; break; } } @@ -145,7 +148,7 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -156,158 +159,165 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) int main(int argc, const char ** argv) { - bool opt_display = true; - bool opt_click_allowed = true; + try { + bool opt_display = true; + bool opt_click_allowed = true; - // Read the command line options - if (getOptions(argc, argv, opt_click_allowed, opt_display) == false) { - exit (-1); - } + // Read the command line options + if (getOptions(argc, argv, opt_click_allowed, opt_display) == false) { + exit (-1); + } - vpImage<unsigned char> I(512,512,0) ; + vpImage<unsigned char> I(512,512,0) ; - // We open a window using either X11, GTK or GDI. + // We open a window using either X11, GTK or GDI. #if defined VISP_HAVE_X11 - vpDisplayX display; + vpDisplayX display; #elif defined VISP_HAVE_GTK - vpDisplayGTK display; + vpDisplayGTK display; #elif defined VISP_HAVE_GDI - vpDisplayGDI display; + vpDisplayGDI display; #endif - if (opt_display) { - try{ - // Display size is automatically defined by the image (I) size - display.init(I, 100, 100,"Camera view...") ; - // 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) ; - vpDisplay::flush(I) ; - } - catch(...) - { - vpERROR_TRACE("Error while displaying the image") ; - exit(-1); + if (opt_display) { + try{ + // Display size is automatically defined by the image (I) size + display.init(I, 100, 100,"Camera view...") ; + // 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) ; + vpDisplay::flush(I) ; + } + catch(...) + { + vpERROR_TRACE("Error while displaying the image") ; + exit(-1); + } } - } - double px, py ; px = py = 600 ; - double u0, v0 ; u0 = v0 = 256 ; - - vpCameraParameters cam(px,py,u0,v0); - - vpServo task ; - vpSimulatorCamera robot ; - - // sets the initial camera location - vpHomogeneousMatrix cMo(-0.2,0.1,1, - vpMath::rad(5), vpMath::rad(5), vpMath::rad(90)); - - // Compute the position of the object in the world frame - vpHomogeneousMatrix wMc, wMo; - robot.getPosition(wMc) ; - wMo = wMc * cMo; - - // sets the final camera location (for simulation purpose) - vpHomogeneousMatrix cMod(0,0,1, - vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); - - // sets the line coordinates (2 planes) in the world frame - vpColVector plane1(4) ; - vpColVector plane2(4) ; - plane1[0] = 0; // z = 0 - plane1[1] = 0; - plane1[2] = 1; - plane1[3] = 0; - plane2[0] = 0; // y =0 - plane2[1] = 1; - plane2[2] = 0; - plane2[3] = 0; - - vpLine line ; - line.setWorldCoordinates(plane1, plane2) ; - - // sets the desired position of the visual feature - line.track(cMod) ; - line.print() ; - - vpFeatureLine ld ; - vpFeatureBuilder::create(ld,line) ; - - // computes the line coordinates in the camera frame and its 2D coordinates - // sets the current position of the visual feature - line.track(cMo) ; - line.print() ; - - vpFeatureLine l ; - vpFeatureBuilder::create(l,line) ; - l.print() ; - - // define the task - // - we want an eye-in-hand control law - // - robot is controlled in the camera frame - task.setServo(vpServo::EYEINHAND_CAMERA) ; - - // we want to see a line on a line - - task.addFeature(l,ld) ; - vpDisplay::display(I) ; - vpServoDisplay::display(task,cam,I) ; - vpDisplay::flush(I) ; - - // set the gain - task.setLambda(1) ; - // Display task information " ) ; - task.print() ; - - if (opt_display && opt_click_allowed) { - std::cout << "\n\nClick in the camera view window to start..." << std::endl; - vpDisplay::getClick(I) ; - } + double px, py ; px = py = 600 ; + double u0, v0 ; u0 = v0 = 256 ; - unsigned int iter=0 ; - // loop - while(iter++<200) - { - std::cout << "---------------------------------------------" << iter <<std::endl ; - vpColVector v ; + vpCameraParameters cam(px,py,u0,v0); - // get the robot position - robot.getPosition(wMc) ; - // Compute the position of the camera wrt the object frame - cMo = wMc.inverse() * wMo; + vpServo task ; + vpSimulatorCamera robot ; - // new line position + // sets the initial camera location + vpHomogeneousMatrix cMo(-0.2,0.1,1, + vpMath::rad(5), vpMath::rad(5), vpMath::rad(90)); + + // Compute the position of the object in the world frame + vpHomogeneousMatrix wMc, wMo; + robot.getPosition(wMc) ; + wMo = wMc * cMo; + + // sets the final camera location (for simulation purpose) + vpHomogeneousMatrix cMod(0,0,1, + vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); + + // sets the line coordinates (2 planes) in the world frame + vpColVector plane1(4) ; + vpColVector plane2(4) ; + plane1[0] = 0; // z = 0 + plane1[1] = 0; + plane1[2] = 1; + plane1[3] = 0; + plane2[0] = 0; // y =0 + plane2[1] = 1; + plane2[2] = 0; + plane2[3] = 0; + + vpLine line ; + line.setWorldCoordinates(plane1, plane2) ; + + // sets the desired position of the visual feature + line.track(cMod) ; + line.print() ; + + vpFeatureLine ld ; + vpFeatureBuilder::create(ld,line) ; + + // computes the line coordinates in the camera frame and its 2D coordinates + // sets the current position of the visual feature line.track(cMo) ; - // retrieve x,y and Z of the vpLine structure - vpFeatureBuilder::create(l,line); + line.print() ; - if (opt_display) { - vpDisplay::display(I) ; - vpServoDisplay::display(task,cam,I) ; - vpDisplay::flush(I) ; + vpFeatureLine l ; + vpFeatureBuilder::create(l,line) ; + l.print() ; + + // define the task + // - we want an eye-in-hand control law + // - robot is controlled in the camera frame + task.setServo(vpServo::EYEINHAND_CAMERA) ; + + // we want to see a line on a line + + task.addFeature(l,ld) ; + vpDisplay::display(I) ; + vpServoDisplay::display(task,cam,I) ; + vpDisplay::flush(I) ; + + // set the gain + task.setLambda(1) ; + // Display task information " ) ; + task.print() ; + + if (opt_display && opt_click_allowed) { + std::cout << "\n\nClick in the camera view window to start..." << std::endl; + vpDisplay::getClick(I) ; } - // compute the control law - v = task.computeControlLaw() ; + unsigned int iter=0 ; + // loop + while(iter++<200) + { + std::cout << "---------------------------------------------" << iter <<std::endl ; + vpColVector v ; - // send the camera velocity to the controller - robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + // get the robot position + robot.getPosition(wMc) ; + // Compute the position of the camera wrt the object frame + cMo = wMc.inverse() * wMo; - std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; - } + // new line position + line.track(cMo) ; + // retrieve x,y and Z of the vpLine structure + vpFeatureBuilder::create(l,line); - if (opt_display && opt_click_allowed) { - std::cout << "\nClick in the camera view window to end..." << std::endl; - vpDisplay::getClick(I) ; - } + if (opt_display) { + vpDisplay::display(I) ; + vpServoDisplay::display(task,cam,I) ; + vpDisplay::flush(I) ; + } + + // compute the control law + v = task.computeControlLaw() ; - // Display task information - task.print() ; - task.kill(); + // send the camera velocity to the controller + robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + + std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; + } + + if (opt_display && opt_click_allowed) { + std::cout << "\nClick in the camera view window to end..." << std::endl; + vpDisplay::getClick(I) ; + } + + // Display task information + task.print() ; + task.kill(); + return 0; + } + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; + } } #else diff --git a/example/robot-simulator/camera/servoSimuPoint2DCamVelocity1.cpp b/example/robot-simulator/camera/servoSimuPoint2DCamVelocity1.cpp index d28e601b38e6e82f6db951942664db8b4962e32e..d1066f2187055d93225352422638de56c233066e 100644 --- a/example/robot-simulator/camera/servoSimuPoint2DCamVelocity1.cpp +++ b/example/robot-simulator/camera/servoSimuPoint2DCamVelocity1.cpp @@ -3,7 +3,7 @@ * $Id: servoSimuPoint2DCamVelocity1.cpp 2457 2010-01-07 10:41:18Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -62,6 +62,9 @@ // List of allowed command line options #define GETOPTARGS "h" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); + /*! Print the program options. @@ -103,15 +106,15 @@ Set the program options. */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -120,7 +123,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -130,83 +133,90 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } - vpServo task ; - vpSimulatorCamera robot ; + vpServo task ; + vpSimulatorCamera robot ; - // sets the initial camera location - vpHomogeneousMatrix cMo ; - cMo[0][3] = 0.1 ; - cMo[1][3] = 0.2 ; - cMo[2][3] = 2 ; + // sets the initial camera location + vpHomogeneousMatrix cMo ; + cMo[0][3] = 0.1 ; + cMo[1][3] = 0.2 ; + cMo[2][3] = 2 ; - // Compute the position of the object in the world frame - vpHomogeneousMatrix wMc, wMo; - robot.getPosition(wMc) ; - wMo = wMc * cMo; + // Compute the position of the object in the world frame + vpHomogeneousMatrix wMc, wMo; + robot.getPosition(wMc) ; + wMo = wMc * cMo; - // sets the point coordinates in the world frame - vpPoint point ; - point.setWorldCoordinates(0,0,0) ; + // sets the point coordinates in the world frame + vpPoint point ; + point.setWorldCoordinates(0,0,0) ; - // computes the point coordinates in the camera frame and its 2D coordinates - point.track(cMo) ; + // computes the point coordinates in the camera frame and its 2D coordinates + point.track(cMo) ; - // sets the current position of the visual feature - vpFeaturePoint p ; - vpFeatureBuilder::create(p,point) ; //retrieve x,y and Z of the vpPoint structure + // sets the current position of the visual feature + vpFeaturePoint p ; + vpFeatureBuilder::create(p,point) ; //retrieve x,y and Z of the vpPoint structure - // sets the desired position of the visual feature - vpFeaturePoint pd ; - pd.buildFrom(0,0,1) ; // buildFrom(x,y,Z) ; + // sets the desired position of the visual feature + vpFeaturePoint pd ; + pd.buildFrom(0,0,1) ; // buildFrom(x,y,Z) ; - // define the task - // - we want an eye-in-hand control law - // - robot is controlled in the camera frame - task.setServo(vpServo::EYEINHAND_CAMERA) ; + // define the task + // - we want an eye-in-hand control law + // - robot is controlled in the camera frame + task.setServo(vpServo::EYEINHAND_CAMERA) ; - // we want to see a point on a point - std::cout << std::endl ; - task.addFeature(p,pd) ; + // we want to see a point on a point + std::cout << std::endl ; + task.addFeature(p,pd) ; - // set the gain - task.setLambda(1) ; + // set the gain + task.setLambda(1) ; - // Display task information - task.print() ; + // Display task information + task.print() ; - unsigned int iter=0 ; - // loop - while(iter++<100) - { - std::cout << "---------------------------------------------" << iter <<std::endl ; - vpColVector v ; + unsigned int iter=0 ; + // loop + while(iter++<100) + { + std::cout << "---------------------------------------------" << iter <<std::endl ; + vpColVector v ; - // get the robot position - robot.getPosition(wMc) ; - // Compute the position of the camera wrt the object frame - cMo = wMc.inverse() * wMo; + // get the robot position + robot.getPosition(wMc) ; + // Compute the position of the camera wrt the object frame + cMo = wMc.inverse() * wMo; - // new point position - point.track(cMo) ; - //retrieve x,y and Z of the vpPoint structure - vpFeatureBuilder::create(p,point); + // new point position + point.track(cMo) ; + //retrieve x,y and Z of the vpPoint structure + vpFeatureBuilder::create(p,point); - // compute the control law - v = task.computeControlLaw() ; + // compute the control law + v = task.computeControlLaw() ; - // send the camera velocity to the controller - robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + // send the camera velocity to the controller + robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; - std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; - } + std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; + } - // Display task information - task.print() ; - task.kill(); + // Display task information + task.print() ; + task.kill(); + return 0; + } + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; + } } diff --git a/example/robot-simulator/camera/servoSimuPoint2DCamVelocity2.cpp b/example/robot-simulator/camera/servoSimuPoint2DCamVelocity2.cpp index b483fd947ffe4aa6488e766f38b9b41378287bd0..1524bb64b39de1555200bfa6d552b7038e6f741b 100644 --- a/example/robot-simulator/camera/servoSimuPoint2DCamVelocity2.cpp +++ b/example/robot-simulator/camera/servoSimuPoint2DCamVelocity2.cpp @@ -3,7 +3,7 @@ * $Id: servoSimuPoint2DCamVelocity2.cpp 2503 2010-02-16 18:55:01Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -70,6 +70,9 @@ // List of allowed command line options #define GETOPTARGS "h" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); + /*! Print the program options. @@ -111,15 +114,15 @@ Set the program options. */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -128,7 +131,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -138,106 +141,113 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } + + vpServo task ; + vpSimulatorCamera robot ; + + + std::cout << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << " Test program for vpServo " <<std::endl ; + std::cout << " Eye-in-hand task control, articular velocity are computed" << std::endl ; + std::cout << " Simulation " << std::endl ; + std::cout << " task : servo a point " << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << std::endl ; + + // sets the initial camera location + vpHomogeneousMatrix cMo ; + cMo[0][3] = 0.1 ; + cMo[1][3] = 0.2 ; + cMo[2][3] = 2 ; + // Compute the position of the object in the world frame + vpHomogeneousMatrix wMc, wMo; + robot.getPosition(wMc) ; + wMo = wMc * cMo; + + // sets the point coordinates in the world frame + vpPoint point ; + point.setWorldCoordinates(0,0,0) ; + + // computes the point coordinates in the camera frame and its 2D coordinates + point.track(cMo) ; + + // sets the current position of the visual feature + vpFeaturePoint p ; + vpFeatureBuilder::create(p,point) ; //retrieve x,y and Z of the vpPoint structure + + // sets the desired position of the visual feature + vpFeaturePoint pd ; + pd.buildFrom(0,0,1) ; + + // define the task + // - we want an eye-in-hand control law + // - articular velocity are computed + task.setServo(vpServo::EYEINHAND_L_cVe_eJe) ; + task.setInteractionMatrixType(vpServo::MEAN) ; - vpServo task ; - vpSimulatorCamera robot ; - - - std::cout << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << " Test program for vpServo " <<std::endl ; - std::cout << " Eye-in-hand task control, articular velocity are computed" << std::endl ; - std::cout << " Simulation " << std::endl ; - std::cout << " task : servo a point " << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << std::endl ; - - // sets the initial camera location - vpHomogeneousMatrix cMo ; - cMo[0][3] = 0.1 ; - cMo[1][3] = 0.2 ; - cMo[2][3] = 2 ; - // Compute the position of the object in the world frame - vpHomogeneousMatrix wMc, wMo; - robot.getPosition(wMc) ; - wMo = wMc * cMo; - - // sets the point coordinates in the world frame - vpPoint point ; - point.setWorldCoordinates(0,0,0) ; - - // computes the point coordinates in the camera frame and its 2D coordinates - point.track(cMo) ; - - // sets the current position of the visual feature - vpFeaturePoint p ; - vpFeatureBuilder::create(p,point) ; //retrieve x,y and Z of the vpPoint structure - - // sets the desired position of the visual feature - vpFeaturePoint pd ; - pd.buildFrom(0,0,1) ; - - // define the task - // - we want an eye-in-hand control law - // - articular velocity are computed - task.setServo(vpServo::EYEINHAND_L_cVe_eJe) ; - task.setInteractionMatrixType(vpServo::MEAN) ; - - // Set the position of the camera in the end-effector frame - vpHomogeneousMatrix cMe ; - vpVelocityTwistMatrix cVe(cMe) ; - task.set_cVe(cVe) ; - - // Set the Jacobian (expressed in the end-effector frame) - vpMatrix eJe ; - robot.get_eJe(eJe) ; - task.set_eJe(eJe) ; - - // we want to see a point on a point - task.addFeature(p,pd) ; - - // set the gain - task.setLambda(1) ; - // Display task information - task.print() ; - - unsigned int iter=0 ; - // loop - while(iter++<100) - { - std::cout << "---------------------------------------------" << iter <<std::endl ; - vpColVector v ; + // Set the position of the camera in the end-effector frame + vpHomogeneousMatrix cMe ; + vpVelocityTwistMatrix cVe(cMe) ; + task.set_cVe(cVe) ; // Set the Jacobian (expressed in the end-effector frame) - // since q is modified eJe is modified + vpMatrix eJe ; robot.get_eJe(eJe) ; task.set_eJe(eJe) ; - // get the robot position - robot.getPosition(wMc) ; - // Compute the position of the camera wrt the object frame - cMo = wMc.inverse() * wMo; + // we want to see a point on a point + task.addFeature(p,pd) ; - // new point position - point.track(cMo) ; - vpFeatureBuilder::create(p,point) ; //retrieve x,y and Z of the vpPoint structure - pd.buildFrom(0,0,1) ; // Since vpServo::MEAN interaction matrix is used, we need to update the desired feature at each iteration + // set the gain + task.setLambda(1) ; + // Display task information + task.print() ; - // compute the control law - v = task.computeControlLaw() ; + unsigned int iter=0 ; + // loop + while(iter++<100) + { + std::cout << "---------------------------------------------" << iter <<std::endl ; + vpColVector v ; - // send the camera velocity to the controller - robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + // Set the Jacobian (expressed in the end-effector frame) + // since q is modified eJe is modified + robot.get_eJe(eJe) ; + task.set_eJe(eJe) ; - std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; - } + // get the robot position + robot.getPosition(wMc) ; + // Compute the position of the camera wrt the object frame + cMo = wMc.inverse() * wMo; + + // new point position + point.track(cMo) ; + vpFeatureBuilder::create(p,point) ; //retrieve x,y and Z of the vpPoint structure + pd.buildFrom(0,0,1) ; // Since vpServo::MEAN interaction matrix is used, we need to update the desired feature at each iteration + + // compute the control law + v = task.computeControlLaw() ; - // Display task information - task.print() ; - task.kill(); + // send the camera velocity to the controller + robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + + std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; + } + + // Display task information + task.print() ; + task.kill(); + return 0; + } + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; + } } diff --git a/example/robot-simulator/camera/servoSimuPoint2DCamVelocity3.cpp b/example/robot-simulator/camera/servoSimuPoint2DCamVelocity3.cpp index 9808dfd8f634bfb6e2d226ddd45fb8edbfad453f..5806ace9e67078454b9176477f534cea95d8907c 100644 --- a/example/robot-simulator/camera/servoSimuPoint2DCamVelocity3.cpp +++ b/example/robot-simulator/camera/servoSimuPoint2DCamVelocity3.cpp @@ -3,7 +3,7 @@ * $Id: servoSimuPoint2DCamVelocity3.cpp 2503 2010-02-16 18:55:01Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -69,6 +69,9 @@ // List of allowed command line options #define GETOPTARGS "h" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); + /*! Print the program options. @@ -111,15 +114,15 @@ Set the program options. */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -128,7 +131,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -138,104 +141,111 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } + + vpServo task ; + vpSimulatorCamera robot ; + + std::cout << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << " Test program for vpServo " <<std::endl ; + std::cout << " Eye-in-hand task control, articular velocity are computed" << std::endl ; + std::cout << " Simulation " << std::endl ; + std::cout << " task : servo a point " << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << std::endl ; + + // sets the initial camera location + vpHomogeneousMatrix cMo ; + cMo[0][3] = 0.1 ; + cMo[1][3] = 0.2 ; + cMo[2][3] = 2 ; + // Compute the position of the object in the world frame + vpHomogeneousMatrix wMc, wMo; + robot.getPosition(wMc) ; + wMo = wMc * cMo; + + // sets the point coordinates in the world frame + vpPoint point ; + point.setWorldCoordinates(0,0,0) ; + + // computes the point coordinates in the camera frame and its 2D coordinates + point.track(cMo) ; + + // sets the current position of the visual feature + vpFeaturePoint p ; + vpFeatureBuilder::create(p,point) ; //retrieve x,y and Z of the vpPoint structure + + // sets the desired position of the visual feature + vpFeaturePoint pd ; + pd.buildFrom(0,0,1) ; // buildFrom(x,y,Z) ; + + // define the task + // - we want an eye-in-hand control law + // - articular velocity are computed + task.setServo(vpServo::EYEINHAND_L_cVe_eJe) ; - vpServo task ; - vpSimulatorCamera robot ; - - std::cout << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << " Test program for vpServo " <<std::endl ; - std::cout << " Eye-in-hand task control, articular velocity are computed" << std::endl ; - std::cout << " Simulation " << std::endl ; - std::cout << " task : servo a point " << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << std::endl ; - - // sets the initial camera location - vpHomogeneousMatrix cMo ; - cMo[0][3] = 0.1 ; - cMo[1][3] = 0.2 ; - cMo[2][3] = 2 ; - // Compute the position of the object in the world frame - vpHomogeneousMatrix wMc, wMo; - robot.getPosition(wMc) ; - wMo = wMc * cMo; - - // sets the point coordinates in the world frame - vpPoint point ; - point.setWorldCoordinates(0,0,0) ; - - // computes the point coordinates in the camera frame and its 2D coordinates - point.track(cMo) ; - - // sets the current position of the visual feature - vpFeaturePoint p ; - vpFeatureBuilder::create(p,point) ; //retrieve x,y and Z of the vpPoint structure - - // sets the desired position of the visual feature - vpFeaturePoint pd ; - pd.buildFrom(0,0,1) ; // buildFrom(x,y,Z) ; - - // define the task - // - we want an eye-in-hand control law - // - articular velocity are computed - task.setServo(vpServo::EYEINHAND_L_cVe_eJe) ; - - // Set the position of the camera in the end-effector frame - vpHomogeneousMatrix cMe ; - vpVelocityTwistMatrix cVe(cMe) ; - task.set_cVe(cVe) ; - - // Set the Jacobian (expressed in the end-effector frame) - vpMatrix eJe ; - robot.get_eJe(eJe) ; - task.set_eJe(eJe) ; - - // we want to see a point on a point - task.addFeature(p,pd, vpFeaturePoint::selectX()) ; - - // set the gain - task.setLambda(1) ; - - // Display task information - task.print() ; - - unsigned int iter=0 ; - // loop - while(iter++ < 100) - { - std::cout << "---------------------------------------------" << iter <<std::endl ; - vpColVector v ; + // Set the position of the camera in the end-effector frame + vpHomogeneousMatrix cMe ; + vpVelocityTwistMatrix cVe(cMe) ; + task.set_cVe(cVe) ; // Set the Jacobian (expressed in the end-effector frame) - // since q is modified eJe is modified + vpMatrix eJe ; robot.get_eJe(eJe) ; task.set_eJe(eJe) ; - // get the robot position - robot.getPosition(wMc) ; - // Compute the position of the camera wrt the object frame - cMo = wMc.inverse() * wMo; + // we want to see a point on a point + task.addFeature(p,pd, vpFeaturePoint::selectX()) ; - // new point position - point.track(cMo) ; - vpFeatureBuilder::create(p,point) ; //retrieve x,y and Z of the vpPoint structure + // set the gain + task.setLambda(1) ; - // compute the control law - v = task.computeControlLaw() ; + // Display task information + task.print() ; - // send the camera velocity to the controller - robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + unsigned int iter=0 ; + // loop + while(iter++ < 100) + { + std::cout << "---------------------------------------------" << iter <<std::endl ; + vpColVector v ; - std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; - } + // Set the Jacobian (expressed in the end-effector frame) + // since q is modified eJe is modified + robot.get_eJe(eJe) ; + task.set_eJe(eJe) ; + + // get the robot position + robot.getPosition(wMc) ; + // Compute the position of the camera wrt the object frame + cMo = wMc.inverse() * wMo; + + // new point position + point.track(cMo) ; + vpFeatureBuilder::create(p,point) ; //retrieve x,y and Z of the vpPoint structure - // Display task information - task.print() ; - task.kill(); + // compute the control law + v = task.computeControlLaw() ; + + // send the camera velocity to the controller + robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + + std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; + } + + // Display task information + task.print() ; + task.kill(); + return 0; + } + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; + } } diff --git a/example/robot-simulator/camera/servoSimuPoint2DhalfCamVelocity1.cpp b/example/robot-simulator/camera/servoSimuPoint2DhalfCamVelocity1.cpp index 3bb573ea15a79a0b816b3057186fe1698fa6601b..2788691fe5c72e83d873bef8991f96abe34e2c0e 100644 --- a/example/robot-simulator/camera/servoSimuPoint2DhalfCamVelocity1.cpp +++ b/example/robot-simulator/camera/servoSimuPoint2DhalfCamVelocity1.cpp @@ -3,7 +3,7 @@ * $Id: servoSimuPoint2DhalfCamVelocity1.cpp 2457 2010-01-07 10:41:18Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -69,6 +69,9 @@ // List of allowed command line options #define GETOPTARGS "h" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); + /*! Print the program options. @@ -112,15 +115,15 @@ Set the program options. */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -129,7 +132,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -139,124 +142,131 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } + + vpServo task ; + vpSimulatorCamera robot ; - vpServo task ; - vpSimulatorCamera robot ; - - std::cout << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << " Test program for vpServo " <<std::endl ; - std::cout << " task : 2 1/2 D visual servoing " << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << std::endl ; - - // sets the initial camera location - vpPoseVector c_r_o(0.1,0.2,2, - vpMath::rad(20), vpMath::rad(10), vpMath::rad(50) - ) ; - - vpHomogeneousMatrix cMo(c_r_o) ; - // Compute the position of the object in the world frame - vpHomogeneousMatrix wMc, wMo; - robot.getPosition(wMc) ; - wMo = wMc * cMo; - - // sets the desired camera location - vpPoseVector cd_r_o(0,0,1, - vpMath::rad(0),vpMath::rad(0),vpMath::rad(0)) ; - vpHomogeneousMatrix cdMo(cd_r_o) ; - - // sets the point coordinates in the world frame - vpPoint point ; - point.setWorldCoordinates(0,0,0) ; - // computes the point coordinates in the camera frame and its 2D coordinates - point.track(cMo) ; - - vpPoint pointd ; - pointd.setWorldCoordinates(0,0,0) ; - pointd.track(cdMo) ; - //------------------------------------------------------------------ - // 1st feature (x,y) - // want to it at (0,0) - vpFeaturePoint p ; - vpFeatureBuilder::create(p,point) ; - - vpFeaturePoint pd ; - vpFeatureBuilder::create(pd,pointd) ; - - //------------------------------------------------------------------ - // 2nd feature (Z) - // not necessary to project twice (reuse p) - vpFeaturePoint3D Z ; - vpFeatureBuilder::create(Z,point) ; //retrieve x,y and Z of the vpPoint structure - - // want to see it one meter away (here again use pd) - vpFeaturePoint3D Zd ; - vpFeatureBuilder::create(Zd,pointd) ; //retrieve x,y and Z of the vpPoint structure - - //------------------------------------------------------------------ - // 3rd feature ThetaU - // compute the rotation that the camera has to achieve - vpHomogeneousMatrix cdMc ; - cdMc = cdMo*cMo.inverse() ; - - vpFeatureThetaU tu(vpFeatureThetaU::cdRc) ; - tu.buildFrom(cdMc) ; - - // sets the desired rotation (always zero !) - // since s is the rotation that the camera has to achieve - - //------------------------------------------------------------------ - // define the task - // - we want an eye-in-hand control law - // - robot is controlled in the camera frame - task.setServo(vpServo::EYEINHAND_CAMERA) ; - - task.addFeature(p,pd) ; - task.addFeature(Z,Zd,vpFeaturePoint3D::selectZ()) ; - task.addFeature(tu) ; - - // set the gain - task.setLambda(1) ; - - // Display task information - task.print() ; - - unsigned int iter=0 ; - // loop - while(iter++<200) - { - std::cout << "---------------------------------------------" << iter <<std::endl ; - vpColVector v ; - - // get the robot position + std::cout << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << " Test program for vpServo " <<std::endl ; + std::cout << " task : 2 1/2 D visual servoing " << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << std::endl ; + + // sets the initial camera location + vpPoseVector c_r_o(0.1,0.2,2, + vpMath::rad(20), vpMath::rad(10), vpMath::rad(50) + ) ; + + vpHomogeneousMatrix cMo(c_r_o) ; + // Compute the position of the object in the world frame + vpHomogeneousMatrix wMc, wMo; robot.getPosition(wMc) ; - // Compute the position of the camera wrt the object frame - cMo = wMc.inverse() * wMo; + wMo = wMc * cMo; + + // sets the desired camera location + vpPoseVector cd_r_o(0,0,1, + vpMath::rad(0),vpMath::rad(0),vpMath::rad(0)) ; + vpHomogeneousMatrix cdMo(cd_r_o) ; - // update the feature + // sets the point coordinates in the world frame + vpPoint point ; + point.setWorldCoordinates(0,0,0) ; + // computes the point coordinates in the camera frame and its 2D coordinates point.track(cMo) ; + + vpPoint pointd ; + pointd.setWorldCoordinates(0,0,0) ; + pointd.track(cdMo) ; + //------------------------------------------------------------------ + // 1st feature (x,y) + // want to it at (0,0) + vpFeaturePoint p ; vpFeatureBuilder::create(p,point) ; - vpFeatureBuilder::create(Z,point) ; + vpFeaturePoint pd ; + vpFeatureBuilder::create(pd,pointd) ; + + //------------------------------------------------------------------ + // 2nd feature (Z) + // not necessary to project twice (reuse p) + vpFeaturePoint3D Z ; + vpFeatureBuilder::create(Z,point) ; //retrieve x,y and Z of the vpPoint structure + + // want to see it one meter away (here again use pd) + vpFeaturePoint3D Zd ; + vpFeatureBuilder::create(Zd,pointd) ; //retrieve x,y and Z of the vpPoint structure + + //------------------------------------------------------------------ + // 3rd feature ThetaU + // compute the rotation that the camera has to achieve + vpHomogeneousMatrix cdMc ; cdMc = cdMo*cMo.inverse() ; + + vpFeatureThetaU tu(vpFeatureThetaU::cdRc) ; tu.buildFrom(cdMc) ; - // compute the control law - v = task.computeControlLaw() ; - // send the camera velocity to the controller ") ; - robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + // sets the desired rotation (always zero !) + // since s is the rotation that the camera has to achieve - std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; - } + //------------------------------------------------------------------ + // define the task + // - we want an eye-in-hand control law + // - robot is controlled in the camera frame + task.setServo(vpServo::EYEINHAND_CAMERA) ; - // Display task information - task.print() ; - task.kill(); - std::cout << "Final camera location:\n " << cMo << std::endl ; + task.addFeature(p,pd) ; + task.addFeature(Z,Zd,vpFeaturePoint3D::selectZ()) ; + task.addFeature(tu) ; + + // set the gain + task.setLambda(1) ; + + // Display task information + task.print() ; + + unsigned int iter=0 ; + // loop + while(iter++<200) + { + std::cout << "---------------------------------------------" << iter <<std::endl ; + vpColVector v ; + + // get the robot position + robot.getPosition(wMc) ; + // Compute the position of the camera wrt the object frame + cMo = wMc.inverse() * wMo; + + // update the feature + point.track(cMo) ; + vpFeatureBuilder::create(p,point) ; + vpFeatureBuilder::create(Z,point) ; + + cdMc = cdMo*cMo.inverse() ; + tu.buildFrom(cdMc) ; + + // compute the control law + v = task.computeControlLaw() ; + // send the camera velocity to the controller ") ; + robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + + std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; + } + + // Display task information + task.print() ; + task.kill(); + std::cout << "Final camera location:\n " << cMo << std::endl ; + return 0; + } + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; + } } diff --git a/example/robot-simulator/camera/servoSimuPoint2DhalfCamVelocity2.cpp b/example/robot-simulator/camera/servoSimuPoint2DhalfCamVelocity2.cpp index e8308cc8eeae7f86c05f26199f32c33656d26156..5e98f980fe1973c343eea69b8f4465e464d73a2c 100644 --- a/example/robot-simulator/camera/servoSimuPoint2DhalfCamVelocity2.cpp +++ b/example/robot-simulator/camera/servoSimuPoint2DhalfCamVelocity2.cpp @@ -4,7 +4,7 @@ * $Id: servoSimuPoint2DhalfCamVelocity2.cpp 2457 2010-01-07 10:41:18Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -69,6 +69,9 @@ // List of allowed command line options #define GETOPTARGS "h" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); + /*! Print the program options. @@ -109,15 +112,15 @@ Set the program options. */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -126,7 +129,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -136,221 +139,228 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } - - std::cout << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << " simulation of a 2 1/2 D visual servoing " << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << std::endl ; - - // In this example we will simulate a visual servoing task. - // In simulation, we have to define the scene frane Ro and the - // camera frame Rc. - // The camera location is given by an homogenous matrix cMo that - // describes the position of the camera in the scene frame. - - vpServo task ; - - // sets the initial camera location - // we give the camera location as a size 6 vector (3 translations in meter - // and 3 rotation (theta U representation) - vpPoseVector c_r_o(0.1,0.2,2, - vpMath::rad(20), vpMath::rad(10), vpMath::rad(50) - ) ; - - // this pose vector is then transformed in a 4x4 homogeneous matrix - vpHomogeneousMatrix cMo(c_r_o) ; - - // We define a robot - // The vpSimulatorCamera implements a simple moving that is juste defined - // by its location cMo - vpSimulatorCamera robot ; - - // Compute the position of the object in the world frame - vpHomogeneousMatrix wMc, wMo; - robot.getPosition(wMc) ; - wMo = wMc * cMo; - - // Now that the current camera position has been defined, - // let us defined the defined camera location. - // It is defined by cdMo - // sets the desired camera location - vpPoseVector cd_r_o(0,0,1, - vpMath::rad(0),vpMath::rad(0),vpMath::rad(0)) ; - vpHomogeneousMatrix cdMo(cd_r_o) ; - - - //---------------------------------------------------------------------- - // A 2 1/2 D visual servoing can be defined by - // - the position of a point x,y - // - the difference between this point depth and a desire depth - // modeled by log Z/Zd to be regulated to 0 - // - the rotation that the camera has to realized cdMc - - // Let us now defined the current value of these features - - - // since we simulate we have to define a 3D point that will - // forward-projected to define the current position x,y of the - // reference point - - //------------------------------------------------------------------ - // First feature (x,y) - //------------------------------------------------------------------ - // Let oP be this ... point, - // a vpPoint class has three main member - // .oP : 3D coordinates in scene frame - // .cP : 3D coordinates in camera frame - // .p : 2D - - //------------------------------------------------------------------ - // sets the point coordinates in the world frame - vpPoint point ; - // defined point coordinates in the scene frame : oP - point.setWorldCoordinates(0,0,0) ; - // computes the point coordinates in the camera frame and its - // 2D coordinates cP and then p - // computes the point coordinates in the camera frame and its 2D coordinates" ) ; - point.track(cMo) ; - - // We also defined (again by forward projection) the desired position - // of this point according to the desired camera position - vpPoint pointd ; - pointd.setWorldCoordinates(0,0,0) ; - pointd.track(cdMo) ; - - // Nevertheless, a vpPoint is not a feature, this is just a "tracker" - // from which the feature are built - // a feature is juste defined by a vector s, a way to compute the - // interaction matrix and the error, and if required a (or a vector of) - // 3D information - - // for a point (x,y) Visp implements the vpFeaturePoint class. - // we no defined a feature for x,y (and for (x*,y*)) - vpFeaturePoint p,pd ; - - // and we initialized the vector s=(x,y) of p from the tracker P - // Z coordinates in p is also initialized, it will be used to compute - // the interaction matrix - vpFeatureBuilder::create(p,point) ; - vpFeatureBuilder::create(pd,pointd) ; - - //------------------------------------------------------------------ - // Second feature log (Z/Zd) - // not necessary to project twice (reuse p) - - // This case in intersting since this visual feature has not - // been predefined in VisP - // In such case we have a generic feature class vpGenericFeature - // We will have to defined - // the vector s : .set_s(...) - // the interaction matrix Ls : .setInteractionMatrix(...) - - // log(Z/Zd) is then a size 1 vector logZ - vpGenericFeature logZ(1) ; - // initialized to s = log(Z/Zd) - // Let us note that here we use the point P and Pd, it's not necessary - // to forward project twice (it's already done) - logZ.set_s(log(point.get_Z()/pointd.get_Z())) ; - - // This visual has to be regulated to zero - - //------------------------------------------------------------------ - // 3rd feature ThetaU - // The thetaU feature is defined, tu represents the rotation that the camera - // has to realized. - // the complete displacement is then defined by: - //------------------------------------------------------------------ - vpHomogeneousMatrix cdMc ; - // compute the rotation that the camera has to achieve - cdMc = cdMo*cMo.inverse() ; - - // from this displacement, we extract the rotation cdRc represented by - // the angle theta and the rotation axis u - vpFeatureThetaU tu(vpFeatureThetaU::cdRc) ; - tu.buildFrom(cdMc) ; - // This visual has to be regulated to zero - - // sets the desired rotation (always zero !) - // since s is the rotation that the camera has to realize - - //------------------------------------------------------------------ - // Let us now the task itself - //------------------------------------------------------------------ - - // define the task - // - we want an eye-in-hand control law - // - robot is controlled in the camera frame - // we choose to control the robot in the camera frame - task.setServo(vpServo::EYEINHAND_CAMERA) ; - // Interaction matrix is computed with the current value of s - task.setInteractionMatrixType(vpServo::CURRENT) ; - - // we build the task by "stacking" the visual feature - // previously defined - task.addFeature(p,pd) ; - task.addFeature(logZ) ; - task.addFeature(tu) ; - // addFeature(X,Xd) means X should be regulated to Xd - // addFeature(X) means that X should be regulated to 0 - // some features such as vpFeatureThetaU MUST be regulated to zero - // (otherwise, it will results in an error at exectution level) - - // set the gain - task.setLambda(1) ; - - // Display task information - task.print() ; - //------------------------------------------------------------------ - // An now the closed loop - - unsigned int iter=0 ; - // loop - while(iter++<200) - { - std::cout << "---------------------------------------------" << iter <<std::endl ; - vpColVector v ; - - // get the robot position - robot.getPosition(wMc) ; - // Compute the position of the camera wrt the object frame - cMo = wMc.inverse() * wMo; + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } - // update the feature + std::cout << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << " simulation of a 2 1/2 D visual servoing " << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << std::endl ; + + // In this example we will simulate a visual servoing task. + // In simulation, we have to define the scene frane Ro and the + // camera frame Rc. + // The camera location is given by an homogenous matrix cMo that + // describes the position of the camera in the scene frame. + + vpServo task ; + + // sets the initial camera location + // we give the camera location as a size 6 vector (3 translations in meter + // and 3 rotation (theta U representation) + vpPoseVector c_r_o(0.1,0.2,2, + vpMath::rad(20), vpMath::rad(10), vpMath::rad(50) + ) ; + + // this pose vector is then transformed in a 4x4 homogeneous matrix + vpHomogeneousMatrix cMo(c_r_o) ; + + // We define a robot + // The vpSimulatorCamera implements a simple moving that is juste defined + // by its location cMo + vpSimulatorCamera robot ; + + // Compute the position of the object in the world frame + vpHomogeneousMatrix wMc, wMo; + robot.getPosition(wMc) ; + wMo = wMc * cMo; + + // Now that the current camera position has been defined, + // let us defined the defined camera location. + // It is defined by cdMo + // sets the desired camera location + vpPoseVector cd_r_o(0,0,1, + vpMath::rad(0),vpMath::rad(0),vpMath::rad(0)) ; + vpHomogeneousMatrix cdMo(cd_r_o) ; + + + //---------------------------------------------------------------------- + // A 2 1/2 D visual servoing can be defined by + // - the position of a point x,y + // - the difference between this point depth and a desire depth + // modeled by log Z/Zd to be regulated to 0 + // - the rotation that the camera has to realized cdMc + + // Let us now defined the current value of these features + + + // since we simulate we have to define a 3D point that will + // forward-projected to define the current position x,y of the + // reference point + + //------------------------------------------------------------------ + // First feature (x,y) + //------------------------------------------------------------------ + // Let oP be this ... point, + // a vpPoint class has three main member + // .oP : 3D coordinates in scene frame + // .cP : 3D coordinates in camera frame + // .p : 2D + + //------------------------------------------------------------------ + // sets the point coordinates in the world frame + vpPoint point ; + // defined point coordinates in the scene frame : oP + point.setWorldCoordinates(0,0,0) ; + // computes the point coordinates in the camera frame and its + // 2D coordinates cP and then p + // computes the point coordinates in the camera frame and its 2D coordinates" ) ; point.track(cMo) ; - vpFeatureBuilder::create(p,point) ; - cdMc = cdMo*cMo.inverse() ; - tu.buildFrom(cdMc) ; - - // there is no feature for logZ, we explicitely build - // the related interaction matrix") ; + // We also defined (again by forward projection) the desired position + // of this point according to the desired camera position + vpPoint pointd ; + pointd.setWorldCoordinates(0,0,0) ; + pointd.track(cdMo) ; + + // Nevertheless, a vpPoint is not a feature, this is just a "tracker" + // from which the feature are built + // a feature is juste defined by a vector s, a way to compute the + // interaction matrix and the error, and if required a (or a vector of) + // 3D information + + // for a point (x,y) Visp implements the vpFeaturePoint class. + // we no defined a feature for x,y (and for (x*,y*)) + vpFeaturePoint p,pd ; + + // and we initialized the vector s=(x,y) of p from the tracker P + // Z coordinates in p is also initialized, it will be used to compute + // the interaction matrix + vpFeatureBuilder::create(p,point) ; + vpFeatureBuilder::create(pd,pointd) ; + + //------------------------------------------------------------------ + // Second feature log (Z/Zd) + // not necessary to project twice (reuse p) + + // This case in intersting since this visual feature has not + // been predefined in VisP + // In such case we have a generic feature class vpGenericFeature + // We will have to defined + // the vector s : .set_s(...) + // the interaction matrix Ls : .setInteractionMatrix(...) + + // log(Z/Zd) is then a size 1 vector logZ + vpGenericFeature logZ(1) ; + // initialized to s = log(Z/Zd) + // Let us note that here we use the point P and Pd, it's not necessary + // to forward project twice (it's already done) logZ.set_s(log(point.get_Z()/pointd.get_Z())) ; - vpMatrix LlogZ(1,6) ; - LlogZ[0][0] = LlogZ[0][1] = LlogZ[0][5] = 0 ; - LlogZ[0][2] = -1/p.get_Z() ; - LlogZ[0][3] = -p.get_y() ; - LlogZ[0][4] = p.get_x() ; - logZ.setInteractionMatrix(LlogZ) ; + // This visual has to be regulated to zero - // compute the control law - v = task.computeControlLaw() ; + //------------------------------------------------------------------ + // 3rd feature ThetaU + // The thetaU feature is defined, tu represents the rotation that the camera + // has to realized. + // the complete displacement is then defined by: + //------------------------------------------------------------------ + vpHomogeneousMatrix cdMc ; + // compute the rotation that the camera has to achieve + cdMc = cdMo*cMo.inverse() ; - // send the camera velocity to the controller ") ; - robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + // from this displacement, we extract the rotation cdRc represented by + // the angle theta and the rotation axis u + vpFeatureThetaU tu(vpFeatureThetaU::cdRc) ; + tu.buildFrom(cdMc) ; + // This visual has to be regulated to zero + + // sets the desired rotation (always zero !) + // since s is the rotation that the camera has to realize + + //------------------------------------------------------------------ + // Let us now the task itself + //------------------------------------------------------------------ + + // define the task + // - we want an eye-in-hand control law + // - robot is controlled in the camera frame + // we choose to control the robot in the camera frame + task.setServo(vpServo::EYEINHAND_CAMERA) ; + // Interaction matrix is computed with the current value of s + task.setInteractionMatrixType(vpServo::CURRENT) ; + + // we build the task by "stacking" the visual feature + // previously defined + task.addFeature(p,pd) ; + task.addFeature(logZ) ; + task.addFeature(tu) ; + // addFeature(X,Xd) means X should be regulated to Xd + // addFeature(X) means that X should be regulated to 0 + // some features such as vpFeatureThetaU MUST be regulated to zero + // (otherwise, it will results in an error at exectution level) + + // set the gain + task.setLambda(1) ; + + // Display task information + task.print() ; + //------------------------------------------------------------------ + // An now the closed loop + + unsigned int iter=0 ; + // loop + while(iter++<200) + { + std::cout << "---------------------------------------------" << iter <<std::endl ; + vpColVector v ; + + // get the robot position + robot.getPosition(wMc) ; + // Compute the position of the camera wrt the object frame + cMo = wMc.inverse() * wMo; + + // update the feature + point.track(cMo) ; + vpFeatureBuilder::create(p,point) ; + + cdMc = cdMo*cMo.inverse() ; + tu.buildFrom(cdMc) ; + + // there is no feature for logZ, we explicitely build + // the related interaction matrix") ; + logZ.set_s(log(point.get_Z()/pointd.get_Z())) ; + vpMatrix LlogZ(1,6) ; + LlogZ[0][0] = LlogZ[0][1] = LlogZ[0][5] = 0 ; + LlogZ[0][2] = -1/p.get_Z() ; + LlogZ[0][3] = -p.get_y() ; + LlogZ[0][4] = p.get_x() ; + + logZ.setInteractionMatrix(LlogZ) ; + + // compute the control law + v = task.computeControlLaw() ; + + // send the camera velocity to the controller ") ; + robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + + std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; + } - std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; + // Display task information + task.print() ; + task.kill(); + // Final camera location + std::cout << cMo << std::endl ; + return 0; + } + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; } - - // Display task information - task.print() ; - task.kill(); - // Final camera location - std::cout << cMo << std::endl ; } diff --git a/example/robot-simulator/camera/servoSimuPoint2DhalfCamVelocity3.cpp b/example/robot-simulator/camera/servoSimuPoint2DhalfCamVelocity3.cpp index 76161538b0d893151b1b9fca7b835e7de49a2e50..d42e4931d983255d3913c7f9bd989d3ba748f0a5 100644 --- a/example/robot-simulator/camera/servoSimuPoint2DhalfCamVelocity3.cpp +++ b/example/robot-simulator/camera/servoSimuPoint2DhalfCamVelocity3.cpp @@ -4,7 +4,7 @@ * $Id: servoSimuPoint2DhalfCamVelocity3.cpp 2457 2010-01-07 10:41:18Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -69,6 +69,9 @@ // List of allowed command line options #define GETOPTARGS "h" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); + /*! Print the program options. @@ -109,15 +112,15 @@ Set the program options. */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -126,7 +129,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -136,197 +139,204 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } - - std::cout << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << " simulation of a 2 1/2 D visual servoing " << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << std::endl ; - - // In this example we will simulate a visual servoing task. - // In simulation, we have to define the scene frane Ro and the - // camera frame Rc. - // The camera location is given by an homogenous matrix cMo that - // describes the position of the camera in the scene frame. - - vpServo task ; - - // sets the initial camera location - // we give the camera location as a size 6 vector (3 translations in meter - // and 3 rotation (theta U representation) - vpPoseVector c_r_o(0.1,0.2,2, - vpMath::rad(20), vpMath::rad(10), vpMath::rad(50) - ) ; - - // this pose vector is then transformed in a 4x4 homogeneous matrix - vpHomogeneousMatrix cMo(c_r_o) ; - - // We define a robot - // The vpSimulatorCamera implements a simple moving that is juste defined - // by its location cMo - vpSimulatorCamera robot ; - - // Compute the position of the object in the world frame - vpHomogeneousMatrix wMc, wMo; - robot.getPosition(wMc) ; - wMo = wMc * cMo; - - // Now that the current camera position has been defined, - // let us defined the defined camera location. - // It is defined by cdMo - // sets the desired camera location " ) ; - vpPoseVector cd_r_o(0,0,1, - vpMath::rad(0),vpMath::rad(0),vpMath::rad(0)) ; - vpHomogeneousMatrix cdMo(cd_r_o) ; - - //---------------------------------------------------------------------- - // A 2 1/2 D visual servoing can be defined by - // - the position of a point x,y - // - the difference between this point depth and a desire depth - // modeled by log Z/Zd to be regulated to 0 - // - the rotation that the camera has to realized cdMc - - // Let us now defined the current value of these features - - - // since we simulate we have to define a 3D point that will - // forward-projected to define the current position x,y of the - // reference point - - //------------------------------------------------------------------ - // First feature (x,y) - //------------------------------------------------------------------ - // Let oP be this ... point, - // a vpPoint class has three main member - // .oP : 3D coordinates in scene frame - // .cP : 3D coordinates in camera frame - // .p : 2D - - //------------------------------------------------------------------ - // sets the point coordinates in the world frame - vpPoint P ; - // defined point coordinates in the scene frame : oP - P.setWorldCoordinates(0,0,0) ; - // computes the P coordinates in the camera frame and its - // 2D coordinates cP and then p - // computes the point coordinates in the camera frame and its 2D coordinates - P.track(cMo) ; - - // We also defined (again by forward projection) the desired position - // of this point according to the desired camera position - vpPoint Pd ; - Pd.setWorldCoordinates(0,0,0) ; - Pd.track(cdMo) ; - - // Nevertheless, a vpPoint is not a feature, this is just a "tracker" - // from which the feature are built - // a feature is juste defined by a vector s, a way to compute the - // interaction matrix and the error, and if required a (or a vector of) - // 3D information - - // for a point (x,y) Visp implements the vpFeaturePoint class. - // we no defined a feature for x,y (and for (x*,y*)) - vpFeaturePoint p,pd ; - - // and we initialized the vector s=(x,y) of p from the tracker P - // Z coordinates in p is also initialized, it will be used to compute - // the interaction matrix - vpFeatureBuilder::create(p,P) ; - vpFeatureBuilder::create(pd,Pd) ; - - // This visual has to be regulated to zero - - //------------------------------------------------------------------ - // 2nd feature ThetaUz and 3rd feature t - // The thetaU feature is defined, tu represents the rotation that the camera - // has to realized. t the translation. - // the complete displacement is then defined by: - //------------------------------------------------------------------ - vpHomogeneousMatrix cdMc ; - // compute the rotation that the camera has to achieve - cdMc = cdMo*cMo.inverse() ; - - // from this displacement, we extract the rotation cdRc represented by - // the angle theta and the rotation axis u - vpFeatureThetaU tuz(vpFeatureThetaU::cdRc) ; - tuz.buildFrom(cdMc) ; - // And the translations - vpFeatureTranslation t(vpFeatureTranslation::cdMc) ; - t.buildFrom(cdMc) ; - - // This visual has to be regulated to zero - - // sets the desired rotation (always zero !) - // since s is the rotation that the camera has to achieve - - //------------------------------------------------------------------ - // Let us now the task itself - //------------------------------------------------------------------ - - // define the task - // - we want an eye-in-hand control law - // - robot is controlled in the camera frame - // we choose to control the robot in the camera frame - task.setServo(vpServo::EYEINHAND_CAMERA) ; - // Interaction matrix is computed with the current value of s - task.setInteractionMatrixType(vpServo::CURRENT) ; - - // we build the task by "stacking" the visual feature - // previously defined - task.addFeature(t) ; - task.addFeature(p,pd) ; - task.addFeature(tuz,vpFeatureThetaU::TUz) ; //selection of TUz - - // addFeature(X,Xd) means X should be regulated to Xd - // addFeature(X) means that X should be regulated to 0 - // some features such as vpFeatureThetaU MUST be regulated to zero - // (otherwise, it will results in an error at exectution level) - - // set the gain - task.setLambda(1) ; - - // Display task information " ) ; - task.print() ; - //------------------------------------------------------------------ - // An now the closed loop - - unsigned int iter=0 ; - // loop - while(iter++<200) - { - std::cout << "---------------------------------------------" << iter <<std::endl ; - vpColVector v ; - - // get the robot position - robot.getPosition(wMc) ; - // Compute the position of the camera wrt the object frame - cMo = wMc.inverse() * wMo; + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } - // update the feature + std::cout << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << " simulation of a 2 1/2 D visual servoing " << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << std::endl ; + + // In this example we will simulate a visual servoing task. + // In simulation, we have to define the scene frane Ro and the + // camera frame Rc. + // The camera location is given by an homogenous matrix cMo that + // describes the position of the camera in the scene frame. + + vpServo task ; + + // sets the initial camera location + // we give the camera location as a size 6 vector (3 translations in meter + // and 3 rotation (theta U representation) + vpPoseVector c_r_o(0.1,0.2,2, + vpMath::rad(20), vpMath::rad(10), vpMath::rad(50) + ) ; + + // this pose vector is then transformed in a 4x4 homogeneous matrix + vpHomogeneousMatrix cMo(c_r_o) ; + + // We define a robot + // The vpSimulatorCamera implements a simple moving that is juste defined + // by its location cMo + vpSimulatorCamera robot ; + + // Compute the position of the object in the world frame + vpHomogeneousMatrix wMc, wMo; + robot.getPosition(wMc) ; + wMo = wMc * cMo; + + // Now that the current camera position has been defined, + // let us defined the defined camera location. + // It is defined by cdMo + // sets the desired camera location " ) ; + vpPoseVector cd_r_o(0,0,1, + vpMath::rad(0),vpMath::rad(0),vpMath::rad(0)) ; + vpHomogeneousMatrix cdMo(cd_r_o) ; + + //---------------------------------------------------------------------- + // A 2 1/2 D visual servoing can be defined by + // - the position of a point x,y + // - the difference between this point depth and a desire depth + // modeled by log Z/Zd to be regulated to 0 + // - the rotation that the camera has to realized cdMc + + // Let us now defined the current value of these features + + + // since we simulate we have to define a 3D point that will + // forward-projected to define the current position x,y of the + // reference point + + //------------------------------------------------------------------ + // First feature (x,y) + //------------------------------------------------------------------ + // Let oP be this ... point, + // a vpPoint class has three main member + // .oP : 3D coordinates in scene frame + // .cP : 3D coordinates in camera frame + // .p : 2D + + //------------------------------------------------------------------ + // sets the point coordinates in the world frame + vpPoint P ; + // defined point coordinates in the scene frame : oP + P.setWorldCoordinates(0,0,0) ; + // computes the P coordinates in the camera frame and its + // 2D coordinates cP and then p + // computes the point coordinates in the camera frame and its 2D coordinates P.track(cMo) ; - vpFeatureBuilder::create(p,P) ; + // We also defined (again by forward projection) the desired position + // of this point according to the desired camera position + vpPoint Pd ; + Pd.setWorldCoordinates(0,0,0) ; + Pd.track(cdMo) ; + + // Nevertheless, a vpPoint is not a feature, this is just a "tracker" + // from which the feature are built + // a feature is juste defined by a vector s, a way to compute the + // interaction matrix and the error, and if required a (or a vector of) + // 3D information + + // for a point (x,y) Visp implements the vpFeaturePoint class. + // we no defined a feature for x,y (and for (x*,y*)) + vpFeaturePoint p,pd ; + + // and we initialized the vector s=(x,y) of p from the tracker P + // Z coordinates in p is also initialized, it will be used to compute + // the interaction matrix + vpFeatureBuilder::create(p,P) ; + vpFeatureBuilder::create(pd,Pd) ; + + // This visual has to be regulated to zero + + //------------------------------------------------------------------ + // 2nd feature ThetaUz and 3rd feature t + // The thetaU feature is defined, tu represents the rotation that the camera + // has to realized. t the translation. + // the complete displacement is then defined by: + //------------------------------------------------------------------ + vpHomogeneousMatrix cdMc ; + // compute the rotation that the camera has to achieve cdMc = cdMo*cMo.inverse() ; + + // from this displacement, we extract the rotation cdRc represented by + // the angle theta and the rotation axis u + vpFeatureThetaU tuz(vpFeatureThetaU::cdRc) ; tuz.buildFrom(cdMc) ; + // And the translations + vpFeatureTranslation t(vpFeatureTranslation::cdMc) ; t.buildFrom(cdMc) ; - // compute the control law: v = -lambda L^+(s-sd) - v = task.computeControlLaw() ; - - // send the camera velocity to the controller - robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + // This visual has to be regulated to zero + + // sets the desired rotation (always zero !) + // since s is the rotation that the camera has to achieve + + //------------------------------------------------------------------ + // Let us now the task itself + //------------------------------------------------------------------ + + // define the task + // - we want an eye-in-hand control law + // - robot is controlled in the camera frame + // we choose to control the robot in the camera frame + task.setServo(vpServo::EYEINHAND_CAMERA) ; + // Interaction matrix is computed with the current value of s + task.setInteractionMatrixType(vpServo::CURRENT) ; + + // we build the task by "stacking" the visual feature + // previously defined + task.addFeature(t) ; + task.addFeature(p,pd) ; + task.addFeature(tuz,vpFeatureThetaU::TUz) ; //selection of TUz + + // addFeature(X,Xd) means X should be regulated to Xd + // addFeature(X) means that X should be regulated to 0 + // some features such as vpFeatureThetaU MUST be regulated to zero + // (otherwise, it will results in an error at exectution level) + + // set the gain + task.setLambda(1) ; + + // Display task information " ) ; + task.print() ; + //------------------------------------------------------------------ + // An now the closed loop + + unsigned int iter=0 ; + // loop + while(iter++<200) + { + std::cout << "---------------------------------------------" << iter <<std::endl ; + vpColVector v ; + + // get the robot position + robot.getPosition(wMc) ; + // Compute the position of the camera wrt the object frame + cMo = wMc.inverse() * wMo; + + // update the feature + P.track(cMo) ; + vpFeatureBuilder::create(p,P) ; + + cdMc = cdMo*cMo.inverse() ; + tuz.buildFrom(cdMc) ; + t.buildFrom(cdMc) ; + + // compute the control law: v = -lambda L^+(s-sd) + v = task.computeControlLaw() ; + + // send the camera velocity to the controller + robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + + std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; + } - std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; + // Display task information + task.print() ; + task.kill(); + // Final camera location + std::cout << "Final camera location: \n" << cMo << std::endl ; + return 0; + } + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; } - - // Display task information - task.print() ; - task.kill(); - // Final camera location - std::cout << "Final camera location: \n" << cMo << std::endl ; } diff --git a/example/robot-simulator/camera/servoSimuPoint3DCamVelocity.cpp b/example/robot-simulator/camera/servoSimuPoint3DCamVelocity.cpp index 9032832d8826f86a1f8b0e93704463105f6aa653..b2361f4737eb75ea85bbc8b653f92b2fe082d05a 100644 --- a/example/robot-simulator/camera/servoSimuPoint3DCamVelocity.cpp +++ b/example/robot-simulator/camera/servoSimuPoint3DCamVelocity.cpp @@ -3,7 +3,7 @@ * $Id: servoSimuPoint3DCamVelocity.cpp 2457 2010-01-07 10:41:18Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -66,6 +66,9 @@ // List of allowed command line options #define GETOPTARGS "h" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); + /*! Print the program options. @@ -107,15 +110,15 @@ Set the program options. */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -124,7 +127,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -134,92 +137,99 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } - vpServo task ; - vpSimulatorCamera robot ; - - std::cout << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << " Test program for vpServo " <<std::endl ; - std::cout << " Eye-in-hand task control, velocity computed in the camera frame" << std::endl ; - std::cout << " Simulation " << std::endl ; - std::cout << " task : servo a 3D point " << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << std::endl ; - - // sets the initial camera location - vpHomogeneousMatrix cMo ; - cMo[0][3] = 0.1 ; - cMo[1][3] = 0.2 ; - cMo[2][3] = 2 ; - // Compute the position of the object in the world frame - vpHomogeneousMatrix wMc, wMo; - robot.getPosition(wMc) ; - wMo = wMc * cMo; - - // sets the point coordinates in the world frame - vpPoint point ; - point.setWorldCoordinates(0,0,0) ; - - // computes the point coordinates in the camera frame - point.track(cMo) ; - - std::cout << "Point coordinates in the camera frame: " << point.cP.t() ; - - vpFeaturePoint3D p ; - p.buildFrom(point) ; - - // sets the desired position of the point - vpFeaturePoint3D pd ; - pd.set_XYZ(0,0,1) ; - - // define the task - // - we want an eye-in-hand control law - // - robot is controlled in the camera frame - task.setServo(vpServo::EYEINHAND_CAMERA) ; - - // we want to see a point on a point - std::cout << std::endl ; - task.addFeature(p,pd) ; - - // set the gain") ; - task.setLambda(1) ; - - // Display task information - task.print() ; - - unsigned int iter=0 ; - // loop - while(iter++<200) - { - std::cout << "---------------------------------------------" << iter <<std::endl ; - vpColVector v ; - - // get the robot position + vpServo task ; + vpSimulatorCamera robot ; + + std::cout << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << " Test program for vpServo " <<std::endl ; + std::cout << " Eye-in-hand task control, velocity computed in the camera frame" << std::endl ; + std::cout << " Simulation " << std::endl ; + std::cout << " task : servo a 3D point " << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << std::endl ; + + // sets the initial camera location + vpHomogeneousMatrix cMo ; + cMo[0][3] = 0.1 ; + cMo[1][3] = 0.2 ; + cMo[2][3] = 2 ; + // Compute the position of the object in the world frame + vpHomogeneousMatrix wMc, wMo; robot.getPosition(wMc) ; - // Compute the position of the camera wrt the object frame - cMo = wMc.inverse() * wMo; + wMo = wMc * cMo; - // new point position + // sets the point coordinates in the world frame + vpPoint point ; + point.setWorldCoordinates(0,0,0) ; + + // computes the point coordinates in the camera frame point.track(cMo) ; + + std::cout << "Point coordinates in the camera frame: " << point.cP.t() ; + + vpFeaturePoint3D p ; p.buildFrom(point) ; - // std::cout << p.cP.t() ; - // std::cout << (p.get_s()).t() ; - // compute the control law - v = task.computeControlLaw() ; - // send the camera velocity to the controller - robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + // sets the desired position of the point + vpFeaturePoint3D pd ; + pd.set_XYZ(0,0,1) ; + + // define the task + // - we want an eye-in-hand control law + // - robot is controlled in the camera frame + task.setServo(vpServo::EYEINHAND_CAMERA) ; + + // we want to see a point on a point + std::cout << std::endl ; + task.addFeature(p,pd) ; + + // set the gain") ; + task.setLambda(1) ; + + // Display task information + task.print() ; + + unsigned int iter=0 ; + // loop + while(iter++<200) + { + std::cout << "---------------------------------------------" << iter <<std::endl ; + vpColVector v ; + + // get the robot position + robot.getPosition(wMc) ; + // Compute the position of the camera wrt the object frame + cMo = wMc.inverse() * wMo; + + // new point position + point.track(cMo) ; + p.buildFrom(point) ; + // std::cout << p.cP.t() ; + // std::cout << (p.get_s()).t() ; + + // compute the control law + v = task.computeControlLaw() ; + // send the camera velocity to the controller + robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + + std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; + } - std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; + // Display task information + task.print() ; + task.kill(); + return 0; + } + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; } - - // Display task information - task.print() ; - task.kill(); } diff --git a/example/robot-simulator/camera/servoSimuSphere2DCamVelocity.cpp b/example/robot-simulator/camera/servoSimuSphere2DCamVelocity.cpp index 0840404b144696abf355784fdd506e23432de420..9c39af785e7993dbfdfcaf7bd3862f513999a7c5 100644 --- a/example/robot-simulator/camera/servoSimuSphere2DCamVelocity.cpp +++ b/example/robot-simulator/camera/servoSimuSphere2DCamVelocity.cpp @@ -4,7 +4,7 @@ * $Id: servoSimuSphere2DCamVelocity.cpp 2457 2010-01-07 10:41:18Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -66,6 +66,9 @@ // List of allowed command line options #define GETOPTARGS "h" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); + /*! Print the program options. @@ -107,15 +110,15 @@ Set the program options. */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -124,7 +127,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -134,94 +137,100 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } - vpServo task ; - vpSimulatorCamera robot ; - - std::cout << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << " Test program for vpServo " <<std::endl ; - std::cout << " Simulation " << std::endl ; - std::cout << " task : servo a sphere " << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << std::endl ; - - // sets the initial camera location - vpHomogeneousMatrix cMo ; - cMo[0][3] = 0.1 ; - cMo[1][3] = 0.2 ; - cMo[2][3] = 2 ; - // Compute the position of the object in the world frame - vpHomogeneousMatrix wMc, wMo; - robot.getPosition(wMc) ; - wMo = wMc * cMo; - - vpHomogeneousMatrix cMod ; - cMod[0][3] = 0 ; - cMod[1][3] = 0 ; - cMod[2][3] = 1 ; - - // sets the sphere coordinates in the world frame - vpSphere sphere ; - sphere.setWorldCoordinates(0,0,0,0.1) ; - - // sets the desired position of the visual feature - vpFeatureEllipse pd ; - sphere.track(cMod) ; - vpFeatureBuilder::create(pd,sphere) ; - - // computes the sphere coordinates in the camera frame and its 2D coordinates - // sets the current position of the visual feature - vpFeatureEllipse p ; - sphere.track(cMo) ; - vpFeatureBuilder::create(p,sphere) ; - - // define the task - // - we want an eye-in-hand control law - // - robot is controlled in the camera frame - task.setServo(vpServo::EYEINHAND_CAMERA) ; - - // we want to see a sphere on a sphere - task.addFeature(p,pd) ; - - // set the gain - task.setLambda(1) ; - - // Display task information - task.print() ; - - unsigned int iter=0 ; - // loop - while(iter++ < 500) - { - std::cout << "---------------------------------------------" << iter <<std::endl ; - vpColVector v ; - - // get the robot position + vpServo task ; + vpSimulatorCamera robot ; + + std::cout << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << " Test program for vpServo " <<std::endl ; + std::cout << " Simulation " << std::endl ; + std::cout << " task : servo a sphere " << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << std::endl ; + + // sets the initial camera location + vpHomogeneousMatrix cMo ; + cMo[0][3] = 0.1 ; + cMo[1][3] = 0.2 ; + cMo[2][3] = 2 ; + // Compute the position of the object in the world frame + vpHomogeneousMatrix wMc, wMo; robot.getPosition(wMc) ; - // Compute the position of the camera wrt the object frame - cMo = wMc.inverse() * wMo; + wMo = wMc * cMo; + + vpHomogeneousMatrix cMod ; + cMod[0][3] = 0 ; + cMod[1][3] = 0 ; + cMod[2][3] = 1 ; + + // sets the sphere coordinates in the world frame + vpSphere sphere ; + sphere.setWorldCoordinates(0,0,0,0.1) ; - // new sphere position: retrieve x,y and Z of the vpSphere structure + // sets the desired position of the visual feature + vpFeatureEllipse pd ; + sphere.track(cMod) ; + vpFeatureBuilder::create(pd,sphere) ; + + // computes the sphere coordinates in the camera frame and its 2D coordinates + // sets the current position of the visual feature + vpFeatureEllipse p ; sphere.track(cMo) ; - vpFeatureBuilder::create(p,sphere); + vpFeatureBuilder::create(p,sphere) ; - // compute the control law - v = task.computeControlLaw() ; + // define the task + // - we want an eye-in-hand control law + // - robot is controlled in the camera frame + task.setServo(vpServo::EYEINHAND_CAMERA) ; - std::cout << "Task rank: " << task.getTaskRank() << std::endl ; - // send the camera velocity to the controller - robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + // we want to see a sphere on a sphere + task.addFeature(p,pd) ; - std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; - } + // set the gain + task.setLambda(1) ; - // Display task information - task.print() ; - task.kill(); -} + // Display task information + task.print() ; + + unsigned int iter=0 ; + // loop + while(iter++ < 500) + { + std::cout << "---------------------------------------------" << iter <<std::endl ; + vpColVector v ; + // get the robot position + robot.getPosition(wMc) ; + // Compute the position of the camera wrt the object frame + cMo = wMc.inverse() * wMo; + + // new sphere position: retrieve x,y and Z of the vpSphere structure + sphere.track(cMo) ; + vpFeatureBuilder::create(p,sphere); + + // compute the control law + v = task.computeControlLaw() ; + + std::cout << "Task rank: " << task.getTaskRank() << std::endl ; + // send the camera velocity to the controller + robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + + std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; + } + + // Display task information + task.print() ; + task.kill(); + return 0; + } + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; + } +} diff --git a/example/robot-simulator/camera/servoSimuSphere2DCamVelocitySecondaryTask.cpp b/example/robot-simulator/camera/servoSimuSphere2DCamVelocitySecondaryTask.cpp index 76dd01973b1db1c33543a90257485322a12a00c6..340f2dcb5643dbf1af31d3f0ca21456e3cf1b9e2 100644 --- a/example/robot-simulator/camera/servoSimuSphere2DCamVelocitySecondaryTask.cpp +++ b/example/robot-simulator/camera/servoSimuSphere2DCamVelocitySecondaryTask.cpp @@ -3,7 +3,7 @@ * $Id: servoSimuSphere2DCamVelocitySecondaryTask.cpp 2457 2010-01-07 10:41:18Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -67,6 +67,9 @@ // List of allowed command line options #define GETOPTARGS "h" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); + /*! Print the program options. @@ -109,15 +112,15 @@ Set the program options. */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -126,7 +129,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -136,107 +139,114 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } - vpServo task ; - vpSimulatorCamera robot ; - - std::cout << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << " Test program for vpServo " <<std::endl ; - std::cout << " Simulation " << std::endl ; - std::cout << " task : servo a sphere with a secondary task" << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << std::endl ; - - - // sets the initial camera location - vpHomogeneousMatrix cMo ; - cMo[0][3] = 0.1 ; - cMo[1][3] = 0.2 ; - cMo[2][3] = 2 ; - // Compute the position of the object in the world frame - vpHomogeneousMatrix wMc, wMo; - robot.getPosition(wMc) ; - wMo = wMc * cMo; - - vpHomogeneousMatrix cMod ; - cMod[0][3] = 0 ; - cMod[1][3] = 0 ; - cMod[2][3] = 1 ; - - // sets the sphere coordinates in the world frame - vpSphere sphere ; - sphere.setWorldCoordinates(0,0,0,0.1) ; - - // sets the desired position of the visual feature - vpFeatureEllipse pd ; - sphere.track(cMod) ; - vpFeatureBuilder::create(pd,sphere) ; - - // computes the sphere coordinates in the camera frame and its 2D coordinates - // sets the current position of the visual feature - vpFeatureEllipse p ; - sphere.track(cMo) ; - vpFeatureBuilder::create(p,sphere) ; - - // define the task - // - we want an eye-in-hand control law - // - robot is controlled in the camera frame - task.setServo(vpServo::EYEINHAND_CAMERA) ; - - // we want to see a sphere on a sphere - std::cout << std::endl ; - task.addFeature(p,pd) ; - - // set the gain - task.setLambda(1) ; - - // Display task information - task.print() ; - // exit(1) ; - unsigned int iter=0 ; - // loop - while(iter++ < 500) - { - std::cout << "---------------------------------------------" << iter <<std::endl ; - vpColVector v ; - - // get the robot position + vpServo task ; + vpSimulatorCamera robot ; + + std::cout << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << " Test program for vpServo " <<std::endl ; + std::cout << " Simulation " << std::endl ; + std::cout << " task : servo a sphere with a secondary task" << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << std::endl ; + + + // sets the initial camera location + vpHomogeneousMatrix cMo ; + cMo[0][3] = 0.1 ; + cMo[1][3] = 0.2 ; + cMo[2][3] = 2 ; + // Compute the position of the object in the world frame + vpHomogeneousMatrix wMc, wMo; robot.getPosition(wMc) ; - // Compute the position of the camera wrt the object frame - cMo = wMc.inverse() * wMo; - - // new sphere position: retrieve x,y and Z of the vpSphere structure - sphere.track(cMo) ; - vpFeatureBuilder::create(p,sphere); + wMo = wMc * cMo; - vpColVector de2dt(6) ; - de2dt[2] = 1 ; // should be zero in (I-WpW)de2dt - de2dt[5] = 0.01 ; // should be ok - de2dt[0] = 0.01 ; // should generate a motion on (I-WpW)de2dt[4] + vpHomogeneousMatrix cMod ; + cMod[0][3] = 0 ; + cMod[1][3] = 0 ; + cMod[2][3] = 1 ; - // compute the control law - v = task.computeControlLaw() ; + // sets the sphere coordinates in the world frame + vpSphere sphere ; + sphere.setWorldCoordinates(0,0,0,0.1) ; - std::cout << "de2dt :"<< de2dt.t() << std::endl; - vpColVector sec ; - sec = task.secondaryTask(de2dt) ; - std::cout << "(I-WpW)de2dt :"<< sec.t() << std::endl; + // sets the desired position of the visual feature + vpFeatureEllipse pd ; + sphere.track(cMod) ; + vpFeatureBuilder::create(pd,sphere) ; - if (iter>20) v += sec ; - - // send the camera velocity to the controller - robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + // computes the sphere coordinates in the camera frame and its 2D coordinates + // sets the current position of the visual feature + vpFeatureEllipse p ; + sphere.track(cMo) ; + vpFeatureBuilder::create(p,sphere) ; + + // define the task + // - we want an eye-in-hand control law + // - robot is controlled in the camera frame + task.setServo(vpServo::EYEINHAND_CAMERA) ; + + // we want to see a sphere on a sphere + std::cout << std::endl ; + task.addFeature(p,pd) ; + + // set the gain + task.setLambda(1) ; + + // Display task information + task.print() ; + // exit(1) ; + unsigned int iter=0 ; + // loop + while(iter++ < 500) + { + std::cout << "---------------------------------------------" << iter <<std::endl ; + vpColVector v ; + + // get the robot position + robot.getPosition(wMc) ; + // Compute the position of the camera wrt the object frame + cMo = wMc.inverse() * wMo; + + // new sphere position: retrieve x,y and Z of the vpSphere structure + sphere.track(cMo) ; + vpFeatureBuilder::create(p,sphere); + + vpColVector de2dt(6) ; + de2dt[2] = 1 ; // should be zero in (I-WpW)de2dt + de2dt[5] = 0.01 ; // should be ok + de2dt[0] = 0.01 ; // should generate a motion on (I-WpW)de2dt[4] + + // compute the control law + v = task.computeControlLaw() ; + + std::cout << "de2dt :"<< de2dt.t() << std::endl; + vpColVector sec ; + sec = task.secondaryTask(de2dt) ; + std::cout << "(I-WpW)de2dt :"<< sec.t() << std::endl; + + if (iter>20) v += sec ; + + // send the camera velocity to the controller + robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + + std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; + } - std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; + // Display task information + task.print() ; + task.kill(); + return 0; + } + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; } - - // Display task information - task.print() ; - task.kill(); } diff --git a/example/robot-simulator/camera/servoSimuSquareLine2DCamVelocityDisplay.cpp b/example/robot-simulator/camera/servoSimuSquareLine2DCamVelocityDisplay.cpp index 487b66f86a54aa50527366c4434ff1a497f4e15e..dc5da979ca921ef00a11237c523d7f9ee79ed3f3 100644 --- a/example/robot-simulator/camera/servoSimuSquareLine2DCamVelocityDisplay.cpp +++ b/example/robot-simulator/camera/servoSimuSquareLine2DCamVelocityDisplay.cpp @@ -4,7 +4,7 @@ * $Id: servoSimuSquareLine2DCamVelocityDisplay.cpp 2457 2010-01-07 10:41:18Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -77,6 +77,9 @@ // List of allowed command line options #define GETOPTARGS "cdh" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display); + /*! Print the program options. @@ -127,9 +130,9 @@ Set the program options. */ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; @@ -137,7 +140,7 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) case 'h': usage(argv[0], NULL); return false; break; default: - usage(argv[0], optarg); + usage(argv[0], optarg_); return false; break; } } @@ -146,7 +149,7 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -157,170 +160,177 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) int main(int argc, const char ** argv) { - bool opt_display = true; - bool opt_click_allowed = true; + try { + bool opt_display = true; + bool opt_click_allowed = true; - // Read the command line options - if (getOptions(argc, argv, opt_click_allowed, opt_display) == false) { - exit (-1); - } + // Read the command line options + if (getOptions(argc, argv, opt_click_allowed, opt_display) == false) { + exit (-1); + } - vpImage<unsigned char> I(512,512,0) ; + vpImage<unsigned char> I(512,512,0) ; - // We open a window using either X11, GTK or GDI. + // We open a window using either X11, GTK or GDI. #if defined VISP_HAVE_X11 - vpDisplayX display; + vpDisplayX display; #elif defined VISP_HAVE_GTK - vpDisplayGTK display; + vpDisplayGTK display; #elif defined VISP_HAVE_GDI - vpDisplayGDI display; + vpDisplayGDI display; #endif - if (opt_display) { - try{ - // Display size is automatically defined by the image (I) size - display.init(I, 100, 100,"Camera view...") ; - // 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) ; - vpDisplay::flush(I) ; - } - catch(...) - { - vpERROR_TRACE("Error while displaying the image") ; - exit(-1); + if (opt_display) { + try{ + // Display size is automatically defined by the image (I) size + display.init(I, 100, 100,"Camera view...") ; + // 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) ; + vpDisplay::flush(I) ; + } + catch(...) + { + vpERROR_TRACE("Error while displaying the image") ; + exit(-1); + } } - } - // Set the camera parameters - double px, py ; px = py = 600 ; - double u0, v0 ; u0 = v0 = 256 ; + // Set the camera parameters + double px, py ; px = py = 600 ; + double u0, v0 ; u0 = v0 = 256 ; - vpCameraParameters cam(px,py,u0,v0); + vpCameraParameters cam(px,py,u0,v0); - vpServo task ; - vpSimulatorCamera robot ; + vpServo task ; + vpSimulatorCamera robot ; - // sets the initial camera location - vpHomogeneousMatrix cMo(0.2,0.2,1, - vpMath::rad(45), vpMath::rad(45), vpMath::rad(125)); + // sets the initial camera location + vpHomogeneousMatrix cMo(0.2,0.2,1, + vpMath::rad(45), vpMath::rad(45), vpMath::rad(125)); - // Compute the position of the object in the world frame - vpHomogeneousMatrix wMc, wMo; - robot.getPosition(wMc) ; - wMo = wMc * cMo; + // Compute the position of the object in the world frame + vpHomogeneousMatrix wMc, wMo; + robot.getPosition(wMc) ; + wMo = wMc * cMo; - // sets the final camera location (for simulation purpose) - vpHomogeneousMatrix cMod(0,0,1, - vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); + // sets the final camera location (for simulation purpose) + vpHomogeneousMatrix cMod(0,0,1, + vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); - int nbline = 4; + int nbline = 4; - // sets the line coordinates (2 planes) in the world frame - vpLine line[4] ; - line[0].setWorldCoordinates(1,0,0,0.05,0,0,1,0); - line[1].setWorldCoordinates(0,1,0,0.05,0,0,1,0); - line[2].setWorldCoordinates(1,0,0,-0.05,0,0,1,0); - line[3].setWorldCoordinates(0,1,0,-0.05,0,0,1,0); + // sets the line coordinates (2 planes) in the world frame + vpLine line[4] ; + line[0].setWorldCoordinates(1,0,0,0.05,0,0,1,0); + line[1].setWorldCoordinates(0,1,0,0.05,0,0,1,0); + line[2].setWorldCoordinates(1,0,0,-0.05,0,0,1,0); + line[3].setWorldCoordinates(0,1,0,-0.05,0,0,1,0); - vpFeatureLine ld[4] ; - vpFeatureLine l[4] ; + vpFeatureLine ld[4] ; + vpFeatureLine l[4] ; - // sets the desired position of the visual feature - for(int i = 0; i < nbline; i++) - { - line[i].track(cMod) ; - line[i].print() ; + // sets the desired position of the visual feature + for(int i = 0; i < nbline; i++) + { + line[i].track(cMod) ; + line[i].print() ; - vpFeatureBuilder::create(ld[i],line[i]) ; - } + vpFeatureBuilder::create(ld[i],line[i]) ; + } - // computes the line coordinates in the camera frame and its 2D coordinates - // sets the current position of the visual feature - for(int i = 0; i < nbline; i++) - { - line[i].track(cMo) ; - line[i].print() ; + // computes the line coordinates in the camera frame and its 2D coordinates + // sets the current position of the visual feature + for(int i = 0; i < nbline; i++) + { + line[i].track(cMo) ; + line[i].print() ; - vpFeatureBuilder::create(l[i],line[i]) ; - l[i].print() ; - } + vpFeatureBuilder::create(l[i],line[i]) ; + l[i].print() ; + } - // define the task - // - we want an eye-in-hand control law - // - robot is controlled in the camera frame - task.setServo(vpServo::EYEINHAND_CAMERA) ; - task.setInteractionMatrixType(vpServo::CURRENT, vpServo::PSEUDO_INVERSE); - //It could be also interesting to test the following tasks - //task.setInteractionMatrixType(vpServo::DESIRED, vpServo::PSEUDO_INVERSE); - //task.setInteractionMatrixType(vpServo::MEAN, vpServo::PSEUDO_INVERSE); + // define the task + // - we want an eye-in-hand control law + // - robot is controlled in the camera frame + task.setServo(vpServo::EYEINHAND_CAMERA) ; + task.setInteractionMatrixType(vpServo::CURRENT, vpServo::PSEUDO_INVERSE); + //It could be also interesting to test the following tasks + //task.setInteractionMatrixType(vpServo::DESIRED, vpServo::PSEUDO_INVERSE); + //task.setInteractionMatrixType(vpServo::MEAN, vpServo::PSEUDO_INVERSE); - // we want to see a four lines on four lines - for(int i = 0; i < nbline; i++) - task.addFeature(l[i],ld[i]) ; + // we want to see a four lines on four lines + for(int i = 0; i < nbline; i++) + task.addFeature(l[i],ld[i]) ; - vpDisplay::display(I) ; - vpServoDisplay::display(task,cam,I) ; - vpDisplay::flush(I) ; + vpDisplay::display(I) ; + vpServoDisplay::display(task,cam,I) ; + vpDisplay::flush(I) ; - // set the gain - task.setLambda(1) ; + // set the gain + task.setLambda(1) ; - // Display task information - task.print() ; + // Display task information + task.print() ; - if (opt_display && opt_click_allowed) { - std::cout << "\n\nClick in the camera view window to start..." << std::endl; - vpDisplay::getClick(I) ; - } + if (opt_display && opt_click_allowed) { + std::cout << "\n\nClick in the camera view window to start..." << std::endl; + vpDisplay::getClick(I) ; + } - unsigned int iter=0 ; - // loop - while(iter++<200) - { - std::cout << "---------------------------------------------" << iter <<std::endl ; - vpColVector v ; + unsigned int iter=0 ; + // loop + while(iter++<200) + { + std::cout << "---------------------------------------------" << iter <<std::endl ; + vpColVector v ; - // get the robot position - robot.getPosition(wMc) ; - // Compute the position of the camera wrt the object frame - cMo = wMc.inverse() * wMo; + // get the robot position + robot.getPosition(wMc) ; + // Compute the position of the camera wrt the object frame + cMo = wMc.inverse() * wMo; - // new line position: retrieve x,y and Z of the vpLine structure - for(int i = 0; i < nbline; i++) - { - line[i].track(cMo) ; - vpFeatureBuilder::create(l[i],line[i]); - } + // new line position: retrieve x,y and Z of the vpLine structure + for(int i = 0; i < nbline; i++) + { + line[i].track(cMo) ; + vpFeatureBuilder::create(l[i],line[i]); + } - if (opt_display) { - vpDisplay::display(I) ; - vpServoDisplay::display(task,cam,I) ; - vpDisplay::flush(I) ; - } + if (opt_display) { + vpDisplay::display(I) ; + vpServoDisplay::display(task,cam,I) ; + vpDisplay::flush(I) ; + } - // compute the control law - v = task.computeControlLaw() ; + // compute the control law + v = task.computeControlLaw() ; - // send the camera velocity to the controller - robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + // send the camera velocity to the controller + robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; - std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; ; + std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; ; - } + } - if (opt_display && opt_click_allowed) { - std::cout << "\nClick in the camera view window to end..." << std::endl; - vpDisplay::getClick(I) ; - } + if (opt_display && opt_click_allowed) { + std::cout << "\nClick in the camera view window to end..." << std::endl; + vpDisplay::getClick(I) ; + } - // Display task information - task.print() ; - task.kill(); + // Display task information + task.print() ; + task.kill(); + return 0; + } + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; + } } #else diff --git a/example/robot-simulator/camera/servoSimuThetaUCamVelocity.cpp b/example/robot-simulator/camera/servoSimuThetaUCamVelocity.cpp index fe54722307ec10bfb6ef42f74ea67e51c5fadaed..b28ab523f3c18585aa8fb2b664cd70fb8a53fb7e 100644 --- a/example/robot-simulator/camera/servoSimuThetaUCamVelocity.cpp +++ b/example/robot-simulator/camera/servoSimuThetaUCamVelocity.cpp @@ -3,7 +3,7 @@ * $Id: servoSimuThetaUCamVelocity.cpp 2457 2010-01-07 10:41:18Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -66,7 +66,8 @@ // List of allowed command line options #define GETOPTARGS "h" - +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); /*! Print the program options. @@ -108,15 +109,15 @@ Set the program options. */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -125,7 +126,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -135,88 +136,95 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } - vpServo task ; - vpSimulatorCamera robot ; + vpServo task ; + vpSimulatorCamera robot ; - std::cout << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << " Test program for vpServo " <<std::endl ; - std::cout << " Eye-in-hand task control, velocity computed in the camera frame" << std::endl ; - std::cout << " Simulation " << std::endl ; - std::cout << " task : servo using theta U visual feature " << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << std::endl ; + std::cout << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << " Test program for vpServo " <<std::endl ; + std::cout << " Eye-in-hand task control, velocity computed in the camera frame" << std::endl ; + std::cout << " Simulation " << std::endl ; + std::cout << " task : servo using theta U visual feature " << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << std::endl ; - // sets the initial camera location - vpPoseVector c_r_o(0.1,0.2,2, - vpMath::rad(20), vpMath::rad(10), vpMath::rad(50) - ) ; + // sets the initial camera location + vpPoseVector c_r_o(0.1,0.2,2, + vpMath::rad(20), vpMath::rad(10), vpMath::rad(50) + ) ; - vpHomogeneousMatrix cMo(c_r_o) ; - // Compute the position of the object in the world frame - vpHomogeneousMatrix wMc, wMo; - robot.getPosition(wMc) ; - wMo = wMc * cMo; + vpHomogeneousMatrix cMo(c_r_o) ; + // Compute the position of the object in the world frame + vpHomogeneousMatrix wMc, wMo; + robot.getPosition(wMc) ; + wMo = wMc * cMo; - // sets the desired camera location - vpPoseVector cd_r_o(0,0,1, - vpMath::rad(0),vpMath::rad(0),vpMath::rad(0)) ; - vpHomogeneousMatrix cdMo(cd_r_o) ; + // sets the desired camera location + vpPoseVector cd_r_o(0,0,1, + vpMath::rad(0),vpMath::rad(0),vpMath::rad(0)) ; + vpHomogeneousMatrix cdMo(cd_r_o) ; - // compute the rotation that the camera has to realize - vpHomogeneousMatrix cdMc ; - cdMc = cdMo*cMo.inverse() ; - vpFeatureThetaU tu(vpFeatureThetaU::cdRc) ; - tu.buildFrom(cdMc) ; + // compute the rotation that the camera has to realize + vpHomogeneousMatrix cdMc ; + cdMc = cdMo*cMo.inverse() ; + vpFeatureThetaU tu(vpFeatureThetaU::cdRc) ; + tu.buildFrom(cdMc) ; - // define the task - // - we want an eye-in-hand control law - // - robot is controlled in the camera frame - task.setServo(vpServo::EYEINHAND_CAMERA) ; - task.setInteractionMatrixType(vpServo::DESIRED) ; + // define the task + // - we want an eye-in-hand control law + // - robot is controlled in the camera frame + task.setServo(vpServo::EYEINHAND_CAMERA) ; + task.setInteractionMatrixType(vpServo::DESIRED) ; - task.addFeature(tu) ; + task.addFeature(tu) ; - // - set the gain - task.setLambda(1) ; + // - set the gain + task.setLambda(1) ; - // Display task information - task.print() ; + // Display task information + task.print() ; - unsigned int iter=0 ; - // loop - while(iter++ < 200) - { - std::cout << "---------------------------------------------" << iter <<std::endl ; - vpColVector v ; + unsigned int iter=0 ; + // loop + while(iter++ < 200) + { + std::cout << "---------------------------------------------" << iter <<std::endl ; + vpColVector v ; - // get the robot position - robot.getPosition(wMc) ; - // Compute the position of the camera wrt the object frame - cMo = wMc.inverse() * wMo; + // get the robot position + robot.getPosition(wMc) ; + // Compute the position of the camera wrt the object frame + cMo = wMc.inverse() * wMo; - // new rotation to achieve - cdMc = cdMo*cMo.inverse() ; - tu.buildFrom(cdMc) ; + // new rotation to achieve + cdMc = cdMo*cMo.inverse() ; + tu.buildFrom(cdMc) ; - // compute the control law - v = task.computeControlLaw() ; + // compute the control law + v = task.computeControlLaw() ; - // send the camera velocity to the controller - robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + // send the camera velocity to the controller + robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; - std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; ; - } + std::cout << "|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ; ; + } - // Display task information - task.print() ; - task.kill(); + // Display task information + task.print() ; + task.kill(); + return 0; + } + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; + } } diff --git a/example/robot-simulator/viper850/CMakeLists.txt b/example/robot-simulator/viper850/CMakeLists.txt index c3ea7c65612ec57502e5e7d33a87f3ccd952d35c..e33e6c99c3344c20d300272f1610c3e48865ecf9 100644 --- a/example/robot-simulator/viper850/CMakeLists.txt +++ b/example/robot-simulator/viper850/CMakeLists.txt @@ -3,7 +3,7 @@ # $Id: CMakeLists.txt 2457 2010-01-07 10:41:18Z nmelchio $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/robot-simulator/viper850/servoSimuViper850FourPoints2DCamVelocity.cpp b/example/robot-simulator/viper850/servoSimuViper850FourPoints2DCamVelocity.cpp index 089be393d0633cb5bc4c1fc8c3e61de7f7753df6..f00a4760a896ef005cdd0056c9f258c65a3cf007 100644 --- a/example/robot-simulator/viper850/servoSimuViper850FourPoints2DCamVelocity.cpp +++ b/example/robot-simulator/viper850/servoSimuViper850FourPoints2DCamVelocity.cpp @@ -3,7 +3,7 @@ * $Id: servoSimuFourPoints2DPolarCamVelocityDisplay.cpp 2503 2010-02-16 18:55:01Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -60,7 +60,7 @@ #include <visp/vpDebug.h> #include <visp/vpConfig.h> -#if (defined(WIN32) || defined(VISP_HAVE_PTHREAD)) && (defined (VISP_HAVE_X11) || defined(VISP_HAVE_OPENCV) || defined(VISP_HAVE_GDI)) +#if (defined(_WIN32) || defined(VISP_HAVE_PTHREAD)) && (defined (VISP_HAVE_X11) || defined(VISP_HAVE_OPENCV) || defined(VISP_HAVE_GDI)) // We need to use threading capabilities. Thus on Unix-like // platforms, the libpthread third-party library need to be @@ -88,6 +88,9 @@ // List of allowed command line options #define GETOPTARGS "cdh" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display); + /*! Print the program options. @@ -137,9 +140,9 @@ Set the program options. */ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; @@ -147,7 +150,7 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) case 'h': usage(argv[0], NULL); return false; break; default: - usage(argv[0], optarg); + usage(argv[0], optarg_); return false; break; } } @@ -156,7 +159,7 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -166,194 +169,194 @@ bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display) int main(int argc, const char ** argv) { - bool opt_click_allowed = true; - bool opt_display = true; + try { + 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); - } + // Read the command line options + if (getOptions(argc, argv, opt_click_allowed, opt_display) == false) { + exit (-1); + } - // We open two displays, one for the internal camera view, the other one for - // the external view, using either X11, GTK or GDI. + // We open two displays, one for the internal camera view, the other one for + // the external view, using either X11, GTK or GDI. #if defined VISP_HAVE_X11 - vpDisplayX displayInt; + vpDisplayX displayInt; #elif defined VISP_HAVE_GDI - vpDisplayGDI displayInt; + vpDisplayGDI displayInt; #elif defined VISP_HAVE_OPENCV - vpDisplayOpenCV displayInt; + vpDisplayOpenCV displayInt; #endif - // open a display for the visualization + // open a display for the visualization - vpImage<unsigned char> Iint(480, 640, 255); + vpImage<unsigned char> Iint(480, 640, 255); - if (opt_display) { - displayInt.init(Iint,700,0, "Internal view") ; - } - - int i; - vpServo task; - - std::cout << std::endl ; - std::cout << "----------------------------------------------" << std::endl ; - std::cout << " Test program for vpServo " <<std::endl ; - std::cout << " Eye-in-hand task control, articular velocity are computed" - << std::endl ; - std::cout << " Simulation " << std::endl ; - std::cout << " task : servo 4 points " << std::endl ; - std::cout << "----------------------------------------------" << std::endl ; - std::cout << std::endl ; - - // sets the initial camera location - vpHomogeneousMatrix cMo(-0.05,-0.05,0.7, - vpMath::rad(10), vpMath::rad(10), vpMath::rad(-30)); - - - // sets the point coordinates in the object frame - vpPoint point[4] ; - point[0].setWorldCoordinates(-0.045,-0.045,0) ; - point[3].setWorldCoordinates(-0.045,0.045,0) ; - point[2].setWorldCoordinates(0.045,0.045,0) ; - point[1].setWorldCoordinates(0.045,-0.045,0) ; - - // computes the point coordinates in the camera frame and its 2D coordinates - for (i = 0 ; i < 4 ; i++) - point[i].track(cMo) ; - - // 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 - - // sets the desired position of the feature point s* - vpFeaturePoint pd[4] ; - - //Desired pose - vpHomogeneousMatrix cdMo(vpHomogeneousMatrix(0.0,0.0,0.8,vpMath::rad(0),vpMath::rad(0),vpMath::rad(0))); - - // Projection of the points - for (int i = 0 ; i < 4 ; i++) - point[i].track(cdMo); - - for (int i = 0 ; i < 4 ; i++) - vpFeatureBuilder::create(pd[i], point[i]); - - // define the task - // - we want an eye-in-hand control law - // - articular velocity are computed - task.setServo(vpServo::EYEINHAND_CAMERA); - task.setInteractionMatrixType(vpServo::DESIRED) ; - - // - we want to see a point on a point - for (i = 0 ; i < 4 ; i++) - task.addFeature(p[i],pd[i]) ; - - // set the gain - task.setLambda(0.8) ; - - // Declaration of the robot - vpSimulatorViper850 robot(opt_display); - - // Initialise the robot and especially the camera - robot.init(vpViper850::TOOL_PTGREY_FLEA2_CAMERA,vpCameraParameters::perspectiveProjWithoutDistortion); - robot.setRobotState(vpRobot::STATE_VELOCITY_CONTROL); - - // Initialise the object for the display part - robot.initScene(vpWireFrameSimulator::PLATE, 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 display part) - robot.setDesiredCameraPosition(cdMo); - - // Get the internal robot's camera parameters - vpCameraParameters cam; - robot.getCameraParameters(cam,Iint); - - if (opt_display) - { - //Get the internal view - vpDisplay::display(Iint); - robot.getInternalView(Iint); - vpDisplay::flush(Iint); - } + if (opt_display) { + displayInt.init(Iint,700,0, "Internal view") ; + } - // Display task information - task.print() ; + vpServo task; - unsigned int iter=0 ; - // loop - while(iter++<500) - { - std::cout << "---------------------------------------------" << iter <<std::endl ; - vpColVector v ; + std::cout << std::endl ; + std::cout << "----------------------------------------------" << std::endl ; + std::cout << " Test program for vpServo " <<std::endl ; + std::cout << " Eye-in-hand task control, articular velocity are computed" + << std::endl ; + std::cout << " Simulation " << std::endl ; + std::cout << " task : servo 4 points " << std::endl ; + std::cout << "----------------------------------------------" << std::endl ; + std::cout << std::endl ; - //Get the Time at the beginning of the loop - double t = vpTime::measureTimeMs(); + // sets the initial camera location + vpHomogeneousMatrix cMo(-0.05,-0.05,0.7, + vpMath::rad(10), vpMath::rad(10), vpMath::rad(-30)); - //Get the current pose of the camera - cMo = robot.get_cMo(); - if (iter==1) { - std::cout <<"Initial robot position with respect to the object frame:\n"; - cMo.print(); - } + // sets the point coordinates in the object frame + vpPoint point[4] ; + point[0].setWorldCoordinates(-0.045,-0.045,0) ; + point[3].setWorldCoordinates(-0.045,0.045,0) ; + point[2].setWorldCoordinates(0.045,0.045,0) ; + point[1].setWorldCoordinates(0.045,-0.045,0) ; - // new point position - for (i = 0 ; i < 4 ; i++) - { + // computes the point coordinates in the camera frame and its 2D coordinates + for (unsigned int i = 0 ; i < 4 ; i++) point[i].track(cMo) ; - //retrieve x,y and Z of the vpPoint structure - try { - vpFeatureBuilder::create(p[i],point[i]) ; - } - catch(...) - { - break; - } - } + + // sets the desired position of the point + vpFeaturePoint p[4] ; + for (unsigned int i = 0 ; i < 4 ; i++) + vpFeatureBuilder::create(p[i],point[i]) ; //retrieve x,y and Z of the vpPoint structure + + // sets the desired position of the feature point s* + vpFeaturePoint pd[4] ; + + //Desired pose + vpHomogeneousMatrix cdMo(vpHomogeneousMatrix(0.0,0.0,0.8,vpMath::rad(0),vpMath::rad(0),vpMath::rad(0))); + + // Projection of the points + for (unsigned int i = 0 ; i < 4 ; i++) + point[i].track(cdMo); + + for (unsigned int i = 0 ; i < 4 ; i++) + vpFeatureBuilder::create(pd[i], point[i]); + + // define the task + // - we want an eye-in-hand control law + // - articular velocity are computed + task.setServo(vpServo::EYEINHAND_CAMERA); + task.setInteractionMatrixType(vpServo::DESIRED) ; + + // - we want to see a point on a point + for (unsigned int i = 0 ; i < 4 ; i++) + task.addFeature(p[i],pd[i]) ; + + // set the gain + task.setLambda(0.8) ; + + // Declaration of the robot + vpSimulatorViper850 robot(opt_display); + + // Initialise the robot and especially the camera + robot.init(vpViper850::TOOL_PTGREY_FLEA2_CAMERA,vpCameraParameters::perspectiveProjWithoutDistortion); + robot.setRobotState(vpRobot::STATE_VELOCITY_CONTROL); + + // Initialise the object for the display part + robot.initScene(vpWireFrameSimulator::PLATE, 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 display part) + robot.setDesiredCameraPosition(cdMo); + + // Get the internal robot's camera parameters + vpCameraParameters cam; + robot.getCameraParameters(cam,Iint); if (opt_display) { - // Get the internal view and display it - vpDisplay::display(Iint) ; + //Get the internal view + vpDisplay::display(Iint); robot.getInternalView(Iint); vpDisplay::flush(Iint); } - if (opt_display && opt_click_allowed && iter == 1) + // Display task information + task.print() ; + + unsigned int iter=0 ; + // loop + while(iter++<500) { - // suppressed for automate test - std::cout << "Click in the internal view window to continue..." << std::endl; - vpDisplay::getClick(Iint) ; - } + std::cout << "---------------------------------------------" << iter <<std::endl ; + vpColVector v ; - // compute the control law - v = task.computeControlLaw() ; + //Get the Time at the beginning of the loop + double t = vpTime::measureTimeMs(); - // send the camera velocity to the controller - robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + //Get the current pose of the camera + cMo = robot.get_cMo(); - std::cout << "|| s - s* || " << ( task.getError() ).sumSquare() <<std::endl ; + if (iter==1) { + std::cout <<"Initial robot position with respect to the object frame:\n"; + cMo.print(); + } - // The main loop has a duration of 10 ms at minimum - vpTime::wait(t,10); - } + // new point position + for (unsigned int i = 0 ; i < 4 ; i++) + { + point[i].track(cMo) ; + //retrieve x,y and Z of the vpPoint structure + vpFeatureBuilder::create(p[i],point[i]) ; + } + + if (opt_display) + { + // Get the internal view and display it + vpDisplay::display(Iint) ; + robot.getInternalView(Iint); + vpDisplay::flush(Iint); + } - // Display task information - task.print() ; - task.kill(); + if (opt_display && opt_click_allowed && iter == 1) + { + // suppressed for automate test + std::cout << "Click in the internal view window to continue..." << std::endl; + vpDisplay::getClick(Iint) ; + } + + // compute the control law + v = task.computeControlLaw() ; + + // send the camera velocity to the controller + robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + + std::cout << "|| s - s* || " << ( task.getError() ).sumSquare() <<std::endl ; + + // The main loop has a duration of 10 ms at minimum + vpTime::wait(t,10); + } - std::cout <<"Final robot position with respect to the object frame:\n"; - cMo.print(); + // Display task information + task.print() ; + task.kill(); - if (opt_display && opt_click_allowed) - { - // suppressed for automate test - std::cout << "Click in the internal view window to end..." << std::endl; - vpDisplay::getClick(Iint) ; + std::cout <<"Final robot position with respect to the object frame:\n"; + cMo.print(); + + if (opt_display && opt_click_allowed) + { + // suppressed for automate test + std::cout << "Click in the internal view window to end..." << std::endl; + vpDisplay::getClick(Iint) ; + } + return 0; + } + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; } } #else diff --git a/example/servo-afma4/CMakeLists.txt b/example/servo-afma4/CMakeLists.txt index 33f25e09642e0d8b4a61e765c74424d67786ab36..d7be99ed9fa297aed1e1818c5728fd8c8884f71d 100644 --- a/example/servo-afma4/CMakeLists.txt +++ b/example/servo-afma4/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/servo-afma4/moveAfma4.cpp b/example/servo-afma4/moveAfma4.cpp index 3cb1cae3a3932dd06c893bd2b2efa74e1063c4bb..f889ed7a739770dee7b1de6e08ccc3fb424f9e7c 100644 --- a/example/servo-afma4/moveAfma4.cpp +++ b/example/servo-afma4/moveAfma4.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: moveAfma4.cpp 4086 2013-02-02 07:26:19Z fspindle $ + * $Id: moveAfma4.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -241,11 +241,12 @@ main(int argc, const char ** argv) sleep(5) ; std::cout << "The end" << std::endl; + return 0; } - catch (...) { - vpERROR_TRACE(" Test failed") ; + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; } - return 0; } #else int diff --git a/example/servo-afma4/servoAfma4Point2DArtVelocity.cpp b/example/servo-afma4/servoAfma4Point2DArtVelocity.cpp index 01f8f4281f74edf54748bb50cd83f4ab0b9ec7be..53763b0ca9a2fd6c9d1480b977038fb4d7594634 100644 --- a/example/servo-afma4/servoAfma4Point2DArtVelocity.cpp +++ b/example/servo-afma4/servoAfma4Point2DArtVelocity.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoAfma4Point2DArtVelocity.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: servoAfma4Point2DArtVelocity.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -101,40 +101,40 @@ int main() { - // Log file creation in /tmp/$USERNAME/log.dat - // This file contains by line: - // - the 6 computed joint velocities (m/s, rad/s) to achieve the task - // - the 6 mesured joint velocities (m/s, rad/s) - // - the 6 mesured joint positions (m, rad) - // - the 2 values of s - s* - std::string username; - // Get the user login name - vpIoTools::getUserName(username); - - // Create a log filename to save velocities... - std::string logdirname; - logdirname ="/tmp/" + username; - - // Test if the output path exist. If no try to create it - if (vpIoTools::checkDirectory(logdirname) == false) { - try { - // Create the dirname - vpIoTools::makeDirectory(logdirname); - } - catch (...) { - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Cannot create " << logdirname << std::endl; - exit(-1); + try { + // Log file creation in /tmp/$USERNAME/log.dat + // This file contains by line: + // - the 6 computed joint velocities (m/s, rad/s) to achieve the task + // - the 6 mesured joint velocities (m/s, rad/s) + // - the 6 mesured joint positions (m, rad) + // - the 2 values of s - s* + std::string username; + // Get the user login name + vpIoTools::getUserName(username); + + // Create a log filename to save velocities... + std::string logdirname; + logdirname ="/tmp/" + username; + + // Test if the output path exist. If no try to create it + if (vpIoTools::checkDirectory(logdirname) == false) { + try { + // Create the dirname + vpIoTools::makeDirectory(logdirname); + } + catch (...) { + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Cannot create " << logdirname << std::endl; + exit(-1); + } } - } - std::string logfilename; - logfilename = logdirname + "/log.dat"; + std::string logfilename; + logfilename = logdirname + "/log.dat"; - // Open the log file name - std::ofstream flog(logfilename.c_str()); + // Open the log file name + std::ofstream flog(logfilename.c_str()); - try { // vpRobotAfma4 robot ; vpRobotAfma4 robot ; @@ -273,7 +273,7 @@ main() // v[0], v[1], v[2] correspond to joint translation velocities in m/s // v[3], v[4], v[5] correspond to joint rotation velocities in rad/s flog << v[0] << " " << v[1] << " " << v[2] << " " - << v[3] << " " << v[4] << " " << v[5] << " "; + << v[3] << " " << v[4] << " " << v[5] << " "; // Get the measured joint velocities of the robot vpColVector qvel; @@ -284,7 +284,7 @@ main() // - qvel[3], qvel[4], qvel[5] correspond to measured joint rotation // velocities in rad/s flog << qvel[0] << " " << qvel[1] << " " << qvel[2] << " " - << qvel[3] << " " << qvel[4] << " " << qvel[5] << " "; + << qvel[3] << " " << qvel[4] << " " << qvel[5] << " "; // Get the measured joint positions of the robot vpColVector q; @@ -295,7 +295,7 @@ main() // - q[3], q[4], q[5] correspond to measured joint rotation // positions in rad flog << q[0] << " " << q[1] << " " << q[2] << " " - << q[3] << " " << q[4] << " " << q[5] << " "; + << q[3] << " " << q[4] << " " << q[5] << " "; // Save feature error (s-s*) for the feature point. For this feature // point, we have 2 errors (along x and y axis). This error is expressed @@ -313,11 +313,9 @@ main() task.kill(); return 0; } - catch (...) - { - flog.close() ; // Close the log file - vpERROR_TRACE(" Test failed") ; - return 0; + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; } } diff --git a/example/servo-afma4/servoAfma4Point2DCamVelocity.cpp b/example/servo-afma4/servoAfma4Point2DCamVelocity.cpp index 5a3499ff348f37cf84dee96fb3134b85cc253cfd..5549e73e46dc1b87d84916017b100cebe2e9f3ba 100644 --- a/example/servo-afma4/servoAfma4Point2DCamVelocity.cpp +++ b/example/servo-afma4/servoAfma4Point2DCamVelocity.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoAfma4Point2DCamVelocity.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: servoAfma4Point2DCamVelocity.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -98,41 +98,40 @@ int main() { - // Log file creation in /tmp/$USERNAME/log.dat - // This file contains by line: - // - the 6 computed cam velocities (m/s, rad/s) to achieve the task - // - the 6 mesured joint velocities (m/s, rad/s) - // - the 6 mesured joint positions (m, rad) - // - the 2 values of s - s* - std::string username; - // Get the user login name - vpIoTools::getUserName(username); - - // Create a log filename to save velocities... - std::string logdirname; - logdirname ="/tmp/" + username; - - // Test if the output path exist. If no try to create it - if (vpIoTools::checkDirectory(logdirname) == false) { - try { - // Create the dirname - vpIoTools::makeDirectory(logdirname); + try { + // Log file creation in /tmp/$USERNAME/log.dat + // This file contains by line: + // - the 6 computed cam velocities (m/s, rad/s) to achieve the task + // - the 6 mesured joint velocities (m/s, rad/s) + // - the 6 mesured joint positions (m, rad) + // - the 2 values of s - s* + std::string username; + // Get the user login name + vpIoTools::getUserName(username); + + // Create a log filename to save velocities... + std::string logdirname; + logdirname ="/tmp/" + username; + + // Test if the output path exist. If no try to create it + if (vpIoTools::checkDirectory(logdirname) == false) { + try { + // Create the dirname + vpIoTools::makeDirectory(logdirname); + } + catch (...) { + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Cannot create " << logdirname << std::endl; + exit(-1); + } } - catch (...) { - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Cannot create " << logdirname << std::endl; - exit(-1); - } - } - std::string logfilename; - logfilename = logdirname + "/log.dat"; + std::string logfilename; + logfilename = logdirname + "/log.dat"; - // Open the log file name - std::ofstream flog(logfilename.c_str()); + // Open the log file name + std::ofstream flog(logfilename.c_str()); - try - { vpRobotAfma4 robot ; vpServo task ; @@ -170,7 +169,7 @@ main() std::cout << "Click on a dot..." << std::endl; dot.initTracking(I) ; - + // Get the cog of the dot vpImagePoint cog = dot.getCog(); @@ -241,7 +240,7 @@ main() // v[0], v[1], v[2] correspond to camera translation velocities in m/s // v[3], v[4], v[5] correspond to camera rotation velocities in rad/s flog << v[0] << " " << v[1] << " " << v[2] << " " - << v[3] << " " << v[4] << " " << v[5] << " "; + << v[3] << " " << v[4] << " " << v[5] << " "; // Get the measured joint velocities of the robot vpColVector qvel; @@ -252,7 +251,7 @@ main() // - qvel[3], qvel[4], qvel[5] correspond to measured joint rotation // velocities in rad/s flog << qvel[0] << " " << qvel[1] << " " << qvel[2] << " " - << qvel[3] << " " << qvel[4] << " " << qvel[5] << " "; + << qvel[3] << " " << qvel[4] << " " << qvel[5] << " "; // Get the measured joint positions of the robot vpColVector q; @@ -263,7 +262,7 @@ main() // - q[3], q[4], q[5] correspond to measured joint rotation // positions in rad flog << q[0] << " " << q[1] << " " << q[2] << " " - << q[3] << " " << q[4] << " " << q[5] << " "; + << q[3] << " " << q[4] << " " << q[5] << " "; // Save feature error (s-s*) for the feature point. For this feature // point, we have 2 errors (along x and y axis). This error is expressed @@ -285,11 +284,9 @@ main() return 0; } - catch (...) - { - flog.close() ; // Close the log file - vpERROR_TRACE(" Test failed") ; - return 0; + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; } } diff --git a/example/servo-afma4/servoAfma4Point2DCamVelocityKalman.cpp b/example/servo-afma4/servoAfma4Point2DCamVelocityKalman.cpp index 17b8610692dc698ee089f401ce51a5c6ef6de4dd..05a8ec830e8fd579759fe24f0a5d7d9282c48cf7 100644 --- a/example/servo-afma4/servoAfma4Point2DCamVelocityKalman.cpp +++ b/example/servo-afma4/servoAfma4Point2DCamVelocityKalman.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoAfma4Point2DCamVelocityKalman.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: servoAfma4Point2DCamVelocityKalman.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -194,53 +194,53 @@ bool getOptions(int argc, const char **argv, KalmanType &kalman, int main(int argc, const char ** argv) { - KalmanType opt_kalman = K_NONE; - vpAdaptiveGain lambda; // Gain de la commande - bool doAdaptativeGain = true; // Compute adaptative gain - lambda.initStandard(4, 0.2, 40); - int opt_cam_frequency = 60; // 60 Hz - - // Read the command line options - if (getOptions(argc, argv, opt_kalman, doAdaptativeGain, lambda) == false) { - return (-1); - } - - // Log file creation in /tmp/$USERNAME/log.dat - // This file contains by line: - // - the 6 computed cam velocities (m/s, rad/s) to achieve the task - // - the 6 mesured joint velocities (m/s, rad/s) - // - the 6 mesured joint positions (m, rad) - // - the 2 values of s - s* - std::string username; - // Get the user login name - vpIoTools::getUserName(username); - - // Create a log filename to save velocities... - std::string logdirname; - logdirname ="/tmp/" + username; - - // Test if the output path exist. If no try to create it - if (vpIoTools::checkDirectory(logdirname) == false) { - try { - // Create the dirname - vpIoTools::makeDirectory(logdirname); + try { + KalmanType opt_kalman = K_NONE; + vpAdaptiveGain lambda; // Gain de la commande + bool doAdaptativeGain = true; // Compute adaptative gain + lambda.initStandard(4, 0.2, 40); + int opt_cam_frequency = 60; // 60 Hz + + // Read the command line options + if (getOptions(argc, argv, opt_kalman, doAdaptativeGain, lambda) == false) { + return (-1); } - catch (...) { - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Cannot create " << logdirname << std::endl; - exit(-1); + + // Log file creation in /tmp/$USERNAME/log.dat + // This file contains by line: + // - the 6 computed cam velocities (m/s, rad/s) to achieve the task + // - the 6 mesured joint velocities (m/s, rad/s) + // - the 6 mesured joint positions (m, rad) + // - the 2 values of s - s* + std::string username; + // Get the user login name + vpIoTools::getUserName(username); + + // Create a log filename to save velocities... + std::string logdirname; + logdirname ="/tmp/" + username; + + // Test if the output path exist. If no try to create it + if (vpIoTools::checkDirectory(logdirname) == false) { + try { + // Create the dirname + vpIoTools::makeDirectory(logdirname); + } + catch (...) { + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Cannot create " << logdirname << std::endl; + exit(-1); + } } - } - std::string logfilename; - logfilename = logdirname + "/log.dat"; + std::string logfilename; + logfilename = logdirname + "/log.dat"; - // Open the log file name - std::ofstream flog(logfilename.c_str()); + // Open the log file name + std::ofstream flog(logfilename.c_str()); + + vpServo task ; - vpServo task ; - - try { vpImage<unsigned char> I ; vp1394TwoGrabber g(false); g.setVideoMode(vp1394TwoGrabber::vpVIDEO_MODE_640x480_MONO8); @@ -271,16 +271,16 @@ main(int argc, const char ** argv) std::cout << "Eye-in-hand task control, velocity computed in the camera frame" << std::endl ; std::cout << "Task : servo a point \n" << std::endl ; - // Kalman filtering + // Kalman filtering switch(opt_kalman) { - case K_NONE: + case K_NONE: std::cout << "Servo with no target motion compensation (see -K option)\n"; break; case K_VELOCITY: std::cout << "Servo with target motion compensation using a Kalman filter\n" << "with constant velocity modelization (see -K option)\n"; break; - case K_ACCELERATION: + case K_ACCELERATION: std::cout << "Servo with target motion compensation using a Kalman filter\n" << "with constant acceleration modelization (see -K option)\n"; break; @@ -309,7 +309,7 @@ main(int argc, const char ** argv) // Sets the current position of the visual feature vpFeaturePoint p ; - vpFeatureBuilder::create(p, cam, dot) ; + vpFeatureBuilder::create(p, cam, dot) ; // Sets the desired position of the visual feature vpFeaturePoint pd ; @@ -336,7 +336,7 @@ main(int argc, const char ** argv) //!Initialize filter vpLinearKalmanFilterInstantiation kalman; - + // Initialize the kalman filter unsigned int nsignal = 2; // The two values of dedt double rho = 0.3; @@ -350,9 +350,9 @@ main(int argc, const char ** argv) kalman.setStateModel(vpLinearKalmanFilterInstantiation::stateConstVelWithColoredNoise_MeasureVel); state_size = kalman.getStateSize(); sigma_state.resize(state_size*nsignal); - sigma_state = 0.00001; // Same state variance for all signals + sigma_state = 0.00001; // Same state variance for all signals sigma_measure = 0.05; // Same measure variance for all the signals - double dummy = 0; // non used parameter dt for the velocity state model + double dummy = 0; // non used parameter dt for the velocity state model kalman.initFilter(nsignal, sigma_state, sigma_measure, rho, dummy); break; @@ -381,15 +381,15 @@ main(int argc, const char ** argv) vpColVector v(6), v1(6), v2(6); // robot velocities //task error vpColVector err(2), err_0(2), err_1(2); - vpColVector dedt_filt(2), dedt_mes(2); + vpColVector dedt_filt(2), dedt_mes(2); - t_1 = vpTime::measureTimeMs(); // t_1: time at previous iter + t_1 = vpTime::measureTimeMs(); // t_1: time at previous iter Tv_0 = 0; // - // Warning: In all varaible names, + // Warning: In all varaible names, // _0 means the value for the current iteration (t=0) // _1 means the value for the previous iteration (t=-1) // _2 means the value for the previous previous iteration (t=-2) @@ -426,7 +426,7 @@ main(int argc, const char ** argv) //!-------------------- Update displacements and time ------------------ //---------------------------------------------------------------------- vm_0 = vm; - + // Update current loop time and previous one Tv_1 = Tv_0; Tv_0 = Tv; @@ -437,13 +437,13 @@ main(int argc, const char ** argv) err = task.error; //!terme correctif : de/dt = Delta s / Delta t - L*vc - if (iter==0){ + if (iter==0){ err_0 = 0; err_1 = 0; dedt_mes = 0; dedt_filt = 0; } - else{ + else{ err_1 = err_0; err_0 = err; @@ -457,13 +457,13 @@ main(int argc, const char ** argv) //---------------------------------------------------------------------- //----------------------- Kalman Filter Equations ---------------------- //---------------------------------------------------------------------- - // Kalman filtering + // Kalman filtering switch(opt_kalman) { - case K_NONE: + case K_NONE: dedt_filt = 0; break; case K_VELOCITY: - case K_ACCELERATION: + case K_ACCELERATION: kalman.filter(dedt_mes); for (unsigned int i=0; i < nsignal; i++) { dedt_filt[i] = kalman.Xest[i*state_size]; @@ -477,15 +477,15 @@ main(int argc, const char ** argv) // std::cout << "task J1p: " << J1p.t() << std::endl ; // std::cout << "dedt_filt: " << dedt_filt.t() << std::endl ; - v = v1 + v2; - + v = v1 + v2; + // Display the current and desired feature points in the image display vpServoDisplay::display(task, cam, I) ; // std::cout << "v2 : " << v2.t() << std::endl ; // std::cout << "v1 : " << v1.t() << std::endl ; - + // std::cout << "v : " << v.t(); // Apply the camera velocities to the robot @@ -498,15 +498,15 @@ main(int argc, const char ** argv) // v[0], v[1], v[2] correspond to camera translation velocities in m/s // v[3], v[4], v[5] correspond to camera rotation velocities in rad/s flog << v[0] << " " << v[1] << " " << v[2] << " " - << v[3] << " " << v[4] << " " << v[5] << " "; + << v[3] << " " << v[4] << " " << v[5] << " "; // Save feature error (s-s*) for the feature point. For this feature // point, we have 2 errors (along x and y axis). This error is expressed // in meters in the camera frame - flog << task.error[0] << " " << task.error[1] << " "; + flog << task.error[0] << " " << task.error[1] << " "; // Save feature error (s-s*) in pixels in the image. - flog << cog.get_u()-cam.get_u0() << " " + flog << cog.get_u()-cam.get_u0() << " " << cog.get_v()-cam.get_v0() << " "; // Save de/dt @@ -534,15 +534,11 @@ main(int argc, const char ** argv) return 0; } - catch (...) { - flog.close() ; // Close the log file - - // Kill the task - task.kill(); - - vpERROR_TRACE(" Test failed") ; - return 0; + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + return 1; } + } diff --git a/example/servo-afma6/CMakeLists.txt b/example/servo-afma6/CMakeLists.txt index e32c378dac93c692b1e6252f08e51c65aa850e10..f010c4a76b34a5af550cbb6d8e9122d113cf3dce 100644 --- a/example/servo-afma6/CMakeLists.txt +++ b/example/servo-afma6/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/servo-afma6/servoAfma62DhalfCamVelocity.cpp b/example/servo-afma6/servoAfma62DhalfCamVelocity.cpp index d7a0f240511fa745ff0d33852354dad5de3cb687..9180438597b16ecd7d34242ec1925cf9e24c0a91 100644 --- a/example/servo-afma6/servoAfma62DhalfCamVelocity.cpp +++ b/example/servo-afma6/servoAfma62DhalfCamVelocity.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoAfma62DhalfCamVelocity.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: servoAfma62DhalfCamVelocity.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/example/servo-afma6/servoAfma6Cylinder2DCamVelocity.cpp b/example/servo-afma6/servoAfma6Cylinder2DCamVelocity.cpp index fcfecf99f45f19fe0c5bcc996c8acc5652ff405e..a45fed980c1ab8fdc49d410863e9ea99f800dda8 100644 --- a/example/servo-afma6/servoAfma6Cylinder2DCamVelocity.cpp +++ b/example/servo-afma6/servoAfma6Cylinder2DCamVelocity.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoAfma6Cylinder2DCamVelocity.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: servoAfma6Cylinder2DCamVelocity.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/example/servo-afma6/servoAfma6Cylinder2DCamVelocitySecondaryTask.cpp b/example/servo-afma6/servoAfma6Cylinder2DCamVelocitySecondaryTask.cpp index 77436b2641570ae2825661d27f76d0eaf750c5cb..44429118db3f36d25467e9a8aba1f08b5069a8dd 100644 --- a/example/servo-afma6/servoAfma6Cylinder2DCamVelocitySecondaryTask.cpp +++ b/example/servo-afma6/servoAfma6Cylinder2DCamVelocitySecondaryTask.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoAfma6Cylinder2DCamVelocitySecondaryTask.cpp 4107 2013-02-06 10:04:49Z fspindle $ + * $Id: servoAfma6Cylinder2DCamVelocitySecondaryTask.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/example/servo-afma6/servoAfma6Ellipse2DCamVelocity.cpp b/example/servo-afma6/servoAfma6Ellipse2DCamVelocity.cpp index 8452d4b1006106731394c9c04368d84ae708cc11..1accd1a233d4ef0d1e2350fc00a8833c0f44a28e 100644 --- a/example/servo-afma6/servoAfma6Ellipse2DCamVelocity.cpp +++ b/example/servo-afma6/servoAfma6Ellipse2DCamVelocity.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoAfma6Ellipse2DCamVelocity.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: servoAfma6Ellipse2DCamVelocity.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/example/servo-afma6/servoAfma6FourPoints2DArtVelocity.cpp b/example/servo-afma6/servoAfma6FourPoints2DArtVelocity.cpp index 42d959e3e78aa00f549117a0a9dea8c8cf766f41..5e1c2cdb494338874a19353b16afad8f28ccfdc5 100644 --- a/example/servo-afma6/servoAfma6FourPoints2DArtVelocity.cpp +++ b/example/servo-afma6/servoAfma6FourPoints2DArtVelocity.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoAfma6FourPoints2DArtVelocity.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: servoAfma6FourPoints2DArtVelocity.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/example/servo-afma6/servoAfma6FourPoints2DCamVelocityInteractionCurrent.cpp b/example/servo-afma6/servoAfma6FourPoints2DCamVelocityInteractionCurrent.cpp index 952c098142bdeedb05178a697f2c10fbaf4aeff8..debf5ddf0865d59851187654f1111f26c49f4e0c 100644 --- a/example/servo-afma6/servoAfma6FourPoints2DCamVelocityInteractionCurrent.cpp +++ b/example/servo-afma6/servoAfma6FourPoints2DCamVelocityInteractionCurrent.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoAfma6FourPoints2DCamVelocityInteractionCurrent.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: servoAfma6FourPoints2DCamVelocityInteractionCurrent.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/example/servo-afma6/servoAfma6FourPoints2DCamVelocityInteractionDesired.cpp b/example/servo-afma6/servoAfma6FourPoints2DCamVelocityInteractionDesired.cpp index 0fa9f323bbfa77b3aa05d91cb7195706b4bd912d..d59457f51ea8aedf0517184de691f0edb64bdf61 100644 --- a/example/servo-afma6/servoAfma6FourPoints2DCamVelocityInteractionDesired.cpp +++ b/example/servo-afma6/servoAfma6FourPoints2DCamVelocityInteractionDesired.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoAfma6FourPoints2DCamVelocityInteractionDesired.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: servoAfma6FourPoints2DCamVelocityInteractionDesired.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/example/servo-afma6/servoAfma6Line2DCamVelocity.cpp b/example/servo-afma6/servoAfma6Line2DCamVelocity.cpp index 1ea51394ae8b9421c4ae1dc8f76db4be943e48eb..3acfdff3e20b7c272a28d19ccac1576ccfced2d4 100644 --- a/example/servo-afma6/servoAfma6Line2DCamVelocity.cpp +++ b/example/servo-afma6/servoAfma6Line2DCamVelocity.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoAfma6Line2DCamVelocity.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: servoAfma6Line2DCamVelocity.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/example/servo-afma6/servoAfma6Point2DArtVelocity.cpp b/example/servo-afma6/servoAfma6Point2DArtVelocity.cpp index 43f0aa423d94ef524270b2c7f12ea8893834b428..7f0e31d955b9da8e6d9046c44560c83a2977d649 100644 --- a/example/servo-afma6/servoAfma6Point2DArtVelocity.cpp +++ b/example/servo-afma6/servoAfma6Point2DArtVelocity.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoAfma6Point2DArtVelocity.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: servoAfma6Point2DArtVelocity.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/example/servo-afma6/servoAfma6Point2DCamVelocity.cpp b/example/servo-afma6/servoAfma6Point2DCamVelocity.cpp index 695a3dd6edfe43724cf80f440b879f2fb78b5457..6ed0b84aef400d4c53a31a558a9fca55e2233850 100644 --- a/example/servo-afma6/servoAfma6Point2DCamVelocity.cpp +++ b/example/servo-afma6/servoAfma6Point2DCamVelocity.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoAfma6Point2DCamVelocity.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: servoAfma6Point2DCamVelocity.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/example/servo-afma6/servoAfma6Points2DCamVelocityEyeToHand.cpp b/example/servo-afma6/servoAfma6Points2DCamVelocityEyeToHand.cpp index 1858d2f6d88193a9fade3446396e7ffc074684fd..f42ea7315a054d87586fd6b55f3015bc88bfe1cf 100644 --- a/example/servo-afma6/servoAfma6Points2DCamVelocityEyeToHand.cpp +++ b/example/servo-afma6/servoAfma6Points2DCamVelocityEyeToHand.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoAfma6Points2DCamVelocityEyeToHand.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: servoAfma6Points2DCamVelocityEyeToHand.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/example/servo-afma6/servoAfma6Segment2DCamVelocity.cpp b/example/servo-afma6/servoAfma6Segment2DCamVelocity.cpp index 867f09f88060df1a43704c2151cbf7428269a2bd..c151bdebf20521cf70b50730edf0137bfd4905e6 100644 --- a/example/servo-afma6/servoAfma6Segment2DCamVelocity.cpp +++ b/example/servo-afma6/servoAfma6Segment2DCamVelocity.cpp @@ -3,7 +3,7 @@ * $Id: servoAfma6Point2DCamVelocity.cpp 3616 2012-03-09 14:31:52Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/example/servo-afma6/servoAfma6SquareLines2DCamVelocity.cpp b/example/servo-afma6/servoAfma6SquareLines2DCamVelocity.cpp index 10fae34613eca720379c22f521ceafb7574afb47..663fa0feb2e373ab6f362b74263e969ee532a8e3 100644 --- a/example/servo-afma6/servoAfma6SquareLines2DCamVelocity.cpp +++ b/example/servo-afma6/servoAfma6SquareLines2DCamVelocity.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoAfma6SquareLines2DCamVelocity.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: servoAfma6SquareLines2DCamVelocity.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/example/servo-afma6/servoAfma6TwoLines2DCamVelocity.cpp b/example/servo-afma6/servoAfma6TwoLines2DCamVelocity.cpp index 7bb5006060d708aadc1897b0d8880667adc5a20e..45f8bd8c5ea8fbb286b89633a3768d8f668fac02 100644 --- a/example/servo-afma6/servoAfma6TwoLines2DCamVelocity.cpp +++ b/example/servo-afma6/servoAfma6TwoLines2DCamVelocity.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoAfma6TwoLines2DCamVelocity.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: servoAfma6TwoLines2DCamVelocity.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/example/servo-biclops/CMakeLists.txt b/example/servo-biclops/CMakeLists.txt index 62e38ba63ff5951fd01b7decfde1bda50fcb1917..0c420c620e548e5da7e685e067a2dd9e389a6dab 100644 --- a/example/servo-biclops/CMakeLists.txt +++ b/example/servo-biclops/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/servo-biclops/moveBiclops.cpp b/example/servo-biclops/moveBiclops.cpp index a0bc6c6f1c8dac5a631195491fae3371ac7651ff..c02ed031d1eb2633b9455bc3d69d33f45a0c9f5b 100644 --- a/example/servo-biclops/moveBiclops.cpp +++ b/example/servo-biclops/moveBiclops.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: moveBiclops.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: moveBiclops.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/example/servo-biclops/servoBiclopsPoint2DArtVelocity.cpp b/example/servo-biclops/servoBiclopsPoint2DArtVelocity.cpp index bc30fe207b8b792172aaa4419491789d2303db0a..8450bd3bfcbc623077b0a5738828d1a5facf7ca7 100644 --- a/example/servo-biclops/servoBiclopsPoint2DArtVelocity.cpp +++ b/example/servo-biclops/servoBiclopsPoint2DArtVelocity.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoBiclopsPoint2DArtVelocity.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: servoBiclopsPoint2DArtVelocity.cpp 4604 2014-01-21 14:15:23Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -69,14 +69,13 @@ #include <visp/vpDebug.h> // Debug trace #include <signal.h> #include <stdlib.h> -#if ( defined (VISP_HAVE_BICLOPS) && (defined (VISP_HAVE_DC1394_2) /*|| defined (VISP_HAVE_DC1394_1)*/ || defined(VISP_HAVE_DIRECTSHOW)) ) +#if ( defined (VISP_HAVE_BICLOPS) && (defined (VISP_HAVE_DC1394_2) || defined(VISP_HAVE_DIRECTSHOW)) ) #ifdef VISP_HAVE_PTHREAD # include <pthread.h> #endif #include <visp/vp1394TwoGrabber.h> -//#include <visp/vp1394Grabber.h> #include <visp/vpDirectShowGrabber.h> #include <visp/vpImage.h> #include <visp/vpDisplay.h> @@ -224,9 +223,9 @@ main(int argc, const char ** argv) std::string opt_debugdir; // Set the default output path -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX opt_debugdir = "/tmp"; -#elif WIN32 +#elif defined(_WIN32) opt_debugdir = "C:/temp"; #endif @@ -279,8 +278,6 @@ main(int argc, const char ** argv) #if defined VISP_HAVE_DC1394_2 vp1394TwoGrabber g; - // #elif defined VISP_HAVE_DC1394_1 - // vp1394Grabber g; #elif defined VISP_HAVE_DIRECTSHOW vpDirectShowGrabber g; #endif @@ -302,11 +299,10 @@ main(int argc, const char ** argv) vpDisplayX display(I, 100, 100,"Display X...") ; #elif defined VISP_HAVE_GTK vpDisplayGTK display(I, 100, 100,"Display GTK...") ; -#elif defined WIN32 +#elif defined(_WIN32) vpDisplayGDI display(I, 100, 100,"Display GDI...") ; #endif - try{ vpDisplay::display(I) ; vpDisplay::flush(I) ; diff --git a/example/servo-cycab/CMakeLists.txt b/example/servo-cycab/CMakeLists.txt deleted file mode 100644 index 184a92adabcad28b20d6c1d54bfb7ab580ebe2c3..0000000000000000000000000000000000000000 --- a/example/servo-cycab/CMakeLists.txt +++ /dev/null @@ -1,60 +0,0 @@ -############################################################################# -# -# $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) - diff --git a/example/servo-cycab/servoCycab.cpp b/example/servo-cycab/servoCycab.cpp deleted file mode 100644 index 4d621269288455d303a5facf30c762bea6849754..0000000000000000000000000000000000000000 --- a/example/servo-cycab/servoCycab.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/**************************************************************************** - * - * $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 <visp/vpConfig.h> -#include <iostream> -#include <cmath> // std::fabs -#include <limits> // numeric_limits - -#include <signal.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <math.h> -using namespace std; - -#ifdef VISP_HAVE_CYCAB -#include <visp/vpRobotCycab.h> -#include <visp/vpMath.h> -#include <visp/vpTime.h> - - -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<double>::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<double>::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 - diff --git a/example/servo-cycab/servoCycabBasic.cpp b/example/servo-cycab/servoCycabBasic.cpp deleted file mode 100644 index 2abfd9d80732bd350ac4006949eaa80f67bc7756..0000000000000000000000000000000000000000 --- a/example/servo-cycab/servoCycabBasic.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** - * - * $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 <iostream> -#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 - diff --git a/example/servo-pioneer/CMakeLists.txt b/example/servo-pioneer/CMakeLists.txt index c7e4908182ba543cebf7b58d77d8e5c20bf13e9b..cbdfedf19af0df91f384fc2d8f0e9613c188d7f7 100644 --- a/example/servo-pioneer/CMakeLists.txt +++ b/example/servo-pioneer/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/servo-pioneer/movePioneer.cpp b/example/servo-pioneer/movePioneer.cpp index 8a80def971ccc4ae5a438b474fa72644dd4cbfdd..31bb006dc517f37348ccb2a5330eb8ab5fd89760 100644 --- a/example/servo-pioneer/movePioneer.cpp +++ b/example/servo-pioneer/movePioneer.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: movePioneer.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: movePioneer.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -69,43 +69,44 @@ int main() */ int main(int argc, char **argv) { - std::cout << "\nWARNING: this program does no sensing or avoiding of obstacles, \n" - "the robot WILL collide with any objects in the way! Make sure the \n" - "robot has approximately 3 meters of free space on all sides.\n" - << std::endl; + try { + std::cout << "\nWARNING: this program does no sensing or avoiding of obstacles, \n" + "the robot WILL collide with any objects in the way! Make sure the \n" + "robot has approximately 3 meters of free space on all sides.\n" + << std::endl; - vpRobotPioneer robot; + vpRobotPioneer robot; - ArArgumentParser parser(&argc, argv); - parser.loadDefaultArguments(); + ArArgumentParser parser(&argc, argv); + parser.loadDefaultArguments(); - // ArRobotConnector connects to the robot, get some initial data from it such as type and name, - // and then loads parameter files for this robot. - ArRobotConnector robotConnector(&parser, &robot); - if(!robotConnector.connectRobot()) - { - ArLog::log(ArLog::Terse, "Could not connect to the robot."); - if(parser.checkHelpAndWarnUnparsed()) + // ArRobotConnector connects to the robot, get some initial data from it such as type and name, + // and then loads parameter files for this robot. + ArRobotConnector robotConnector(&parser, &robot); + if(!robotConnector.connectRobot()) + { + ArLog::log(ArLog::Terse, "Could not connect to the robot."); + if(parser.checkHelpAndWarnUnparsed()) + { + Aria::logOptions(); + Aria::exit(1); + } + } + if (!Aria::parseArgs()) { Aria::logOptions(); - Aria::exit(1); + Aria::shutdown(); + return false; } - } - if (!Aria::parseArgs()) - { - Aria::logOptions(); - Aria::shutdown(); - return false; - } - - std::cout << "Robot connected" << std::endl; - robot.useSonar(false); // disable the sonar device usage - // Robot velocities - vpColVector v(2), v_mes(2); + std::cout << "Robot connected" << std::endl; + robot.useSonar(false); // disable the sonar device usage + + // Robot velocities + vpColVector v(2), v_mes(2); - for (int i=0; i < 100; i++) - { + for (int i=0; i < 100; i++) + { double t = vpTime::measureTimeMs(); v = 0; @@ -120,28 +121,33 @@ int main(int argc, char **argv) std::cout << "Battery=" << robot.getBatteryVoltage() << std::endl; vpTime::wait(t, 40); - } + } - ArLog::log(ArLog::Normal, "simpleMotionCommands: Stopping."); - robot.lock(); - robot.stop(); - robot.unlock(); - ArUtil::sleep(1000); + ArLog::log(ArLog::Normal, "simpleMotionCommands: Stopping."); + robot.lock(); + robot.stop(); + robot.unlock(); + ArUtil::sleep(1000); - robot.lock(); - ArLog::log(ArLog::Normal, "simpleMotionCommands: Pose=(%.2f,%.2f,%.2f), Trans. Vel=%.2f, Rot. Vel=%.2f, Battery=%.2fV", - robot.getX(), robot.getY(), robot.getTh(), robot.getVel(), robot.getRotVel(), robot.getBatteryVoltage()); - robot.unlock(); + robot.lock(); + ArLog::log(ArLog::Normal, "simpleMotionCommands: Pose=(%.2f,%.2f,%.2f), Trans. Vel=%.2f, Rot. Vel=%.2f, Battery=%.2fV", + robot.getX(), robot.getY(), robot.getTh(), robot.getVel(), robot.getRotVel(), robot.getBatteryVoltage()); + robot.unlock(); - std::cout << "Ending robot thread..." << std::endl; - robot.stopRunning(); + std::cout << "Ending robot thread..." << std::endl; + robot.stopRunning(); - // wait for the thread to stop - robot.waitForRunExit(); + // wait for the thread to stop + robot.waitForRunExit(); - // exit - ArLog::log(ArLog::Normal, "simpleMotionCommands: Exiting."); - return 0; + // exit + ArLog::log(ArLog::Normal, "simpleMotionCommands: Exiting."); + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } #endif diff --git a/example/servo-pioneer/servoPioneerPanSegment3D.cpp b/example/servo-pioneer/servoPioneerPanSegment3D.cpp index 4b508eccb81b3b1f094cf6a5d81d963596d9f0a8..8b3296e5d34dca6334eb51a4816e8920450e17d5 100644 --- a/example/servo-pioneer/servoPioneerPanSegment3D.cpp +++ b/example/servo-pioneer/servoPioneerPanSegment3D.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoPioneerPanSegment3D.cpp 4258 2013-05-15 15:54:05Z fspindle $ + * $Id: servoPioneerPanSegment3D.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -86,326 +86,331 @@ int main(int argc, char **argv) { #if defined(VISP_HAVE_DC1394_2) || defined(VISP_HAVE_V4L2) || defined(VISP_HAVE_CMU1394) #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) - vpImage<unsigned char> I; // Create a gray level image container - double lambda = 0.1; - // Scale parameter used to estimate the depth Z of the blob from its surface - //double coef = 0.9/14.85; // At 0.9m, the blob has a surface of 14.85 (Logitec sphere) - double coef = 1.2/13.0; // At 1m, the blob has a surface of 11.3 (AVT Pike 032C) - double L = 0.21; // 3D horizontal segment length - double Z_d = 0.8; // Desired distance along Z between camera and segment - bool normalized = true; // segment normilized features are used - - // Warning: To have a non singular task of rank 3, Y_d should be different from 0 so that - // the optical axis doesn't intersect the horizontal segment - double Y_d = -.11; // Desired distance along Y between camera and segment. - vpColVector qm(2); // Measured head position - qm = 0; - double qm_pan = 0; // Measured pan position (tilt is not handled in that example) + try { + vpImage<unsigned char> I; // Create a gray level image container + double lambda = 0.1; + // Scale parameter used to estimate the depth Z of the blob from its surface + //double coef = 0.9/14.85; // At 0.9m, the blob has a surface of 14.85 (Logitec sphere) + double coef = 1.2/13.0; // At 1m, the blob has a surface of 11.3 (AVT Pike 032C) + double L = 0.21; // 3D horizontal segment length + double Z_d = 0.8; // Desired distance along Z between camera and segment + bool normalized = true; // segment normilized features are used + + // Warning: To have a non singular task of rank 3, Y_d should be different from 0 so that + // the optical axis doesn't intersect the horizontal segment + double Y_d = -.11; // Desired distance along Y between camera and segment. + vpColVector qm(2); // Measured head position + qm = 0; + double qm_pan = 0; // Measured pan position (tilt is not handled in that example) #ifdef USE_REAL_ROBOT - // Initialize the biclops head - - vpRobotBiclops biclops("/usr/share/BiclopsDefault.cfg"); - biclops.setDenavitHartenbergModel(vpBiclops::DH1); - - // Move to the initial position - vpColVector q(2); - - q=0; -// q[0] = vpMath::rad(63); -// q[1] = vpMath::rad(12); // introduce a tilt angle to compensate camera sphere tilt so that the camera is parallel to the plane - - biclops.setRobotState(vpRobot::STATE_POSITION_CONTROL) ; - biclops.setPosition( vpRobot::ARTICULAR_FRAME, q ); - //biclops.setPositioningVelocity(50); - biclops.getPosition(vpRobot::ARTICULAR_FRAME, qm); - qm_pan = qm[0]; - - // Now the head will be controlled in velocity - biclops.setRobotState(vpRobot::STATE_VELOCITY_CONTROL) ; - - // Initialize the pioneer robot - vpRobotPioneer pioneer; - ArArgumentParser parser(&argc, argv); - parser.loadDefaultArguments(); - - // ArRobotConnector connects to the robot, get some initial data from it such as type and name, - // and then loads parameter files for this robot. - ArRobotConnector robotConnector(&parser, &pioneer); - if(!robotConnector.connectRobot()) - { - ArLog::log(ArLog::Terse, "Could not connect to the pioneer robot."); - if(parser.checkHelpAndWarnUnparsed()) + // Initialize the biclops head + + vpRobotBiclops biclops("/usr/share/BiclopsDefault.cfg"); + biclops.setDenavitHartenbergModel(vpBiclops::DH1); + + // Move to the initial position + vpColVector q(2); + + q=0; + // q[0] = vpMath::rad(63); + // q[1] = vpMath::rad(12); // introduce a tilt angle to compensate camera sphere tilt so that the camera is parallel to the plane + + biclops.setRobotState(vpRobot::STATE_POSITION_CONTROL) ; + biclops.setPosition( vpRobot::ARTICULAR_FRAME, q ); + //biclops.setPositioningVelocity(50); + biclops.getPosition(vpRobot::ARTICULAR_FRAME, qm); + qm_pan = qm[0]; + + // Now the head will be controlled in velocity + biclops.setRobotState(vpRobot::STATE_VELOCITY_CONTROL) ; + + // Initialize the pioneer robot + vpRobotPioneer pioneer; + ArArgumentParser parser(&argc, argv); + parser.loadDefaultArguments(); + + // ArRobotConnector connects to the robot, get some initial data from it such as type and name, + // and then loads parameter files for this robot. + ArRobotConnector robotConnector(&parser, &pioneer); + if(!robotConnector.connectRobot()) + { + ArLog::log(ArLog::Terse, "Could not connect to the pioneer robot."); + if(parser.checkHelpAndWarnUnparsed()) + { + Aria::logOptions(); + Aria::exit(1); + } + } + if (!Aria::parseArgs()) { Aria::logOptions(); - Aria::exit(1); + Aria::shutdown(); + return false; } - } - if (!Aria::parseArgs()) - { - Aria::logOptions(); - Aria::shutdown(); - return false; - } - pioneer.useSonar(false); // disable the sonar device usage + pioneer.useSonar(false); // disable the sonar device usage - // Wait 3 sec to be sure that the low level Aria thread used to control - // the robot is started. Without this delay we experienced a delay (arround 2.2 sec) - // between the velocity send to the robot and the velocity that is really applied - // to the wheels. - sleep(3); + // Wait 3 sec to be sure that the low level Aria thread used to control + // the robot is started. Without this delay we experienced a delay (arround 2.2 sec) + // between the velocity send to the robot and the velocity that is really applied + // to the wheels. + sleep(3); - std::cout << "Pioneer robot connected" << std::endl; + std::cout << "Pioneer robot connected" << std::endl; #endif - vpPioneerPan robot_pan; // Generic robot that computes the velocities for the pioneer and the biclops head + vpPioneerPan robot_pan; // Generic robot that computes the velocities for the pioneer and the biclops head - // Camera parameters. In this experiment we don't need a precise calibration of the camera - vpCameraParameters cam; + // Camera parameters. In this experiment we don't need a precise calibration of the camera + vpCameraParameters cam; - // Create the camera framegrabber + // Create the camera framegrabber #if defined(VISP_HAVE_V4L2) - // Create a grabber based on v4l2 third party lib (for usb cameras under Linux) - vpV4l2Grabber g; - g.setScale(1); - g.setInput(0); - g.setDevice("/dev/video1"); - g.open(I); - // Logitec sphere parameters - cam.initPersProjWithoutDistortion(558, 555, 312, 210); + // Create a grabber based on v4l2 third party lib (for usb cameras under Linux) + vpV4l2Grabber g; + g.setScale(1); + g.setInput(0); + g.setDevice("/dev/video1"); + g.open(I); + // Logitec sphere parameters + cam.initPersProjWithoutDistortion(558, 555, 312, 210); #elif defined(VISP_HAVE_DC1394_2) - // Create a grabber based on libdc1394-2.x third party lib (for firewire cameras under Linux) - vp1394TwoGrabber g(false); - g.setVideoMode(vp1394TwoGrabber::vpVIDEO_MODE_640x480_MONO8); - g.setFramerate(vp1394TwoGrabber::vpFRAMERATE_30); - // AVT Pike 032C parameters - cam.initPersProjWithoutDistortion(800, 795, 320, 216); + // Create a grabber based on libdc1394-2.x third party lib (for firewire cameras under Linux) + vp1394TwoGrabber g(false); + g.setVideoMode(vp1394TwoGrabber::vpVIDEO_MODE_640x480_MONO8); + g.setFramerate(vp1394TwoGrabber::vpFRAMERATE_30); + // AVT Pike 032C parameters + cam.initPersProjWithoutDistortion(800, 795, 320, 216); #elif defined(VISP_HAVE_CMU1394) - // Create a grabber based on CMU 1394 third party lib (for firewire cameras under windows) - vp1394CMUGrabber g; - g.setVideoMode(0, 5); // 640x480 MONO8 - g.setFramerate(4); // 30 Hz - g.open(I); - // AVT Pike 032C parameters - cam.initPersProjWithoutDistortion(800, 795, 320, 216); + // Create a grabber based on CMU 1394 third party lib (for firewire cameras under windows) + vp1394CMUGrabber g; + g.setVideoMode(0, 5); // 640x480 MONO8 + g.setFramerate(4); // 30 Hz + g.open(I); + // AVT Pike 032C parameters + cam.initPersProjWithoutDistortion(800, 795, 320, 216); #endif - // Acquire an image from the grabber - g.acquire(I); + // Acquire an image from the grabber + g.acquire(I); - // Create an image viewer + // Create an image viewer #if defined(VISP_HAVE_X11) - vpDisplayX d(I, 10, 10, "Current frame"); + vpDisplayX d(I, 10, 10, "Current frame"); #elif defined(VISP_HAVE_GDI) - vpDisplayGDI d(I, 10, 10, "Current frame"); + vpDisplayGDI d(I, 10, 10, "Current frame"); #endif - vpDisplay::display(I); - vpDisplay::flush(I); - - // The 3D segment consists in two horizontal dots - vpDot2 dot[2]; - for (int i=0; i <2; i++) - { - dot[i].setGraphics(true); - dot[i].setComputeMoments(true); - dot[i].setEllipsoidShapePrecision(0.); // to track a blob without any constraint on the shape - dot[i].setGrayLevelPrecision(0.9); // to set the blob gray level bounds for binarisation - dot[i].setEllipsoidBadPointsPercentage(0.5); // to be accept 50% of bad inner and outside points with bad gray level - dot[i].initTracking(I); + vpDisplay::display(I); vpDisplay::flush(I); - } - vpServo task; - task.setServo(vpServo::EYEINHAND_L_cVe_eJe) ; - task.setInteractionMatrixType(vpServo::DESIRED, vpServo::PSEUDO_INVERSE) ; - task.setLambda(lambda) ; - vpVelocityTwistMatrix cVe ; // keep to identity - cVe = robot_pan.get_cVe() ; - task.set_cVe(cVe) ; - - std::cout << "cVe: \n" << cVe << std::endl; - - vpMatrix eJe; - - // Update the robot jacobian that depends on the pan position - robot_pan.set_eJe(qm_pan); - // Get the robot jacobian - eJe = robot_pan.get_eJe() ; - task.set_eJe(eJe) ; - std::cout << "eJe: \n" << eJe << std::endl; - - // Define a 3D horizontal segment an its cordinates in the image plane - vpPoint P[2]; - P[0].setWorldCoordinates(-L/2, 0, 0); - P[1].setWorldCoordinates( L/2, 0, 0); - // Define the desired camera position - vpHomogeneousMatrix cMo(0, Y_d, Z_d, 0, 0, 0); // Here we are in front of the segment - for (int i=0; i <2; i++) - { - P[i].changeFrame(cMo); - P[i].project(); // Here the x,y parameters obtained by perspective projection are computed - } + // The 3D segment consists in two horizontal dots + vpDot2 dot[2]; + for (int i=0; i <2; i++) + { + dot[i].setGraphics(true); + dot[i].setComputeMoments(true); + dot[i].setEllipsoidShapePrecision(0.); // to track a blob without any constraint on the shape + dot[i].setGrayLevelPrecision(0.9); // to set the blob gray level bounds for binarisation + dot[i].setEllipsoidBadPointsPercentage(0.5); // to be accept 50% of bad inner and outside points with bad gray level + dot[i].initTracking(I); + vpDisplay::flush(I); + } - // Estimate the depth of the segment extremity points - double surface[2]; - double Z[2]; // Depth of the segment points - for (int i=0; i<2; i++) - { - // Surface of the blob estimated from the image moment m00 and converted in meters - surface[i] = 1./sqrt(dot[i].m00/(cam.get_px()*cam.get_py())); + vpServo task; + task.setServo(vpServo::EYEINHAND_L_cVe_eJe) ; + task.setInteractionMatrixType(vpServo::DESIRED, vpServo::PSEUDO_INVERSE) ; + task.setLambda(lambda) ; + vpVelocityTwistMatrix cVe ; // keep to identity + cVe = robot_pan.get_cVe() ; + task.set_cVe(cVe) ; + + std::cout << "cVe: \n" << cVe << std::endl; + + vpMatrix eJe; + + // Update the robot jacobian that depends on the pan position + robot_pan.set_eJe(qm_pan); + // Get the robot jacobian + eJe = robot_pan.get_eJe() ; + task.set_eJe(eJe) ; + std::cout << "eJe: \n" << eJe << std::endl; + + // Define a 3D horizontal segment an its cordinates in the image plane + vpPoint P[2]; + P[0].setWorldCoordinates(-L/2, 0, 0); + P[1].setWorldCoordinates( L/2, 0, 0); + // Define the desired camera position + vpHomogeneousMatrix cMo(0, Y_d, Z_d, 0, 0, 0); // Here we are in front of the segment + for (int i=0; i <2; i++) + { + P[i].changeFrame(cMo); + P[i].project(); // Here the x,y parameters obtained by perspective projection are computed + } - // Initial depth of the blob - Z[i] = coef * surface[i] ; - } + // Estimate the depth of the segment extremity points + double surface[2]; + double Z[2]; // Depth of the segment points + for (int i=0; i<2; i++) + { + // Surface of the blob estimated from the image moment m00 and converted in meters + surface[i] = 1./sqrt(dot[i].m00/(cam.get_px()*cam.get_py())); + + // Initial depth of the blob + Z[i] = coef * surface[i] ; + } - // Use here a feature segment builder - vpFeatureSegment s_segment(normalized), s_segment_d(normalized); // From the segment feature we use only alpha - vpFeatureBuilder::create(s_segment, cam, dot[0], dot[1]); - s_segment.setZ1(Z[0]); - s_segment.setZ2(Z[1]); - // Set the desired feature - vpFeatureBuilder::create(s_segment_d, P[0], P[1]); - s_segment.setZ1( P[0].get_Z() ); // Desired depth - s_segment.setZ2( P[1].get_Z() ); - - task.addFeature(s_segment, s_segment_d, - vpFeatureSegment::selectXc() | - vpFeatureSegment::selectL() | - vpFeatureSegment::selectAlpha()); + // Use here a feature segment builder + vpFeatureSegment s_segment(normalized), s_segment_d(normalized); // From the segment feature we use only alpha + vpFeatureBuilder::create(s_segment, cam, dot[0], dot[1]); + s_segment.setZ1(Z[0]); + s_segment.setZ2(Z[1]); + // Set the desired feature + vpFeatureBuilder::create(s_segment_d, P[0], P[1]); + s_segment.setZ1( P[0].get_Z() ); // Desired depth + s_segment.setZ2( P[1].get_Z() ); + + task.addFeature(s_segment, s_segment_d, + vpFeatureSegment::selectXc() | + vpFeatureSegment::selectL() | + vpFeatureSegment::selectAlpha()); #ifdef USE_PLOTTER - //Create a window (500 by 500) at position (700, 10) with two graphics - vpPlot graph(2, 500, 500, 700, 10, "Curves..."); - - //The first graphic contains 3 curve and the second graphic contains 3 curves - graph.initGraph(0,3); - graph.initGraph(1,3); - graph.setTitle(0, "Velocities"); - graph.setTitle(1, "Error s-s*"); - graph.setLegend(0, 0, "vx"); - graph.setLegend(0, 1, "wz"); - graph.setLegend(0, 2, "w_pan"); - graph.setLegend(1, 0, "xm/l"); - graph.setLegend(1, 1, "1/l"); - graph.setLegend(1, 2, "alpha"); + //Create a window (500 by 500) at position (700, 10) with two graphics + vpPlot graph(2, 500, 500, 700, 10, "Curves..."); + + //The first graphic contains 3 curve and the second graphic contains 3 curves + graph.initGraph(0,3); + graph.initGraph(1,3); + graph.setTitle(0, "Velocities"); + graph.setTitle(1, "Error s-s*"); + graph.setLegend(0, 0, "vx"); + graph.setLegend(0, 1, "wz"); + graph.setLegend(0, 2, "w_pan"); + graph.setLegend(1, 0, "xm/l"); + graph.setLegend(1, 1, "1/l"); + graph.setLegend(1, 2, "alpha"); #endif - vpColVector v; // vz, wx - unsigned int iter = 0; - try - { - while(1) + vpColVector v; // vz, wx + unsigned int iter = 0; + try { + while(1) + { #ifdef USE_REAL_ROBOT - // Get the new pan position - biclops.getPosition(vpRobot::ARTICULAR_FRAME, qm); + // Get the new pan position + biclops.getPosition(vpRobot::ARTICULAR_FRAME, qm); #endif - qm_pan = qm[0]; - - // Acquire a new image - g.acquire(I); - // Set the image as background of the viewer - vpDisplay::display(I); - - // Display the desired position of the segment - for (int i=0; i<2; i++) - P[i].display(I, cam, vpColor::red, 3); - - // Does the blob tracking - for (int i=0; i<2; i++) - dot[i].track(I); - - for (int i=0; i<2; i++) - { - // Surface of the blob estimated from the image moment m00 and converted in meters - surface[i] = 1./sqrt(dot[i].m00/(cam.get_px()*cam.get_py())); - - // Initial depth of the blob - Z[i] = coef * surface[i] ; - } - - // Update the features - vpFeatureBuilder::create(s_segment, cam, dot[0], dot[1]); - // Update the depth of the point. Useful only if current interaction matrix is used - // when task.setInteractionMatrixType(vpServo::CURRENT, vpServo::PSEUDO_INVERSE) is set - s_segment.setZ1(Z[0]); - s_segment.setZ2(Z[1]); - - robot_pan.get_cVe(cVe); - task.set_cVe(cVe); - - // Update the robot jacobian that depends on the pan position - robot_pan.set_eJe(qm_pan); - // Get the robot jacobian - eJe = robot_pan.get_eJe(); - // Update the jacobian that will be used to compute the control law - task.set_eJe(eJe); - - // Compute the control law. Velocities are computed in the mobile robot reference frame - v = task.computeControlLaw(); - -// std::cout << "-----" << std::endl; -// std::cout << "v: " << v.t() << std::endl; -// std::cout << "error: " << task.getError().t() << std::endl; -// std::cout << "L:\n " << task.getInteractionMatrix() << std::endl; -// std::cout << "eJe:\n " << task.get_eJe() << std::endl; -// std::cout << "cVe:\n " << task.get_cVe() << std::endl; -// std::cout << "L_cVe_eJe:\n" << task.getInteractionMatrix() * task.get_cVe() * task.get_eJe() << std::endl; -// task.print() ; - if (task.getTaskRank() != 3) - std::cout << "Warning: task is of rank " << task.getTaskRank() << std::endl; + qm_pan = qm[0]; + + // Acquire a new image + g.acquire(I); + // Set the image as background of the viewer + vpDisplay::display(I); + + // Display the desired position of the segment + for (int i=0; i<2; i++) + P[i].display(I, cam, vpColor::red, 3); + + // Does the blob tracking + for (int i=0; i<2; i++) + dot[i].track(I); + + for (int i=0; i<2; i++) + { + // Surface of the blob estimated from the image moment m00 and converted in meters + surface[i] = 1./sqrt(dot[i].m00/(cam.get_px()*cam.get_py())); + + // Initial depth of the blob + Z[i] = coef * surface[i] ; + } + + // Update the features + vpFeatureBuilder::create(s_segment, cam, dot[0], dot[1]); + // Update the depth of the point. Useful only if current interaction matrix is used + // when task.setInteractionMatrixType(vpServo::CURRENT, vpServo::PSEUDO_INVERSE) is set + s_segment.setZ1(Z[0]); + s_segment.setZ2(Z[1]); + + robot_pan.get_cVe(cVe); + task.set_cVe(cVe); + + // Update the robot jacobian that depends on the pan position + robot_pan.set_eJe(qm_pan); + // Get the robot jacobian + eJe = robot_pan.get_eJe(); + // Update the jacobian that will be used to compute the control law + task.set_eJe(eJe); + + // Compute the control law. Velocities are computed in the mobile robot reference frame + v = task.computeControlLaw(); + + // std::cout << "-----" << std::endl; + // std::cout << "v: " << v.t() << std::endl; + // std::cout << "error: " << task.getError().t() << std::endl; + // std::cout << "L:\n " << task.getInteractionMatrix() << std::endl; + // std::cout << "eJe:\n " << task.get_eJe() << std::endl; + // std::cout << "cVe:\n " << task.get_cVe() << std::endl; + // std::cout << "L_cVe_eJe:\n" << task.getInteractionMatrix() * task.get_cVe() * task.get_eJe() << std::endl; + // task.print() ; + if (task.getTaskRank() != 3) + std::cout << "Warning: task is of rank " << task.getTaskRank() << std::endl; #ifdef USE_PLOTTER - graph.plot(0, iter, v); // plot velocities applied to the robot - graph.plot(1, iter, task.getError()); // plot error vector + graph.plot(0, iter, v); // plot velocities applied to the robot + graph.plot(1, iter, task.getError()); // plot error vector #endif #ifdef USE_REAL_ROBOT - // Send the velocity to the robot - vpColVector v_pioneer(2); // vx, wz - v_pioneer[0] = v[0]; - v_pioneer[1] = v[1]; - vpColVector v_biclops(2); // qdot pan and tilt - v_biclops[0] = v[2]; - v_biclops[1] = 0; - - std::cout << "Send velocity to the pionner: " << v_pioneer[0] << " m/s " - << vpMath::deg(v_pioneer[1]) << " deg/s" << std::endl; - std::cout << "Send velocity to the biclops head: " << vpMath::deg(v_biclops[0]) << " deg/s" << std::endl; - - pioneer.setVelocity(vpRobot::REFERENCE_FRAME, v_pioneer); - biclops.setVelocity(vpRobot::ARTICULAR_FRAME, v_biclops) ; + // Send the velocity to the robot + vpColVector v_pioneer(2); // vx, wz + v_pioneer[0] = v[0]; + v_pioneer[1] = v[1]; + vpColVector v_biclops(2); // qdot pan and tilt + v_biclops[0] = v[2]; + v_biclops[1] = 0; + + std::cout << "Send velocity to the pionner: " << v_pioneer[0] << " m/s " + << vpMath::deg(v_pioneer[1]) << " deg/s" << std::endl; + std::cout << "Send velocity to the biclops head: " << vpMath::deg(v_biclops[0]) << " deg/s" << std::endl; + + pioneer.setVelocity(vpRobot::REFERENCE_FRAME, v_pioneer); + biclops.setVelocity(vpRobot::ARTICULAR_FRAME, v_biclops) ; #endif - // Draw a vertical line which corresponds to the desired x coordinate of the dot cog - vpDisplay::displayLine(I, 0, cam.get_u0(), 479, cam.get_u0(), vpColor::red); - vpDisplay::flush(I); + // Draw a vertical line which corresponds to the desired x coordinate of the dot cog + vpDisplay::displayLine(I, 0, cam.get_u0(), 479, cam.get_u0(), vpColor::red); + vpDisplay::flush(I); - // A click in the viewer to exit - if ( vpDisplay::getClick(I, false) ) - break; + // A click in the viewer to exit + if ( vpDisplay::getClick(I, false) ) + break; - iter ++; - //break; + iter ++; + //break; + } + } + catch(...) + { } - } - catch(...) - { - } #ifdef USE_REAL_ROBOT - std::cout << "Ending robot thread..." << std::endl; - pioneer.stopRunning(); + std::cout << "Ending robot thread..." << std::endl; + pioneer.stopRunning(); - // wait for the thread to stop - pioneer.waitForRunExit(); + // wait for the thread to stop + pioneer.waitForRunExit(); #endif - // Kill the servo task - task.print() ; - task.kill(); - + // Kill the servo task + task.print() ; + task.kill(); + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } #endif #endif } diff --git a/example/servo-pioneer/servoPioneerPoint2DDepth.cpp b/example/servo-pioneer/servoPioneerPoint2DDepth.cpp index b2f57cfc8f0afae94391bc886c3d271a5d8c51b8..39ebfbfdd86b0395851e935bef39ceddaad35f04 100644 --- a/example/servo-pioneer/servoPioneerPoint2DDepth.cpp +++ b/example/servo-pioneer/servoPioneerPoint2DDepth.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoPioneerPoint2DDepth.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: servoPioneerPoint2DDepth.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -93,169 +93,168 @@ #ifdef TEST_COULD_BE_ACHIEVED int main(int argc, char **argv) { - vpImage<unsigned char> I; // Create a gray level image container - double depth = 1.; - double lambda = 0.6; - double coef = 1./6.77; // Scale parameter used to estimate the depth Z of the blob from its surface - - vpRobotPioneer robot; - ArArgumentParser parser(&argc, argv); - parser.loadDefaultArguments(); - - // ArRobotConnector connects to the robot, get some initial data from it such as type and name, - // and then loads parameter files for this robot. - ArRobotConnector robotConnector(&parser, &robot); - if(!robotConnector.connectRobot()) - { - ArLog::log(ArLog::Terse, "Could not connect to the robot."); - if(parser.checkHelpAndWarnUnparsed()) + try { + vpImage<unsigned char> I; // Create a gray level image container + double depth = 1.; + double lambda = 0.6; + double coef = 1./6.77; // Scale parameter used to estimate the depth Z of the blob from its surface + + vpRobotPioneer robot; + ArArgumentParser parser(&argc, argv); + parser.loadDefaultArguments(); + + // ArRobotConnector connects to the robot, get some initial data from it such as type and name, + // and then loads parameter files for this robot. + ArRobotConnector robotConnector(&parser, &robot); + if(!robotConnector.connectRobot()) + { + ArLog::log(ArLog::Terse, "Could not connect to the robot."); + if(parser.checkHelpAndWarnUnparsed()) + { + Aria::logOptions(); + Aria::exit(1); + } + } + if (!Aria::parseArgs()) { Aria::logOptions(); - Aria::exit(1); + Aria::shutdown(); + return false; } - } - if (!Aria::parseArgs()) - { - Aria::logOptions(); - Aria::shutdown(); - return false; - } - // Wait 3 sec to be sure that the low level Aria thread used to control - // the robot is started. Without this delay we experienced a delay (arround 2.2 sec) - // between the velocity send to the robot and the velocity that is really applied - // to the wheels. - vpTime::sleepMs(3000); + // Wait 3 sec to be sure that the low level Aria thread used to control + // the robot is started. Without this delay we experienced a delay (arround 2.2 sec) + // between the velocity send to the robot and the velocity that is really applied + // to the wheels. + vpTime::sleepMs(3000); - std::cout << "Robot connected" << std::endl; + std::cout << "Robot connected" << std::endl; - // Camera parameters. In this experiment we don't need a precise calibration of the camera - vpCameraParameters cam; + // Camera parameters. In this experiment we don't need a precise calibration of the camera + vpCameraParameters cam; - // Create the camera framegrabber + // Create the camera framegrabber #if defined(VISP_HAVE_OPENCV) - int device = 1; - std::cout << "Use device: " << device << std::endl; - cv::VideoCapture g(device); // open the default camera - g.set(CV_CAP_PROP_FRAME_WIDTH, 640); - g.set(CV_CAP_PROP_FRAME_HEIGHT, 480); - if(!g.isOpened()) // check if we succeeded - return -1; - cv::Mat frame; - g >> frame; // get a new frame from camera - vpImageConvert::convert(frame, I); - - // Logitec sphere parameters - cam.initPersProjWithoutDistortion(558, 555, 312, 210); + int device = 1; + std::cout << "Use device: " << device << std::endl; + cv::VideoCapture g(device); // open the default camera + g.set(CV_CAP_PROP_FRAME_WIDTH, 640); + g.set(CV_CAP_PROP_FRAME_HEIGHT, 480); + if(!g.isOpened()) // check if we succeeded + return -1; + cv::Mat frame; + g >> frame; // get a new frame from camera + vpImageConvert::convert(frame, I); + + // Logitec sphere parameters + cam.initPersProjWithoutDistortion(558, 555, 312, 210); #elif defined(VISP_HAVE_V4L2) - // Create a grabber based on v4l2 third party lib (for usb cameras under Linux) - vpV4l2Grabber g; - g.setScale(1); - g.setInput(0); - g.setDevice("/dev/video1"); - g.open(I); - // Logitec sphere parameters - cam.initPersProjWithoutDistortion(558, 555, 312, 210); + // Create a grabber based on v4l2 third party lib (for usb cameras under Linux) + vpV4l2Grabber g; + g.setScale(1); + g.setInput(0); + g.setDevice("/dev/video1"); + g.open(I); + // Logitec sphere parameters + cam.initPersProjWithoutDistortion(558, 555, 312, 210); #elif defined(VISP_HAVE_DC1394_2) - // Create a grabber based on libdc1394-2.x third party lib (for firewire cameras under Linux) - vp1394TwoGrabber g(false); - g.setVideoMode(vp1394TwoGrabber::vpVIDEO_MODE_640x480_MONO8); - g.setFramerate(vp1394TwoGrabber::vpFRAMERATE_30); - // AVT Pike 032C parameters - cam.initPersProjWithoutDistortion(800, 795, 320, 216); + // Create a grabber based on libdc1394-2.x third party lib (for firewire cameras under Linux) + vp1394TwoGrabber g(false); + g.setVideoMode(vp1394TwoGrabber::vpVIDEO_MODE_640x480_MONO8); + g.setFramerate(vp1394TwoGrabber::vpFRAMERATE_30); + // AVT Pike 032C parameters + cam.initPersProjWithoutDistortion(800, 795, 320, 216); #elif defined(VISP_HAVE_CMU1394) - // Create a grabber based on CMU 1394 third party lib (for firewire cameras under windows) - vp1394CMUGrabber g; - g.setVideoMode(0, 5); // 640x480 MONO8 - g.setFramerate(4); // 30 Hz - g.open(I); - // AVT Pike 032C parameters - cam.initPersProjWithoutDistortion(800, 795, 320, 216); + // Create a grabber based on CMU 1394 third party lib (for firewire cameras under windows) + vp1394CMUGrabber g; + g.setVideoMode(0, 5); // 640x480 MONO8 + g.setFramerate(4); // 30 Hz + g.open(I); + // AVT Pike 032C parameters + cam.initPersProjWithoutDistortion(800, 795, 320, 216); #endif - // Acquire an image from the grabber + // Acquire an image from the grabber #if defined(VISP_HAVE_OPENCV) - g >> frame; // get a new frame from camera - vpImageConvert::convert(frame, I); + g >> frame; // get a new frame from camera + vpImageConvert::convert(frame, I); #else - g.acquire(I); + g.acquire(I); #endif - // Create an image viewer + // Create an image viewer #if defined(VISP_HAVE_X11) - vpDisplayX d(I, 10, 10, "Current frame"); + vpDisplayX d(I, 10, 10, "Current frame"); #elif defined(VISP_HAVE_GDI) - vpDisplayGDI d(I, 10, 10, "Current frame"); + vpDisplayGDI d(I, 10, 10, "Current frame"); #endif - vpDisplay::display(I); - vpDisplay::flush(I); - - // Create a blob tracker - vpDot2 dot; - dot.setGraphics(true); - dot.setComputeMoments(true); - dot.setEllipsoidShapePrecision(0.); // to track a blob without any constraint on the shape - dot.setGrayLevelPrecision(0.9); // to set the blob gray level bounds for binarisation - dot.setEllipsoidBadPointsPercentage(0.5); // to be accept 50% of bad inner and outside points with bad gray level - dot.initTracking(I); - vpDisplay::flush(I); - - vpServo task; - task.setServo(vpServo::EYEINHAND_L_cVe_eJe) ; - task.setInteractionMatrixType(vpServo::DESIRED, vpServo::PSEUDO_INVERSE) ; - task.setLambda(lambda) ; - vpVelocityTwistMatrix cVe ; - cVe = robot.get_cVe() ; - task.set_cVe(cVe) ; - - std::cout << "cVe: \n" << cVe << std::endl; - - vpMatrix eJe; - robot.get_eJe(eJe) ; - task.set_eJe(eJe) ; - std::cout << "eJe: \n" << eJe << std::endl; - - // Current and desired visual feature associated to the x coordinate of the point - vpFeaturePoint s_x, s_xd; - - // Create the current x visual feature - vpFeatureBuilder::create(s_x, cam, dot); - - // Create the desired x* visual feature - s_xd.buildFrom(0, 0, depth); - - // Add the feature - task.addFeature(s_x, s_xd) ; - - // Create the current log(Z/Z*) visual feature - vpFeatureDepth s_Z, s_Zd; - // Surface of the blob estimated from the image moment m00 and converted in meters - double surface = 1./sqrt(dot.m00/(cam.get_px()*cam.get_py())); - double Z, Zd; - // Initial depth of the blob in from of the camera - Z = coef * surface ; - // Desired depth Z* of the blob. This depth is learned and equal to the initial depth - Zd = Z; - - std::cout << "Z " << Z << std::endl; - s_Z.buildFrom(s_x.get_x(), s_x.get_y(), Z , 0); // log(Z/Z*) = 0 that's why the last parameter is 0 - s_Zd.buildFrom(s_x.get_x(), s_x.get_y(), Zd , 0); // log(Z/Z*) = 0 that's why the last parameter is 0 - - // Add the feature - task.addFeature(s_Z, s_Zd) ; - - vpColVector v; // vz, wx - - try - { + vpDisplay::display(I); + vpDisplay::flush(I); + + // Create a blob tracker + vpDot2 dot; + dot.setGraphics(true); + dot.setComputeMoments(true); + dot.setEllipsoidShapePrecision(0.); // to track a blob without any constraint on the shape + dot.setGrayLevelPrecision(0.9); // to set the blob gray level bounds for binarisation + dot.setEllipsoidBadPointsPercentage(0.5); // to be accept 50% of bad inner and outside points with bad gray level + dot.initTracking(I); + vpDisplay::flush(I); + + vpServo task; + task.setServo(vpServo::EYEINHAND_L_cVe_eJe) ; + task.setInteractionMatrixType(vpServo::DESIRED, vpServo::PSEUDO_INVERSE) ; + task.setLambda(lambda) ; + vpVelocityTwistMatrix cVe ; + cVe = robot.get_cVe() ; + task.set_cVe(cVe) ; + + std::cout << "cVe: \n" << cVe << std::endl; + + vpMatrix eJe; + robot.get_eJe(eJe) ; + task.set_eJe(eJe) ; + std::cout << "eJe: \n" << eJe << std::endl; + + // Current and desired visual feature associated to the x coordinate of the point + vpFeaturePoint s_x, s_xd; + + // Create the current x visual feature + vpFeatureBuilder::create(s_x, cam, dot); + + // Create the desired x* visual feature + s_xd.buildFrom(0, 0, depth); + + // Add the feature + task.addFeature(s_x, s_xd) ; + + // Create the current log(Z/Z*) visual feature + vpFeatureDepth s_Z, s_Zd; + // Surface of the blob estimated from the image moment m00 and converted in meters + double surface = 1./sqrt(dot.m00/(cam.get_px()*cam.get_py())); + double Z, Zd; + // Initial depth of the blob in from of the camera + Z = coef * surface ; + // Desired depth Z* of the blob. This depth is learned and equal to the initial depth + Zd = Z; + + std::cout << "Z " << Z << std::endl; + s_Z.buildFrom(s_x.get_x(), s_x.get_y(), Z , 0); // log(Z/Z*) = 0 that's why the last parameter is 0 + s_Zd.buildFrom(s_x.get_x(), s_x.get_y(), Zd , 0); // log(Z/Z*) = 0 that's why the last parameter is 0 + + // Add the feature + task.addFeature(s_Z, s_Zd) ; + + vpColVector v; // vz, wx + while(1) { // Acquire a new image #if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100) - g >> frame; // get a new frame from camera - vpImageConvert::convert(frame, I); + g >> frame; // get a new frame from camera + vpImageConvert::convert(frame, I); #else - g.acquire(I); + g.acquire(I); #endif // Set the image as background of the viewer vpDisplay::display(I); @@ -293,20 +292,21 @@ int main(int argc, char **argv) if ( vpDisplay::getClick(I, false) ) break; } - } - catch(...) - { - } - std::cout << "Ending robot thread..." << std::endl; - robot.stopRunning(); + std::cout << "Ending robot thread..." << std::endl; + robot.stopRunning(); - // wait for the thread to stop - robot.waitForRunExit(); + // wait for the thread to stop + robot.waitForRunExit(); - // Kill the servo task - task.print() ; - task.kill(); + // Kill the servo task + task.print() ; + task.kill(); + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } #else int main() diff --git a/example/servo-pioneer/servoPioneerPoint2DDepthWithoutVpServo.cpp b/example/servo-pioneer/servoPioneerPoint2DDepthWithoutVpServo.cpp index 3e7f0437116767d0bf50322aa87e1469acdacdce..610da20df53025bc1480a6e654989fd2c357cbfb 100644 --- a/example/servo-pioneer/servoPioneerPoint2DDepthWithoutVpServo.cpp +++ b/example/servo-pioneer/servoPioneerPoint2DDepthWithoutVpServo.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoPioneerPoint2DDepthWithoutVpServo.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: servoPioneerPoint2DDepthWithoutVpServo.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -91,150 +91,149 @@ #ifdef TEST_COULD_BE_ACHIEVED int main(int argc, char **argv) { - vpImage<unsigned char> I; // Create a gray level image container - double depth = 1.; - double lambda = 0.6; - double coef = 1./6.77; // Scale parameter used to estimate the depth Z of the blob from its surface - - vpRobotPioneer robot; - ArArgumentParser parser(&argc, argv); - parser.loadDefaultArguments(); - - // ArRobotConnector connects to the robot, get some initial data from it such as type and name, - // and then loads parameter files for this robot. - ArRobotConnector robotConnector(&parser, &robot); - if(!robotConnector.connectRobot()) - { - ArLog::log(ArLog::Terse, "Could not connect to the robot."); - if(parser.checkHelpAndWarnUnparsed()) + try { + vpImage<unsigned char> I; // Create a gray level image container + double depth = 1.; + double lambda = 0.6; + double coef = 1./6.77; // Scale parameter used to estimate the depth Z of the blob from its surface + + vpRobotPioneer robot; + ArArgumentParser parser(&argc, argv); + parser.loadDefaultArguments(); + + // ArRobotConnector connects to the robot, get some initial data from it such as type and name, + // and then loads parameter files for this robot. + ArRobotConnector robotConnector(&parser, &robot); + if(!robotConnector.connectRobot()) + { + ArLog::log(ArLog::Terse, "Could not connect to the robot."); + if(parser.checkHelpAndWarnUnparsed()) + { + Aria::logOptions(); + Aria::exit(1); + } + } + if (!Aria::parseArgs()) { Aria::logOptions(); - Aria::exit(1); + Aria::shutdown(); + return false; } - } - if (!Aria::parseArgs()) - { - Aria::logOptions(); - Aria::shutdown(); - return false; - } - // Wait 3 sec to be sure that the low level Aria thread used to control - // the robot is started. Without this delay we experienced a delay (arround 2.2 sec) - // between the velocity send to the robot and the velocity that is really applied - // to the wheels. - vpTime::sleepMs(3000); + // Wait 3 sec to be sure that the low level Aria thread used to control + // the robot is started. Without this delay we experienced a delay (arround 2.2 sec) + // between the velocity send to the robot and the velocity that is really applied + // to the wheels. + vpTime::sleepMs(3000); - std::cout << "Robot connected" << std::endl; + std::cout << "Robot connected" << std::endl; - // Camera parameters. In this experiment we don't need a precise calibration of the camera - vpCameraParameters cam; + // Camera parameters. In this experiment we don't need a precise calibration of the camera + vpCameraParameters cam; - // Create the camera framegrabber + // Create the camera framegrabber #if defined(VISP_HAVE_OPENCV) - int device = 1; - std::cout << "Use device: " << device << std::endl; - cv::VideoCapture g(device); // open the default camera - g.set(CV_CAP_PROP_FRAME_WIDTH, 640); - g.set(CV_CAP_PROP_FRAME_HEIGHT, 480); - if(!g.isOpened()) // check if we succeeded - return -1; - cv::Mat frame; - g >> frame; // get a new frame from camera - vpImageConvert::convert(frame, I); - - // Logitec sphere parameters - cam.initPersProjWithoutDistortion(558, 555, 312, 210); + int device = 1; + std::cout << "Use device: " << device << std::endl; + cv::VideoCapture g(device); // open the default camera + g.set(CV_CAP_PROP_FRAME_WIDTH, 640); + g.set(CV_CAP_PROP_FRAME_HEIGHT, 480); + if(!g.isOpened()) // check if we succeeded + return -1; + cv::Mat frame; + g >> frame; // get a new frame from camera + vpImageConvert::convert(frame, I); + + // Logitec sphere parameters + cam.initPersProjWithoutDistortion(558, 555, 312, 210); #elif defined(VISP_HAVE_V4L2) - // Create a grabber based on v4l2 third party lib (for usb cameras under Linux) - vpV4l2Grabber g; - g.setScale(1); - g.setInput(0); - g.setDevice("/dev/video1"); - g.open(I); - // Logitec sphere parameters - cam.initPersProjWithoutDistortion(558, 555, 312, 210); + // Create a grabber based on v4l2 third party lib (for usb cameras under Linux) + vpV4l2Grabber g; + g.setScale(1); + g.setInput(0); + g.setDevice("/dev/video1"); + g.open(I); + // Logitec sphere parameters + cam.initPersProjWithoutDistortion(558, 555, 312, 210); #elif defined(VISP_HAVE_DC1394_2) - // Create a grabber based on libdc1394-2.x third party lib (for firewire cameras under Linux) - vp1394TwoGrabber g(false); - g.setVideoMode(vp1394TwoGrabber::vpVIDEO_MODE_640x480_MONO8); - g.setFramerate(vp1394TwoGrabber::vpFRAMERATE_30); - // AVT Pike 032C parameters - cam.initPersProjWithoutDistortion(800, 795, 320, 216); + // Create a grabber based on libdc1394-2.x third party lib (for firewire cameras under Linux) + vp1394TwoGrabber g(false); + g.setVideoMode(vp1394TwoGrabber::vpVIDEO_MODE_640x480_MONO8); + g.setFramerate(vp1394TwoGrabber::vpFRAMERATE_30); + // AVT Pike 032C parameters + cam.initPersProjWithoutDistortion(800, 795, 320, 216); #elif defined(VISP_HAVE_CMU1394) - // Create a grabber based on CMU 1394 third party lib (for firewire cameras under windows) - vp1394CMUGrabber g; - g.setVideoMode(0, 5); // 640x480 MONO8 - g.setFramerate(4); // 30 Hz - g.open(I); - // AVT Pike 032C parameters - cam.initPersProjWithoutDistortion(800, 795, 320, 216); + // Create a grabber based on CMU 1394 third party lib (for firewire cameras under windows) + vp1394CMUGrabber g; + g.setVideoMode(0, 5); // 640x480 MONO8 + g.setFramerate(4); // 30 Hz + g.open(I); + // AVT Pike 032C parameters + cam.initPersProjWithoutDistortion(800, 795, 320, 216); #endif - // Acquire an image from the grabber + // Acquire an image from the grabber #if defined(VISP_HAVE_OPENCV) - g >> frame; // get a new frame from camera - vpImageConvert::convert(frame, I); + g >> frame; // get a new frame from camera + vpImageConvert::convert(frame, I); #else - g.acquire(I); + g.acquire(I); #endif - // Create an image viewer + // Create an image viewer #if defined(VISP_HAVE_X11) - vpDisplayX d(I, 10, 10, "Current frame"); + vpDisplayX d(I, 10, 10, "Current frame"); #elif defined(VISP_HAVE_GDI) - vpDisplayGDI d(I, 10, 10, "Current frame"); + vpDisplayGDI d(I, 10, 10, "Current frame"); #endif - vpDisplay::display(I); - vpDisplay::flush(I); - - // Create a blob tracker - vpDot2 dot; - dot.setGraphics(true); - dot.setComputeMoments(true); - dot.setEllipsoidShapePrecision(0.); // to track a blob without any constraint on the shape - dot.setGrayLevelPrecision(0.9); // to set the blob gray level bounds for binarisation - dot.setEllipsoidBadPointsPercentage(0.5); // to be accept 50% of bad inner and outside points with bad gray level - dot.initTracking(I); - vpDisplay::flush(I); - - // Current and desired visual feature associated to the x coordinate of the point - vpFeaturePoint s_x, s_xd; - - // Create the current x visual feature - vpFeatureBuilder::create(s_x, cam, dot); - - // Create the desired x* visual feature - s_xd.buildFrom(0, 0, depth); - vpMatrix L_x = s_xd.interaction(vpFeaturePoint::selectX()); - - // Create the current log(Z/Z*) visual feature - vpFeatureDepth s_Z; - // Surface of the blob estimated from the image moment m00 and converted in meters - double surface = 1./sqrt(dot.m00/(cam.get_px()*cam.get_py())); - double Z, Zd; - // Initial depth of the blob in from of the camera - Z = coef * surface ; - // Desired depth Z* of the blob. This depth is learned and equal to the initial depth - Zd = Z; - s_Z.buildFrom(s_x.get_x(), s_x.get_y(), Z , 0); // log(Z/Z*) = 0 that's why the last parameter is 0 - vpMatrix L_Z = s_Z.interaction(); - - vpVelocityTwistMatrix cVe = robot.get_cVe(); - vpMatrix eJe; // pioneer jacobian - robot.get_eJe(eJe); - - vpMatrix L; // Interaction matrix - L.stackMatrices(L_x); // constant since build with the desired feature - L.stackMatrices(L_Z); // not constant since it corresponds to log(Z/Z*) that evolves at each iteration - - vpColVector v; // vz, wx - - vpFeatureDepth s_Zd; - s_Zd.buildFrom(0, 0, 1, 0); // The value of s* is 0 with Z=1 meter. - - try - { + vpDisplay::display(I); + vpDisplay::flush(I); + + // Create a blob tracker + vpDot2 dot; + dot.setGraphics(true); + dot.setComputeMoments(true); + dot.setEllipsoidShapePrecision(0.); // to track a blob without any constraint on the shape + dot.setGrayLevelPrecision(0.9); // to set the blob gray level bounds for binarisation + dot.setEllipsoidBadPointsPercentage(0.5); // to be accept 50% of bad inner and outside points with bad gray level + dot.initTracking(I); + vpDisplay::flush(I); + + // Current and desired visual feature associated to the x coordinate of the point + vpFeaturePoint s_x, s_xd; + + // Create the current x visual feature + vpFeatureBuilder::create(s_x, cam, dot); + + // Create the desired x* visual feature + s_xd.buildFrom(0, 0, depth); + vpMatrix L_x = s_xd.interaction(vpFeaturePoint::selectX()); + + // Create the current log(Z/Z*) visual feature + vpFeatureDepth s_Z; + // Surface of the blob estimated from the image moment m00 and converted in meters + double surface = 1./sqrt(dot.m00/(cam.get_px()*cam.get_py())); + double Z, Zd; + // Initial depth of the blob in from of the camera + Z = coef * surface ; + // Desired depth Z* of the blob. This depth is learned and equal to the initial depth + Zd = Z; + s_Z.buildFrom(s_x.get_x(), s_x.get_y(), Z , 0); // log(Z/Z*) = 0 that's why the last parameter is 0 + vpMatrix L_Z = s_Z.interaction(); + + vpVelocityTwistMatrix cVe = robot.get_cVe(); + vpMatrix eJe; // pioneer jacobian + robot.get_eJe(eJe); + + vpMatrix L; // Interaction matrix + L.stackMatrices(L_x); // constant since build with the desired feature + L.stackMatrices(L_Z); // not constant since it corresponds to log(Z/Z*) that evolves at each iteration + + vpColVector v; // vz, wx + + vpFeatureDepth s_Zd; + s_Zd.buildFrom(0, 0, 1, 0); // The value of s* is 0 with Z=1 meter. + while(1) { // Acquire a new image @@ -285,16 +284,17 @@ int main(int argc, char **argv) if ( vpDisplay::getClick(I, false) ) break; } - } - catch(...) - { - } - std::cout << "Ending robot thread..." << std::endl; - robot.stopRunning(); + std::cout << "Ending robot thread..." << std::endl; + robot.stopRunning(); - // wait for the thread to stop - robot.waitForRunExit(); + // wait for the thread to stop + robot.waitForRunExit(); + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } #else int main() diff --git a/example/servo-pioneer/sonarPioneerReader.cpp b/example/servo-pioneer/sonarPioneerReader.cpp index 9c8cf4f8287231cc11d13237bbd0115c1193b22a..531fb8b332b0015443abb6e4e60bee3b5feaf792 100644 --- a/example/servo-pioneer/sonarPioneerReader.cpp +++ b/example/servo-pioneer/sonarPioneerReader.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: sonarPioneerReader.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: sonarPioneerReader.cpp 4604 2014-01-21 14:15:23Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -207,142 +207,148 @@ void sonarPrinter(void) */ int main(int argc, char **argv) { - ArArgumentParser parser(&argc, argv); - parser.loadDefaultArguments(); + try { + ArArgumentParser parser(&argc, argv); + parser.loadDefaultArguments(); - robot = new vpRobotPioneer; + robot = new vpRobotPioneer; - // ArRobotConnector connects to the robot, get some initial data from it such as type and name, - // and then loads parameter files for this robot. - ArRobotConnector robotConnector(&parser, robot); - if(!robotConnector.connectRobot()) - { - ArLog::log(ArLog::Terse, "Could not connect to the robot"); - if(parser.checkHelpAndWarnUnparsed()) + // ArRobotConnector connects to the robot, get some initial data from it such as type and name, + // and then loads parameter files for this robot. + ArRobotConnector robotConnector(&parser, robot); + if(!robotConnector.connectRobot()) + { + ArLog::log(ArLog::Terse, "Could not connect to the robot"); + if(parser.checkHelpAndWarnUnparsed()) + { + Aria::logOptions(); + Aria::exit(1); + } + } + if (!Aria::parseArgs()) { Aria::logOptions(); - Aria::exit(1); + Aria::shutdown(); + return false; } - } - if (!Aria::parseArgs()) - { - Aria::logOptions(); - Aria::shutdown(); - return false; - } - - std::cout << "Robot connected" << std::endl; + + std::cout << "Robot connected" << std::endl; #if defined(VISP_HAVE_X11) || defined (VISP_HAVE_GDI) - // Create a display to show sensor data - if (isInitialized == false) - { - I.resize(half_size*2, half_size*2); - I = 255; + // Create a display to show sensor data + if (isInitialized == false) + { + I.resize(half_size*2, half_size*2); + I = 255; #if defined(VISP_HAVE_X11) - d = new vpDisplayX; + d = new vpDisplayX; #elif defined (VISP_HAVE_GDI) - d = new vpDisplayGDI; + d = new vpDisplayGDI; #endif - d->init(I, -1, -1, "Sonar range data"); - isInitialized = true; - } + d->init(I, -1, -1, "Sonar range data"); + isInitialized = true; + } #endif - // Activates the sonar - ArGlobalFunctor sonarPrinterCB(&sonarPrinter); - robot->addRangeDevice(&sonar); - robot->addUserTask("Sonar printer", 50, &sonarPrinterCB); + // Activates the sonar + ArGlobalFunctor sonarPrinterCB(&sonarPrinter); + robot->addRangeDevice(&sonar); + robot->addUserTask("Sonar printer", 50, &sonarPrinterCB); - robot->useSonar(true); // activates the sonar device usage + robot->useSonar(true); // activates the sonar device usage - // Robot velocities - vpColVector v_mes(2); + // Robot velocities + vpColVector v_mes(2); - for (int i=0; i < 1000; i++) - { - double t = vpTime::measureTimeMs(); + for (int i=0; i < 1000; i++) + { + double t = vpTime::measureTimeMs(); - v_mes = robot->getVelocity(vpRobot::REFERENCE_FRAME); - std::cout << "Trans. vel= " << v_mes[0] << " m/s, Rot. vel=" << vpMath::deg(v_mes[1]) << " deg/s" << std::endl; - v_mes = robot->getVelocity(vpRobot::ARTICULAR_FRAME); - std::cout << "Left wheel vel= " << v_mes[0] << " m/s, Right wheel vel=" << v_mes[1] << " m/s" << std::endl; - std::cout << "Battery=" << robot->getBatteryVoltage() << std::endl; + v_mes = robot->getVelocity(vpRobot::REFERENCE_FRAME); + std::cout << "Trans. vel= " << v_mes[0] << " m/s, Rot. vel=" << vpMath::deg(v_mes[1]) << " deg/s" << std::endl; + v_mes = robot->getVelocity(vpRobot::ARTICULAR_FRAME); + std::cout << "Left wheel vel= " << v_mes[0] << " m/s, Right wheel vel=" << v_mes[1] << " m/s" << std::endl; + std::cout << "Battery=" << robot->getBatteryVoltage() << std::endl; #if defined(VISP_HAVE_X11) || defined (VISP_HAVE_GDI) - if (isInitialized) { - // A mouse click to exit - // Before exiting save the last sonar image - if (vpDisplay::getClick(I, false) == true) { - { - // Set the default output path - std::string opath; -#ifdef UNIX - opath = "/tmp"; -#elif WIN32 - opath = "C:\\temp"; + if (isInitialized) { + // A mouse click to exit + // Before exiting save the last sonar image + if (vpDisplay::getClick(I, false) == true) { + { + // Set the default output path + std::string opath; +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX + opath = "/tmp"; +#elif defined(_WIN32) + opath = "C:\\temp"; #endif - std::string username = vpIoTools::getUserName(); - - // Append to the output path string, the login name of the user - opath += vpIoTools::path("/") + username; - - // Test if the output path exist. If no try to create it - if (vpIoTools::checkDirectory(opath) == false) { - try { - // Create the dirname - vpIoTools::makeDirectory(opath); - } - catch (...) { - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Cannot create " << opath << std::endl; - exit(-1); + std::string username = vpIoTools::getUserName(); + + // Append to the output path string, the login name of the user + opath += vpIoTools::path("/") + username; + + // Test if the output path exist. If no try to create it + if (vpIoTools::checkDirectory(opath) == false) { + try { + // Create the dirname + vpIoTools::makeDirectory(opath); + } + catch (...) { + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Cannot create " << opath << std::endl; + exit(-1); + } } + std::string filename = opath + "/sonar.png"; + vpImage<vpRGBa> C; + vpDisplay::getImage(I, C); + vpImageIo::write(C, filename); } - std::string filename = opath + "/sonar.png"; - vpImage<vpRGBa> C; - vpDisplay::getImage(I, C); - vpImageIo::write(C, filename); + break; } - break; } - } #endif - vpTime::wait(t, 40); - } + vpTime::wait(t, 40); + } - ArLog::log(ArLog::Normal, "simpleMotionCommands: Stopping."); - robot->lock(); - robot->stop(); - robot->unlock(); - ArUtil::sleep(1000); + ArLog::log(ArLog::Normal, "simpleMotionCommands: Stopping."); + robot->lock(); + robot->stop(); + robot->unlock(); + ArUtil::sleep(1000); - robot->lock(); - ArLog::log(ArLog::Normal, "simpleMotionCommands: Pose=(%.2f,%.2f,%.2f), Trans. Vel=%.2f, Rot. Vel=%.2f, Battery=%.2fV", - robot->getX(), robot->getY(), robot->getTh(), robot->getVel(), robot->getRotVel(), robot->getBatteryVoltage()); - robot->unlock(); + robot->lock(); + ArLog::log(ArLog::Normal, "simpleMotionCommands: Pose=(%.2f,%.2f,%.2f), Trans. Vel=%.2f, Rot. Vel=%.2f, Battery=%.2fV", + robot->getX(), robot->getY(), robot->getTh(), robot->getVel(), robot->getRotVel(), robot->getBatteryVoltage()); + robot->unlock(); - std::cout << "Ending robot thread..." << std::endl; - robot->stopRunning(); + std::cout << "Ending robot thread..." << std::endl; + robot->stopRunning(); #if defined(VISP_HAVE_X11) || defined (VISP_HAVE_GDI) - if (isInitialized) { - if (d != NULL) - delete d; - } + if (isInitialized) { + if (d != NULL) + delete d; + } #endif - // wait for the thread to stop - robot->waitForRunExit(); + // wait for the thread to stop + robot->waitForRunExit(); - delete robot; + delete robot; - // exit - ArLog::log(ArLog::Normal, "simpleMotionCommands: Exiting."); - return 0; + // exit + ArLog::log(ArLog::Normal, "simpleMotionCommands: Exiting."); + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } #endif diff --git a/example/servo-ptu46/CMakeLists.txt b/example/servo-ptu46/CMakeLists.txt index c8ec1bbecb26699d01311ef199a1eca6acf13c76..5cab5447d89b87e408b143c74782c0b7ca190203 100644 --- a/example/servo-ptu46/CMakeLists.txt +++ b/example/servo-ptu46/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/servo-ptu46/movePtu46.cpp b/example/servo-ptu46/movePtu46.cpp index d4b9b30a55d22d983fe04278424bd79f9f96405a..920aed4fad5290c3693029223b91868bee712d3d 100644 --- a/example/servo-ptu46/movePtu46.cpp +++ b/example/servo-ptu46/movePtu46.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: movePtu46.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: movePtu46.cpp 4604 2014-01-21 14:15:23Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -56,7 +56,7 @@ */ #include <visp/vpConfig.h> #include <visp/vpDebug.h> -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX # include <unistd.h> #endif diff --git a/example/servo-ptu46/servoPtu46Point2DArtVelocity.cpp b/example/servo-ptu46/servoPtu46Point2DArtVelocity.cpp index 2c930937e0b294c9798458d1716585a69ddf5871..3a2a365c398afaa7276372e9c0bbe1d197b6d624 100644 --- a/example/servo-ptu46/servoPtu46Point2DArtVelocity.cpp +++ b/example/servo-ptu46/servoPtu46Point2DArtVelocity.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoPtu46Point2DArtVelocity.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: servoPtu46Point2DArtVelocity.cpp 4604 2014-01-21 14:15:23Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -63,20 +63,20 @@ */ #include <visp/vpConfig.h> #include <visp/vpDebug.h> // Debug trace -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX # include <unistd.h> #endif #include <signal.h> -#if (defined(VISP_HAVE_PTU46) & defined (VISP_HAVE_DC1394) ) +#if (defined(VISP_HAVE_PTU46) & defined (VISP_HAVE_DC1394_2) ) #ifdef VISP_HAVE_PTHREAD # include <pthread.h> #endif -#include <visp/vp1394Grabber.h> +#include <visp/vp1394TwoGrabber.h> #include <visp/vpImage.h> #include <visp/vpDisplay.h> #include <visp/vpDisplayX.h> @@ -139,7 +139,7 @@ main() vpImage<unsigned char> I ; - vp1394Grabber g; + vp1394TwoGrabber g; g.open(I) ; diff --git a/example/servo-viper650/CMakeLists.txt b/example/servo-viper650/CMakeLists.txt index 512283044282dc298d239a9b69e29568328b8244..f1dc24192bdcddc5b9700b6e59c7e837c90ef79f 100644 --- a/example/servo-viper650/CMakeLists.txt +++ b/example/servo-viper650/CMakeLists.txt @@ -3,7 +3,7 @@ # $Id: CMakeLists.txt 3750 2012-06-01 09:39:38Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/servo-viper650/servoViper650FourPoints2DArtVelocityInteractionCurrent.cpp b/example/servo-viper650/servoViper650FourPoints2DArtVelocityInteractionCurrent.cpp index 5ee16cc6719b6a0338590f795a7d73b1914b1b1d..2f0ad87b6d802c4418561496bb2bed96cd3be4c8 100644 --- a/example/servo-viper650/servoViper650FourPoints2DArtVelocityInteractionCurrent.cpp +++ b/example/servo-viper650/servoViper650FourPoints2DArtVelocityInteractionCurrent.cpp @@ -3,7 +3,7 @@ * $Id: servoViper850FourPoints2DArtVelocityInteractionCurrent.cpp 3870 2012-09-05 17:03:43Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/example/servo-viper650/servoViper650FourPoints2DCamVelocityInteractionCurrent.cpp b/example/servo-viper650/servoViper650FourPoints2DCamVelocityInteractionCurrent.cpp index ac5c06da153a6e3d0528f13a112f4553adcaa6e8..facd496ca10b3da72a0045532887a989e878eb05 100644 --- a/example/servo-viper650/servoViper650FourPoints2DCamVelocityInteractionCurrent.cpp +++ b/example/servo-viper650/servoViper650FourPoints2DCamVelocityInteractionCurrent.cpp @@ -3,7 +3,7 @@ * $Id: servoViper850FourPoints2DCamVelocityInteractionCurrent.cpp 3870 2012-09-05 17:03:43Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/example/servo-viper650/servoViper650Point2DCamVelocity.cpp b/example/servo-viper650/servoViper650Point2DCamVelocity.cpp index bb7f49f2c225d8eb99f9021cbd0576824c44c93e..fba34b3d6026286614bc3169887ae0cefe69ff35 100644 --- a/example/servo-viper650/servoViper650Point2DCamVelocity.cpp +++ b/example/servo-viper650/servoViper650Point2DCamVelocity.cpp @@ -3,7 +3,7 @@ * $Id: servoViper650Point2DCamVelocity.cpp 3616 2012-03-09 14:31:52Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/example/servo-viper850/CMakeLists.txt b/example/servo-viper850/CMakeLists.txt index 167d3acff3f7109b81cb480ecdfad385d34d58c1..641b2309365c6356fd3f54e511f984bb80586d7e 100644 --- a/example/servo-viper850/CMakeLists.txt +++ b/example/servo-viper850/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/servo-viper850/servoViper850FourPoints2DArtVelocityInteractionCurrent.cpp b/example/servo-viper850/servoViper850FourPoints2DArtVelocityInteractionCurrent.cpp index 6a004a177089f52728cdd0d85bcb3fbd7266be68..0a894bf4e912f7c2b17b5752045e21bc49c41255 100644 --- a/example/servo-viper850/servoViper850FourPoints2DArtVelocityInteractionCurrent.cpp +++ b/example/servo-viper850/servoViper850FourPoints2DArtVelocityInteractionCurrent.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoViper850FourPoints2DArtVelocityInteractionCurrent.cpp 4065 2013-01-11 13:32:47Z fspindle $ + * $Id: servoViper850FourPoints2DArtVelocityInteractionCurrent.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/example/servo-viper850/servoViper850FourPoints2DArtVelocityInteractionDesired.cpp b/example/servo-viper850/servoViper850FourPoints2DArtVelocityInteractionDesired.cpp index 526900e3cb45e73ae19ab048dae887ae1bd35251..0a9e9687b2ee76ef9ae2c793722d0f3b5842f8f6 100644 --- a/example/servo-viper850/servoViper850FourPoints2DArtVelocityInteractionDesired.cpp +++ b/example/servo-viper850/servoViper850FourPoints2DArtVelocityInteractionDesired.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoViper850FourPoints2DArtVelocityInteractionDesired.cpp 4065 2013-01-11 13:32:47Z fspindle $ + * $Id: servoViper850FourPoints2DArtVelocityInteractionDesired.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/example/servo-viper850/servoViper850FourPoints2DCamVelocityInteractionCurrent.cpp b/example/servo-viper850/servoViper850FourPoints2DCamVelocityInteractionCurrent.cpp index 6a6a343eca2ff6d0993d7a147cb80847727d66a5..a10613a180197ff50aa608de61178199202cad31 100644 --- a/example/servo-viper850/servoViper850FourPoints2DCamVelocityInteractionCurrent.cpp +++ b/example/servo-viper850/servoViper850FourPoints2DCamVelocityInteractionCurrent.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoViper850FourPoints2DCamVelocityInteractionCurrent.cpp 4065 2013-01-11 13:32:47Z fspindle $ + * $Id: servoViper850FourPoints2DCamVelocityInteractionCurrent.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/example/servo-viper850/servoViper850FourPointsKinect.cpp b/example/servo-viper850/servoViper850FourPointsKinect.cpp index eefc36ea3b9d56b8dabdd37a222c60682b7fd7f6..4fc9b644b96dd70a5a89e5f77946e070bbad1a47 100644 --- a/example/servo-viper850/servoViper850FourPointsKinect.cpp +++ b/example/servo-viper850/servoViper850FourPointsKinect.cpp @@ -4,7 +4,7 @@ * $Id: servoViper850FourPoints2DCamVelocityKinect.cpp 3530 2012-01-03 10:52:12Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/example/servo-viper850/servoViper850Point2DArtVelocity-jointAvoidance-basic.cpp b/example/servo-viper850/servoViper850Point2DArtVelocity-jointAvoidance-basic.cpp index 5d0957daba8ef83224b50ffc7e990d27ab9a2ae0..bf3aaa8532dfd89ba40ea465bd43464b7994b497 100644 --- a/example/servo-viper850/servoViper850Point2DArtVelocity-jointAvoidance-basic.cpp +++ b/example/servo-viper850/servoViper850Point2DArtVelocity-jointAvoidance-basic.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoViper850Point2DArtVelocity-jointAvoidance-basic.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: servoViper850Point2DArtVelocity-jointAvoidance-basic.cpp 4664 2014-02-16 16:17:54Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -47,10 +47,8 @@ Joint limits avoidance by stopping the motion on axis near the joint limits. - Implemented from section III.B in F. Chaumette, E. Marchand. A - redundancy-based iterative approach for avoiding joint limits: Application - to visual servoing. IEEE Trans. on Robotics and Automation, 17(5):719-730, - October 2001. + Implemented from section III.B in \cite Chaumette01c. + */ #include <visp/vpConfig.h> diff --git a/example/servo-viper850/servoViper850Point2DArtVelocity-jointAvoidance-gpa.cpp b/example/servo-viper850/servoViper850Point2DArtVelocity-jointAvoidance-gpa.cpp index 427ecc924220bae79f86a27a5262cf4d955591fc..4e5b56c7bac8c708779d6f6ba4343aa52cf24f6f 100644 --- a/example/servo-viper850/servoViper850Point2DArtVelocity-jointAvoidance-gpa.cpp +++ b/example/servo-viper850/servoViper850Point2DArtVelocity-jointAvoidance-gpa.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoViper850Point2DArtVelocity-jointAvoidance-gpa.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: servoViper850Point2DArtVelocity-jointAvoidance-gpa.cpp 4664 2014-02-16 16:17:54Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -47,16 +47,7 @@ Joint limits avoidance using a gradient projection approach. - Implemented from : - - - E. Marchand, F. Chaumette, A. Rizzo. Using the task function approach to - avoid robot joint limits and kinematic singularities in visual servoing. In - IEEE/RSJ Int. Conf. on Intelligent Robots and Systems, IROS'96, Volume 3, - Pages 1083-1090, Osaka, Japan, November 1996. details. - - - and section II.B in F. Chaumette, E. Marchand. A redundancy-based iterative - approach for avoiding joint limits: Application to visual servoing. IEEE - Trans. on Robotics and Automation, 17(5):719-730, October 2001. + Implemented from \cite Marchand96f and section II.B in \cite Chaumette01c. */ #include <visp/vpConfig.h> diff --git a/example/servo-viper850/servoViper850Point2DArtVelocity.cpp b/example/servo-viper850/servoViper850Point2DArtVelocity.cpp index f85015a4c6fdbc68131129dca00d9d5b9351897d..a790b56166c59a3a05b728468a83c729033e0c1c 100644 --- a/example/servo-viper850/servoViper850Point2DArtVelocity.cpp +++ b/example/servo-viper850/servoViper850Point2DArtVelocity.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoViper850Point2DArtVelocity.cpp 4065 2013-01-11 13:32:47Z fspindle $ + * $Id: servoViper850Point2DArtVelocity.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/example/servo-viper850/servoViper850Point2DCamVelocity.cpp b/example/servo-viper850/servoViper850Point2DCamVelocity.cpp index abfce2017f456600dc1e832b924479f3975af4dc..7b72b9c7fe8419c8d3e43ea9eb9f363d213cf7ed 100644 --- a/example/servo-viper850/servoViper850Point2DCamVelocity.cpp +++ b/example/servo-viper850/servoViper850Point2DCamVelocity.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoViper850Point2DCamVelocity.cpp 4065 2013-01-11 13:32:47Z fspindle $ + * $Id: servoViper850Point2DCamVelocity.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/example/servo-viper850/servoViper850Point2DCamVelocityKalman.cpp b/example/servo-viper850/servoViper850Point2DCamVelocityKalman.cpp index 85865860a5172c5d585f70aec17e3d58a55956a2..e2926ad7d59e10229f9f331fef8b4fba10d637c1 100644 --- a/example/servo-viper850/servoViper850Point2DCamVelocityKalman.cpp +++ b/example/servo-viper850/servoViper850Point2DCamVelocityKalman.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: servoViper850Point2DCamVelocityKalman.cpp 4300 2013-07-04 09:21:07Z fspindle $ + * $Id: servoViper850Point2DCamVelocityKalman.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/example/tools/CMakeLists.txt b/example/tools/CMakeLists.txt index 2e83d624148b248a65fb0f7abbbace034d88c249..b1bab01c98c60243728cb5b0e32f8c5f6ce72c48 100644 --- a/example/tools/CMakeLists.txt +++ b/example/tools/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/tools/histogram.cpp b/example/tools/histogram.cpp index 09bf7d007e71fcd2fd0c1957a39ed267f7d2aaf7..23f7347dc9f0934fd5c093b0c02d59e4f3cdf9eb 100644 --- a/example/tools/histogram.cpp +++ b/example/tools/histogram.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: histogram.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: histogram.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -63,6 +63,9 @@ // List of allowed command line options #define GETOPTARGS "i:o:h" +void usage(const char *name, const char *badparam, std::string ipath, std::string opath, std::string user); +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &opath, std::string user); + /*! \example histogram.cpp @@ -81,8 +84,7 @@ \param user : Username. */ -void usage(const char *name, const char *badparam, std::string ipath, - std::string opath, std::string user) +void usage(const char *name, const char *badparam, std::string ipath, std::string opath, std::string user) { fprintf(stdout, "\n\ Read an image on the disk, display it using X11, display some\n\ @@ -132,21 +134,19 @@ OPTIONS: Default\n\ \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) +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &opath, std::string user) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { - case 'i': ipath = optarg; break; - case 'o': opath = optarg; break; + 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; + usage(argv[0], optarg_, ipath, opath, user); return false; break; } } @@ -154,7 +154,7 @@ bool getOptions(int argc, const char **argv, // 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; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -164,236 +164,233 @@ bool getOptions(int argc, const char **argv, 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; - - // Get the VISP_IMAGE_PATH environment variable value - char *ptenv = getenv("VISP_INPUT_IMAGE_PATH"); - if (ptenv != NULL) - env_ipath = ptenv; - // std::cout << "env_ipath: " << env_ipath << std::endl; - - // Set the default input path - if (! env_ipath.empty()) - ipath = env_ipath; - - // Set the default output path -#ifdef WIN32 - opt_opath = "C:/temp"; + try { + std::string env_ipath; + std::string opt_ipath; + std::string opt_opath; + std::string ipath; + std::string opath; + std::string filename; + std::string username; + + // Get the VISP_IMAGE_PATH environment variable value + char *ptenv = getenv("VISP_INPUT_IMAGE_PATH"); + if (ptenv != NULL) + env_ipath = ptenv; + // std::cout << "env_ipath: " << env_ipath << std::endl; + + // Set the default input path + if (! env_ipath.empty()) + ipath = env_ipath; + + // Set the default output path +#if defined(_WIN32) + opt_opath = "C:/temp"; #else - opt_opath = "/tmp"; + opt_opath = "/tmp"; #endif - // Get the user login name - vpIoTools::getUserName(username); - - // Read the command line options - if (getOptions(argc, argv, opt_ipath, opt_opath, username) == false) { - exit (-1); - } + // Get the user login name + vpIoTools::getUserName(username); - // Get the option values - if (!opt_ipath.empty()) - ipath = opt_ipath; - if (!opt_opath.empty()) - opath = opt_opath; + // Read the command line options + if (getOptions(argc, argv, opt_ipath, opt_opath, username) == false) { + exit (-1); + } - // Append to the output path string, the login name of the user - std::string dirname = opath + vpIoTools::path("/") + username; + // Get the option values + if (!opt_ipath.empty()) + ipath = opt_ipath; + if (!opt_opath.empty()) + opath = opt_opath; + + // Append to the output path string, the login name of the user + std::string dirname = opath + vpIoTools::path("/") + username; + + // Test if the output path exist. If no try to create it + if (vpIoTools::checkDirectory(dirname) == false) { + try { + // Create the dirname + vpIoTools::makeDirectory(dirname); + } + catch (...) { + usage(argv[0], NULL, ipath, opath, username); + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Cannot create " << dirname << std::endl; + std::cerr << " Check your -o " << opath << " option " << std::endl; + exit(-1); + } + } - // Test if the output path exist. If no try to create it - if (vpIoTools::checkDirectory(dirname) == false) { - try { - // Create the dirname - vpIoTools::makeDirectory(dirname); + // 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()) { + if (ipath != env_ipath) { + std::cout << std::endl + << "WARNING: " << std::endl; + std::cout << " Since -i <visp image path=" << ipath << "> " + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; + } } - catch (...) { + + // 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 << " Cannot create " << dirname << std::endl; - std::cerr << " Check your -o " << opath << " option " << std::endl; + std::cerr << " Use -i <visp image path> 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); } - } - // 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()) { - if (ipath != env_ipath) { - std::cout << std::endl - << "WARNING: " << std::endl; - std::cout << " Since -i <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + // Create a grey level image + vpImage<unsigned char> I ; + + // Load a grey image from the disk + filename = ipath; + if (opt_ipath.empty()) + filename += vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); + + std::cout << "Read: " << filename << std::endl; + vpImageIo::read(I, filename) ; + + unsigned char distance = 60; + vpHistogram h; + + // Computes the histogram from the image + h.calculate(I); + + // Save the histogram + filename = dirname + vpIoTools::path("/histogram.txt"); + std::cout << "Save the histogram in: " << filename << std::endl; + h.write(filename); + + // Smooth the histogram + h.smooth(); + // Save the histogram + filename = dirname + vpIoTools::path("/histogram_smoothed.txt"); + std::cout << "Save the smoothed histogram in: " << filename << std::endl; + h.write(filename); + + std::list<vpHistogramPeak> peaks; + unsigned int nbpeaks = 0; + + // get all the histogram peaks + nbpeaks = h.getPeaks(peaks); + + vpTRACE("List of peaks"); + vpTRACE("Nb peaks: %d", nbpeaks); + if (nbpeaks) { + for(std::list<vpHistogramPeak>::const_iterator it = peaks.begin(); it != peaks.end(); ++it) + { + vpHistogramPeak p = *it; + vpTRACE("Peak: gray level: %d value: %d", p.getLevel(), p.getValue()); + } } - } - - // 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 <visp image path> 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); - } - - // Create a grey level image - vpImage<unsigned char> I ; - - // Load a grey image from the disk - filename = ipath; - if (opt_ipath.empty()) - filename += vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); - - std::cout << "Read: " << filename << std::endl; - vpImageIo::read(I, filename) ; - unsigned char distance = 60; - vpHistogram h; - - // Computes the histogram from the image - h.calculate(I); - - // Save the histogram - filename = dirname + vpIoTools::path("/histogram.txt"); - std::cout << "Save the histogram in: " << filename << std::endl; - h.write(filename); + // sort all the histogram peaks list to have the highest peak at the + // beginning of the list, the smallest at the end. + nbpeaks = h.sort(peaks); + + vpTRACE("Sorted list of peaks"); + vpTRACE("Nb peaks: %d", nbpeaks); + if (nbpeaks) { + for(std::list<vpHistogramPeak>::const_iterator it = peaks.begin(); it != peaks.end(); ++it) + { + vpHistogramPeak p = *it; + vpTRACE("Peak: gray level: %d value: %d", p.getLevel(), p.getValue()); + } + } - // Smooth the histogram - h.smooth(); - // Save the histogram - filename = dirname + vpIoTools::path("/histogram_smoothed.txt"); - std::cout << "Save the smoothed histogram in: " << filename << std::endl; - h.write(filename); + // Get the two highest histogram peaks. peak1 is the highest + vpHistogramPeak peak1, peak2; + nbpeaks = h.getPeaks(distance, peak1, peak2); + if (nbpeaks != 2) { + std::cout << "Not a bimodal histogram..." << std::endl; + } + else { + vpTRACE("Bimodal histogram: main peak1: %d-%d second peak2: %d-%d", + peak1.getLevel(), peak1.getValue(), + peak2.getLevel(), peak2.getValue()); + } - std::list<vpHistogramPeak> peaks; - unsigned int nbpeaks = 0; + // Get the valey between the two highest peaks + vpHistogramValey valey; + if (h.getValey(peak1, peak2, valey) == false) { + vpTRACE("No valey found..."); + } + else { + vpTRACE("Valey: %d-%d", valey.getLevel(), valey.getValue()); + } - // get all the histogram peaks - nbpeaks = h.getPeaks(peaks); + vpHistogramValey valeyl, valeyr; - vpTRACE("List of peaks"); - vpTRACE("Nb peaks: %d", nbpeaks); - if (nbpeaks) { - for(std::list<vpHistogramPeak>::const_iterator it = peaks.begin(); it != peaks.end(); ++it) { - vpHistogramPeak p = *it; - vpTRACE("Peak: gray level: %d value: %d", p.getLevel(), p.getValue()); + // Search the two valeys around peak1 + unsigned ret = h.getValey(distance, peak1, valeyl, valeyr); + if (ret == 0x00) { + vpTRACE("No left and right valey for peak %d-%d...", + peak1.getLevel(), peak1.getValue()); + } + else if (ret == 0x10) { + vpTRACE("No right valey for peak %d-%d...", + peak1.getLevel(), peak1.getValue()); + vpTRACE("Left valey: %d-%d", valeyl.getLevel(), valeyl.getValue()); + } + else if (ret == 0x01) { + vpTRACE("No left valey for peak %d-%d...", + peak1.getLevel(), peak1.getValue()); + vpTRACE("Right valey: %d-%d", valeyr.getLevel(), valeyr.getValue()); + } + else if (ret == 0x11) { + vpTRACE("Left valey: %d-%d", valeyl.getLevel(), valeyl.getValue()); + vpTRACE("Right valey: %d-%d", valeyr.getLevel(), valeyr.getValue()); + } } - } - - // sort all the histogram peaks list to have the highest peak at the - // beginning of the list, the smallest at the end. - nbpeaks = h.sort(peaks); - - vpTRACE("Sorted list of peaks"); - vpTRACE("Nb peaks: %d", nbpeaks); - if (nbpeaks) { - for(std::list<vpHistogramPeak>::const_iterator it = peaks.begin(); it != peaks.end(); ++it) { - vpHistogramPeak p = *it; - vpTRACE("Peak: gray level: %d value: %d", p.getLevel(), p.getValue()); + // Search the two valeys around peak2 + unsigned ret = h.getValey(distance, peak2, valeyl, valeyr); + if (ret == 0x00) { + vpTRACE("No left and right valey for peak %d-%d...", + peak2.getLevel(), peak2.getValue()); + } + else if (ret == 0x10) { + vpTRACE("No right valey for peak %d-%d...", + peak2.getLevel(), peak2.getValue()); + vpTRACE("Left valey: %d-%d", valeyl.getLevel(), valeyl.getValue()); + } + else if (ret == 0x01) { + vpTRACE("No left valey for peak %d-%d...", + peak2.getLevel(), peak2.getValue()); + vpTRACE("Right valey: %d-%d", valeyr.getLevel(), valeyr.getValue()); + } + else if (ret == 0x11) { + vpTRACE("Left valey: %d-%d", valeyl.getLevel(), valeyl.getValue()); + vpTRACE("Right valey: %d-%d", valeyr.getLevel(), valeyr.getValue()); + } } - } - // Get the two highest histogram peaks. peak1 is the highest - vpHistogramPeak peak1, peak2; - nbpeaks = h.getPeaks(distance, peak1, peak2); - if (nbpeaks != 2) { - std::cout << "Not a bimodal histogram..." << std::endl; - } - else { - vpTRACE("Bimodal histogram: main peak1: %d-%d second peak2: %d-%d", - peak1.getLevel(), peak1.getValue(), - peak2.getLevel(), peak2.getValue()); - } - - // Get the valey between the two highest peaks - vpHistogramValey valey; - if (h.getValey(peak1, peak2, valey) == false) { - vpTRACE("No valey found..."); - } - else { - vpTRACE("Valey: %d-%d", valey.getLevel(), valey.getValue()); - } - - - vpHistogramValey valeyl, valeyr; - - { - // Search the two valeys around peak1 - unsigned ret = h.getValey(distance, peak1, valeyl, valeyr); - if (ret == 0x00) { - vpTRACE("No left and right valey for peak %d-%d...", - peak1.getLevel(), peak1.getValue()); - } - else if (ret == 0x10) { - vpTRACE("No right valey for peak %d-%d...", - peak1.getLevel(), peak1.getValue()); - vpTRACE("Left valey: %d-%d", valeyl.getLevel(), valeyl.getValue()); - } - else if (ret == 0x01) { - vpTRACE("No left valey for peak %d-%d...", - peak1.getLevel(), peak1.getValue()); - vpTRACE("Right valey: %d-%d", valeyr.getLevel(), valeyr.getValue()); + //////////////////////////////////////////////////////////// + // get the valey between the two highest peaks. Here we don't know + // which of peakl or peakr is the highest. + vpHistogramPeak peakl, peakr; + if (h.getPeaks(distance, peakl, peakr, valey) == false) { + std::cout << "Not a bimodal histogram..." << std::endl; } - else if (ret == 0x11) { - vpTRACE("Left valey: %d-%d", valeyl.getLevel(), valeyl.getValue()); - vpTRACE("Right valey: %d-%d", valeyr.getLevel(), valeyr.getValue()); + else { + vpTRACE("Bimodal histogram: valey %d-%d for peakl: %d-%d peakr: %d-%d", + valey.getLevel(), valey.getValue(), + peakl.getLevel(), peakl.getValue(), + peakr.getLevel(), peakr.getValue()); } + return 0; } - { - // Search the two valeys around peak2 - unsigned ret = h.getValey(distance, peak2, valeyl, valeyr); - if (ret == 0x00) { - vpTRACE("No left and right valey for peak %d-%d...", - peak2.getLevel(), peak2.getValue()); - } - else if (ret == 0x10) { - vpTRACE("No right valey for peak %d-%d...", - peak2.getLevel(), peak2.getValue()); - vpTRACE("Left valey: %d-%d", valeyl.getLevel(), valeyl.getValue()); - } - else if (ret == 0x01) { - vpTRACE("No left valey for peak %d-%d...", - peak2.getLevel(), peak2.getValue()); - vpTRACE("Right valey: %d-%d", valeyr.getLevel(), valeyr.getValue()); - } - else if (ret == 0x11) { - vpTRACE("Left valey: %d-%d", valeyl.getLevel(), valeyl.getValue()); - vpTRACE("Right valey: %d-%d", valeyr.getLevel(), valeyr.getValue()); - } - } - - //////////////////////////////////////////////////////////// - // get the valey between the two highest peaks. Here we don't know - // which of peakl or peakr is the highest. - vpHistogramPeak peakl, peakr; - if (h.getPeaks(distance, peakl, peakr, valey) == false) { - std::cout << "Not a bimodal histogram..." << std::endl; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - else { - vpTRACE("Bimodal histogram: valey %d-%d for peakl: %d-%d peakr: %d-%d", - valey.getLevel(), valey.getValue(), - peakl.getLevel(), peakl.getValue(), - peakr.getLevel(), peakr.getValue()); - } - } - - - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ diff --git a/example/tools/keyboard.cpp b/example/tools/keyboard.cpp index d12a13b7de68208d0b973a518894bb184c2ee9a0..ef97dd0279ab98e3e75c7a3f52b3fa20cc2dd6be 100644 --- a/example/tools/keyboard.cpp +++ b/example/tools/keyboard.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: keyboard.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: keyboard.cpp 4604 2014-01-21 14:15:23Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -48,7 +48,7 @@ #include <visp/vpConfig.h> #include <visp/vpDebug.h> -#if ( defined(UNIX) && ( ! defined(WIN32) ) ) +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) #include <stdio.h> #include <iostream> #include <signal.h> diff --git a/example/tools/parallelPort.cpp b/example/tools/parallelPort.cpp index f2573335b26d70ee1223521ed1985576df364db1..789f5222d8253b27840db8ab991b93f347d7d601 100644 --- a/example/tools/parallelPort.cpp +++ b/example/tools/parallelPort.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: parallelPort.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: parallelPort.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/example/tools/plot2d.cpp b/example/tools/plot2d.cpp index cbf86f5c2b9daffbbf9ef503da77b1ce5051c5af..5c487c30e5daf1a01f9ae3ddb7c2c383fdec50d4 100644 --- a/example/tools/plot2d.cpp +++ b/example/tools/plot2d.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: plot2d.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: plot2d.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -55,65 +55,72 @@ int main () { #if defined(VISP_HAVE_DISPLAY) - vpPlot plot(2, 700, 700, 100, 200, "Curves..."); - - // Change the default font - // plot.setFont("-misc-fixed-bold-r-semicondensed--0-0-75-75-c-0-iso8859-10"); - - //Initialize the number of curve for each graphic - plot.initGraph(0,1); - plot.initGraph(1,1); - - //Set the color of the curves - plot.setColor(0,0,vpColor::green); - plot.setColor(1,0,vpColor::red); - - //Set the titles of the graphic - char title[40]; - strncpy( title, "cos function", 40 ); - plot.setTitle(0,title); - strncpy( title, "sin function", 40 ); - plot.setTitle(1, title); - - //Set the legend of each curves - char legend[40]; - strncpy( legend, "cos x", 40 ); - plot.setLegend(0,0,legend); - strncpy( legend, "sin x", 40 ); - plot.setLegend(1,0, legend); - - //Set the x axis legend of each curves - char unit[40]; - strncpy( unit, "x", 40 ); - plot.setUnitX(0,unit); - strncpy( unit, "x", 40 ); - plot.setUnitX(1,unit); - - //Set the y axis legend of each curves - strncpy( unit, "y", 40 ); - plot.setUnitY(0,unit); - strncpy( unit, "y", 40 ); - plot.setUnitY(1,unit); - - //Plot the cosinus and sinus functions - double i = 0; - while(i <= 20*2*M_PI) - { - double co = cos(i); - double si = sin(i); - plot.plot(0,0,i,co); - plot.plot(1,0,i,si); - i+=0.1; + try { + vpPlot plot(2, 700, 700, 100, 200, "Curves..."); + + // Change the default font + // plot.setFont("-misc-fixed-bold-r-semicondensed--0-0-75-75-c-0-iso8859-10"); + + //Initialize the number of curve for each graphic + plot.initGraph(0,1); + plot.initGraph(1,1); + + //Set the color of the curves + plot.setColor(0,0,vpColor::green); + plot.setColor(1,0,vpColor::red); + + //Set the titles of the graphic + char title[40]; + strncpy( title, "cos function", 40 ); + plot.setTitle(0,title); + strncpy( title, "sin function", 40 ); + plot.setTitle(1, title); + + //Set the legend of each curves + char legend[40]; + strncpy( legend, "cos x", 40 ); + plot.setLegend(0,0,legend); + strncpy( legend, "sin x", 40 ); + plot.setLegend(1,0, legend); + + //Set the x axis legend of each curves + char unit[40]; + strncpy( unit, "x", 40 ); + plot.setUnitX(0,unit); + strncpy( unit, "x", 40 ); + plot.setUnitX(1,unit); + + //Set the y axis legend of each curves + strncpy( unit, "y", 40 ); + plot.setUnitY(0,unit); + strncpy( unit, "y", 40 ); + plot.setUnitY(1,unit); + + //Plot the cosinus and sinus functions + double i = 0; + while(i <= 20*2*M_PI) + { + double co = cos(i); + double si = sin(i); + plot.plot(0,0,i,co); + plot.plot(1,0,i,si); + i+=0.1; + } + + vpDisplay::getClick(plot.I); + + //Save the datas as text files + plot.saveData(0, "dataCos.txt"); + plot.saveData(0, "dataSin.txt"); + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - - vpDisplay::getClick(plot.I); - - //Save the datas as text files - plot.saveData(0, "dataCos.txt"); - plot.saveData(0, "dataSin.txt"); + #else std::cout << "Plot functionalities are not avalaible since no display is available." << std::endl; #endif - return 0; } diff --git a/example/tools/plot3d.cpp b/example/tools/plot3d.cpp index 94848d5ce0377765d75a8d439bad9e055ea077bb..9485e5983a92c1990146b127c99fc6998c9fa8d5 100755 --- a/example/tools/plot3d.cpp +++ b/example/tools/plot3d.cpp @@ -3,7 +3,7 @@ * $Id: plot.cpp 3530 2012-01-03 10:52:12Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -53,64 +53,70 @@ int main () { #if defined(VISP_HAVE_DISPLAY) - //Create a window with one graphic - vpPlot plot(1); + try { + //Create a window with one graphic + vpPlot plot(1); - // Change the default font - //plot.setFont("-misc-fixed-bold-r-semicondensed--0-0-75-75-c-0-iso8859-10"); + // Change the default font + //plot.setFont("-misc-fixed-bold-r-semicondensed--0-0-75-75-c-0-iso8859-10"); - //The graphic contains 2 curves - plot.initGraph(0,2); - - //Set the graphic parameters - plot.setTitle(0, "First graphic"); - plot.setUnitX(0, "time (s)"); - plot.setUnitY(0, "y"); - plot.setUnitZ(0, "z"); - plot.setLegend(0,0, "y^2+z^2=1 and y(0) = 1"); - plot.setLegend(0,1, "y^2+z^2=1 and y(0) = -1"); - plot.setColor(0,0,vpColor::red); - plot.setColor(0,1,vpColor::green); + //The graphic contains 2 curves + plot.initGraph(0,2); - double x = 0; - double y = 1; - double z = 0 ; - double dx = 0.08; - double dy = 0.04; - double zsign = 1.0; + //Set the graphic parameters + plot.setTitle(0, "First graphic"); + plot.setUnitX(0, "time (s)"); + plot.setUnitY(0, "y"); + plot.setUnitZ(0, "z"); + plot.setLegend(0,0, "y^2+z^2=1 and y(0) = 1"); + plot.setLegend(0,1, "y^2+z^2=1 and y(0) = -1"); + plot.setColor(0,0,vpColor::red); + plot.setColor(0,1,vpColor::green); - unsigned long iter = 0; + double x = 0; + double y = 1; + double z = 0 ; + double dx = 0.08; + double dy = 0.04; + double zsign = 1.0; - std::cout << "Hit CTRL-C to exit..."; - while(1) { - if (iter < 300) { - //y*y+z*z = 1 - if (fabs(y) < 1.0) - z = sqrt(1.0-y*y); - else z = 0; + unsigned long iter = 0; - //Add points to the graphic - plot.plot(0,0, x, y,z*zsign); - plot.plot(0,1, x, -y,-z*zsign); - - x += dx; - - if (fabs(y) >= 1.0 ) - dy = -dy; - y += dy; - if (fabs(y) >= 1.0 ) - zsign = -zsign; - } - else { - // Tip: to allows modifying the point of view with the mouse we - // plot always the last point - plot.plot(0,0, x, y,z*zsign); - plot.plot(0,1, x, -y,-z*zsign); + std::cout << "Hit CTRL-C to exit..."; + while(1) { + if (iter < 300) { + //y*y+z*z = 1 + if (fabs(y) < 1.0) + z = sqrt(1.0-y*y); + else z = 0; + + //Add points to the graphic + plot.plot(0,0, x, y,z*zsign); + plot.plot(0,1, x, -y,-z*zsign); + + x += dx; + + if (fabs(y) >= 1.0 ) + dy = -dy; + y += dy; + if (fabs(y) >= 1.0 ) + zsign = -zsign; + } + else { + // Tip: to allows modifying the point of view with the mouse we + // plot always the last point + plot.plot(0,0, x, y,z*zsign); + plot.plot(0,1, x, -y,-z*zsign); + } + iter ++; } - iter ++; + + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - - return 0; #else std::cout << "Plot functionalities are not avalaible since no display is available." << std::endl; #endif diff --git a/example/tracking/CMakeLists.txt b/example/tracking/CMakeLists.txt index 39d1b5411de446ac0567f6687dd98ef531f70baa..21287d1d91b7462fc3cee4bfe7407804843dc4bc 100644 --- a/example/tracking/CMakeLists.txt +++ b/example/tracking/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4156 2013-03-11 16:12:24Z ayol $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 @@ -47,6 +47,7 @@ SET (SOURCE mbtEdgeTracking.cpp mbtEdgeKltTracking.cpp mbtKltTracking.cpp + templateTracker.cpp trackDot2WithAutoDetection.cpp trackMeCircle.cpp trackMeEllipse.cpp @@ -81,6 +82,78 @@ ADD_TEST(trackMeNurbs trackMeNurbs -c ${OPTION_TO_DESACTIVE_DISPLAY}) ADD_TEST(trackDot trackDot -c ${OPTION_TO_DESACTIVE_DISPLAY}) ADD_TEST(trackDot2 trackDot2 -c ${OPTION_TO_DESACTIVE_DISPLAY}) +#ADD_TEST(templateTracker-SSDESM-Affine templateTracker -c -l 2 -t 0 -w 0 ${OPTION_TO_DESACTIVE_DISPLAY}) +#ADD_TEST(templateTracker-SSDESM-Homography templateTracker -c -l 2 -t 0 -w 1 ${OPTION_TO_DESACTIVE_DISPLAY}) +#ADD_TEST(templateTracker-SSDESM-HomographySL3 templateTracker -c -l 2 -t 0 -w 2 ${OPTION_TO_DESACTIVE_DISPLAY}) +#ADD_TEST(templateTracker-SSDESM-SRT templateTracker -c -l 2 -t 0 -w 3 ${OPTION_TO_DESACTIVE_DISPLAY}) +#ADD_TEST(templateTracker-SSDESM-Translation templateTracker -c -l 2 -t 0 -w 4 ${OPTION_TO_DESACTIVE_DISPLAY}) + +ADD_TEST(templateTrackerPyramidal-SSDESM-Affine templateTracker -c -l 2 -t 0 -w 0 -p ${OPTION_TO_DESACTIVE_DISPLAY}) +ADD_TEST(templateTrackerPyramidal-SSDESM-Homography templateTracker -c -l 2 -t 0 -w 1 -p ${OPTION_TO_DESACTIVE_DISPLAY}) +ADD_TEST(templateTrackerPyramidal-SSDESM-HomographySL3 templateTracker -c -l 2 -t 0 -w 2 -p ${OPTION_TO_DESACTIVE_DISPLAY}) +ADD_TEST(templateTrackerPyramidal-SSDESM-SRT templateTracker -c -l 2 -t 0 -w 3 -p ${OPTION_TO_DESACTIVE_DISPLAY}) +ADD_TEST(templateTrackerPyramidal-SSDESM-Translation templateTracker -c -l 2 -t 0 -w 4 -p ${OPTION_TO_DESACTIVE_DISPLAY}) + +#ADD_TEST(templateTracker-SSDForwardAdditional-Affine templateTracker -c -l 2 -t 1 -w 0 ${OPTION_TO_DESACTIVE_DISPLAY}) +#ADD_TEST(templateTracker-SSDForwardAdditional-Homography templateTracker -c -l 2 -t 1 -w 1 ${OPTION_TO_DESACTIVE_DISPLAY}) +#ADD_TEST(templateTracker-SSDForwardAdditional-HomographySL3 templateTracker -c -l 2 -t 1 -w 2 ${OPTION_TO_DESACTIVE_DISPLAY}) +#ADD_TEST(templateTracker-SSDForwardAdditional-SRT templateTracker -c -l 2 -t 1 -w 3 ${OPTION_TO_DESACTIVE_DISPLAY}) +#ADD_TEST(templateTracker-SSDForwardAdditional-Translation templateTracker -c -l 2 -t 1 -w 4 ${OPTION_TO_DESACTIVE_DISPLAY}) + +ADD_TEST(templateTrackerPyramidal-SSDForwardAdditional-Affine templateTracker -c -l 2 -t 1 -w 0 -p ${OPTION_TO_DESACTIVE_DISPLAY}) +ADD_TEST(templateTrackerPyramidal-SSDForwardAdditional-Homography templateTracker -c -l 2 -t 1 -w 1 -p ${OPTION_TO_DESACTIVE_DISPLAY}) +ADD_TEST(templateTrackerPyramidal-SSDForwardAdditional-HomographySL3 templateTracker -c -l 2 -t 1 -w 2 -p ${OPTION_TO_DESACTIVE_DISPLAY}) +ADD_TEST(templateTrackerPyramidal-SSDForwardAdditional-SRT templateTracker -c -l 2 -t 1 -w 3 -p ${OPTION_TO_DESACTIVE_DISPLAY}) +ADD_TEST(templateTrackerPyramidal-SSDForwardAdditional-Translation templateTracker -c -l 2 -t 1 -w 4 -p ${OPTION_TO_DESACTIVE_DISPLAY}) + +#ADD_TEST(templateTracker-SSDForwardCompositional-Affine templateTracker -c -l 2 -t 2 -w 0 ${OPTION_TO_DESACTIVE_DISPLAY}) +#ADD_TEST(templateTracker-SSDForwardCompositional-Homography templateTracker -c -l 2 -t 2 -w 1 ${OPTION_TO_DESACTIVE_DISPLAY}) +#ADD_TEST(templateTracker-SSDForwardCompositional-HomographySL3 templateTracker -c -l 2 -t 2 -w 2 ${OPTION_TO_DESACTIVE_DISPLAY}) +#ADD_TEST(templateTracker-SSDForwardCompositional-SRT templateTracker -c -l 2 -t 2 -w 3 ${OPTION_TO_DESACTIVE_DISPLAY}) +#ADD_TEST(templateTracker-SSDForwardCompositional-Translation templateTracker -c -l 2 -t 2 -w 4 ${OPTION_TO_DESACTIVE_DISPLAY}) + +ADD_TEST(templateTrackerPyramidal-SSDForwardCompositional-Affine templateTracker -c -l 2 -t 2 -w 0 -p ${OPTION_TO_DESACTIVE_DISPLAY}) +ADD_TEST(templateTrackerPyramidal-SSDForwardCompositional-Homography templateTracker -c -l 2 -t 2 -w 1 -p ${OPTION_TO_DESACTIVE_DISPLAY}) +ADD_TEST(templateTrackerPyramidal-SSDForwardCompositional-HomographySL3 templateTracker -c -l 2 -t 2 -w 2 -p ${OPTION_TO_DESACTIVE_DISPLAY}) +ADD_TEST(templateTrackerPyramidal-SSDForwardCompositional-SRT templateTracker -c -l 2 -t 2 -w 3 -p ${OPTION_TO_DESACTIVE_DISPLAY}) +ADD_TEST(templateTrackerPyramidal-SSDForwardCompositional-Translation templateTracker -c -l 2 -t 2 -w 4 -p ${OPTION_TO_DESACTIVE_DISPLAY}) + +#ADD_TEST(templateTracker-SSDInverseCompositional-Affine templateTracker -c -l 2 -t 3 -w 0 ${OPTION_TO_DESACTIVE_DISPLAY}) +#ADD_TEST(templateTracker-SSDInverseCompositional-Homography templateTracker -c -l 2 -t 3 -w 1 ${OPTION_TO_DESACTIVE_DISPLAY}) +#ADD_TEST(templateTracker-SSDInverseCompositional-HomographySL3 templateTracker -c -l 2 -t 3 -w 2 ${OPTION_TO_DESACTIVE_DISPLAY}) +#ADD_TEST(templateTracker-SSDInverseCompositional-SRT templateTracker -c -l 2 -t 3 -w 3 ${OPTION_TO_DESACTIVE_DISPLAY}) +#ADD_TEST(templateTracker-SSDInverseCompositional-Translation templateTracker -c -l 2 -t 3 -w 4 ${OPTION_TO_DESACTIVE_DISPLAY}) + +ADD_TEST(templateTrackerPyramidal-SSDInverseCompositional-Affine templateTracker -c -l 2 -t 3 -w 0 -p ${OPTION_TO_DESACTIVE_DISPLAY}) +ADD_TEST(templateTrackerPyramidal-SSDInverseCompositional-Homography templateTracker -c -l 2 -t 3 -w 1 -p ${OPTION_TO_DESACTIVE_DISPLAY}) +ADD_TEST(templateTrackerPyramidal-SSDInverseCompositional-HomographySL3 templateTracker -c -l 2 -t 3 -w 2 -p ${OPTION_TO_DESACTIVE_DISPLAY}) +ADD_TEST(templateTrackerPyramidal-SSDInverseCompositional-SRT templateTracker -c -l 2 -t 3 -w 3 -p ${OPTION_TO_DESACTIVE_DISPLAY}) +ADD_TEST(templateTrackerPyramidal-SSDInverseCompositional-Translation templateTracker -c -l 2 -t 3 -w 4 -p ${OPTION_TO_DESACTIVE_DISPLAY}) + +#ADD_TEST(templateTracker-ZNCCForwardAdditional-Affine templateTracker -c -l 2 -t 4 -w 0 ${OPTION_TO_DESACTIVE_DISPLAY}) +#ADD_TEST(templateTracker-ZNCCForwardAdditional-Homography templateTracker -c -l 2 -t 4 -w 1 ${OPTION_TO_DESACTIVE_DISPLAY}) +#ADD_TEST(templateTracker-ZNCCForwardAdditional-HomographySL3 templateTracker -c -l 2 -t 4 -w 2 ${OPTION_TO_DESACTIVE_DISPLAY}) +#ADD_TEST(templateTracker-ZNCCForwardAdditional-SRT templateTracker -c -l 2 -t 4 -w 3 ${OPTION_TO_DESACTIVE_DISPLAY}) +#ADD_TEST(templateTracker-ZNCCForwardAdditional-Translation templateTracker -c -l 2 -t 4 -w 4 ${OPTION_TO_DESACTIVE_DISPLAY}) + +ADD_TEST(templateTrackerPyramidal-ZNCCForwardAdditional-Affine templateTracker -c -l 2 -t 4 -w 0 -p ${OPTION_TO_DESACTIVE_DISPLAY}) +ADD_TEST(templateTrackerPyramidal-ZNCCForwardAdditional-Homography templateTracker -c -l 2 -t 4 -w 1 -p ${OPTION_TO_DESACTIVE_DISPLAY}) +ADD_TEST(templateTrackerPyramidal-ZNCCForwardAdditional-HomographySL3 templateTracker -c -l 2 -t 4 -w 2 -p ${OPTION_TO_DESACTIVE_DISPLAY}) +ADD_TEST(templateTrackerPyramidal-ZNCCForwardAdditional-SRT templateTracker -c -l 2 -t 4 -w 3 -p ${OPTION_TO_DESACTIVE_DISPLAY}) +ADD_TEST(templateTrackerPyramidal-ZNCCForwardAdditional-Translation templateTracker -c -l 2 -t 4 -w 4 -p ${OPTION_TO_DESACTIVE_DISPLAY}) + +#ADD_TEST(templateTracker-ZNCCInverseCompositional-Affine templateTracker -c -l 2 -t 5 -w 0 ${OPTION_TO_DESACTIVE_DISPLAY}) +#ADD_TEST(templateTracker-ZNCCInverseCompositional-Homography templateTracker -c -l 2 -t 5 -w 1 ${OPTION_TO_DESACTIVE_DISPLAY}) +#ADD_TEST(templateTracker-ZNCCInverseCompositional-HomographySL3 templateTracker -c -l 2 -t 5 -w 2 ${OPTION_TO_DESACTIVE_DISPLAY}) +#ADD_TEST(templateTracker-ZNCCInverseCompositional-SRT templateTracker -c -l 2 -t 5 -w 3 ${OPTION_TO_DESACTIVE_DISPLAY}) +#ADD_TEST(templateTracker-ZNCCInverseCompositional-Translation templateTracker -c -l 2 -t 5 -w 4 ${OPTION_TO_DESACTIVE_DISPLAY}) + +ADD_TEST(templateTrackerPyramidal-ZNCCInverseCompositional-Affine templateTracker -c -l 2 -t 5 -w 0 -p ${OPTION_TO_DESACTIVE_DISPLAY}) +ADD_TEST(templateTrackerPyramidal-ZNCCInverseCompositional-Homography templateTracker -c -l 2 -t 5 -w 1 -p ${OPTION_TO_DESACTIVE_DISPLAY}) +ADD_TEST(templateTrackerPyramidal-ZNCCInverseCompositional-HomographySL3 templateTracker -c -l 2 -t 5 -w 2 -p ${OPTION_TO_DESACTIVE_DISPLAY}) +ADD_TEST(templateTrackerPyramidal-ZNCCInverseCompositional-SRT templateTracker -c -l 2 -t 5 -w 3 -p ${OPTION_TO_DESACTIVE_DISPLAY}) +ADD_TEST(templateTrackerPyramidal-ZNCCInverseCompositional-Translation templateTracker -c -l 2 -t 5 -w 4 -p ${OPTION_TO_DESACTIVE_DISPLAY}) + # customize clean target SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "core*;*~;gmon.out;DartTestfile.txt" diff --git a/example/tracking/mbtEdgeKltTracking.cpp b/example/tracking/mbtEdgeKltTracking.cpp index ac53ba8685fffe782ce8561f36c7d7a98d8f1b9f..8fc11f8e050d7d446fa0b0c31f10e41ca67fae05 100644 --- a/example/tracking/mbtEdgeKltTracking.cpp +++ b/example/tracking/mbtEdgeKltTracking.cpp @@ -3,7 +3,7 @@ * $Id: mbtTracking.cpp 3957 2012-11-07 15:22:30Z fnovotny $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -65,6 +65,10 @@ #define GETOPTARGS "x:m:i:n:dchtfCo" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &configFile, std::string &modelFile, + std::string &initFile, bool &displayFeatures, bool &click_allowed, bool &display, + bool& cao3DModel, bool& trackCylinder, bool &useOgre); void usage(const char *name, const char *badparam) { @@ -134,17 +138,19 @@ OPTIONS: \n\ } -bool getOptions(int argc, const char **argv, std::string &ipath, std::string &configFile, std::string &modelFile, std::string &initFile, bool &displayFeatures, bool &click_allowed, bool &display, bool& cao3DModel, bool& trackCylinder, bool &useOgre) +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &configFile, std::string &modelFile, + std::string &initFile, bool &displayFeatures, bool &click_allowed, bool &display, + bool& cao3DModel, bool& trackCylinder, bool &useOgre) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { - case 'i': ipath = optarg; break; - case 'x': configFile = optarg; break; - case 'm': modelFile = optarg; break; - case 'n': initFile = optarg; break; + case 'i': ipath = optarg_; break; + case 'x': configFile = optarg_; break; + case 'm': modelFile = optarg_; break; + case 'n': initFile = optarg_; break; case 't': displayFeatures = false; break; case 'f': cao3DModel = true; break; case 'c': click_allowed = false; break; @@ -154,7 +160,7 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &co case 'h': usage(argv[0], NULL); return false; break; default: - usage(argv[0], optarg); + usage(argv[0], optarg_); return false; break; } } @@ -163,7 +169,7 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &co // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -173,254 +179,248 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &co int main(int argc, const char ** argv) { - std::string env_ipath; - std::string opt_ipath; - std::string ipath; - std::string opt_configFile; - std::string configFile; - std::string opt_modelFile; - std::string modelFile; - std::string opt_initFile; - std::string initFile; - bool displayFeatures = true; - bool opt_click_allowed = true; - bool opt_display = true; - bool cao3DModel = false; - bool trackCylinder = true; - bool useOgre = false; - - // 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_configFile, opt_modelFile, opt_initFile, displayFeatures, opt_click_allowed, opt_display, cao3DModel, trackCylinder, useOgre)) { - return (-1); - } - - // Test if an input path is set - if (opt_ipath.empty() && env_ipath.empty() ){ - usage(argv[0], NULL); - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Use -i <visp image path> 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; - - return (-1); - } + try { + std::string env_ipath; + std::string opt_ipath; + std::string ipath; + std::string opt_configFile; + std::string configFile; + std::string opt_modelFile; + std::string modelFile; + std::string opt_initFile; + std::string initFile; + bool displayFeatures = true; + bool opt_click_allowed = true; + bool opt_display = true; + bool cao3DModel = false; + bool trackCylinder = true; + bool useOgre = false; + + // 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_configFile, opt_modelFile, opt_initFile, displayFeatures, opt_click_allowed, opt_display, cao3DModel, trackCylinder, useOgre)) { + return (-1); + } - // Get the option values - if (!opt_ipath.empty()) - ipath = opt_ipath + vpIoTools::path("/ViSP-images/mbt/cube/image%04d.pgm"); - else - ipath = env_ipath + vpIoTools::path("/ViSP-images/mbt/cube/image%04d.pgm"); - - if (!opt_configFile.empty()) - configFile = opt_configFile; - else if (!opt_ipath.empty()) - configFile = opt_ipath + vpIoTools::path("/ViSP-images/mbt/cube.xml"); - else - configFile = env_ipath + vpIoTools::path("/ViSP-images/mbt/cube.xml"); - - if (!opt_modelFile.empty()){ - modelFile = opt_modelFile; - }else{ - std::string modelFileCao; - std::string modelFileWrl; - if(trackCylinder){ - modelFileCao = "/ViSP-images/mbt/cube_and_cylinder.cao"; - modelFileWrl = "/ViSP-images/mbt/cube_and_cylinder.wrl"; - }else{ - modelFileCao = "/ViSP-images/mbt/cube.cao"; - modelFileWrl = "/ViSP-images/mbt/cube.wrl"; + // Test if an input path is set + if (opt_ipath.empty() && env_ipath.empty() ){ + usage(argv[0], NULL); + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Use -i <visp image path> 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; + + return (-1); } - if(!opt_ipath.empty()){ - if(cao3DModel){ - modelFile = opt_ipath + vpIoTools::path(modelFileCao); + // Get the option values + if (!opt_ipath.empty()) + ipath = opt_ipath + vpIoTools::path("/ViSP-images/mbt/cube/image%04d.pgm"); + else + ipath = env_ipath + vpIoTools::path("/ViSP-images/mbt/cube/image%04d.pgm"); + + if (!opt_configFile.empty()) + configFile = opt_configFile; + else if (!opt_ipath.empty()) + configFile = opt_ipath + vpIoTools::path("/ViSP-images/mbt/cube.xml"); + else + configFile = env_ipath + vpIoTools::path("/ViSP-images/mbt/cube.xml"); + + if (!opt_modelFile.empty()){ + modelFile = opt_modelFile; + }else{ + std::string modelFileCao; + std::string modelFileWrl; + if(trackCylinder){ + modelFileCao = "/ViSP-images/mbt/cube_and_cylinder.cao"; + modelFileWrl = "/ViSP-images/mbt/cube_and_cylinder.wrl"; + }else{ + modelFileCao = "/ViSP-images/mbt/cube.cao"; + modelFileWrl = "/ViSP-images/mbt/cube.wrl"; } - else{ + + if(!opt_ipath.empty()){ + if(cao3DModel){ + modelFile = opt_ipath + vpIoTools::path(modelFileCao); + } + else{ #ifdef VISP_HAVE_COIN - modelFile = opt_ipath + vpIoTools::path(modelFileWrl); + modelFile = opt_ipath + vpIoTools::path(modelFileWrl); #else - std::cerr << "Coin is not detected in ViSP. Use the .cao model instead." << std::endl; - modelFile = opt_ipath + vpIoTools::path(modelFileCao); + std::cerr << "Coin is not detected in ViSP. Use the .cao model instead." << std::endl; + modelFile = opt_ipath + vpIoTools::path(modelFileCao); #endif - } - } - else{ - if(cao3DModel){ - modelFile = env_ipath + vpIoTools::path(modelFileCao); + } } else{ + if(cao3DModel){ + modelFile = env_ipath + vpIoTools::path(modelFileCao); + } + else{ #ifdef VISP_HAVE_COIN - modelFile = env_ipath + vpIoTools::path(modelFileWrl); + modelFile = env_ipath + vpIoTools::path(modelFileWrl); #else - std::cerr << "Coin is not detected in ViSP. Use the .cao model instead." << std::endl; - modelFile = env_ipath + vpIoTools::path(modelFileCao); + std::cerr << "Coin is not detected in ViSP. Use the .cao model instead." << std::endl; + modelFile = env_ipath + vpIoTools::path(modelFileCao); #endif + } } } - } - - if (!opt_initFile.empty()) - initFile = opt_initFile; - else if (!opt_ipath.empty()) - initFile = opt_ipath + vpIoTools::path("/ViSP-images/mbt/cube"); - else - initFile = env_ipath + vpIoTools::path("/ViSP-images/mbt/cube"); - - vpImage<unsigned char> I; - vpVideoReader reader; - - reader.setFileName(ipath.c_str()); - try{ - reader.open(I); - }catch(...){ - std::cout << "Cannot open sequence: " << ipath << std::endl; - return -1; - } - - reader.acquire(I); - // initialise a display + if (!opt_initFile.empty()) + initFile = opt_initFile; + else if (!opt_ipath.empty()) + initFile = opt_ipath + vpIoTools::path("/ViSP-images/mbt/cube"); + else + initFile = env_ipath + vpIoTools::path("/ViSP-images/mbt/cube"); + + vpImage<unsigned char> I; + vpVideoReader reader; + + reader.setFileName(ipath.c_str()); + try{ + reader.open(I); + }catch(...){ + std::cout << "Cannot open sequence: " << ipath << std::endl; + return -1; + } + + reader.acquire(I); + + // initialise a display #if defined VISP_HAVE_X11 - vpDisplayX display; + vpDisplayX display; #elif defined VISP_HAVE_GDI - vpDisplayGDI display; + vpDisplayGDI display; #elif defined VISP_HAVE_OPENCV - vpDisplayOpenCV display; + vpDisplayOpenCV display; #elif defined VISP_HAVE_D3D9 - vpDisplayD3D display; + vpDisplayD3D display; #elif defined VISP_HAVE_GTK - vpDisplayGTK display; + vpDisplayGTK display; #else - opt_display = false; + opt_display = false; #endif - if (opt_display) - { + if (opt_display) + { #if (defined VISP_HAVE_DISPLAY) - display.init(I, 100, 100, "Test tracking") ; + display.init(I, 100, 100, "Test tracking") ; #endif - vpDisplay::display(I) ; - vpDisplay::flush(I); - } + vpDisplay::display(I) ; + vpDisplay::flush(I); + } - vpMbEdgeKltTracker tracker; - vpHomogeneousMatrix cMo; - vpCameraParameters cam; + vpMbEdgeKltTracker tracker; + vpHomogeneousMatrix cMo; + vpCameraParameters cam; - // Initialise the tracker: camera parameters, moving edge and KLT settings + // Initialise the tracker: camera parameters, moving edge and KLT settings #if defined (VISP_HAVE_XML2) - // From the xml file - tracker.loadConfigFile(configFile.c_str()); + // From the xml file + tracker.loadConfigFile(configFile.c_str()); #else - // By setting the parameters: - cam.initPersProjWithoutDistortion(547, 542, 338, 234); - - vpMe me; - me.setMaskSize(5); - me.setMaskNumber(180); - me.setRange(7); - me.setThreshold(5000); - me.setMu1(0.5); - me.setMu2(0.5); - me.setMinSampleStep(4); - me.setNbTotalSample(250); - - vpKltOpencv klt; - klt.setMaxFeatures(10000); - klt.setWindowSize(5); - klt.setQuality(0.01); - klt.setMinDistance(5); - klt.setHarrisFreeParameter(0.01); - klt.setBlockSize(3); - klt.setPyramidLevels(3); - - tracker.setCameraParameters(cam); - tracker.setMovingEdge(me); - tracker.setKltOpencv(klt); - tracker.setAngleAppear( vpMath::rad(65) ); - tracker.setAngleDisappear( vpMath::rad(75) ); - tracker.setMaskBorder(5); - - // Specify the clipping to - tracker.setNearClippingDistance(0.01); - tracker.setFarClippingDistance(0.90); - tracker.setClipping(tracker.getClipping() | vpMbtPolygon::FOV_CLIPPING); -// tracker.setClipping(tracker.getClipping() | vpMbtPolygon::LEFT_CLIPPING | vpMbtPolygon::RIGHT_CLIPPING | vpMbtPolygon::UP_CLIPPING | vpMbtPolygon::DOWN_CLIPPING); // Equivalent to FOV_CLIPPING + // By setting the parameters: + cam.initPersProjWithoutDistortion(547, 542, 338, 234); + + vpMe me; + me.setMaskSize(5); + me.setMaskNumber(180); + me.setRange(7); + me.setThreshold(5000); + me.setMu1(0.5); + me.setMu2(0.5); + me.setMinSampleStep(4); + me.setNbTotalSample(250); + + vpKltOpencv klt; + klt.setMaxFeatures(10000); + klt.setWindowSize(5); + klt.setQuality(0.01); + klt.setMinDistance(5); + klt.setHarrisFreeParameter(0.01); + klt.setBlockSize(3); + klt.setPyramidLevels(3); + + tracker.setCameraParameters(cam); + tracker.setMovingEdge(me); + tracker.setKltOpencv(klt); + tracker.setAngleAppear( vpMath::rad(65) ); + tracker.setAngleDisappear( vpMath::rad(75) ); + tracker.setMaskBorder(5); + + // Specify the clipping to + tracker.setNearClippingDistance(0.01); + tracker.setFarClippingDistance(0.90); + tracker.setClipping(tracker.getClipping() | vpMbtPolygon::FOV_CLIPPING); + // tracker.setClipping(tracker.getClipping() | vpMbtPolygon::LEFT_CLIPPING | vpMbtPolygon::RIGHT_CLIPPING | vpMbtPolygon::UP_CLIPPING | vpMbtPolygon::DOWN_CLIPPING); // Equivalent to FOV_CLIPPING #endif - - // Display the moving edges, and the Klt points - tracker.setDisplayFeatures(displayFeatures); - - // Tells if the tracker has to use Ogre3D for visibility tests - tracker.setOgreVisibilityTest(useOgre); - - // Retrieve the camera parameters from the tracker - tracker.getCameraParameters(cam); - - // Loop to position the cube - if (opt_display && opt_click_allowed) - { - while(!vpDisplay::getClick(I,false)){ - vpDisplay::display(I); - vpDisplay::displayCharString(I, 15, 10, - "click after positioning the object", - vpColor::red); - vpDisplay::flush(I) ; + + // Display the moving edges, and the Klt points + tracker.setDisplayFeatures(displayFeatures); + + // Tells if the tracker has to use Ogre3D for visibility tests + tracker.setOgreVisibilityTest(useOgre); + + // Retrieve the camera parameters from the tracker + tracker.getCameraParameters(cam); + + // Loop to position the cube + if (opt_display && opt_click_allowed) + { + while(!vpDisplay::getClick(I,false)){ + vpDisplay::display(I); + vpDisplay::displayCharString(I, 15, 10, + "click after positioning the object", + vpColor::red); + vpDisplay::flush(I) ; + } } - } - // Load the 3D model (either a vrml file or a .cao file) - try{ + // Load the 3D model (either a vrml file or a .cao file) tracker.loadModel(modelFile.c_str()); - } - catch(...) - { - return 0; - } - // Initialise the tracker by clicking on the image - // This function looks for - // - a ./cube/cube.init file that defines the 3d coordinates (in meter, in the object basis) of the points used for the initialisation - // - a ./cube/cube.ppm file to display where the user have to click (optionnal, set by the third parameter) - if (opt_display && opt_click_allowed) - { - tracker.initClick(I, initFile.c_str(), true); + + // Initialise the tracker by clicking on the image + // This function looks for + // - a ./cube/cube.init file that defines the 3d coordinates (in meter, in the object basis) of the points used for the initialisation + // - a ./cube/cube.ppm file to display where the user have to click (optionnal, set by the third parameter) + if (opt_display && opt_click_allowed) + { + tracker.initClick(I, initFile.c_str(), true); + tracker.getPose(cMo); + // display the 3D model at the given pose + tracker.display(I,cMo, cam, vpColor::red); + } + else + { + vpHomogeneousMatrix cMoi(0.02044769891, 0.1101505452, 0.5078963719, 2.063603907, 1.110231561, -0.4392789872); + tracker.initFromPose(I, cMoi); + } + + //track the model + tracker.track(I); tracker.getPose(cMo); - // display the 3D model at the given pose - tracker.display(I,cMo, cam, vpColor::red); - } - else - { - vpHomogeneousMatrix cMoi(0.02044769891, 0.1101505452, 0.5078963719, 2.063603907, 1.110231561, -0.4392789872); - tracker.initFromPose(I, cMoi); - } - //track the model - tracker.track(I); - tracker.getPose(cMo); - - if (opt_display) - vpDisplay::flush(I); - - // Uncomment if you want to compute the covariance matrix. - // tracker.setCovarianceComputation(true); //Important if you want tracker.getCovarianceMatrix() to work. - - while (!reader.end()) - { - try + if (opt_display) + vpDisplay::flush(I); + + // Uncomment if you want to compute the covariance matrix. + // tracker.setCovarianceComputation(true); //Important if you want tracker.getCovarianceMatrix() to work. + + while (!reader.end()) { - // acquire a new image + // acquire a new image reader.acquire(I); // display the image if (opt_display) @@ -428,39 +428,38 @@ main(int argc, const char ** argv) // track the object tracker.track(I); tracker.getPose(cMo); - // display the 3D model + // display the 3D model if (opt_display) { tracker.display(I, cMo, cam, vpColor::darkRed); // display the frame vpDisplay::displayFrame (I, cMo, cam, 0.05, vpColor::blue); } - - // Uncomment if you want to print the covariance matrix. + + // Uncomment if you want to print the covariance matrix. // Make sure tracker.setCovarianceComputation(true) has been called (uncomment below). // std::cout << tracker.getCovarianceMatrix() << std::endl << std::endl; - - } - catch(...) - { - std::cout << "error caught" << std::endl; - break; + + vpDisplay::flush(I) ; } - vpDisplay::flush(I) ; - } - reader.close(); + reader.close(); #if defined (VISP_HAVE_XML2) - // Cleanup memory allocated by xml library used to parse the xml config file in vpMbEdgeKltTracker::loadConfigFile() - vpXmlParser::cleanup(); + // Cleanup memory allocated by xml library used to parse the xml config file in vpMbEdgeKltTracker::loadConfigFile() + vpXmlParser::cleanup(); #endif #ifdef VISP_HAVE_COIN - // Cleanup memory allocated by Coin library used to load a vrml model in vpMbEdgeKltTracker::loadModel() - SoDB::finish(); + // Cleanup memory allocated by Coin library used to load a vrml model in vpMbEdgeKltTracker::loadModel() + SoDB::finish(); #endif - return 0; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } #else diff --git a/example/tracking/mbtEdgeTracking.cpp b/example/tracking/mbtEdgeTracking.cpp index 9edb4b4bf42a9d1ea2b7e74703fc5969b58e3121..37c9fbe04a3f5374a4e240fa9ccba93d0f193de5 100644 --- a/example/tracking/mbtEdgeTracking.cpp +++ b/example/tracking/mbtEdgeTracking.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: mbtEdgeTracking.cpp 4330 2013-07-20 11:04:19Z ayol $ + * $Id: mbtEdgeTracking.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -66,6 +66,10 @@ #define GETOPTARGS "x:m:i:n:dchtfCo" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &configFile, std::string &modelFile, + std::string &initFile, bool &displayMovingEdge, bool &click_allowed, bool &display, + bool& cao3DModel, bool& trackCylinder, bool &useOgre); void usage(const char *name, const char *badparam) { @@ -135,17 +139,19 @@ OPTIONS: \n\ } -bool getOptions(int argc, const char **argv, std::string &ipath, std::string &configFile, std::string &modelFile, std::string &initFile, bool &displayMovingEdge, bool &click_allowed, bool &display, bool& cao3DModel, bool& trackCylinder, bool &useOgre) +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &configFile, std::string &modelFile, + std::string &initFile, bool &displayMovingEdge, bool &click_allowed, bool &display, + bool& cao3DModel, bool& trackCylinder, bool &useOgre) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { - case 'i': ipath = optarg; break; - case 'x': configFile = optarg; break; - case 'm': modelFile = optarg; break; - case 'n': initFile = optarg; break; + case 'i': ipath = optarg_; break; + case 'x': configFile = optarg_; break; + case 'm': modelFile = optarg_; break; + case 'n': initFile = optarg_; break; case 't': displayMovingEdge = false; break; case 'f': cao3DModel = true; break; case 'c': click_allowed = false; break; @@ -155,7 +161,7 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &co case 'h': usage(argv[0], NULL); return false; break; default: - usage(argv[0], optarg); + usage(argv[0], optarg_); return false; break; } } @@ -164,7 +170,7 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &co // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -174,241 +180,239 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &co int main(int argc, const char ** argv) { - std::string env_ipath; - std::string opt_ipath; - std::string ipath; - std::string opt_configFile; - std::string configFile; - std::string opt_modelFile; - std::string modelFile; - std::string opt_initFile; - std::string initFile; - bool displayMovingEdge = true; - bool opt_click_allowed = true; - bool opt_display = true; - bool cao3DModel = false; - bool trackCylinder = true; - bool useOgre = false; - - // 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_configFile, opt_modelFile, opt_initFile, displayMovingEdge, opt_click_allowed, opt_display, cao3DModel, trackCylinder, useOgre)) { - return (-1); - } - - // Test if an input path is set - if (opt_ipath.empty() && env_ipath.empty() ){ - usage(argv[0], NULL); - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Use -i <visp image path> 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; - - return (-1); - } + try { + std::string env_ipath; + std::string opt_ipath; + std::string ipath; + std::string opt_configFile; + std::string configFile; + std::string opt_modelFile; + std::string modelFile; + std::string opt_initFile; + std::string initFile; + bool displayMovingEdge = true; + bool opt_click_allowed = true; + bool opt_display = true; + bool cao3DModel = false; + bool trackCylinder = true; + bool useOgre = false; + + // 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_configFile, opt_modelFile, opt_initFile, displayMovingEdge, opt_click_allowed, opt_display, cao3DModel, trackCylinder, useOgre)) { + return (-1); + } - // Get the option values - if (!opt_ipath.empty()) - ipath = opt_ipath + vpIoTools::path("/ViSP-images/mbt/cube/image%04d.pgm"); - else - ipath = env_ipath + vpIoTools::path("/ViSP-images/mbt/cube/image%04d.pgm"); - - if (!opt_configFile.empty()) - configFile = opt_configFile; - else if (!opt_ipath.empty()) - configFile = opt_ipath + vpIoTools::path("/ViSP-images/mbt/cube.xml"); - else - configFile = env_ipath + vpIoTools::path("/ViSP-images/mbt/cube.xml"); - - if (!opt_modelFile.empty()){ - modelFile = opt_modelFile; - }else{ - std::string modelFileCao; - std::string modelFileWrl; - if(trackCylinder){ - modelFileCao = "/ViSP-images/mbt/cube_and_cylinder.cao"; - modelFileWrl = "/ViSP-images/mbt/cube_and_cylinder.wrl"; - }else{ - modelFileCao = "/ViSP-images/mbt/cube.cao"; - modelFileWrl = "/ViSP-images/mbt/cube.wrl"; + // Test if an input path is set + if (opt_ipath.empty() && env_ipath.empty() ){ + usage(argv[0], NULL); + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Use -i <visp image path> 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; + + return (-1); } - if(!opt_ipath.empty()){ - if(cao3DModel){ - modelFile = opt_ipath + vpIoTools::path(modelFileCao); + // Get the option values + if (!opt_ipath.empty()) + ipath = opt_ipath + vpIoTools::path("/ViSP-images/mbt/cube/image%04d.pgm"); + else + ipath = env_ipath + vpIoTools::path("/ViSP-images/mbt/cube/image%04d.pgm"); + + if (!opt_configFile.empty()) + configFile = opt_configFile; + else if (!opt_ipath.empty()) + configFile = opt_ipath + vpIoTools::path("/ViSP-images/mbt/cube.xml"); + else + configFile = env_ipath + vpIoTools::path("/ViSP-images/mbt/cube.xml"); + + if (!opt_modelFile.empty()){ + modelFile = opt_modelFile; + }else{ + std::string modelFileCao; + std::string modelFileWrl; + if(trackCylinder){ + modelFileCao = "/ViSP-images/mbt/cube_and_cylinder.cao"; + modelFileWrl = "/ViSP-images/mbt/cube_and_cylinder.wrl"; + }else{ + modelFileCao = "/ViSP-images/mbt/cube.cao"; + modelFileWrl = "/ViSP-images/mbt/cube.wrl"; } - else{ + + if(!opt_ipath.empty()){ + if(cao3DModel){ + std::cout << "use cao" << std::endl; + modelFile = opt_ipath + vpIoTools::path(modelFileCao); + } + else{ #ifdef VISP_HAVE_COIN - modelFile = opt_ipath + vpIoTools::path(modelFileWrl); + std::cout << "use wrl" << std::endl; + modelFile = opt_ipath + vpIoTools::path(modelFileWrl); #else - std::cerr << "Coin is not detected in ViSP. Use the .cao model instead." << std::endl; - modelFile = opt_ipath + vpIoTools::path(modelFileCao); + std::cerr << "Coin is not detected in ViSP. Use the .cao model instead." << std::endl; + modelFile = opt_ipath + vpIoTools::path(modelFileCao); #endif - } - } - else{ - if(cao3DModel){ - modelFile = env_ipath + vpIoTools::path(modelFileCao); + } } else{ + if(cao3DModel){ + std::cout << "use cao" << std::endl; + modelFile = env_ipath + vpIoTools::path(modelFileCao); + } + else{ #ifdef VISP_HAVE_COIN - modelFile = env_ipath + vpIoTools::path(modelFileWrl); + std::cout << "use wrl" << std::endl; + modelFile = env_ipath + vpIoTools::path(modelFileWrl); #else - std::cerr << "Coin is not detected in ViSP. Use the .cao model instead." << std::endl; - modelFile = env_ipath + vpIoTools::path(modelFileCao); + std::cerr << "Coin is not detected in ViSP. Use the .cao model instead." << std::endl; + modelFile = env_ipath + vpIoTools::path(modelFileCao); #endif + } } } - } - - if (!opt_initFile.empty()) - initFile = opt_initFile; - else if (!opt_ipath.empty()) - initFile = opt_ipath + vpIoTools::path("/ViSP-images/mbt/cube"); - else - initFile = env_ipath + vpIoTools::path("/ViSP-images/mbt/cube"); - - vpImage<unsigned char> I; - vpVideoReader reader; - - reader.setFileName(ipath.c_str()); - try{ - reader.open(I); - }catch(...){ - std::cout << "Cannot open sequence: " << ipath << std::endl; - return -1; - } - - reader.acquire(I); - // initialise a display + if (!opt_initFile.empty()) + initFile = opt_initFile; + else if (!opt_ipath.empty()) + initFile = opt_ipath + vpIoTools::path("/ViSP-images/mbt/cube"); + else + initFile = env_ipath + vpIoTools::path("/ViSP-images/mbt/cube"); + + vpImage<unsigned char> I; + vpVideoReader reader; + + reader.setFileName(ipath.c_str()); + try{ + reader.open(I); + }catch(...){ + std::cout << "Cannot open sequence: " << ipath << std::endl; + return -1; + } + + reader.acquire(I); + + // initialise a display #if defined VISP_HAVE_X11 - vpDisplayX display; + vpDisplayX display; #elif defined VISP_HAVE_GDI - vpDisplayGDI display; + vpDisplayGDI display; #elif defined VISP_HAVE_OPENCV - vpDisplayOpenCV display; + vpDisplayOpenCV display; #elif defined VISP_HAVE_D3D9 - vpDisplayD3D display; + vpDisplayD3D display; #elif defined VISP_HAVE_GTK - vpDisplayGTK display; + vpDisplayGTK display; #else - opt_display = false; + opt_display = false; #endif - if (opt_display) - { + if (opt_display) + { #if (defined VISP_HAVE_DISPLAY) - display.init(I, 100, 100, "Test tracking") ; + display.init(I, 100, 100, "Test tracking") ; #endif - vpDisplay::display(I) ; - vpDisplay::flush(I); - } + vpDisplay::display(I) ; + vpDisplay::flush(I); + } - vpMbEdgeTracker tracker; - vpHomogeneousMatrix cMo; + vpMbEdgeTracker tracker; + vpHomogeneousMatrix cMo; - // Initialise the tracker: camera parameters, moving edge and KLT settings - vpCameraParameters cam; + // Initialise the tracker: camera parameters, moving edge and KLT settings + vpCameraParameters cam; #if defined (VISP_HAVE_XML2) - // From the xml file - tracker.loadConfigFile(configFile.c_str()); + // From the xml file + tracker.loadConfigFile(configFile.c_str()); #else - // By setting the parameters: - cam.initPersProjWithoutDistortion(547, 542, 338, 234); - - vpMe me; - me.setMaskSize(5); - me.setMaskNumber(180); - me.setRange(7); - me.setThreshold(5000); - me.setMu1(0.5); - me.setMu2(0.5); - me.setMinSampleStep(4); - me.setNbTotalSample(250); - - tracker.setCameraParameters(cam); - tracker.setMovingEdge(me); - - // Specify the clipping to use - tracker.setNearClippingDistance(0.01); - tracker.setFarClippingDistance(0.90); - tracker.setClipping(tracker.getClipping() | vpMbtPolygon::FOV_CLIPPING); -// tracker.setClipping(tracker.getClipping() | vpMbtPolygon::LEFT_CLIPPING | vpMbtPolygon::RIGHT_CLIPPING | vpMbtPolygon::UP_CLIPPING | vpMbtPolygon::DOWN_CLIPPING); // Equivalent to FOV_CLIPPING + // By setting the parameters: + cam.initPersProjWithoutDistortion(547, 542, 338, 234); + + vpMe me; + me.setMaskSize(5); + me.setMaskNumber(180); + me.setRange(7); + me.setThreshold(5000); + me.setMu1(0.5); + me.setMu2(0.5); + me.setMinSampleStep(4); + me.setNbTotalSample(250); + + tracker.setCameraParameters(cam); + tracker.setMovingEdge(me); + + // Specify the clipping to use + tracker.setNearClippingDistance(0.01); + tracker.setFarClippingDistance(0.90); + tracker.setClipping(tracker.getClipping() | vpMbtPolygon::FOV_CLIPPING); + // tracker.setClipping(tracker.getClipping() | vpMbtPolygon::LEFT_CLIPPING | vpMbtPolygon::RIGHT_CLIPPING | vpMbtPolygon::UP_CLIPPING | vpMbtPolygon::DOWN_CLIPPING); // Equivalent to FOV_CLIPPING #endif - // Display the moving edges, see documentation for the significations of the colour - tracker.setDisplayMovingEdges(displayMovingEdge); - - // Tells if the tracker has to use Ogre3D for visibility tests - tracker.setOgreVisibilityTest(useOgre); - - // Retrieve the camera parameters from the tracker - tracker.getCameraParameters(cam); - - // Loop to position the cube - if (opt_display && opt_click_allowed) - { - while(!vpDisplay::getClick(I,false)){ - vpDisplay::display(I); - vpDisplay::displayCharString(I, 15, 10, - "click after positioning the object", - vpColor::red); - vpDisplay::flush(I) ; + // Display the moving edges, see documentation for the significations of the colour + tracker.setDisplayMovingEdges(displayMovingEdge); + + // Tells if the tracker has to use Ogre3D for visibility tests + tracker.setOgreVisibilityTest(useOgre); + + // Retrieve the camera parameters from the tracker + tracker.getCameraParameters(cam); + + // Loop to position the cube + if (opt_display && opt_click_allowed) + { + while(!vpDisplay::getClick(I,false)){ + vpDisplay::display(I); + vpDisplay::displayCharString(I, 15, 10, + "click after positioning the object", + vpColor::red); + vpDisplay::flush(I) ; + } } - } - // Load the 3D model (either a vrml file or a .cao file) - try{ + // Load the 3D model (either a vrml file or a .cao file) tracker.loadModel(modelFile.c_str()); - } - catch(...) - { - return 0; - } - // Initialise the tracker by clicking on the image - // This function looks for - // - a ./cube/cube.init file that defines the 3d coordinates (in meter, in the object basis) of the points used for the initialisation - // - a ./cube/cube.ppm file to display where the user have to click (optionnal, set by the third parameter) - if (opt_display && opt_click_allowed) - { - tracker.initClick(I, initFile.c_str(), true); + + // Initialise the tracker by clicking on the image + // This function looks for + // - a ./cube/cube.init file that defines the 3d coordinates (in meter, in the object basis) of the points used for the initialisation + // - a ./cube/cube.ppm file to display where the user have to click (optionnal, set by the third parameter) + if (opt_display && opt_click_allowed) + { + tracker.initClick(I, initFile.c_str(), true); + tracker.getPose(cMo); + // display the 3D model at the given pose + tracker.display(I,cMo, cam, vpColor::red); + } + else + { + vpHomogeneousMatrix cMoi(0.02044769891, 0.1101505452, 0.5078963719, 2.063603907, 1.110231561, -0.4392789872); + tracker.initFromPose(I, cMoi); + } + + //track the model + tracker.track(I); tracker.getPose(cMo); - // display the 3D model at the given pose - tracker.display(I,cMo, cam, vpColor::red); - } - else - { - vpHomogeneousMatrix cMoi(0.02044769891, 0.1101505452, 0.5078963719, 2.063603907, 1.110231561, -0.4392789872); - tracker.initFromPose(I, cMoi); - } - //track the model - tracker.track(I); - tracker.getPose(cMo); - - if (opt_display) - vpDisplay::flush(I); + if (opt_display) + vpDisplay::flush(I); - // Uncomment if you want to compute the covariance matrix. - // tracker.setCovarianceComputation(true); //Important if you want tracker.getCovarianceMatrix() to work. - - while (!reader.end()) - { - try + // Uncomment if you want to compute the covariance matrix. + // tracker.setCovarianceComputation(true); //Important if you want tracker.getCovarianceMatrix() to work. + + while (!reader.end()) { - // acquire a new image + // acquire a new image reader.acquire(I); // display the image if (opt_display) @@ -416,7 +420,7 @@ main(int argc, const char ** argv) // track the object tracker.track(I); tracker.getPose(cMo); - // display the 3D model + // display the 3D model if (opt_display) { tracker.display(I, cMo, cam, vpColor::darkRed); @@ -424,31 +428,29 @@ main(int argc, const char ** argv) vpDisplay::displayFrame (I, cMo, cam, 0.05, vpColor::blue); } - // Uncomment if you want to print the covariance matrix. + // Uncomment if you want to print the covariance matrix. // Make sure tracker.setCovarianceComputation(true) has been called (uncomment below). // std::cout << tracker.getCovarianceMatrix() << std::endl << std::endl; - - } - catch(...) - { - std::cout << "error caught" << std::endl; - break; + vpDisplay::flush(I) ; } - vpDisplay::flush(I) ; - } - reader.close(); + reader.close(); #if defined (VISP_HAVE_XML2) - // Cleanup memory allocated by xml library used to parse the xml config file in vpMbEdgeTracker::loadConfigFile() - vpXmlParser::cleanup(); + // Cleanup memory allocated by xml library used to parse the xml config file in vpMbEdgeTracker::loadConfigFile() + vpXmlParser::cleanup(); #endif #ifdef VISP_HAVE_COIN - // Cleanup memory allocated by Coin library used to load a vrml model in vpMbEdgeTracker::loadModel() - SoDB::finish(); + // Cleanup memory allocated by Coin library used to load a vrml model in vpMbEdgeTracker::loadModel() + SoDB::finish(); #endif - return 0; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } #else diff --git a/example/tracking/mbtKltTracking.cpp b/example/tracking/mbtKltTracking.cpp index 18a8217bf534ccb298f745f1f5722caa9844f9ab..45621b7d00fc1d0fbbd74d1e4c6958a14e0a9dac 100644 --- a/example/tracking/mbtKltTracking.cpp +++ b/example/tracking/mbtKltTracking.cpp @@ -3,7 +3,7 @@ * $Id: mbtTracking.cpp 3957 2012-11-07 15:22:30Z fnovotny $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -65,6 +65,10 @@ #define GETOPTARGS "x:m:i:n:dchtfo" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &configFile, std::string &modelFile, + std::string &initFile, bool &displayKltPoints, bool &click_allowed, bool &display, + bool& cao3DModel, bool &useOgre); void usage(const char *name, const char *badparam) { @@ -129,26 +133,28 @@ OPTIONS: \n\ } -bool getOptions(int argc, const char **argv, std::string &ipath, std::string &configFile, std::string &modelFile, std::string &initFile, bool &displayKltPoints, bool &click_allowed, bool &display, bool& cao3DModel, bool &useOgre) +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &configFile, std::string &modelFile, + std::string &initFile, bool &displayKltPoints, bool &click_allowed, bool &display, + bool& cao3DModel, bool &useOgre) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { - case 'i': ipath = optarg; break; - case 'x': configFile = optarg; break; - case 'm': modelFile = optarg; break; - case 'n': initFile = optarg; break; + case 'i': ipath = optarg_; break; + case 'x': configFile = optarg_; break; + case 'm': modelFile = optarg_; break; + case 'n': initFile = optarg_; break; case 't': displayKltPoints = false; break; case 'f': cao3DModel = true; break; case 'c': click_allowed = false; break; case 'd': display = false; break; - case 'o' : useOgre = true; break; + case 'o': useOgre = true; break; case 'h': usage(argv[0], NULL); return false; break; default: - usage(argv[0], optarg); + usage(argv[0], optarg_); return false; break; } } @@ -157,7 +163,7 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &co // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -167,233 +173,227 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &co int main(int argc, const char ** argv) { - std::string env_ipath; - std::string opt_ipath; - std::string ipath; - std::string opt_configFile; - std::string configFile; - std::string opt_modelFile; - std::string modelFile; - std::string opt_initFile; - std::string initFile; - bool displayKltPoints = true; - bool opt_click_allowed = true; - bool opt_display = true; - bool cao3DModel = false; - bool useOgre = false; - - // 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_configFile, opt_modelFile, opt_initFile, displayKltPoints, opt_click_allowed, opt_display, cao3DModel, useOgre)) { - return (-1); - } + try { + std::string env_ipath; + std::string opt_ipath; + std::string ipath; + std::string opt_configFile; + std::string configFile; + std::string opt_modelFile; + std::string modelFile; + std::string opt_initFile; + std::string initFile; + bool displayKltPoints = true; + bool opt_click_allowed = true; + bool opt_display = true; + bool cao3DModel = false; + bool useOgre = false; + + // 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_configFile, opt_modelFile, opt_initFile, displayKltPoints, opt_click_allowed, opt_display, cao3DModel, useOgre)) { + return (-1); + } - // Test if an input path is set - if (opt_ipath.empty() && env_ipath.empty() ){ - usage(argv[0], NULL); - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Use -i <visp image path> 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; - - return (-1); - } + // Test if an input path is set + if (opt_ipath.empty() && env_ipath.empty() ){ + usage(argv[0], NULL); + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Use -i <visp image path> 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; + + return (-1); + } - // Get the option values - if (!opt_ipath.empty()) - ipath = opt_ipath + vpIoTools::path("/ViSP-images/mbt/cube/image%04d.pgm"); - else - ipath = env_ipath + vpIoTools::path("/ViSP-images/mbt/cube/image%04d.pgm"); - - if (!opt_configFile.empty()) - configFile = opt_configFile; - else if (!opt_ipath.empty()) - configFile = opt_ipath + vpIoTools::path("/ViSP-images/mbt/cube.xml"); - else - configFile = env_ipath + vpIoTools::path("/ViSP-images/mbt/cube.xml"); - - if (!opt_modelFile.empty()){ - modelFile = opt_modelFile; - }else{ - std::string modelFileCao = "/ViSP-images/mbt/cube.cao"; - std::string modelFileWrl = "/ViSP-images/mbt/cube.wrl"; - - if(!opt_ipath.empty()){ - if(cao3DModel){ - modelFile = opt_ipath + vpIoTools::path(modelFileCao); - } - else{ + // Get the option values + if (!opt_ipath.empty()) + ipath = opt_ipath + vpIoTools::path("/ViSP-images/mbt/cube/image%04d.pgm"); + else + ipath = env_ipath + vpIoTools::path("/ViSP-images/mbt/cube/image%04d.pgm"); + + if (!opt_configFile.empty()) + configFile = opt_configFile; + else if (!opt_ipath.empty()) + configFile = opt_ipath + vpIoTools::path("/ViSP-images/mbt/cube.xml"); + else + configFile = env_ipath + vpIoTools::path("/ViSP-images/mbt/cube.xml"); + + if (!opt_modelFile.empty()){ + modelFile = opt_modelFile; + }else{ + std::string modelFileCao = "/ViSP-images/mbt/cube.cao"; + std::string modelFileWrl = "/ViSP-images/mbt/cube.wrl"; + + if(!opt_ipath.empty()){ + if(cao3DModel){ + modelFile = opt_ipath + vpIoTools::path(modelFileCao); + } + else{ #ifdef VISP_HAVE_COIN - modelFile = opt_ipath + vpIoTools::path(modelFileWrl); + modelFile = opt_ipath + vpIoTools::path(modelFileWrl); #else - std::cerr << "Coin is not detected in ViSP. Use the .cao model instead." << std::endl; - modelFile = opt_ipath + vpIoTools::path(modelFileCao); + std::cerr << "Coin is not detected in ViSP. Use the .cao model instead." << std::endl; + modelFile = opt_ipath + vpIoTools::path(modelFileCao); #endif - } - } - else{ - if(cao3DModel){ - modelFile = env_ipath + vpIoTools::path(modelFileCao); + } } else{ + if(cao3DModel){ + modelFile = env_ipath + vpIoTools::path(modelFileCao); + } + else{ #ifdef VISP_HAVE_COIN - modelFile = env_ipath + vpIoTools::path(modelFileWrl); + modelFile = env_ipath + vpIoTools::path(modelFileWrl); #else - std::cerr << "Coin is not detected in ViSP. Use the .cao model instead." << std::endl; - modelFile = env_ipath + vpIoTools::path(modelFileCao); + std::cerr << "Coin is not detected in ViSP. Use the .cao model instead." << std::endl; + modelFile = env_ipath + vpIoTools::path(modelFileCao); #endif + } } } - } - - if (!opt_initFile.empty()) - initFile = opt_initFile; - else if (!opt_ipath.empty()) - initFile = opt_ipath + vpIoTools::path("/ViSP-images/mbt/cube"); - else - initFile = env_ipath + vpIoTools::path("/ViSP-images/mbt/cube"); - - vpImage<unsigned char> I; - vpVideoReader reader; - - reader.setFileName(ipath.c_str()); - try{ - reader.open(I); - }catch(...){ - std::cout << "Cannot open sequence: " << ipath << std::endl; - return -1; - } - - reader.acquire(I); - // initialise a display + if (!opt_initFile.empty()) + initFile = opt_initFile; + else if (!opt_ipath.empty()) + initFile = opt_ipath + vpIoTools::path("/ViSP-images/mbt/cube"); + else + initFile = env_ipath + vpIoTools::path("/ViSP-images/mbt/cube"); + + vpImage<unsigned char> I; + vpVideoReader reader; + + reader.setFileName(ipath.c_str()); + try{ + reader.open(I); + }catch(...){ + std::cout << "Cannot open sequence: " << ipath << std::endl; + return -1; + } + + reader.acquire(I); + + // initialise a display #if defined VISP_HAVE_X11 - vpDisplayX display; + vpDisplayX display; #elif defined VISP_HAVE_GDI - vpDisplayGDI display; + vpDisplayGDI display; #elif defined VISP_HAVE_OPENCV - vpDisplayOpenCV display; + vpDisplayOpenCV display; #elif defined VISP_HAVE_D3D9 - vpDisplayD3D display; + vpDisplayD3D display; #elif defined VISP_HAVE_GTK - vpDisplayGTK display; + vpDisplayGTK display; #else - opt_display = false; + opt_display = false; #endif - if (opt_display) - { + if (opt_display) + { #if (defined VISP_HAVE_DISPLAY) - display.init(I, 100, 100, "Test tracking") ; + display.init(I, 100, 100, "Test tracking") ; #endif - vpDisplay::display(I) ; - vpDisplay::flush(I); - } + vpDisplay::display(I) ; + vpDisplay::flush(I); + } - vpMbKltTracker tracker; - vpHomogeneousMatrix cMo; - - // Load tracker config file (camera parameters and moving edge settings) - vpCameraParameters cam; + vpMbKltTracker tracker; + vpHomogeneousMatrix cMo; + + // Load tracker config file (camera parameters and moving edge settings) + vpCameraParameters cam; #if defined (VISP_HAVE_XML2) - // From the xml file - tracker.loadConfigFile(configFile.c_str()); + // From the xml file + tracker.loadConfigFile(configFile.c_str()); #else - // By setting the parameters: - cam.initPersProjWithoutDistortion(547, 542, 338, 234); - - vpKltOpencv klt; - klt.setMaxFeatures(10000); - klt.setWindowSize(5); - klt.setQuality(0.01); - klt.setMinDistance(5); - klt.setHarrisFreeParameter(0.01); - klt.setBlockSize(3); - klt.setPyramidLevels(3); - - tracker.setCameraParameters(cam); - tracker.setKltOpencv(klt); - tracker.setAngleAppear( vpMath::rad(65) ); - tracker.setAngleDisappear( vpMath::rad(75) ); - tracker.setMaskBorder(5); - - // Specify the clipping to use - tracker.setNearClippingDistance(0.01); - tracker.setFarClippingDistance(0.90); - tracker.setClipping(tracker.getClipping() | vpMbtPolygon::FOV_CLIPPING); -// tracker.setClipping(tracker.getClipping() | vpMbtPolygon::LEFT_CLIPPING | vpMbtPolygon::RIGHT_CLIPPING | vpMbtPolygon::UP_CLIPPING | vpMbtPolygon::DOWN_CLIPPING); // Equivalent to FOV_CLIPPING + // By setting the parameters: + cam.initPersProjWithoutDistortion(547, 542, 338, 234); + + vpKltOpencv klt; + klt.setMaxFeatures(10000); + klt.setWindowSize(5); + klt.setQuality(0.01); + klt.setMinDistance(5); + klt.setHarrisFreeParameter(0.01); + klt.setBlockSize(3); + klt.setPyramidLevels(3); + + tracker.setCameraParameters(cam); + tracker.setKltOpencv(klt); + tracker.setAngleAppear( vpMath::rad(65) ); + tracker.setAngleDisappear( vpMath::rad(75) ); + tracker.setMaskBorder(5); + + // Specify the clipping to use + tracker.setNearClippingDistance(0.01); + tracker.setFarClippingDistance(0.90); + tracker.setClipping(tracker.getClipping() | vpMbtPolygon::FOV_CLIPPING); + // tracker.setClipping(tracker.getClipping() | vpMbtPolygon::LEFT_CLIPPING | vpMbtPolygon::RIGHT_CLIPPING | vpMbtPolygon::UP_CLIPPING | vpMbtPolygon::DOWN_CLIPPING); // Equivalent to FOV_CLIPPING #endif - - // Display the klt points - tracker.setDisplayFeatures(displayKltPoints); - - // Tells if the tracker has to use Ogre3D for visibility tests - tracker.setOgreVisibilityTest(useOgre); - // Retrieve the camera parameters from the tracker - tracker.getCameraParameters(cam); - - // Loop to position the cube - if (opt_display && opt_click_allowed) - { - while(!vpDisplay::getClick(I,false)){ - vpDisplay::display(I); - vpDisplay::displayCharString(I, 15, 10, - "click after positioning the object", - vpColor::red); - vpDisplay::flush(I) ; + // Display the klt points + tracker.setDisplayFeatures(displayKltPoints); + + // Tells if the tracker has to use Ogre3D for visibility tests + tracker.setOgreVisibilityTest(useOgre); + + // Retrieve the camera parameters from the tracker + tracker.getCameraParameters(cam); + + // Loop to position the cube + if (opt_display && opt_click_allowed) + { + while(!vpDisplay::getClick(I,false)){ + vpDisplay::display(I); + vpDisplay::displayCharString(I, 15, 10, + "click after positioning the object", + vpColor::red); + vpDisplay::flush(I) ; + } } - } - // Load the 3D model (either a vrml file or a .cao file) - try{ + // Load the 3D model (either a vrml file or a .cao file) tracker.loadModel(modelFile.c_str()); - } - catch(...) - { - return 0; - } - // Initialise the tracker by clicking on the image - // This function looks for - // - a ./cube/cube.init file that defines the 3d coordinates (in meter, in the object basis) of the points used for the initialisation - // - a ./cube/cube.ppm file to display where the user have to click (optionnal, set by the third parameter) - if (opt_display && opt_click_allowed) - { - tracker.initClick(I, initFile.c_str(), true); + + // Initialise the tracker by clicking on the image + // This function looks for + // - a ./cube/cube.init file that defines the 3d coordinates (in meter, in the object basis) of the points used for the initialisation + // - a ./cube/cube.ppm file to display where the user have to click (optionnal, set by the third parameter) + if (opt_display && opt_click_allowed) + { + tracker.initClick(I, initFile.c_str(), true); + tracker.getPose(cMo); + // display the 3D model at the given pose + tracker.display(I,cMo, cam, vpColor::red); + } + else + { + vpHomogeneousMatrix cMoi(0.02044769891, 0.1101505452, 0.5078963719, 2.063603907, 1.110231561, -0.4392789872); + tracker.initFromPose(I, cMoi); + } + + //track the model + tracker.track(I); tracker.getPose(cMo); - // display the 3D model at the given pose - tracker.display(I,cMo, cam, vpColor::red); - } - else - { - vpHomogeneousMatrix cMoi(0.02044769891, 0.1101505452, 0.5078963719, 2.063603907, 1.110231561, -0.4392789872); - tracker.initFromPose(I, cMoi); - } - //track the model - tracker.track(I); - tracker.getPose(cMo); - - if (opt_display) - vpDisplay::flush(I); + if (opt_display) + vpDisplay::flush(I); - // Uncomment if you want to compute the covariance matrix. - // tracker.setCovarianceComputation(true); //Important if you want tracker.getCovarianceMatrix() to work. - - while (!reader.end()) - { - try + // Uncomment if you want to compute the covariance matrix. + // tracker.setCovarianceComputation(true); //Important if you want tracker.getCovarianceMatrix() to work. + + while (!reader.end()) { // acquire a new image reader.acquire(I); @@ -414,28 +414,27 @@ main(int argc, const char ** argv) // Uncomment if you want to print the covariance matrix. // Make sure tracker.setCovarianceComputation(true) has been called (uncomment below). // std::cout << tracker.getCovarianceMatrix() << std::endl << std::endl; - - } - catch(...) - { - std::cout << "error caught" << std::endl; - break; + + vpDisplay::flush(I) ; } - vpDisplay::flush(I) ; - } - reader.close(); + reader.close(); #if defined (VISP_HAVE_XML2) - // Cleanup memory allocated by xml library used to parse the xml config file in vpMbKltTracker::loadConfigFile() - vpXmlParser::cleanup(); + // Cleanup memory allocated by xml library used to parse the xml config file in vpMbKltTracker::loadConfigFile() + vpXmlParser::cleanup(); #endif #ifdef VISP_HAVE_COIN - // Cleanup memory allocated by Coin library used to load a vrml model in vpMbKltTracker::loadModel() - SoDB::finish(); + // Cleanup memory allocated by Coin library used to load a vrml model in vpMbKltTracker::loadModel() + SoDB::finish(); #endif - return 0; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } #else diff --git a/example/tracking/templateTracker.cpp b/example/tracking/templateTracker.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1d1c0bebd5bb6278cbf8a125d34db27bd0d580c7 --- /dev/null +++ b/example/tracking/templateTracker.cpp @@ -0,0 +1,430 @@ +/**************************************************************************** + * + * $Id: templateTracker.cpp 4658 2014-02-09 09:50:14Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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 template tracking. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ + +/*! + \example templateTracker.cpp + + \brief Example of template tracking. +*/ + +#include <visp/vpConfig.h> +#include <visp/vpDebug.h> +#include <visp/vpDisplayD3D.h> +#include <visp/vpDisplayGTK.h> +#include <visp/vpDisplayGDI.h> +#include <visp/vpDisplayOpenCV.h> +#include <visp/vpDisplayX.h> +#include <visp/vpHomogeneousMatrix.h> +#include <visp/vpImageIo.h> +#include <visp/vpIoTools.h> +#include <visp/vpMath.h> +#include <visp/vpVideoReader.h> +#include <visp/vpParseArgv.h> + +#include <visp/vpTemplateTrackerSSD.h> +#include <visp/vpTemplateTrackerSSDForwardAdditional.h> +#include <visp/vpTemplateTrackerSSDForwardCompositional.h> +#include <visp/vpTemplateTrackerSSDInverseCompositional.h> +#include <visp/vpTemplateTrackerSSDESM.h> +#include <visp/vpTemplateTrackerZNCCForwardAdditional.h> +#include <visp/vpTemplateTrackerZNCCInverseCompositional.h> + +#include <visp/vpTemplateTrackerWarpAffine.h> +#include <visp/vpTemplateTrackerWarpHomography.h> +#include <visp/vpTemplateTrackerWarpHomographySL3.h> +#include <visp/vpTemplateTrackerWarpSRT.h> +#include <visp/vpTemplateTrackerWarpTranslation.h> + +#if defined (VISP_HAVE_DISPLAY) + + +#define GETOPTARGS "cdhi:l:pt:w:" + +#ifndef DOXYGEN_SHOULD_SKIP_THIS +typedef enum { + WARP_AFFINE, + WARP_HOMOGRAPHY, + WARP_HOMOGRAPHY_SL3, + WARP_SRT, + WARP_TRANSLATION +} WarpType; + +typedef enum { + TRACKER_SSD_ESM, + TRACKER_SSD_FORWARD_ADDITIONAL, + TRACKER_SSD_FORWARD_COMPOSITIONAL, + TRACKER_SSD_INVERSE_COMPOSITIONAL, // The most efficient + TRACKER_ZNCC_FORWARD_ADDITIONEL, + TRACKER_ZNCC_INVERSE_COMPOSITIONAL +} TrackerType; + +#endif + +void usage(const char *name, const char *badparam, const WarpType &warp_type, + TrackerType &tracker_type, const long &last_frame); +bool getOptions(int argc, const char **argv, std::string &ipath, bool &click_allowed, bool &display, + bool &pyramidal, WarpType &warp_type, TrackerType &tracker_type, long &last_frame); + +void usage(const char *name, const char *badparam, const WarpType &warp_type, + TrackerType &tracker_type, const long &last_frame) +{ + fprintf(stdout, "\n\ +Example of template tracking.\n\ +\n\ +SYNOPSIS\n\ + %s [-i <test image path>] [-c] [-d] [-p] \n\ + [-w <warp type>] [-t <tracker type>] \n\ + [-l <last frame number>] [-h]\n", name ); + + fprintf(stdout, "\n\ +OPTIONS: Default\n\ + -i <input image path> \n\ + Set image input path.\n\ + From this path read images \n\ + \"ViSP-images/cube/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\ + -l <last frame number> %ld\n\ + Last frame number to consider.\n\ + \n\ + -d \n\ + Turn off the display.\n\ + \n\ + -c\n\ + Disable the mouse click. Useful to automaze the \n\ + execution of this program without humain intervention.\n\ + \n\ + -w <warp type=[0,1,2,3,4]> %d\n\ + Set the model used to warp the template. \n\ + Authorized values are:\n\ + %d : Affine\n\ + %d : Homography\n\ + %d : Homography in SL3\n\ + %d : SRT (scale, rotation, translation)\n\ + %d : Translation\n\ + \n\ + -t <tracker type=[0,1,2,3,4,5]> %d\n\ + Set the tracker used to track the template. \n\ + Authorized values are:\n\ + %d : SSD ESM\n\ + %d : SSD forward additional\n\ + %d : SSD forward compositional\n\ + %d : SSD inverse compositional\n\ + %d : ZNCC forward additional\n\ + %d : ZNCC inverse compositional\n\ + \n\ + -p\n\ + Enable pyramidal tracking.\n\ + \n\ + -h \n\ + Print the help.\n\n", + last_frame, (int)warp_type, + (int)WARP_AFFINE, (int)WARP_HOMOGRAPHY, (int)WARP_HOMOGRAPHY_SL3, (int)WARP_SRT, (int)WARP_TRANSLATION, + (int)tracker_type, + (int)TRACKER_SSD_ESM, (int)TRACKER_SSD_FORWARD_ADDITIONAL, (int)TRACKER_SSD_FORWARD_COMPOSITIONAL, + (int)TRACKER_SSD_INVERSE_COMPOSITIONAL, (int)TRACKER_ZNCC_FORWARD_ADDITIONEL, + (int)TRACKER_ZNCC_INVERSE_COMPOSITIONAL); + if (badparam) + fprintf(stdout, "\nERROR: Bad parameter [%s]\n", badparam); +} + + +bool getOptions(int argc, const char **argv, std::string &ipath, bool &click_allowed, bool &display, + bool &pyramidal, WarpType &warp_type, TrackerType &tracker_type, long &last_frame) +{ + 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, warp_type, tracker_type, last_frame); return false; break; + case 'i': ipath = optarg_; break; + case 'l': last_frame = (long)atoi(optarg_); break; + case 'p': pyramidal = true; break; + case 't': tracker_type = (TrackerType)atoi(optarg_); break; + case 'w': warp_type = (WarpType)atoi(optarg_); break; + + default: + usage(argv[0], optarg_, warp_type, tracker_type, last_frame); + return false; break; + } + } + + if (warp_type > WARP_TRANSLATION) { + usage(argv[0], NULL, warp_type, tracker_type, last_frame); + std::cerr << "ERROR: " << std::endl; + std::cerr << " Bad argument -w <warp type> with \"warp type\"=" << (int)warp_type << std::endl << std::endl; + return false; + } + if (tracker_type > TRACKER_ZNCC_INVERSE_COMPOSITIONAL) { + usage(argv[0], NULL, warp_type, tracker_type, last_frame); + std::cerr << "ERROR: " << std::endl; + std::cerr << " Bad argument -t <tracker type> with \"tracker type\"=" << (int)tracker_type << std::endl << std::endl; + return false; + } + if ((c == 1) || (c == -1)) { + // standalone param or error + usage(argv[0], NULL, warp_type, tracker_type, last_frame); + 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) +{ + try { + std::string env_ipath; + std::string opt_ipath; + std::string ipath; + bool opt_click_allowed = true; + bool opt_display = true; + bool opt_pyramidal = false; + TrackerType opt_tracker_type = TRACKER_SSD_INVERSE_COMPOSITIONAL; + WarpType opt_warp_type = WARP_AFFINE; + long opt_last_frame = 30; + + // 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_click_allowed, opt_display, opt_pyramidal, + opt_warp_type, opt_tracker_type, opt_last_frame)) { + return (-1); + } + + // Test if an input path is set + if (opt_ipath.empty() && env_ipath.empty() ){ + usage(argv[0], NULL, opt_warp_type, opt_tracker_type, opt_last_frame); + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Use -i <visp image path> 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; + + return (-1); + } + + // Get the option values + if (!opt_ipath.empty()) + ipath = opt_ipath + vpIoTools::path("/ViSP-images/mire-2/image.%04d.pgm"); + else + ipath = env_ipath + vpIoTools::path("/ViSP-images/mire-2/image.%04d.pgm"); + + vpImage<unsigned char> I; + vpVideoReader reader; + + reader.setFileName(ipath.c_str()); + reader.setFirstFrameIndex(1); + reader.setLastFrameIndex(opt_last_frame); + try{ + reader.open(I); + }catch(...){ + std::cout << "Cannot open sequence: " << ipath << std::endl; + return -1; + } + reader.acquire(I); + + vpDisplay *display = NULL; + if (opt_display) + { + // initialise a display +#if defined VISP_HAVE_X11 + display = new vpDisplayX; +#elif defined VISP_HAVE_GDI + display = new vpDisplayGDI; +#elif defined VISP_HAVE_OPENCV + display = new vpDisplayOpenCV; +#elif defined VISP_HAVE_D3D9 + display = new vpDisplayD3D; +#elif defined VISP_HAVE_GTK + display = new vpDisplayGTK; +#else + opt_display = false; +#endif +#if (defined VISP_HAVE_DISPLAY) + display->init(I, 100, 100, "Test tracking") ; +#endif + vpDisplay::display(I) ; + vpDisplay::flush(I); + } + + vpTemplateTrackerWarp *warp = NULL; + switch(opt_warp_type) { + case WARP_AFFINE: warp = new vpTemplateTrackerWarpAffine; break; + case WARP_HOMOGRAPHY: warp = new vpTemplateTrackerWarpHomography; break; + case WARP_HOMOGRAPHY_SL3: warp = new vpTemplateTrackerWarpHomographySL3; break; + case WARP_SRT: warp = new vpTemplateTrackerWarpSRT; break; + case WARP_TRANSLATION: warp = new vpTemplateTrackerWarpTranslation; break; + } + + vpTemplateTracker *tracker = NULL; + switch(opt_tracker_type) { + case TRACKER_SSD_ESM: tracker = new vpTemplateTrackerSSDESM(warp); break; + case TRACKER_SSD_FORWARD_ADDITIONAL: tracker = new vpTemplateTrackerSSDForwardAdditional(warp); break; + case TRACKER_SSD_FORWARD_COMPOSITIONAL: tracker = new vpTemplateTrackerSSDForwardCompositional(warp); break; + case TRACKER_SSD_INVERSE_COMPOSITIONAL: tracker = new vpTemplateTrackerSSDInverseCompositional(warp); break; + case TRACKER_ZNCC_FORWARD_ADDITIONEL: tracker = new vpTemplateTrackerZNCCForwardAdditional(warp); break; + case TRACKER_ZNCC_INVERSE_COMPOSITIONAL: tracker = new vpTemplateTrackerZNCCInverseCompositional(warp); break; + } + + tracker->setSampling(2,2); + tracker->setLambda(0.001); + tracker->setThresholdGradient(60.); + tracker->setIterationMax(800); + if (opt_pyramidal) { + tracker->setPyramidal(2, 1); + } + bool delaunay = false; + if (opt_display && opt_click_allowed) + tracker->initClick(I, delaunay); + else { + std::vector<vpImagePoint> v_ip; + vpImagePoint ip; + ip.set_ij(166, 54); v_ip.push_back(ip); + ip.set_ij(284, 55); v_ip.push_back(ip); + ip.set_ij(259, 284); v_ip.push_back(ip); // ends the first triangle + ip.set_ij(259, 284); v_ip.push_back(ip); // start the second triangle + ip.set_ij(149, 240); v_ip.push_back(ip); + ip.set_ij(167, 58); v_ip.push_back(ip); + + tracker->initFromPoints(I, v_ip, false); + } + + while (! reader.end()) + { + std::cout << "Process image number " << reader.getFrameIndex() << std::endl; + // Acquire a new image + reader.acquire(I); + // Display the image + vpDisplay::display(I); + // Track the template + tracker->track(I); + + // Simulate a re-init + if (reader.getFrameIndex() == 10){ + std::cout << "re-init simulation" << std::endl; + if (opt_click_allowed) + vpDisplay::getClick(I); + + tracker->resetTracker(); + + if (opt_display && opt_click_allowed) { + vpDisplay::displayCharString(I, 10, 10, "Re-init simulation", vpColor::red); + vpDisplay::flush(I); + tracker->initClick(I, delaunay); + } + else { + std::vector<vpImagePoint> v_ip; + vpImagePoint ip; + ip.set_ij(146, 60); v_ip.push_back(ip); + ip.set_ij(254, 74); v_ip.push_back(ip); + ip.set_ij(228, 288); v_ip.push_back(ip); // ends the first triangle + ip.set_ij(228, 288); v_ip.push_back(ip); // start the second triangle + ip.set_ij(126, 242); v_ip.push_back(ip); + ip.set_ij(146, 60); v_ip.push_back(ip); + + tracker->initFromPoints(I, v_ip, false); + } + } + + // Display the template +#if 1 + tracker->display(I, vpColor::red, 3); +#else + vpTemplateTrackerZone zoneWarped_, zoneRef_ = tracker->getZoneRef(); + vpTemplateTrackerWarp *warp_ = tracker->getWarp(); + vpColVector p_= tracker->getp(); + warp_->warpZone(zoneRef_, p_, zoneWarped_); + zoneWarped_.display(I, vpColor::red, 3); + zoneRef_.display(I, vpColor::green, 3); +#endif + + vpDisplay::flush(I) ; + } + if (opt_click_allowed) { + vpDisplay::displayCharString(I, 10,10, "A click to exit...", vpColor::red); + vpDisplay::flush(I) ; + vpDisplay::getClick(I) ; + } + reader.close(); + if (display) + delete display; + + delete warp; + delete tracker; + + return 0; + } + catch(vpException e) + { + std::cout << "Catch an exception: " << e << std::endl; + return -1; + } +} + +#else + +int main() +{ + std::cout << "No display is available." << std::endl; + return 0; +} + +#endif diff --git a/example/tracking/trackDot.cpp b/example/tracking/trackDot.cpp index 2c58fb70db825362be9fdb701f258cb6ee42c5c2..82928582d0c2f6952401dbb5e35b00db76c8dbdd 100644 --- a/example/tracking/trackDot.cpp +++ b/example/tracking/trackDot.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: trackDot.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: trackDot.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -76,6 +76,11 @@ // List of allowed command line options #define GETOPTARGS "cdf:i:n:p:s:h" +void usage(const char *name, const char *badparam, std::string ipath, std::string ppath, + unsigned first, unsigned nimages, unsigned step); +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &ppath, unsigned &first, + unsigned &nimages, unsigned &step, bool &click_allowed, bool &display); + /*! Print the program options. @@ -90,7 +95,7 @@ Print the program options. */ void usage(const char *name, const char *badparam, std::string ipath, std::string ppath, - unsigned first, unsigned nimages, unsigned step) + unsigned first, unsigned nimages, unsigned step) { fprintf(stdout, "\n\ Test dot tracking.\n\ @@ -162,27 +167,26 @@ OPTIONS: Default\n\ \return false if the program has to be stopped, true otherwise. */ -bool getOptions(int argc, const char **argv, std::string &ipath, std::string &ppath, - unsigned &first, unsigned &nimages, unsigned &step, - bool &click_allowed, bool &display) +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &ppath, unsigned &first, + unsigned &nimages, unsigned &step, bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; case 'd': display = false; break; - case 'i': ipath = optarg; break; - case 'p': ppath = optarg; break; - case 'f': first = (unsigned) atoi(optarg); break; - case 'n': nimages = (unsigned) atoi(optarg); break; - case 's': step = (unsigned) atoi(optarg); break; + case 'i': ipath = optarg_; break; + case 'p': ppath = optarg_; break; + case 'f': first = (unsigned) atoi(optarg_); break; + case 'n': nimages = (unsigned) atoi(optarg_); break; + case 's': step = (unsigned) atoi(optarg_); break; case 'h': usage(argv[0], NULL, ipath, ppath, first, nimages, step); return false; break; default: - usage(argv[0], optarg, ipath, ppath, first, nimages, step); + usage(argv[0], optarg_, ipath, ppath, first, nimages, step); return false; break; } } @@ -191,7 +195,7 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &pp // standalone param or error usage(argv[0], NULL, ipath, ppath, first, nimages, step); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -202,141 +206,141 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &pp 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; - unsigned opt_first = 1; - unsigned opt_nimages = 500; - unsigned opt_step = 1; - bool opt_click_allowed = true; - 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_ppath,opt_first, opt_nimages, - opt_step, opt_click_allowed, opt_display) == false) { - exit (-1); - } + try { + std::string env_ipath; + std::string opt_ipath; + std::string ipath; + std::string opt_ppath; + std::string dirname; + std::string filename; + unsigned opt_first = 1; + unsigned opt_nimages = 500; + unsigned opt_step = 1; + bool opt_click_allowed = true; + 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_ppath,opt_first, opt_nimages, + opt_step, opt_click_allowed, 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() && opt_ppath.empty()) { - if (ipath != env_ipath) { - std::cout << std::endl - << "WARNING: " << std::endl; - std::cout << " Since -i <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + // 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 <visp image path=" << ipath << "> " + << " 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, opt_first, opt_nimages, opt_step); - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Use -i <visp image path> 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 <personal image path> option if you want to "<<std::endl - << " use personal images." << std::endl - << std::endl; - - exit(-1); - } + // Test if an input path is set + if (opt_ipath.empty() && env_ipath.empty() && opt_ppath.empty() ){ + usage(argv[0], NULL, ipath, opt_ppath, opt_first, opt_nimages, opt_step); + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Use -i <visp image path> 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 <personal image path> option if you want to "<<std::endl + << " use personal images." << std::endl + << std::endl; - // 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<unsigned char> I ; + exit(-1); + } - unsigned iter = opt_first; - std::ostringstream s; - char cfilename[FILENAME_MAX]; + // 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<unsigned char> I ; - if (opt_ppath.empty()){ + unsigned iter = opt_first; + std::ostringstream s; + char cfilename[FILENAME_MAX]; + if (opt_ppath.empty()){ - // Warning : - // the image sequence is not provided with the ViSP package - // therefore the program will return you an error : - // !! vpImageIoPnm.cpp: readPGM(#210) :couldn't read file - // ViSP-images/mire-2/image.0001.pgm - // !! vpDotExample.cpp: main(#95) :Error while reading the image - // terminate called after throwing an instance of 'vpImageException' - // - // The sequence is available on the visp www site - // http://www.irisa.fr/lagadic/visp/visp.html - // in the download section. It is named "ViSP-images.tar.gz" - // Set the path location of the image sequence - dirname = ipath + vpIoTools::path("/ViSP-images/mire-2/"); + // Warning : + // the image sequence is not provided with the ViSP package + // therefore the program will return you an error : + // !! vpImageIoPnm.cpp: readPGM(#210) :couldn't read file + // ViSP-images/mire-2/image.0001.pgm + // !! vpDotExample.cpp: main(#95) :Error while reading the image + // terminate called after throwing an instance of 'vpImageException' + // + // The sequence is available on the visp www site + // http://www.irisa.fr/lagadic/visp/visp.html + // in the download section. It is named "ViSP-images.tar.gz" - // Build the name of the image file + // Set the path location of the image sequence + dirname = ipath + vpIoTools::path("/ViSP-images/mire-2/"); - s.setf(std::ios::right, std::ios::adjustfield); - s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; - filename = dirname + s.str(); - } - else { + // Build the name of the image file - sprintf(cfilename,opt_ppath.c_str(), iter) ; - filename = cfilename; - } + s.setf(std::ios::right, std::ios::adjustfield); + s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; + filename = dirname + s.str(); + } + else { - // 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; + sprintf(cfilename,opt_ppath.c_str(), iter) ; + filename = cfilename; + } - vpImageIo::read(I, filename) ; - } - catch(...) - { - // an exception is throwned if an exception from readPGM has been catched - // 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); - } + // 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; - // We open a window using either X11, GTK or GDI. + vpImageIo::read(I, filename) ; + } + catch(...) + { + // an exception is throwned if an exception from readPGM has been catched + // 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); + } + + // We open a window using either X11, GTK or GDI. #if defined VISP_HAVE_X11 - vpDisplayX display; + vpDisplayX display; #elif defined VISP_HAVE_GTK - vpDisplayGTK display; + vpDisplayGTK display; #elif defined VISP_HAVE_GDI - vpDisplayGDI display; + vpDisplayGDI display; #endif - if (opt_display) { - try{ + if (opt_display) { // Display size is automatically defined by the image (I) size display.init(I, 100, 100,"Display...") ; // Display the image @@ -347,30 +351,23 @@ main(int argc, const char ** argv) vpDisplay::display(I) ; vpDisplay::flush(I) ; } - catch(...) - { - vpERROR_TRACE("Error while displaying the image") ; - exit(-1); - } - } - // by using setGraphics, we request to see the all the pixel of the dot - vpDot d ; - if (opt_display) { // by using setGraphics, we request to see the all the pixel of the dot - // in green on the screen. - // It uses the overlay image plane. - // The default of this setting is that it is time consumming - d.setGraphics(true) ; - } - else { - d.setGraphics(false) ; - } - // we also request to compute the dot moment m00, m10, m01, m11, m20, m02 - d.setComputeMoments(true); - d.setConnexity(vpDot::CONNEXITY_8); + vpDot d ; + if (opt_display) { + // by using setGraphics, we request to see the all the pixel of the dot + // in green on the screen. + // It uses the overlay image plane. + // The default of this setting is that it is time consumming + d.setGraphics(true) ; + } + else { + d.setGraphics(false) ; + } + // we also request to compute the dot moment m00, m10, m01, m11, m20, m02 + d.setComputeMoments(true); + d.setConnexity(vpDot::CONNEXITY_8); - try { if (opt_display && opt_click_allowed) { // tracking is initalized // if no other parameters are given to the iniTracking(..) method @@ -384,17 +381,12 @@ main(int argc, const char ** argv) // image point from which the dot is searched vpImagePoint ip; ip.set_u( 160 ); - ip.set_v( 212 ); + ip.set_v( 212 ); d.initTracking(I, ip) ; } - } - catch(...) - { - vpERROR_TRACE("Cannot initialise the tracking... ") ; - exit(-1); - } - try { + + vpImagePoint cog; while (iter < opt_first + opt_nimages*opt_step) { // set the new image name @@ -458,17 +450,18 @@ main(int argc, const char ** argv) } iter ++; } - } - catch (...) { - std::cerr << "Error during the tracking..." << std::endl; - std::cerr << "The progam was stopped." << std::endl; - exit(-1); - } - if (opt_display && opt_click_allowed) { - std::cout << "\nA click to exit..." << std::endl; - // Wait for a blocking mouse click - vpDisplay::getClick(I) ; + + if (opt_display && opt_click_allowed) { + std::cout << "\nA click to exit..." << std::endl; + // Wait for a blocking mouse click + vpDisplay::getClick(I) ; + } + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } } #else diff --git a/example/tracking/trackDot2.cpp b/example/tracking/trackDot2.cpp index 3836da96c424b6acbb5e14b1528070584b71cd80..9c170a85bae41749a946dcab07bf60163fe3d036 100644 --- a/example/tracking/trackDot2.cpp +++ b/example/tracking/trackDot2.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: trackDot2.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: trackDot2.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -70,6 +70,10 @@ //int gsl_warnings_off; +void usage(const char *name, const char *badparam, std::string ipath, std::string ppath, + unsigned first, unsigned nimages, unsigned step); +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &ppath, unsigned &first, + unsigned &nimages, unsigned &step, bool &click_allowed, bool &display); /*! \example trackDot2.cpp Example of dot tracking on an image sequence using vpDot2. @@ -90,7 +94,7 @@ Print the program options. */ void usage(const char *name, const char *badparam, std::string ipath, std::string ppath, - unsigned first, unsigned nimages, unsigned step) + unsigned first, unsigned nimages, unsigned step) { fprintf(stdout, "\n\ Test dot tracking using vpDot2 class.\n\ @@ -162,27 +166,26 @@ OPTIONS: Default\n\ \return false if the program has to be stopped, true otherwise. */ -bool getOptions(int argc, const char **argv, std::string &ipath, std::string &ppath, - unsigned &first, unsigned &nimages, unsigned &step, - bool &click_allowed, bool &display) +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &ppath, unsigned &first, + unsigned &nimages, unsigned &step, bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; case 'd': display = false; break; - case 'i': ipath = optarg; break; - case 'p': ppath = optarg; break; - case 'f': first = (unsigned) atoi(optarg); break; - case 'n': nimages = (unsigned) atoi(optarg); break; - case 's': step = (unsigned) atoi(optarg); break; + case 'i': ipath = optarg_; break; + case 'p': ppath = optarg_; break; + case 'f': first = (unsigned) atoi(optarg_); break; + case 'n': nimages = (unsigned) atoi(optarg_); break; + case 's': step = (unsigned) atoi(optarg_); break; case 'h': usage(argv[0], NULL, ipath, ppath, first, nimages, step); return false; break; default: - usage(argv[0], optarg, ipath, ppath, first, nimages, step); + usage(argv[0], optarg_, ipath, ppath, first, nimages, step); return false; break; } } @@ -191,7 +194,7 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &pp // standalone param or error usage(argv[0], NULL, ipath, ppath, first, nimages, step); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -201,142 +204,142 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &pp 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; - unsigned opt_first = 1; - unsigned opt_nimages = 500; - unsigned opt_step = 1; - bool opt_click_allowed = true; - 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_ppath,opt_first, opt_nimages, - opt_step, opt_click_allowed, opt_display) == false) { - exit (-1); - } + try { + std::string env_ipath; + std::string opt_ipath; + std::string ipath; + std::string opt_ppath; + std::string dirname; + std::string filename; + unsigned opt_first = 1; + unsigned opt_nimages = 500; + unsigned opt_step = 1; + bool opt_click_allowed = true; + 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_ppath,opt_first, opt_nimages, + opt_step, opt_click_allowed, 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() && opt_ppath.empty()) { - if (ipath != env_ipath) { - std::cout << std::endl - << "WARNING: " << std::endl; - std::cout << " Since -i <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + // 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 <visp image path=" << ipath << "> " + << " 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, opt_first, opt_nimages, opt_step); - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Use -i <visp image path> 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 <personal image path> option if you want to "<<std::endl - << " use personal images." << std::endl - << std::endl; - - exit(-1); - } + // Test if an input path is set + if (opt_ipath.empty() && env_ipath.empty() && opt_ppath.empty() ){ + usage(argv[0], NULL, ipath, opt_ppath, opt_first, opt_nimages, opt_step); + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Use -i <visp image path> 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 <personal image path> option if you want to "<<std::endl + << " use personal images." << std::endl + << std::endl; - // 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<unsigned char> I ; + exit(-1); + } - unsigned iter = opt_first; - std::ostringstream s; - char cfilename[FILENAME_MAX]; + // 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<unsigned char> I ; - if (opt_ppath.empty()){ + unsigned iter = opt_first; + std::ostringstream s; + char cfilename[FILENAME_MAX]; + if (opt_ppath.empty()){ - // Warning : - // the image sequence is not provided with the ViSP package - // therefore the program will return you an error : - // !! vpImageIoPnm.cpp: readPGM(#210) :couldn't read file - // ViSP-images/mire-2/image.0001.pgm - // !! vpDotExample.cpp: main(#95) :Error while reading the image - // terminate called after throwing an instance of 'vpImageException' - // - // The sequence is available on the visp www site - // http://www.irisa.fr/lagadic/visp/visp.html - // in the download section. It is named "ViSP-images.tar.gz" - // Set the path location of the image sequence - dirname = ipath + vpIoTools::path("/ViSP-images/mire-2/"); + // Warning : + // the image sequence is not provided with the ViSP package + // therefore the program will return you an error : + // !! vpImageIoPnm.cpp: readPGM(#210) :couldn't read file + // ViSP-images/mire-2/image.0001.pgm + // !! vpDotExample.cpp: main(#95) :Error while reading the image + // terminate called after throwing an instance of 'vpImageException' + // + // The sequence is available on the visp www site + // http://www.irisa.fr/lagadic/visp/visp.html + // in the download section. It is named "ViSP-images.tar.gz" - // Build the name of the image file + // Set the path location of the image sequence + dirname = ipath + vpIoTools::path("/ViSP-images/mire-2/"); - s.setf(std::ios::right, std::ios::adjustfield); - s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; - filename = dirname + s.str(); - } - else { + // Build the name of the image file - sprintf(cfilename,opt_ppath.c_str(), iter) ; - filename = cfilename; - } + s.setf(std::ios::right, std::ios::adjustfield); + s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; + filename = dirname + s.str(); + } + else { - // 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; + sprintf(cfilename,opt_ppath.c_str(), iter) ; + filename = cfilename; + } - vpImageIo::read(I, filename) ; - } - catch(...) - { - // an exception is throwned if an exception from readPGM has been catched - // 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); - } + // 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; + + vpImageIo::read(I, filename) ; + } + catch(...) + { + // an exception is throwned if an exception from readPGM has been catched + // 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); + } - // We open a window using either X11, GTK or GDI. + // We open a window using either X11, GTK or GDI. #if defined VISP_HAVE_X11 - vpDisplayX display; + vpDisplayX display; #elif defined VISP_HAVE_GTK - vpDisplayGTK display; + vpDisplayGTK display; #elif defined VISP_HAVE_GDI - vpDisplayGDI display; + vpDisplayGDI display; #endif - if (opt_display) { - try{ + if (opt_display) { // Display size is automatically defined by the image (I) size display.init(I, 100, 100,"Display...") ; // Display the image @@ -347,52 +350,40 @@ main(int argc, const char ** argv) vpDisplay::display(I) ; vpDisplay::flush(I) ; } - catch(...) - { - // an exception is throwned if an exception from readPGM has been catched - // 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 + // define the vpDot structure. - vpERROR_TRACE("Error while displaying the image") ; - exit(-1); - } - } - // define the vpDot structure. + // vpDot and vpDot2 correspond to two different algorithms designed to track + // a dot. vpDot is based on recurse connex componants (all the pixels of the + // dot are parsed), while vpDot2 is based on freeman chain code (only the + // contour of the dot is parsed) - // vpDot and vpDot2 correspond to two different algorithms designed to track - // a dot. vpDot is based on recurse connex componants (all the pixels of the - // dot are parsed), while vpDot2 is based on freeman chain code (only the - // contour of the dot is parsed) + vpDot2 d ; + vpImagePoint cog; - vpDot2 d ; - vpImagePoint cog; + if (opt_display) { + // by using setGraphics, we request to see the all the pixel of the dot + // in green on the screen. + // It uses the overlay image plane. + // The default of this setting is that it is time consumming - if (opt_display) { - // by using setGraphics, we request to see the all the pixel of the dot - // in green on the screen. - // It uses the overlay image plane. - // The default of this setting is that it is time consumming + d.setGraphics(true) ; + } + else { - d.setGraphics(true) ; - } - else { + d.setGraphics(false) ; + } + // We want to track an ellipsoid shape. If you want to track a non ellipsoid + // object, use d.setEllipsoidShape(0); + // we also request to compute the dot moment m00, m10, m01, m11, m20, m02 + d.setComputeMoments(true); + d.setGrayLevelPrecision(0.90); + + // tracking is initalized if no other parameters are given to the + // iniTracking(..) method a right mouse click on the dot is expected + // dot location can also be specified explicitely in the + // initTracking method : d.initTracking(I,ip) where ip is the image + // point from which the dot is searched - d.setGraphics(false) ; - } - // We want to track an ellipsoid shape. If you want to track a non ellipsoid - // object, use d.setEllipsoidShape(0); - // we also request to compute the dot moment m00, m10, m01, m11, m20, m02 - d.setComputeMoments(true); - d.setGrayLevelPrecision(0.90); - - // tracking is initalized if no other parameters are given to the - // iniTracking(..) method a right mouse click on the dot is expected - // dot location can also be specified explicitely in the - // initTracking method : d.initTracking(I,ip) where ip is the image - // point from which the dot is searched - - try{ if (opt_display && opt_click_allowed) { std::cout << "Click on a dot to track it."<< std::endl; d.initTracking(I) ; @@ -411,7 +402,7 @@ main(int argc, const char ** argv) << d.m10 / d.m00 << " " << d.m01 / d.m00 << std::endl; std::cout << "Size:" << std::endl; std::cout << " w: " << d.getWidth() << " h: " << d.getHeight() << std::endl; - std::cout << "Surface: " << d.getSurface() << std::endl; + std::cout << "Area: " << d.getArea() << std::endl; std::cout << "Moments:" << std::endl; std::cout << " m00: " << d.m00 << std::endl; std::cout << " m10: " << d.m10 << std::endl; @@ -429,14 +420,7 @@ main(int argc, const char ** argv) std::cout << " size precision: " << d.getSizePrecision() << std::endl; std::cout << " gray level precision: " << d.getGrayLevelPrecision() << std::endl; } - } - catch(...) - { - vpERROR_TRACE("Cannot initialise the tracking... ") ; - exit(-1); - } - try { while (iter < opt_first + opt_nimages*opt_step) { // set the new image name if (opt_ppath.empty()){ @@ -475,7 +459,7 @@ main(int argc, const char ** argv) << d.m10 / d.m00 << " " << d.m01 / d.m00 << std::endl; std::cout << "Size:" << std::endl; std::cout << " w: " << d.getWidth() << " h: " << d.getHeight() << std::endl; - std::cout << "Surface: " << d.getSurface() << std::endl; + std::cout << "Area: " << d.getArea() << std::endl; std::cout << "Moments:" << std::endl; std::cout << " m00: " << d.m00 << std::endl; std::cout << " m10: " << d.m10 << std::endl; @@ -513,16 +497,17 @@ main(int argc, const char ** argv) } iter ++; } + + if (opt_display && opt_click_allowed) { + std::cout << "\nA click to exit..." << std::endl; + // Wait for a blocking mouse click + vpDisplay::getClick(I) ; + } + return 0; } - catch (...) { - std::cerr << "Error during the tracking..." << std::endl; - std::cerr << "The progam was stopped." << std::endl; - exit(-1); - } - if (opt_display && opt_click_allowed) { - std::cout << "\nA click to exit..." << std::endl; - // Wait for a blocking mouse click - vpDisplay::getClick(I) ; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } } #else diff --git a/example/tracking/trackDot2WithAutoDetection.cpp b/example/tracking/trackDot2WithAutoDetection.cpp index bd497b2155255addcb922d4c0cb330b63bc12eb6..033cbbabc04afc446bbc1a3125441afffcbb1e62 100644 --- a/example/tracking/trackDot2WithAutoDetection.cpp +++ b/example/tracking/trackDot2WithAutoDetection.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: trackDot2WithAutoDetection.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: trackDot2WithAutoDetection.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -74,6 +74,14 @@ // List of allowed command line options #define GETOPTARGS "cdi:p:f:n:s:S:G:E:h" +void usage(const char *name, const char *badparam, std::string ipath, std::string ppath, + unsigned first, unsigned nimages, unsigned step, double sizePrecision, + double grayLevelPrecision, double ellipsoidShapePrecision ); +bool getOptions(int argc, const char **argv, std::string &ipath, + std::string &ppath,unsigned &first, unsigned &nimages, + unsigned &step, double &sizePrecision, double &grayLevelPrecision, + double &ellipsoidShapePrecision, bool &click_allowed, bool &display); + /*! Print the program options. @@ -93,7 +101,7 @@ */ void usage(const char *name, const char *badparam, std::string ipath, std::string ppath, unsigned first, unsigned nimages, unsigned step, double sizePrecision, - double grayLevelPrecision, double ellipsoidShapePrecision ) + double grayLevelPrecision, double ellipsoidShapePrecision) { fprintf(stdout, "\n\ Test auto detection of dots using vpDot2.\n\ @@ -196,27 +204,27 @@ bool getOptions(int argc, const char **argv, std::string &ipath, unsigned &step, double &sizePrecision, double &grayLevelPrecision, double &ellipsoidShapePrecision, bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; case 'd': display = false; break; - case 'i': ipath = optarg; break; - case 'p': ppath = optarg; break; - case 'f': first = (unsigned) atoi(optarg); break; - case 'n': nimages = (unsigned) atoi(optarg); break; - case 's': step = (unsigned) atoi(optarg); break; - case 'S': sizePrecision = atof(optarg);break; - case 'G': grayLevelPrecision = atof(optarg);break; - case 'E': ellipsoidShapePrecision = atof(optarg);break; + case 'i': ipath = optarg_; break; + case 'p': ppath = optarg_; break; + case 'f': first = (unsigned) atoi(optarg_); break; + case 'n': nimages = (unsigned) atoi(optarg_); break; + case 's': step = (unsigned) atoi(optarg_); break; + case 'S': sizePrecision = atof(optarg_);break; + case 'G': grayLevelPrecision = atof(optarg_);break; + case 'E': ellipsoidShapePrecision = atof(optarg_);break; case 'h': usage(argv[0], NULL, ipath, ppath, first, nimages, step, sizePrecision,grayLevelPrecision,ellipsoidShapePrecision); return false; break; default: - usage(argv[0], optarg, ipath, ppath, first, nimages, step, + usage(argv[0], optarg_, ipath, ppath, first, nimages, step, sizePrecision,grayLevelPrecision,ellipsoidShapePrecision); return false; break; } @@ -227,7 +235,7 @@ bool getOptions(int argc, const char **argv, std::string &ipath, usage(argv[0], NULL, ipath, ppath, first, nimages, step, sizePrecision,grayLevelPrecision,ellipsoidShapePrecision); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -238,146 +246,146 @@ bool getOptions(int argc, const char **argv, std::string &ipath, 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; - unsigned opt_first = 1; - unsigned opt_nimages = 10; - unsigned opt_step = 1; - double opt_sizePrecision = 0.65; - double opt_grayLevelPrecision = 0.85; - double opt_ellipsoidShapePrecision = 0.8; - bool opt_click_allowed = true; - 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_ppath,opt_first, opt_nimages, - opt_step,opt_sizePrecision,opt_grayLevelPrecision, - opt_ellipsoidShapePrecision, opt_click_allowed, opt_display) == false) { - exit (-1); - } + try { + std::string env_ipath; + std::string opt_ipath; + std::string ipath; + std::string opt_ppath; + std::string dirname; + std::string filename; + unsigned opt_first = 1; + unsigned opt_nimages = 10; + unsigned opt_step = 1; + double opt_sizePrecision = 0.65; + double opt_grayLevelPrecision = 0.85; + double opt_ellipsoidShapePrecision = 0.8; + bool opt_click_allowed = true; + 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_ppath,opt_first, opt_nimages, + opt_step,opt_sizePrecision,opt_grayLevelPrecision, + opt_ellipsoidShapePrecision, opt_click_allowed, 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() && opt_ppath.empty()) { - if (ipath != env_ipath) { - std::cout << std::endl - << "WARNING: " << std::endl; - std::cout << " Since -i <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + // 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 <visp image path=" << ipath << "> " + << " 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, opt_ppath, opt_first, opt_nimages, + // Test if an input path is set + if (opt_ipath.empty() && env_ipath.empty()){ + usage(argv[0], NULL, ipath, opt_ppath, opt_first, opt_nimages, opt_step,opt_sizePrecision,opt_grayLevelPrecision, opt_ellipsoidShapePrecision); - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Use -i <visp image path> 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 - << " Use -p <personal image path> option if you want to "<<std::endl - << " use personal images." << std::endl; - exit(-1); - } + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Use -i <visp image path> 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 + << " Use -p <personal image path> option if you want to "<<std::endl + << " use personal images." << std::endl; + 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<unsigned char> I ; - std::ostringstream s; - char cfilename[FILENAME_MAX]; - unsigned iter = opt_first; // Image number + // 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<unsigned char> I ; + std::ostringstream s; + char cfilename[FILENAME_MAX]; + unsigned iter = opt_first; // Image number - if (opt_ppath.empty()){ + if (opt_ppath.empty()){ - // Warning : - // the image sequence is not provided with the ViSP package - // therefore the program will return you an error : - // !! vpImageIoPnm.cpp: readPGM(#210) :couldn't read file - // ViSP-images/cube/image.0001.pgm - // !! vpDotExample.cpp: main(#95) :Error while reading the image - // terminate called after throwing an instance of 'vpImageException' - // - // The sequence is available on the visp www site - // http://www.irisa.fr/lagadic/visp/visp.html - // in the download section. It is named "ViSP-images.tar.gz" + // Warning : + // the image sequence is not provided with the ViSP package + // therefore the program will return you an error : + // !! vpImageIoPnm.cpp: readPGM(#210) :couldn't read file + // ViSP-images/cube/image.0001.pgm + // !! vpDotExample.cpp: main(#95) :Error while reading the image + // terminate called after throwing an instance of 'vpImageException' + // + // The sequence is available on the visp www site + // http://www.irisa.fr/lagadic/visp/visp.html + // in the download section. It is named "ViSP-images.tar.gz" - // Set the path location of the image sequence - dirname = ipath + vpIoTools::path("/ViSP-images/mire-2/"); + // Set the path location of the image sequence + dirname = ipath + vpIoTools::path("/ViSP-images/mire-2/"); - // Build the name of the image file + // Build the name of the image file - s.setf(std::ios::right, std::ios::adjustfield); - s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; - filename = dirname + s.str(); - } - else { + s.setf(std::ios::right, std::ios::adjustfield); + s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; + filename = dirname + s.str(); + } + else { - sprintf(cfilename,opt_ppath.c_str(), iter) ; - filename = cfilename; - } - // 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; - - vpImageIo::read(I, filename) ; - } - catch(...) - { - // an exception is throwned if an exception from readPGM has been catched - // 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 your -p " << opt_ppath << " option " <<std::endl - << " or VISP_INPUT_IMAGE_PATH environment variable." - << std::endl; - exit(-1); - } + sprintf(cfilename,opt_ppath.c_str(), iter) ; + filename = cfilename; + } + // 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; + vpImageIo::read(I, filename) ; + } + catch(...) + { + // an exception is throwned if an exception from readPGM has been catched + // 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 your -p " << opt_ppath << " option " <<std::endl + << " or VISP_INPUT_IMAGE_PATH environment variable." + << std::endl; + exit(-1); + } - // We open a window using either GTK, X11 or GDI. + + // We open a window using either GTK, X11 or GDI. #if defined VISP_HAVE_GTK - vpDisplayGTK display; + vpDisplayGTK display; #elif defined VISP_HAVE_X11 - vpDisplayX display; + vpDisplayX display; #elif defined VISP_HAVE_GDI - vpDisplayGDI display; + vpDisplayGDI display; #endif - if (opt_display) { - try{ + if (opt_display) { // Display size is automatically defined by the image (I) size display.init(I, 100, 100,"Display...") ; // Display the image @@ -388,19 +396,12 @@ main(int argc, const char ** argv) vpDisplay::display(I) ; vpDisplay::flush(I) ; } - catch(...) - { - vpERROR_TRACE("Error while displaying the image") ; - exit(-1); - } - } - // Dot declaration - vpDot2 d ; + // Dot declaration + vpDot2 d ; - d.setGraphics(true); - if (opt_click_allowed & opt_display) { - try{ + d.setGraphics(true); + if (opt_click_allowed & opt_display) { d.setGrayLevelPrecision(opt_grayLevelPrecision); std::cout << "Please click on a dot to initialize detection" @@ -418,97 +419,97 @@ main(int argc, const char ** argv) printf("Dot characteristics: \n"); printf(" width : %lf\n", d.getWidth()); printf(" height: %lf\n", d.getHeight()); - printf(" surface: %lf\n", d.getSurface()); + printf(" area: %lf\n", d.getArea()); printf(" gray level min: %d\n", d.getGrayLevelMin()); printf(" gray level max: %d\n", d.getGrayLevelMax()); printf(" grayLevelPrecision: %lf\n", d.getGrayLevelPrecision()); printf(" sizePrecision: %lf\n", d.getSizePrecision()); printf(" ellipsoidShapePrecision: %lf\n", d.getEllipsoidShapePrecision()); } - catch(...) - { - std::cerr << "Cannot initialize the tracking..."<< std::endl; - exit(-1); + else{ + // Set dot characteristics for the auto detection + d.setGraphics(true); + d.setWidth(15.0); + d.setHeight(12.0); + d.setArea(124); + d.setGrayLevelMin(164); + d.setGrayLevelMax(255); + d.setGrayLevelPrecision(opt_grayLevelPrecision); + d.setSizePrecision(opt_sizePrecision); + d.setEllipsoidShapePrecision(opt_ellipsoidShapePrecision); } - } - else{ - // Set dot characteristics for the auto detection - d.setGraphics(true); - d.setWidth(15.0); - d.setHeight(12.0); - d.setSurface(124); - d.setGrayLevelMin(164); - d.setGrayLevelMax(255); - d.setGrayLevelPrecision(opt_grayLevelPrecision); - d.setSizePrecision(opt_sizePrecision); - d.setEllipsoidShapePrecision(opt_ellipsoidShapePrecision); - } - - while (iter < opt_first + opt_nimages*opt_step) - { - - // set the new image name - if (opt_ppath.empty()){ - - s.str(""); - s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; - filename = dirname + s.str(); - } - else { - sprintf(cfilename, opt_ppath.c_str(), iter) ; - filename = cfilename; - } - // read the image - vpImageIo::read(I, filename); + while (iter < opt_first + opt_nimages*opt_step) + { - if (opt_display) { - // Display the image - vpDisplay::display(I) ; - } + // set the new image name - std::cout << "Search dots in image" << filename << std::endl; - std::list<vpDot2> list_d; - d.searchDotsInArea(I, 0, 0, I.getWidth(), I.getHeight(), list_d) ; + if (opt_ppath.empty()){ - if( list_d.empty() ) { - std::cout << "Dot auto detection did not work." << std::endl; - return(-1) ; - } - else { - std::cout << std::endl << list_d.size() << " dots are detected" << std::endl; + s.str(""); + s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; + filename = dirname + s.str(); + } + else { + sprintf(cfilename, opt_ppath.c_str(), iter) ; + filename = cfilename; + } + // read the image + vpImageIo::read(I, filename); if (opt_display) { - int i=0; - // Parse all founded dots for display - for (std::list<vpDot2>::const_iterator it = list_d.begin(); it != list_d.end(); ++ it) - { - vpImagePoint cog = (*it).getCog(); + // Display the image + vpDisplay::display(I) ; + } - std::cout << "Dot " << i++ << " : " << cog.get_u() - << " " << cog.get_v() << std::endl; + std::cout << "Search dots in image" << filename << std::endl; + std::list<vpDot2> list_d; + d.searchDotsInArea(I, 0, 0, I.getWidth(), I.getHeight(), list_d) ; - vpDisplay::displayCross(I, cog, 16, vpColor::blue, 3) ; + if( list_d.empty() ) { + std::cout << "Dot auto detection did not work." << std::endl; + return(-1) ; + } + else { + std::cout << std::endl << list_d.size() << " dots are detected" << std::endl; + + if (opt_display) { + int i=0; + // Parse all founded dots for display + for (std::list<vpDot2>::const_iterator it = list_d.begin(); it != list_d.end(); ++ it) + { + vpImagePoint cog = (*it).getCog(); + + std::cout << "Dot " << i++ << " : " << cog.get_u() + << " " << cog.get_v() << std::endl; + + vpDisplay::displayCross(I, cog, 16, vpColor::blue, 3) ; + } + vpDisplay::flush(I); } - vpDisplay::flush(I); } - } - // If click is allowed, wait for a mouse click to launch the next iteration + // If click is allowed, wait for a mouse click to launch the next iteration + if (opt_display && opt_click_allowed) { + std::cout << "\nA click to continue..." << std::endl; + // Wait for a blocking mouse click + vpDisplay::getClick(I) ; + } + + iter += opt_step ; + } if (opt_display && opt_click_allowed) { - std::cout << "\nA click to continue..." << std::endl; + std::cout << "\nA click to exit..." << std::endl; // Wait for a blocking mouse click vpDisplay::getClick(I) ; } - iter += opt_step ; + return 0; } - if (opt_display && opt_click_allowed) { - std::cout << "\nA click to exit..." << std::endl; - // Wait for a blocking mouse click - vpDisplay::getClick(I) ; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - vpTRACE("End..."); } #else int diff --git a/example/tracking/trackKltOpencv.cpp b/example/tracking/trackKltOpencv.cpp index 0400c59706a815d0a0bee4c09410613702764a2b..849f30f85af3ce762c5a8451c89944e321d1a6cc 100644 --- a/example/tracking/trackKltOpencv.cpp +++ b/example/tracking/trackKltOpencv.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: trackKltOpencv.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: trackKltOpencv.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -69,6 +69,10 @@ // List of allowed command line options #define GETOPTARGS "cdf:i:n:p:s:h" +void usage(const char *name, const char *badparam, std::string ipath, std::string ppath, + unsigned first, unsigned nimages, unsigned step); +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &ppath, unsigned &first, + unsigned &nimages, unsigned &step, bool &click_allowed, bool &display); /*! \example trackKltOpencv.cpp @@ -91,7 +95,7 @@ Print the program options. */ void usage(const char *name, const char *badparam, std::string ipath, std::string ppath, - unsigned first, unsigned nimages, unsigned step) + unsigned first, unsigned nimages, unsigned step) { fprintf(stdout, "\n\ Example of KLT tracking using OpenCV library.\n\ @@ -163,27 +167,26 @@ OPTIONS: Default\n\ \return false if the program has to be stopped, true otherwise. */ -bool getOptions(int argc, const char **argv, std::string &ipath, std::string &ppath, - unsigned &first, unsigned &nimages, unsigned &step, - bool &click_allowed, bool &display) +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &ppath, unsigned &first, + unsigned &nimages, unsigned &step, bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; case 'd': display = false; break; - case 'i': ipath = optarg; break; - case 'p': ppath = optarg; break; - case 'f': first = (unsigned) atoi(optarg); break; - case 'n': nimages = (unsigned) atoi(optarg); break; - case 's': step = (unsigned) atoi(optarg); break; + case 'i': ipath = optarg_; break; + case 'p': ppath = optarg_; break; + case 'f': first = (unsigned) atoi(optarg_); break; + case 'n': nimages = (unsigned) atoi(optarg_); break; + case 's': step = (unsigned) atoi(optarg_); break; case 'h': usage(argv[0], NULL, ipath, ppath, first, nimages, step); return false; break; default: - usage(argv[0], optarg, ipath, ppath, first, nimages, step); + usage(argv[0], optarg_, ipath, ppath, first, nimages, step); return false; break; } } @@ -192,7 +195,7 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &pp // standalone param or error usage(argv[0], NULL, ipath, ppath, first, nimages, step); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -202,149 +205,149 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &pp 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; - unsigned opt_first = 1; - unsigned opt_nimages = 500; - unsigned opt_step = 1; - bool opt_click_allowed = true; - 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_ppath,opt_first, opt_nimages, - opt_step, opt_click_allowed, opt_display) == false) { - exit (-1); - } + try { + std::string env_ipath; + std::string opt_ipath; + std::string ipath; + std::string opt_ppath; + std::string dirname; + std::string filename; + unsigned opt_first = 1; + unsigned opt_nimages = 500; + unsigned opt_step = 1; + bool opt_click_allowed = true; + 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_ppath,opt_first, opt_nimages, + opt_step, opt_click_allowed, 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() && opt_ppath.empty()) { - if (ipath != env_ipath) { - std::cout << std::endl - << "WARNING: " << std::endl; - std::cout << " Since -i <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + // 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 <visp image path=" << ipath << "> " + << " 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, opt_first, opt_nimages, opt_step); - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Use -i <visp image path> 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 <personal image path> option if you want to "<<std::endl - << " use personal images." << std::endl - << std::endl; - - exit(-1); - } + // Test if an input path is set + if (opt_ipath.empty() && env_ipath.empty() && opt_ppath.empty() ){ + usage(argv[0], NULL, ipath, opt_ppath, opt_first, opt_nimages, opt_step); + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Use -i <visp image path> 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 <personal image path> option if you want to "<<std::endl + << " use personal images." << std::endl + << std::endl; - // 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<unsigned char> vpI ; // This is a ViSP image used for display only - IplImage * cvI; // This is an OpenCV IPL image used by the tracker + exit(-1); + } - unsigned iter = opt_first; - std::ostringstream s; - char cfilename[FILENAME_MAX]; + // 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<unsigned char> vpI ; // This is a ViSP image used for display only + IplImage * cvI; // This is an OpenCV IPL image used by the tracker - if (opt_ppath.empty()){ + unsigned iter = opt_first; + std::ostringstream s; + char cfilename[FILENAME_MAX]; + if (opt_ppath.empty()){ - // Warning : - // the image sequence is not provided with the ViSP package - // therefore the program will return you an error : - // !! vpImageIoPnm.cpp: readPGM(#210) :couldn't read file - // ViSP-images/mire-2/image.0001.pgm - // !! vpDotExample.cpp: main(#95) :Error while reading the image - // terminate called after throwing an instance of 'vpImageException' - // - // The sequence is available on the visp www site - // http://www.irisa.fr/lagadic/visp/visp.html - // in the download section. It is named "ViSP-images.tar.gz" - // Set the path location of the image sequence - dirname = ipath + vpIoTools::path("/ViSP-images/mire-2/"); + // Warning : + // the image sequence is not provided with the ViSP package + // therefore the program will return you an error : + // !! vpImageIoPnm.cpp: readPGM(#210) :couldn't read file + // ViSP-images/mire-2/image.0001.pgm + // !! vpDotExample.cpp: main(#95) :Error while reading the image + // terminate called after throwing an instance of 'vpImageException' + // + // The sequence is available on the visp www site + // http://www.irisa.fr/lagadic/visp/visp.html + // in the download section. It is named "ViSP-images.tar.gz" - // Build the name of the image file + // Set the path location of the image sequence + dirname = ipath + vpIoTools::path("/ViSP-images/mire-2/"); - s.setf(std::ios::right, std::ios::adjustfield); - s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; - filename = dirname + s.str(); - } - else { + // Build the name of the image file - sprintf(cfilename,opt_ppath.c_str(), iter) ; - filename = cfilename; - } + s.setf(std::ios::right, std::ios::adjustfield); + s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; + filename = dirname + s.str(); + } + else { - // 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; - - // Load a ViSP image used for the display - vpImageIo::read(vpI, filename) ; - // Load an OpenCV IPL image used by the tracker - if((cvI = cvLoadImage(filename.c_str(), CV_LOAD_IMAGE_GRAYSCALE))== NULL) { - printf("Cannot read image: %s\n", filename.c_str()); - return (0); + sprintf(cfilename,opt_ppath.c_str(), iter) ; + filename = cfilename; } - } - catch(...) - { - // an exception is throwned if an exception from readPGM has been catched - // 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); - } - // We open a window using either X11, GTK or GDI. + // 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; + + // Load a ViSP image used for the display + vpImageIo::read(vpI, filename) ; + // Load an OpenCV IPL image used by the tracker + if((cvI = cvLoadImage(filename.c_str(), CV_LOAD_IMAGE_GRAYSCALE))== NULL) { + printf("Cannot read image: %s\n", filename.c_str()); + return (0); + } + } + catch(...) + { + // an exception is throwned if an exception from readPGM has been catched + // 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); + } + + // We open a window using either X11, GTK or GDI. #if defined VISP_HAVE_X11 - vpDisplayX display; + vpDisplayX display; #elif defined VISP_HAVE_GTK - vpDisplayGTK display; + vpDisplayGTK display; #elif defined VISP_HAVE_GDI - vpDisplayGDI display; + vpDisplayGDI display; #endif - if (opt_display) { - try{ + if (opt_display) { // Display size is automatically defined by the image (I) size display.init(vpI, 100, 100,"Display...") ; // Display the image @@ -355,49 +358,36 @@ main(int argc, const char ** argv) vpDisplay::display(vpI) ; vpDisplay::flush(vpI) ; } - catch(...) - { - // an exception is throwned if an exception from readPGM has been catched - // 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 - vpERROR_TRACE("Error while displaying the image") ; - exit(-1); + // KLT tracker + vpKltOpencv tracker; + + // Event manager + //tracker.setOnNewFeature(&newFeature); + //tracker.setOnFeatureLost(&lostFeature); + //tracker.setIsFeatureValid(&isValid); + + // Tracker parameters + tracker.setTrackerId(1); + //tracker.setOnMeasureFeature(&modifyFeature); + tracker.setMaxFeatures(200); + tracker.setWindowSize(10); + tracker.setQuality(0.01); + tracker.setMinDistance(15); + tracker.setHarrisFreeParameter(0.04); + tracker.setBlockSize(9); + tracker.setUseHarris(1); + tracker.setPyramidLevels(3); + + // Point detection using Harris. In input we have an OpenCV IPL image + tracker.initTracking(cvI); + + if (opt_display) { + // Plot the Harris points on ViSP image + tracker.display(vpI, vpColor::red); } - } - - // KLT tracker - vpKltOpencv tracker; - - // Event manager - //tracker.setOnNewFeature(&newFeature); - //tracker.setOnFeatureLost(&lostFeature); - //tracker.setIsFeatureValid(&isValid); - - // Tracker parameters - tracker.setTrackerId(1); - //tracker.setOnMeasureFeature(&modifyFeature); - tracker.setMaxFeatures(200); - tracker.setWindowSize(10); - tracker.setQuality(0.01); - tracker.setMinDistance(15); - tracker.setHarrisFreeParameter(0.04); - tracker.setBlockSize(9); - tracker.setUseHarris(1); - tracker.setPyramidLevels(3); - - // Point detection using Harris. In input we have an OpenCV IPL image - tracker.initTracking(cvI); - - if (opt_display) { - // Plot the Harris points on ViSP image - tracker.display(vpI, vpColor::red); - } - - // tracking is now initialized. We can start the tracker. - try { + // tracking is now initialized. We can start the tracker. while (iter < opt_first + opt_nimages*opt_step) { // set the new image name if (opt_ppath.empty()){ @@ -446,16 +436,16 @@ main(int argc, const char ** argv) } iter += opt_step; } + if (opt_display && opt_click_allowed) { + std::cout << "\nA click to exit..." << std::endl; + // Wait for a blocking mouse click + vpDisplay::getClick(vpI) ; + } + return 0; } - catch (...) { - std::cerr << "Error during the tracking..." << std::endl; - std::cerr << "The progam was stopped." << std::endl; - exit(-1); - } - if (opt_display && opt_click_allowed) { - std::cout << "\nA click to exit..." << std::endl; - // Wait for a blocking mouse click - vpDisplay::getClick(vpI) ; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } } #else diff --git a/example/tracking/trackMeCircle.cpp b/example/tracking/trackMeCircle.cpp index 09d182e92e6d08679f9a9c899451db888bc48a17..b820333a94ba87af41cf597134aad3febf1a4643 100644 --- a/example/tracking/trackMeCircle.cpp +++ b/example/tracking/trackMeCircle.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: trackMeCircle.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: trackMeCircle.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -75,6 +75,9 @@ // List of allowed command line options #define GETOPTARGS "cdi:h" +void usage(const char *name, const char *badparam, std::string ipath); +bool getOptions(int argc, const char **argv, std::string &ipath, bool &click_allowed, bool &display); + /*! Print the program options. @@ -129,21 +132,20 @@ OPTIONS: Default\n\ \return false if the program has to be stopped, true otherwise. */ -bool getOptions(int argc, const char **argv, std::string &ipath, - bool &click_allowed, bool &display) +bool getOptions(int argc, const char **argv, std::string &ipath, bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; case 'd': display = false; break; - case 'i': ipath = optarg; break; + case 'i': ipath = optarg_; break; case 'h': usage(argv[0], NULL, ipath); return false; break; default: - usage(argv[0], optarg, ipath); + usage(argv[0], optarg_, ipath); return false; break; } } @@ -152,7 +154,7 @@ bool getOptions(int argc, const char **argv, std::string &ipath, // standalone param or error usage(argv[0], NULL, ipath); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -163,108 +165,108 @@ bool getOptions(int argc, const char **argv, std::string &ipath, int main(int argc, const char ** argv) { - std::string env_ipath; - std::string opt_ipath; - std::string ipath; - std::string dirname; - std::string filename; - bool opt_click_allowed = true; - 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_click_allowed, - opt_display) == false) { - exit (-1); - } + try { + std::string env_ipath; + std::string opt_ipath; + std::string ipath; + std::string dirname; + std::string filename; + bool opt_click_allowed = true; + 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_click_allowed, + 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 <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + // 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 <visp image path=" << ipath << "> " + << " 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 <visp image path> 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); - } + // 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 <visp image path> 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); + } - // 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<unsigned char> I ; + // 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<unsigned char> I ; - // Set the path location of the image sequence - dirname = ipath + vpIoTools::path("/ViSP-images/circle/"); + // Set the path location of the image sequence + dirname = ipath + vpIoTools::path("/ViSP-images/circle/"); - // Build the name of the image file - filename = dirname + "circle.pgm"; + // Build the name of the image file + filename = dirname + "circle.pgm"; - // 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; + // 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; - vpImageIo::read(I, filename) ; - } - catch(...) - { - // an exception is throwned if an exception from readPGM has been catched - // 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); - } + vpImageIo::read(I, filename) ; + } + catch(...) + { + // an exception is throwned if an exception from readPGM has been catched + // 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); + } - // We open a window using either X11, GTK or GDI. + // We open a window using either X11, GTK or GDI. #if defined VISP_HAVE_X11 - vpDisplayX display; + vpDisplayX display; #elif defined VISP_HAVE_GTK - vpDisplayGTK display; + vpDisplayGTK display; #elif defined VISP_HAVE_GDI - vpDisplayGDI display; + vpDisplayGDI display; #endif - if (opt_display) { - try{ + if (opt_display) { // Display size is automatically defined by the image (I) size display.init(I, 100, 100,"Display...") ; // Display the image @@ -275,61 +277,60 @@ main(int argc, const char ** argv) vpDisplay::display(I) ; vpDisplay::flush(I) ; } - catch(...) - { - vpERROR_TRACE("Error while displaying the image") ; - exit(-1); - } - } - vpMeEllipse E1 ; + vpMeEllipse E1 ; - vpMe me ; - me.setRange(20) ; - me.setSampleStep(2) ; - me.setPointsToTrack(60) ; - me.setThreshold(15000) ; + vpMe me ; + me.setRange(20) ; + me.setSampleStep(2) ; + me.setPointsToTrack(60) ; + me.setThreshold(15000) ; - E1.setCircle(true) ; - E1.setMe(&me) ; - E1.setDisplay(vpMeSite::RANGE_RESULT) ; - // If click is allowed, wait for a mouse click to select the points - // on the ellipse - if (opt_display && opt_click_allowed) { - E1.initTracking(I) ; - } - else { - // Create a list of points to automate the test - unsigned int n=5 ; - vpImagePoint *ip = new vpImagePoint [n]; - ip[0].set_i( 39 ); ip[0].set_j( 136 ); - ip[1].set_i( 42 ); ip[1].set_j( 83 ); - ip[2].set_i( 86 ); ip[2].set_j( 55 ); - ip[3].set_i( 132 ); ip[3].set_j( 72 ); - ip[4].set_i( 145 ); ip[4].set_j( 134 ); - E1.initTracking(I, n, ip) ; - delete [] ip ; - } + E1.setCircle(true) ; + E1.setMe(&me) ; + E1.setDisplay(vpMeSite::RANGE_RESULT) ; + // If click is allowed, wait for a mouse click to select the points + // on the ellipse + if (opt_display && opt_click_allowed) { + E1.initTracking(I) ; + } + else { + // Create a list of points to automate the test + unsigned int n=5 ; + vpImagePoint *ip = new vpImagePoint [n]; + ip[0].set_i( 39 ); ip[0].set_j( 136 ); + ip[1].set_i( 42 ); ip[1].set_j( 83 ); + ip[2].set_i( 86 ); ip[2].set_j( 55 ); + ip[3].set_i( 132 ); ip[3].set_j( 72 ); + ip[4].set_i( 145 ); ip[4].set_j( 134 ); + E1.initTracking(I, n, ip) ; + delete [] ip ; + } - if (opt_display) { - E1.display(I, vpColor::green) ; - vpDisplay::flush(I); - } + if (opt_display) { + E1.display(I, vpColor::green) ; + vpDisplay::flush(I); + } - vpTRACE("sample step %f ",E1.getMe()->getSampleStep()) ; - std::cout << "Tracking on image: " << filename << std::endl; - E1.track(I) ; - if (opt_display) { - vpDisplay::flush(I); - } + vpTRACE("sample step %f ",E1.getMe()->getSampleStep()) ; + std::cout << "Tracking on image: " << filename << std::endl; + E1.track(I) ; + if (opt_display) { + vpDisplay::flush(I); + } - if (opt_display && opt_click_allowed) { - std::cout << "A click to exit..." << std::endl; - vpDisplay::getClick(I) ; + if (opt_display && opt_click_allowed) { + std::cout << "A click to exit..." << std::endl; + vpDisplay::getClick(I) ; + } + std::cout <<"------------------------------------------------------------"<<std::endl; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - std::cout <<"------------------------------------------------------------"<<std::endl; - } #else int diff --git a/example/tracking/trackMeEllipse.cpp b/example/tracking/trackMeEllipse.cpp index 317fb87ed9ba0a1aee4dd3a65d721cbd72752ae8..6b0397f87a328a5b122a30942f37f714e139a37a 100644 --- a/example/tracking/trackMeEllipse.cpp +++ b/example/tracking/trackMeEllipse.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: trackMeEllipse.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: trackMeEllipse.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -77,6 +77,9 @@ // List of allowed command line options #define GETOPTARGS "cdi:h" +void usage(const char *name, const char *badparam, std::string ipath); +bool getOptions(int argc, const char **argv, std::string &ipath, bool &click_allowed, bool &display); + /*! Print the program options. @@ -133,18 +136,18 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv, std::string &ipath, bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; case 'd': display = false; break; - case 'i': ipath = optarg; break; + case 'i': ipath = optarg_; break; case 'h': usage(argv[0], NULL, ipath); return false; break; default: - usage(argv[0], optarg, ipath); + usage(argv[0], optarg_, ipath); return false; break; } } @@ -153,7 +156,7 @@ bool getOptions(int argc, const char **argv, std::string &ipath, bool &click_all // standalone param or error usage(argv[0], NULL, ipath); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -164,110 +167,110 @@ bool getOptions(int argc, const char **argv, std::string &ipath, bool &click_all int main(int argc, const char ** argv) { - std::string env_ipath; - std::string opt_ipath; - std::string ipath; - std::string dirname; - std::string filename; - bool opt_click_allowed = true; - 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_click_allowed, opt_display) == false) { - exit (-1); - } + try { + std::string env_ipath; + std::string opt_ipath; + std::string ipath; + std::string dirname; + std::string filename; + bool opt_click_allowed = true; + 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_click_allowed, 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 <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + // 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 <visp image path=" << ipath << "> " + << " 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 <visp image path> 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); - } + // 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 <visp image path> 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); + } - // Declare an image, this is a gray level image (unsigned char) - // it size is not defined yet, it will be defined when the image is - // read on the disk - vpImage<unsigned char> I ; + // Declare an image, this is a gray level image (unsigned char) + // it size is not defined yet, it will be defined when the image is + // read on the disk + vpImage<unsigned char> I ; - // Set the path location of the image sequence - dirname = ipath + vpIoTools::path("/ViSP-images/ellipse-1/"); + // Set the path location of the image sequence + dirname = ipath + vpIoTools::path("/ViSP-images/ellipse-1/"); - // Build the name of the image file - unsigned iter = 1; // Image number - std::ostringstream s; - s.setf(std::ios::right, std::ios::adjustfield); - s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; - filename = dirname + s.str(); + // Build the name of the image file + unsigned int iter = 1; // Image number + std::ostringstream s; + s.setf(std::ios::right, std::ios::adjustfield); + s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; + filename = dirname + s.str(); - // 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; + // 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; - vpImageIo::read(I, filename) ; - } - 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); - } + vpImageIo::read(I, filename) ; + } + 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); + } - // We open a window using either X11, GTK or GDI. + // We open a window using either X11, GTK or GDI. #if defined VISP_HAVE_X11 - vpDisplayX display; + vpDisplayX display; #elif defined VISP_HAVE_GTK - vpDisplayGTK display; + vpDisplayGTK display; #elif defined VISP_HAVE_GDI - vpDisplayGDI display; + vpDisplayGDI display; #endif - if (opt_display) { - try{ + if (opt_display) { // Display size is automatically defined by the image (I) size display.init(I, 100, 100,"Display...") ; // Display the image @@ -278,81 +281,74 @@ main(int argc, const char ** argv) vpDisplay::display(I) ; vpDisplay::flush(I) ; } - catch(...) - { - vpERROR_TRACE("Error while displaying the image") ; - exit(-1); - } - } - vpMeEllipse E1 ; - - vpMe me ; - me.setRange(20) ; - me.setSampleStep(2) ; - me.setPointsToTrack(60) ; - me.setThreshold(15000) ; - - E1.setMe(&me) ; - E1.setDisplay(vpMeSite::RANGE_RESULT) ; - if (opt_click_allowed) - E1.initTracking(I) ; - else { - // Create a list of points to automate the test - unsigned int n=5 ; - vpImagePoint *ip = new vpImagePoint [n]; - ip[0].set_i( 33 ); ip[0].set_j( 276 ); - ip[1].set_i( 83 ); ip[1].set_j( 126 ); - ip[2].set_i( 201 ); ip[2].set_j( 36 ); - ip[3].set_i( 243 ); ip[3].set_j( 164 ); - ip[4].set_i( 195 ); ip[4].set_j( 329 ); - E1.initTracking(I, n, ip) ; - delete [] ip ; - } - if (opt_display) { - E1.display(I, vpColor::green) ; - } + vpMeEllipse E1 ; + + vpMe me ; + me.setRange(20) ; + me.setSampleStep(2) ; + me.setPointsToTrack(60) ; + me.setThreshold(15000) ; + + E1.setMe(&me) ; + E1.setDisplay(vpMeSite::RANGE_RESULT) ; + if (opt_click_allowed) + E1.initTracking(I) ; + else { + // Create a list of points to automate the test + unsigned int n=5 ; + vpImagePoint *ip = new vpImagePoint [n]; + ip[0].set_i( 33 ); ip[0].set_j( 276 ); + ip[1].set_i( 83 ); ip[1].set_j( 126 ); + ip[2].set_i( 201 ); ip[2].set_j( 36 ); + ip[3].set_i( 243 ); ip[3].set_j( 164 ); + ip[4].set_i( 195 ); ip[4].set_j( 329 ); + E1.initTracking(I, n, ip) ; + delete [] ip ; + } + if (opt_display) { + E1.display(I, vpColor::green) ; + } - vpERROR_TRACE("sample step %f ",E1.getMe()->getSampleStep()) ; - E1.track(I) ; - if (opt_display && opt_click_allowed) { - std::cout << "A click to continue..." << std::endl; - vpDisplay::getClick(I) ; - } - std::cout <<"------------------------------------------------------------"<<std::endl; + vpERROR_TRACE("sample step %f ",E1.getMe()->getSampleStep()) ; + E1.track(I) ; + if (opt_display && opt_click_allowed) { + std::cout << "A click to continue..." << std::endl; + vpDisplay::getClick(I) ; + } + std::cout <<"------------------------------------------------------------"<<std::endl; - for (int iter = 1 ; iter < 51 ; iter++) // initially : iter < 1500 - { - // set the new image name - s.str(""); - s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; - filename = dirname + s.str(); - std::cout << "Tracking on image: " << filename << std::endl; - // read the image - vpImageIo::read(I, filename); - if (opt_display) { - // Display the image - vpDisplay::display(I) ; - } - try + for (iter = 1 ; iter < 51 ; iter++) // initially : iter < 1500 { + // set the new image name + s.str(""); + s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; + filename = dirname + s.str(); + std::cout << "Tracking on image: " << filename << std::endl; + // read the image + vpImageIo::read(I, filename); + if (opt_display) { + // Display the image + vpDisplay::display(I) ; + } + E1.track(I) ; - } - catch(...) - { - vpERROR_TRACE("Error in tracking vpMeLine ") ; - exit(1) ; - } - if (opt_display) { - E1.display(I,vpColor::green) ; - vpDisplay::flush(I) ; + if (opt_display) { + E1.display(I,vpColor::green) ; + vpDisplay::flush(I) ; + } + } + if (opt_display && opt_click_allowed) { + std::cout << "A click to exit..." << std::endl; + vpDisplay::getClick(I) ; } + return 0; } - if (opt_display && opt_click_allowed) { - std::cout << "A click to exit..." << std::endl; - vpDisplay::getClick(I) ; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } } #else diff --git a/example/tracking/trackMeLine.cpp b/example/tracking/trackMeLine.cpp index a74df86862a65129563eaedf5d7c6614e8cd1553..4bd5e3eaff2491b34c30b03aee6ad64b75402600 100644 --- a/example/tracking/trackMeLine.cpp +++ b/example/tracking/trackMeLine.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: trackMeLine.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: trackMeLine.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -81,6 +81,9 @@ // List of allowed command line options #define GETOPTARGS "cdi:h" +void usage(const char *name, const char *badparam, std::string ipath); +bool getOptions(int argc, const char **argv, std::string &ipath, bool &click_allowed, bool &display); + /*! Print the program options. @@ -135,21 +138,20 @@ OPTIONS: Default\n\ \return false if the program has to be stopped, true otherwise. */ -bool getOptions(int argc, const char **argv, std::string &ipath, - bool &click_allowed, bool &display) +bool getOptions(int argc, const char **argv, std::string &ipath, bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; case 'd': display = false; break; - case 'i': ipath = optarg; break; + case 'i': ipath = optarg_; break; case 'h': usage(argv[0], NULL, ipath); return false; break; default: - usage(argv[0], optarg, ipath); + usage(argv[0], optarg_, ipath); return false; break; } } @@ -158,7 +160,7 @@ bool getOptions(int argc, const char **argv, std::string &ipath, // standalone param or error usage(argv[0], NULL, ipath); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -169,110 +171,110 @@ bool getOptions(int argc, const char **argv, std::string &ipath, int main(int argc, const char ** argv) { - std::string env_ipath; - std::string opt_ipath; - std::string ipath; - std::string dirname; - std::string filename; - bool opt_click_allowed = true; - 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_click_allowed, - opt_display) == false) { - exit (-1); - } + try { + std::string env_ipath; + std::string opt_ipath; + std::string ipath; + std::string dirname; + std::string filename; + bool opt_click_allowed = true; + 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_click_allowed, + 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 <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + // 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 <visp image path=" << ipath << "> " + << " 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 <visp image path> 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); - } + // 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 <visp image path> 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); + } - // 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<unsigned char> I ; - - // Set the path location of the image sequence - dirname = ipath + vpIoTools::path("/ViSP-images/line/"); - - // Build the name of the image file - unsigned iter = 1; // Image number - std::ostringstream s; - s.setf(std::ios::right, std::ios::adjustfield); - s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; - filename = dirname + s.str(); - - // 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; - - vpImageIo::read(I, filename) ; - } - catch(...) - { - // an exception is throwned if an exception from readPGM has been catched - // 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); - } + // 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<unsigned char> I ; - // We open a window using either X11, GTK or GDI. + // Set the path location of the image sequence + dirname = ipath + vpIoTools::path("/ViSP-images/line/"); + + // Build the name of the image file + unsigned int iter = 1; // Image number + std::ostringstream s; + s.setf(std::ios::right, std::ios::adjustfield); + s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; + filename = dirname + s.str(); + + // 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; + + vpImageIo::read(I, filename) ; + } + catch(...) + { + // an exception is throwned if an exception from readPGM has been catched + // 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); + } + + // We open a window using either X11, GTK or GDI. #if defined VISP_HAVE_X11 - vpDisplayX display; + vpDisplayX display; #elif defined VISP_HAVE_GTK - vpDisplayGTK display; + vpDisplayGTK display; #elif defined VISP_HAVE_GDI - vpDisplayGDI display; + vpDisplayGDI display; #endif - if (opt_display) { - try{ + if (opt_display) { // Display size is automatically defined by the image (I) size display.init(I, 100, 100,"Display...") ; // Display the image @@ -283,91 +285,82 @@ main(int argc, const char ** argv) vpDisplay::display(I) ; vpDisplay::flush(I) ; } - catch(...) - { - vpERROR_TRACE("Error while displaying the image") ; - exit(-1); - } - } - - vpMeLine L1 ; + vpMeLine L1 ; - vpMe me ; - me.setRange(15) ; - me.setPointsToTrack(160) ; - me.setThreshold(15000) ; + vpMe me ; + me.setRange(15) ; + me.setPointsToTrack(160) ; + me.setThreshold(15000) ; - L1.setMe(&me) ; - L1.setDisplay(vpMeSite::RANGE_RESULT) ; - - if (opt_display && opt_click_allowed) - L1.initTracking(I) ; - else { - vpImagePoint ip1, ip2; - ip1.set_i( 96 ); - ip1.set_j( 191 ); - ip2.set_i( 122 ); - ip2.set_j( 211 ); - L1.initTracking(I, ip1, ip2) ; - } - - if (opt_display) - L1.display(I, vpColor::green) ; + L1.setMe(&me) ; + L1.setDisplay(vpMeSite::RANGE_RESULT) ; - L1.track(I) ; - if (opt_display && opt_click_allowed) { - std::cout << "A click to continue..." << std::endl; - vpDisplay::getClick(I) ; - } - std::cout <<"----------------------------------------------------------"<<std::endl; + if (opt_display && opt_click_allowed) + L1.initTracking(I) ; + else { + vpImagePoint ip1, ip2; + ip1.set_i( 96 ); + ip1.set_j( 191 ); + ip2.set_i( 122 ); + ip2.set_j( 211 ); + L1.initTracking(I, ip1, ip2) ; + } - vpFeatureLine l ; + if (opt_display) + L1.display(I, vpColor::green) ; - vpCameraParameters cam ; - vpImage<vpRGBa> Ic ; - for (int iter = 1 ; iter < 30 ; iter++) - { - std::cout <<"----------------------------------------------------------"<<std::endl; - // set the new image name - s.str(""); - s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; - filename = dirname + s.str(); - // read the image - vpImageIo::read(I, filename); - if (opt_display) { - // Display the image - vpDisplay::display(I) ; + L1.track(I) ; + if (opt_display && opt_click_allowed) { + std::cout << "A click to continue..." << std::endl; + vpDisplay::getClick(I) ; } + std::cout <<"----------------------------------------------------------"<<std::endl; - try + vpFeatureLine l ; + + vpCameraParameters cam ; + vpImage<vpRGBa> Ic ; + for (iter = 1 ; iter < 30 ; iter++) { + std::cout <<"----------------------------------------------------------"<<std::endl; + // set the new image name + s.str(""); + s << "image." << std::setw(4) << std::setfill('0') << iter << ".pgm"; + filename = dirname + s.str(); + // read the image + vpImageIo::read(I, filename); + if (opt_display) { + // Display the image + vpDisplay::display(I) ; + } + std::cout << "Tracking on image: " << filename << std::endl; L1.track(I) ; - } - catch(...) - { - vpERROR_TRACE("Error in tracking vpMeLine ") ; - exit(1) ; - } - - vpTRACE("L1 : %f %f", L1.getRho(), vpMath::deg(L1.getTheta())) ; - vpFeatureBuilder::create(l,cam,L1) ; - vpTRACE("L1 : %f %f", l.getRho(), vpMath::deg(l.getTheta())) ; - if (opt_display) { - L1.display(I,vpColor::green) ; - vpDisplay::flush(I) ; - if (opt_click_allowed) { - std::cout << "A click to continue..." << std::endl; - vpDisplay::getClick(I) ; + vpTRACE("L1 : %f %f", L1.getRho(), vpMath::deg(L1.getTheta())) ; + vpFeatureBuilder::create(l,cam,L1) ; + vpTRACE("L1 : %f %f", l.getRho(), vpMath::deg(l.getTheta())) ; + + if (opt_display) { + L1.display(I,vpColor::green) ; + vpDisplay::flush(I) ; + if (opt_click_allowed) { + std::cout << "A click to continue..." << std::endl; + vpDisplay::getClick(I) ; + } } } + if (opt_display && opt_click_allowed) { + std::cout << "A click to exit..." << std::endl; + vpDisplay::getClick(I) ; + } + return 0; } - if (opt_display && opt_click_allowed) { - std::cout << "A click to exit..." << std::endl; - vpDisplay::getClick(I) ; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } } diff --git a/example/tracking/trackMeNurbs.cpp b/example/tracking/trackMeNurbs.cpp index fa99856219ab8f688cdf592315997da6c016b4a9..e6192aad6e0a6958c0c9fd673a6352db62efe0ea 100644 --- a/example/tracking/trackMeNurbs.cpp +++ b/example/tracking/trackMeNurbs.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: trackMeNurbs.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: trackMeNurbs.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -78,6 +78,9 @@ // List of allowed command line options #define GETOPTARGS "cdi:h" +void usage(const char *name, const char *badparam, std::string ipath); +bool getOptions(int argc, const char **argv, std::string &ipath, bool &click_allowed, bool &display); + /*! Print the program options. @@ -134,18 +137,18 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv, std::string &ipath, bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; case 'd': display = false; break; - case 'i': ipath = optarg; break; + case 'i': ipath = optarg_; break; case 'h': usage(argv[0], NULL, ipath); return false; break; default: - usage(argv[0], optarg, ipath); + usage(argv[0], optarg_, ipath); return false; break; } } @@ -154,7 +157,7 @@ bool getOptions(int argc, const char **argv, std::string &ipath, bool &click_all // standalone param or error usage(argv[0], NULL, ipath); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -165,83 +168,83 @@ bool getOptions(int argc, const char **argv, std::string &ipath, bool &click_all int main(int argc, const char ** argv) { - std::string env_ipath; - std::string opt_ipath; - std::string ipath; - std::string filename; - bool opt_click_allowed = true; - 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_click_allowed, opt_display) == false) { - exit (-1); - } + try { + std::string env_ipath; + std::string opt_ipath; + std::string ipath; + std::string filename; + bool opt_click_allowed = true; + 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_click_allowed, 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 <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + // 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 <visp image path=" << ipath << "> " + << " 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 <visp image path> 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); - } + // 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 <visp image path> 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); + } - // Declare an image, this is a gray level image (unsigned char) - // it size is not defined yet, it will be defined when the image is - // read on the disk - vpImage<unsigned char> I ; + // Declare an image, this is a gray level image (unsigned char) + // it size is not defined yet, it will be defined when the image is + // read on the disk + vpImage<unsigned char> I ; - // Set the path location of the image sequence - filename = ipath + vpIoTools::path("/ViSP-images/ellipse-1/image.%04d.pgm"); + // Set the path location of the image sequence + filename = ipath + vpIoTools::path("/ViSP-images/ellipse-1/image.%04d.pgm"); - // Build the name of the image file - vpVideoReader reader; - //Initialize the reader and get the first frame. - reader.setFileName(filename.c_str()); - reader.setFirstFrameIndex(1); - reader.open(I); + // Build the name of the image file + vpVideoReader reader; + //Initialize the reader and get the first frame. + reader.setFileName(filename.c_str()); + reader.setFirstFrameIndex(1); + reader.open(I); - // We open a window using either X11, GTK or GDI. + // We open a window using either X11, GTK or GDI. #if defined VISP_HAVE_X11 - vpDisplayX display; + vpDisplayX display; #elif defined VISP_HAVE_GTK - vpDisplayGTK display; + vpDisplayGTK display; #elif defined VISP_HAVE_GDI - vpDisplayGDI display; + vpDisplayGDI display; #endif - if (opt_display) { - try{ + if (opt_display) { // Display size is automatically defined by the image (I) size display.init(I, 100, 100,"Display...") ; // Display the image @@ -252,85 +255,79 @@ main(int argc, const char ** argv) vpDisplay::display(I) ; vpDisplay::flush(I) ; } - catch(...) - { - vpERROR_TRACE("Error while displaying the image") ; - exit(-1); - } - } - vpMeNurbs nurbs ; + vpMeNurbs nurbs ; - vpMe me ; - me.setRange(30) ; - me.setSampleStep(5) ; - me.setPointsToTrack(60) ; - me.setThreshold(15000) ; + vpMe me ; + me.setRange(30) ; + me.setSampleStep(5) ; + me.setPointsToTrack(60) ; + me.setThreshold(15000) ; - nurbs.setMe(&me); - nurbs.setDisplay(vpMeSite::RANGE_RESULT) ; - nurbs.setNbControlPoints(14); + nurbs.setMe(&me); + nurbs.setDisplay(vpMeSite::RANGE_RESULT) ; + nurbs.setNbControlPoints(14); - if (opt_click_allowed) - { - std::cout << "Click on points along the edge with the left button." << std::endl; - std::cout << "Then click on the right button to continue." << std::endl; - nurbs.initTracking(I); - } - else - { - // Create a list of points to automate the test - std::list<vpImagePoint> list; - list.push_back(vpImagePoint(178,357)); - list.push_back(vpImagePoint(212,287)); - list.push_back(vpImagePoint(236,210)); - list.push_back(vpImagePoint(240, 118)); - list.push_back(vpImagePoint(210, 40)); - - nurbs.initTracking(I, list) ; - } - if (opt_display) { - nurbs.display(I, vpColor::green) ; - } + if (opt_click_allowed) + { + std::cout << "Click on points along the edge with the left button." << std::endl; + std::cout << "Then click on the right button to continue." << std::endl; + nurbs.initTracking(I); + } + else + { + // Create a list of points to automate the test + std::list<vpImagePoint> list; + list.push_back(vpImagePoint(178,357)); + list.push_back(vpImagePoint(212,287)); + list.push_back(vpImagePoint(236,210)); + list.push_back(vpImagePoint(240, 118)); + list.push_back(vpImagePoint(210, 40)); + + nurbs.initTracking(I, list) ; + } + if (opt_display) { + nurbs.display(I, vpColor::green) ; + } - nurbs.track(I) ; - if (opt_display && opt_click_allowed) { - std::cout << "A click to continue..." << std::endl; - vpDisplay::getClick(I) ; - } - std::cout <<"------------------------------------------------------------"<<std::endl; + nurbs.track(I) ; + if (opt_display && opt_click_allowed) { + std::cout << "A click to continue..." << std::endl; + vpDisplay::getClick(I) ; + } + std::cout <<"------------------------------------------------------------"<<std::endl; - for (int iter = 1 ; iter < 40 ; iter++) - { - //read the image - reader.getFrame(I,iter); - if (opt_display) { - // Display the image - vpDisplay::display(I) ; - } - try + for (int iter = 1 ; iter < 40 ; iter++) { + //read the image + reader.getFrame(I,iter); + if (opt_display) { + // Display the image + vpDisplay::display(I) ; + } + //Track the nurbs nurbs.track(I) ; - } - catch(...) - { - vpERROR_TRACE("Error in tracking vpMeLine ") ; - exit(1) ; - } - if (opt_display) { - nurbs.display(I,vpColor::green) ; - vpDisplay::flush(I) ; - vpTime::wait(100); + + if (opt_display) { + nurbs.display(I,vpColor::green) ; + vpDisplay::flush(I) ; + vpTime::wait(100); + } + } + if (opt_display && opt_click_allowed) { + std::cout << "A click to exit..." << std::endl; + vpDisplay::getClick(I) ; } + return 0; } - if (opt_display && opt_click_allowed) { - std::cout << "A click to exit..." << std::endl; - vpDisplay::getClick(I) ; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } } #else diff --git a/example/video/CMakeLists.txt b/example/video/CMakeLists.txt index 9204ded644f8760844e079b5e3fd1d52eaca238a..1c115f539c85f6470fe34310ecdc9e4567730d0e 100644 --- a/example/video/CMakeLists.txt +++ b/example/video/CMakeLists.txt @@ -3,7 +3,7 @@ # $Id: CMakeLists.txt 2158 2009-05-07 07:24:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/video/imageSequenceReader.cpp b/example/video/imageSequenceReader.cpp index e349b31af846d3c41847c5d721c922c0bf9016ba..bcc804b35cfddd9958b13693a38997e16805a61f 100644 --- a/example/video/imageSequenceReader.cpp +++ b/example/video/imageSequenceReader.cpp @@ -3,7 +3,7 @@ * $Id: imageDiskRW.cpp 2158 2009-05-07 07:24:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -65,6 +65,10 @@ // List of allowed command line options #define GETOPTARGS "cdi:p:f:h" +void usage(const char *name, const char *badparam, std::string ipath, std::string ppath); +bool getOptions(int argc, const char **argv, + std::string &ipath, std::string &ppath, int &first, bool &click_allowed, bool &display); + /*! Print the program options. @@ -137,20 +141,20 @@ OPTIONS: Default\n\ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &ppath, int &first, bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; case 'd': display = false; break; - case 'i': ipath = optarg; break; - case 'p': ppath = optarg; break; - case 'f': first = atoi(optarg); break; + case 'i': ipath = optarg_; break; + case 'p': ppath = optarg_; break; + case 'f': first = atoi(optarg_); break; case 'h': usage(argv[0], NULL, ipath, ppath); return false; break; default: - usage(argv[0], optarg, ipath, ppath); return false; break; + usage(argv[0], optarg_, ipath, ppath); return false; break; } } @@ -158,7 +162,7 @@ bool getOptions(int argc, const char **argv, // standalone param or error usage(argv[0], NULL, ipath, ppath); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -170,171 +174,167 @@ bool getOptions(int argc, const char **argv, int main(int argc, const char ** argv) { + try { + std::string env_ipath; + std::string opt_ipath; + std::string ipath; + std::string opt_ppath; + std::string filename; + int opt_first = 1; + bool opt_click_allowed = true; + bool opt_display = true; + + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << " videoImageSequenceReader.cpp" <<std::endl << std::endl ; + + std::cout << " reading an image sequence" << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << std::endl ; + + // 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_first, opt_click_allowed, + opt_display) == false) { + exit (-1); + } - std::string env_ipath; - std::string opt_ipath; - std::string ipath; - std::string opt_ppath; - std::string filename; - int opt_first = 1; - bool opt_click_allowed = true; - bool opt_display = true; + // 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 <visp image path=" << ipath << "> " + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; + } + } - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << " videoImageSequenceReader.cpp" <<std::endl << 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 <visp image path> option or set VISP_INPUT_IMAGE_PATH " + << std::endl + << " environment variable to specify the location of the " << std::endl + << " video path where test images are located." << std::endl << std::endl; + exit(-1); + } - std::cout << " reading an image sequence" << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << std::endl ; + ///////////////////////////////////////////////////////////////////// - // 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; + // vpImage is a template class you can declare vpImage of ... everything... + vpImage<vpRGBa> I ; - // Read the command line options - if (getOptions(argc, argv, opt_ipath, opt_ppath, opt_first, opt_click_allowed, - opt_display) == false) { - exit (-1); - } + //Create the video Reader + vpVideoReader reader; - // 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 <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + if (opt_ppath.empty()) + { + filename = ipath + vpIoTools::path("/ViSP-images/mire-2/image.%04d.pgm"); + } + else + { + filename.assign(opt_ppath); } - } - - // 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 <visp image path> option or set VISP_INPUT_IMAGE_PATH " - << std::endl - << " environment variable to specify the location of the " << std::endl - << " video path where test images are located." << std::endl << std::endl; - exit(-1); - } - - - ///////////////////////////////////////////////////////////////////// - - // vpImage is a template class you can declare vpImage of ... everything... - vpImage<vpRGBa> I ; - - //Create the video Reader - vpVideoReader reader; + //Initialize the reader and get the first frame. + reader.setFileName(filename.c_str()); + reader.setFirstFrameIndex(opt_first); + reader.open(I); - if (opt_ppath.empty()) - { - filename = ipath + vpIoTools::path("/ViSP-images/mire-2/image.%04d.pgm"); - } - else - { - filename.assign(opt_ppath); - } - - //Initialize the reader and get the first frame. - reader.setFileName(filename.c_str()); - reader.setFirstFrameIndex(opt_first); - reader.open(I); - - // We open a window using either X11, GTK, GDI or OpenCV. + // We open a window using either X11, GTK, GDI or OpenCV. #if defined VISP_HAVE_X11 - vpDisplayX display; + vpDisplayX display; #elif defined VISP_HAVE_GTK - vpDisplayGTK display; + vpDisplayGTK display; #elif defined VISP_HAVE_GDI - vpDisplayGDI display; + vpDisplayGDI display; #elif defined VISP_HAVE_OPENCV - vpDisplayOpenCV display; + vpDisplayOpenCV display; #endif - if (opt_display) - { - try - { + if (opt_display) { // Display size is automatically defined by the image (I) size display.init(I, 100, 100,"Display video frame") ; vpDisplay::display(I) ; vpDisplay::flush(I) ; + } - catch(...) + + if (opt_display && opt_click_allowed) { - vpERROR_TRACE("Error while displaying the image") ; - exit(-1); + std::cout << "Click on the image to read and display the second frame" << std::endl; + vpDisplay::getClick(I); + } + + reader.getFrame(I,opt_first+1); + + if (opt_display) + { + vpDisplay::display(I) ; + vpDisplay::flush(I); + } + + if (opt_display && opt_click_allowed) + { + std::cout << "Click on the image to read and display the last frame" << std::endl; + vpDisplay::getClick(I); } - } - - if (opt_display && opt_click_allowed) - { - std::cout << "Click on the image to read and display the second frame" << std::endl; - vpDisplay::getClick(I); - } - - reader.getFrame(I,opt_first+1); - - if (opt_display) - { - vpDisplay::display(I) ; - vpDisplay::flush(I); - } - - if (opt_display && opt_click_allowed) - { - std::cout << "Click on the image to read and display the last frame" << std::endl; - vpDisplay::getClick(I); - } - - reader.getFrame(I,reader.getLastFrameIndex()); - - if (opt_display) - { - vpDisplay::display(I) ; - vpDisplay::flush(I); - } - - if (opt_display && opt_click_allowed) - { - std::cout << "Click to see the video" << std::endl; - vpDisplay::getClick(I); - } - - int lastFrame = reader.getLastFrameIndex(); - for (int i = opt_first; i <= lastFrame; i++) - { - reader.getFrame(I,i); + reader.getFrame(I,reader.getLastFrameIndex()); + if (opt_display) { vpDisplay::display(I) ; vpDisplay::flush(I); } + + if (opt_display && opt_click_allowed) + { + std::cout << "Click to see the video" << std::endl; + vpDisplay::getClick(I); + } + + int lastFrame = reader.getLastFrameIndex(); + + for (int i = opt_first; i <= lastFrame; i++) + { + reader.getFrame(I,i); + if (opt_display) + { + vpDisplay::display(I) ; + vpDisplay::flush(I); + } + } + + if (opt_display && opt_click_allowed) + { + std::cout << "Click to exit the test" << std::endl; + vpDisplay::getClick(I); + } + + return 0; } - - if (opt_display && opt_click_allowed) - { - std::cout << "Click to exit the test" << std::endl; - vpDisplay::getClick(I); + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - - return 0; } #else int main() diff --git a/example/video/videoReader.cpp b/example/video/videoReader.cpp index c8e93806ba15e19595ba6310cba63134345a2092..68794b7d97da40ec1631a4b7275f56df78571792 100644 --- a/example/video/videoReader.cpp +++ b/example/video/videoReader.cpp @@ -3,7 +3,7 @@ * $Id: imageDiskRW.cpp 2158 2009-05-07 07:24:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -66,6 +66,10 @@ // List of allowed command line options #define GETOPTARGS "cdi:p:h" +void usage(const char *name, const char *badparam, std::string ipath, std::string ppath); +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &ppath, + bool &click_allowed, bool &display); + /*! Print the program options. @@ -130,22 +134,22 @@ OPTIONS: Default\n\ \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, bool &display) +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &ppath, + bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; case 'd': display = false; break; - case 'i': ipath = optarg; break; - case 'p': ppath = optarg; 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; + usage(argv[0], optarg_, ipath, ppath); return false; break; } } @@ -153,7 +157,7 @@ bool getOptions(int argc, const char **argv, // standalone param or error usage(argv[0], NULL, ipath, ppath); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -165,161 +169,149 @@ bool getOptions(int argc, const char **argv, int main(int argc, const char ** argv) { + try { + std::string env_ipath; + std::string opt_ipath; + std::string ipath; + std::string opt_ppath; + std::string filename; + bool opt_click_allowed = true; + bool opt_display = true; + + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << " videoReader.cpp" <<std::endl << std::endl ; + + std::cout << " reading a video file" << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << std::endl ; + + + // 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, + opt_display) == false) { + exit (-1); + } - std::string env_ipath; - std::string opt_ipath; - std::string ipath; - std::string opt_ppath; - std::string filename; - bool opt_click_allowed = true; - bool opt_display = true; + // 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 <visp image path=" << ipath << "> " + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; + } + } - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << " videoReader.cpp" <<std::endl << 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 <visp image path> option or set VISP_INPUT_IMAGE_PATH " + << std::endl + << " environment variable to specify the location of the " << std::endl + << " video path where test images are located." << std::endl << std::endl; + exit(-1); + } - std::cout << " reading a video file" << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << std::endl ; + ///////////////////////////////////////////////////////////////////// - // 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; + // vpImage is a template class you can declare vpImage of ... everything... + vpImage<vpRGBa> I ; - // Read the command line options - if (getOptions(argc, argv, opt_ipath, opt_ppath, opt_click_allowed, - opt_display) == false) { - exit (-1); - } + //Create the video Reader + vpVideoReader reader; - // 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 <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + if (opt_ppath.empty()) + { + filename = ipath + vpIoTools::path("/ViSP-images/video/cube.mpeg"); + } + else + { + filename.assign(opt_ppath); } - } - - // 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 <visp image path> option or set VISP_INPUT_IMAGE_PATH " - << std::endl - << " environment variable to specify the location of the " << std::endl - << " video path where test images are located." << std::endl << std::endl; - exit(-1); - } - - - ///////////////////////////////////////////////////////////////////// - - - // vpImage is a template class you can declare vpImage of ... everything... - vpImage<vpRGBa> I ; - - //Create the video Reader - vpVideoReader reader; - if (opt_ppath.empty()) - { - filename = ipath + vpIoTools::path("/ViSP-images/video/cube.mpeg"); - } - else - { - filename.assign(opt_ppath); - } - - //Initialize the reader and get the first frame. - reader.setFileName(filename.c_str()); - try - { + //Initialize the reader and get the first frame. + reader.setFileName(filename.c_str()); reader.open(I); - } - catch(...) - { - return 0; - } - // We open a window using either X11, GTK, GDI or OpenCV. + // We open a window using either X11, GTK, GDI or OpenCV. #if defined VISP_HAVE_X11 - vpDisplayX display; + vpDisplayX display; #elif defined VISP_HAVE_GTK - vpDisplayGTK display; + vpDisplayGTK display; #elif defined VISP_HAVE_GDI - vpDisplayGDI display; + vpDisplayGDI display; #elif defined VISP_HAVE_OPENCV - vpDisplayOpenCV display; + vpDisplayOpenCV display; #endif - if (opt_display) - { - try - { + if (opt_display) { // Display size is automatically defined by the image (I) size display.init(I, 100, 100,"Display video frame") ; vpDisplay::display(I) ; vpDisplay::flush(I) ; } - catch(...) + + // if (opt_display && opt_click_allowed) + // { + // std::cout << "Click on the image to read and display the last key frame" << std::endl; + // vpDisplay::getClick(I); + // } + // + // reader.getFrame(I,reader.getLastFrameIndex()); + // + // if (opt_display) + // { + // vpDisplay::display(I) ; + // vpDisplay::flush(I); + // } + + if (opt_display && opt_click_allowed) { - vpERROR_TRACE("Error while displaying the image") ; - exit(-1); + std::cout << "Click to see the video" << std::endl; + vpDisplay::getClick(I); } - } - - // if (opt_display && opt_click_allowed) - // { - // std::cout << "Click on the image to read and display the last key frame" << std::endl; - // vpDisplay::getClick(I); - // } - // - // reader.getFrame(I,reader.getLastFrameIndex()); - // - // if (opt_display) - // { - // vpDisplay::display(I) ; - // vpDisplay::flush(I); - // } - - if (opt_display && opt_click_allowed) - { - std::cout << "Click to see the video" << std::endl; - vpDisplay::getClick(I); - } - - int lastFrame = reader.getLastFrameIndex(); - //To go to the beginning of the video - reader.getFrame(I,0); - - for (int i = 0; i <= lastFrame; i++) - { - reader.acquire(I); - if (opt_display) + + int lastFrame = reader.getLastFrameIndex(); + //To go to the beginning of the video + reader.getFrame(I,0); + + for (int i = 0; i <= lastFrame; i++) { - vpDisplay::display(I) ; - vpDisplay::flush(I); + reader.acquire(I); + if (opt_display) + { + vpDisplay::display(I) ; + vpDisplay::flush(I); + } + } + + if (opt_display && opt_click_allowed) + { + std::cout << "Click to exit the test" << std::endl; + vpDisplay::getClick(I); } } - - if (opt_display && opt_click_allowed) - { - std::cout << "Click to exit the test" << std::endl; - vpDisplay::getClick(I); + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; } return 0; } diff --git a/example/wireframe-simulator/CMakeLists.txt b/example/wireframe-simulator/CMakeLists.txt index 523661c993e8caf82e77b063f559d4df7afbbd7c..a237b438925f430c1395f691fb8f5f264fc9918a 100644 --- a/example/wireframe-simulator/CMakeLists.txt +++ b/example/wireframe-simulator/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/example/wireframe-simulator/wireframeSimulator.cpp b/example/wireframe-simulator/wireframeSimulator.cpp index db922cf0cbd32b0437c4f42db60c142136c5ff51..46600a04ae99f17c62d12c0e445236045af6fa3b 100644 --- a/example/wireframe-simulator/wireframeSimulator.cpp +++ b/example/wireframe-simulator/wireframeSimulator.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: wireframeSimulator.cpp 4182 2013-03-27 13:20:58Z fspindle $ + * $Id: wireframeSimulator.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -65,6 +65,9 @@ #ifdef VISP_HAVE_DISPLAY +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv, bool &display, bool &click); + /*! Print the program options. @@ -113,9 +116,9 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv, bool &display, bool &click) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click = false; break; @@ -123,7 +126,7 @@ bool getOptions(int argc, const char **argv, bool &display, bool &click) case 'h': usage(argv[0], NULL); return false; break; default: - usage(argv[0], optarg); + usage(argv[0], optarg_); return false; break; } } @@ -132,7 +135,7 @@ bool getOptions(int argc, const char **argv, bool &display, bool &click) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -143,41 +146,39 @@ bool getOptions(int argc, const char **argv, bool &display, bool &click) int main(int argc, const char ** argv) { - bool opt_display = true; - bool opt_click = true; - - // Read the command line options - if (getOptions(argc, argv, opt_display, opt_click) == false) { - exit (-1); - } - - /* + try { + bool opt_display = true; + bool opt_click = true; + + // Read the command line options + if (getOptions(argc, argv, opt_display, opt_click) == false) { + exit (-1); + } + + /* Three vpImage are created : one for the main camera and the others for two external cameras */ - vpImage<vpRGBa> Iint(480,640,255); - vpImage<vpRGBa> Iext1(480,640,255); - vpImage<vpRGBa> Iext2(480,640,255); + vpImage<vpRGBa> Iint(480,640,255); + vpImage<vpRGBa> Iext1(480,640,255); + vpImage<vpRGBa> Iext2(480,640,255); - /* + /* Create a display for each different cameras. */ #if defined VISP_HAVE_X11 - vpDisplayX display[3]; + vpDisplayX display[3]; #elif defined VISP_HAVE_OPENCV - vpDisplayOpenCV display[3]; + vpDisplayOpenCV display[3]; #elif defined VISP_HAVE_GDI - vpDisplayGDI display[3]; + vpDisplayGDI display[3]; #elif defined VISP_HAVE_D3D9 - vpDisplayD3D display[3]; + vpDisplayD3D display[3]; #elif defined VISP_HAVE_GTK - vpDisplayGTK display[3]; + vpDisplayGTK display[3]; #endif - - if (opt_display) - { - try - { + + if (opt_display) { // Display size is automatically defined by the image (I) size display[0].init(Iint, 100, 100,"The internal view") ; display[1].init(Iext1, 100, 100,"The first external view") ; @@ -192,146 +193,145 @@ main(int argc, const char ** argv) vpDisplay::display(Iext2); vpDisplay::flush(Iext2); } - catch(...) - { - vpERROR_TRACE("Error while displaying the image") ; - exit(-1); - } - } - //The homogeneous matrix which gives the current position of the main camera relative to the object - vpHomogeneousMatrix cMo(0,0.05,1.3,vpMath::rad(15),vpMath::rad(25),0); - - //The homogeneous matrix which gives the desired position of the main camera relative to the object - vpHomogeneousMatrix cdMo(vpHomogeneousMatrix(0.0,0.0,1.0,vpMath::rad(0),vpMath::rad(0),vpMath::rad(0))); + //The homogeneous matrix which gives the current position of the main camera relative to the object + vpHomogeneousMatrix cMo(0,0.05,1.3,vpMath::rad(15),vpMath::rad(25),0); + + //The homogeneous matrix which gives the desired position of the main camera relative to the object + vpHomogeneousMatrix cdMo(vpHomogeneousMatrix(0.0,0.0,1.0,vpMath::rad(0),vpMath::rad(0),vpMath::rad(0))); - //Declaration of the simulator - vpWireFrameSimulator sim; - /* + //Declaration of the simulator + vpWireFrameSimulator sim; + /* Set the scene. It enables to choose the shape of the object and the shape of the desired object which is - displayed in the main camera view. It exists several objects in ViSP. See the html documentation of the + displayed in the main camera view. It exists several objects in ViSP. See the html documentation of the simulator class to have the complete list. Note : if you don't want to have a desired object displayed in the main camera view you can use the initObject Method. - Here the object is a plate with 4 points and it is the same object which is used to display the object at the desired position. + Here the object is a plate with 4 points and it is the same object which is used to display the object at the desired position. */ - sim.initScene(vpWireFrameSimulator::PLATE, vpWireFrameSimulator::D_STANDARD); - - /* + sim.initScene(vpWireFrameSimulator::PLATE, vpWireFrameSimulator::D_STANDARD); + + /* The object at the current position will be displayed in blue The object at the desired position will be displayed in red The camera will be display in green */ - sim.setCurrentViewColor(vpColor::blue); - sim.setDesiredViewColor(vpColor::red); - sim.setCameraColor(vpColor::green); - /* + sim.setCurrentViewColor(vpColor::blue); + sim.setDesiredViewColor(vpColor::red); + sim.setCameraColor(vpColor::green); + /* Set the current and the desired position of the camera relative to the object. */ - sim.setCameraPositionRelObj(cMo) ; - sim.setDesiredCameraPosition(cdMo); - /* + sim.setCameraPositionRelObj(cMo) ; + sim.setDesiredCameraPosition(cdMo); + /* Set the main external camera's position relative to the world reference frame. More information about the different frames are given in the html documentation. */ - vpHomogeneousMatrix camMw(vpHomogeneousMatrix(0.0,0,4.5,vpMath::rad(0),vpMath::rad(-30),0)); - sim.setExternalCameraPosition(camMw); - - /* + vpHomogeneousMatrix camMw(vpHomogeneousMatrix(0.0,0,4.5,vpMath::rad(0),vpMath::rad(-30),0)); + sim.setExternalCameraPosition(camMw); + + /* Set the parameters of the cameras (internal and external) */ - vpCameraParameters camera(1000,1000,320,240); - sim.setInternalCameraParameters(camera); - sim.setExternalCameraParameters(camera); - - vpHomogeneousMatrix camoMw(vpHomogeneousMatrix(-0.3,0.2,2.5,vpMath::rad(0),vpMath::rad(10),0)); - - if (opt_display) - { - //Get the view of the internal camera - sim.getInternalImage(Iint); - //Get the view of the main external camera - sim.getExternalImage(Iext1); - //Get the view of an external camera that you can positionned thanks - //to a vpHomogeneousMatrix which describes the position of the camera - //relative to the world reference frame. - sim.getExternalImage(Iext2,camoMw); - //Display the views. - - vpDisplay::flush(Iint); - vpDisplay::flush(Iext1); - vpDisplay::flush(Iext2); - } - - std::cout << std::endl; - std::cout << "Here are presented the effect of the basic functions of the simulator" << std::endl; - std::cout << std::endl; - - if (opt_display) - { - if (opt_click) { - std::cout << "Click on the internal view window to continue. the object will move. The external cameras are fixed. The main camera moves too because the homogeneous matrix cMo didn't change." << std::endl; - vpDisplay::getClick(Iint); + vpCameraParameters camera(1000,1000,320,240); + sim.setInternalCameraParameters(camera); + sim.setExternalCameraParameters(camera); + + vpHomogeneousMatrix camoMw(vpHomogeneousMatrix(-0.3,0.2,2.5,vpMath::rad(0),vpMath::rad(10),0)); + + if (opt_display) + { + //Get the view of the internal camera + sim.getInternalImage(Iint); + //Get the view of the main external camera + sim.getExternalImage(Iext1); + //Get the view of an external camera that you can positionned thanks + //to a vpHomogeneousMatrix which describes the position of the camera + //relative to the world reference frame. + sim.getExternalImage(Iext2,camoMw); + //Display the views. + + vpDisplay::flush(Iint); + vpDisplay::flush(Iext1); + vpDisplay::flush(Iext2); } - vpDisplay::display(Iint) ; - vpDisplay::display(Iext1) ; - vpDisplay::display(Iext2) ; - } - /* + + std::cout << std::endl; + std::cout << "Here are presented the effect of the basic functions of the simulator" << std::endl; + std::cout << std::endl; + + if (opt_display) + { + if (opt_click) { + std::cout << "Click on the internal view window to continue. the object will move. The external cameras are fixed. The main camera moves too because the homogeneous matrix cMo didn't change." << std::endl; + vpDisplay::getClick(Iint); + } + vpDisplay::display(Iint) ; + vpDisplay::display(Iext1) ; + vpDisplay::display(Iext2) ; + } + /* To move the object you have to define a vpHomogeneousMatrix which gives the position of the object relative to the world refrenece frame. */ - vpHomogeneousMatrix mov(0.05,0.05,0.2,vpMath::rad(10),0,0); - sim.set_fMo(mov); - - - if (opt_display) - { - //Get the view of the internal camera - sim.getInternalImage(Iint); - //Get the view of the main external camera - sim.getExternalImage(Iext1); - //Get the view of an external camera that you can positionned thanks - //to a vpHomogeneousMatrix which describes the position of the camera - //relative to the world reference frame. - sim.getExternalImage(Iext2,camoMw); - //Display the views. - - vpDisplay::flush(Iint); - vpDisplay::flush(Iext1); - vpDisplay::flush(Iext2); - } - - std::cout << std::endl; - if (opt_display) - { - if (opt_click) { - std::cout << "Click on the internal view window to continue" << std::endl; - vpDisplay::getClick(Iint); + vpHomogeneousMatrix mov(0.05,0.05,0.2,vpMath::rad(10),0,0); + sim.set_fMo(mov); + + + if (opt_display) + { + //Get the view of the internal camera + sim.getInternalImage(Iint); + //Get the view of the main external camera + sim.getExternalImage(Iext1); + //Get the view of an external camera that you can positionned thanks + //to a vpHomogeneousMatrix which describes the position of the camera + //relative to the world reference frame. + sim.getExternalImage(Iext2,camoMw); + //Display the views. + + vpDisplay::flush(Iint); + vpDisplay::flush(Iext1); + vpDisplay::flush(Iext2); } - } - std::cout << std::endl; - std::cout << "Now you can move the main external camera. Click inside the corresponding window with one of the three buttons of your mouse and move the pointer." << std::endl; - std::cout << std::endl; - std::cout << "Click on the internal view window when you are finished" << std::endl; - - /* + + std::cout << std::endl; + if (opt_display) + { + if (opt_click) { + std::cout << "Click on the internal view window to continue" << std::endl; + vpDisplay::getClick(Iint); + } + } + std::cout << std::endl; + std::cout << "Now you can move the main external camera. Click inside the corresponding window with one of the three buttons of your mouse and move the pointer." << std::endl; + std::cout << std::endl; + std::cout << "Click on the internal view window when you are finished" << std::endl; + + /* To move the main external camera you need a loop containing the getExternalImage method. This functionnality is only available for the main external camera. */ - if (opt_display && opt_click) - { - while (!vpDisplay::getClick(Iint, false)) + if (opt_display && opt_click) { - vpDisplay::display(Iext1) ; - sim.getExternalImage(Iext1); - vpDisplay::flush(Iext1); + while (!vpDisplay::getClick(Iint, false)) + { + vpDisplay::display(Iext1) ; + sim.getExternalImage(Iext1); + vpDisplay::flush(Iext1); + } } - } - std::cout << std::endl; - std::cout << "You have seen the main capabilities of the simulator. Other specific functionalities are available. Please refers to the html documentation to access the list of all functions" << std::endl; - return 0; + std::cout << std::endl; + std::cout << "You have seen the main capabilities of the simulator. Other specific functionalities are available. Please refers to the html documentation to access the list of all functions" << std::endl; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } #else int diff --git a/include/vpConfig.h.cmake b/include/vpConfig.h.cmake index e9fe8aaa682dc207401ab3b04321f7fcd0ae7e95..dd4cc054480fcc5f8efc455b2238a4377d442ea2 100644 --- a/include/vpConfig.h.cmake +++ b/include/vpConfig.h.cmake @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpConfig.h.cmake 4308 2013-07-08 08:47:09Z fspindle $ + * $Id: vpConfig.h.cmake 4604 2014-01-21 14:15:23Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -203,9 +203,6 @@ // Defined if ffmpeg library available. #cmakedefine VISP_HAVE_FFMPEG -// Defined if raw1394 and dc1394-1.x libraries available. -#cmakedefine VISP_HAVE_DC1394_1 - // Defined if raw1394 and dc1394-2.x libraries available. #cmakedefine VISP_HAVE_DC1394_2 @@ -247,19 +244,6 @@ // Defined if Irisa's Viper S850 robot available. #cmakedefine VISP_HAVE_VIPER850 -// Defined if Irisa's Cycab car-like mobile robot is found. -// If found, either VISP_HAVE_CYCABTK_OLD nor VISP_HAVE_CYCABTK -// is defined. -#cmakedefine VISP_HAVE_CYCAB - -// Defined if the old cycabtk library is found. CycabTk is used to -// communicate with Irisa's Cycab car-like robot (obsolete). -#cmakedefine VISP_HAVE_CYCABTK_OLD - -// Defined if the last cycabtk library is found. CycabTk is used to -// communicate with Irisa's Cycab car-like robot (to use). -#cmakedefine VISP_HAVE_CYCABTK - // Defined if the Aria library and (pthread, rt, dl libraries under Unix) is found. // These libraries are used to control Pioneer mobile robots. #cmakedefine VISP_HAVE_PIONEER @@ -298,7 +282,7 @@ // // On Linux, set the visibility accordingly. If C++ symbol visibility // is handled by the compiler, see: http://gcc.gnu.org/wiki/Visibility -# if defined _WIN32 || defined __CYGWIN__ +# if defined(_WIN32) || defined(__CYGWIN__) // On Microsoft Windows, use dllimport and dllexport to tag symbols. # define VISP_DLLIMPORT __declspec(dllimport) # define VISP_DLLEXPORT __declspec(dllexport) @@ -315,7 +299,7 @@ # define VISP_DLLEXPORT # define VISP_DLLLOCAL # endif // __GNUC__ >= 4 -# endif // defined _WIN32 || defined __CYGWIN__ +# endif // defined(_WIN32) || defined(__CYGWIN__) // Under Windows, for shared libraries (DLL) we need to define export on // compilation or import on use (like a third party project). @@ -339,7 +323,7 @@ // Add the material to produce a warning when deprecated functions are used #ifndef vp_deprecated -# if defined (UNIX) +# if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX # define vp_deprecated __attribute__((deprecated)) # else # define vp_deprecated __declspec(deprecated) diff --git a/macros/have_visp.m4 b/macros/have_visp.m4 index bdec273b28724e9c5dd46b105c712a4f8aea4b25..951eb3df63aa02ba5d18054d46aaaa9b7333e129 100644 --- a/macros/have_visp.m4 +++ b/macros/have_visp.m4 @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: have_visp.m4 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: have_visp.m4 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c735bbc5e655e6de9b05d8e75f1fe63da8bf3cfe..c60c08c2f43f50acdbd31bf51dfc7c81a47355d1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4059 2013-01-07 17:04:01Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/src/camera/calibration/vpCalibration.cpp b/src/camera/calibration/vpCalibration.cpp index cb69acc3616c8ae98f599d07233412afd76ba158..28f5f19b4e43ed0bf89fded024ccfb36feff247f 100644 --- a/src/camera/calibration/vpCalibration.cpp +++ b/src/camera/calibration/vpCalibration.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpCalibration.cpp 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpCalibration.cpp 4663 2014-02-14 10:32:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -62,6 +62,8 @@ int vpCalibration::init() { npt = 0 ; + residual = residual_dist = 1000.; + LoX.clear() ; LoY.clear() ; LoZ.clear() ; @@ -70,10 +72,24 @@ int vpCalibration::init() return 0 ; } +/*! + Default constructor. + */ vpCalibration::vpCalibration() + : cMo(), cMo_dist(), cam(), cam_dist(), rMe(), eMc(), eMc_dist(), + npt(0), LoX(), LoY(), LoZ(), Lip(), residual(1000.), residual_dist(1000.) { init() ; } +/*! + Copy constructor. + */ +vpCalibration::vpCalibration(const vpCalibration &c) + : cMo(), cMo_dist(), cam(), cam_dist(), rMe(), eMc(), eMc_dist(), + npt(0), LoX(), LoY(), LoZ(), Lip(), residual(1000.), residual_dist(1000.) +{ + (*this) = c; +} /*! @@ -89,8 +105,8 @@ vpCalibration::~vpCalibration() \param twinCalibration : object to be copied */ -void vpCalibration::operator=(vpCalibration& twinCalibration ) - { +vpCalibration& vpCalibration::operator=(const vpCalibration& twinCalibration ) +{ npt = twinCalibration.npt ; LoX = twinCalibration.LoX ; LoY = twinCalibration.LoY ; @@ -109,6 +125,8 @@ void vpCalibration::operator=(vpCalibration& twinCalibration ) eMc = twinCalibration.eMc; eMc_dist = twinCalibration.eMc_dist; + + return (*this); } @@ -147,11 +165,10 @@ int vpCalibration::addPoint(double X, double Y, double Z, vpImagePoint &ip) /*! Compute the pose cMo - \param cam : camera intrinsic parameters used for computation - \param cMo : computed pose + \param camera : camera intrinsic parameters used for computation. + \param cMo_est : computed pose */ -void - vpCalibration::computePose(const vpCameraParameters &cam, vpHomogeneousMatrix &cMo) +void vpCalibration::computePose(const vpCameraParameters &camera, vpHomogeneousMatrix &cMo_est) { // The vpPose class mainly contents a list of vpPoint (that is (X,Y,Z, x, y) ) vpPose pose ; @@ -168,7 +185,7 @@ void vpPoint P; P.setWorldCoordinates(*it_LoX, *it_LoY, *it_LoZ); double x=0,y=0 ; - vpPixelMeterConversion::convertPoint(cam, *it_Lip, x,y) ; + vpPixelMeterConversion::convertPoint(camera, *it_Lip, x,y) ; P.set_x(x) ; P.set_y(y) ; @@ -195,50 +212,47 @@ void //we keep the better initialization if (residual_lagrange < residual_dementhon) - cMo = cMo_lagrange; + cMo_est = cMo_lagrange; else - cMo = cMo_dementhon; + cMo_est = cMo_dementhon; // the pose is now refined using the virtual visual servoing approach // Warning: cMo needs to be initialized otherwise it may diverge - pose.computePose(vpPose::VIRTUAL_VS, cMo) ; - + pose.computePose(vpPose::VIRTUAL_VS, cMo_est) ; } /*! Compute and return the standard deviation expressed in pixel for pose matrix and camera intrinsic parameters for model without distortion. - \param cMo : the matrix that defines the pose to be tested. - \param cam : camera intrinsic parameters to be tested. + \param cMo_est : the matrix that defines the pose to be tested. + \param camera : camera intrinsic parameters to be tested. \return the standard deviation by point of the error in pixel . */ -double - vpCalibration::computeStdDeviation(vpHomogeneousMatrix& cMo, - vpCameraParameters& cam) +double vpCalibration::computeStdDeviation(const vpHomogeneousMatrix& cMo_est, + const vpCameraParameters& camera) { - double residual = 0 ; + double residual_ = 0 ; std::list<double>::const_iterator it_LoX = LoX.begin(); std::list<double>::const_iterator it_LoY = LoY.begin(); std::list<double>::const_iterator it_LoZ = LoZ.begin(); std::list<vpImagePoint>::const_iterator it_Lip = Lip.begin(); - double u0 = cam.get_u0() ; - double v0 = cam.get_v0() ; - double px = cam.get_px() ; - double py = cam.get_py() ; + double u0 = camera.get_u0() ; + double v0 = camera.get_v0() ; + double px = camera.get_px() ; + double py = camera.get_py() ; vpImagePoint ip; for (unsigned int i =0 ; i < npt ; i++) { - double oX = *it_LoX; double oY = *it_LoY; double oZ = *it_LoZ; - double cX = oX*cMo[0][0]+oY*cMo[0][1]+oZ*cMo[0][2] + cMo[0][3]; - double cY = oX*cMo[1][0]+oY*cMo[1][1]+oZ*cMo[1][2] + cMo[1][3]; - double cZ = oX*cMo[2][0]+oY*cMo[2][1]+oZ*cMo[2][2] + cMo[2][3]; + double cX = oX*cMo_est[0][0]+oY*cMo_est[0][1]+oZ*cMo_est[0][2] + cMo_est[0][3]; + double cY = oX*cMo_est[1][0]+oY*cMo_est[1][1]+oZ*cMo_est[1][2] + cMo_est[1][3]; + double cZ = oX*cMo_est[2][0]+oY*cMo_est[2][1]+oZ*cMo_est[2][2] + cMo_est[2][3]; double x = cX/cZ ; double y = cY/cZ ; @@ -250,40 +264,39 @@ double double xp = u0 + x*px; double yp = v0 + y*py; - residual += (vpMath::sqr(xp-u) + vpMath::sqr(yp-v)) ; + residual_ += (vpMath::sqr(xp-u) + vpMath::sqr(yp-v)) ; ++it_LoX; ++it_LoY; ++it_LoZ; ++it_Lip; } - this->residual = residual ; - return sqrt(residual/npt) ; + this->residual = residual_ ; + return sqrt(residual_/npt) ; } /*! Compute and return the standard deviation expressed in pixel for pose matrix and camera intrinsic parameters with pixel to meter model. - \param cMo : the matrix that defines the pose to be tested. - \param cam : camera intrinsic parameters to be tested. + \param cMo_est : the matrix that defines the pose to be tested. + \param camera : camera intrinsic parameters to be tested. \return the standard deviation by point of the error in pixel . */ -double - vpCalibration::computeStdDeviation_dist(vpHomogeneousMatrix& cMo, - vpCameraParameters& cam) +double vpCalibration::computeStdDeviation_dist(const vpHomogeneousMatrix& cMo_est, + const vpCameraParameters& camera) { - double residual = 0 ; + double residual_ = 0 ; std::list<double>::const_iterator it_LoX = LoX.begin(); std::list<double>::const_iterator it_LoY = LoY.begin(); std::list<double>::const_iterator it_LoZ = LoZ.begin(); std::list<vpImagePoint>::const_iterator it_Lip = Lip.begin(); - double u0 = cam.get_u0() ; - double v0 = cam.get_v0() ; - double px = cam.get_px() ; - double py = cam.get_py() ; - double kud = cam.get_kud() ; - double kdu = cam.get_kdu() ; + double u0 = camera.get_u0() ; + double v0 = camera.get_v0() ; + double px = camera.get_px() ; + double py = camera.get_py() ; + double kud = camera.get_kud() ; + double kdu = camera.get_kdu() ; double inv_px = 1/px; double inv_py = 1/px; @@ -291,14 +304,13 @@ double for (unsigned int i =0 ; i < npt ; i++) { - double oX = *it_LoX; double oY = *it_LoY; double oZ = *it_LoZ; - double cX = oX*cMo[0][0]+oY*cMo[0][1]+oZ*cMo[0][2] + cMo[0][3]; - double cY = oX*cMo[1][0]+oY*cMo[1][1]+oZ*cMo[1][2] + cMo[1][3]; - double cZ = oX*cMo[2][0]+oY*cMo[2][1]+oZ*cMo[2][2] + cMo[2][3]; + double cX = oX*cMo_est[0][0]+oY*cMo_est[0][1]+oZ*cMo_est[0][2] + cMo_est[0][3]; + double cY = oX*cMo_est[1][0]+oY*cMo_est[1][1]+oZ*cMo_est[1][2] + cMo_est[1][3]; + double cZ = oX*cMo_est[2][0]+oY*cMo_est[2][1]+oZ*cMo_est[2][2] + cMo_est[2][3]; double x = cX/cZ ; double y = cY/cZ ; @@ -312,23 +324,23 @@ double double xp = u0 + x*px*r2ud; double yp = v0 + y*py*r2ud; - residual += (vpMath::sqr(xp-u) + vpMath::sqr(yp-v)) ; + residual_ += (vpMath::sqr(xp-u) + vpMath::sqr(yp-v)) ; double r2du = (vpMath::sqr((u-u0)*inv_px)+vpMath::sqr((v-v0)*inv_py)) ; xp = u0 + x*px - kdu*(u-u0)*r2du; yp = v0 + y*py - kdu*(v-v0)*r2du; - residual += (vpMath::sqr(xp-u) + vpMath::sqr(yp-v)) ; + residual_ += (vpMath::sqr(xp-u) + vpMath::sqr(yp-v)) ; ++it_LoX; ++it_LoY; ++it_LoZ; ++it_Lip; } - residual /=2; + residual_ /=2; - this->residual_dist = residual; - return sqrt(residual/npt) ; + this->residual_dist = residual_; + return sqrt(residual_/npt) ; } /*! @@ -349,26 +361,26 @@ void Compute the calibration according to the desired method using one pose. \param method : Method that will be used to estimate the parameters. - \param cMo : the homogeneous matrix that defines the pose. - \param cam : intrinsic camera parameters. + \param cMo_est : estimated homogeneous matrix that defines the pose. + \param cam_est : estimated intrinsic camera parameters. \param verbose : set at true if information about the residual at each loop of the algorithm is hoped. \return 0 if the calibration computation succeed. */ int vpCalibration::computeCalibration(vpCalibrationMethodType method, - vpHomogeneousMatrix &cMo, - vpCameraParameters &cam, + vpHomogeneousMatrix &cMo_est, + vpCameraParameters &cam_est, bool verbose) { try{ - computePose(cam,cMo); + computePose(cam_est,cMo_est); switch (method) { case CALIB_LAGRANGE : case CALIB_LAGRANGE_VIRTUAL_VS : { - calibLagrange(cam, cMo); + calibLagrange(cam_est, cMo_est); } break; case CALIB_VIRTUAL_VS: @@ -386,23 +398,23 @@ int vpCalibration::computeCalibration(vpCalibrationMethodType method, case CALIB_LAGRANGE_VIRTUAL_VS_DIST: { if (verbose){std::cout << "start calibration without distortion"<< std::endl;} - calibVVS(cam, cMo, verbose); + calibVVS(cam_est, cMo_est, verbose); } break ; case CALIB_LAGRANGE: default: break; } - this->cMo = cMo; - this->cMo_dist = cMo; + this->cMo = cMo_est; + this->cMo_dist = cMo_est; //Print camera parameters if(verbose){ // std::cout << "Camera parameters without distortion :" << std::endl; - cam.printParameters(); + cam_est.printParameters(); } - this->cam = cam; + this->cam = cam_est; switch (method) { @@ -410,7 +422,7 @@ int vpCalibration::computeCalibration(vpCalibrationMethodType method, case CALIB_LAGRANGE_VIRTUAL_VS_DIST: { if (verbose){std::cout << "start calibration with distortion"<< std::endl;} - calibVVSWithDistortion(cam, cMo, verbose); + calibVVSWithDistortion(cam_est, cMo_est, verbose); } break ; case CALIB_LAGRANGE: @@ -424,12 +436,12 @@ int vpCalibration::computeCalibration(vpCalibrationMethodType method, // std::cout << "Camera parameters without distortion :" << std::endl; this->cam.printParameters(); // std::cout << "Camera parameters with distortion :" << std::endl; - cam.printParameters(); + cam_est.printParameters(); } - this->cam_dist = cam ; + this->cam_dist = cam_est ; - this->cMo_dist = cMo; + this->cMo_dist = cMo_est; return 0 ; } catch(...){ @@ -442,7 +454,7 @@ int vpCalibration::computeCalibration(vpCalibrationMethodType method, \param method : Method used to estimate the camera parameters. \param table_cal : Vector of vpCalibration. - \param cam : Estimated intrinsic camera parameters. + \param cam_est : Estimated intrinsic camera parameters. \param globalReprojectionError : Global reprojection error or global residual. \param verbose : Set at true if information about the residual at each loop of the algorithm is hoped. @@ -451,7 +463,7 @@ int vpCalibration::computeCalibration(vpCalibrationMethodType method, */ int vpCalibration::computeCalibrationMulti(vpCalibrationMethodType method, std::vector<vpCalibration> &table_cal, - vpCameraParameters& cam, + vpCameraParameters& cam_est, double &globalReprojectionError, bool verbose) { @@ -459,7 +471,7 @@ int vpCalibration::computeCalibrationMulti(vpCalibrationMethodType method, unsigned int nbPose = (unsigned int) table_cal.size(); for(unsigned int i=0;i<nbPose;i++){ if(table_cal[i].get_npt()>3) - table_cal[i].computePose(cam,table_cal[i].cMo); + table_cal[i].computePose(cam_est,table_cal[i].cMo); } switch (method) { case CALIB_LAGRANGE : @@ -469,9 +481,9 @@ int vpCalibration::computeCalibrationMulti(vpCalibrationMethodType method, return -1 ; } else { - table_cal[0].calibLagrange(cam,table_cal[0].cMo); - table_cal[0].cam = cam ; - table_cal[0].cam_dist = cam ; + table_cal[0].calibLagrange(cam_est,table_cal[0].cMo); + table_cal[0].cam = cam_est ; + table_cal[0].cam_dist = cam_est ; table_cal[0].cMo_dist = table_cal[0].cMo ; } break; @@ -484,22 +496,22 @@ int vpCalibration::computeCalibrationMulti(vpCalibrationMethodType method, return -1 ; } else { - table_cal[0].calibLagrange(cam,table_cal[0].cMo); - table_cal[0].cam = cam ; - table_cal[0].cam_dist = cam ; + table_cal[0].calibLagrange(cam_est,table_cal[0].cMo); + table_cal[0].cam = cam_est ; + table_cal[0].cam_dist = cam_est ; table_cal[0].cMo_dist = table_cal[0].cMo ; } case CALIB_VIRTUAL_VS: case CALIB_VIRTUAL_VS_DIST: { - calibVVSMulti(table_cal, cam, globalReprojectionError, verbose); + calibVVSMulti(table_cal, cam_est, globalReprojectionError, verbose); } break ; } //Print camera parameters if(verbose){ // std::cout << "Camera parameters without distortion :" << std::endl; - cam.printParameters(); + cam_est.printParameters(); } switch (method) @@ -515,7 +527,7 @@ int vpCalibration::computeCalibrationMulti(vpCalibrationMethodType method, if(verbose) std::cout << "Compute camera parameters with distortion"<<std::endl; - calibVVSWithDistortionMulti(table_cal, cam, globalReprojectionError, verbose); + calibVVSWithDistortionMulti(table_cal, cam_est, globalReprojectionError, verbose); } break ; } @@ -524,7 +536,7 @@ int vpCalibration::computeCalibrationMulti(vpCalibrationMethodType method, // std::cout << "Camera parameters without distortion :" << std::endl; table_cal[0].cam.printParameters(); // std::cout << "Camera parameters with distortion:" << std::endl; - cam.printParameters(); + cam_est.printParameters(); std::cout<<std::endl; } return 0 ; @@ -635,13 +647,17 @@ int vpCalibration::readData(const char* filename) vpImagePoint ip; std::ifstream f; f.open(filename); - if (f != NULL){ - int n ; + if (! f.fail()){ + unsigned int n ; f >> n ; std::cout << "There are "<< n <<" point on the calibration grid " << std::endl ; clearPoint() ; - for (int i=0 ; i < n ; i++) + + if (n > 100000) + throw(vpException(vpException::badValue, "Bad number of point in the calibration grid")); + + for (unsigned int i=0 ; i < n ; i++) { double x, y, z, u, v ; f >> x >> y >> z >> u >> v ; @@ -680,7 +696,7 @@ int vpCalibration::readGrid(const char* filename, unsigned int &n, try{ std::ifstream f; f.open(filename); - if (f != NULL){ + if (! f.fail()){ f >> n ; if(verbose) @@ -693,6 +709,9 @@ int vpCalibration::readGrid(const char* filename, unsigned int &n, oY.clear(); oZ.clear(); + if (n > 100000) + throw(vpException(vpException::badValue, "Bad number of point in the calibration grid")); + for (unsigned int i=0 ; i < n ; i++) { f >> no_pt >> x >> y >> z ; @@ -760,7 +779,6 @@ int vpCalibration::displayGrid(vpImage<unsigned char> &I, vpColor color, for (unsigned int i =0 ; i < npt ; i++) { - double oX = *it_LoX; double oY = *it_LoY; double oZ = *it_LoZ; @@ -814,7 +832,7 @@ int vpCalibration::displayGrid(vpImage<unsigned char> &I, vpColor color, \param method : Method used to estimate the camera parameters. \param nbPose : number of images used to compute multi-images calibration \param table_cal : array of vpCalibration. - \param cam : intrinsic camera parameters. + \param cam_est : estimated intrinsic camera parameters. \param verbose : set at true if information about the residual at each loop of the algorithm is hoped. @@ -823,13 +841,13 @@ int vpCalibration::displayGrid(vpImage<unsigned char> &I, vpColor color, int vpCalibration::computeCalibrationMulti(vpCalibrationMethodType method, unsigned int nbPose, vpCalibration table_cal[], - vpCameraParameters& cam, + vpCameraParameters& cam_est, bool verbose) { try{ for(unsigned int i=0;i<nbPose;i++){ if(table_cal[i].get_npt()>3) - table_cal[i].computePose(cam,table_cal[i].cMo); + table_cal[i].computePose(cam_est,table_cal[i].cMo); } switch (method) { case CALIB_LAGRANGE : @@ -839,9 +857,9 @@ int vpCalibration::computeCalibrationMulti(vpCalibrationMethodType method, return -1 ; } else { - table_cal[0].calibLagrange(cam,table_cal[0].cMo); - table_cal[0].cam = cam ; - table_cal[0].cam_dist = cam ; + table_cal[0].calibLagrange(cam_est,table_cal[0].cMo); + table_cal[0].cam = cam_est ; + table_cal[0].cam_dist = cam_est ; table_cal[0].cMo_dist = table_cal[0].cMo ; } break; @@ -854,22 +872,22 @@ int vpCalibration::computeCalibrationMulti(vpCalibrationMethodType method, return -1 ; } else { - table_cal[0].calibLagrange(cam,table_cal[0].cMo); - table_cal[0].cam = cam ; - table_cal[0].cam_dist = cam ; + table_cal[0].calibLagrange(cam_est,table_cal[0].cMo); + table_cal[0].cam = cam_est ; + table_cal[0].cam_dist = cam_est ; table_cal[0].cMo_dist = table_cal[0].cMo ; } case CALIB_VIRTUAL_VS: case CALIB_VIRTUAL_VS_DIST: { - calibVVSMulti(nbPose, table_cal, cam, verbose); + calibVVSMulti(nbPose, table_cal, cam_est, verbose); } break ; } //Print camera parameters if(verbose){ // std::cout << "Camera parameters without distortion :" << std::endl; - cam.printParameters(); + cam_est.printParameters(); } switch (method) @@ -885,7 +903,7 @@ int vpCalibration::computeCalibrationMulti(vpCalibrationMethodType method, if(verbose) std::cout << "Compute camera parameters with distortion"<<std::endl; - calibVVSWithDistortionMulti(nbPose, table_cal, cam, verbose); + calibVVSWithDistortionMulti(nbPose, table_cal, cam_est, verbose); } break ; } @@ -894,7 +912,7 @@ int vpCalibration::computeCalibrationMulti(vpCalibrationMethodType method, // std::cout << "Camera parameters without distortion :" << std::endl; table_cal[0].cam.printParameters(); // std::cout << "Camera parameters with distortion:" << std::endl; - cam.printParameters(); + cam_est.printParameters(); std::cout<<std::endl; } return 0 ; @@ -981,7 +999,7 @@ int vpCalibration::readGrid(const char* filename,unsigned int &n, try{ std::ifstream f; f.open(filename); - if (f != NULL){ + if (! f.fail()){ f >> n ; if(verbose) @@ -992,6 +1010,10 @@ int vpCalibration::readGrid(const char* filename,unsigned int &n, oX.front(); oY.front(); oZ.front(); + + if (n > 100000) + throw(vpException(vpException::badValue, "Bad number of point in the calibration grid")); + for (unsigned int i=0 ; i < n ; i++) { f >> no_pt >> x >> y >> z ; diff --git a/src/camera/calibration/vpCalibration.h b/src/camera/calibration/vpCalibration.h index a75150ccf3168b0bcb83d77fe00dd1a964e254c9..ed44d2f86dd97a9e1d0d353532de8c91f849c63b 100644 --- a/src/camera/calibration/vpCalibration.h +++ b/src/camera/calibration/vpCalibration.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpCalibration.h 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpCalibration.h 4663 2014-02-14 10:32:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -105,36 +105,30 @@ public: vpHomogeneousMatrix eMc_dist; public: - int init() ; - - //! Suppress all the point in the array of point - int clearPoint() ; - // Add a new point in this array - int addPoint(double X, double Y, double Z, vpImagePoint &ip) ; - - //! Constructor + // Constructor vpCalibration() ; + vpCalibration(const vpCalibration& c) ; - //! Destructor + // Destructor virtual ~vpCalibration() ; - //! = operator - void operator=(vpCalibration& twinCalibration ); - //!get the residual in pixels - double getResidual(void) const {return residual;} - //!get the residual for perspective projection with distortion (in pixels) - double getResidual_dist(void) const {return residual_dist;} - //!get the number of points - unsigned int get_npt() const {return npt;} + // Add a new point in this array + int addPoint(double X, double Y, double Z, vpImagePoint &ip) ; + + // = operator + vpCalibration& operator=(const vpCalibration& twinCalibration); static void calibrationTsai(std::vector<vpHomogeneousMatrix> &cMo, std::vector<vpHomogeneousMatrix> &rMe, vpHomogeneousMatrix &eMc); + //! Suppress all the point in the array of point + int clearPoint() ; + void computeStdDeviation(double &deviation, double &deviation_dist); int computeCalibration(vpCalibrationMethodType method, - vpHomogeneousMatrix &cMo, - vpCameraParameters &cam, + vpHomogeneousMatrix &cMo_est, + vpCameraParameters &cam_est, bool verbose = false) ; static int computeCalibrationMulti(vpCalibrationMethodType method, std::vector<vpCalibration> &table_cal, @@ -145,17 +139,27 @@ public: static int computeCalibrationTsai(std::vector<vpCalibration> &table_cal, vpHomogeneousMatrix &eMc, vpHomogeneousMatrix &eMc_dist); - double computeStdDeviation(vpHomogeneousMatrix &cMo, - vpCameraParameters &cam); - double computeStdDeviation_dist(vpHomogeneousMatrix &cMo, - vpCameraParameters &cam); + double computeStdDeviation(const vpHomogeneousMatrix &cMo_est, + const vpCameraParameters &camera); + double computeStdDeviation_dist(const vpHomogeneousMatrix &cMo, + const vpCameraParameters &cam); int displayData(vpImage<unsigned char> &I, vpColor color=vpColor::red, unsigned int thickness=1) ; int displayGrid(vpImage<unsigned char> &I, vpColor color=vpColor::yellow, unsigned int thickness=1) ; - //!set the gain for the virtual visual servoing algorithm + //! Set the gain for the virtual visual servoing algorithm. static double getLambda(){return gain;} + + //!get the residual in pixels + double getResidual(void) const {return residual;} + //!get the residual for perspective projection with distortion (in pixels) + double getResidual_dist(void) const {return residual_dist;} + //!get the number of points + unsigned int get_npt() const {return npt;} + + int init() ; + int readData(const char *filename) ; static int readGrid(const char *filename,unsigned int &n, std::list<double> &oX, std::list<double> &oY, std::list<double> &oZ, diff --git a/src/camera/calibration/vpCalibrationException.h b/src/camera/calibration/vpCalibrationException.h index 4e83a6080701f4e5d42c806e27620f935fcfa190..17724202e736513e67d2a54bad563545e24ed56d 100644 --- a/src/camera/calibration/vpCalibrationException.h +++ b/src/camera/calibration/vpCalibrationException.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpCalibrationException.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpCalibrationException.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -70,12 +70,12 @@ */ class VISP_EXPORT vpCalibrationException : public vpException { -public: - /*! + public: + /*! \brief Lists the possible error than can be emmited while calling vpCalibration member */ - enum errorCodeEnum + enum errorCodeEnum { //! error returns by a constructor constructionError, @@ -90,25 +90,19 @@ public: forbiddenOperatorError, } ; -public: - vpCalibrationException (const int code, const char * msg) - : vpException(code, msg){ ; } - vpCalibrationException (const int code, const std::string & msg) - : vpException(code, msg){ ; } - vpCalibrationException (const int code) - : vpException(code){ ; } - // vpMatrixException() : vpException() { ;} + public: + vpCalibrationException (const int id, const char* format, ...) + { + this->code = id; + va_list args; + va_start(args, format); + setMessage(format, args); + va_end (args); + } + vpCalibrationException (const int id, const std::string & msg) + : vpException(id, msg){ ; } + vpCalibrationException (const int id) + : vpException(id){ ; } }; - - - - -#endif /* #ifndef __vpCalibrationException_ERROR_H */ - - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ +#endif diff --git a/src/camera/calibration/vpCalibrationTools.cpp b/src/camera/calibration/vpCalibrationTools.cpp index 54a7c0e21d53fb2218df65342ba94a48b308516b..37230606e1e6fe817a4d450286a49face4589343 100644 --- a/src/camera/calibration/vpCalibrationTools.cpp +++ b/src/camera/calibration/vpCalibrationTools.cpp @@ -10,8 +10,7 @@ #undef MIN void -vpCalibration::calibLagrange( - vpCameraParameters &cam, vpHomogeneousMatrix &cMo) +vpCalibration::calibLagrange(vpCameraParameters &cam_est, vpHomogeneousMatrix &cMo_est) { vpMatrix A(2*npt,3) ; @@ -141,7 +140,7 @@ vpCalibration::calibLagrange( resul[3] = sqrt(sol[6]*sol[6]+sol[7]*sol[7]+sol[8]*sol[8] /* py */ -resul[1]*resul[1]); - cam.initPersProjWithoutDistortion(resul[2],resul[3],resul[0],resul[1]); + cam_est.initPersProjWithoutDistortion(resul[2],resul[3],resul[0],resul[1]); resul[4] = (sol[9]-sol[11]*resul[0])/resul[2]; /* X0 */ resul[5] = (sol[10]-sol[11]*resul[1])/resul[3]; /* Y0 */ @@ -159,12 +158,12 @@ vpCalibration::calibLagrange( for (unsigned int i=0 ; i < 3 ; i++) { for (unsigned int j=0 ; j < 3 ; j++) - cMo[i][j] = rd[i][j]; + cMo_est[i][j] = rd[i][j]; } - for (unsigned int i=0 ; i < 3 ; i++) cMo[i][3] = resul[i+4] ; + for (unsigned int i=0 ; i < 3 ; i++) cMo_est[i][3] = resul[i+4] ; - this->cMo = cMo ; - this->cMo_dist = cMo; + this->cMo = cMo_est ; + this->cMo_dist = cMo_est; double deviation,deviation_dist; this->computeStdDeviation(deviation,deviation_dist); @@ -173,11 +172,11 @@ vpCalibration::calibLagrange( void -vpCalibration::calibVVS( - vpCameraParameters &cam, - vpHomogeneousMatrix &cMo, - bool verbose) +vpCalibration::calibVVS(vpCameraParameters &cam_est, + vpHomogeneousMatrix &cMo_est, + bool verbose) { + std::ios::fmtflags original_flags( std::cout.flags() ); std::cout.precision(10); unsigned int n_points = npt ; @@ -199,7 +198,6 @@ vpCalibration::calibVVS( for (unsigned int i =0 ; i < n_points ; i++) { - oX[i] = *it_LoX; oY[i] = *it_LoY; oZ[i] = *it_LoZ; @@ -209,7 +207,6 @@ vpCalibration::calibVVS( u[i] = ip.get_u() ; v[i] = ip.get_v() ; - ++it_LoX; ++it_LoY; ++it_LoZ; @@ -223,22 +220,21 @@ vpCalibration::calibVVS( double r =1e12-1; while (vpMath::equal(residu_1,r,threshold) == false && iter < nbIterMax) { - iter++ ; residu_1 = r ; - double px = cam.get_px(); - double py = cam.get_py(); - double u0 = cam.get_u0(); - double v0 = cam.get_v0(); + double px = cam_est.get_px(); + double py = cam_est.get_py(); + double u0 = cam_est.get_u0(); + double v0 = cam_est.get_v0(); r = 0 ; for (unsigned int i=0 ; i < n_points; i++) { - cX[i] = oX[i]*cMo[0][0]+oY[i]*cMo[0][1]+oZ[i]*cMo[0][2] + cMo[0][3]; - cY[i] = oX[i]*cMo[1][0]+oY[i]*cMo[1][1]+oZ[i]*cMo[1][2] + cMo[1][3]; - cZ[i] = oX[i]*cMo[2][0]+oY[i]*cMo[2][1]+oZ[i]*cMo[2][2] + cMo[2][3]; + cX[i] = oX[i]*cMo_est[0][0]+oY[i]*cMo_est[0][1]+oZ[i]*cMo_est[0][2] + cMo_est[0][3]; + cY[i] = oX[i]*cMo_est[1][0]+oY[i]*cMo_est[1][1]+oZ[i]*cMo_est[1][2] + cMo_est[1][3]; + cZ[i] = oX[i]*cMo_est[2][0]+oY[i]*cMo_est[2][1]+oZ[i]*cMo_est[2][2] + cMo_est[2][3]; Pd[2*i] = u[i] ; Pd[2*i+1] = v[i] ; @@ -249,7 +245,6 @@ vpCalibration::calibVVS( r += ((vpMath::sqr(P[2*i]-Pd[2*i]) + vpMath::sqr(P[2*i+1]-Pd[2*i+1]))) ; } - vpColVector error ; error = P-Pd ; //r = r/n_points ; @@ -257,7 +252,6 @@ vpCalibration::calibVVS( vpMatrix L(n_points*2,10) ; for (unsigned int i=0 ; i < n_points; i++) { - double x = cX[i] ; double y = cY[i] ; double z = cZ[i] ; @@ -267,7 +261,6 @@ vpCalibration::calibVVS( double Y = y*inv_z ; //--------------- - { L[2*i][0] = px * (-inv_z) ; L[2*i][1] = 0 ; @@ -296,8 +289,6 @@ vpCalibration::calibVVS( L[2*i+1][8]= 0; L[2*i+1][9]= Y ; } - - } // end interaction vpMatrix Lp ; Lp = L.pseudoInverse(1e-10) ; @@ -312,10 +303,10 @@ vpCalibration::calibVVS( for (unsigned int i=0 ; i <6 ; i++) Tc_v[i] = Tc[i] ; - cam.initPersProjWithoutDistortion(px+Tc[8],py+Tc[9], + cam_est.initPersProjWithoutDistortion(px+Tc[8],py+Tc[9], u0+Tc[6],v0+Tc[7]) ; - cMo = vpExponentialMap::direct(Tc_v).inverse()*cMo ; + cMo_est = vpExponentialMap::direct(Tc_v).inverse()*cMo_est ; if (verbose) std::cout << " std dev " << sqrt(r/n_points) << std::endl; @@ -326,21 +317,23 @@ vpCalibration::calibVVS( throw(vpCalibrationException(vpCalibrationException::convergencyError, "Maximum number of iterations reached")) ; } - this->cMo = cMo; - this->cMo_dist = cMo; + this->cMo = cMo_est; + this->cMo_dist = cMo_est; this->residual = r; this->residual_dist = r; if (verbose) std::cout << " std dev " << sqrt(r/n_points) << std::endl; - + // Restore ostream format + std::cout.flags(original_flags); } void vpCalibration::calibVVSMulti(std::vector<vpCalibration> &table_cal, - vpCameraParameters &cam, + vpCameraParameters &cam_est, double &globalReprojectionError, bool verbose) { + std::ios::fmtflags original_flags( std::cout.flags() ); std::cout.precision(10); unsigned int nbPoint[256]; //number of points by image unsigned int nbPointTotal = 0; //total number of points @@ -353,6 +346,12 @@ vpCalibration::calibVVSMulti(std::vector<vpCalibration> &table_cal, nbPointTotal += nbPoint[i]; } + if (nbPointTotal < 4) { + //vpERROR_TRACE("Not enough point to calibrate"); + throw(vpCalibrationException(vpCalibrationException::notInitializedError, + "Not enough point to calibrate")) ; + } + vpColVector oX(nbPointTotal), cX(nbPointTotal) ; vpColVector oY(nbPointTotal), cY(nbPointTotal) ; vpColVector oZ(nbPointTotal), cZ(nbPointTotal) ; @@ -400,10 +399,10 @@ vpCalibration::calibVVSMulti(std::vector<vpCalibration> &table_cal, iter++ ; residu_1 = r ; - double px = cam.get_px(); - double py = cam.get_py(); - double u0 = cam.get_u0(); - double v0 = cam.get_v0(); + double px = cam_est.get_px(); + double py = cam_est.get_py(); + double u0 = cam_est.get_u0(); + double v0 = cam_est.get_v0(); r = 0 ; curPoint = 0 ; //current point indice @@ -504,7 +503,7 @@ vpCalibration::calibVVSMulti(std::vector<vpCalibration> &table_cal, for (unsigned int i = 0 ; i < nbPose6 ; i++) Tc_v[i] = Tc[i] ; - cam.initPersProjWithoutDistortion(px+Tc[nbPose6+2], + cam_est.initPersProjWithoutDistortion(px+Tc[nbPose6+2], py+Tc[nbPose6+3], u0+Tc[nbPose6], v0+Tc[nbPose6+1]) ; @@ -534,20 +533,22 @@ vpCalibration::calibVVSMulti(std::vector<vpCalibration> &table_cal, for (unsigned int p = 0 ; p < nbPose ; p++) { table_cal[p].cMo_dist = table_cal[p].cMo ; - table_cal[p].cam = cam; - table_cal[p].cam_dist = cam; + table_cal[p].cam = cam_est; + table_cal[p].cam_dist = cam_est; double deviation,deviation_dist; table_cal[p].computeStdDeviation(deviation,deviation_dist); } globalReprojectionError = sqrt(r/nbPointTotal); + // Restore ostream format + std::cout.flags(original_flags); } void -vpCalibration::calibVVSWithDistortion( - vpCameraParameters& cam, - vpHomogeneousMatrix& cMo, - bool verbose) +vpCalibration::calibVVSWithDistortion(vpCameraParameters& cam_est, + vpHomogeneousMatrix& cMo_est, + bool verbose) { + std::ios::fmtflags original_flags( std::cout.flags() ); std::cout.precision(10); unsigned int n_points =npt ; @@ -590,23 +591,21 @@ vpCalibration::calibVVSWithDistortion( double r =1e12-1; while (vpMath::equal(residu_1,r,threshold) == false && iter < nbIterMax) { - iter++ ; residu_1 = r ; - r = 0 ; - double u0 = cam.get_u0() ; - double v0 = cam.get_v0() ; + double u0 = cam_est.get_u0() ; + double v0 = cam_est.get_v0() ; - double px = cam.get_px() ; - double py = cam.get_py() ; + double px = cam_est.get_px() ; + double py = cam_est.get_py() ; double inv_px = 1/px ; double inv_py = 1/py ; - double kud = cam.get_kud() ; - double kdu = cam.get_kdu() ; + double kud = cam_est.get_kud() ; + double kdu = cam_est.get_kdu() ; double k2ud = 2*kud; double k2du = 2*kdu; @@ -619,9 +618,9 @@ vpCalibration::calibVVSWithDistortion( unsigned int i42 = 4*i+2; unsigned int i43 = 4*i+3; - cX[i] = oX[i]*cMo[0][0]+oY[i]*cMo[0][1]+oZ[i]*cMo[0][2] + cMo[0][3]; - cY[i] = oX[i]*cMo[1][0]+oY[i]*cMo[1][1]+oZ[i]*cMo[1][2] + cMo[1][3]; - cZ[i] = oX[i]*cMo[2][0]+oY[i]*cMo[2][1]+oZ[i]*cMo[2][2] + cMo[2][3]; + cX[i] = oX[i]*cMo_est[0][0]+oY[i]*cMo_est[0][1]+oZ[i]*cMo_est[0][2] + cMo_est[0][3]; + cY[i] = oX[i]*cMo_est[1][0]+oY[i]*cMo_est[1][1]+oZ[i]*cMo_est[1][2] + cMo_est[1][3]; + cZ[i] = oX[i]*cMo_est[2][0]+oY[i]*cMo_est[2][1]+oZ[i]*cMo_est[2][2] + cMo_est[2][3]; double x = cX[i] ; double y = cY[i] ; @@ -670,7 +669,6 @@ vpCalibration::calibVVSWithDistortion( P[i42] = u0 + px*X*kr2ud ; P[i43] = v0 + py*Y*kr2ud ; - r += (vpMath::sqr(P[i4]-Pd[i4]) + vpMath::sqr(P[i41]-Pd[i41]) + vpMath::sqr(P[i42]-Pd[i42]) + @@ -762,12 +760,12 @@ vpCalibration::calibVVSWithDistortion( for (unsigned int i=0 ; i <6 ; i++) Tc_v[i] = Tc[i] ; - cam.initPersProjWithDistortion(px + Tc[8], py + Tc[9], + cam_est.initPersProjWithDistortion(px + Tc[8], py + Tc[9], u0 + Tc[6], v0 + Tc[7], kud + Tc[11], kdu + Tc[10]); - cMo = vpExponentialMap::direct(Tc_v).inverse()*cMo ; + cMo_est = vpExponentialMap::direct(Tc_v).inverse()*cMo_est ; if (verbose) std::cout << " std dev " << sqrt(r/n_points) << std::endl; @@ -779,19 +777,23 @@ vpCalibration::calibVVSWithDistortion( "Maximum number of iterations reached")) ; } this->residual_dist = r; - this->cMo_dist = cMo ; - this->cam_dist = cam ; + this->cMo_dist = cMo_est ; + this->cam_dist = cam_est ; if (verbose) std::cout << " std dev " << sqrt(r/n_points) << std::endl; + + // Restore ostream format + std::cout.flags(original_flags); } void vpCalibration::calibVVSWithDistortionMulti(std::vector<vpCalibration> &table_cal, - vpCameraParameters &cam, double &globalReprojectionError, + vpCameraParameters &cam_est, double &globalReprojectionError, bool verbose) { + std::ios::fmtflags original_flags( std::cout.flags() ); std::cout.precision(10); unsigned int nbPoint[1024]; //number of points by image unsigned int nbPointTotal = 0; //total number of points @@ -803,6 +805,13 @@ vpCalibration::calibVVSWithDistortionMulti(std::vector<vpCalibration> &table_cal nbPointTotal += nbPoint[i]; } + if (nbPointTotal < 4) + { + //vpERROR_TRACE("Not enough point to calibrate"); + throw(vpCalibrationException(vpCalibrationException::notInitializedError, + "Not enough point to calibrate")) ; + } + vpColVector oX(nbPointTotal), cX(nbPointTotal) ; vpColVector oY(nbPointTotal), cY(nbPointTotal) ; vpColVector oZ(nbPointTotal), cZ(nbPointTotal) ; @@ -869,16 +878,16 @@ vpCalibration::calibVVSWithDistortionMulti(std::vector<vpCalibration> &table_cal vpMatrix L(nbPointTotal*4,nbPose6+6) ; curPoint = 0 ; //current point indice - double px = cam.get_px() ; - double py = cam.get_py() ; - double u0 = cam.get_u0() ; - double v0 = cam.get_v0() ; + double px = cam_est.get_px() ; + double py = cam_est.get_py() ; + double u0 = cam_est.get_u0() ; + double v0 = cam_est.get_v0() ; double inv_px = 1/px ; double inv_py = 1/py ; - double kud = cam.get_kud() ; - double kdu = cam.get_kdu() ; + double kud = cam_est.get_kud() ; + double kdu = cam_est.get_kdu() ; double k2ud = 2*kud; double k2du = 2*kdu; @@ -1031,7 +1040,7 @@ vpCalibration::calibVVSWithDistortionMulti(std::vector<vpCalibration> &table_cal for (unsigned int i = 0 ; i < 6*nbPose ; i++) Tc_v[i] = Tc[i] ; - cam.initPersProjWithDistortion( px+Tc[nbPose6+2], py+Tc[nbPose6+3], + cam_est.initPersProjWithDistortion( px+Tc[nbPose6+2], py+Tc[nbPose6+3], u0+Tc[nbPose6], v0+Tc[nbPose6+1], kud + Tc[nbPose6+5], kdu + Tc[nbPose6+4]); @@ -1062,12 +1071,15 @@ vpCalibration::calibVVSWithDistortionMulti(std::vector<vpCalibration> &table_cal int totalPoints = 0; for (unsigned int p = 0 ; p < nbPose ; p++) { - table_cal[p].cam_dist = cam ; - perViewError = table_cal[p].computeStdDeviation_dist(table_cal[p].cMo_dist, cam); + table_cal[p].cam_dist = cam_est ; + perViewError = table_cal[p].computeStdDeviation_dist(table_cal[p].cMo_dist, cam_est); totalError += perViewError*perViewError * table_cal[p].npt; totalPoints += (int)table_cal[p].npt; } globalReprojectionError = sqrt(r/(nbPointTotal)); + + // Restore ostream format + std::cout.flags(original_flags); } #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS @@ -1488,9 +1500,10 @@ void vpCalibration::calibrationTsai(std::vector<vpHomogeneousMatrix>& cMo, void vpCalibration::calibVVSMulti(unsigned int nbPose, vpCalibration table_cal[], - vpCameraParameters &cam, + vpCameraParameters &cam_est, bool verbose) { + std::ios::fmtflags original_flags( std::cout.flags() ); std::cout.precision(10); unsigned int nbPoint[256]; //number of points by image unsigned int nbPointTotal = 0; //total number of points @@ -1503,6 +1516,13 @@ vpCalibration::calibVVSMulti(unsigned int nbPose, nbPointTotal += nbPoint[i]; } + if (nbPointTotal < 4) + { + //vpERROR_TRACE("Not enough point to calibrate"); + throw(vpCalibrationException(vpCalibrationException::notInitializedError, + "Not enough point to calibrate")) ; + } + vpColVector oX(nbPointTotal), cX(nbPointTotal) ; vpColVector oY(nbPointTotal), cY(nbPointTotal) ; vpColVector oZ(nbPointTotal), cZ(nbPointTotal) ; @@ -1550,10 +1570,10 @@ vpCalibration::calibVVSMulti(unsigned int nbPose, iter++ ; residu_1 = r ; - double px = cam.get_px(); - double py = cam.get_py(); - double u0 = cam.get_u0(); - double v0 = cam.get_v0(); + double px = cam_est.get_px(); + double py = cam_est.get_py(); + double u0 = cam_est.get_u0(); + double v0 = cam_est.get_v0(); r = 0 ; curPoint = 0 ; //current point indice @@ -1654,7 +1674,7 @@ vpCalibration::calibVVSMulti(unsigned int nbPose, for (unsigned int i = 0 ; i < nbPose6 ; i++) Tc_v[i] = Tc[i] ; - cam.initPersProjWithoutDistortion(px+Tc[nbPose6+2], + cam_est.initPersProjWithoutDistortion(px+Tc[nbPose6+2], py+Tc[nbPose6+3], u0+Tc[nbPose6], v0+Tc[nbPose6+1]) ; @@ -1683,13 +1703,16 @@ vpCalibration::calibVVSMulti(unsigned int nbPose, for (unsigned int p = 0 ; p < nbPose ; p++) { table_cal[p].cMo_dist = table_cal[p].cMo ; - table_cal[p].cam = cam; - table_cal[p].cam_dist = cam; + table_cal[p].cam = cam_est; + table_cal[p].cam_dist = cam_est; double deviation,deviation_dist; table_cal[p].computeStdDeviation(deviation,deviation_dist); } if (verbose) std::cout << " Global std dev " << sqrt(r/nbPointTotal) << std::endl; + + // Restore ostream format + std::cout.flags(original_flags); } @@ -1697,9 +1720,10 @@ void vpCalibration::calibVVSWithDistortionMulti( unsigned int nbPose, vpCalibration table_cal[], - vpCameraParameters &cam, + vpCameraParameters &cam_est, bool verbose) { + std::ios::fmtflags original_flags( std::cout.flags() ); std::cout.precision(10); unsigned int nbPoint[1024]; //number of points by image unsigned int nbPointTotal = 0; //total number of points @@ -1711,6 +1735,13 @@ vpCalibration::calibVVSWithDistortionMulti( nbPointTotal += nbPoint[i]; } + if (nbPointTotal < 4) + { + //vpERROR_TRACE("Not enough point to calibrate"); + throw(vpCalibrationException(vpCalibrationException::notInitializedError, + "Not enough point to calibrate")) ; + } + vpColVector oX(nbPointTotal), cX(nbPointTotal) ; vpColVector oY(nbPointTotal), cY(nbPointTotal) ; vpColVector oZ(nbPointTotal), cZ(nbPointTotal) ; @@ -1777,16 +1808,16 @@ vpCalibration::calibVVSWithDistortionMulti( vpMatrix L(nbPointTotal*4,nbPose6+6) ; curPoint = 0 ; //current point indice - double px = cam.get_px() ; - double py = cam.get_py() ; - double u0 = cam.get_u0() ; - double v0 = cam.get_v0() ; + double px = cam_est.get_px() ; + double py = cam_est.get_py() ; + double u0 = cam_est.get_u0() ; + double v0 = cam_est.get_v0() ; double inv_px = 1/px ; double inv_py = 1/py ; - double kud = cam.get_kud() ; - double kdu = cam.get_kdu() ; + double kud = cam_est.get_kud() ; + double kdu = cam_est.get_kdu() ; double k2ud = 2*kud; double k2du = 2*kdu; @@ -1939,7 +1970,7 @@ vpCalibration::calibVVSWithDistortionMulti( for (unsigned int i = 0 ; i < 6*nbPose ; i++) Tc_v[i] = Tc[i] ; - cam.initPersProjWithDistortion( px+Tc[nbPose6+2], py+Tc[nbPose6+3], + cam_est.initPersProjWithDistortion( px+Tc[nbPose6+2], py+Tc[nbPose6+3], u0+Tc[nbPose6], v0+Tc[nbPose6+1], kud + Tc[nbPose6+5], kdu + Tc[nbPose6+4]); @@ -1967,10 +1998,12 @@ vpCalibration::calibVVSWithDistortionMulti( for (unsigned int p = 0 ; p < nbPose ; p++) { - table_cal[p].cam_dist = cam ; - table_cal[p].computeStdDeviation_dist(table_cal[p].cMo_dist, - cam); + table_cal[p].cam_dist = cam_est ; + table_cal[p].computeStdDeviation_dist(table_cal[p].cMo_dist, cam_est); } if (verbose) std::cout <<" Global std dev " << sqrt(r/(nbPointTotal)) << std::endl; + + // Restore ostream format + std::cout.flags(original_flags); } diff --git a/src/camera/vpCameraParameters.cpp b/src/camera/vpCameraParameters.cpp index ef7d8c79664276e703c55ad0b6af8d311a464ce3..abffc7becebbdf26118acb85c7b1a19f02349deb 100644 --- a/src/camera/vpCameraParameters.cpp +++ b/src/camera/vpCameraParameters.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpCameraParameters.cpp 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpCameraParameters.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -54,6 +54,9 @@ #include <visp/vpRotationMatrix.h> #include <cmath> #include <limits> +#include <iostream> +#include <sstream> +#include <iomanip> const double vpCameraParameters::DEFAULT_PX_PARAMETER = 600.0; const double vpCameraParameters::DEFAULT_PY_PARAMETER = 600.0; @@ -72,12 +75,15 @@ const vpCameraParameters::vpCameraParametersProjType \sa init() */ vpCameraParameters::vpCameraParameters() + : + px(DEFAULT_PX_PARAMETER), py(DEFAULT_PY_PARAMETER), + u0(DEFAULT_U0_PARAMETER), v0(DEFAULT_V0_PARAMETER), + kud(DEFAULT_KUD_PARAMETER), kdu(DEFAULT_KDU_PARAMETER), + width(0), height(0), + isFov(false), fovAngleX(0), fovAngleY(0), fovNormals(), + inv_px(1./DEFAULT_PX_PARAMETER), inv_py(1./DEFAULT_PY_PARAMETER), + projModel(DEFAULT_PROJ_TYPE) { - isFov = false; - fovAngleX = 0; - fovAngleY = 0; - width = 0; - height = 0; init() ; } @@ -85,6 +91,14 @@ vpCameraParameters::vpCameraParameters() Copy constructor */ vpCameraParameters::vpCameraParameters(const vpCameraParameters &c) + : + px(DEFAULT_PX_PARAMETER), py(DEFAULT_PY_PARAMETER), + u0(DEFAULT_U0_PARAMETER), v0(DEFAULT_V0_PARAMETER), + kud(DEFAULT_KUD_PARAMETER), kdu(DEFAULT_KDU_PARAMETER), + width(0), height(0), + isFov(false), fovAngleX(0), fovAngleY(0), fovNormals(), + inv_px(1./DEFAULT_PX_PARAMETER), inv_py(1./DEFAULT_PY_PARAMETER), + projModel(DEFAULT_PROJ_TYPE) { init(c) ; } @@ -92,40 +106,46 @@ vpCameraParameters::vpCameraParameters(const vpCameraParameters &c) /*! Constructor for perspective projection without distortion model - \param px,py : pixel size - \param u0,v0 : principal points + \param cam_px,cam_py : pixel size + \param cam_u0,cam_v0 : principal points */ -vpCameraParameters::vpCameraParameters(const double px, const double py, - const double u0, const double v0) +vpCameraParameters::vpCameraParameters(const double cam_px, const double cam_py, + const double cam_u0, const double cam_v0) + : + px(DEFAULT_PX_PARAMETER), py(DEFAULT_PY_PARAMETER), + u0(DEFAULT_U0_PARAMETER), v0(DEFAULT_V0_PARAMETER), + kud(DEFAULT_KUD_PARAMETER), kdu(DEFAULT_KDU_PARAMETER), + width(0), height(0), + isFov(false), fovAngleX(0), fovAngleY(0), fovNormals(), + inv_px(1./DEFAULT_PX_PARAMETER), inv_py(1./DEFAULT_PY_PARAMETER), + projModel(DEFAULT_PROJ_TYPE) { - isFov = false; - fovAngleX = 0; - fovAngleY = 0; - width = 0; - height = 0; - initPersProjWithoutDistortion(px,py,u0,v0) ; + initPersProjWithoutDistortion(cam_px,cam_py,cam_u0,cam_v0) ; } /*! Constructor for perspective projection with distortion model - \param px,py : pixel size - \param u0,v0 : principal points - \param kud : undistorted to distorted radial distortion - \param kdu : distorted to undistorted radial distortion + \param cam_px,cam_py : pixel size + \param cam_u0,cam_v0 : principal points + \param cam_kud : undistorted to distorted radial distortion + \param cam_kdu : distorted to undistorted radial distortion */ -vpCameraParameters::vpCameraParameters(const double px, const double py, - const double u0, const double v0, - const double kud, const double kdu) +vpCameraParameters::vpCameraParameters(const double cam_px, const double cam_py, + const double cam_u0, const double cam_v0, + const double cam_kud, const double cam_kdu) + : + px(DEFAULT_PX_PARAMETER), py(DEFAULT_PY_PARAMETER), + u0(DEFAULT_U0_PARAMETER), v0(DEFAULT_V0_PARAMETER), + kud(DEFAULT_KUD_PARAMETER), kdu(DEFAULT_KDU_PARAMETER), + width(0), height(0), + isFov(false), fovAngleX(0), fovAngleY(0), fovNormals(), + inv_px(1./DEFAULT_PX_PARAMETER), inv_py(1./DEFAULT_PY_PARAMETER), + projModel(DEFAULT_PROJ_TYPE) { - isFov = false; - fovAngleX = 0; - fovAngleY = 0; - width = 0; - height = 0; - initPersProjWithDistortion(px,py,u0,v0,kud,kdu) ; + initPersProjWithDistortion(cam_px,cam_py,cam_u0,cam_v0,cam_kud,cam_kdu) ; } /*! @@ -133,16 +153,7 @@ vpCameraParameters::vpCameraParameters(const double px, const double py, */ void vpCameraParameters::init() -{ - this->projModel = DEFAULT_PROJ_TYPE ; - - this->px = DEFAULT_PX_PARAMETER ; - this->py = DEFAULT_PY_PARAMETER ; - this->u0 = DEFAULT_U0_PARAMETER ; - this->v0 = DEFAULT_V0_PARAMETER ; - this->kud = DEFAULT_KUD_PARAMETER ; - this->kdu = DEFAULT_KDU_PARAMETER ; - +{ if (fabs(this->px)<1e-6) { vpERROR_TRACE("Camera parameter px = 0") ; @@ -162,19 +173,19 @@ vpCameraParameters::init() /*! Initialization with specific parameters using perpective projection without distortion model. - \param px,py : pixel size - \param u0,v0 : principal point + \param cam_px,cam_py : pixel size + \param cam_u0,cam_v0 : principal point */ void -vpCameraParameters::initPersProjWithoutDistortion(const double px, - const double py, const double u0, const double v0) +vpCameraParameters::initPersProjWithoutDistortion(const double cam_px, const double cam_py, + const double cam_u0, const double cam_v0) { this->projModel = vpCameraParameters::perspectiveProjWithoutDistortion ; - this->px = px ; - this->py = py ; - this->u0 = u0 ; - this->v0 = v0 ; + this->px = cam_px ; + this->py = cam_py ; + this->u0 = cam_u0 ; + this->v0 = cam_v0 ; this->kud = 0 ; this->kdu = 0 ; @@ -197,24 +208,24 @@ vpCameraParameters::initPersProjWithoutDistortion(const double px, /*! Initialization with specific parameters using perpective projection with distortion model. - \param px,py : pixel size - \param u0,v0 : principal points - \param kud : undistorted to distorted radial distortion - \param kdu : distorted to undistorted radial distortion + \param cam_px,cam_py : pixel size + \param cam_u0,cam_v0 : principal points + \param cam_kud : undistorted to distorted radial distortion + \param cam_kdu : distorted to undistorted radial distortion */ void -vpCameraParameters::initPersProjWithDistortion(const double px, const double py, - const double u0, const double v0, - const double kud, const double kdu) +vpCameraParameters::initPersProjWithDistortion(const double cam_px, const double cam_py, + const double cam_u0, const double cam_v0, + const double cam_kud, const double cam_kdu) { this->projModel = vpCameraParameters::perspectiveProjWithDistortion ; - this->px = px ; - this->py = py ; - this->u0 = u0 ; - this->v0 = v0 ; - this->kud = kud ; - this->kdu = kdu ; + this->px = cam_px ; + this->py = cam_py ; + this->u0 = cam_u0 ; + this->v0 = cam_v0 ; + this->kud = cam_kud ; + this->kdu = cam_kdu ; if (fabs(px)<1e-6) { @@ -447,6 +458,7 @@ vpCameraParameters::get_K_inverse() const void vpCameraParameters::printParameters() { + std::ios::fmtflags original_flags( std::cout.flags() ); switch(projModel){ case vpCameraParameters::perspectiveProjWithoutDistortion : std::cout.precision(10); @@ -465,6 +477,8 @@ vpCameraParameters::printParameters() std::cout << " kdu = " << kdu << std::endl ; break; } + // Restore ostream format + std::cout.flags(original_flags); } /*! @@ -473,37 +487,33 @@ vpCameraParameters::printParameters() \param os : Output stream. \param cam : Camera parameters. */ -std::ostream & operator << (std::ostream & os, - const vpCameraParameters &cam) +VISP_EXPORT std::ostream & operator << (std::ostream & os, const vpCameraParameters &cam) { switch(cam.get_projModel()){ - case vpCameraParameters::perspectiveProjWithoutDistortion : - os << "Camera parameters for perspective projection without distortion:" - << std::endl ; - os << " px = " << cam.get_px() <<"\t py = "<< cam.get_py() - << std::endl ; - os << " u0 = " << cam.get_u0() <<"\t v0 = "<< cam.get_v0() - << std::endl ; - break; - case vpCameraParameters::perspectiveProjWithDistortion : - os.precision(10); - os << "Camera parameters for perspective projection with distortion:" - << std::endl ; - os << " px = " << cam.get_px() <<"\t py = "<< cam.get_py() - << std::endl ; - os << " u0 = " << cam.get_u0() <<"\t v0 = "<< cam.get_v0() - << std::endl ; - os << " kud = " << cam.get_kud() << std::endl ; - os << " kdu = " << cam.get_kdu() << std::endl ; - break; - } + case vpCameraParameters::perspectiveProjWithoutDistortion : + os << "Camera parameters for perspective projection without distortion:" + << std::endl ; + os << " px = " << cam.get_px() <<"\t py = "<< cam.get_py() + << std::endl ; + os << " u0 = " << cam.get_u0() <<"\t v0 = "<< cam.get_v0() + << std::endl ; + break; + case vpCameraParameters::perspectiveProjWithDistortion : + std::ios_base::fmtflags original_flags = os.flags(); + os.precision(10); + os << "Camera parameters for perspective projection with distortion:" + << std::endl ; + os << " px = " << cam.get_px() <<"\t py = "<< cam.get_py() + << std::endl ; + os << " u0 = " << cam.get_u0() <<"\t v0 = "<< cam.get_v0() + << std::endl ; + os << " kud = " << cam.get_kud() << std::endl ; + os << " kdu = " << cam.get_kdu() << std::endl ; + + os.flags(original_flags); // restore os to standard state + break; + } return os; } -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ - diff --git a/src/camera/vpCameraParameters.h b/src/camera/vpCameraParameters.h index 3bd73d4528a57421f57720fce5723f34fd8ecfde..633cb4ac764b6321752fb2f4d6386980801f97ff 100644 --- a/src/camera/vpCameraParameters.h +++ b/src/camera/vpCameraParameters.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpCameraParameters.h 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpCameraParameters.h 4620 2014-01-27 21:28:32Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -299,8 +299,7 @@ public : vpMatrix get_K_inverse() const; void printParameters() ; - friend VISP_EXPORT std::ostream & operator << (std::ostream & os, - const vpCameraParameters &cam); + friend VISP_EXPORT std::ostream & operator << (std::ostream & os, const vpCameraParameters &cam); private: static const double DEFAULT_U0_PARAMETER; @@ -327,7 +326,6 @@ private: double inv_px, inv_py; vpCameraParametersProjType projModel ; //!< used projection model - } ; #endif diff --git a/src/camera/vpMeterPixelConversion.cpp b/src/camera/vpMeterPixelConversion.cpp index 726e2f16fd6d271f98e7a112ac893d2a43947ec2..a2aedf70f6a0859cbfcb25e5fc3c73872223d703 100644 --- a/src/camera/vpMeterPixelConversion.cpp +++ b/src/camera/vpMeterPixelConversion.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMeterPixelConversion.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMeterPixelConversion.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/camera/vpMeterPixelConversion.h b/src/camera/vpMeterPixelConversion.h index 13a00c41f9a011de9bbebc703d2a06170100b55a..4e030f6bc4fb83c5a71ea62cd29d2b05f9f49829 100644 --- a/src/camera/vpMeterPixelConversion.h +++ b/src/camera/vpMeterPixelConversion.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMeterPixelConversion.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMeterPixelConversion.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/camera/vpPixelMeterConversion.cpp b/src/camera/vpPixelMeterConversion.cpp index acf73b82544e9cb40c8975a5cbdbb81ed0449574..ae35c1da3dc4a58765dc44de5f472065458fc95a 100644 --- a/src/camera/vpPixelMeterConversion.cpp +++ b/src/camera/vpPixelMeterConversion.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpPixelMeterConversion.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpPixelMeterConversion.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/camera/vpPixelMeterConversion.h b/src/camera/vpPixelMeterConversion.h index 698f53f0af0bc9fb4b1c769e8a1f164aff0972d8..f93f24f719aa87ca243966a111c77fdccbf1a5fc 100644 --- a/src/camera/vpPixelMeterConversion.h +++ b/src/camera/vpPixelMeterConversion.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpPixelMeterConversion.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpPixelMeterConversion.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/camera/vpXmlParserCamera.cpp b/src/camera/vpXmlParserCamera.cpp index a2e0fc0491a7b04f75892f223a8866e9d1cb320c..59ecf5e4dd29ce89627ed7bd94817d26f70ffc0b 100644 --- a/src/camera/vpXmlParserCamera.cpp +++ b/src/camera/vpXmlParserCamera.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpXmlParserCamera.cpp 4270 2013-06-25 12:15:16Z fspindle $ + * $Id: vpXmlParserCamera.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -80,20 +80,22 @@ /*! Default constructor */ -vpXmlParserCamera::vpXmlParserCamera(): vpXmlParser(){ - camera_name = ""; - image_width = 0; - image_height = 0; - subsampling_width = 0; - subsampling_height = 0; - full_width = 0; - full_height = 0; +vpXmlParserCamera::vpXmlParserCamera() + : vpXmlParser(), + camera(), camera_name(), image_width(0), image_height(0), + subsampling_width(0), subsampling_height(0), full_width(0), full_height(0) +{ } /*! Copy constructor \param twinParser : parser object to copy */ -vpXmlParserCamera::vpXmlParserCamera(vpXmlParserCamera& twinParser): vpXmlParser(twinParser){ +vpXmlParserCamera::vpXmlParserCamera(vpXmlParserCamera& twinParser) + : vpXmlParser(twinParser), + camera(), camera_name(), image_width(0), image_height(0), + subsampling_width(0), subsampling_height(0), full_width(0), full_height(0) + +{ this->camera = twinParser.camera; this->camera_name = twinParser.camera_name; this->image_width = twinParser.image_width; @@ -126,22 +128,22 @@ vpXmlParserCamera::operator =(const vpXmlParserCamera& twinParser) { Parse an xml file to load camera parameters. \param cam : camera parameters to fill. \param filename : name of the xml file to parse - \param camera_name : name of the camera : useful if the xml file has multiple + \param cam_name : name of the camera : useful if the xml file has multiple camera parameters. Set as "" if the camera name is not ambiguous. \param projModel : camera projection model needed. - \param image_width : image width on which camera calibration was performed. + \param im_width : image width on which camera calibration was performed. Set as 0 if not ambiguous. - \param image_height : image height on which camera calibration was performed. + \param im_height : image height on which camera calibration was performed. Set as 0 if not ambiguous. \return error code. */ int vpXmlParserCamera::parse(vpCameraParameters &cam, const char * filename, - const std::string& camera_name, + const std::string& cam_name, const vpCameraParameters::vpCameraParametersProjType &projModel, - const unsigned int image_width, - const unsigned int image_height) + const unsigned int im_width, + const unsigned int im_height) { xmlDocPtr doc; xmlNodePtr node; @@ -159,7 +161,7 @@ vpXmlParserCamera::parse(vpCameraParameters &cam, const char * filename, return SEQUENCE_ERROR; } - int ret = this ->read (doc, node, camera_name, projModel, image_width, image_height); + int ret = this ->read (doc, node, cam_name, projModel, im_width, im_height); cam = camera ; @@ -172,20 +174,20 @@ vpXmlParserCamera::parse(vpCameraParameters &cam, const char * filename, Save camera parameters in an xml file. \param cam : camera parameters to save. \param filename : name of the xml file to fill. - \param camera_name : name of the camera : useful if the xml file has multiple + \param cam_name : name of the camera : useful if the xml file has multiple camera parameters. Set as "" if the camera name is not ambiguous. - \param image_width : width of image on which camera calibration was performed. + \param im_width : width of image on which camera calibration was performed. Set as 0 if not ambiguous. - \param image_height : height of the image on which camera calibration was performed. + \param im_height : height of the image on which camera calibration was performed. Set as 0 if not ambiguous. \return error code. */ int vpXmlParserCamera::save(const vpCameraParameters &cam, const char * filename, - const std::string& camera_name, - const unsigned int image_width, - const unsigned int image_height) + const std::string& cam_name, + const unsigned int im_width, + const unsigned int im_height) { xmlDocPtr doc; xmlNodePtr node; @@ -215,8 +217,8 @@ vpXmlParserCamera::save(const vpCameraParameters &cam, const char * filename, this->camera = cam; - int nbCamera = count(doc, node, camera_name,cam.get_projModel(), - image_width, image_height); + int nbCamera = count(doc, node, cam_name,cam.get_projModel(), + im_width, im_height); if( nbCamera > 0){ // vpCERROR << nbCamera // << " set(s) of camera parameters is(are) already "<< std::endl @@ -248,27 +250,27 @@ vpXmlParserCamera::save(const vpCameraParameters &cam, const char * filename, \param doc : XML file. \param node : XML tree, pointing on a marker equipement. - \param camera_name : name of the camera : useful if the xml file has multiple + \param cam_name : name of the camera : useful if the xml file has multiple camera parameters. Set as "" if the camera name is not ambiguous. - \param image_width : width of image on which camera calibration was performed. + \param im_width : width of image on which camera calibration was performed. Set as 0 if not ambiguous. - \param image_height : height of the image on which camera calibration + \param im_height : height of the image on which camera calibration was performed. Set as 0 if not ambiguous. - \param subsampling_width : subsampling of the image width sent by the camera. + \param subsampl_width : subsampling of the image width sent by the camera. Set as 0 if not ambiguous. - \param subsampling_height : subsampling of the image height sent by the camera. + \param subsampl_height : subsampling of the image height sent by the camera. Set as 0 if not ambiguous. \return error code. */ int vpXmlParserCamera::read (xmlDocPtr doc, xmlNodePtr node, - const std::string& camera_name, + const std::string& cam_name, const vpCameraParameters::vpCameraParametersProjType &projModel, - const unsigned int image_width, - const unsigned int image_height, - const unsigned int subsampling_width, - const unsigned int subsampling_height) + const unsigned int im_width, + const unsigned int im_height, + const unsigned int subsampl_width, + const unsigned int subsampl_height) { // char * val_char; vpXmlCodeType prop; @@ -299,8 +301,8 @@ vpXmlParserCamera::read (xmlDocPtr doc, xmlNodePtr node, } */ if (prop == CODE_XML_CAMERA){ - if (SEQUENCE_OK == this->read_camera (doc, node, camera_name, projModel, - image_width, image_height, subsampling_width, subsampling_height)) + if (SEQUENCE_OK == this->read_camera (doc, node, cam_name, projModel, + im_width, im_height, subsampl_width, subsampl_height)) nbCamera++; } else back = SEQUENCE_ERROR; @@ -326,27 +328,27 @@ vpXmlParserCamera::read (xmlDocPtr doc, xmlNodePtr node, \param doc : XML file. \param node : XML tree, pointing on a marker equipement. - \param camera_name : name of the camera : useful if the xml file has multiple + \param cam_name : name of the camera : useful if the xml file has multiple camera parameters. Set as "" if the camera name is not ambiguous. - \param image_width : width of image on which camera calibration was performed. + \param im_width : width of image on which camera calibration was performed. Set as 0 if not ambiguous. - \param image_height : height of the image on which camera calibration + \param im_height : height of the image on which camera calibration was performed. Set as 0 if not ambiguous. - \param subsampling_width : subsampling of the image width sent by the camera. + \param subsampl_width : subsampling of the image width sent by the camera. Set as 0 if not ambiguous. - \param subsampling_height : subsampling of the image height sent by the camera. + \param subsampl_height : subsampling of the image height sent by the camera. Set as 0 if not ambiguous. \return number of available camera parameters corresponding with inputs. */ int vpXmlParserCamera::count (xmlDocPtr doc, xmlNodePtr node, - const std::string& camera_name, + const std::string& cam_name, const vpCameraParameters::vpCameraParametersProjType &projModel, - const unsigned int image_width, - const unsigned int image_height, - const unsigned int subsampling_width, - const unsigned int subsampling_height) + const unsigned int im_width, + const unsigned int im_height, + const unsigned int subsampl_width, + const unsigned int subsampl_height) { // char * val_char; vpXmlCodeType prop; @@ -374,9 +376,9 @@ vpXmlParserCamera::count (xmlDocPtr doc, xmlNodePtr node, } */ if (prop== CODE_XML_CAMERA) { - if (SEQUENCE_OK == this->read_camera (doc, node, camera_name, projModel, - image_width, image_height, - subsampling_width, subsampling_height)) + if (SEQUENCE_OK == this->read_camera (doc, node, cam_name, projModel, + im_width, im_height, + subsampl_width, subsampl_height)) nbCamera++; } } @@ -389,26 +391,26 @@ vpXmlParserCamera::count (xmlDocPtr doc, xmlNodePtr node, \param doc : XML file. \param node : XML tree, pointing on a marker equipement. - \param camera_name : name of the camera : useful if the xml file has multiple + \param cam_name : name of the camera : useful if the xml file has multiple camera parameters. Set as "" if the camera name is not ambiguous. - \param image_width : width of image on which camera calibration was performed. + \param im_width : width of image on which camera calibration was performed. Set as 0 if not ambiguous. - \param image_height : height of the image on which camera calibration + \param im_height : height of the image on which camera calibration was performed. Set as 0 if not ambiguous. - \param subsampling_width : subsampling of the image width sent by the camera. + \param subsampl_width : subsampling of the image width sent by the camera. Set as 0 if not ambiguous. - \param subsampling_height : subsampling of the image height sent by the camera. + \param subsampl_height : subsampling of the image height sent by the camera. Set as 0 if not ambiguous. \return number of available camera parameters corresponding with inputs. */ xmlNodePtr vpXmlParserCamera::find_camera (xmlDocPtr doc, xmlNodePtr node, - const std::string& camera_name, - const unsigned int image_width, - const unsigned int image_height, - const unsigned int subsampling_width, - const unsigned int subsampling_height) + const std::string& cam_name, + const unsigned int im_width, + const unsigned int im_height, + const unsigned int subsampl_width, + const unsigned int subsampl_height) { // char * val_char; vpXmlCodeType prop; @@ -435,9 +437,9 @@ vpXmlParserCamera::find_camera (xmlDocPtr doc, xmlNodePtr node, } */ if(prop == CODE_XML_CAMERA){ - if (SEQUENCE_OK == this->read_camera_header(doc, node, camera_name, - image_width, image_height, - subsampling_width, subsampling_height)) + if (SEQUENCE_OK == this->read_camera_header(doc, node, cam_name, + im_width, im_height, + subsampl_width, subsampl_height)) return node; } } @@ -449,15 +451,15 @@ vpXmlParserCamera::find_camera (xmlDocPtr doc, xmlNodePtr node, \param doc : XML file. \param node : XML tree, pointing on a marker equipement. - \param camera_name : name of the camera : useful if the xml file has multiple + \param cam_name : name of the camera : useful if the xml file has multiple camera parameters. Set as "" if the camera name is not ambiguous. - \param image_width : width of image on which camera calibration was performed. + \param im_width : width of image on which camera calibration was performed. Set as 0 if not ambiguous. - \param image_height : height of the image on which camera calibration + \param im_height : height of the image on which camera calibration was performed. Set as 0 if not ambiguous. - \param subsampling_width : scale of the image width sent by the camera. + \param subsampl_width : scale of the image width sent by the camera. Set as 0 if not ambiguous. - \param subsampling_height : scale of the image height sent by the camera. + \param subsampl_height : scale of the image height sent by the camera. Set as 0 if not ambiguous. \return error code. @@ -465,12 +467,12 @@ vpXmlParserCamera::find_camera (xmlDocPtr doc, xmlNodePtr node, */ int vpXmlParserCamera::read_camera (xmlDocPtr doc, xmlNodePtr node, - const std::string& camera_name, + const std::string& cam_name, const vpCameraParameters::vpCameraParametersProjType &projModel, - const unsigned int image_width, - const unsigned int image_height, - const unsigned int subsampling_width, - const unsigned int subsampling_height) + const unsigned int im_width, + const unsigned int im_height, + const unsigned int subsampl_width, + const unsigned int subsampl_height) { vpXmlCodeType prop; /* read value in the XML file. */ @@ -552,13 +554,21 @@ vpXmlParserCamera::read_camera (xmlDocPtr doc, xmlNodePtr node, } } - if( !((projModelFound == true) && (camera_name == camera_name_tmp) && - (abs((int)image_width - (int)image_width_tmp) < allowedPixelDiffOnImageSize || image_width == 0) && - (abs((int)image_height - (int)image_height_tmp) < allowedPixelDiffOnImageSize || image_height == 0) && - ( subsampling_width == 0 || - abs((int)subsampling_width - (int)subsampling_width_tmp) < (allowedPixelDiffOnImageSize * (int)(subsampling_width_tmp / subsampling_width)))&& - ( subsampling_height == 0 || - abs((int)subsampling_height - (int)subsampling_height_tmp) < (allowedPixelDiffOnImageSize * (int)(subsampling_width_tmp / subsampling_width))))){ + // Create a specific test for subsampling_width and subsampling_height to ensure that division by zero is not possible in the next test + bool test_subsampling_width = true; + bool test_subsampling_height = true; + + if (subsampling_width) { + test_subsampling_width = (abs((int)subsampl_width - (int)subsampling_width_tmp) < (allowedPixelDiffOnImageSize * (int)(subsampling_width_tmp / subsampling_width))); + } + if (subsampling_height) { + test_subsampling_height = (abs((int)subsampl_height - (int)subsampling_height_tmp) < (allowedPixelDiffOnImageSize * (int)(subsampling_height_tmp / subsampling_height))); + } + if( !((projModelFound == true) && (cam_name == camera_name_tmp) && + (abs((int)im_width - (int)image_width_tmp) < allowedPixelDiffOnImageSize || im_width == 0) && + (abs((int)im_height - (int)image_height_tmp) < allowedPixelDiffOnImageSize || im_height == 0) && + (test_subsampling_width)&& + (test_subsampling_height))){ back = SEQUENCE_ERROR; } else{ @@ -578,15 +588,15 @@ vpXmlParserCamera::read_camera (xmlDocPtr doc, xmlNodePtr node, \param doc : XML file. \param node : XML tree, pointing on a marker equipement. - \param camera_name : name of the camera : useful if the xml file has multiple + \param cam_name : name of the camera : useful if the xml file has multiple camera parameters. Set as "" if the camera name is not ambiguous. - \param image_width : width of image on which camera calibration was performed. + \param im_width : width of image on which camera calibration was performed. Set as 0 if not ambiguous. - \param image_height : height of the image on which camera calibration + \param im_height : height of the image on which camera calibration was performed. Set as 0 if not ambiguous. - \param subsampling_width : scale of the image width sent by the camera. + \param subsampl_width : scale of the image width sent by the camera. Set as 0 if not ambiguous. - \param subsampling_height : scale of the image height sent by the camera. + \param subsampl_height : scale of the image height sent by the camera. Set as 0 if not ambiguous. \return error code. @@ -595,11 +605,11 @@ vpXmlParserCamera::read_camera (xmlDocPtr doc, xmlNodePtr node, int vpXmlParserCamera:: read_camera_header (xmlDocPtr doc, xmlNodePtr node, - const std::string& camera_name, - const unsigned int image_width, - const unsigned int image_height, - const unsigned int subsampling_width, - const unsigned int subsampling_height) + const std::string& cam_name, + const unsigned int im_width, + const unsigned int im_height, + const unsigned int subsampl_width, + const unsigned int subsampl_height) { vpXmlCodeType prop; /* read value in the XML file. */ @@ -672,13 +682,13 @@ read_camera_header (xmlDocPtr doc, xmlNodePtr node, break; } } - if( !((camera_name == camera_name_tmp) && - (image_width == image_width_tmp || image_width == 0) && - (image_height == image_height_tmp || image_height == 0) && - (subsampling_width == subsampling_width_tmp || - subsampling_width == 0)&& - (subsampling_height == subsampling_height_tmp || - subsampling_height == 0))){ + if( !((cam_name == camera_name_tmp) && + (im_width == image_width_tmp || im_width == 0) && + (im_height == image_height_tmp || im_height == 0) && + (subsampl_width == subsampling_width_tmp || + subsampl_width == 0)&& + (subsampl_height == subsampling_height_tmp || + subsampl_height == 0))){ back = SEQUENCE_ERROR; } return back; @@ -780,14 +790,18 @@ vpXmlParserCamera::read_camera_model (xmlDocPtr doc, xmlNodePtr node, } } + if(model_type == NULL) { + vpERROR_TRACE("projection model type doesn't match with any known model !"); + return SEQUENCE_ERROR; + } + if( !strcmp(model_type,LABEL_XML_MODEL_WITHOUT_DISTORTION)){ if (nb != 5 || validation != 0x1F) { vpCERROR <<"ERROR in 'model' field:\n"; vpCERROR << "it must contain 5 parameters\n"; - if(model_type != NULL){ - xmlFree(model_type); - } + xmlFree(model_type); + return SEQUENCE_ERROR; } cam_tmp.initPersProjWithoutDistortion(px,py,u0,v0) ; @@ -797,23 +811,20 @@ vpXmlParserCamera::read_camera_model (xmlDocPtr doc, xmlNodePtr node, { vpCERROR <<"ERROR in 'model' field:\n"; vpCERROR << "it must contain 7 parameters\n"; - if(model_type != NULL){ - xmlFree(model_type); - } + xmlFree(model_type); + return SEQUENCE_ERROR; } cam_tmp.initPersProjWithDistortion(px,py,u0,v0,kud,kdu); } else{ vpERROR_TRACE("projection model type doesn't match with any known model !"); - if(model_type != NULL){ - xmlFree(model_type); - } - return SEQUENCE_ERROR; - } - if(model_type != NULL){ xmlFree(model_type); + + return SEQUENCE_ERROR; } + xmlFree(model_type); + return back; } @@ -821,24 +832,24 @@ vpXmlParserCamera::read_camera_model (xmlDocPtr doc, xmlNodePtr node, Write camera parameters in an XML Tree. \param node : XML tree, pointing on a marker equipement. - \param camera_name : name of the camera : useful if the xml file has multiple + \param cam_name : name of the camera : useful if the xml file has multiple camera parameters. Set as "" if the camera name is not ambiguous. - \param image_width : width of image on which camera calibration was performed. + \param im_width : width of image on which camera calibration was performed. Set as 0 if not ambiguous. - \param image_height : height of the image on which camera calibration + \param im_height : height of the image on which camera calibration was performed. Set as 0 if not ambiguous. - \param subsampling_width : subsampling of the image width sent by the camera. + \param subsampl_width : subsampling of the image width sent by the camera. Set as 0 if not ambiguous. - \param subsampling_height : subsampling of the image height sent by the camera. + \param subsampl_height : subsampling of the image height sent by the camera. Set as 0 if not ambiguous. \return error code. */ int vpXmlParserCamera:: -write (xmlNodePtr node, const std::string& camera_name, - const unsigned int image_width, const unsigned int image_height, - const unsigned int subsampling_width, - const unsigned int subsampling_height) +write (xmlNodePtr node, const std::string& cam_name, + const unsigned int im_width, const unsigned int im_height, + const unsigned int subsampl_width, + const unsigned int subsampl_height) { int back = SEQUENCE_OK; @@ -851,46 +862,46 @@ write (xmlNodePtr node, const std::string& camera_name, { //<name> - if(!camera_name.empty()){ + if(!cam_name.empty()){ node_tmp = xmlNewComment((xmlChar*)"Name of the camera"); xmlAddChild(node_camera,node_tmp); xmlNewTextChild(node_camera,NULL,(xmlChar*)LABEL_XML_CAMERA_NAME, - (xmlChar*)camera_name.c_str()); + (xmlChar*)cam_name.c_str()); } - if(image_width != 0 || image_height != 0){ + if(im_width != 0 || im_height != 0){ char str[11]; //<image_width> node_tmp = xmlNewComment((xmlChar*)"Size of the image on which camera calibration was performed"); xmlAddChild(node_camera,node_tmp); - sprintf(str,"%u",image_width); + sprintf(str,"%u",im_width); xmlNewTextChild(node_camera,NULL,(xmlChar*)LABEL_XML_WIDTH,(xmlChar*)str); //<image_height> - sprintf(str,"%u",image_height); + sprintf(str,"%u",im_height); xmlNewTextChild(node_camera,NULL,(xmlChar*)LABEL_XML_HEIGHT,(xmlChar*)str); if(subsampling_width != 0 || subsampling_height != 0){ node_tmp = xmlNewComment((xmlChar*)"Subsampling used to obtain the current size of the image."); xmlAddChild(node_camera,node_tmp); //<subsampling_width> - sprintf(str,"%u",subsampling_width); + sprintf(str,"%u",subsampl_width); xmlNewTextChild(node_camera,NULL,(xmlChar*)LABEL_XML_SUBSAMPLING_WIDTH, (xmlChar*)str); //<subsampling_height> - sprintf(str,"%u",subsampling_height); + sprintf(str,"%u",subsampl_height); xmlNewTextChild(node_camera,NULL,(xmlChar*)LABEL_XML_SUBSAMPLING_HEIGHT, (xmlChar*)str); node_tmp = xmlNewComment((xmlChar*)"The full size is the sensor size actually used to grab the image. full_width = subsampling_width * image_width"); xmlAddChild(node_camera,node_tmp); //<full_width> - sprintf(str,"%u",image_width*subsampling_width); + sprintf(str,"%u",im_width*subsampl_width); xmlNewTextChild(node_camera,NULL,(xmlChar*)LABEL_XML_FULL_WIDTH, (xmlChar*)str); //<full_height> - sprintf(str,"%u",image_height*subsampling_height); + sprintf(str,"%u",im_height*subsampl_height); xmlNewTextChild(node_camera,NULL,(xmlChar*)LABEL_XML_FULL_HEIGHT, (xmlChar*)str); } diff --git a/src/camera/vpXmlParserCamera.h b/src/camera/vpXmlParserCamera.h index de24acd6e7765f95104b98de74602eda012641c6..f768641eb33397159ef61044e3c1e5d66362f029 100644 --- a/src/camera/vpXmlParserCamera.h +++ b/src/camera/vpXmlParserCamera.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpXmlParserCamera.h 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpXmlParserCamera.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -257,16 +257,16 @@ public: unsigned int getSubsampling_height(){return this->subsampling_height;} vpCameraParameters getCameraParameters(){return this->camera;} - void setCameraName(const std::string& camera_name){ - this->camera_name = camera_name; + void setCameraName(const std::string& name){ + this->camera_name = name; } void setWidth(const unsigned int width){ this->image_width = width ; } void setHeight(const unsigned int height){ this->image_height = height ; } - void setSubsampling_width(const unsigned int subsampling_width){ - this->subsampling_width = subsampling_width ; + void setSubsampling_width(const unsigned int subsampling){ + this->subsampling_width = subsampling ; } - void setSubsampling_height(const unsigned int subsampling_height){ - this->subsampling_height = subsampling_height ; + void setSubsampling_height(const unsigned int subsampling){ + this->subsampling_height = subsampling ; } private: diff --git a/src/computer-vision/homography-estimation/vpHomography.cpp b/src/computer-vision/homography-estimation/vpHomography.cpp index a16e81eb3999e4f3041655fa9898d7c43349dc74..cb4ee3033b8b06211789560a52d2d9b94a61bdd5 100644 --- a/src/computer-vision/homography-estimation/vpHomography.cpp +++ b/src/computer-vision/homography-estimation/vpHomography.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpHomography.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpHomography.cpp 4661 2014-02-10 19:34:58Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -47,55 +47,24 @@ the particular case of homography */ -#include <visp/vpHomography.h> +#include <stdio.h> + #include <visp/vpDebug.h> +#include <visp/vpHomography.h> #include <visp/vpMatrix.h> +#include <visp/vpRobust.h> // Exception #include <visp/vpException.h> #include <visp/vpMatrixException.h> -// Debug trace -#include <visp/vpDebug.h> - -#include <stdio.h> - - - -/*! - \brief initialiaze a 4x4 matrix as identity -*/ - -void -vpHomography::init() -{ - unsigned int i,j ; - - try { - vpMatrix::resize(3,3) ; - } - catch(vpException me) - { - vpERROR_TRACE("Error caught") ; - throw ; - } - - - for (i=0 ; i < 3 ; i++) - for (j=0 ; j < 3; j++) - if (i==j) - (*this)[i][j] = 1.0 ; - else - (*this)[i][j] = 0.0; - -} - /*! \brief initialize an homography as Identity */ -vpHomography::vpHomography() : vpMatrix() +vpHomography::vpHomography() : data(NULL), aMb(), bP() { - init() ; + data = new double [9]; + setIdentity(); } @@ -103,98 +72,87 @@ vpHomography::vpHomography() : vpMatrix() \brief initialize an homography from another homography */ -vpHomography::vpHomography(const vpHomography &aHb) : vpMatrix() +vpHomography::vpHomography(const vpHomography &H) : data(NULL), aMb(), bP() { - init() ; - *this = aHb ; + data = new double [9]; + + *this = H; } /*! \brief initialize an homography from another homography */ - -vpHomography::vpHomography(const vpHomogeneousMatrix &aMb, - const vpPlane &_bP) : vpMatrix() +vpHomography::vpHomography(const vpHomogeneousMatrix &M, const vpPlane &p) : data(NULL), aMb(), bP() { - - - init() ; - - buildFrom(aMb,_bP) ; - - + data = new double [9]; + buildFrom(M, p) ; } vpHomography::vpHomography(const vpThetaUVector &tu, - const vpTranslationVector &atb, - const vpPlane &_bP) : vpMatrix() + const vpTranslationVector &atb, + const vpPlane &p) : data(NULL), aMb(), bP() { - init() ; - buildFrom(tu,atb,_bP) ; + data = new double [9]; + buildFrom(tu, atb, p) ; } vpHomography::vpHomography(const vpRotationMatrix &aRb, - const vpTranslationVector &atb, - const vpPlane &_bP) : vpMatrix() + const vpTranslationVector &atb, + const vpPlane &p) : data(NULL), aMb(), bP() { - init() ; - buildFrom(aRb,atb,_bP) ; - } + data = new double [9]; + buildFrom(aRb, atb, p) ; +} -vpHomography::vpHomography(const vpPoseVector &arb, - const vpPlane &_bP) : vpMatrix() +vpHomography::vpHomography(const vpPoseVector &arb, const vpPlane &p) : data(NULL), aMb(), bP() { - - init() ; - buildFrom(arb,_bP) ; + data = new double [9]; + buildFrom(arb, p) ; } - +vpHomography::~vpHomography() +{ + if (data) + delete [] data; + data = NULL; +} void -vpHomography::buildFrom(const vpHomogeneousMatrix &aMb, - const vpPlane &_bP) +vpHomography::buildFrom(const vpHomogeneousMatrix &M, + const vpPlane &p) { - - - insert(aMb) ; - insert(_bP) ; + insert(M) ; + insert(p) ; build() ; - - } void vpHomography::buildFrom(const vpThetaUVector &tu, - const vpTranslationVector &atb, - const vpPlane &_bP) + const vpTranslationVector &atb, + const vpPlane &p) { - insert(tu) ; insert(atb) ; - insert(_bP) ; + insert(p) ; build() ; } void vpHomography::buildFrom(const vpRotationMatrix &aRb, - const vpTranslationVector &atb, - const vpPlane &_bP) + const vpTranslationVector &atb, + const vpPlane &p) { - init() ; insert(aRb) ; insert(atb) ; - insert(_bP) ; + insert(p) ; build() ; } void -vpHomography::buildFrom(const vpPoseVector &arb, - const vpPlane &_bP) +vpHomography::buildFrom(const vpPoseVector &arb, const vpPlane &p) { - aMb.buildFrom(arb[0],arb[1],arb[2],arb[3],arb[4],arb[5]) ; - insert(_bP) ; + insert(p) ; build() ; } @@ -204,31 +162,28 @@ vpHomography::buildFrom(const vpPoseVector &arb, /*! - \brief insert the rotational component and - recompute the homography + \brief insert the rotational component. + To recompute the homography call build(). */ void vpHomography::insert(const vpRotationMatrix &aRb) { aMb.insert(aRb) ; - //build() ; } + /*! - \brief insert the rotational component and - recompute the homography + \brief insert the rotational component. + To recompute the homography call build(). */ void -vpHomography::insert(const vpHomogeneousMatrix &_aMb) +vpHomography::insert(const vpHomogeneousMatrix &M) { - - aMb = _aMb ; - //build() ; + this->aMb = M ; } - /*! \brief insert the rotational component, insert a - theta u vector (transformation into a rotation matrix) and - recompute the homography + theta u vector (transformation into a rotation matrix). + To recompute the homography call build(). */ void @@ -236,56 +191,53 @@ vpHomography::insert(const vpThetaUVector &tu) { vpRotationMatrix aRb(tu) ; aMb.insert(aRb) ; - //build() ; } - /*! - \brief insert the translational component in a homography and - recompute the homography + \brief insert the translational component in a homography. + To recompute the homography call build(). */ void vpHomography::insert(const vpTranslationVector &atb) { aMb.insert(atb) ; - //build() ; } /*! - \brief insert the reference plane and - recompute the homography + \brief insert the reference plane. + To recompute the homography call build(). */ void -vpHomography::insert(const vpPlane &_bP) +vpHomography::insert(const vpPlane &p) { - - bP= _bP ; - //build() ; + this->bP = p; } - /*! - \brief invert the homography + \brief Invert the homography - - \return [H]^-1 + \return \f$\bf H^{-1}\f$ */ vpHomography vpHomography::inverse() const { - vpHomography bHa ; + vpMatrix M = (*this); + vpMatrix Minv; + M.pseudoInverse(Minv, 1e-16); + vpHomography H; - vpMatrix::pseudoInverse(bHa,1e-16) ; + for(unsigned int i=0; i<3; i++) + for(unsigned int j=0; j<3; j++) + H[i][j] = Minv[i][j]; - return bHa; + return H; } /*! - \brief invert the homography - + \brief Invert the homography. - \param bHa : [H]^-1 + \param bHa : \f$\bf H^{-1}\f$ with H = *this. */ void vpHomography::inverse(vpHomography &bHa) const @@ -297,14 +249,13 @@ vpHomography::inverse(vpHomography &bHa) const void vpHomography::save(std::ofstream &f) const { - if (f != NULL) + if (! f.fail()) { f << *this ; } else { - vpERROR_TRACE("\t\t file not open " ); - throw(vpException(vpException::ioError, "\t\t file not open")) ; + throw(vpException(vpException::ioError, "Cannot write the homography to the output stream")) ; } } @@ -328,7 +279,7 @@ vpHomography vpHomography::operator*(const vpHomography &H) const for(unsigned int j = 0; j < 3; j++) { double s = 0.; for(unsigned int k = 0; k < 3; k ++) { - s += (*this)[i][k] * H[k][j]; + s += (*this)[i][k] * H[k][j]; } Hp[i][j] = s; } @@ -336,6 +287,27 @@ vpHomography vpHomography::operator*(const vpHomography &H) const return Hp; } +/*! + Operation a = aHb * b. + + \param b : 3 dimension vector. +*/ +vpColVector +vpHomography::operator*(const vpColVector &b) const +{ + if (b.size() != 3) + throw(vpException(vpException::dimensionError, "Cannot multiply an homography by a vector of dimension %d", b.size())); + + vpColVector a(3); + for(unsigned int i=0; i<3; i++) { + a[i] = 0.; + for(unsigned int j=0; j<3; j++) + a[i] += (*this)[i][j] * b[j]; + } + + return a; +} + /*! Multiply an homography by a scalar. @@ -377,14 +349,67 @@ vpHomography vpHomography::operator*(const double &v) const vpHomography vpHomography::operator/(const double &v) const { vpHomography H; - double one_over_v = 1. / v; - + if (std::fabs(v) <= std::numeric_limits<double>::epsilon()) + throw vpMatrixException(vpMatrixException::divideByZeroError, "Divide by zero in method /=(double v)"); + + double vinv = 1/v ; + for (unsigned int i=0; i < 9; i ++) { - H.data[i] = this->data[i] * one_over_v; + H.data[i] = this->data[i] * vinv; } return H; } + +//! Divide all the element of the homography matrix by v : Hij = Hij / v +vpHomography & vpHomography::operator/=(double v) +{ + //if (x == 0) + if (std::fabs(v) <= std::numeric_limits<double>::epsilon()) + throw vpMatrixException(vpMatrixException::divideByZeroError, "Divide by zero in method /=(double v)"); + + double vinv = 1/v ; + + for (unsigned int i=0;i<9;i++) + data[i] *= vinv; + + return *this; +} + +/*! + Copy operator. + Allow operation such as aHb = H + + \param H : Homography matrix to be copied. +*/ +vpHomography & +vpHomography::operator=(const vpHomography &H) +{ + for (unsigned int i=0; i< 3; i++) + for (unsigned int j=0; j< 3; j++) + (*this)[i][j] = H[i][j]; + + return *this; +} +/*! + Copy operator. + Allow operation such as aHb = H + + \param H : Matrix to be copied. +*/ +vpHomography & +vpHomography::operator=(const vpMatrix &H) +{ + if (H.getRows() !=3 || H.getCols() != 3) + throw(vpException(vpException::dimensionError, "The matrix is not an homography")); + + for (unsigned int i=0; i< 3; i++) + for (unsigned int j=0; j< 3; j++) + (*this)[i][j] = H[i][j]; + + return *this; +} + /*! Read an homography in a file, verify if it is really an homogeneous matrix. @@ -394,29 +419,29 @@ vpHomography vpHomography::operator/(const double &v) const void vpHomography::load(std::ifstream &f) { - if (f != NULL) + if (! f.fail()) { for (unsigned int i=0 ; i < 3 ; i++) for (unsigned int j=0 ; j < 3 ; j++) { - f>> (*this)[i][j] ; + f >> (*this)[i][j] ; } } else { - vpERROR_TRACE("\t\t file not open " ); - throw(vpException(vpException::ioError, "\t\t file not open")) ; + throw(vpException(vpException::ioError, "Cannot read the homography from the input stream")) ; } } - -//! Print the matrix as a vector [T thetaU] +#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS +//! Print the homography as a matrix. void vpHomography::print() { std::cout <<*this << std::endl ; } +#endif // #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS /*! \brief Compute aHb such that @@ -428,23 +453,26 @@ vpHomography::print() void vpHomography::build() { - unsigned int i,j ; - vpColVector n(3) ; vpColVector atb(3) ; - for (i=0 ; i < 3 ; i++) + vpMatrix aRb(3,3); + for (unsigned int i=0 ; i < 3 ; i++) { - atb[i] = aMb[i][3] ; - for (j=0 ; j < 3 ; j++) (*this)[i][j] = aMb[i][j]; + atb[i] = aMb[i][3]; + for (unsigned int j=0 ; j < 3 ; j++) + aRb[i][j] = aMb[i][j]; } bP.getNormal(n) ; double d = bP.getD() ; - *this -= atb*n.t()/d ; // the d used in the equation is such as nX=d is the + vpMatrix aHb = aRb - atb*n.t()/d ; // the d used in the equation is such as nX=d is the // plane equation. So if the plane is described by // Ax+By+Cz+D=0, d=-D + for (unsigned int i=0 ; i < 3 ; i++) + for (unsigned int j=0 ; j < 3 ; j++) + (*this)[i][j] = aHb[i][j]; } /*! @@ -457,30 +485,284 @@ vpHomography::build() */ void vpHomography::build(vpHomography &aHb, - const vpHomogeneousMatrix &aMb, - const vpPlane &bP) + const vpHomogeneousMatrix &aMb, + const vpPlane &bP) { - unsigned int i,j ; - vpColVector n(3) ; vpColVector atb(3) ; - for (i=0 ; i < 3 ; i++) + vpMatrix aRb(3,3); + for (unsigned int i=0 ; i < 3 ; i++) { atb[i] = aMb[i][3] ; - for (j=0 ; j < 3 ; j++) aHb[i][j] = aMb[i][j]; + for (unsigned int j=0 ; j < 3 ; j++) + aRb[i][j] = aMb[i][j]; } bP.getNormal(n) ; double d = bP.getD() ; - aHb -= atb*n.t()/d ; // the d used in the equation is such as nX=d is the + vpMatrix aHb_ = aRb - atb*n.t()/d ; // the d used in the equation is such as nX=d is the // plane equation. So if the plane is described by // Ax+By+Cz+D=0, d=-D + for (unsigned int i=0 ; i < 3 ; i++) + for (unsigned int j=0 ; j < 3 ; j++) + aHb[i][j] = aHb_[i][j]; } -/* - * Local variables: - * c-basic-offset: 2 - * End: +/*! + Set the homography as identity transformation. +*/ +void +vpHomography::setIdentity() +{ + for (unsigned int i=0 ; i < 3 ; i++) + for (unsigned int j=0 ; j < 3; j++) + if (i==j) + (*this)[i][j] = 1.0 ; + else + (*this)[i][j] = 0.0; +} + +/*! + Given \c iPa a point with coordinates \f$(u_a,v_a)\f$ expressed in pixel in image a, and the homography \c bHa that + links image a and b, computes the coordinates of the point \f$(u_b,v_b)\f$ in the image b using the camera parameters + matrix \f$\bf K\f$. + + Compute \f$^b{\bf p} = {\bf K} \; {^b}{\bf H}_a \; {\bf K}^{-1} {^a}{\bf p}\f$ with \f$^a{\bf p}=(u_a,v_a,1)\f$ + and \f$^b{\bf p}=(u_b,v_b,1)\f$ + + \return The coordinates in pixel of the point with coordinates \f$(u_b,v_b)\f$. + */ +vpImagePoint vpHomography::project(const vpCameraParameters &cam, const vpHomography &bHa, const vpImagePoint &iPa) +{ + double xa = iPa.get_u(); + double ya = iPa.get_v(); + vpMatrix H = cam.get_K() * bHa * cam.get_K_inverse(); + double z = xa * H[2][0] + ya * H[2][1] + H[2][2]; + double xb = (xa * H[0][0] + ya * H[0][1] + H[0][2]) / z; + double yb = (xa * H[1][0] + ya * H[1][1] + H[1][2]) / z; + + vpImagePoint iPb(yb, xb); + + return iPb; +} +/*! + Given \c Pa a point with normalized coordinates \f$(x_a,y_a,1)\f$ in the image plane a, and the homography \c bHa that + links image a and b, computes the normalized coordinates of the point \f$(x_b,y_b,1)\f$ in the image plane b. + + Compute \f$^b{\bf p} = {^b}{\bf H}_a \; {^a}{\bf p}\f$ with \f$^a{\bf p}=(x_a,y_a,1)\f$ + and \f$^b{\bf p}=(x_b,y_b,1)\f$ + + \return The coordinates in meter of the point with coordinates \f$(x_b,y_b)\f$. + */ +vpPoint vpHomography::project(const vpHomography &bHa, const vpPoint &Pa) +{ + double xa = Pa.get_x(); + double ya = Pa.get_y(); + double z = xa * bHa[2][0] + ya * bHa[2][1] + bHa[2][2]; + double xb = (xa * bHa[0][0] + ya * bHa[0][1] + bHa[0][2]) / z; + double yb = (xa * bHa[1][0] + ya * bHa[1][1] + bHa[1][2]) / z; + + vpPoint Pb; + Pb.set_x(xb); + Pb.set_y(yb); + + return Pb; +} + +/*! + From couples of matched points \f$^a{\bf p}=(x_a,y_a,1)\f$ in image a + and \f$^b{\bf p}=(x_b,y_b,1)\f$ in image b with homogeneous coordinates, computes the + homography matrix by resolving \f$^a{\bf p} = ^a{\bf H}_b\; ^b{\bf p}\f$ + using a robust estimation scheme. + + This method is to compare to DLT() except that here a robust estimator is used to reject + couples of points that are considered as outliers. + + At least 4 couples of points are needed. + + \param xb, yb : Coordinates vector of matched points in image b. These coordinates are expressed in meters. + \param xa, ya : Coordinates vector of matched points in image a. These coordinates are expressed in meters. + \param aHb : Estimated homography that relies the transformation from image a to image b. + \param inliers : Vector that indicates if a matched point is an inlier (true) or an outlier (false). + \param residual : Global residual computed as + \f$r = \sqrt{1/n \sum_{inliers} {\| {^a{\bf p} - {\hat{^a{\bf H}_b}} {^b{\bf p}}} \|}^{2}}\f$ with \f$n\f$ the + number of inliers. + \param weights_threshold : Threshold applied on the weights updated during the robust estimation and + used to consider if a point is an outlier or an inlier. Values should be in [0:1]. + A couple of matched points that have a weight lower than this threshold is considered as an outlier. + A value equal to zero indicates that all the points are inliers. + \param niter : Number of iterations of the estimation process. + \param normalization : When set to true, the coordinates of the points are normalized. The normalization + carried out is the one preconized by Hartley. + + \sa DLT(), ransac() */ +void +vpHomography::robust(const std::vector<double> &xb, const std::vector<double> &yb, + const std::vector<double> &xa, const std::vector<double> &ya, + vpHomography &aHb, + std::vector<bool> &inliers, + double &residual, + double weights_threshold, + unsigned int niter, + bool normalization) +{ + unsigned int n = (unsigned int) xb.size(); + if (yb.size() != n || xa.size() != n || ya.size() != n) + throw(vpException(vpException::dimensionError, + "Bad dimension for robust homography estimation")); + + // 4 point are required + if(n<4) + throw(vpException(vpException::fatalError, "There must be at least 4 matched points")); + + try{ + std::vector<double> xan, yan, xbn, ybn; + + double xg1=0., yg1=0., coef1=0., xg2=0., yg2=0., coef2=0.; + + vpHomography aHbn; + + if (normalization) { + vpHomography::HartleyNormalization(xb, yb, xbn, ybn, xg1, yg1, coef1); + vpHomography::HartleyNormalization(xa, ya, xan, yan, xg2, yg2, coef2); + } + else { + xbn = xb; + ybn = yb; + xan = xa; + yan = ya; + } + + unsigned int nbLinesA = 2; + vpMatrix A(nbLinesA*n,8); + vpColVector X(8); + vpColVector Y(nbLinesA*n); + vpMatrix W(nbLinesA*n, nbLinesA*n) ; // Weight matrix + + vpColVector w(nbLinesA*n) ; + + // All the weights are set to 1 at the beginning to use a classical least square scheme + w = 1; + // Update the square matrix associated to the weights + for (unsigned int i=0; i < nbLinesA*n; i ++) { + W[i][i] = w[i]; + } + + // build matrix A + for(unsigned int i=0; i<n;i++) { + A[nbLinesA*i][0]=xbn[i]; + A[nbLinesA*i][1]=ybn[i]; + A[nbLinesA*i][2]=1; + A[nbLinesA*i][3]=0 ; + A[nbLinesA*i][4]=0 ; + A[nbLinesA*i][5]=0; + A[nbLinesA*i][6]=-xbn[i]*xan[i] ; + A[nbLinesA*i][7]=-ybn[i]*xan[i]; + + A[nbLinesA*i+1][0]=0 ; + A[nbLinesA*i+1][1]=0; + A[nbLinesA*i+1][2]=0; + A[nbLinesA*i+1][3]=xbn[i]; + A[nbLinesA*i+1][4]=ybn[i]; + A[nbLinesA*i+1][5]=1; + A[nbLinesA*i+1][6]=-xbn[i]*yan[i]; + A[nbLinesA*i+1][7]=-ybn[i]*yan[i]; + + Y[nbLinesA*i] = xan[i]; + Y[nbLinesA*i+1] = yan[i]; + } + + vpMatrix WA; + vpMatrix WAp; + unsigned int iter = 0; + vpRobust r(nbLinesA*n) ; // M-Estimator + + while (iter < niter) { + WA = W * A; + + X = WA.pseudoInverse(1e-26)*W*Y; + vpColVector residu; + residu = Y - A * X; + + // Compute the weights using the Tukey biweight M-Estimator + r.setIteration(iter) ; + r.MEstimator(vpRobust::TUKEY, residu, w) ; + + // Update the weights matrix + for (unsigned int i=0; i < n*nbLinesA; i ++) { + W[i][i] = w[i]; + } + // Build the homography + for(unsigned int i=0;i<8;i++) + aHbn.data[i]= X[i]; + aHbn[2][2] = 1; + { + vpMatrix aHbnorm = aHbn; + aHbnorm /= aHbnorm[2][2] ; + } + + iter ++; + } + inliers.resize(n); + unsigned int nbinliers = 0; + for(unsigned int i=0; i< n; i++) { + if (w[i*2] < weights_threshold && w[i*2+1] < weights_threshold) + inliers[i] = false; + else { + inliers[i] = true; + nbinliers ++; + } + } + + if (normalization) { + // H after denormalization + vpHomography::HartleyDenormalization(aHbn, aHb, xg1, yg1, coef1, xg2, yg2, coef2); + } + else { + aHb = aHbn; + } + + residual = 0 ; + vpColVector a(3), b(3), c(3); + for (unsigned int i=0 ; i < n ; i++) { + if (inliers[i]) { + a[0] = xa[i] ; a[1] = ya[i] ; a[2] = 1 ; + b[0] = xb[i] ; b[1] = yb[i] ; b[2] = 1 ; + + c = aHb*b ; c /= c[2] ; + residual += (a-c).sumSquare(); + } + } + + residual = sqrt(residual/nbinliers); + } + catch(...) + { + throw(vpException(vpException::fatalError, "Cannot estimate an homography")) ; + } +} + +/*! +\brief std::cout a matrix +*/ +VISP_EXPORT std::ostream &operator <<(std::ostream &s,const vpHomography &H) +{ + std::ios_base::fmtflags original_flags = s.flags(); + + s.precision(10) ; + for (unsigned int i=0;i<H.getRows();i++) { + for (unsigned int j=0;j<H.getCols();j++){ + s << H[i][j] << " "; + } + // We don't add a \n char on the end of the last matrix line + if (i < H.getRows()-1) + s << std::endl; + } + + s.flags(original_flags); // restore s to standard state + + return s; +} diff --git a/src/computer-vision/homography-estimation/vpHomography.h b/src/computer-vision/homography-estimation/vpHomography.h index f4d031bdd9ebdd6e0e26cf1c13212638e0ad5c0d..c7c885377c077e3f505ec4f59830db4640b8f4fb 100644 --- a/src/computer-vision/homography-estimation/vpHomography.h +++ b/src/computer-vision/homography-estimation/vpHomography.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpHomography.h 4276 2013-06-25 12:36:48Z fspindle $ + * $Id: vpHomography.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -51,14 +51,17 @@ tools for homography computation. #ifndef vpHomography_hh #define vpHomography_hh +#include <list> +#include <vector> + +#include <visp/vpCameraParameters.h> +#include <visp/vpImagePoint.h> #include <visp/vpHomogeneousMatrix.h> #include <visp/vpPlane.h> #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS # include <visp/vpList.h> #endif -#include <list> - /*! \class vpHomography @@ -84,7 +87,9 @@ tools for homography computation. { ^b{\bf n}^T} \f] - The example below shows how to manipulate this class to first + The \ref tutorial-homography explains how to use this class. + + The example below shows also how to manipulate this class to first compute a ground truth homography from camera poses, project pixel coordinates points using an homography and lastly estimate an homography from a subset of 4 matched points in frame a and frame b @@ -123,7 +128,7 @@ int main() // Compute the coordinates in pixels of the 4 object points in the // camera frame a vpPoint Pa[4]; - double xa[4], ya[4]; // Coordinates in pixels of the points in frame a + std::vector<double> xa(4), ya(4); // Coordinates in pixels of the points in frame a for(int i=0 ; i < 4 ; i++) { Pa[i] = Po[i]; Pa[i].project(aMo); // Project the points from object frame to @@ -136,7 +141,7 @@ int main() // Compute the coordinates in pixels of the 4 object points in the // camera frame b vpPoint Pb[4]; - double xb[4], yb[4]; // Coordinates in pixels of the points in frame b + std::vector<double> xb(4), yb(4); // Coordinates in pixels of the points in frame b for(int i=0 ; i < 4 ; i++) { Pb[i] = Po[i]; Pb[i].project(bMo); // Project the points from object frame to @@ -162,7 +167,7 @@ int main() } // Estimate the homography from 4 points coordinates expressed in pixels - vpHomography::HartleyDLT(4, xb, yb, xa, ya, aHb); + vpHomography::DLT(xb, yb, xa, ya, aHb, true); aHb /= aHb[2][2]; // Apply a scale factor to have aHb[2][2] = 1 std::cout << "Estimated homography aHb: \n" << aHb<< std::endl; @@ -170,211 +175,264 @@ int main() \endcode */ -class VISP_EXPORT vpHomography : public vpMatrix +class VISP_EXPORT vpHomography { - -private: - static const double sing_threshold; // = 0.0001; - static const double threshold_rotation; - static const double threshold_displacement; - vpHomogeneousMatrix aMb ; - // bool isplanar; - //! reference plane coordinates expressed in Rb - vpPlane bP ; - void init() ; - -private: - //! insert a rotation matrix - void insert(const vpHomogeneousMatrix &aRb) ; - //! insert a rotation matrix - void insert(const vpRotationMatrix &aRb) ; - //! insert a theta u vector (transformation into a rotation matrix) - void insert(const vpThetaUVector &tu) ; - //! insert a translation vector - void insert(const vpTranslationVector &atb) ; - //! insert a translation vector - void insert(const vpPlane &bP) ; - - static void initRansac(unsigned int n, - double *xb, double *yb, - double *xa, double *ya, - vpColVector &x) ; - -public: - static void HartleyNormalization(unsigned int n, - double *x, double *y, - double *xn, double *yn, - double &xg, double &yg, - double &coef); - static void HartleyDenormalization(vpHomography &aHbn, - vpHomography &aHb, - double xg1, double yg1, double coef1, - double xg2, double yg2, double coef2 ) ; - - - vpHomography() ; - - //! copy constructor - vpHomography(const vpHomography &aMb) ; - //! Construction from Translation and rotation and a plane - vpHomography(const vpHomogeneousMatrix &aMb, - const vpPlane &bP) ; - //! Construction from Translation and rotation and a plane - vpHomography(const vpRotationMatrix &aRb, - const vpTranslationVector &atb, - const vpPlane &bP) ; - //! Construction from Translation and rotation and a plane - vpHomography(const vpThetaUVector &tu, - const vpTranslationVector &atb, - const vpPlane &bP) ; - //! Construction from Translation and rotation and a plane - vpHomography(const vpPoseVector &arb, - const vpPlane &bP) ; - virtual ~vpHomography() { } - - //! Construction from Translation and rotation and a plane - void buildFrom(const vpRotationMatrix &aRb, - const vpTranslationVector &atb, + public: + //! Data array + double *data; + + private: + static const double sing_threshold; // = 0.0001; + static const double threshold_rotation; + static const double threshold_displacement; + vpHomogeneousMatrix aMb ; + // bool isplanar; + //! reference plane coordinates expressed in Rb + vpPlane bP ; + + private: + //! build the homography from aMb and Rb + void build() ; + + //! insert a rotation matrix + void insert(const vpHomogeneousMatrix &aRb) ; + //! insert a rotation matrix + void insert(const vpRotationMatrix &aRb) ; + //! insert a theta u vector (transformation into a rotation matrix) + void insert(const vpThetaUVector &tu) ; + //! insert a translation vector + void insert(const vpTranslationVector &atb) ; + //! insert a translation vector + void insert(const vpPlane &bP) ; + + static void initRansac(unsigned int n, + double *xb, double *yb, + double *xa, double *ya, + vpColVector &x) ; + + public: + vpHomography() ; + vpHomography(const vpHomography &H) ; + //! Construction from Translation and rotation and a plane + vpHomography(const vpHomogeneousMatrix &aMb, const vpPlane &bP) ; - //! Construction from Translation and rotation and a plane - void buildFrom(const vpThetaUVector &tu, + //! Construction from Translation and rotation and a plane + vpHomography(const vpRotationMatrix &aRb, const vpTranslationVector &atb, const vpPlane &bP) ; - //! Construction from Translation and rotation and a plane - void buildFrom(const vpPoseVector &arb, + //! Construction from Translation and rotation and a plane + vpHomography(const vpThetaUVector &tu, + const vpTranslationVector &atb, const vpPlane &bP) ; - //! Construction from homogeneous matrix and a plane - void buildFrom(const vpHomogeneousMatrix &aMb, + //! Construction from Translation and rotation and a plane + vpHomography(const vpPoseVector &arb, const vpPlane &bP) ; - - //! build the homography from aMb and Rb - void build() ; - - - void computeDisplacement(vpRotationMatrix &aRb, - vpTranslationVector &atb, - vpColVector &n) ; - - void computeDisplacement(const vpColVector& nd, - vpRotationMatrix &aRb, - vpTranslationVector &atb, - vpColVector &n) ; - - //! Load an homography from a file - void load(std::ifstream &f) ; - //! Print the matrix - void print() ; - //! Save an homography in a file - void save(std::ofstream &f) const ; - - //! invert the homography - vpHomography inverse() const ; - //! invert the homography - void inverse(vpHomography &Hi) const; - - // Multiplication by an homography - vpHomography operator*(const vpHomography &H) const; - - // Multiplication by a scalar - vpHomography operator*(const double &v) const; - - // Division by a scalar - vpHomography operator/(const double &v) const; - - //! build the homography from aMb and Rb - static void build(vpHomography &aHb, - const vpHomogeneousMatrix &aMb, - const vpPlane &bP) ; - - static void DLT(unsigned int n, - double *xb, double *yb , - double *xa, double *ya, - vpHomography &aHb) ; - - static void HartleyDLT(unsigned int n, - double *xb, double *yb , - double *xa, double *ya, - vpHomography &aHb) ; - static void HLM(unsigned int n, - double *xb, double *yb, - double *xa, double *ya , - bool isplan, - vpHomography &aHb) ; - - static void computeDisplacement(const vpHomography &aHb, - const vpColVector& nd, - vpRotationMatrix &aRb, - vpTranslationVector &atb, - vpColVector &n) ; - - static void computeDisplacement (const vpHomography &aHb, - vpRotationMatrix &aRb, - vpTranslationVector &atb, - vpColVector &n) ; - - static void computeDisplacement(const vpMatrix &H, - const double x, - const double y, - std::list<vpRotationMatrix> & vR, - std::list<vpTranslationVector> & vT, - std::list<vpColVector> & vN) ; - static double computeDisplacement(unsigned int nbpoint, - vpPoint *c1P, - vpPoint *c2P, - vpPlane &oN, - vpHomogeneousMatrix &c2Mc1, - vpHomogeneousMatrix &c1Mo, - int userobust - ) ; - static double computeDisplacement(unsigned int nbpoint, - vpPoint *c1P, - vpPoint *c2P, - vpPlane *oN, - vpHomogeneousMatrix &c2Mc1, - vpHomogeneousMatrix &c1Mo, - int userobust - ) ; - static double computeResidual(vpColVector &x, vpColVector &M, vpColVector &d); - // VVS - static double computeRotation(unsigned int nbpoint, - vpPoint *c1P, - vpPoint *c2P, - vpHomogeneousMatrix &c2Mc1, - int userobust - ) ; - static void computeTransformation(vpColVector &x,unsigned int *ind, vpColVector &M) ; - - static bool degenerateConfiguration(vpColVector &x,unsigned int *ind) ; - static bool degenerateConfiguration(vpColVector &x,unsigned int *ind, double threshold_area); - - static bool ransac(unsigned int n, - double *xb, double *yb, - double *xa, double *ya , - vpHomography &aHb, - int consensus = 1000, - double threshold = 1e-6 - ) ; - - static bool ransac(unsigned int n, - double *xb, double *yb, - double *xa, double *ya , - vpHomography &aHb, - vpColVector& inliers, - double& residual, - int consensus = 1000, - double epsilon = 1e-6, - double areaThreshold = 0.0); + virtual ~vpHomography(); + + //! Construction from Translation and rotation and a plane + void buildFrom(const vpRotationMatrix &aRb, + const vpTranslationVector &atb, + const vpPlane &bP) ; + //! Construction from Translation and rotation and a plane + void buildFrom(const vpThetaUVector &tu, + const vpTranslationVector &atb, + const vpPlane &bP) ; + //! Construction from Translation and rotation and a plane + void buildFrom(const vpPoseVector &arb, + const vpPlane &bP) ; + //! Construction from homogeneous matrix and a plane + void buildFrom(const vpHomogeneousMatrix &aMb, + const vpPlane &bP) ; + + void computeDisplacement(vpRotationMatrix &aRb, + vpTranslationVector &atb, + vpColVector &n) ; + + void computeDisplacement(const vpColVector& nd, + vpRotationMatrix &aRb, + vpTranslationVector &atb, + vpColVector &n) ; + + //! Return the number of rows of the homography matrix. + inline unsigned int getRows() const { return 3;} + //! Return the number of columns of the homography matrix. + inline unsigned int getCols() const { return 3; } + + //! invert the homography + vpHomography inverse() const ; + //! invert the homography + void inverse(vpHomography &Hi) const; + + //! Load an homography from a file + void load(std::ifstream &f) ; + + //! Write elements Hij (usage : H[i][j] = x ) + inline double *operator[](unsigned int i) { return &data[i*3]; } + //! Read elements Hij (usage : x = H[i][j] ) + inline double *operator[](unsigned int i) const {return &data[i*3];} + + // Multiplication by an homography + vpHomography operator*(const vpHomography &H) const; + + // Multiplication by a scalar + vpHomography operator*(const double &v) const; + vpColVector operator*(const vpColVector &b) const; + + // Division by a scalar + vpHomography operator/(const double &v) const; + vpHomography & operator/=(double v); + vpHomography & operator=(const vpHomography &H); + vpHomography & operator=(const vpMatrix &H); + + //! Save an homography in a file + void save(std::ofstream &f) const ; + + void setIdentity(); + + friend VISP_EXPORT std::ostream &operator << (std::ostream &s,const vpHomography &H); + + static void DLT(const std::vector<double> &xb, const std::vector<double> &yb, + const std::vector<double> &xa, const std::vector<double> &ya , + vpHomography &aHb, + bool normalization=true); + + static void HLM(const std::vector<double> &xb, const std::vector<double> &yb, + const std::vector<double> &xa, const std::vector<double> &ya, + bool isplanar, + vpHomography &aHb) ; + + static bool ransac(const std::vector<double> &xb, const std::vector<double> &yb, + const std::vector<double> &xa, const std::vector<double> &ya, + vpHomography &aHb, + std::vector<bool> &inliers, + double &residual, + unsigned int nbInliersConsensus, + double threshold, + bool normalization=true); + + static vpImagePoint project(const vpCameraParameters &cam, const vpHomography &bHa, const vpImagePoint &iPa); + static vpPoint project(const vpHomography &bHa, const vpPoint &Pa); + + static void robust(const std::vector<double> &xb, const std::vector<double> &yb, + const std::vector<double> &xa, const std::vector<double> &ya, + vpHomography &aHb, + std::vector<bool> &inlier, + double &residual, + double weights_threshold=0.4, + unsigned int niter=4, + bool normalization=true); + +#ifndef DOXYGEN_SHOULD_SKIP_THIS + //! build the homography from aMb and Rb + static void build(vpHomography &aHb, + const vpHomogeneousMatrix &aMb, + const vpPlane &bP) ; + + static void computeDisplacement(const vpHomography &aHb, + const vpColVector& nd, + vpRotationMatrix &aRb, + vpTranslationVector &atb, + vpColVector &n) ; + + static void computeDisplacement (const vpHomography &aHb, + vpRotationMatrix &aRb, + vpTranslationVector &atb, + vpColVector &n) ; + + static void computeDisplacement(const vpMatrix &H, + const double x, + const double y, + std::list<vpRotationMatrix> & vR, + std::list<vpTranslationVector> & vT, + std::list<vpColVector> & vN) ; + static double computeDisplacement(unsigned int nbpoint, + vpPoint *c1P, + vpPoint *c2P, + vpPlane &oN, + vpHomogeneousMatrix &c2Mc1, + vpHomogeneousMatrix &c1Mo, + int userobust + ) ; + static double computeDisplacement(unsigned int nbpoint, + vpPoint *c1P, + vpPoint *c2P, + vpPlane *oN, + vpHomogeneousMatrix &c2Mc1, + vpHomogeneousMatrix &c1Mo, + int userobust + ) ; + static double computeResidual(vpColVector &x, vpColVector &M, vpColVector &d); + // VVS + static double computeRotation(unsigned int nbpoint, + vpPoint *c1P, + vpPoint *c2P, + vpHomogeneousMatrix &c2Mc1, + int userobust) ; + static void computeTransformation(vpColVector &x,unsigned int *ind, vpColVector &M) ; + static bool degenerateConfiguration(vpColVector &x,unsigned int *ind) ; + static bool degenerateConfiguration(vpColVector &x,unsigned int *ind, double threshold_area); + static bool degenerateConfiguration(const std::vector<double> &xb, const std::vector<double> &yb, + const std::vector<double> &xa, const std::vector<double> &ya); + static void HartleyNormalization(unsigned int n, + const double *x, const double *y, + double *xn, double *yn, + double &xg, double &yg, + double &coef); + static void HartleyNormalization(const std::vector<double> &x, const std::vector<double> &y, + std::vector<double> &xn, std::vector<double> &yn, + double &xg, double &yg, double &coef); + static void HartleyDenormalization(vpHomography &aHbn, + vpHomography &aHb, + double xg1, double yg1, double coef1, + double xg2, double yg2, double coef2 ) ; + +#endif // DOXYGEN_SHOULD_SKIP_THIS #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS - /*! + /*! @name Deprecated functions */ - vp_deprecated static void computeDisplacement(const vpMatrix H, - const double x, - const double y, - vpList<vpRotationMatrix> & vR, - vpList<vpTranslationVector> & vT, - vpList<vpColVector> & vN) ; + vp_deprecated static void computeDisplacement(const vpMatrix H, + const double x, + const double y, + vpList<vpRotationMatrix> & vR, + vpList<vpTranslationVector> & vT, + vpList<vpColVector> & vN); + + static void DLT(unsigned int n, + double *xb, double *yb , + double *xa, double *ya, + vpHomography &aHb) ; + vp_deprecated static void HartleyDLT(unsigned int n, + double *xb, double *yb , + double *xa, double *ya, + vpHomography &aHb) ; + + static void HLM(unsigned int n, + double *xb, double *yb, + double *xa, double *ya , + bool isplan, + vpHomography &aHb) ; + + //! Print the matrix + vp_deprecated void print() ; + + vp_deprecated static bool ransac(unsigned int n, + double *xb, double *yb, + double *xa, double *ya , + vpHomography &aHb, + int consensus = 1000, + double threshold = 1e-6) ; + + vp_deprecated static bool ransac(unsigned int n, + double *xb, double *yb, + double *xa, double *ya , + vpHomography &aHb, + vpColVector& inliers, + double residual = 0.1, // Not used + int consensus = 1000, + double threshold = 1e-6, + double areaThreshold = 0.0); #endif // VISP_BUILD_DEPRECATED_FUNCTIONS } ; diff --git a/src/computer-vision/homography-estimation/vpHomographyDLT.cpp b/src/computer-vision/homography-estimation/vpHomographyDLT.cpp index 1c48c142203b7e7c4a86630f005516d18deaf4ed..6669a46df5c1c421c65af78547cb54187b4b87ae 100644 --- a/src/computer-vision/homography-estimation/vpHomographyDLT.cpp +++ b/src/computer-vision/homography-estimation/vpHomographyDLT.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpHomographyDLT.cpp 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpHomographyDLT.cpp 4661 2014-02-10 19:34:58Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -48,17 +48,74 @@ */ #include <visp/vpHomography.h> +#include <visp/vpMatrix.h> #include <visp/vpMatrixException.h> #include <cmath> // std::fabs #include <limits> // numeric_limits +#ifndef DOXYGEN_SHOULD_SKIP_THIS + +void +vpHomography::HartleyNormalization(const std::vector<double> &x, const std::vector<double> &y, + std::vector<double> &xn, std::vector<double> &yn, + double &xg, double &yg, double &coef) +{ + if (x.size() != y.size()) + throw(vpException(vpException::dimensionError, + "Hartley normalization require that x and y vector have the same dimension")); + + unsigned int n = (unsigned int) x.size(); + if (xn.size() != n) + xn.resize(n); + if (yn.size() != n) + yn.resize(n); + + xg = 0 ; + yg = 0 ; + + for (unsigned int i =0 ; i < n ; i++) + { + xg += x[i] ; + yg += y[i] ; + } + xg /= n ; + yg /= n ; + + // Changement d'origine : le centre de gravite doit correspondre + // a l'origine des coordonnees + double distance=0; + for(unsigned int i=0; i<n;i++) + { + double xni=x[i]-xg; + double yni=y[i]-yg; + xn[i] = xni ; + yn[i] = yni ; + distance+=sqrt(vpMath::sqr(xni)+vpMath::sqr(yni)); + }//for translation sur tous les points + + //Changement d'echelle + distance/=n; + //calcul du coef de changement d'echelle + //if(distance ==0) + if(std::fabs(distance) <= std::numeric_limits<double>::epsilon()) + coef=1; + else + coef=sqrt(2.0)/distance; + + for(unsigned int i=0; i<n;i++) + { + xn[i] *= coef; + yn[i] *= coef; + } +} + void vpHomography::HartleyNormalization(unsigned int n, - double *x, double *y, - double *xn, double *yn, - double &xg, double &yg, - double &coef) + const double *x, const double *y, + double *xn, double *yn, + double &xg, double &yg, + double &coef) { unsigned int i; xg = 0 ; @@ -72,8 +129,8 @@ vpHomography::HartleyNormalization(unsigned int n, xg /= n ; yg /= n ; - //Changement d'origine : le centre de gravité doit correspondre - // à l'origine des coordonnées + //Changement d'origine : le centre de gravite doit correspondre + // a l'origine des coordonnees double distance=0; for(i=0; i<n;i++) { @@ -84,9 +141,9 @@ vpHomography::HartleyNormalization(unsigned int n, distance+=sqrt(vpMath::sqr(xni)+vpMath::sqr(yni)); }//for translation sur tous les points - //Changement d'échelle + //Changement d'echelle distance/=n; - //calcul du coef de changement d'échelle + //calcul du coef de changement d'echelle //if(distance ==0) if(std::fabs(distance) <= std::numeric_limits<double>::epsilon()) coef=1; @@ -98,7 +155,6 @@ vpHomography::HartleyNormalization(unsigned int n, xn[i] *= coef; yn[i] *= coef; } - } //--------------------------------------------------------------------------------------- @@ -110,8 +166,8 @@ vpHomography::HartleyDenormalization(vpHomography &aHbn, double xg2, double yg2, double coef2 ) { - //calcul des transformations à appliquer sur M_norm pour obtenir M - //en fonction des deux normalisations effectuées au début sur + //calcul des transformations a appliquer sur M_norm pour obtenir M + //en fonction des deux normalisations effectuees au debut sur //les points: aHb = T2^ aHbn T1 vpMatrix T1(3,3); vpMatrix T2(3,3); @@ -129,19 +185,29 @@ vpHomography::HartleyDenormalization(vpHomography &aHbn, T2[0][2]=-coef2*xg2 ; T2[1][2]=-coef2*yg2 ; - T2T=T2.pseudoInverse(1e-16) ; - vpMatrix maHb=T2T*(vpMatrix)aHbn*T1; + vpMatrix aHbn_(3,3); + for(unsigned int i=0; i<3; i++) + for(unsigned int j=0; j<3; j++) + aHbn_[i][j] = aHbn[i][j]; - for (unsigned int i=0 ; i < 3 ; i++) - for (unsigned int j=0 ; j < 3 ; j++) aHb[i][j] = maHb[i][j] ; + vpMatrix maHb=T2T*aHbn_*T1; + for (unsigned int i=0 ; i < 3 ; i++) + for (unsigned int j=0 ; j < 3 ; j++) + aHb[i][j] = maHb[i][j] ; } +#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS + +#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS /*! + \deprecated You should rather use + vpHomography::DLT(const std::vector<double> &, const std::vector<double> &, const std::vector<double> &, const std::vector<double> &, vpHomography &, bool) + \brief Computes the homography matrix using the DLT (Direct Linear Transform) algorithm on normalized data. @@ -157,12 +223,12 @@ vpHomography::HartleyDenormalization(vpHomography &aHbn, */ void vpHomography::HartleyDLT(unsigned int n, - double *xb, double *yb, - double *xa, double *ya , - vpHomography &aHb) + double *xb, double *yb, + double *xa, double *ya , + vpHomography &aHb) { try{ - //initialise les données initiales + //initialise les donnees initiales // code_retour =InitialData(n, p1,p2); // normalize points @@ -173,9 +239,9 @@ vpHomography::HartleyDLT(unsigned int n, double xg1, yg1, coef1 ; vpHomography::HartleyNormalization(n, - xb,yb, - xbn,ybn, - xg1, yg1,coef1); + xb,yb, + xbn,ybn, + xg1, yg1,coef1); double *xan; double *yan; @@ -184,15 +250,15 @@ vpHomography::HartleyDLT(unsigned int n, double xg2, yg2, coef2 ; vpHomography::HartleyNormalization(n, - xa,ya, - xan,yan, - xg2, yg2,coef2); + xa,ya, + xan,yan, + xg2, yg2,coef2); vpHomography aHbn ; //compute the homography using the DLT from normalized data vpHomography::DLT(n,xbn,ybn,xan,yan,aHbn); - //H dénormalisée + //H denormalisee vpHomography::HartleyDenormalization(aHbn,aHb,xg1,yg1,coef1,xg2,yg2, coef2); delete [] xbn; @@ -207,9 +273,14 @@ vpHomography::HartleyDLT(unsigned int n, throw ; } } +#endif //#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS +#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS /*! + \deprecated You should rather use + vpHomography::DLT(const std::vector<double> &, const std::vector<double> &, const std::vector<double> &, const std::vector<double> &, vpHomography &, bool) + \brief Computes the homography matrix wrt. the data using the DLT (Direct Linear Transform) algorithm. @@ -225,7 +296,6 @@ vpHomography::HartleyDLT(unsigned int n, At least 4 correspondant points couples are needed. - For each point, in homogeneous coordinates we have: \f[ \mathbf{p}_{a}= \mathbf{H}\mathbf{p}_{b} @@ -244,7 +314,6 @@ vpHomography::HartleyDLT(unsigned int n, \mathbf{p}_{a} \times \mathbf{H}\mathbf{p}_{b} =\left( \begin{array}{c}y_{a}\mathbf{h}_3^T\mathbf{p}_{b}-w_{a}\mathbf{h}_2^T\mathbf{p}_{b} \\w_{a}\mathbf{h}_1^T\mathbf{p}_{b} -x_{a}\mathbf{h}_3^T \mathbf{p}_{b} \\x_{a}\mathbf{h}_2^T \mathbf{p}_{b}- y_{a}\mathbf{h}_1^T\mathbf{p}_{b}\end{array}\right) \f] - \f[ \underbrace{\left( \begin{array}{ccc}\mathbf{0}^T & -w_{a} \mathbf{p}_{b}^T & y_{a} \mathbf{p}_{b}^T \\ w_{a} @@ -267,9 +336,9 @@ vpHomography::HartleyDLT(unsigned int n, that should be 8 is deficient. */ void vpHomography::DLT(unsigned int n, - double *xb, double *yb, - double *xa, double *ya , - vpHomography &aHb) + double *xb, double *yb, + double *xa, double *ya , + vpHomography &aHb) { // 4 point are required @@ -284,19 +353,17 @@ void vpHomography::DLT(unsigned int n, vpColVector h(9); vpColVector D(9); vpMatrix V(9,9); - unsigned int i, j; // We need here to compute the SVD on a (n*2)*9 matrix (where n is // the number of points). if n == 4, the matrix has more columns // than rows. This kind of matrix is not supported by GSL for // SVD. The solution is to add an extra line with zeros - if (n == 4) + if (n == 4) A.resize(2*n+1,9); // build matrix A - for(i=0; i<n;i++) + for(unsigned int i=0; i<n;i++) { - A[2*i][0]=0; A[2*i][1]=0; A[2*i][2]=0; @@ -321,24 +388,24 @@ void vpHomography::DLT(unsigned int n, // Add an extra line with zero. if (n == 4) { - for (int i=0; i < 9; i ++) { - A[2*n][i] = 0; + for (unsigned int i=0; i < 9; i ++) { + A[2*n][i] = 0; } - } + } // solve Ah = 0 // SVD Decomposition A = UDV^T (destructive wrt A) A.svd(D,V); // on en profite pour effectuer un controle sur le rang de la matrice : - // pas plus de 2 valeurs singulières quasi=0 + // pas plus de 2 valeurs singulieres quasi=0 int rank=0; - for(i = 0; i<9;i++) if(D[i]>1e-7) rank++; + for(unsigned int i = 0; i<9;i++) if(D[i]>1e-7) rank++; if(rank <7) { vpTRACE(" Rank is : %d, should be 8", rank); throw(vpMatrixException(vpMatrixException::rankDeficient, - "\n\t\t Matrix rank is deficient")) ; + "\n\t\t Matrix rank is deficient")) ; } //h = is the column of V associated with the smallest singular value of A @@ -346,17 +413,17 @@ void vpHomography::DLT(unsigned int n, // singular value... we seek for the smallest double smallestSv = 1e30 ; unsigned int indexSmallestSv = 0 ; - for (i=0 ; i < 9 ; i++) + for (unsigned int i=0 ; i < 9 ; i++) if ((D[i] < smallestSv) ){ smallestSv = D[i] ;indexSmallestSv = i ; } h=V.column(indexSmallestSv+1); // build the homography - for(i =0;i<3;i++) + for(unsigned int i =0;i<3;i++) { - for(j=0;j<3;j++) - aHb[i][j]=h[3*i+j]; + for(unsigned int j=0;j<3;j++) + aHb[i][j]=h[3*i+j]; } } @@ -373,3 +440,192 @@ void vpHomography::DLT(unsigned int n, } } +#endif // #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS + +/*! + From couples of matched points \f$^a{\bf p}=(x_a,y_a,1)\f$ in image a + and \f$^b{\bf p}=(x_b,y_b,1)\f$ in image b with homogeneous coordinates, computes the + homography matrix by resolving \f$^a{\bf p} = ^a{\bf H}_b\; ^b{\bf p}\f$ + using the DLT (Direct Linear Transform) algorithm. + + At least 4 couples of points are needed. + + To do so, we use the DLT algorithm on the data, + ie we resolve the linear system by SDV : \f$\bf{Ah} =0\f$ where + \f$\bf{h}\f$ is the vector with the terms of \f$^a{\bf H}_b\f$ and + \f$\mathbf{A}\f$ depends on the points coordinates. + + For each point, in homogeneous coordinates we have: + \f[ + ^a{\bf p} = ^a{\bf H}_b\; ^b{\bf p} + \f] + which is equivalent to: + \f[ + ^a{\bf p} \times {^a{\bf H}_b \; ^b{\bf p}} =0 + \f] + If we note \f$\mathbf{h}_j^T\f$ the \f$j^{\textrm{th}}\f$ line of \f$^a{\bf H}_b\f$, we can write: + \f[ + ^a{\bf H}_b \; ^b{\bf p} = \left( \begin{array}{c}\mathbf{h}_1^T \;^b{\bf p} \\\mathbf{h}_2^T \; ^b{\bf p} \\\mathbf{h}_3^T \;^b{\bf p} \end{array}\right) + \f] + + Setting \f$^a{\bf p}=(x_{a},y_{a},w_{a})\f$, the cross product can be rewritten by: + \f[ + ^a{\bf p} \times ^a{\bf H}_b \; ^b{\bf p} =\left( \begin{array}{c}y_{a}\mathbf{h}_3^T \; ^b{\bf p}-w_{a}\mathbf{h}_2^T \; ^b{\bf p} \\w_{a}\mathbf{h}_1^T \; ^b{\bf p} -x_{a}\mathbf{h}_3^T \; ^b{\bf p} \\x_{a}\mathbf{h}_2^T \; ^b{\bf p}- y_{a}\mathbf{h}_1^T \; ^b{\bf p}\end{array}\right) + \f] + + \f[ + \underbrace{\left( \begin{array}{ccc}\mathbf{0}^T & -w_{a} \; ^b{\bf p}^T + & y_{a} \; ^b{\bf p}^T \\ w_{a} + \; ^b{\bf p}^T&\mathbf{0}^T & -x_{a} \; ^b{\bf p}^T \\ + -y_{a} \; ^b{\bf p}^T & x_{a} \; ^b{\bf p}^T & + \mathbf{0}^T\end{array}\right)}_{\mathbf{A}_i (3\times 9)} + \underbrace{\left( \begin{array}{c}\mathbf{h}_{1}^{T} \\ + \mathbf{h}_{2}^{T}\\\mathbf{h}_{3}^{T}\end{array}\right)}_{\mathbf{h} (9\times 1)}=0 + \f] + + leading to an homogeneous system to be solved: \f$\mathbf{A}\mathbf{h}=0\f$ with + \f$\mathbf{A}=\left(\mathbf{A}_1^T, ..., \mathbf{A}_i^T, ..., \mathbf{A}_n^T \right)^T\f$. + + It can be solved using an SVD decomposition: + \f[\bf A = UDV^T \f] + <b>h</b> is the column of <b>V</b> associated with the smalest singular value of <b>A + </b> + + \param xb, yb : Coordinates vector of matched points in image b. These coordinates are expressed in meters. + \param xa, ya : Coordinates vector of matched points in image a. These coordinates are expressed in meters. + \param aHb : Estimated homography that relies the transformation from image a to image b. + \param normalization : When set to true, the coordinates of the points are normalized. The normalization + carried out is the one preconized by Hartley. + + \exception vpMatrixException::rankDeficient : When the rank of the matrix + that should be 8 is deficient. +*/ +void vpHomography::DLT(const std::vector<double> &xb, const std::vector<double> &yb, + const std::vector<double> &xa, const std::vector<double> &ya , + vpHomography &aHb, + bool normalization) +{ + unsigned int n = (unsigned int) xb.size(); + if (yb.size() != n || xa.size() != n || ya.size() != n) + throw(vpException(vpException::dimensionError, + "Bad dimension for DLT homography estimation")); + + // 4 point are required + if(n<4) + throw(vpException(vpException::fatalError, "There must be at least 4 matched points")); + + try{ + std::vector<double> xan, yan, xbn, ybn; + + double xg1=0., yg1=0., coef1=0., xg2=0., yg2=0., coef2=0.; + + vpHomography aHbn; + + if (normalization) { + vpHomography::HartleyNormalization(xb, yb, xbn, ybn, xg1, yg1, coef1); + vpHomography::HartleyNormalization(xa, ya, xan, yan, xg2, yg2, coef2); + } + else { + xbn = xb; + ybn = yb; + xan = xa; + yan = ya; + } + + vpMatrix A(2*n,9); + vpColVector h(9); + vpColVector D(9); + vpMatrix V(9,9); + + // We need here to compute the SVD on a (n*2)*9 matrix (where n is + // the number of points). if n == 4, the matrix has more columns + // than rows. This kind of matrix is not supported by GSL for + // SVD. The solution is to add an extra line with zeros + if (n == 4) + A.resize(2*n+1,9); + + // build matrix A + for(unsigned int i=0; i<n;i++) + { + A[2*i][0]=0; + A[2*i][1]=0; + A[2*i][2]=0; + A[2*i][3]=-xbn[i] ; + A[2*i][4]=-ybn[i] ; + A[2*i][5]=-1; + A[2*i][6]=xbn[i]*yan[i] ; + A[2*i][7]=ybn[i]*yan[i]; + A[2*i][8]=yan[i]; + + + A[2*i+1][0]=xbn[i] ; + A[2*i+1][1]=ybn[i] ; + A[2*i+1][2]=1; + A[2*i+1][3]=0; + A[2*i+1][4]=0; + A[2*i+1][5]=0; + A[2*i+1][6]=-xbn[i]*xan[i]; + A[2*i+1][7]=-ybn[i]*xan[i]; + A[2*i+1][8]=-xan[i] ; + } + + // Add an extra line with zero. + if (n == 4) { + for (unsigned int i=0; i < 9; i ++) { + A[2*n][i] = 0; + } + } + + // solve Ah = 0 + // SVD Decomposition A = UDV^T (destructive wrt A) + A.svd(D,V); + + // on en profite pour effectuer un controle sur le rang de la matrice : + // pas plus de 2 valeurs singulieres quasi=0 + int rank=0; + for(unsigned int i = 0; i<9;i++) if(D[i]>1e-7) rank++; + if(rank <7) + { + vpTRACE(" Rank is : %d, should be 8", rank); + throw(vpMatrixException(vpMatrixException::rankDeficient, + "\n\t\t Matrix rank is deficient")) ; + } + //h = is the column of V associated with the smallest singular value of A + + // since we are not sure that the svd implemented sort the + // singular value... we seek for the smallest + double smallestSv = 1e30 ; + unsigned int indexSmallestSv = 0 ; + for (unsigned int i=0 ; i < 9 ; i++) + if ((D[i] < smallestSv) ){ smallestSv = D[i] ;indexSmallestSv = i ; } + + h=V.column(indexSmallestSv+1); + + // build the homography + for(unsigned int i =0;i<3;i++) + { + for(unsigned int j=0;j<3;j++) + aHbn[i][j]=h[3*i+j]; + } + + if (normalization) { + // H after denormalization + vpHomography::HartleyDenormalization(aHbn, aHb, xg1, yg1, coef1, xg2, yg2, coef2); + } + else { + aHb = aHbn; + } + + } + catch(vpMatrixException me) + { + vpTRACE("Matrix Exception ") ; + throw(me) ; + } + catch(vpException me) + { + vpERROR_TRACE("caught another error") ; + std::cout <<std::endl << me << std::endl ; + throw(me) ; + } +} diff --git a/src/computer-vision/homography-estimation/vpHomographyExtract.cpp b/src/computer-vision/homography-estimation/vpHomographyExtract.cpp index 63590430f7358b228d59084f927eb8d0a065af2e..8937d63a6906cc2095723955f0efcb9cf0a22a13 100644 --- a/src/computer-vision/homography-estimation/vpHomographyExtract.cpp +++ b/src/computer-vision/homography-estimation/vpHomographyExtract.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpHomographyExtract.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpHomographyExtract.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -50,16 +50,70 @@ /* ------------------------------------------------------------------------ */ const double vpHomography::sing_threshold = 0.0001; +/*! + Compute the camera displacement between two images from the homography \f$ + {^a}{\bf H}_b \f$ which is here an implicit parameter (*this). + + \param aRb : Rotation matrix as an output \f$ {^a}{\bf R}_b \f$. + + \param atb : Translation vector as an output \f$ ^a{\bf t}_b \f$. + + \param n : Normal vector to the plane as an output. + +*/ +void vpHomography::computeDisplacement(vpRotationMatrix &aRb, + vpTranslationVector &atb, + vpColVector &n) +{ + + + vpColVector nd(3) ; + nd[0]=0;nd[1]=0;nd[2]=1; + + computeDisplacement(*this,aRb,atb,n); + +} + /*! Compute the camera displacement between two images from the homography \f$ - {^a}{\bf H}_b \f$. + {^a}{\bf H}_b \f$ which is here an implicit parameter (*this). Camera displacement between \f$ {^a}{\bf p} \f$ and \f$ {^a}{\bf p} \f$ is represented as a rotation matrix \f$ {^a}{\bf R}_b \f$ and a translation vector \f$ ^a{\bf t}_b \f$ from which an homogenous matrix can be build (vpHomogeneousMatrix). + \param nd : Input normal vector to the plane used to compar with the normal + vector \e n extracted from the homography. + + \param aRb : Rotation matrix as an output \f$ {^a}{\bf R}_b \f$. + + \param atb : Translation vector as an output \f$ ^a{\bf t}_b \f$. + + \param n : Normal vector to the plane as an output. + +*/ +void vpHomography::computeDisplacement(const vpColVector& nd, + vpRotationMatrix &aRb, + vpTranslationVector &atb, + vpColVector &n) +{ + computeDisplacement(*this,nd, aRb,atb,n); +} + +#ifndef DOXYGEN_SHOULD_SKIP_THIS + +/*! + + Compute the camera displacement between two images from the homography \f$ + {^a}{\bf H}_b \f$. + + Camera displacement between \f$ {^a}{\bf p} \f$ and \f$ {^b}{\bf p} \f$ is + represented as a rotation matrix \f$ {^a}{\bf R}_b \f$ and a translation + vector \f$ ^a{\bf t}_b \f$ from which an homogenous matrix can be build + (vpHomogeneousMatrix). + \param aHb : Input homography \f$ {^a}{\bf H}_b \f$. \param nd : Input normal vector to the plane used to compar with the normal @@ -79,7 +133,7 @@ void vpTranslationVector &atb, vpColVector &n) { - /**** Déclarations des variables ****/ + /**** Declarations des variables ****/ vpMatrix aRbint(3,3) ; vpColVector svTemp(3), sv(3); @@ -341,35 +395,6 @@ void } -/*! - - Compute the camera displacement between two images from the homography \f$ - {^a}{\bf H}_b \f$ which is here an implicit parameter (*this). - - Camera displacement between \f$ {^a}{\bf p} \f$ and \f$ {^a}{\bf p} \f$ is - represented as a rotation matrix \f$ {^a}{\bf R}_b \f$ and a translation - vector \f$ ^a{\bf t}_b \f$ from which an homogenous matrix can be build - (vpHomogeneousMatrix). - - \param nd : Input normal vector to the plane used to compar with the normal - vector \e n extracted from the homography. - - \param aRb : Rotation matrix as an output \f$ {^a}{\bf R}_b \f$. - - \param atb : Translation vector as an output \f$ ^a{\bf t}_b \f$. - - \param n : Normal vector to the plane as an output. - - \sa computeDisplacement(const vpHomography &, const vpColVector &, vpRotationMatrix &, vpTranslationVector &, vpColVector &) -*/ -void - vpHomography::computeDisplacement(const vpColVector& nd, - vpRotationMatrix &aRb, - vpTranslationVector &atb, - vpColVector &n) -{ - computeDisplacement(*this,nd, aRb,atb,n); -} /*! Compute the camera displacement between two images from the homography \f$ @@ -394,7 +419,7 @@ void vpTranslationVector &atb, vpColVector &n) { - /**** Déclarations des variables ****/ + /**** Declarations des variables ****/ vpMatrix aRbint(3,3) ; vpColVector svTemp(3), sv(3); @@ -655,32 +680,6 @@ void } - -/*! - Compute the camera displacement between two images from the homography \f$ - {^a}{\bf H}_b \f$ which is here an implicit parameter (*this). - - \param aRb : Rotation matrix as an output \f$ {^a}{\bf R}_b \f$. - - \param atb : Translation vector as an output \f$ ^a{\bf t}_b \f$. - - \param n : Normal vector to the plane as an output. - - \sa computeDisplacement(const vpHomography &, vpRotationMatrix &, vpTranslationVector &, vpColVector &) -*/ -void vpHomography::computeDisplacement(vpRotationMatrix &aRb, - vpTranslationVector &atb, - vpColVector &n) -{ - - - vpColVector nd(3) ; - nd[0]=0;nd[1]=0;nd[2]=1; - - computeDisplacement(*this,aRb,atb,n); - -} - void vpHomography::computeDisplacement(const vpMatrix &H, const double x, const double y, @@ -697,7 +696,7 @@ void vpHomography::computeDisplacement(const vpMatrix &H, vT.clear(); vN.clear(); - /**** Déclarations des variables ****/ + /**** Declarations des variables ****/ int cas1 =1, cas2=2, cas3=3, cas4=4; int cas =0; bool norm1ok=false, norm2ok = false,norm3ok=false,norm4ok =false; @@ -1333,6 +1332,7 @@ void vpHomography::computeDisplacement(const vpMatrix &H, printf("fin : Homographie_EstimationDeplacementCamera\n"); #endif } +#endif //#ifndef DOXYGEN_SHOULD_SKIP_THIS #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS /*! @@ -1355,7 +1355,7 @@ void vpHomography::computeDisplacement(const vpMatrix H, vT.kill(); vN.kill(); - /**** Déclarations des variables ****/ + /**** Declarations des variables ****/ int cas1 =1, cas2=2, cas3=3, cas4=4; int cas =0; bool norm1ok=false, norm2ok = false,norm3ok=false,norm4ok =false; diff --git a/src/computer-vision/homography-estimation/vpHomographyMalis.cpp b/src/computer-vision/homography-estimation/vpHomographyMalis.cpp index 7a75eca10245ae812a44f91f273b09c973e15c09..b723142c5327d3670d1c82e6cb5de4e0d4d5b51a 100644 --- a/src/computer-vision/homography-estimation/vpHomographyMalis.cpp +++ b/src/computer-vision/homography-estimation/vpHomographyMalis.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpHomographyMalis.cpp 4276 2013-06-25 12:36:48Z fspindle $ + * $Id: vpHomographyMalis.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -91,16 +91,36 @@ const double eps = 1e-6 ; **************************************************************************** */ +void changeFrame(unsigned int *pts_ref, + unsigned int nb_pts, + vpMatrix &pd, vpMatrix &p, + vpMatrix &pnd, vpMatrix &pn, + vpMatrix &M, vpMatrix &Mdp); +void HLM2D(unsigned int nb_pts, + vpMatrix &points_des, + vpMatrix &points_cour, + vpMatrix &H); +void HLM3D(unsigned int nb_pts, + vpMatrix &pd, + vpMatrix &p, + vpMatrix &H); +void HLM(unsigned int q_cible, + unsigned int nbpt, + double *xm, double *ym, + double *xmi, double *ymi, + vpMatrix &H); + +void HLM(unsigned int q_cible, + const std::vector<double> &xm, const std::vector<double> &ym, + const std::vector<double> &xmi, const std::vector<double> &ymi, + vpMatrix &H); void changeFrame(unsigned int *pts_ref, - unsigned int nb_pts, - vpMatrix &pd, vpMatrix &p, - vpMatrix &pnd, vpMatrix &pn, - vpMatrix &M, vpMatrix &Mdp) + unsigned int nb_pts, + vpMatrix &pd, vpMatrix &p, + vpMatrix &pnd, vpMatrix &pn, + vpMatrix &M, vpMatrix &Mdp) { - - - unsigned int i,j, k ; unsigned int cont_pts; /* */ double lamb_des[3]; /* */ @@ -240,16 +260,16 @@ HLM2D(unsigned int nb_pts, M[3*j+2][8] = 0 ; } - /** calcul de la pseudo-inverse V de M et des valeurs singulières **/ + /** calcul de la pseudo-inverse V de M et des valeurs singulieres **/ M.svd(sv,V); /***** La meilleure solution est le vecteur de V associe a la valeur singuliere la plus petite en valeur absolu. Pour cela on parcourt la matrice des valeurs singulieres - et on repère la plus petite valeur singulière, on en profite + et on repere la plus petite valeur singuliere, on en profite pour effectuer un controle sur le rang de la matrice : pas plus - de 2 valeurs singulières quasi=0 + de 2 valeurs singulieres quasi=0 *****/ vals_inf = fabs(sv[0]) ; vect = 0 ; @@ -268,7 +288,7 @@ HLM2D(unsigned int nb_pts, } - /** cas d'erreur : plus de 2 valeurs singulières =0 **/ + /** cas d'erreur : plus de 2 valeurs singulieres =0 **/ if (contZeros > 2) { //vpERROR_TRACE("matrix is rank deficient"); throw (vpMatrixException(vpMatrixException::matrixError, @@ -320,8 +340,8 @@ HLM3D(unsigned int nb_pts, unsigned int cont_pts; /* Pour compter le nombre de points dans l'image */ //unsigned int nl; /*** Nombre de lignes ***/ unsigned int nc ; /*** Nombre de colonnes ***/ - unsigned int pts_ref[4]; /*** définit lesquels des points de - l'image sont les points de référence***/ + unsigned int pts_ref[4]; /*** definit lesquels des points de + l'image sont les points de reference***/ /*** ***/ int perm; /*** Compte le nombre de permutations, quand le nombre de permutations =0 arret de l'ordonnancement **/ @@ -345,10 +365,10 @@ HLM3D(unsigned int nb_pts, vpMatrix H_int(3,3) ; - vpMatrix pn((nb_pts-3),3) ; //points courant nouveau repère + vpMatrix pn((nb_pts-3),3) ; //points courant nouveau repere - vpMatrix pnd((nb_pts-3),3) ; //points dérivés nouveau repère + vpMatrix pnd((nb_pts-3),3) ; //points derives nouveau repere /* preparation du changement de repere */ /**** @@ -491,7 +511,7 @@ HLM3D(unsigned int nb_pts, pour obtenir une solution il faut au moins 5 equations independantes donc il faut au moins la mise en correspondence de 3+5 points *****/ - vpColVector sv(nc) ; //Vecteur contenant les valeurs singulières + vpColVector sv(nc) ; //Vecteur contenant les valeurs singulieres CtC.svd(sv,V) ; @@ -521,9 +541,9 @@ HLM3D(unsigned int nb_pts, } /***** - Parcours de la matrice ordonnée des valeurs singulières - On note "cont_zeros" le nbre de valeurs quasi= à 0. - On note "vect" le rang de la plus petite valeur singlière + Parcours de la matrice ordonnee des valeurs singulieres + On note "cont_zeros" le nbre de valeurs quasi= a 0. + On note "vect" le rang de la plus petite valeur singliere en valeur absolu *****/ @@ -605,29 +625,30 @@ HLM3D(unsigned int nb_pts, } } +#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS /************************************************************************** * NOM : * Homographie_CrvMafCalculHomographie * * DESCRIPTION : - * Calcul de l'homographie, en fonction de la cible désirée et de la cible - * en cours. C'est une estimation linéaire. - * Cette procédure n'effectue pas elle-même le calcul de l'homographie : - * elle se contente d'appeler la bonne sous-procédure. - * Cette procédure est appellée par "crv_maf_calcul_tomographie". + * Calcul de l'homographie, en fonction de la cible desiree et de la cible + * en cours. C'est une estimation lineaire. + * Cette procedure n'effectue pas elle-meme le calcul de l'homographie : + * elle se contente d'appeler la bonne sous-procedure. + * Cette procedure est appellee par "crv_maf_calcul_tomographie". * **************************************************************************** * ENTREES : * STR_CIBLE_ASSER *cible_asser Pointeur sur structure contenant les - * commandes du robot, les données de la + * commandes du robot, les donnees de la * carte... * Voir "cvda/edixaa/param/robot.h" - * STR_VITESSE_ROBOT *data_common Pointeur sur la structure décrivant la + * STR_VITESSE_ROBOT *data_common Pointeur sur la structure decrivant la * cible d'asservissement. * Voir "cvda/edixia/param/param.h" * STR_MACH_DIV *machine_div Pointeur sur structure contenant divers - * paramètres de configuration du robot. + * parametres de configuration du robot. * Voir "cvda/edixia/param/param.h" * * SORTIES : @@ -636,7 +657,7 @@ HLM3D(unsigned int nb_pts, * **************************************************************************** - * AUTEUR : BOSSARD Nicolas. INSA Rennes 5ème année. + * AUTEUR : BOSSARD Nicolas. INSA Rennes 5eme annee. * * DATE DE CREATION : 01/12/98 * @@ -690,9 +711,57 @@ HLM(unsigned int q_cible, } /* fin procedure calcul_homogaphie */ +#endif // #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS + +void +HLM(unsigned int q_cible, + const std::vector<double> &xm, const std::vector<double> &ym, + const std::vector<double> &xmi, const std::vector<double> &ymi, + vpMatrix &H) +{ + unsigned int nbpt = (unsigned int)xm.size(); + + /**** + on regarde si il y a au moins un point mais pour l'homographie + il faut au moins quatre points + ****/ + vpMatrix pd(nbpt,3) ; + vpMatrix p(nbpt,3) ; + + for (unsigned int i=0;i<nbpt;i++) { + /**** + on assigne les points fournies par la structure robot + pour la commande globale + ****/ + pd[i][0] = xmi[i]; + pd[i][1] = ymi[i]; + pd[i][2] = 1.0 ; + p[i][0] = xm[i]; + p[i][1] = ym[i]; + p[i][2] = 1.0 ; + } + switch (q_cible) { + case (1): + case (2): + /* La cible est planaire de type points */ -#endif + HLM2D(nbpt,pd,p,H); + + break; + case (3) : /* cible non planaire : chateau */ + /* cible non planaire de type points */ + HLM3D(nbpt,pd,p,H); + break; + } /* fin switch */ + + + +} /* fin procedure calcul_homogaphie */ + +#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS + +#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS /*! \brief Computes the homography matrix from planar \cite TheseMalis or non planar points @@ -712,20 +781,15 @@ HLM(unsigned int q_cible, */ void vpHomography::HLM(unsigned int n, - double *xb, double *yb, - double *xa, double *ya , - bool isplanar, - vpHomography &aHb) + double *xb, double *yb, + double *xa, double *ya , + bool isplanar, + vpHomography &aHb) { -#ifndef DOXYGEN_SHOULD_SKIP_THIS - unsigned int i,j; unsigned int q_cible; vpMatrix H; // matrice d'homographie en metre - aHb.setIdentity(); - - if (isplanar) q_cible =1; else @@ -736,7 +800,56 @@ void vpHomography::HLM(unsigned int n, for(i=0;i<3;i++) for(j=0;j<3;j++) aHb[i][j] = H[i][j]; +} + +#endif //#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS + +/*! + From couples of matched points \f$^a{\bf p}=(x_a,y_a,1)\f$ in image a + and \f$^b{\bf p}=(x_b,y_b,1)\f$ in image b with homogeneous coordinates, computes the + homography matrix by resolving \f$^a{\bf p} = ^a{\bf H}_b\; ^b{\bf p}\f$ + using Ezio Malis linear method (HLM) \cite Malis00b. + + This method can consider points that are planar or non planar. The algorithm for planar + scene implemented in this file is described in Ezio + Malis PhD thesis \cite TheseMalis. + + \param xb, yb : Coordinates vector of matched points in image b. These coordinates are expressed in meters. + \param xa, ya : Coordinates vector of matched points in image a. These coordinates are expressed in meters. + \param isplanar : If true the points are assumed to be in a plane, + otherwise there are assumed to be non planar. + \param aHb : Estimated homography that relies the transformation from image a to image b. + + If the boolean isplanar is true the points are assumed to be in a plane + otherwise there are assumed to be non planar. + + \sa DLT() when the scene is planar. +*/ +void vpHomography::HLM(const std::vector<double> &xb, const std::vector<double> &yb, + const std::vector<double> &xa, const std::vector<double> &ya, + bool isplanar, + vpHomography &aHb) +{ + unsigned int n = (unsigned int) xb.size(); + if (yb.size() != n || xa.size() != n || ya.size() != n) + throw(vpException(vpException::dimensionError, + "Bad dimension for HLM shomography estimation")); + + // 4 point are required + if(n<4) + throw(vpException(vpException::fatalError, "There must be at least 4 matched points")); + + // The reference plane is the plane build from the 3 first points. + unsigned int q_cible; + vpMatrix H; // matrice d'homographie en metre + + if (isplanar) + q_cible =1; + else + q_cible =3; + + ::HLM(q_cible, xa, ya, xb, yb, H) ; -#endif + aHb = H; } diff --git a/src/computer-vision/homography-estimation/vpHomographyRansac.cpp b/src/computer-vision/homography-estimation/vpHomographyRansac.cpp index d60d8a77db23a306e5c9e0c8002f4e418c76326f..777c0eeb144c63f01d34b991221619e66132d9a7 100644 --- a/src/computer-vision/homography-estimation/vpHomographyRansac.cpp +++ b/src/computer-vision/homography-estimation/vpHomographyRansac.cpp @@ -12,7 +12,7 @@ * Version control * =============== * - * $Id: vpHomographyRansac.cpp 3496 2011-11-22 15:14:32Z fspindle $ + * $Id: vpHomographyRansac.cpp 4649 2014-02-07 14:57:11Z fspindle $ * optimized by Tran to improve speed. * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ @@ -20,6 +20,10 @@ #include <visp/vpColVector.h> #include <visp/vpRansac.h> +#include <visp/vpImage.h> +#include <visp/vpDisplay.h> +#include <visp/vpMeterPixelConversion.h> + #define vpEps 1e-6 /*! @@ -27,6 +31,10 @@ \brief function used to estimate an homography using the Ransac algorithm */ +#ifndef DOXYGEN_SHOULD_SKIP_THIS + +bool iscolinear(double *x1, double *x2, double *x3); +bool isColinear(vpColVector &p1, vpColVector &p2, vpColVector &p3); bool iscolinear(double *x1, double *x2, double *x3) @@ -42,6 +50,11 @@ iscolinear(double *x1, double *x2, double *x3) // scale. return ((vpColVector::cross(p2-p1, p3-p1).sumSquare()) < vpEps); } +bool +isColinear(vpColVector &p1, vpColVector &p2, vpColVector &p3) +{ + return ((vpColVector::cross(p2-p1, p3-p1).sumSquare()) < vpEps); +} bool @@ -149,14 +162,49 @@ vpHomography::degenerateConfiguration(vpColVector &x, unsigned int *ind) iscolinear(pb[0],pb[2],pb[3]) || iscolinear(pb[1],pb[2],pb[3])); } +bool +vpHomography::degenerateConfiguration(const std::vector<double> &xb, const std::vector<double> &yb, + const std::vector<double> &xa, const std::vector<double> &ya) +{ + unsigned int n = (unsigned int)xb.size(); + if (n < 4) + throw(vpException(vpException::fatalError, "There must be at least 4 matched points")); + + std::vector<vpColVector> pa(n), pb(n); + for (unsigned i=0; i<n;i++) { + pa[i].resize(3); + pa[i][0] = xa[i]; + pa[i][1] = ya[i]; + pa[i][2] = 1; + pb[i].resize(3); + pb[i][0] = xb[i]; + pb[i][1] = yb[i]; + pb[i][2] = 1; + } + + for (unsigned int i = 0; i < n-2; i++) { + for (unsigned int j = i+1; j < n-1; j++) { + for (unsigned int k = j+1; k < n ; k++) + { + if (isColinear(pa[i], pa[j], pa[k])) { + return true; + } + if (isColinear(pb[i], pb[j], pb[k])){ + return true; + } + } + } + } + return false; +} // Fit model to this random selection of data points. void vpHomography::computeTransformation(vpColVector &x, unsigned int *ind, vpColVector &M) { unsigned int i ; unsigned int n = x.getRows()/4 ; - double xa[4], xb[4]; - double ya[4], yb[4]; + std::vector<double> xa(4), xb(4); + std::vector<double> ya(4), yb(4); unsigned int n2 = n * 2; unsigned int ind2; for(i=0 ; i < 4 ; i++) @@ -171,8 +219,7 @@ vpHomography::computeTransformation(vpColVector &x, unsigned int *ind, vpColVect vpHomography aHb ; try { - vpHomography::HLM(4,xb, yb, xa, ya, true, aHb); - //vpHomography::HLM(8, xb, yb, xa, ya, false, aHb); //modified 13/09 + vpHomography::HLM(xb, yb, xa, ya, true, aHb); } catch(...) { @@ -240,6 +287,7 @@ vpHomography::computeResidual(vpColVector &x, vpColVector &M, vpColVector &d) return 0 ; } +#endif //#ifndef DOXYGEN_SHOULD_SKIP_THIS void @@ -261,14 +309,20 @@ vpHomography::initRansac(unsigned int n, } } +#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS + +/*! + \deprecated This method is deprecated. You should rather use + vpHomography::ransac(const std::vector<double> &, const std::vector<double> &, const std::vector<double> &, const std::vector<double> &, vpHomography &, std::vector<bool> &, double &, unsigned int, double, bool) + */ bool vpHomography::ransac(unsigned int n, - double *xb, double *yb, - double *xa, double *ya , - vpHomography &aHb, - int consensus, - double threshold - ) + double *xb, double *yb, + double *xa, double *ya , + vpHomography &aHb, + int consensus, + double threshold + ) { vpColVector x ; vpHomography::initRansac(n, xb, yb, xa, ya, x) ; @@ -291,6 +345,8 @@ vpHomography::ransac(unsigned int n, } /*! + \deprecated This method is deprecated. You should rather use + vpHomography::ransac(const std::vector<double> &, const std::vector<double> &, const std::vector<double> &, const std::vector<double> &, vpHomography &, std::vector<bool> &, double &, unsigned int, double, bool) Computes homography matrix \f$ b^H_a \f$ such as \f$X_b = b^H_a X_a \f$ with \f$ X_a = (xa, ya)^t \f$ and \f$ X_b = (xb, yb)^t \f$. @@ -321,14 +377,14 @@ vpHomography::ransac(unsigned int n, */ bool vpHomography::ransac(unsigned int n, - double *xb, double *yb, - double *xa, double *ya , - vpHomography &bHa, - vpColVector &inliers, - double& /* residual */, - int consensus, - double threshold, - double areaThreshold) + double *xb, double *yb, + double *xa, double *ya , + vpHomography &bHa, + vpColVector &inliers, + double /* residual */, + int consensus, + double threshold, + double areaThreshold) { vpColVector x ; vpHomography::initRansac(n, xb, yb, xa, ya, x); @@ -348,9 +404,215 @@ bool vpHomography::ransac(unsigned int n, bHa /= bHa[2][2]; return ransacable; } +#endif //#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ +/*! + + From couples of matched points \f$^a{\bf p}=(x_a,y_a,1)\f$ in image a + and \f$^b{\bf p}=(x_b,y_b,1)\f$ in image b with homogeneous coordinates, computes the + homography matrix by resolving \f$^a{\bf p} = ^a{\bf H}_b\; ^b{\bf p}\f$ + using Ransac algorithm. + + \param xb, yb : Coordinates vector of matched points in image b. These coordinates are expressed in meters. + \param xa, ya : Coordinates vector of matched points in image a. These coordinates are expressed in meters. + \param aHb : Estimated homography that relies the transformation from image a to image b. + \param inliers : Vector that indicates if a matched point is an inlier (true) or an outlier (false). + \param residual : Global residual computed as + \f$r = \sqrt{1/n \sum_{inliers} {\| {^a{\bf p} - {\hat{^a{\bf H}_b}} {^b{\bf p}}} \|}^{2}}\f$ with \f$n\f$ the + number of inliers. + + \param nbInliersConsensus : Minimal number of points requested to fit the estimated homography. + + \param threshold : Threshold for outlier removing. A point is considered as an outlier if the reprojection error + \f$\| {^a{\bf p} - {\hat{^a{\bf H}_b}} {^b{\bf p}}} \|\f$ is greater than this threshold. + + \param normalization : When set to true, the coordinates of the points are normalized. The normalization + carried out is the one preconized by Hartley. + + \return true if the homography could be computed, false otherwise. + +*/ +bool vpHomography::ransac(const std::vector<double> &xb, const std::vector<double> &yb, + const std::vector<double> &xa, const std::vector<double> &ya, + vpHomography &aHb, + std::vector<bool> &inliers, + double &residual, + unsigned int nbInliersConsensus, + double threshold, + bool normalization) +{ + unsigned int n = (unsigned int)xb.size(); + if (yb.size() != n || xa.size() != n || ya.size() != n) + throw(vpException(vpException::dimensionError, + "Bad dimension for robust homography estimation")); + + // 4 point are required + if(n<4) + throw(vpException(vpException::fatalError, "There must be at least 4 matched points")); + + vpUniRand random((const long)time(NULL)) ; + + std::vector<unsigned int> best_consensus; + std::vector<unsigned int> cur_consensus; + std::vector<unsigned int> cur_outliers; + std::vector<unsigned int> cur_randoms; + + std::vector<unsigned int> rand_ind; + + unsigned int nbMinRandom = 4 ; + unsigned int ransacMaxTrials = 1000; + unsigned int maxDegenerateIter = 1000; + + unsigned int nbTrials = 0; + unsigned int nbDegenerateIter = 0; + unsigned int nbInliers = 0; + + bool foundSolution = false; + + std::vector<double> xa_rand(nbMinRandom); + std::vector<double> ya_rand(nbMinRandom); + std::vector<double> xb_rand(nbMinRandom); + std::vector<double> yb_rand(nbMinRandom); + + if (inliers.size() != n) + inliers.resize(n); + + while (nbTrials < ransacMaxTrials && nbInliers < nbInliersConsensus) + { + cur_outliers.clear(); + cur_randoms.clear(); + + bool degenerate = true; + while(degenerate == true){ + std::vector<bool> usedPt(n, false); + + rand_ind.clear(); + for(unsigned int i = 0; i < nbMinRandom; i++) + { + // Generate random indicies in the range 0..n + unsigned int r = (unsigned int)ceil(random()*n) -1; + while(usedPt[r]) { + r = (unsigned int)ceil(random()*n) -1; + } + usedPt[r] = true; + rand_ind.push_back(r); + + xa_rand[i] = xa[r]; + ya_rand[i] = ya[r]; + xb_rand[i] = xb[r]; + yb_rand[i] = yb[r]; + } + + try{ + if (! vpHomography::degenerateConfiguration(xb_rand, yb_rand, xa_rand, ya_rand)) { + vpHomography::DLT(xb_rand, yb_rand, xa_rand, ya_rand, aHb, normalization); + degenerate = false; + } + } + catch(...){ + degenerate = true; + } + + nbDegenerateIter ++; + + if (nbDegenerateIter > maxDegenerateIter){ + vpERROR_TRACE("Unable to select a nondegenerate data set"); + throw(vpException(vpException::fatalError, "Unable to select a nondegenerate data set")); + } + } + + aHb /= aHb[2][2] ; + + // Computing Residual + double r = 0; + vpColVector a(3), b(3), c(3) ; + for (unsigned int i=0 ; i < nbMinRandom ; i++) { + a[0] = xa_rand[i] ; a[1] = ya_rand[i] ; a[2] = 1 ; + b[0] = xb_rand[i] ; b[1] = yb_rand[i] ; b[2] = 1 ; + + c = aHb*b; c /= c[2] ; + r += (a-c).sumSquare() ; + //cout << "point " <<i << " " << (a-c).sumSquare() <<endl ;; + } + + // Finding inliers & ouliers + r = sqrt(r/nbMinRandom); + //std::cout << "Candidate residual: " << r << std::endl; + if (r < threshold) + { + unsigned int nbInliersCur = 0; + for (unsigned int i = 0; i < n ; i++) + { + a[0] = xa[i] ; a[1] = ya[i] ; a[2] = 1 ; + b[0] = xb[i] ; b[1] = yb[i] ; b[2] = 1 ; + + c = aHb*b ; c /= c[2] ; + double error = sqrt((a-c).sumSquare()) ; + if(error <= threshold){ + nbInliersCur++; + cur_consensus.push_back(i); + inliers[i] = true; + } + else{ + cur_outliers.push_back(i); + inliers[i] = false; + } + } + //std::cout << "nb inliers that matches: " << nbInliersCur << std::endl; + if(nbInliersCur > nbInliers) + { + foundSolution = true; + best_consensus = cur_consensus; + nbInliers = nbInliersCur; + } + + cur_consensus.clear(); + } + + nbTrials++; + if(nbTrials >= ransacMaxTrials){ + vpERROR_TRACE("Ransac reached the maximum number of trials"); + foundSolution = true; + } + } + + if(foundSolution){ + if(nbInliers >= nbInliersConsensus) + { + std::vector<double> xa_best(best_consensus.size()); + std::vector<double> ya_best(best_consensus.size()); + std::vector<double> xb_best(best_consensus.size()); + std::vector<double> yb_best(best_consensus.size()); + + for(unsigned i = 0 ; i < best_consensus.size(); i++) + { + xa_best[i] = xa[best_consensus[i]]; + ya_best[i] = ya[best_consensus[i]]; + xb_best[i] = xb[best_consensus[i]]; + yb_best[i] = yb[best_consensus[i]]; + } + + vpHomography::DLT(xb_best, yb_best, xa_best, ya_best, aHb, normalization) ; + aHb /= aHb[2][2]; + + residual = 0 ; + vpColVector a(3), b(3), c(3); + for (unsigned int i=0 ; i < best_consensus.size() ; i++) { + a[0] = xa_best[i] ; a[1] = ya_best[i] ; a[2] = 1 ; + b[0] = xb_best[i] ; b[1] = yb_best[i] ; b[2] = 1 ; + + c = aHb*b ; c /= c[2] ; + residual += (a-c).sumSquare() ; + } + + residual = sqrt(residual/best_consensus.size()); + return true; + } + else { + return false; + } + } + else { + return false; + } +} diff --git a/src/computer-vision/homography-estimation/vpHomographyVVS.cpp b/src/computer-vision/homography-estimation/vpHomographyVVS.cpp index bbb25b6c7410d3de049a0ebef22a89202954ace4..9d8688d7176c785a33b46158b1c7c24c419de844 100644 --- a/src/computer-vision/homography-estimation/vpHomographyVVS.cpp +++ b/src/computer-vision/homography-estimation/vpHomographyVVS.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpHomographyVVS.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpHomographyVVS.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -55,6 +55,8 @@ const double vpHomography::threshold_rotation = 1e-7; const double vpHomography::threshold_displacement = 1e-18; +#ifndef DOXYGEN_SHOULD_SKIP_THIS + static void updatePoseRotation(vpColVector& dx,vpHomogeneousMatrix& mati) { @@ -126,14 +128,16 @@ vpHomography::computeRotation(unsigned int nbpoint, unsigned int n=0 ; for (unsigned int i=0 ; i < nbpoint ; i++) { // if ((c2P[i].get_x() !=-1) && (c1P[i].get_x() !=-1)) - if ( (std::fabs(c2P[i].get_x() + 1) > std::fabs(vpMath::maximum(c2P[i].get_x(), 1.))) - && - (std::fabs(c1P[i].get_x() + 1) > std::fabs(vpMath::maximum(c1P[i].get_x(), 1.))) ) - { - n++ ; - } + if ( (std::fabs(c2P[i].get_x() + 1) > std::fabs(vpMath::maximum(c2P[i].get_x(), 1.))) + && + (std::fabs(c1P[i].get_x() + 1) > std::fabs(vpMath::maximum(c1P[i].get_x(), 1.))) ) + { + n++ ; + } } - if ((only_1==1) || (only_2==1)) ; else n *=2 ; + //if ((only_1==1) || (only_2==1)) ; else n *=2 ; + if ( (! only_1) && (! only_2) ) + n *=2 ; vpRobust robust(n); vpColVector res(n) ; @@ -159,9 +163,9 @@ vpHomography::computeRotation(unsigned int nbpoint, int k =0 ; for (unsigned int i=0 ; i < nbpoint ; i++) { //if ((c2P[i].get_x() !=-1) && (c1P[i].get_x() !=-1)) - if ( (std::fabs(c2P[i].get_x() + 1) > std::fabs(vpMath::maximum(c2P[i].get_x(), 1.))) - && - (std::fabs(c1P[i].get_x() + 1) > std::fabs(vpMath::maximum(c1P[i].get_x(), 1.))) ) + if ( (std::fabs(c2P[i].get_x() + 1) > std::fabs(vpMath::maximum(c2P[i].get_x(), 1.))) + && + (std::fabs(c1P[i].get_x() + 1) > std::fabs(vpMath::maximum(c1P[i].get_x(), 1.))) ) { p2[0] = c2P[i].get_x() ; p2[1] = c2P[i].get_y() ; @@ -240,35 +244,35 @@ vpHomography::computeRotation(unsigned int nbpoint, { robust.setIteration(0); - for (unsigned int k=0 ; k < n ; k++) + for (unsigned int l=0 ; l < n ; l++) { - res[k] = vpMath::sqr(e[2*k]) + vpMath::sqr(e[2*k+1]) ; + res[l] = vpMath::sqr(e[2*l]) + vpMath::sqr(e[2*l+1]) ; } robust.MEstimator(vpRobust::TUKEY, res, w); // compute the pseudo inverse of the interaction matrix - for (unsigned int k=0 ; k < n ; k++) + for (unsigned int l=0 ; l < n ; l++) { - W[2*k][2*k] = w[k] ; - W[2*k+1][2*k+1] = w[k] ; + W[2*l][2*l] = w[l] ; + W[2*l+1][2*l+1] = w[l] ; } } else { - for (unsigned int k=0 ; k < 2*n ; k++) W[k][k] = 1 ; + for (unsigned int l=0 ; l < 2*n ; l++) W[l][l] = 1 ; } // CreateDiagonalMatrix(w, W) ; (L).pseudoInverse(Lp, 1e-6) ; // Compute the camera velocity - vpColVector c2Rc1, v(6) ; + vpColVector c2rc1, v(6) ; - c2Rc1 = -2*Lp*W*e ; - for (unsigned int i=0 ; i < 3 ; i++) v[i+3] = c2Rc1[i] ; + c2rc1 = -2*Lp*W*e ; + for (unsigned int i=0 ; i < 3 ; i++) v[i+3] = c2rc1[i] ; // only for simulation - updatePoseRotation(c2Rc1, c2Mc1) ; + updatePoseRotation(c2rc1, c2Mc1) ; r =e.sumSquare() ; if ((W*e).sumSquare() < 1e-10) break ; @@ -307,13 +311,9 @@ vpHomography::computeDisplacement(unsigned int nbpoint, int userobust ) { - - vpColVector e(2) ; double r_1 = -1 ; - - vpColVector p2(3) ; vpColVector p1(3) ; vpColVector Hp2(3) ; @@ -324,13 +324,17 @@ vpHomography::computeDisplacement(unsigned int nbpoint, vpMatrix H1(2,6) ; vpColVector e1(2) ; - int only_1 = 1 ; - int only_2 = 0 ; + int only_1; + int only_2; int iter = 0 ; - unsigned int i ; unsigned int n=0 ; n = nbpoint ; - if ((only_1==1) || (only_2==1)) ; else n *=2 ; + only_1 = 1 ; + only_2 = 0 ; + + //if ((only_1==1) || (only_2==1)) ; else n *=2 ; + if ( (! only_1) && (! only_2) ) + n *=2 ; vpRobust robust(n); vpColVector res(n) ; @@ -347,11 +351,9 @@ vpHomography::computeDisplacement(unsigned int nbpoint, iter =0 ; while (vpMath::equal(r_1,r,threshold_displacement) == false ) { - r_1 =r ; // compute current position - //Change frame (current) vpHomogeneousMatrix c1Mc2, c2Mo ; vpRotationMatrix c1Rc2, c2Rc1 ; @@ -367,10 +369,9 @@ vpHomography::computeDisplacement(unsigned int nbpoint, getPlaneInfo(oN, c1Mo, N1, d1) ; getPlaneInfo(oN, c2Mo, N2, d2) ; - vpMatrix L(2,3), Lp ; int k =0 ; - for (i=0 ; i < nbpoint ; i++) + for (unsigned int i=0 ; i < nbpoint ; i++) { p2[0] = c2P[i].get_x() ; p2[1] = c2P[i].get_y() ; @@ -405,18 +406,16 @@ vpHomography::computeDisplacement(unsigned int nbpoint, vpMatrix c1CFc2(6,6) ; { vpMatrix sTR = c1Tc2.skew()*(vpMatrix)c1Rc2 ; - for (unsigned int k=0 ; k < 3 ; k++) + for (unsigned int k_=0 ; k_ < 3 ; k_++) for (unsigned int l=0 ; l<3 ; l++) { - c1CFc2[k][l] = c1Rc2[k][l] ; - c1CFc2[k+3][l+3] = c1Rc2[k][l] ; - c1CFc2[k][l+3] = sTR[k][l] ; + c1CFc2[k_][l] = c1Rc2[k_][l] ; + c1CFc2[k_+3][l+3] = c1Rc2[k_][l] ; + c1CFc2[k_][l+3] = sTR[k_][l] ; } } H2 = H2*c1CFc2 ; - - // Set up the error vector e2[0] = Hp2[0] - c1P[i].get_x() ; e2[1] = Hp2[1] - c1P[i].get_y() ; @@ -435,7 +434,6 @@ vpHomography::computeDisplacement(unsigned int nbpoint, e1[0] = Hp1[0] - c2P[i].get_x() ; e1[1] = Hp1[1] - c2P[i].get_y() ; - if (only_2==1) { if (k == 0) { L = H2 ; e = e2 ; } @@ -474,23 +472,22 @@ vpHomography::computeDisplacement(unsigned int nbpoint, if (userobust) { robust.setIteration(0); - for (unsigned int k=0 ; k < n ; k++) + for (unsigned int l=0 ; l < n ; l++) { - res[k] = vpMath::sqr(e[2*k]) + vpMath::sqr(e[2*k+1]) ; + res[l] = vpMath::sqr(e[2*l]) + vpMath::sqr(e[2*l+1]) ; } robust.MEstimator(vpRobust::TUKEY, res, w); - // compute the pseudo inverse of the interaction matrix - for (unsigned int k=0 ; k < n ; k++) + for (unsigned int l=0 ; l < n ; l++) { - W[2*k][2*k] = w[k] ; - W[2*k+1][2*k+1] = w[k] ; + W[2*l][2*l] = w[l] ; + W[2*l+1][2*l+1] = w[l] ; } } else { - for (unsigned int k=0 ; k < 2*n ; k++) W[k][k] = 1 ; + for (unsigned int l=0 ; l < 2*n ; l++) W[l][l] = 1 ; } (W*L).pseudoInverse(Lp, 1e-16) ; // Compute the camera velocity @@ -504,8 +501,6 @@ vpHomography::computeDisplacement(unsigned int nbpoint, // UpdatePose2(c2Tcc1, c2Mc1) ; r =(W*e).sumSquare() ; - - if (r < 1e-15) {break ; } if (iter>1000){break ; } if (r>r_1) { break ; } @@ -532,8 +527,6 @@ vpHomography::computeDisplacement(unsigned int nbpoint, vpColVector e(2) ; double r_1 = -1 ; - - vpColVector p2(3) ; vpColVector p1(3) ; vpColVector Hp2(3) ; @@ -545,13 +538,17 @@ vpHomography::computeDisplacement(unsigned int nbpoint, vpColVector e1(2) ; - int only_1 = 1 ; - int only_2 = 0 ; + int only_1; + int only_2; int iter = 0 ; unsigned int i ; unsigned int n=0 ; + only_1 = 1 ; + only_2 = 0 ; n = nbpoint ; - if ((only_1==1) || (only_2==1)) ; else n *=2 ; + // if ((only_1==1) || (only_2==1)) ; else n *=2 ; + if ( (! only_1) && (! only_2) ) + n *=2 ; vpRobust robust(n); vpColVector res(n) ; @@ -626,18 +623,16 @@ vpHomography::computeDisplacement(unsigned int nbpoint, vpMatrix c1CFc2(6,6) ; { vpMatrix sTR = c1Tc2.skew()*(vpMatrix)c1Rc2 ; - for (unsigned int k=0 ; k < 3 ; k++) + for (unsigned int k_=0 ; k_ < 3 ; k_++) for (unsigned int l=0 ; l<3 ; l++) { - c1CFc2[k][l] = c1Rc2[k][l] ; - c1CFc2[k+3][l+3] = c1Rc2[k][l] ; - c1CFc2[k][l+3] = sTR[k][l] ; + c1CFc2[k_][l] = c1Rc2[k_][l] ; + c1CFc2[k_+3][l+3] = c1Rc2[k_][l] ; + c1CFc2[k_][l+3] = sTR[k_][l] ; } } H2 = H2*c1CFc2 ; - - // Set up the error vector e2[0] = Hp2[0] - c1P[i].get_x() ; e2[1] = Hp2[1] - c1P[i].get_y() ; @@ -695,23 +690,23 @@ vpHomography::computeDisplacement(unsigned int nbpoint, if (userobust) { robust.setIteration(0); - for (unsigned int k=0 ; k < n ; k++) + for (unsigned int k_=0 ; k_ < n ; k_++) { - res[k] = vpMath::sqr(e[2*k]) + vpMath::sqr(e[2*k+1]) ; + res[k_] = vpMath::sqr(e[2*k_]) + vpMath::sqr(e[2*k_+1]) ; } robust.MEstimator(vpRobust::TUKEY, res, w); // compute the pseudo inverse of the interaction matrix - for (unsigned int k=0 ; k < n ; k++) + for (unsigned int k_=0 ; k_ < n ; k_++) { - W[2*k][2*k] = w[k] ; - W[2*k+1][2*k+1] = w[k] ; + W[2*k_][2*k_] = w[k_] ; + W[2*k_+1][2*k_+1] = w[k_] ; } } else { - for (unsigned int k=0 ; k < 2*n ; k++) W[k][k] = 1 ; + for (unsigned int k_=0 ; k_ < 2*n ; k_++) W[k_][k_] = 1 ; } (W*L).pseudoInverse(Lp, 1e-16) ; // Compute the camera velocity @@ -737,3 +732,4 @@ vpHomography::computeDisplacement(unsigned int nbpoint, } +#endif //#ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/src/computer-vision/pose-estimation/vpLevenbergMarquartd.cpp b/src/computer-vision/pose-estimation/vpLevenbergMarquartd.cpp index 2f4c7aaf18babba5f2f26ae18e0ba8ff9e18c9f7..b5dcf13e714809181555c521c14656df59c2d857 100644 --- a/src/computer-vision/pose-estimation/vpLevenbergMarquartd.cpp +++ b/src/computer-vision/pose-estimation/vpLevenbergMarquartd.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpLevenbergMarquartd.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpLevenbergMarquartd.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -46,6 +46,7 @@ #include <cmath> // std::fabs #include <limits> // numeric_limits #include <iostream> +#include <algorithm> // std::min #define SIGN(x) ((x) < 0 ? -1 : 1) #define SWAP(a,b,c) {(c) = (a); (a) = (b); (b) = (c);} @@ -233,7 +234,7 @@ double enorm (const double *x, int n) * */ int lmpar(int n, double *r, int ldr, int *ipvt, double *diag, double *qtb, - double *delta, double *par, double *x, double *sdiag, double *wa1, double *wa2) + double *delta, double *par, double *x, double *sdiag, double *wa1, double *wa2) { const double tol1 = 0.1, tol001 = 0.001; /* tolerance a 0.1 et a 0.001 */ @@ -276,8 +277,8 @@ int lmpar(int n, double *r, int ldr, int *ipvt, double *diag, double *qtb, if (jm1 >= 0) { - for (unsigned int j = 0; j <= (unsigned int)jm1; j++) - wa1[j] -= *MIJ(r, i, j, ldr) * temp; + for (unsigned int j = 0; j <= (unsigned int)jm1; j++) + wa1[j] -= *MIJ(r, i, j, ldr) * temp; } } } @@ -315,22 +316,22 @@ int lmpar(int n, double *r, int ldr, int *ipvt, double *diag, double *qtb, { for (int i = 0; i < n; i++) { - l = ipvt[i]; - wa1[i] = diag[l] * (wa2[l] / dxnorm); + l = ipvt[i]; + wa1[i] = diag[l] * (wa2[l] / dxnorm); } for (int i = 0; i < n; i++) { - long im1; - sum = 0.0; - im1 = (i - 1L); - - if (im1 >= 0) - { - for (unsigned int j = 0; j <= (unsigned int)im1; j++) - sum += (*MIJ(r, i, j, ldr) * wa1[j]); - } - wa1[i] = (wa1[i] - sum) / *MIJ(r, i, i, ldr); + long im1; + sum = 0.0; + im1 = (i - 1L); + + if (im1 >= 0) + { + for (unsigned int j = 0; j <= (unsigned int)im1; j++) + sum += (*MIJ(r, i, j, ldr) * wa1[j]); + } + wa1[i] = (wa1[i] - sum) / *MIJ(r, i, i, ldr); } temp = enorm(wa1, n); @@ -346,7 +347,7 @@ int lmpar(int n, double *r, int ldr, int *ipvt, double *diag, double *qtb, sum = 0.0; for (int j = 0; j <= i; j++) - sum += *MIJ(r, i, j, ldr) * qtb[j]; + sum += *MIJ(r, i, j, ldr) * qtb[j]; l = ipvt[i]; wa1[i] = sum / diag[l]; @@ -384,17 +385,17 @@ int lmpar(int n, double *r, int ldr, int *ipvt, double *diag, double *qtb, */ //if (*par == 0.0) if (std::fabs(*par) <= std::numeric_limits<double>::epsilon() ) - *par = vpMath::maximum(dwarf, (tol001 * paru)); + *par = vpMath::maximum(dwarf, (tol001 * paru)); temp = sqrt(*par); for (int i = 0; i < n; i++) - wa1[i] = temp * diag[i]; + wa1[i] = temp * diag[i]; qrsolv(n, r, ldr, ipvt, wa1, qtb, x, sdiag, wa2); for (int i = 0; i < n; i++) - wa2[i] = diag[i] * x[i]; + wa2[i] = diag[i] * x[i]; dxnorm = enorm(wa2, n); temp = fp; @@ -409,16 +410,15 @@ int lmpar(int n, double *r, int ldr, int *ipvt, double *diag, double *qtb, //if ((std::fabs(fp) <= tol1 * (*delta)) || ((parl == 0.0) && (fp <= temp) // && (temp < 0.0)) || (iter == 10)) if ((std::fabs(fp) <= tol1 * (*delta)) || ((std::fabs(parl) <= std::numeric_limits<double>::epsilon()) && (fp <= temp) - && (temp < 0.0)) || (iter == 10)) + && (temp < 0.0)) || (iter == 10)) { - /* - * terminaison. - */ + // terminaison. - if (iter == 0) - *par = 0.0; + // Remove the two next lines since this is a dead code + /* if (iter == 0) + *par = 0.0; */ - return (0); + return (0); } /* @@ -427,20 +427,20 @@ int lmpar(int n, double *r, int ldr, int *ipvt, double *diag, double *qtb, for (int i = 0; i < n; i++) { - l = ipvt[i]; - wa1[i] = diag[l] * (wa2[l] / dxnorm); + l = ipvt[i]; + wa1[i] = diag[l] * (wa2[l] / dxnorm); } for (unsigned int i = 0; i < (unsigned int)n; i++) { - wa1[i] = wa1[i] / sdiag[i]; - temp = wa1[i]; - jp1 = i + 1; - if ( (unsigned int) n >= jp1) - { - for (unsigned int j = jp1; j < (unsigned int)n; j++) - wa1[j] -= (*MIJ(r, i, j, ldr) * temp); - } + wa1[i] = wa1[i] / sdiag[i]; + temp = wa1[i]; + jp1 = i + 1; + if ( (unsigned int) n >= jp1) + { + for (unsigned int j = jp1; j < (unsigned int)n; j++) + wa1[j] -= (*MIJ(r, i, j, ldr) * temp); + } } temp = enorm(wa1, n); @@ -451,10 +451,10 @@ int lmpar(int n, double *r, int ldr, int *ipvt, double *diag, double *qtb, * de parl ou paru. */ if (fp > 0.0) - parl = vpMath::maximum(parl, *par); + parl = vpMath::maximum(parl, *par); if (fp < 0.0) - paru = vpMath::minimum(paru, *par); + paru = vpMath::minimum(paru, *par); /* * calcul d'une estimee ameliree de "par". diff --git a/src/computer-vision/pose-estimation/vpLevenbergMarquartd.h b/src/computer-vision/pose-estimation/vpLevenbergMarquartd.h index 36ea86d6658f10c6ed6d6c50487b8bc147b9119e..a746f59a44f380174571c9fa239a35248a301ed1 100644 --- a/src/computer-vision/pose-estimation/vpLevenbergMarquartd.h +++ b/src/computer-vision/pose-estimation/vpLevenbergMarquartd.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpLevenbergMarquartd.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpLevenbergMarquartd.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/computer-vision/pose-estimation/vpPose.cpp b/src/computer-vision/pose-estimation/vpPose.cpp index 292e2b0b2989c39e30c7b85d6b62c10610ef87f3..b139175197c215cf8b2df08c5e385b6a47762f29 100644 --- a/src/computer-vision/pose-estimation/vpPose.cpp +++ b/src/computer-vision/pose-estimation/vpPose.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * -* $Id: vpPose.cpp 4056 2013-01-05 13:04:42Z fspindle $ +* $Id: vpPose.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. -* Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +* Copyright (C) 2005 - 2014 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 @@ -71,11 +71,10 @@ vpPose::init() #endif npt = 0 ; listP.clear() ; + c3d.clear(); lambda = 0.25 ; - c3d = NULL ; - vvsIterMax = 200 ; distanceToPlaneForCoplanarityTest = 0.001 ; @@ -86,13 +85,19 @@ vpPose::init() ransacThreshold = 0.0001; ransacNbInlierConsensus = 4; + residual = 0; #if (DEBUG_LEVEL1) std::cout << "end vpPose::Init() " << std::endl ; #endif } +/*! Defaukt constructor. */ vpPose::vpPose() + : npt(0), listP(), residual(0), lambda(0.25), vvsIterMax(200), c3d(), + computeCovariance(false), covarianceMatrix(), + ransacNbInlierConsensus(4), ransacMaxTrials(1000), ransacInliers(), ransacThreshold(0.0001), + distanceToPlaneForCoplanarityTest(0.001) { #if (DEBUG_LEVEL1) std::cout << "begin vpPose::vpPose() " << std::endl ; @@ -107,7 +112,7 @@ vpPose::vpPose() } /*! -\brief destructor delete the array of point (freed the memory) + Destructor that deletes the array of point (freed the memory). */ vpPose::~vpPose() { @@ -122,7 +127,7 @@ vpPose::~vpPose() #endif } /*! -\brief delete the array of point + Delete the array of point */ void vpPose::clearPoint() @@ -338,8 +343,7 @@ the pose matrix 'cMo'. double vpPose::computeResidual(const vpHomogeneousMatrix &cMo) const { - - double residual = 0 ; + double residual_ = 0 ; vpPoint P ; for(std::list<vpPoint>::const_iterator it=listP.begin(); it != listP.end(); ++it) { @@ -349,9 +353,9 @@ vpPose::computeResidual(const vpHomogeneousMatrix &cMo) const P.track(cMo) ; - residual += vpMath::sqr(x-P.get_x()) + vpMath::sqr(y-P.get_y()) ; + residual_ += vpMath::sqr(x-P.get_x()) + vpMath::sqr(y-P.get_y()) ; } - return residual ; + return residual_ ; } @@ -672,8 +676,8 @@ vpPose::poseFromRectangle(vpPoint &p1,vpPoint &p2, vpHomogeneousMatrix & cMo) { - double rectx[4] ; - double recty[4] ; + std::vector<double> rectx(4) ; + std::vector<double> recty(4) ; rectx[0]= 0 ; recty[0]=0 ; rectx[1]=1 ; @@ -682,8 +686,8 @@ vpPose::poseFromRectangle(vpPoint &p1,vpPoint &p2, recty[2]=1 ; rectx[3]=0 ; recty[3]=1 ; - double irectx[4] ; - double irecty[4] ; + std::vector<double> irectx(4) ; + std::vector<double> irecty(4) ; irectx[0]=(p1.get_x()) ; irecty[0]=(p1.get_y()) ; irectx[1]=(p2.get_x()) ; @@ -697,8 +701,8 @@ vpPose::poseFromRectangle(vpPoint &p1,vpPoint &p2, vpMatrix H(3,3); vpHomography hom; - // vpHomography::HartleyDLT(4,rectx,recty,irectx,irecty,hom); - vpHomography::HLM(4,rectx,recty,irectx,irecty,1,hom); + // vpHomography::HartleyDLT(rectx,recty,irectx,irecty,hom); + vpHomography::HLM(rectx,recty,irectx,irecty,1,hom); for (unsigned int i=0 ; i < 3 ; i++) for(unsigned int j=0 ; j < 3 ; j++) H[i][j] = hom[i][j] ; diff --git a/src/computer-vision/pose-estimation/vpPose.h b/src/computer-vision/pose-estimation/vpPose.h index 282718cf670e40295de3b7e046cd9bdf78a66ddf..dd203f1b6914c14ffee6fa350e01ec6b2ed57c4c 100644 --- a/src/computer-vision/pose-estimation/vpPose.h +++ b/src/computer-vision/pose-estimation/vpPose.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpPose.h 4303 2013-07-04 14:14:00Z fspindle $ + * $Id: vpPose.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -102,7 +102,7 @@ protected : private: int vvsIterMax ; //! define the maximum number of iteration in VVS //! variable used in the Dementhon approach - vpPoint *c3d ; + std::vector<vpPoint> c3d ; //! Flag used to specify if the covariance matrix has to be computed or not. bool computeCovariance; //! Covariance matrix @@ -120,7 +120,7 @@ protected: int calculArbreDementhon(vpMatrix &b, vpColVector &U, vpHomogeneousMatrix &cMo) ; public: - //! constructor + // constructor vpPose() ; //! destructor virtual ~vpPose() ; @@ -169,8 +169,8 @@ public: void setRansacNbInliersToReachConsensus(const unsigned int &nbC){ ransacNbInlierConsensus = nbC; } void setRansacThreshold(const double &t){ ransacThreshold = t; } void setRansacMaxTrials(const int &rM){ ransacMaxTrials = rM; } - unsigned int getRansacNbInliers(){ return (unsigned int) ransacInliers.size(); } - std::vector<vpPoint> getRansacInliers(){ return ransacInliers; } + unsigned int getRansacNbInliers() const { return (unsigned int) ransacInliers.size(); } + std::vector<vpPoint> getRansacInliers() const{ return ransacInliers; } /*! Set if the covaraince matrix has to be computed in the Virtual Visual Servoing approach. diff --git a/src/computer-vision/pose-estimation/vpPoseDementhon.cpp b/src/computer-vision/pose-estimation/vpPoseDementhon.cpp index 219062520e0f7acf19aeb1ca67ae115b6a1cd5bb..0d55038765096568a67770148b95f3d22e2ba6ca 100644 --- a/src/computer-vision/pose-estimation/vpPoseDementhon.cpp +++ b/src/computer-vision/pose-estimation/vpPoseDementhon.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * -* $Id: vpPoseDementhon.cpp 4276 2013-06-25 12:36:48Z fspindle $ +* $Id: vpPoseDementhon.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. -* Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +* Copyright (C) 2005 - 2014 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 @@ -70,23 +70,17 @@ vpPose::poseDementhonNonPlan(vpHomogeneousMatrix &cMo) double seuil=1.0; double f=1.; - // CPoint c3d[npt] ; - - if (c3d !=NULL) delete [] c3d ; - c3d = new vpPoint[npt] ; - vpPoint p0 = listP.front() ; - vpPoint P ; - int i=0; + c3d.clear(); + vpPoint P; for (std::list<vpPoint>::const_iterator it = listP.begin(); it != listP.end(); ++it) { - P = *it ; - c3d[i] = P ; - c3d[i].set_oX(P.get_oX()-p0.get_oX()) ; - c3d[i].set_oY(P.get_oY()-p0.get_oY()) ; - c3d[i].set_oZ(P.get_oZ()-p0.get_oZ()) ; - ++i; + P = (*it); + P.set_oX(P.get_oX()-p0.get_oX()) ; + P.set_oY(P.get_oY()-p0.get_oY()) ; + P.set_oZ(P.get_oZ()-p0.get_oZ()) ; + c3d.push_back(P) ; } vpMatrix a ; @@ -227,8 +221,6 @@ vpPose::poseDementhonNonPlan(vpHomogeneousMatrix &cMo) cMo[0][3] -= (p0.get_oX()*cMo[0][0]+p0.get_oY()*cMo[0][1]+p0.get_oZ()*cMo[0][2]); cMo[1][3] -= (p0.get_oX()*cMo[1][0]+p0.get_oY()*cMo[1][1]+p0.get_oZ()*cMo[1][2]); cMo[2][3] -= (p0.get_oX()*cMo[2][0]+p0.get_oY()*cMo[2][1]+p0.get_oZ()*cMo[2][2]); - - delete [] c3d ; c3d = NULL ; } @@ -375,7 +367,6 @@ vpPose::calculArbreDementhon(vpMatrix &b, vpColVector &U, vpColVector I(3) ; vpColVector J(3) ; - vpHomogeneousMatrix cMo_old ; smin_old = 2*smin ; cpt = 0; @@ -519,21 +510,17 @@ vpPose::poseDementhonPlan(vpHomogeneousMatrix &cMo) unsigned int i,j,k ; - if (c3d !=NULL) delete []c3d ; - c3d = new vpPoint[npt] ; - vpPoint p0 = listP.front() ; vpPoint P ; - i=0 ; + c3d.clear(); for (std::list<vpPoint>::const_iterator it = listP.begin(); it != listP.end(); ++it) { P = *it; - c3d[i] = P ; - c3d[i].set_oX(P.get_oX()-p0.get_oX()) ; - c3d[i].set_oY(P.get_oY()-p0.get_oY()) ; - c3d[i].set_oZ(P.get_oZ()-p0.get_oZ()) ; - i++ ; + P.set_oX(P.get_oX()-p0.get_oX()) ; + P.set_oY(P.get_oY()-p0.get_oY()) ; + P.set_oZ(P.get_oZ()-p0.get_oZ()) ; + c3d.push_back(P); } vpMatrix a ; @@ -714,7 +701,6 @@ vpPose::poseDementhonPlan(vpHomogeneousMatrix &cMo) cMo[1][3] -= p0.get_oX()*cMo[1][0]+p0.get_oY()*cMo[1][1]+p0.get_oZ()*cMo[1][2]; cMo[2][3] -= p0.get_oX()*cMo[2][0]+p0.get_oY()*cMo[2][1]+p0.get_oZ()*cMo[2][2]; - delete [] c3d ; c3d = NULL ; #if (DEBUG_LEVEL1) std::cout << "end CCalculPose::PoseDementhonPlan()" << std::endl ; #endif @@ -735,12 +721,10 @@ vpPose::poseDementhonPlan(vpHomogeneousMatrix &cMo) */ double vpPose::computeResidualDementhon(const vpHomogeneousMatrix &cMo) { - unsigned int i ; - double residual = 0 ; - + double residual_ = 0 ; - residual =0 ; - for (i =0 ; i < npt ; i++) + residual_ =0 ; + for (unsigned int i =0 ; i < npt ; i++) { double X = c3d[i].get_oX()*cMo[0][0]+c3d[i].get_oY()*cMo[0][1]+c3d[i].get_oZ()*cMo[0][2] + cMo[0][3]; @@ -750,11 +734,9 @@ double vpPose::computeResidualDementhon(const vpHomogeneousMatrix &cMo) double x = X/Z ; double y = Y/Z ; - - - residual += vpMath::sqr(x-c3d[i].get_x()) + vpMath::sqr(y-c3d[i].get_y()) ; + residual_ += vpMath::sqr(x-c3d[i].get_x()) + vpMath::sqr(y-c3d[i].get_y()) ; } - return residual ; + return residual_ ; } diff --git a/src/computer-vision/pose-estimation/vpPoseException.h b/src/computer-vision/pose-estimation/vpPoseException.h index 09132b6bfd8e4ada276b68711963a3d86f634ba5..23c4c54f38a0141e8a2ed2ca2b0414a463607396 100644 --- a/src/computer-vision/pose-estimation/vpPoseException.h +++ b/src/computer-vision/pose-estimation/vpPoseException.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpPoseException.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpPoseException.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -67,12 +67,12 @@ */ class VISP_EXPORT vpPoseException : public vpException { -public: - /*! + public: + /*! \brief Lists the possible error than can be emmited while calling vpPose member */ - enum errorCodeEnum + enum errorCodeEnum { poseError, //! something is not initialized @@ -84,25 +84,20 @@ public: notEnoughPointError } ; -public: - vpPoseException (const int code, const char * msg) - : vpException(code, msg){ ; } - vpPoseException (const int code, const std::string & msg) - : vpException(code, msg){ ; } - vpPoseException (const int code) - : vpException(code){ ; } - // vpPoseException() : vpException() { ;} + public: + vpPoseException (const int id, const char* format, ...) + { + this->code = id; + va_list args; + va_start(args, format); + setMessage(format, args); + va_end (args); + } + vpPoseException (const int id, const std::string & msg) + : vpException(id, msg){ ; } + vpPoseException (const int id) + : vpException(id){ ; } + // vpPoseException() : vpException() { ;} }; - - - - -#endif /* #ifndef __vpPoseException_ERROR_H */ - - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ +#endif diff --git a/src/computer-vision/pose-estimation/vpPoseFeatures.cpp b/src/computer-vision/pose-estimation/vpPoseFeatures.cpp index 7f1a1060e65d59f0cae142b939a087fca1fa8bfe..132c074351f7fbfa02920e43c20954d2abc5c45b 100644 --- a/src/computer-vision/pose-estimation/vpPoseFeatures.cpp +++ b/src/computer-vision/pose-estimation/vpPoseFeatures.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpPoseFeatures.cpp 4303 2013-07-04 14:14:00Z fspindle $ + * $Id: vpPoseFeatures.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -44,13 +44,11 @@ Default constructor. */ vpPoseFeatures::vpPoseFeatures() + : maxSize(0), totalSize(0), vvsIterMax(200), lambda(1.0), verbose(false), computeCovariance(false), + covarianceMatrix(), featurePoint_Point_list(), featurePoint3D_Point_list(), featureVanishingPoint_Point_list(), + featureVanishingPoint_DuoLine_list(), featureEllipse_Sphere_list(), featureEllipse_Circle_list(), + featureLine_Line_list(), featureLine_DuoLineInt_List(), featureSegment_DuoPoints_list() { - lambda = 1.0; - vvsIterMax = 200; - totalSize = 0; - maxSize = 0; - - verbose = false; } /*! diff --git a/src/computer-vision/pose-estimation/vpPoseFeatures.h b/src/computer-vision/pose-estimation/vpPoseFeatures.h index 409cec78742321502c61fc473731d1d49928b0dd..787ed4ba1a8e2ebc27bb28e3b7ab65e56036ff1b 100644 --- a/src/computer-vision/pose-estimation/vpPoseFeatures.h +++ b/src/computer-vision/pose-estimation/vpPoseFeatures.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpPoseFeatures.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpPoseFeatures.h 4660 2014-02-09 14:13:27Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -323,7 +323,7 @@ public: \brief Template class that allows to estimate a pose from all kind of specific features if the compiler support C++ 11. */ template< typename featureType, typename RetType, typename ...Args > -class VISP_EXPORT vpPoseSpecificFeatureTemplate : public vpPoseSpecificFeature +class vpPoseSpecificFeatureTemplate : public vpPoseSpecificFeature { private: featureType desiredFeature; @@ -372,7 +372,7 @@ public: \brief Template class that allows to estimate a pose from all kind of specific features if the compiler support C++ 11. */ template< typename ObjectType, typename featureType, typename RetType, typename ...Args > -class VISP_EXPORT vpPoseSpecificFeatureTemplateObject : public vpPoseSpecificFeature +class vpPoseSpecificFeatureTemplateObject : public vpPoseSpecificFeature { private: featureType desiredFeature; @@ -440,6 +440,7 @@ private: struct vpDuo{ FeatureType *desiredFeature; FirstParamType firstParam; + vpDuo() : desiredFeature(NULL), firstParam() {} }; template<typename FeatureType, typename FirstParamType, typename SecondParamType> @@ -447,6 +448,8 @@ private: FeatureType *desiredFeature; FirstParamType firstParam; SecondParamType secondParam; + + vpTrio() : desiredFeature(NULL), firstParam(), secondParam() {} }; #endif //#ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/src/computer-vision/pose-estimation/vpPoseLagrange.cpp b/src/computer-vision/pose-estimation/vpPoseLagrange.cpp index 6f2543144a9b2ae1215f2f907ba61b52b1670e38..7cf3c5ae9da374838e04e18c5e321ab16668971f 100644 --- a/src/computer-vision/pose-estimation/vpPoseLagrange.cpp +++ b/src/computer-vision/pose-estimation/vpPoseLagrange.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * -* $Id: vpPoseLagrange.cpp 4056 2013-01-05 13:04:42Z fspindle $ +* $Id: vpPoseLagrange.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. -* Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +* Copyright (C) 2005 - 2014 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 @@ -385,8 +385,9 @@ vpPose::poseLagrangePlan(vpHomogeneousMatrix &cMo, const int coplanar_plane_type for (i=0;i<3;i++) {s += (X1[i]*X2[i]);} for (i=0;i<3;i++) {X2[i] -= (s*X1[i]);} /* X1^T X2 = 0 */ - s = 0.0; - for (i=0;i<3;i++) {s += (X2[i]*X2[i]);} + //s = 0.0; + //for (i=0;i<3;i++) {s += (X2[i]*X2[i]);} + s = X2[0]*X2[0] + X2[1]*X2[1] + X2[2]*X2[2]; // To avoid a Coverity copy/past error if (s<1e-10) { @@ -559,8 +560,9 @@ vpPose::poseLagrangeNonPlan(vpHomogeneousMatrix &cMo) for (i=0;i<3;i++) {s += (X1[i]*X2[i]);} for (i=0;i<3;i++) {X2[i] -= (s*X1[i]);} /* X1^T X2 = 0 */ - s = 0.0; - for (i=0;i<3;i++) {s += (X2[i]*X2[i]);} + //s = 0.0; + //for (i=0;i<3;i++) {s += (X2[i]*X2[i]);} + s = X2[0]*X2[0] + X2[1]*X2[1] + X2[2]*X2[2]; // To avoid a Coverity copy/past error if (s<1e-10) { diff --git a/src/computer-vision/pose-estimation/vpPoseLowe.cpp b/src/computer-vision/pose-estimation/vpPoseLowe.cpp index 1f5c4f9a6bb2d3be5bb6437c142901bc677e3568..e2ce296f2530b04d005e158761de56ca3ce969c9 100644 --- a/src/computer-vision/pose-estimation/vpPoseLowe.cpp +++ b/src/computer-vision/pose-estimation/vpPoseLowe.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * -* $Id: vpPoseLowe.cpp 4276 2013-06-25 12:36:48Z fspindle $ +* $Id: vpPoseLowe.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. -* Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +* Copyright (C) 2005 - 2014 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 @@ -94,6 +94,8 @@ static double XO[NBPTMAX],YO[NBPTMAX],ZO[NBPTMAX]; #define MINI 0.001 #define MINIMUM 0.000001 +void eval_function(int npt,double *xc,double *f); +void fcn (int m, int n, double *xc, double *fvecc, double *jac, int ldfjac, int iflag); void eval_function(int npt,double *xc,double *f) { @@ -290,7 +292,6 @@ vpPose::poseLowe(vpHomogeneousMatrix & cMo) #if (DEBUG_LEVEL1) std::cout << "begin CCalcuvpPose::PoseLowe(...) " << std::endl; #endif - unsigned int i; int n, m; /* nombre d'elements dans la matrice jac */ int lwa; /* taille du vecteur wa */ int ldfjac; /* taille maximum d'une ligne de jac */ @@ -321,19 +322,18 @@ vpPose::poseLowe(vpHomogeneousMatrix & cMo) } vpPoint P ; - i=0; + unsigned int i_=0; for (std::list<vpPoint>::const_iterator it = listP.begin(); it != listP.end(); ++it) { P = *it; - XI[i] = P.get_x();//*cam.px + cam.xc ; - YI[i] = P.get_y() ;//;*cam.py + cam.yc ; - XO[i] = P.get_oX(); - YO[i] = P.get_oY(); - ZO[i] = P.get_oZ(); - ++i; + XI[i_] = P.get_x();//*cam.px + cam.xc ; + YI[i_] = P.get_y() ;//;*cam.py + cam.yc ; + XO[i_] = P.get_oX(); + YO[i_] = P.get_oY(); + ZO[i_] = P.get_oZ(); + ++i_; } - tst_lmder = lmder1 (&fcn, m, n, sol, f, &jac[0][0], ldfjac, tol, &info, - ipvt, lwa, wa); + tst_lmder = lmder1 (&fcn, m, n, sol, f, &jac[0][0], ldfjac, tol, &info, ipvt, lwa, wa); if (tst_lmder == -1) { std::cout << " in CCalculPose::PoseLowe(...) : " ; @@ -341,10 +341,10 @@ vpPose::poseLowe(vpHomogeneousMatrix & cMo) // return FATAL_ERROR ; } - for (i = 0; i < 3; i++) + for (unsigned int i = 0; i < 3; i++) u[i] = sol[i + 3]; - for (i=0;i<3;i++) + for (unsigned int i=0;i<3;i++) { cMo[i][3] = sol[i]; u[i] = sol[i+3]; diff --git a/src/computer-vision/pose-estimation/vpPoseRansac.cpp b/src/computer-vision/pose-estimation/vpPoseRansac.cpp index e6b6dec1fc694515f0f1e568651dc4e743b53ccb..1d81f6154ed7e7d24eb029d49cc517dc19715a98 100644 --- a/src/computer-vision/pose-estimation/vpPoseRansac.cpp +++ b/src/computer-vision/pose-estimation/vpPoseRansac.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpPoseRansac.cpp 4303 2013-07-04 14:14:00Z fspindle $ + * $Id: vpPoseRansac.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -77,9 +77,15 @@ void vpPose::poseRansac(vpHomogeneousMatrix & cMo) int nbTrials = 0; unsigned int nbMinRandom = 4 ; unsigned int nbInliers = 0; + double r, r_lagrange, r_dementhon; vpHomogeneousMatrix cMo_lagrange, cMo_dementhon; - double r, r_lagrange, r_dementhon; + + if (size < 4) { + //vpERROR_TRACE("Not enough point to compute the pose"); + throw(vpPoseException(vpPoseException::notInitializedError, + "Not enough point to compute the pose")) ; + } bool foundSolution = false; @@ -93,12 +99,12 @@ void vpPose::poseRansac(vpHomogeneousMatrix & cMo) vpPose poseMin ; for(unsigned int i = 0; i < nbMinRandom; i++) { - unsigned int r = (unsigned int)rand()%size; - while(usedPt[r] ) r = (unsigned int)rand()%size; - usedPt[r] = true; + unsigned int r_ = (unsigned int)rand()%size; + while(usedPt[r_] ) r_ = (unsigned int)rand()%size; + usedPt[r_] = true; std::list<vpPoint>::const_iterator iter = listP.begin(); - std::advance(iter, r); + std::advance(iter, r_); vpPoint pt = *iter; bool degenerate = false; @@ -112,7 +118,7 @@ void vpPose::poseRansac(vpHomogeneousMatrix & cMo) } if(!degenerate){ poseMin.addPoint(pt) ; - cur_randoms.push_back(r); + cur_randoms.push_back(r_); } else i--; @@ -153,7 +159,7 @@ void vpPose::poseRansac(vpHomogeneousMatrix & cMo) for(unsigned int it_inlier_index = 0; it_inlier_index< cur_consensus.size(); it_inlier_index++){ std::list<vpPoint>::const_iterator it_point = listP.begin(); std::advance(it_point, cur_consensus[it_inlier_index]); - vpPoint pt = *it_point; + pt = *it_point; vpPoint ptdeg = *it; if( ((fabs(pt.get_x() - ptdeg.get_x()) < 1e-6) && (fabs(pt.get_y() - ptdeg.get_y()) < 1e-6)) || diff --git a/src/computer-vision/pose-estimation/vpPoseVirtualVisualServoing.cpp b/src/computer-vision/pose-estimation/vpPoseVirtualVisualServoing.cpp index 6070859ed1936d43b8ac22b23d304518795d4bc6..fa9477c03bad25b50fa8822c69a7d7b3de3fe332 100755 --- a/src/computer-vision/pose-estimation/vpPoseVirtualVisualServoing.cpp +++ b/src/computer-vision/pose-estimation/vpPoseVirtualVisualServoing.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpPoseVirtualVisualServoing.cpp 4303 2013-07-04 14:14:00Z fspindle $ + * $Id: vpPoseVirtualVisualServoing.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -96,7 +96,7 @@ vpPose::poseVirtualVS(vpHomogeneousMatrix & cMo) residu_1 = r ; // Compute the interaction matrix and the error - unsigned int k =0 ; + k =0 ; for (std::list<vpPoint>::const_iterator it = lP.begin(); it != lP.end(); ++it) { P = *it; @@ -186,14 +186,14 @@ vpPose::poseVirtualVSrobust(vpHomogeneousMatrix & cMo) std::list<vpPoint> lP ; // create sd - unsigned int k =0 ; + unsigned int k_ =0 ; for (std::list<vpPoint>::const_iterator it = listP.begin(); it != listP.end(); ++it) { P = *it; - sd[2*k] = P.get_x() ; - sd[2*k+1] = P.get_y() ; + sd[2*k_] = P.get_x() ; + sd[2*k_+1] = P.get_y() ; lP.push_back(P) ; - k ++; + k_ ++; } int iter = 0 ; res.resize(s.getRows()/2) ; @@ -206,8 +206,7 @@ vpPose::poseVirtualVSrobust(vpHomogeneousMatrix & cMo) residu_1 = r ; // Compute the interaction matrix and the error - vpPoint P ; - k =0 ; + k_ =0 ; for (std::list<vpPoint>::const_iterator it = lP.begin(); it != lP.end(); ++it) { P = *it; @@ -216,24 +215,24 @@ vpPose::poseVirtualVSrobust(vpHomogeneousMatrix & cMo) // perspective projection P.track(cMo) ; - double x = s[2*k] = P.get_x(); // point projected from cMo - double y = s[2*k+1] = P.get_y(); + double x = s[2*k_] = P.get_x(); // point projected from cMo + double y = s[2*k_+1] = P.get_y(); double Z = P.get_Z() ; - L[2*k][0] = -1/Z ; - L[2*k][1] = 0 ; - L[2*k][2] = x/Z ; - L[2*k][3] = x*y ; - L[2*k][4] = -(1+x*x) ; - L[2*k][5] = y ; - - L[2*k+1][0] = 0 ; - L[2*k+1][1] = -1/Z ; - L[2*k+1][2] = y/Z ; - L[2*k+1][3] = 1+y*y ; - L[2*k+1][4] = -x*y ; - L[2*k+1][5] = -x ; - - k ++; + L[2*k_][0] = -1/Z ; + L[2*k_][1] = 0 ; + L[2*k_][2] = x/Z ; + L[2*k_][3] = x*y ; + L[2*k_][4] = -(1+x*x) ; + L[2*k_][5] = y ; + + L[2*k_+1][0] = 0 ; + L[2*k_+1][1] = -1/Z ; + L[2*k_+1][2] = y/Z ; + L[2*k_+1][3] = 1+y*y ; + L[2*k_+1][4] = -x*y ; + L[2*k_+1][5] = -x ; + + k_ ++; } error = s - sd ; diff --git a/src/data-structure/vpList.h b/src/data-structure/vpList.h index 44baab2e12de6b3c83e107b4d97e83a9e7bb9cfc..485acb0dd444d9aaded3ec1fcac33175bbd588a3 100644 --- a/src/data-structure/vpList.h +++ b/src/data-structure/vpList.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpList.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpList.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -64,10 +64,11 @@ template <class type> class vpListElement { - public: - vpListElement<type> *prev; //<! pointer to the previous element in the list - vpListElement<type> *next; //<! pointer to the next element in the list - type val; //<! value of the element + public: + vpListElement() : prev(NULL), next(NULL), val() {}; + vpListElement<type> *prev; //<! pointer to the previous element in the list + vpListElement<type> *next; //<! pointer to the next element in the list + type val; //<! value of the element } ; #endif /* DOXYGEN_SHOULD_SKIP_THIS */ @@ -173,7 +174,7 @@ class vpList inline unsigned int nbElement(void); // returns the number of items currently in the list inline unsigned int nbElements(void); // returns the number of items currently in the list - void operator=(const vpList<type>& l); + vpList<type>& operator=(const vpList<type>& l); inline void operator+=(vpList<type>& l); inline void operator+=(const type& l); @@ -222,7 +223,7 @@ void vpList<type>::init() \sa init() */ template<class type> -vpList<type>::vpList() +vpList<type>::vpList() : nb(0), first(NULL), last(NULL), cur(NULL) { init() ; } @@ -236,13 +237,10 @@ vpList<type>::vpList() template<class type> vpList<type>::~vpList() { - kill() ; - if (first != NULL) delete first ; - if (last != NULL) delete last ; - - + /*if (first != NULL) */ delete first ; + /*if (last != NULL) */ delete last ; } /*! @@ -741,7 +739,7 @@ void vpList<type>::suppress(void) */ template<class type> -void vpList<type>::operator=(const vpList<type>& l) +vpList<type>& vpList<type>::operator=(const vpList<type>& l) { type x ; vpListElement<type> *e ; @@ -758,6 +756,8 @@ void vpList<type>::operator=(const vpList<type>& l) nb = l.nb ; cur = first->next ; + + return *this; } /*! @@ -806,6 +806,7 @@ void vpList<type>::operator += (const type& l) */ template<class type> vpList<type>::vpList(const vpList<type>& l) + : nb(0), first(NULL), last(NULL), cur(NULL) { init() ; *this = l; diff --git a/src/device/display/vpDisplay.cpp b/src/device/display/vpDisplay.cpp index 50f501fed02de0975f52278010d3bda8854b8494..a9926151fee4918bca9a10331d8f981b12386aa1 100644 --- a/src/device/display/vpDisplay.cpp +++ b/src/device/display/vpDisplay.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDisplay.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: vpDisplay.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -58,25 +58,28 @@ Default constructor. */ vpDisplay::vpDisplay() + : displayHasBeenInitialized(false), windowXPosition(0), windowYPosition(0), width(0), height(0), title_() {} + +/*! + Copy constructor. +*/ +vpDisplay::vpDisplay(const vpDisplay &d) + : displayHasBeenInitialized(false), windowXPosition(0), windowYPosition(0), width(0), height(0), title_() { - displayHasBeenInitialized = false; - windowXPosition = 0; - windowYPosition = 0; + displayHasBeenInitialized = d.displayHasBeenInitialized; + windowXPosition = d.windowXPosition; + windowYPosition = d.windowYPosition; - title = new char[1024]; - strcpy (title, "" ); + width = d.width; + height = d.height; } + /*! Destructor that desallocates memory. */ vpDisplay::~vpDisplay() { displayHasBeenInitialized = false ; - - if (title != NULL) { - delete [] title; - title = NULL; - } } /*! @@ -117,7 +120,7 @@ vpDisplay::setFont ( const vpImage<unsigned char> &I, */ void vpDisplay::setTitle ( const vpImage<unsigned char> &I, - const char *windowtitle ) + const char *windowtitle ) { try diff --git a/src/device/display/vpDisplay.h b/src/device/display/vpDisplay.h index e350bbc60143c59b2068abc6ed37078ce9085262..dd77098c18dcb4fcc833d1acd14e9bf9c5b84a76 100644 --- a/src/device/display/vpDisplay.h +++ b/src/device/display/vpDisplay.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDisplay.h 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: vpDisplay.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -44,6 +44,8 @@ #ifndef vpDisplay_h #define vpDisplay_h +#include <string> + // image #include <visp/vpImage.h> @@ -89,11 +91,10 @@ int main() vpImage<unsigned char> I; // Grey level image // Read an image in PGM P5 format -#ifdef UNIX - //vpImageIo::read(I, "/local/soft/ViSP/ViSP-images/Klimt/Klimt.pgm"); - vpImageIo::read(I, "/tmp/Klimt.pgm"); -#elif WIN32 +#ifdef _WIN32 vpImageIo::read(I, "C:/temp/ViSP-images/Klimt/Klimt.pgm"); +#else + vpImageIo::read(I, "/local/soft/ViSP/ViSP-images/Klimt/Klimt.pgm"); #endif vpDisplay *d; @@ -181,13 +182,9 @@ class VISP_EXPORT vpDisplay int windowXPosition ; //! display position int windowYPosition ; - //! display title - char *title ; - char *font; unsigned int width ; unsigned int height ; - - vpDisplay() ; + std::string title_; /*! Display an arrow from image point \e ip1 to image point \e ip2. @@ -316,6 +313,8 @@ class VISP_EXPORT vpDisplay unsigned int thickness=1)=0 ; public: + vpDisplay() ; + vpDisplay(const vpDisplay& d) ; virtual ~vpDisplay(); /*! diff --git a/src/device/display/vpDisplayException.h b/src/device/display/vpDisplayException.h index e3eb704fc9edc238ef0b33b294ab94b6238d95a3..7c6263149ddeb9a951c60434adc1dcc8e0682e8d 100644 --- a/src/device/display/vpDisplayException.h +++ b/src/device/display/vpDisplayException.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDisplayException.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpDisplayException.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -73,12 +73,12 @@ */ class VISP_EXPORT vpDisplayException : public vpException { -public: - /*! + public: + /*! \brief Lists the possible error than can be emmited while calling vpDisplay member */ - enum errorDisplayCodeEnum + enum errorDisplayCodeEnum { notInitializedError, cannotOpenWindowError, @@ -89,33 +89,26 @@ public: depthNotSupportedError } ; -public: - vpDisplayException(const int code, const char * msg) - : vpException(code, msg) + public: + vpDisplayException(const int id, const char* format, ...) { + this->code = id; + va_list args; + va_start(args, format); + setMessage(format, args); + va_end (args); } - - vpDisplayException (const int code, const std::string & msg) - : vpException(code, msg) + + vpDisplayException (const int id, const std::string & msg) + : vpException(id, msg) { } - - vpDisplayException (const int code) - : vpException(code) - { - } - -}; - - - + vpDisplayException (const int id) + : vpException(id) + { + } -#endif /* #ifndef __vpDisplayException_H */ - +}; -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ +#endif diff --git a/src/device/display/vpDisplayGTK.cpp b/src/device/display/vpDisplayGTK.cpp index 239549e135c4c11986a0955334151f3f58a3a32f..e365a0a397da5607e640466f2cab76d5efa5df60 100644 --- a/src/device/display/vpDisplayGTK.cpp +++ b/src/device/display/vpDisplayGTK.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDisplayGTK.cpp 4174 2013-03-22 10:28:41Z fspindle $ + * $Id: vpDisplayGTK.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -80,10 +80,17 @@ vpDisplayGTK::vpDisplayGTK(vpImage<unsigned char> &I, int x, int y, - const char *title) : vpDisplay() + const char *title) { + widget = NULL; + vectgtk = NULL; + font = NULL; + colormap = NULL; + background = NULL; + gc = NULL; + nrow = ncol = 0; col = NULL; - widget = NULL ; + init(I, x, y, title) ; } @@ -99,10 +106,17 @@ vpDisplayGTK::vpDisplayGTK(vpImage<unsigned char> &I, vpDisplayGTK::vpDisplayGTK(vpImage<vpRGBa> &I, int x, int y, - const char *title) : vpDisplay() + const char *title) { + widget = NULL; + vectgtk = NULL; + font = NULL; + colormap = NULL; + background = NULL; + gc = NULL; + nrow = ncol = 0; col = NULL; - widget = NULL ; + init(I, x, y, title) ; } @@ -130,16 +144,24 @@ int main() } \endcode */ -vpDisplayGTK::vpDisplayGTK(int x, int y, const char *title) : vpDisplay() +vpDisplayGTK::vpDisplayGTK(int x, int y, const char *title) { + widget = NULL; + vectgtk = NULL; + font = NULL; + colormap = NULL; + background = NULL; + gc = NULL; + nrow = ncol = 0; + col = NULL; + windowXPosition = x ; windowYPosition = y ; - col = NULL; - widget = NULL ; - - if (title != NULL) - strcpy(this->title, title) ; + if(title != NULL) + title_ = std::string(title); + else + title_ = std::string(" "); } /*! @@ -163,8 +185,14 @@ int main() */ vpDisplayGTK::vpDisplayGTK() : vpDisplay() { + widget = NULL; + vectgtk = NULL; + font = NULL; + colormap = NULL; + background = NULL; + gc = NULL; + nrow = ncol = 0; col = NULL; - widget = NULL ; } /*! @@ -361,15 +389,20 @@ vpDisplayGTK::init(unsigned int width, unsigned int height, gdk_colormap_alloc_color(colormap,&darkGray,FALSE,TRUE); col[vpColor::id_darkGray] = &darkGray ; - /* Chargement des polices */ - Police1 = gdk_font_load("-*-times-medium-r-normal-*-16-*-*-*-*-*-*-*"); - Police2 = gdk_font_load("-*-courier-bold-r-normal-*-*-140-*-*-*-*-*-*"); + // Try to load a default font + font = gdk_font_load("-*-times-medium-r-normal-*-16-*-*-*-*-*-*-*"); + if (font == NULL) + font = gdk_font_load("-*-courier-bold-r-normal-*-*-140-*-*-*-*-*-*"); + if (font == NULL) + font = gdk_font_load("-*-courier 10 pitch-medium-r-normal-*-16-*-*-*-*-*-*-*"); - if (title != NULL) - strcpy(this->title, title) ; + if(title != NULL) + title_ = std::string(title); + else + title_ = std::string(" "); displayHasBeenInitialized = true ; - setTitle(this->title) ; + gdk_window_set_title(widget->window, title_.c_str()); } @@ -380,7 +413,7 @@ vpDisplayGTK::init(unsigned int width, unsigned int height, Set the font used to display a text in overlay. The display is performed using displayCharString(). - \param font : The expected font name. + \param fontname : The expected font name. \note Under UNIX, to know all the available fonts, use the "xlsfonts" binary in a terminal. You can also use the "xfontsel" binary. @@ -388,9 +421,9 @@ vpDisplayGTK::init(unsigned int width, unsigned int height, \sa displayCharString() */ void -vpDisplayGTK::setFont(const char * /* font */) +vpDisplayGTK::setFont(const char *fontname) { - vpERROR_TRACE("Not yet implemented" ) ; + font = gdk_font_load((const gchar*)fontname); } /*! @@ -402,8 +435,11 @@ vpDisplayGTK::setTitle(const char *title) { if (displayHasBeenInitialized) { - if (title != NULL) - gdk_window_set_title(widget->window,(char *)title); + if(title != NULL) + title_ = std::string(title); + else + title_ = std::string(" "); + gdk_window_set_title(widget->window, title_.c_str()); } else { @@ -780,12 +816,13 @@ void vpDisplayGTK::displayCharString ( const vpImagePoint &ip, gdk_colormap_alloc_color(colormap,&gdkcolor,FALSE,TRUE); gdk_gc_set_foreground(gc, &gdkcolor); } - - gdk_draw_string(background, Police2, gc, - vpMath::round( ip.get_u() ), - vpMath::round( ip.get_v() ), - (const gchar *)text); - + if (font != NULL) + gdk_draw_string(background, font, gc, + vpMath::round( ip.get_u() ), + vpMath::round( ip.get_v() ), + (const gchar *)text); + else + std::cout << "Cannot draw string: no font is selected" << std::endl; } else { diff --git a/src/device/display/vpDisplayGTK.h b/src/device/display/vpDisplayGTK.h index 64d34aec7afb2ec6909e51b3eb7a83ec1901b5e6..dc58ec2aca00089ead46a266a648c11b8e2e41fe 100644 --- a/src/device/display/vpDisplayGTK.h +++ b/src/device/display/vpDisplayGTK.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDisplayGTK.h 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: vpDisplayGTK.h 4604 2014-01-21 14:15:23Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -44,10 +44,10 @@ #define vpDisplayGTK_h #include <visp/vpConfig.h> -#include <visp/vpDisplay.h> #if ( defined(VISP_HAVE_GTK) ) #include <visp/vpImage.h> +#include <visp/vpDisplay.h> #include <gtk/gtk.h> #include <gdk/gdkrgb.h> @@ -83,10 +83,10 @@ int main() vpImage<unsigned char> I; // Grey level image // Read an image in PGM P5 format -#ifdef UNIX - vpImageIo::read(I, "/local/soft/ViSP/ViSP-images/Klimt/Klimt.pgm"); -#elif WIN32 +#ifdef _WIN32 vpImageIo::read(I, "C:/temp/ViSP-images/Klimt/Klimt.pgm"); +#else + vpImageIo::read(I, "/local/soft/ViSP/ViSP-images/Klimt/Klimt.pgm"); #endif vpDisplayGTK d; @@ -154,7 +154,7 @@ private: purple, lightGray, gray, darkGray; GdkColormap *colormap; - GdkFont *Police1,*Police2; + GdkFont *font; guchar *vectgtk; GdkColor **col ; int ncol, nrow ; @@ -208,7 +208,7 @@ public: protected: - void setFont( const char *font ); + void setFont( const char *fontname ); void setTitle(const char *title) ; void setWindowPosition(int winx, int winy); diff --git a/src/device/display/vpDisplayOpenCV.cpp b/src/device/display/vpDisplayOpenCV.cpp index 1eafa603452fc82e65bc238650bd0c40d2f063cc..d156fed48d5c4949898e3bac56ca62fe0cb0c4d2 100644 --- a/src/device/display/vpDisplayOpenCV.cpp +++ b/src/device/display/vpDisplayOpenCV.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDisplayOpenCV.cpp 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpDisplayOpenCV.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -80,7 +80,7 @@ vpDisplayOpenCV::vpDisplayOpenCV(vpImage<unsigned char> &I, int x, int y, - const char *title) : vpDisplay() + const char *title) { col = NULL; background = NULL; @@ -100,7 +100,7 @@ vpDisplayOpenCV::vpDisplayOpenCV(vpImage<unsigned char> &I, vpDisplayOpenCV::vpDisplayOpenCV(vpImage<vpRGBa> &I, int x, int y, - const char *title) : vpDisplay() + const char *title) { col = NULL; background = NULL; @@ -130,7 +130,7 @@ int main() } \endcode */ -vpDisplayOpenCV::vpDisplayOpenCV ( int x, int y, const char *title ) : vpDisplay() +vpDisplayOpenCV::vpDisplayOpenCV ( int x, int y, const char *title ) { col = NULL; background = NULL; @@ -138,8 +138,20 @@ vpDisplayOpenCV::vpDisplayOpenCV ( int x, int y, const char *title ) : vpDisplay windowXPosition = x; windowYPosition = y; - if (title != NULL) - strcpy (this->title, title); + if(title != NULL) + title_ = std::string(title); + else + title_ = std::string(" "); + + fontHeight = 10; + ncol = nrow = 0; + x_move = y_move = 0; move = false; + x_lbuttondown = y_lbuttondown = 0; lbuttondown = false; + x_mbuttondown = y_mbuttondown = 0; mbuttondown = false; + x_rbuttondown = y_rbuttondown = 0; rbuttondown = false; + x_lbuttonup = y_lbuttonup = 0; lbuttonup = false; + x_mbuttonup = y_mbuttonup = 0; mbuttonup = false; + x_rbuttonup = y_rbuttonup = 0; rbuttonup = false; } /*! @@ -161,11 +173,20 @@ int main() } \endcode */ -vpDisplayOpenCV::vpDisplayOpenCV() : vpDisplay() +vpDisplayOpenCV::vpDisplayOpenCV() { col = NULL; background = NULL; font = NULL; + fontHeight = 10; + ncol = nrow = 0; + x_move = y_move = 0; move = false; + x_lbuttondown = y_lbuttondown = 0; lbuttondown = false; + x_mbuttondown = y_mbuttondown = 0; mbuttondown = false; + x_rbuttondown = y_rbuttondown = 0; rbuttondown = false; + x_lbuttonup = y_lbuttonup = 0; lbuttonup = false; + x_mbuttonup = y_mbuttonup = 0; mbuttonup = false; + x_rbuttonup = y_rbuttonup = 0; rbuttonup = false; } /*! @@ -233,7 +254,7 @@ vpDisplayOpenCV::init(vpImage<vpRGBa> &I, /*! Initialize the display size, position and title. - \param width, height : Width and height of the window. + \param w, h : Width and height of the window. \param x, y : The window is set at position x,y (column index, row index). \param title : Window title. @@ -241,12 +262,12 @@ vpDisplayOpenCV::init(vpImage<vpRGBa> &I, with an available display device suach as Gtk, Cocoa, Carbon, Qt. */ void -vpDisplayOpenCV::init(unsigned int width, unsigned int height, +vpDisplayOpenCV::init(unsigned int w, unsigned int h, int x, int y, const char *title) { - this->width = width; - this->height = height; + this->width = w; + this->height = h; if (x != -1) this->windowXPosition = x; @@ -254,16 +275,18 @@ vpDisplayOpenCV::init(unsigned int width, unsigned int height, this->windowYPosition = y; int flags = CV_WINDOW_AUTOSIZE; - if (title != NULL) - strcpy(this->title, title) ; + if(title != NULL) + title_ = std::string(title); + else + title_ = std::string(" "); /* Create the window*/ - if (cvNamedWindow( this->title, flags ) < 0) { + if (cvNamedWindow( this->title_.c_str(), flags ) < 0) { vpERROR_TRACE("OpenCV was not built with a display device"); throw(vpDisplayException(vpDisplayException::notInitializedError, "OpenCV was not built with a display device")) ; } - cvMoveWindow( this->title, this->windowXPosition, this->windowYPosition ); + cvMoveWindow( this->title_.c_str(), this->windowXPosition, this->windowYPosition ); move = false; lbuttondown = false; mbuttondown = false; @@ -271,11 +294,11 @@ vpDisplayOpenCV::init(unsigned int width, unsigned int height, lbuttonup = false; mbuttonup = false; rbuttonup = false; - cvSetMouseCallback( this->title, on_mouse, this ); + cvSetMouseCallback( this->title_.c_str(), on_mouse, this ); /* Create background pixmap */ // background = cvCreateImage(cvSize((int)width,(int)height),IPL_DEPTH_8U,3); // -// cvShowImage( this->title,background); +// cvShowImage( this->title_.c_str(),background); col = new CvScalar[vpColor::id_unknown] ; @@ -381,7 +404,7 @@ void vpDisplayOpenCV::setWindowPosition(int winx, int winy) if (displayHasBeenInitialized) { this->windowXPosition = winx; this->windowYPosition = winy; - cvMoveWindow( this->title, winx, winy ); + cvMoveWindow( this->title_.c_str(), winx, winy ); } else { @@ -436,18 +459,17 @@ void vpDisplayOpenCV::displayImage(const vpImage<unsigned char> &I) \param iP : Top left corner of the region of interest - \param width : Width of the region of interest + \param w, h : Width and height of the region of interest - \param height : Height of the region of interest - \sa init(), closeDisplay() */ -void vpDisplayOpenCV::displayImageROI ( const vpImage<unsigned char> &I,const vpImagePoint &iP, const unsigned int width, const unsigned int height ) +void vpDisplayOpenCV::displayImageROI ( const vpImage<unsigned char> &I,const vpImagePoint &iP, + const unsigned int w, const unsigned int h ) { if (displayHasBeenInitialized) { vpImage<unsigned char> Itemp; - vpImageTools::createSubImage(I,(unsigned int)iP.get_i(),(unsigned int)iP.get_j(),height,width,Itemp); + vpImageTools::createSubImage(I,(unsigned int)iP.get_i(),(unsigned int)iP.get_j(),h,w,Itemp); vpImage<vpRGBa> Ic; vpImageConvert::convert(Itemp,Ic); @@ -474,15 +496,15 @@ void vpDisplayOpenCV::displayImageROI ( const vpImage<unsigned char> &I,const vp output = output + (int)(iP.get_i()*3*this->width+ iP.get_j()*3); unsigned int i = 0; - while (i < height) + while (i < h) { unsigned int j = 0; - while (j < width) + while (j < w) { - *(output+3*j) = *(input+j*3); - *(output+3*j+1) = *(input+j*3+1); - *(output+3*j+2) = *(input+j*3+2); - j++; + *(output+3*j) = *(input+j*3); + *(output+3*j+1) = *(input+j*3+1); + *(output+3*j+2) = *(input+j*3+2); + j++; } input = input + 3*iwidth; output = output + 3*this->width; @@ -543,18 +565,17 @@ void vpDisplayOpenCV::displayImage(const vpImage<vpRGBa> &I) \param iP : Top left corner of the region of interest - \param width : Width of the region of interest + \param w, h : Width and height of the region of interest - \param height : Height of the region of interest - \sa init(), closeDisplay() */ -void vpDisplayOpenCV::displayImageROI ( const vpImage<vpRGBa> &I,const vpImagePoint &iP, const unsigned int width, const unsigned int height ) +void vpDisplayOpenCV::displayImageROI ( const vpImage<vpRGBa> &I,const vpImagePoint &iP, + const unsigned int w, const unsigned int h ) { if (displayHasBeenInitialized) { vpImage<vpRGBa> Ic; - vpImageTools::createSubImage(I,(unsigned int)iP.get_i(),(unsigned int)iP.get_j(),height,width,Ic); + vpImageTools::createSubImage(I,(unsigned int)iP.get_i(),(unsigned int)iP.get_j(),h,w,Ic); CvSize size = cvSize((int)this->width, (int)this->height); int depth = 8; @@ -579,15 +600,15 @@ void vpDisplayOpenCV::displayImageROI ( const vpImage<vpRGBa> &I,const vpImagePo output = output + (int)(iP.get_i()*3*this->width+ iP.get_j()*3); unsigned int i = 0; - while (i < height) + while (i < h) { unsigned int j = 0; - while (j < width) + while (j < w) { - *(output+3*j) = *(input+j*3); - *(output+3*j+1) = *(input+j*3+1); - *(output+3*j+2) = *(input+j*3+2); - j++; + *(output+3*j) = *(input+j*3); + *(output+3*j+1) = *(input+j*3+1); + *(output+3*j+2) = *(input+j*3+2); + j++; } input = input + 3*iwidth; output = output + 3*this->width; @@ -635,7 +656,7 @@ void vpDisplayOpenCV::closeDisplay() } if (displayHasBeenInitialized) { - cvDestroyWindow( this->title ); + cvDestroyWindow( this->title_.c_str() ); displayHasBeenInitialized= false; } @@ -651,7 +672,7 @@ void vpDisplayOpenCV::flushDisplay() { if (displayHasBeenInitialized) { - cvShowImage(this->title, background ); + cvShowImage(this->title_.c_str(), background ); cvWaitKey(5); } else @@ -671,7 +692,7 @@ void vpDisplayOpenCV::flushDisplayROI(const vpImagePoint &/*iP*/, const unsigned { if (displayHasBeenInitialized) { - cvShowImage(this->title, background ); + cvShowImage(this->title_.c_str(), background ); cvWaitKey(5); } else @@ -1035,7 +1056,7 @@ void vpDisplayOpenCV::displayPoint(const vpImagePoint &ip, width and \e height the rectangle size. \param topLeft : Top-left corner of the rectangle. - \param width,height : Rectangle size. + \param w,h : Rectangle size in terms of width and height. \param color : Rectangle color. \param fill : When set to true fill the rectangle. @@ -1045,7 +1066,7 @@ void vpDisplayOpenCV::displayPoint(const vpImagePoint &ip, */ void vpDisplayOpenCV::displayRectangle(const vpImagePoint &topLeft, - unsigned int width, unsigned int height, + unsigned int w, unsigned int h, const vpColor &color, bool fill, unsigned int thickness) { @@ -1053,41 +1074,40 @@ vpDisplayOpenCV::displayRectangle(const vpImagePoint &topLeft, { if (fill == false) { if (color.id < vpColor::id_unknown) { - cvRectangle( background, - cvPoint( vpMath::round( topLeft.get_u() ), - vpMath::round( topLeft.get_v() ) ), - cvPoint( vpMath::round( topLeft.get_u()+width ), - vpMath::round( topLeft.get_v()+height ) ), - col[color.id], (int)thickness); + cvRectangle( background, + cvPoint( vpMath::round( topLeft.get_u() ), + vpMath::round( topLeft.get_v() ) ), + cvPoint( vpMath::round( topLeft.get_u()+w ), + vpMath::round( topLeft.get_v()+h ) ), + col[color.id], (int)thickness); } else { - cvcolor = CV_RGB(color.R, color.G, color.B) ; - cvRectangle( background, - cvPoint( vpMath::round( topLeft.get_u() ), - vpMath::round( topLeft.get_v() ) ), - cvPoint( vpMath::round( topLeft.get_u()+width ), - vpMath::round( topLeft.get_v()+height ) ), - cvcolor, (int)thickness); + cvcolor = CV_RGB(color.R, color.G, color.B) ; + cvRectangle( background, + cvPoint( vpMath::round( topLeft.get_u() ), + vpMath::round( topLeft.get_v() ) ), + cvPoint( vpMath::round( topLeft.get_u()+w ), + vpMath::round( topLeft.get_v()+h ) ), + cvcolor, (int)thickness); } } else { if (color.id < vpColor::id_unknown) { - cvRectangle( background, - cvPoint( vpMath::round( topLeft.get_u() ), - vpMath::round( topLeft.get_v() ) ), - cvPoint( vpMath::round( topLeft.get_u()+width ), - vpMath::round( topLeft.get_v()+height ) ), - col[color.id], CV_FILLED); + cvRectangle( background, + cvPoint( vpMath::round( topLeft.get_u() ), + vpMath::round( topLeft.get_v() ) ), + cvPoint( vpMath::round( topLeft.get_u()+w ), + vpMath::round( topLeft.get_v()+h ) ), + col[color.id], CV_FILLED); } else { - cvcolor = CV_RGB(color.R, color.G, color.B) ; - cvRectangle( background, - cvPoint( vpMath::round( topLeft.get_u() ), - vpMath::round( topLeft.get_v() ) ), - cvPoint( vpMath::round( topLeft.get_u()+width ), - vpMath::round( topLeft.get_v()+height ) ), - cvcolor, CV_FILLED); - + cvcolor = CV_RGB(color.R, color.G, color.B) ; + cvRectangle( background, + cvPoint( vpMath::round( topLeft.get_u() ), + vpMath::round( topLeft.get_v() ) ), + cvPoint( vpMath::round( topLeft.get_u()+w ), + vpMath::round( topLeft.get_v()+h ) ), + cvcolor, CV_FILLED); } } } diff --git a/src/device/display/vpDisplayOpenCV.h b/src/device/display/vpDisplayOpenCV.h index d27158e8d2eb07318dca53957b636488a887fb12..cd435c99cb8cdce7742f6b1ae3df1f37068470b1 100644 --- a/src/device/display/vpDisplayOpenCV.h +++ b/src/device/display/vpDisplayOpenCV.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDisplayOpenCV.h 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: vpDisplayOpenCV.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/device/display/vpDisplayX.cpp b/src/device/display/vpDisplayX.cpp index 0fdebd9b36c83d5c019fc9f255ae8088111eacf8..b828e86fa3d98e3608f9987b63d7543625832280 100644 --- a/src/device/display/vpDisplayX.cpp +++ b/src/device/display/vpDisplayX.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDisplayX.cpp 4174 2013-03-22 10:28:41Z fspindle $ + * $Id: vpDisplayX.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -79,8 +79,9 @@ vpDisplayX::vpDisplayX ( vpImage<unsigned char> &I, int x, int y, - const char *title ) : vpDisplay() + const char *title ) { + size = 0; x_color = NULL; init ( I, x, y, title ) ; } @@ -98,8 +99,9 @@ vpDisplayX::vpDisplayX ( vpImage<unsigned char> &I, vpDisplayX::vpDisplayX ( vpImage<vpRGBa> &I, int x, int y, - const char *title ) : vpDisplay() + const char *title ) { + size = 0; x_color = NULL; init ( I, x, y, title ) ; } @@ -126,7 +128,7 @@ int main() } \endcode */ -vpDisplayX::vpDisplayX ( int x, int y, const char *title ) : vpDisplay() +vpDisplayX::vpDisplayX ( int x, int y, const char *title ) { windowXPosition = x ; windowYPosition = y ; @@ -134,9 +136,13 @@ vpDisplayX::vpDisplayX ( int x, int y, const char *title ) : vpDisplay() this->x_color = NULL; if (title != NULL) - strcpy (this->title, title); + title_ = std::string(title); + else + title_ = std::string(" "); ximage_data_init = false; + + size = 0; } /*! @@ -158,10 +164,11 @@ int main() } \endcode */ -vpDisplayX::vpDisplayX() : vpDisplay() +vpDisplayX::vpDisplayX() { x_color = NULL; ximage_data_init = false; + size = 0; } /*! @@ -195,8 +202,10 @@ vpDisplayX::init ( vpImage<unsigned char> &I, int x, int y, const char *title ) if (y != -1) windowYPosition = y ; - if ( title != NULL ) - strcpy ( this->title, title ) ; + if (title != NULL) + title_ = std::string(title); + else + title_ = std::string(" "); // Positionnement de la fenetre dans l'�cran. if ( ( windowXPosition < 0 ) || ( windowYPosition < 0 ) ) @@ -568,7 +577,7 @@ vpDisplayX::init ( vpImage<unsigned char> &I, int x, int y, const char *title ) } } - XSetStandardProperties ( display, window, this->title, this->title, None, 0, 0, &hints ); + XSetStandardProperties ( display, window, this->title_.c_str(), this->title_.c_str(), None, 0, 0, &hints ); XMapWindow ( display, window ) ; // Selection des evenements. XSelectInput ( display, window, @@ -612,7 +621,9 @@ vpDisplayX::init ( vpImage<unsigned char> &I, int x, int y, const char *title ) } displayHasBeenInitialized = true ; - setTitle ( this->title ) ; + + XStoreName ( display, window, title_.c_str() ); + XSync ( display, 1 ); I.display = this ; @@ -642,10 +653,12 @@ vpDisplayX::init ( vpImage<vpRGBa> &I, int x, int y, const char *title ) x_color= new unsigned long [vpColor::id_unknown]; } - if ( title != NULL ) - strcpy ( this->title, title ) ; + if (title != NULL) + title_ = std::string(title); + else + title_ = std::string(" "); - // Positionnement de la fenetre dans l'�cran. + // Positionnement de la fenetre dans l'ecran. if ( ( windowXPosition < 0 ) || ( windowYPosition < 0 ) ) { hints.flags = 0; @@ -1019,7 +1032,7 @@ vpDisplayX::init ( vpImage<vpRGBa> &I, int x, int y, const char *title ) } } - XSetStandardProperties ( display, window, this->title, this->title, None, 0, 0, &hints ); + XSetStandardProperties ( display, window, this->title_.c_str(), this->title_.c_str(), None, 0, 0, &hints ); XMapWindow ( display, window ) ; // Selection des evenements. XSelectInput ( display, window, @@ -1067,7 +1080,8 @@ vpDisplayX::init ( vpImage<vpRGBa> &I, int x, int y, const char *title ) displayHasBeenInitialized = true ; XSync ( display, true ); - setTitle ( this->title ) ; + + XStoreName ( display, window, title_.c_str() ); I.display = this ; } @@ -1076,17 +1090,15 @@ vpDisplayX::init ( vpImage<vpRGBa> &I, int x, int y, const char *title ) /*! Initialize the display size, position and title. - \param width, height : Width and height of the window. + \param w, h : Width and height of the window. \param x, y : The window is set at position x,y (column index, row index). \param title : Window title. */ -void vpDisplayX::init ( unsigned int width, unsigned int height, - int x, int y, const char *title ) +void vpDisplayX::init ( unsigned int w, unsigned int h, int x, int y, const char *title ) { - /* setup X11 ------------------------------------------------------------- */ - this->width = width; - this->height = height; + this->width = w; + this->height = h; XSizeHints hints; @@ -1106,8 +1118,10 @@ void vpDisplayX::init ( unsigned int width, unsigned int height, hints.y = windowYPosition; } - if ( title != NULL ) - strcpy ( this->title, title ) ; + if (title != NULL) + title_ = std::string(title); + else + title_ = std::string(" "); if ( ( display = XOpenDisplay ( NULL ) ) == NULL ) { @@ -1489,7 +1503,7 @@ void vpDisplayX::init ( unsigned int width, unsigned int height, } } - XSetStandardProperties ( display, window, this->title, this->title, None, 0, 0, &hints ); + XSetStandardProperties ( display, window, this->title_.c_str(), this->title_.c_str(), None, 0, 0, &hints ); XMapWindow ( display, window ) ; // Selection des evenements. XSelectInput ( display, window, @@ -1534,8 +1548,8 @@ void vpDisplayX::init ( unsigned int width, unsigned int height, displayHasBeenInitialized = true ; XSync ( display, true ); - setTitle ( this->title ) ; + XStoreName ( display, window, title_.c_str() ); } /*! @@ -1588,7 +1602,11 @@ vpDisplayX::setTitle ( const char *title ) { if ( displayHasBeenInitialized ) { - XStoreName ( display, window, title ); + if(title != NULL) + title_ = std::string(title); + else + title_ = std::string(" "); + XStoreName ( display, window, title_.c_str() ); } else { @@ -1647,11 +1665,11 @@ void vpDisplayX::displayImage ( const vpImage<unsigned char> &I ) // ROUGE, VERT, BLEU, JAUNE { unsigned int i = 0; - unsigned int size = width * height; + unsigned int size_ = width * height; unsigned char nivGris; unsigned char nivGrisMax = 255 - vpColor::id_unknown; - while ( i < size ) + while ( i < size_ ) { nivGris = src_8[i] ; if ( nivGris > nivGrisMax ) @@ -1694,10 +1712,10 @@ void vpDisplayX::displayImage ( const vpImage<unsigned char> &I ) default: { unsigned char *dst_32 = NULL; - unsigned int size = width * height ; + unsigned int size_ = width * height ; dst_32 = ( unsigned char* ) Ximage->data; unsigned char *bitmap = I.bitmap ; - unsigned char *n = I.bitmap + size; + unsigned char *n = I.bitmap + size_; //for (unsigned int i = 0; i < size; i++) // suppression de l'iterateur i while ( bitmap < n ) { @@ -1852,136 +1870,135 @@ void vpDisplayX::displayImage ( const unsigned char *I ) \param iP : Top left corner of the region of interest - \param width : Width of the region of interest + \param w, h : Width and height of the region of interest - \param height : Height of the region of interest - \sa init(), closeDisplay() */ -void vpDisplayX::displayImageROI ( const vpImage<unsigned char> &I,const vpImagePoint &iP, const unsigned int width, const unsigned int height ) +void vpDisplayX::displayImageROI ( const vpImage<unsigned char> &I,const vpImagePoint &iP, + const unsigned int w, const unsigned int h ) { if ( displayHasBeenInitialized ) { switch ( screen_depth ) { - case 8: + case 8: + { + unsigned char *src_8 = NULL; + unsigned char *dst_8 = NULL; + src_8 = ( unsigned char * ) I.bitmap; + dst_8 = ( unsigned char * ) Ximage->data; + // Correction de l'image de facon a liberer les niveaux de gris + // ROUGE, VERT, BLEU, JAUNE { - unsigned char *src_8 = NULL; - unsigned char *dst_8 = NULL; - src_8 = ( unsigned char * ) I.bitmap; - dst_8 = ( unsigned char * ) Ximage->data; - // Correction de l'image de facon a liberer les niveaux de gris - // ROUGE, VERT, BLEU, JAUNE + //int size = width * height; + unsigned char nivGris; + unsigned char nivGrisMax = 255 - vpColor::id_unknown; + + //unsigned int iwidth = I.getWidth(); + unsigned int iwidth = I.getWidth(); + + src_8 = src_8 + (int)(iP.get_i()*iwidth+ iP.get_j()); + dst_8 = dst_8 + (int)(iP.get_i()*this->height+ iP.get_j()); + + unsigned int i = 0; + while (i < h) { - //int size = width * height; - unsigned char nivGris; - unsigned char nivGrisMax = 255 - vpColor::id_unknown; - - //unsigned int iwidth = I.getWidth(); - unsigned int iwidth = I.getWidth(); - - src_8 = src_8 + (int)(iP.get_i()*iwidth+ iP.get_j()); - dst_8 = dst_8 + (int)(iP.get_i()*this->height+ iP.get_j()); - - unsigned int i = 0; - while (i < height) - { - unsigned int j = 0; - while (j < width) - { - nivGris = *(src_8+j); - if ( nivGris > nivGrisMax ) - *(dst_8+j) = 255; - else - *(dst_8+j) = nivGris; - j++; - } - src_8 = src_8 + iwidth; - dst_8 = dst_8 + this->height; - i++; - } + unsigned int j = 0; + while (j < w) + { + nivGris = *(src_8+j); + if ( nivGris > nivGrisMax ) + *(dst_8+j) = 255; + else + *(dst_8+j) = nivGris; + j++; + } + src_8 = src_8 + iwidth; + dst_8 = dst_8 + this->height; + i++; } - - // Affichage de l'image dans la Pixmap. - XPutImage ( display, pixmap, context, Ximage, iP.get_u(), iP.get_v(), iP.get_u(), iP.get_v(), width, height ); - XSetWindowBackgroundPixmap ( display, window, pixmap ); -// XClearWindow ( display, window ); -// XSync ( display,1 ); - break; } - case 16: - { - unsigned short *dst_16 = NULL; - dst_16 = ( unsigned short* ) Ximage->data; - unsigned char *src_8 = NULL; - src_8 = ( unsigned char * ) I.bitmap; - - unsigned int iwidth = I.getWidth(); - - src_8 = src_8 + (int)(iP.get_i()*iwidth+ iP.get_j()); - dst_16 = dst_16 + (int)(iP.get_i()*this->height+ iP.get_j()); - - unsigned int i = 0; - while (i < height) - { - unsigned int j = 0; - while (j < width) - { - *(dst_16+j) = ( unsigned short ) colortable[*(src_8+j)]; - j++; - } - src_8 = src_8 + iwidth; - dst_16 = dst_16 + this->height; - i++; - } - // Affichage de l'image dans la Pixmap. - XPutImage ( display, pixmap, context, Ximage, iP.get_u(), iP.get_v(), iP.get_u(), iP.get_v(), width, height ); - XSetWindowBackgroundPixmap ( display, window, pixmap ); -// XClearWindow ( display, window ); -// XSync ( display,1 ); - break; - } + // Affichage de l'image dans la Pixmap. + XPutImage ( display, pixmap, context, Ximage, iP.get_u(), iP.get_v(), iP.get_u(), iP.get_v(), w, h ); + XSetWindowBackgroundPixmap ( display, window, pixmap ); + // XClearWindow ( display, window ); + // XSync ( display,1 ); + break; + } + case 16: + { + unsigned short *dst_16 = NULL; + dst_16 = ( unsigned short* ) Ximage->data; + unsigned char *src_8 = NULL; + src_8 = ( unsigned char * ) I.bitmap; - case 24: - default: + unsigned int iwidth = I.getWidth(); + + src_8 = src_8 + (int)(iP.get_i()*iwidth+ iP.get_j()); + dst_16 = dst_16 + (int)(iP.get_i()*this->height+ iP.get_j()); + + unsigned int i = 0; + while (i < h) { - unsigned char *dst_32 = NULL; - //unsigned int size = width * height ; - dst_32 = ( unsigned char* ) Ximage->data; - unsigned char *src_8 = I.bitmap ; - //unsigned char *n = I.bitmap + size; - - unsigned int iwidth = I.getWidth(); - - src_8 = src_8 + (int)(iP.get_i()*iwidth+ iP.get_j()); - dst_32 = dst_32 + (int)(iP.get_i()*4*this->width+ iP.get_j()*4); - - unsigned int i = 0; - while (i < height) - { - unsigned int j = 0; - while (j < width) - { - unsigned char val = *(src_8+j); - *(dst_32+4*j) = val; - *(dst_32+4*j+1) = val; - *(dst_32+4*j+2) = val; - *(dst_32+4*j+3) = val; - j++; - } - src_8 = src_8 + iwidth; - dst_32 = dst_32 + 4*this->width; - i++; - } + unsigned int j = 0; + while (j < w) + { + *(dst_16+j) = ( unsigned short ) colortable[*(src_8+j)]; + j++; + } + src_8 = src_8 + iwidth; + dst_16 = dst_16 + this->height; + i++; + } - // Affichage de l'image dans la Pixmap. - XPutImage ( display, pixmap, context, Ximage, iP.get_u(), iP.get_v(), iP.get_u(), iP.get_v(), width, height ); - XSetWindowBackgroundPixmap ( display, window, pixmap ); -// XClearWindow ( display, window ); -// XSync ( display,1 ); - break; + // Affichage de l'image dans la Pixmap. + XPutImage ( display, pixmap, context, Ximage, iP.get_u(), iP.get_v(), iP.get_u(), iP.get_v(), w, h ); + XSetWindowBackgroundPixmap ( display, window, pixmap ); + // XClearWindow ( display, window ); + // XSync ( display,1 ); + break; + } + + case 24: + default: + { + unsigned char *dst_32 = NULL; + //unsigned int size = width * height ; + dst_32 = ( unsigned char* ) Ximage->data; + unsigned char *src_8 = I.bitmap ; + //unsigned char *n = I.bitmap + size; + + unsigned int iwidth = I.getWidth(); + + src_8 = src_8 + (int)(iP.get_i()*iwidth+ iP.get_j()); + dst_32 = dst_32 + (int)(iP.get_i()*4*this->width+ iP.get_j()*4); + + unsigned int i = 0; + while (i < h) + { + unsigned int j = 0; + while (j < w) + { + unsigned char val = *(src_8+j); + *(dst_32+4*j) = val; + *(dst_32+4*j+1) = val; + *(dst_32+4*j+2) = val; + *(dst_32+4*j+3) = val; + j++; + } + src_8 = src_8 + iwidth; + dst_32 = dst_32 + 4*this->width; + i++; } + + // Affichage de l'image dans la Pixmap. + XPutImage ( display, pixmap, context, Ximage, iP.get_u(), iP.get_v(), iP.get_u(), iP.get_v(), w, h ); + XSetWindowBackgroundPixmap ( display, window, pixmap ); + // XClearWindow ( display, window ); + // XSync ( display,1 ); + break; + } } } else @@ -2004,74 +2021,72 @@ void vpDisplayX::displayImageROI ( const vpImage<unsigned char> &I,const vpImage \param iP : Top left corner of the region of interest - \param width : Width of the region of interest + \param w, h : Width and height of the region of interest - \param height : Height of the region of interest - \sa init(), closeDisplay() */ -void vpDisplayX::displayImageROI ( const vpImage<vpRGBa> &I,const vpImagePoint &iP, const unsigned int width, const unsigned int height ) +void vpDisplayX::displayImageROI ( const vpImage<vpRGBa> &I,const vpImagePoint &iP, + const unsigned int w, const unsigned int h ) { - if ( displayHasBeenInitialized ) { switch ( screen_depth ) { - case 24: - case 32: - { - /* + case 24: + case 32: + { + /* * 32-bit source, 24/32-bit destination */ - unsigned char *dst_32 = NULL; - dst_32 = ( unsigned char* ) Ximage->data; - vpRGBa* src_32 = I.bitmap; - //unsigned int sizeI = I.getWidth() * I.getHeight(); - - unsigned int iwidth = I.getWidth(); - - src_32 = src_32 + (int)(iP.get_i()*iwidth+ iP.get_j()); - dst_32 = dst_32 + (int)(iP.get_i()*4*this->width+ iP.get_j()*4); - - unsigned int i = 0; - while (i < height) - { - unsigned int j = 0; - while (j < width) - { + unsigned char *dst_32 = NULL; + dst_32 = ( unsigned char* ) Ximage->data; + vpRGBa* src_32 = I.bitmap; + //unsigned int sizeI = I.getWidth() * I.getHeight(); + + unsigned int iwidth = I.getWidth(); + + src_32 = src_32 + (int)(iP.get_i()*iwidth+ iP.get_j()); + dst_32 = dst_32 + (int)(iP.get_i()*4*this->width+ iP.get_j()*4); + + unsigned int i = 0; + while (i < h) + { + unsigned int j = 0; + while (j < w) + { #ifdef BIGENDIAN - *(dst_32+4*j) = (src_32+j)->A; - *(dst_32+4*j+1) = (src_32+j)->R; - *(dst_32+4*j+2) = (src_32+j)->G; - *(dst_32+4*j+3) = (src_32+j)->B; + *(dst_32+4*j) = (src_32+j)->A; + *(dst_32+4*j+1) = (src_32+j)->R; + *(dst_32+4*j+2) = (src_32+j)->G; + *(dst_32+4*j+3) = (src_32+j)->B; #else - *(dst_32+4*j) = (src_32+j)->B; - *(dst_32+4*j+1) = (src_32+j)->G; - *(dst_32+4*j+2) = (src_32+j)->R; - *(dst_32+4*j+3) = (src_32+j)->A; + *(dst_32+4*j) = (src_32+j)->B; + *(dst_32+4*j+1) = (src_32+j)->G; + *(dst_32+4*j+2) = (src_32+j)->R; + *(dst_32+4*j+3) = (src_32+j)->A; #endif - j++; - } - src_32 = src_32 + iwidth; - dst_32 = dst_32 + 4*this->width; - i++; - } - - // Affichage de l'image dans la Pixmap. - XPutImage ( display, pixmap, context, Ximage, iP.get_u(), iP.get_v(), iP.get_u(), iP.get_v(), width, height ); - XSetWindowBackgroundPixmap ( display, window, pixmap ); -// XClearWindow ( display, window ); -// XSync ( display,1 ); - break; - + j++; + } + src_32 = src_32 + iwidth; + dst_32 = dst_32 + 4*this->width; + i++; } - default: - vpERROR_TRACE ( "Unsupported depth (%d bpp) for color display", - screen_depth ) ; - throw ( vpDisplayException ( vpDisplayException::depthNotSupportedError, - "Unsupported depth for color display" ) ) ; + + // Affichage de l'image dans la Pixmap. + XPutImage ( display, pixmap, context, Ximage, iP.get_u(), iP.get_v(), iP.get_u(), iP.get_v(), w, h ); + XSetWindowBackgroundPixmap ( display, window, pixmap ); + // XClearWindow ( display, window ); + // XSync ( display,1 ); + break; + + } + default: + vpERROR_TRACE ( "Unsupported depth (%d bpp) for color display", + screen_depth ) ; + throw ( vpDisplayException ( vpDisplayException::depthNotSupportedError, + "Unsupported depth for color display" ) ) ; } } else @@ -2141,15 +2156,14 @@ void vpDisplayX::flushDisplay() It's necessary to use this function to see the results of any drawing. \param iP : Top left corner of the region of interest - \param width : Width of the region of interest - \param height : Height of the region of interest + \param w,h : Width and height of the region of interest */ -void vpDisplayX::flushDisplayROI(const vpImagePoint &iP, const unsigned int width, const unsigned int height) +void vpDisplayX::flushDisplayROI(const vpImagePoint &iP, const unsigned int w, const unsigned int h) { if ( displayHasBeenInitialized ) { //XClearWindow ( display, window ); - XClearArea ( display, window,iP.get_u(),iP.get_v(),width,height,0 ); + XClearArea ( display, window,iP.get_u(),iP.get_v(),w,h,0 ); XFlush ( display ); } else @@ -2354,14 +2368,14 @@ void vpDisplayX::displayCircle ( const vpImagePoint ¢er, /*! Display a cross at the image point \e ip location. \param ip : Cross location. - \param size : Size (width and height) of the cross. + \param cross_size : Size (width and height) of the cross. \param color : Cross color. \param thickness : Thickness of the lines used to display the cross. */ void vpDisplayX::displayCross ( const vpImagePoint &ip, - unsigned int size, - const vpColor &color, - unsigned int thickness) + unsigned int cross_size, + const vpColor &color, + unsigned int thickness) { if ( displayHasBeenInitialized ) { @@ -2371,16 +2385,16 @@ void vpDisplayX::displayCross ( const vpImagePoint &ip, double j = ip.get_j(); vpImagePoint ip1, ip2; - ip1.set_i( i-size/2 ); + ip1.set_i( i-cross_size/2 ); ip1.set_j( j ); - ip2.set_i( i+size/2 ); + ip2.set_i( i+cross_size/2 ); ip2.set_j( j ); displayLine ( ip1, ip2, color, thickness ) ; ip1.set_i( i ); - ip1.set_j( j-size/2 ); + ip1.set_j( j-cross_size/2 ); ip2.set_i( i ); - ip2.set_j( j+size/2 ); + ip2.set_j( j+cross_size/2 ); displayLine ( ip1, ip2, color, thickness ) ; } @@ -2524,7 +2538,7 @@ void vpDisplayX::displayPoint ( const vpImagePoint &ip, width and \e height the rectangle size. \param topLeft : Top-left corner of the rectangle. - \param width,height : Rectangle size. + \param w,h : Rectangle size in terms of width and height. \param color : Rectangle color. \param fill : When set to true fill the rectangle. @@ -2534,9 +2548,9 @@ void vpDisplayX::displayPoint ( const vpImagePoint &ip, */ void vpDisplayX::displayRectangle ( const vpImagePoint &topLeft, - unsigned int width, unsigned int height, + unsigned int w, unsigned int h, const vpColor &color, bool fill, - unsigned int thickness ) + unsigned int thickness ) { if ( displayHasBeenInitialized ) { @@ -2558,14 +2572,14 @@ vpDisplayX::displayRectangle ( const vpImagePoint &topLeft, XDrawRectangle ( display, pixmap, context, vpMath::round( topLeft.get_u() ), vpMath::round( topLeft.get_v() ), - width-1, height-1 ); + w-1, h-1 ); } else { XFillRectangle ( display, pixmap, context, vpMath::round( topLeft.get_u() ), vpMath::round( topLeft.get_v() ), - width, height ); + w, h ); } } else @@ -2592,7 +2606,7 @@ void vpDisplayX::displayRectangle ( const vpImagePoint &topLeft, const vpImagePoint &bottomRight, const vpColor &color, bool fill, - unsigned int thickness ) + unsigned int thickness ) { if ( displayHasBeenInitialized ) { @@ -2611,22 +2625,22 @@ vpDisplayX::displayRectangle ( const vpImagePoint &topLeft, XSetLineAttributes ( display, context, thickness, LineSolid, CapButt, JoinBevel ); - unsigned int width = (unsigned int)vpMath::round( std::fabs(bottomRight.get_u() - topLeft.get_u()) ); - unsigned int height = (unsigned int)vpMath::round( std::fabs(bottomRight.get_v() - topLeft.get_v()) ); + unsigned int w = (unsigned int)vpMath::round( std::fabs(bottomRight.get_u() - topLeft.get_u()) ); + unsigned int h = (unsigned int)vpMath::round( std::fabs(bottomRight.get_v() - topLeft.get_v()) ); if ( fill == false ) { XDrawRectangle ( display, pixmap, context, vpMath::round( topLeft.get_u() < bottomRight.get_u() ? topLeft.get_u() : bottomRight.get_u() ), vpMath::round( topLeft.get_v() < bottomRight.get_v() ? topLeft.get_v() : bottomRight.get_v() ), - width > 0 ? width-1 : 1, height > 0 ? height : 1 ); + w > 0 ? w-1 : 1, h > 0 ? h : 1 ); } else { XFillRectangle ( display, pixmap, context, vpMath::round( topLeft.get_u() < bottomRight.get_u() ? topLeft.get_u() : bottomRight.get_u() ), vpMath::round( topLeft.get_v() < bottomRight.get_v() ? topLeft.get_v() : bottomRight.get_v() ), - width, height ); + w, h ); } } else @@ -3024,46 +3038,46 @@ void vpDisplayX::getImage ( vpImage<vpRGBa> &I ) */ unsigned int vpDisplayX::getScreenDepth() { - Display *_display; - int screen; + Display *display_; + int screen_; unsigned int depth; - if ( ( _display = XOpenDisplay ( NULL ) ) == NULL ) + if ( ( display_ = XOpenDisplay ( NULL ) ) == NULL ) { vpERROR_TRACE ( "Can't connect display on server %s.", XDisplayName ( NULL ) ); throw ( vpDisplayException ( vpDisplayException::connexionError, "Can't connect display on server." ) ) ; } - screen = DefaultScreen ( _display ); - depth = (unsigned int)DefaultDepth ( _display, screen ); + screen_ = DefaultScreen ( display_ ); + depth = (unsigned int)DefaultDepth ( display_, screen_ ); - XCloseDisplay ( _display ); + XCloseDisplay ( display_ ); return ( depth ); } /*! Gets the window size. - \param width, height : Size of the display. + \param w, h : Size of the display in therms of width and height. */ -void vpDisplayX::getScreenSize ( unsigned int &width, unsigned int &height ) +void vpDisplayX::getScreenSize ( unsigned int &w, unsigned int &h ) { - Display *_display; - int screen; + Display *display_; + int screen_; - if ( ( _display = XOpenDisplay ( NULL ) ) == NULL ) + if ( ( display_ = XOpenDisplay ( NULL ) ) == NULL ) { vpERROR_TRACE ( "Can't connect display on server %s.", XDisplayName ( NULL ) ); throw ( vpDisplayException ( vpDisplayException::connexionError, "Can't connect display on server." ) ) ; } - screen = DefaultScreen ( _display ); - width = (unsigned int)DisplayWidth ( _display, screen ); - height = (unsigned int)DisplayHeight ( _display, screen ); + screen_ = DefaultScreen ( display_ ); + w = (unsigned int)DisplayWidth ( display_, screen_ ); + h = (unsigned int)DisplayHeight ( display_, screen_ ); - XCloseDisplay ( _display ); + XCloseDisplay ( display_ ); } /*! diff --git a/src/device/display/vpDisplayX.h b/src/device/display/vpDisplayX.h index d7b9c94029f79ca6edc0729cf918ed0d464b16e7..dd82a4f0a4ba801f0540cf309642e0600444ab41 100644 --- a/src/device/display/vpDisplayX.h +++ b/src/device/display/vpDisplayX.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDisplayX.h 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: vpDisplayX.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -174,23 +174,22 @@ public: vpDisplayX() ; vpDisplayX(int winx, int winy, const char *title=NULL) ; vpDisplayX(vpImage<unsigned char> &I, int winx=-1, int winy=-1, - const char *title=NULL) ; + const char *title=NULL) ; vpDisplayX(vpImage<vpRGBa> &I, int winx=-1, int winy=-1, - const char *title=NULL) ; - + const char *title=NULL) ; virtual ~vpDisplayX() ; void init(vpImage<unsigned char> &I, - int winx=-1, int winy=-1, - const char *title=NULL) ; + int winx=-1, int winy=-1, + const char *title=NULL) ; void init(vpImage<vpRGBa> &I, - int winx=-1, int winy=-1, - const char *title=NULL) ; + int winx=-1, int winy=-1, + const char *title=NULL) ; void init(unsigned int width, unsigned int height, - int winx=-1, int winy=-1 , - const char *title=NULL) ; + int winx=-1, int winy=-1 , + const char *title=NULL) ; unsigned int getScreenDepth(); void getScreenSize(unsigned int &width, unsigned int &height); diff --git a/src/device/display/vpMouseButton.h b/src/device/display/vpMouseButton.h index 138cbd74d6e798c72eee1a44a9501c8818c484d2..081dd21e4f2e8c8063574175bd62be0f59bfa15b 100755 --- a/src/device/display/vpMouseButton.h +++ b/src/device/display/vpMouseButton.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMouseButton.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMouseButton.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/device/display/windows/vpD3DRenderer.cpp b/src/device/display/windows/vpD3DRenderer.cpp index 6af10a3a9f1fafe04c5617fe8d2f7bc9198e3bb3..5ec259de7f29568e2d9b77ad80c65f323a3601a0 100755 --- a/src/device/display/windows/vpD3DRenderer.cpp +++ b/src/device/display/windows/vpD3DRenderer.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpD3DRenderer.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpD3DRenderer.cpp 4604 2014-01-21 14:15:23Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -41,7 +41,7 @@ #ifndef DOXYGEN_SHOULD_SKIP_THIS #include <visp/vpConfig.h> -#if ( defined(WIN32) & defined(VISP_HAVE_D3D9) ) +#if ( defined(_WIN32) & defined(VISP_HAVE_D3D9) ) #include <visp/vpD3DRenderer.h> #include <visp/vpColor.h> diff --git a/src/device/display/windows/vpD3DRenderer.h b/src/device/display/windows/vpD3DRenderer.h index 7edb7a905c641415a0b5c77dce0a03506daf462a..5231be19dc0d62c7f0ad2aefd2e9291ca76f7eca 100755 --- a/src/device/display/windows/vpD3DRenderer.h +++ b/src/device/display/windows/vpD3DRenderer.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpD3DRenderer.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpD3DRenderer.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/device/display/windows/vpDisplayD3D.cpp b/src/device/display/windows/vpDisplayD3D.cpp index a3a11d39efe0b677d5c221c1369421e9ae028277..36d4f0c2ee85af3e1aa01486d7c6cac3772834e1 100755 --- a/src/device/display/windows/vpDisplayD3D.cpp +++ b/src/device/display/windows/vpDisplayD3D.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDisplayD3D.cpp 4174 2013-03-22 10:28:41Z fspindle $ + * $Id: vpDisplayD3D.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -45,7 +45,7 @@ */ #include <visp/vpConfig.h> -#if ( defined(WIN32) & defined(VISP_HAVE_D3D9) ) +#if ( defined(_WIN32) & defined(VISP_HAVE_D3D9) ) #include <visp/vpDisplayD3D.h> #include <visp/vpD3DRenderer.h> @@ -60,17 +60,19 @@ vpDisplayD3D::vpDisplayD3D(): vpDisplayWin32(new vpD3DRenderer()){} \brief Constructor : Initialize a display. \param winx, winy The window is set at position x,y (column index, row index). - \param _title Window's title. + \param title Window's title. */ -vpDisplayD3D::vpDisplayD3D(int winx, int winy, const char *_title) +vpDisplayD3D::vpDisplayD3D(int winx, int winy, const char *title) : vpDisplayWin32(new vpD3DRenderer()) { windowXPosition = winx; windowYPosition = winy; - if (_title != NULL) - strcpy(this->title, _title); + if (title != NULL) + title_ = std::string(title); + else + title_ = std::string(" "); } /*! @@ -80,15 +82,15 @@ vpDisplayD3D::vpDisplayD3D(int winx, int winy, const char *_title) \param I : Image to be displayed (note that image has to be initialized). \param winx, winy : The window is set at position x,y (column index, row index). -\param _title : Window's title. +\param title : Window's title. */ vpDisplayD3D::vpDisplayD3D(vpImage<vpRGBa> &I, int winx, int winy, - const char *_title) + const char *title) : vpDisplayWin32(new vpD3DRenderer()) { - init(I,winx,winy,_title); + init(I,winx,winy,title); } /*! @@ -98,15 +100,15 @@ vpDisplayD3D::vpDisplayD3D(vpImage<vpRGBa> &I, \param I Image to be displayed (note that image has to be initialized). \param winx, winy The window is set at position x,y (column index, row index). -\param _title Window's title. +\param title Window's title. */ vpDisplayD3D::vpDisplayD3D(vpImage<unsigned char> &I, int winx, int winy, - const char *_title) + const char *title) : vpDisplayWin32(new vpD3DRenderer()) { - init(I,winx,winy,_title); + init(I,winx,winy,title); } /*! diff --git a/src/device/display/windows/vpDisplayD3D.h b/src/device/display/windows/vpDisplayD3D.h index b11f7ef5151e599e3dcba24b3519192dc8b9db3a..dd71b666f943b10f7be4293d8eecc378ec7ea5fa 100755 --- a/src/device/display/windows/vpDisplayD3D.h +++ b/src/device/display/windows/vpDisplayD3D.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDisplayD3D.h 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: vpDisplayD3D.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -110,9 +110,9 @@ class VISP_EXPORT vpDisplayD3D : public vpDisplayWin32 { public: vpDisplayD3D(); - vpDisplayD3D(int winx, int winy, const char *_title=NULL); - vpDisplayD3D(vpImage<vpRGBa> &I,int winx=-1, int winy=-1, const char *_title=NULL); - vpDisplayD3D(vpImage<unsigned char> &I, int winx=-1, int winy=-1, const char *_title=NULL); + vpDisplayD3D(int winx, int winy, const char *title=NULL); + vpDisplayD3D(vpImage<vpRGBa> &I,int winx=-1, int winy=-1, const char *title=NULL); + vpDisplayD3D(vpImage<unsigned char> &I, int winx=-1, int winy=-1, const char *title=NULL); virtual ~vpDisplayD3D(); diff --git a/src/device/display/windows/vpDisplayGDI.cpp b/src/device/display/windows/vpDisplayGDI.cpp index 01303c07543f90f7217a5685bbdc1a15812768b9..697211052bcba79ddf32e5ab63496f644479eb47 100755 --- a/src/device/display/windows/vpDisplayGDI.cpp +++ b/src/device/display/windows/vpDisplayGDI.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDisplayGDI.cpp 4174 2013-03-22 10:28:41Z fspindle $ + * $Id: vpDisplayGDI.cpp 4642 2014-02-05 12:42:30Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -61,17 +61,19 @@ vpDisplayGDI::vpDisplayGDI(): vpDisplayWin32(new vpGDIRenderer()){} \brief Constructor : Initialize a display. \param winx, winy The window is set at position x,y (column index, row index). - \param _title Window's title. + \param title Window's title. */ -vpDisplayGDI::vpDisplayGDI(int winx, int winy, const char *_title) +vpDisplayGDI::vpDisplayGDI(int winx, int winy, const char *title) : vpDisplayWin32(new vpGDIRenderer()) { windowXPosition = winx; windowYPosition = winy; - if (_title != NULL) - strcpy(this->title, _title); + if (title != NULL) + title_ = std::string(title); + else + title_ = std::string(" "); } /*! @@ -81,15 +83,15 @@ vpDisplayGDI::vpDisplayGDI(int winx, int winy, const char *_title) \param I : image to be displayed (note that image has to be initialized). \param winx, winy The window is set at position x,y (column index, row index). - \param _title Window's title. + \param title Window's title. */ vpDisplayGDI::vpDisplayGDI(vpImage<vpRGBa> &I, int winx, int winy, - const char *_title) + const char *title) : vpDisplayWin32(new vpGDIRenderer()) { - init(I,winx,winy,_title); + init(I,winx,winy,title); } /*! @@ -99,15 +101,15 @@ vpDisplayGDI::vpDisplayGDI(vpImage<vpRGBa> &I, \param I Image to be displayed (note that image has to be initialized). \param winx, winy The window is set at position x,y (column index, row index). - \param _title Window's title. + \param title Window's title. */ vpDisplayGDI::vpDisplayGDI(vpImage<unsigned char> &I, int winx, int winy, - const char *_title) + const char *title) : vpDisplayWin32(new vpGDIRenderer()) { - init(I,winx,winy,_title); + init(I,winx,winy,title); } /*! diff --git a/src/device/display/windows/vpDisplayGDI.h b/src/device/display/windows/vpDisplayGDI.h index 7b0f3f41beed6ab2677735e34f16cda388068fcf..ffe1b310cbe12bd7679b52528d9472388b105bf5 100755 --- a/src/device/display/windows/vpDisplayGDI.h +++ b/src/device/display/windows/vpDisplayGDI.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDisplayGDI.h 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: vpDisplayGDI.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -71,11 +71,10 @@ int main() vpImage<unsigned char> I; // Grey level image // Read an image in PGM P5 format -#ifdef UNIX - //vpImageIo::read(I, "/local/soft/ViSP/ViSP-images/Klimt/Klimt.pgm"); - vpImageIo::read(I, "/tmp/Klimt.pgm"); -#elif WIN32 +#ifdef _WIN32 vpImageIo::read(I, "C:/temp/ViSP-images/Klimt/Klimt.pgm"); +#else + vpImageIo::read(I, "/local/soft/ViSP/ViSP-images/Klimt/Klimt.pgm"); #endif vpDisplayGDI d; @@ -134,9 +133,9 @@ class VISP_EXPORT vpDisplayGDI : public vpDisplayWin32 { public: vpDisplayGDI(); - vpDisplayGDI(int winx, int winy, const char *_title=NULL); - vpDisplayGDI(vpImage<vpRGBa> &I,int winx=-1, int winy=-1, const char *_title=NULL); - vpDisplayGDI(vpImage<unsigned char> &I, int winx=-1, int winy=-1, const char *_title=NULL); + vpDisplayGDI(int winx, int winy, const char *title=NULL); + vpDisplayGDI(vpImage<vpRGBa> &I,int winx=-1, int winy=-1, const char *title=NULL); + vpDisplayGDI(vpImage<unsigned char> &I, int winx=-1, int winy=-1, const char *title=NULL); virtual ~vpDisplayGDI(); }; diff --git a/src/device/display/windows/vpDisplayWin32.cpp b/src/device/display/windows/vpDisplayWin32.cpp index bb88afde14c2185ea3404480de4e8f9da1abc72a..fdcbd93ba69608a536d98c08373e753d5c7974af 100755 --- a/src/device/display/windows/vpDisplayWin32.cpp +++ b/src/device/display/windows/vpDisplayWin32.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDisplayWin32.cpp 4174 2013-03-22 10:28:41Z fspindle $ + * $Id: vpDisplayWin32.cpp 4661 2014-02-10 19:34:58Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -58,7 +58,7 @@ const int vpDisplayWin32::MAX_INIT_DELAY = 5000; void vpCreateWindow(threadParam * param) { //char* title = param->title; - (param->vpDisp)->window.initWindow(param->title, param->x, param->y, + (param->vpDisp)->window.initWindow(param->title.c_str(), param->x, param->y, param->w, param->h); delete param; } @@ -150,7 +150,9 @@ void vpDisplayWin32::init(unsigned int width, unsigned int height, const char *title) { if (title != NULL) - strcpy(this->title, title) ; + title_ = std::string(title); + else + title_ = std::string(" "); if (x != -1) windowXPosition = x; @@ -164,7 +166,7 @@ void vpDisplayWin32::init(unsigned int width, unsigned int height, param->w = width; param->h = height; param->vpDisp = this; - param->title = this->title; + param->title = this->title_; //creates the window in a separate thread hThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)vpCreateWindow, @@ -706,7 +708,7 @@ void vpDisplayWin32::flushDisplayROI(const vpImagePoint &iP, const unsigned int //sends a message to the window # if 1 // new version FS - WPARAM wp = (hr1.left_top << sizeof(unsigned short)) + hr1.right_bottom; + WPARAM wp = (WPARAM)(hr1.left_top << sizeof(unsigned short)) + hr1.right_bottom; LPARAM lp = (hr2.left_top << sizeof(unsigned short)) + hr2.right_bottom; # else // produce warnings with MinGW WPARAM wp=*((WPARAM*)(&hr1)); diff --git a/src/device/display/windows/vpDisplayWin32.h b/src/device/display/windows/vpDisplayWin32.h index b8d9bf0b656aa0010b7e6b994bd21a61ca6e4e2e..3e6e68004b7a90bf58d7c4c88d171d54b5283462 100755 --- a/src/device/display/windows/vpDisplayWin32.h +++ b/src/device/display/windows/vpDisplayWin32.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDisplayWin32.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpDisplayWin32.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -46,6 +46,8 @@ #ifndef vpDisplayWin32_hh #define vpDisplayWin32_hh +#include <string> + #include <visp/vpImage.h> #include <visp/vpDisplay.h> #include <windows.h> @@ -76,7 +78,7 @@ struct threadParam unsigned int h; //! Title of the window. - char * title; + std::string title; }; #endif /* DOXYGEN_SHOULD_SKIP_THIS */ diff --git a/src/device/display/windows/vpGDIRenderer.cpp b/src/device/display/windows/vpGDIRenderer.cpp index 468ef7f10607940d6012f42a7d53814224af8716..5a6e2f190fdbadddae2698d6cb69e1b1a40d7052 100755 --- a/src/device/display/windows/vpGDIRenderer.cpp +++ b/src/device/display/windows/vpGDIRenderer.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpGDIRenderer.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpGDIRenderer.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/device/display/windows/vpGDIRenderer.h b/src/device/display/windows/vpGDIRenderer.h index 9db8183391ea25cfee45f856f473e2260ea30d47..ca9631dd583caa108305a1318c4cf0c8e11e661d 100755 --- a/src/device/display/windows/vpGDIRenderer.h +++ b/src/device/display/windows/vpGDIRenderer.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpGDIRenderer.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpGDIRenderer.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/device/display/windows/vpWin32API.cpp b/src/device/display/windows/vpWin32API.cpp index a1342300a894b2f14ceec7214da9f918c063e683..c396c28f58d820c23767929b6499f27938c55b9a 100644 --- a/src/device/display/windows/vpWin32API.cpp +++ b/src/device/display/windows/vpWin32API.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpWin32API.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpWin32API.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/device/display/windows/vpWin32API.h b/src/device/display/windows/vpWin32API.h index e5fcb86b0ed534649bcaf1cdb6762acdbedebd7f..9dfd7575ecd8901b3955e85b3aa60e8fd1bcb796 100644 --- a/src/device/display/windows/vpWin32API.h +++ b/src/device/display/windows/vpWin32API.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpWin32API.h 4058 2013-01-06 14:59:58Z fspindle $ + * $Id: vpWin32API.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/device/display/windows/vpWin32Renderer.h b/src/device/display/windows/vpWin32Renderer.h index 2dee8936eb6fbd35e5cd0555ec4c45913d15decb..5602b09f100039e6463c5b3cd39ddebee6abc6a4 100755 --- a/src/device/display/windows/vpWin32Renderer.h +++ b/src/device/display/windows/vpWin32Renderer.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpWin32Renderer.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpWin32Renderer.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/device/display/windows/vpWin32Window.cpp b/src/device/display/windows/vpWin32Window.cpp index f6ea76b8537a1e03f1c58a6324c84e217d6a958d..e72a3b64a88d9750e836dfd4f00084538090417f 100755 --- a/src/device/display/windows/vpWin32Window.cpp +++ b/src/device/display/windows/vpWin32Window.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpWin32Window.cpp 4304 2013-07-04 14:29:24Z fspindle $ + * $Id: vpWin32Window.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/device/display/windows/vpWin32Window.h b/src/device/display/windows/vpWin32Window.h index 7a609e3f4bf624aee48b42251c5431231352100d..a3ea37c46070700e7ef94f25690deda5aaee91f6 100755 --- a/src/device/display/windows/vpWin32Window.h +++ b/src/device/display/windows/vpWin32Window.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpWin32Window.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpWin32Window.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/device/framegrabber/1394/vp1394CMUGrabber.cpp b/src/device/framegrabber/1394/vp1394CMUGrabber.cpp index 2529bccfb413c465930dcb3115b4cdd48f0b7cd0..0e7dac0a86d55748fea32982ffea58dca336f504 100644 --- a/src/device/framegrabber/1394/vp1394CMUGrabber.cpp +++ b/src/device/framegrabber/1394/vp1394CMUGrabber.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vp1394CMUGrabber.cpp 4204 2013-04-10 16:51:46Z fspindle $ + * $Id: vp1394CMUGrabber.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/device/framegrabber/1394/vp1394CMUGrabber.h b/src/device/framegrabber/1394/vp1394CMUGrabber.h index cb45e1d272e4ac931999a3b3048c6fee41d96642..c34a837f81ee0c7347832b8e9f3ed2588c8e4b28 100644 --- a/src/device/framegrabber/1394/vp1394CMUGrabber.h +++ b/src/device/framegrabber/1394/vp1394CMUGrabber.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vp1394CMUGrabber.h 4216 2013-04-17 09:06:18Z fspindle $ + * $Id: vp1394CMUGrabber.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/device/framegrabber/1394/vp1394Grabber.cpp b/src/device/framegrabber/1394/vp1394Grabber.cpp deleted file mode 100644 index 7312e954440edc11ac06ca01591c7cf590f9fcdd..0000000000000000000000000000000000000000 --- a/src/device/framegrabber/1394/vp1394Grabber.cpp +++ /dev/null @@ -1,2394 +0,0 @@ -/**************************************************************************** - * - * $Id: vp1394Grabber.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 vp1394Grabber.cpp - \brief member functions for firewire cameras - \ingroup libdevice -*/ -#include <iostream> - -#include <visp/vpConfig.h> - -#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS -#if defined(VISP_HAVE_DC1394_1) - - - -#include <visp/vp1394Grabber.h> -#include <visp/vpFrameGrabberException.h> -#include <visp/vpImageIo.h> -#include <visp/vpImageConvert.h> - -const int vp1394Grabber::DROP_FRAMES = 1; /*!< With libdc1394-1.0.0 or more rencent versions, DROP_FRAMES has to be set to 1 in order to suppress the latency. */ -const int vp1394Grabber::NUM_BUFFERS = 8; /*!< Number of buffers */ -const int vp1394Grabber::MAX_PORTS = 4; /*!< Maximal number of ports */ -const int vp1394Grabber::MAX_CAMERAS = 8; /*!< Maximal number of cameras */ - -const char * vp1394Grabber::strFormats[NUM_FORMATS]= { - "Format_0", - "Format_1", - "Format_2", - "Reserved", // 3 reserved formats - "Reserved", - "Reserved", - "Format_6", - "Format_7" -}; - -const char * vp1394Grabber::strModesInFormat0[NUM_FORMAT0_MODES]= { - "Format_0, Mode_0: 160x120 YUV (4:4:4)", - "Format_0, Mode_1: 320x240 YUV (4:2:2)", - "Format_0, Mode_2: 640x480 YUV (4:1:1)", - "Format_0, Mode_3: 640x480 YUV (4:2:2)", - "Format_0, Mode_4: 640x480 RGB 24bpp", - "Format_0, Mode_5: 640x480 Mono 8bpp", - "Format_0, Mode_6: 640x480 Mono 16bpp" -}; - -const char * vp1394Grabber::strModesInFormat1[NUM_FORMAT1_MODES]= { - "Format_1, Mode_0: 800x600 YUV (4:2:2)", - "Format_1, Mode_1: 800x600 RGB 24bpp", - "Format_1, Mode_2: 800x600 Mono 8bpp", - "Format_1, Mode_3: 1024x768 YUV (4:2:2)", - "Format_1, Mode_4: 1024x768 RGB 24bpp", - "Format_1, Mode_5: 1024x768 Mono 8bpp", - "Format_1, Mode_6: 800x600 Mono 16bpp", - "Format_1, Mode_7: 1024x768 Mono 16bpp" -}; - -const char * vp1394Grabber::strModesInFormat2[NUM_FORMAT2_MODES]= { - "Format_2, Mode_0: 1280x960 YUV (4:2:2)", - "Format_2, Mode_1: 1280x960 RGB 24bpp", - "Format_2, Mode_2: 1280x960 Mono 8bpp", - "Format_2, Mode_3: 1600x1200 YUV (4:2:2)", - "Format_2, Mode_4: 1600x1200 RGB 24bpp", - "Format_2, Mode_5: 1600x1200 Mono 8bpp", - "Format_2, Mode_6: 1280x960 Mono 16bpp", - "Format_2, Mode_7: 1600x1200 Mono 16bpp" -}; - -const char * vp1394Grabber::strModesInFormat6[NUM_FORMAT6_MODES]= { - "Format6, Mode_0: EXIT (not supported)" -}; - -const char * vp1394Grabber::strModesInFormat7[NUM_MODE_FORMAT7]= { - "Format_7, Mode_0", - "Format_7, Mode_1", - "Format_7, Mode_2", - "Format_7, Mode_3", - "Format_7, Mode_4", - "Format_7, Mode_5", - "Format_7, Mode_6", - "Format_7, Mode_7" -}; - -const char * vp1394Grabber::strColorsInFormat7[NUM_COLOR_FORMAT7] = { - "Format_7 Color, Mono 8bpp", - "Format_7 Color, YUV 4:1:1", - "Format_7 Color, YUV 4:2:2", - "Format_7 Color, YUV 4:4:4", - "Format_7 Color, RGB 24bpp", - "Format_7 Color, Mono 16bpp", - "Format_7 Color, RGB 48bpp" -}; - -const char * vp1394Grabber::strFramerates[NUM_FRAMERATES] = { - "1.875 Hz", - "3.75 Hz", - "7.5 Hz", - "15 Hz", - "30 Hz", - "60 Hz" -}; - -/*! - \deprecated This class is deprecated. You shoud use - vp1394TwoGrabber class instead. - - Default constructor. Using this constructor, you have explicitly to call - open(). - - By default: - - the camera is the first found on the bus, - - Current camera settings can be changed using setCamera(), - setFormat(), setMode() or setFramerate() after a call to open(). The - list of supported formats, modes and framerates is available using - respectively getFormatSupported(), getModeSupported(), - getFramerateSupported(). - - \code - vpImage<unsigned char> I; - vp1394Grabber g; - g.open(I); - g.setFormat(FORMAT_VGA_NONCOMPRESSED); // Format_0 - g.setMode(MODE_640x480_MONO); // Mode 5 - g.setFramerate(FRAMERATE_15); // 15 fps - \endcode - - \sa open(), setCamera(), setFormat(), setMode(), setFramerate() - -*/ -vp1394Grabber::vp1394Grabber( ) -{ - sprintf(device_name, "/dev/video1394/0"); - - // allocations - handles = new raw1394handle_t [vp1394Grabber::MAX_CAMERAS]; - cameras = new dc1394_cameracapture [vp1394Grabber::MAX_CAMERAS]; - cam_count = new int [vp1394Grabber::MAX_CAMERAS]; - pformat = new int [vp1394Grabber::MAX_CAMERAS]; - pmode = new int [vp1394Grabber::MAX_CAMERAS]; - pframerate = new int [vp1394Grabber::MAX_CAMERAS]; - _width = new int [vp1394Grabber::MAX_CAMERAS]; - _height = new int [vp1394Grabber::MAX_CAMERAS]; - image_format = new vp1394ImageFormatType [vp1394Grabber::MAX_CAMERAS]; - - // Camera settings initialisation - for (int i=0; i < vp1394Grabber::MAX_CAMERAS; i ++) { - pformat[i] = 0; - pmode[i] = 0; - pframerate[i] = 0; - } - verbose = false; - - iso_transmission_started = false; - handle_created = false; - camera_found = false; - dma_started = false; - num_cameras = 0; - camera = 0; // the first camera on the bus - - // Image settings - for (int i=0; i < vp1394Grabber::MAX_CAMERAS; i ++) { - _width[i] = 0; - _height[i] = 0; - image_format[i] = RGB; - } - - init = false ; -} - -/*! - - \deprecated This class is deprecated. You shoud use - vp1394TwoGrabber class instead. - - Constructor which initialize the grabber and call the open() method. - - \param I : Image data structure (8 bits image) - - By default: - - the camera is the first found on the bus, - - Current camera settings can be changed using setCamera(), - setFormat(), setMode() or setFramerate() after a call to open(). The - list of supported formats, modes and framerates is available using - respectively getFormatSupported(), getModeSupported(), - getFramerateSupported(). - - \code - vpImage<unsigned char> I; - vp1394Grabber g(I); - g.setFormat(FORMAT_VGA_NONCOMPRESSED); // Format_0 - g.setMode(MODE_640x480_MONO); // Mode 5 - g.setFramerate(FRAMERATE_15); // 15 fps - \endcode - - \sa setCamera(), setFormat(), setMode(), setFramerate() -*/ -vp1394Grabber::vp1394Grabber(vpImage<unsigned char> &I) -{ - sprintf(device_name, "/dev/video1394/0"); - - // allocations - handles = new raw1394handle_t [vp1394Grabber::MAX_CAMERAS]; - cameras = new dc1394_cameracapture [vp1394Grabber::MAX_CAMERAS]; - cam_count = new int [vp1394Grabber::MAX_CAMERAS]; - pformat = new int [vp1394Grabber::MAX_CAMERAS]; - pmode = new int [vp1394Grabber::MAX_CAMERAS]; - pframerate = new int [vp1394Grabber::MAX_CAMERAS]; - _width = new int [vp1394Grabber::MAX_CAMERAS]; - _height = new int [vp1394Grabber::MAX_CAMERAS]; - image_format = new vp1394ImageFormatType [vp1394Grabber::MAX_CAMERAS]; - - // Camera settings - for (int i=0; i < vp1394Grabber::MAX_CAMERAS; i ++) { - pformat[i] = 0; - pmode[i] = 0; - pframerate[i] = 0; - } - verbose = false; - - iso_transmission_started = false; - handle_created = false; - camera_found = false; - num_cameras = 0; - camera = 0; // the first camera on the bus - - // Image settings - for (int i=0; i < vp1394Grabber::MAX_CAMERAS; i ++) { - _width[i] = 0; - _height[i] = 0; - image_format[i] = RGB; - } - - init = false ; - - open ( I ) ; -} - -/*! - - Destructor. - - Stops the iso transmission and close the device. - - \sa close() - -*/ -vp1394Grabber::~vp1394Grabber() -{ - close(); -} - -/*! - - If multiples cameras are connected on the bus, select the camero to dial - with. - - \param camera : A camera. The value must be comprised between 0 (the first - camera) and the number of cameras found on the bus and returned by - getNumCameras(). If two cameras are connected on the bus, setting \e camera - to one allows to communicate with the second one. - - \exception vpFrameGrabberException::settingError : If the required camera is - not reachable. - - \warning Has to be called after open() to be sure that a camera is detected. - - \code - vpImage<unsigned char> I; - vp1394Grabber g; - g.open(I); - unsigned int num_cameras; // Number of cameras on the bus - g.getNumCameras(num_cameras); - g.setCamera(num_cameras-1); // To dial with the last camera on the bus - g.acquire(I); // I contains the frame captured by the last camera on the bus - \endcode - - \sa setFormat(), setMode(), setFramerate(), open(), getNumCameras() - -*/ -void -vp1394Grabber::setCamera(unsigned int camera) -{ - if (camera >= num_cameras) { - close(); - vpERROR_TRACE("The required camera is not present"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "The required camera is not present") ); - } - - this->camera = camera; - -} -/*! - - Get the active camera on the bus. - - \param camera : A camera id. The value is comprised between 0 (the first - camera) and the number of cameras found on the bus and returned by - getNumCameras(). - - \sa setCamera(), getNumCameras() - -*/ -void -vp1394Grabber::getCamera(unsigned int &camera) -{ - camera = this->camera; - -} -/*! - - Set the capture format for a given camera on the bus. To set the format for a - specific camera, call setCamera() before. - - \param format : The camera image format. The current camera format is given by - getFormat(). The camera supported formats are given by - getFormatSupported(). The allowed values given in - libdc1394/dc1394_control.h are: - - FORMAT_VGA_NONCOMPRESSED for the Format_0 - - FORMAT_SVGA_NONCOMPRESSED_1 for the Format_1 - - FORMAT_SVGA_NONCOMPRESSED_2 for the Format_2 - - FORMAT_STILL_IMAGE for the Format_6 - - FORMAT_SCALABLE_IMAGE_SIZE for the Format_7 - - \warning The requested format is sent to the camera only after a call to - close(). Depending on the format and the camera mode, image size can differ. - - \exception vpFrameGrabberException::settingError : If the required camera is - not present. - - \warning Has to be called after open() to be sure that a camera is detected. - - \sa setMode(), setFramerate(), open(), setCamera(), getNumCameras() - -*/ -void -vp1394Grabber::setFormat(int format) -{ - if (iso_transmission_started == true) { - - stopIsoTransmission(); - - for (unsigned int i=0; i < num_cameras; i++) - dc1394_dma_unlisten( handles[i], &cameras[i] ); - iso_transmission_started = false; - } - - this->pformat[camera] = format; - - setup(); - startIsoTransmission(); -} - -/*! - - Query the actual capture format of a given camera. The camera supported - formats are given by getFormatSupported(). - - \warning Before requerying the actual format a handle must - be created by calling open(), and a camera must be connected. - - \param format : The camera capture format (see file - libdc1394/dc1394_control.h), either : - - - FORMAT_VGA_NONCOMPRESSED for the Format_0 - - FORMAT_SVGA_NONCOMPRESSED_1 for the Format_1 - - FORMAT_SVGA_NONCOMPRESSED_2 for the Format_2 - - FORMAT_STILL_IMAGE for the Format_6 - - FORMAT_SCALABLE_IMAGE_SIZE for the Format_7 - - \exception vpFrameGrabberException::settingError : If the required camera is - not present or if an error occurs. - - \sa setFormat(), getFormatSupported(), open(), setCamera(), getNumCameras() - -*/ -void -vp1394Grabber::getFormat(int & format) -{ - if (handle_created == false) { - close(); - vpERROR_TRACE("To set the shutter the handle must be created"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "To set the shutter the handle must be created") ); - } - if (camera_found == false) { - close(); - vpERROR_TRACE("To set the shutter a camera must be connected"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "To set the shutter a camera must be connected") ); - } - - if(dc1394_get_camera_misc_info(handles[camera], - cameras[camera].node, - &miscinfo) !=DC1394_SUCCESS) { - vpERROR_TRACE("Unable to get misc info"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "Unable to get misc info") ); - } - - format = miscinfo.format; -} - -/*! - - Query the available camera image formats. - - \warning Before requerying supported formats a handle must be created by - calling open(), and a camera must be connected. - - \param formats : The list of supported camera image formats. - - \return The number of supported camera image formats, 0 if an error occurs. - - \exception vpFrameGrabberException::settingError : If the required camera is - not present or if an error occurs. - - \sa getModeSupported(), getFramerateSupported(), open(), - getFormat(), setCamera() - -*/ -int -vp1394Grabber::getFormatSupported(vpList<int> & formats) -{ - int nb = 0; // Number of supported formats - - // Refresh the list of supported formats - formats.kill(); - - if (handle_created == false) { - close(); - vpERROR_TRACE("To set the shutter the handle must be created"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "To set the shutter the handle must be created") ); - } - if (camera_found == false) { - close(); - vpERROR_TRACE("To set the shutter a camera must be connected"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "To set the shutter a camera must be connected") ); - } - - quadlet_t value; - if (dc1394_query_supported_formats(handles[camera], - cameras[camera].node, - &value) != DC1394_SUCCESS) { - vpERROR_TRACE("Could not query supported formats"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "Could not query supported formats") ); - } - - if (value & (0x1<<31)) { - formats.addRight(FORMAT_VGA_NONCOMPRESSED); - nb ++; - } - if (value & (0x1<<30)) { - formats.addRight(FORMAT_SVGA_NONCOMPRESSED_1); - nb ++; - } - if (value & (0x1<<29)) { - formats.addRight(FORMAT_SVGA_NONCOMPRESSED_2); - nb ++; - } - if (value & (0x1<<25)) { - formats.addRight(FORMAT_STILL_IMAGE); - nb ++; - } - if (value & (0x1<<24)) { - formats.addRight(FORMAT_SCALABLE_IMAGE_SIZE); - nb ++; - } - - return nb; -} - -/*! - - Set the camera capture mode for a given camera on the bus. - - \param mode : The camera capture mode. The current camera mode is - given by getMode(). The camera supported modes are given by - getSupportedModes(). The allowed values are given in - libdc1394/dc1394_control.h file: - - - Allowed mode for Format 0: MODE_160x120_YUV444 = 64, MODE_320x240_YUV422, MODE_640x480_YUV411, MODE_640x480_YUV422, MODE_640x480_RGB, MODE_640x480_MONO, MODE_640x480_MONO16 - - - Allowed modes for Format 1: MODE_800x600_YUV422 = 96, MODE_800x600_RGB, MODE_800x600_MONO, MODE_1024x768_YUV422, MODE_1024x768_RGB, MODE_1024x768_MONO, MODE_800x600_MONO16, MODE_1024x768_MONO16 - - - Allowed modes for Format 2: MODE_1280x960_YUV422 = 128, MODE_1280x960_RGB, MODE_1280x960_MONO, MODE_1600x1200_YUV422, MODE_1600x1200_RGB, MODE_1600x1200_MONO, MODE_1280x960_MONO16, MODE_1600x1200_MONO16 - - - Allowed modes for Format 6: MODE_EXIF= 256 - - - Allowed modes for Format 7: MODE_FORMAT7_0= 288, MODE_FORMAT7_1, MODE_FORMAT7_2, MODE_FORMAT7_3, MODE_FORMAT7_4, MODE_FORMAT7_5, MODE_FORMAT7_6, MODE_FORMAT7_7 - - - All these modes are not supported by your camera. The camera supported modes - are given by getModeSupported(). - - \warning The requested format is sent to the camera only after a call to - close(). Depending on the format and the camera mode, image size can differ. - - \exception vpFrameGrabberException::settingError : If the required camera is - not present. - - \warning Has to be called after open() to be sure that a camera is detected. - - \sa setFormat(), setFramerate(), open(), getNumCameras(), setCamera() - -*/ -void -vp1394Grabber::setMode(int mode) -{ - if (iso_transmission_started == true) { - - stopIsoTransmission(); - - for (unsigned int i=0; i < num_cameras; i++) - dc1394_dma_unlisten( handles[i], &cameras[i] ); - iso_transmission_started = false; - } - - this->pmode[camera] = mode; - - setup(); - startIsoTransmission(); -} - -/*! - - Query the actual capture mode of a given camera. Given a format, all - the camera supported modes are given by getModeSupported(). - - \warning Before requerying the actual mode a handle must - be created by calling open(), and a camera must be connected. - - \param mode : The camera capture mode. - - \exception vpFrameGrabberException::settingError : If the required camera is - not present. - - \sa setMode(), getModeSupported(), open(), setCamera() - -*/ -void -vp1394Grabber::getMode(int & mode) -{ - - if (handle_created == false) { - close(); - vpERROR_TRACE("To set the shutter the handle must be created"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "To set the shutter the handle must be created") ); - } - if (camera_found == false) { - close(); - vpERROR_TRACE("To set the shutter a camera must be connected"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "To set the shutter a camera must be connected") ); - } - if(dc1394_get_camera_misc_info(handles[camera], - cameras[camera].node, - &miscinfo) !=DC1394_SUCCESS) { - vpERROR_TRACE("Unable to get misc info"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "Unable to get misc info") ); - } - - mode = miscinfo.mode; -} - -/*! - - Query the available camera modes for the given format. - - \warning Before requerying supported modes for a given format a handle must - be created by calling open(), and a camera must be connected. - - \param format : Camera image format. Values for format are parts of the list - (see file libdc1394/dc1394_control.h): - - - FORMAT_VGA_NONCOMPRESSED = 384 for the Format_0 - - FORMAT_SVGA_NONCOMPRESSED_1 for the Format_1 - - FORMAT_SVGA_NONCOMPRESSED_2 for the Format_2 - - FORMAT_STILL_IMAGE = 390 for the Format_6 - - FORMAT_SCALABLE_IMAGE_SIZE for the Format_7 - - \param modes : The list of supported camera modes. - - \return The number of supported camera modes, 0 if an error occurs. - - \exception vpFrameGrabberException::settingError : If the required camera is - not present. - - \sa getMode(), getFramerateSupported(), open(), setCamera() -*/ -int -vp1394Grabber::getModeSupported(int format, vpList<int> & modes) -{ - int nb = 0; // Number of supported modes - - // Refresh the list of supported modes - modes.kill(); - - if (handle_created == false) { - close(); - vpERROR_TRACE("To set the shutter the handle must be created"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "To set the shutter the handle must be created") ); - } - if (camera_found == false) { - close(); - vpERROR_TRACE("To set the shutter a camera must be connected"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "To set the shutter a camera must be connected") ); - } - - quadlet_t value; - if (dc1394_query_supported_modes(handles[camera], - cameras[camera].node, - format, &value) != DC1394_SUCCESS) { - vpERROR_TRACE("Could not query supported modes for format %d\n", format); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "Could not query supported mode") ); - } - - switch (format) { - case FORMAT_VGA_NONCOMPRESSED: - for (int m = MODE_FORMAT0_MIN; m <= MODE_FORMAT0_MAX; m ++) { - if (value & (0x1<<(31-(m-MODE_FORMAT0_MIN)))) { - modes.addRight(m); - nb ++; - } - } - break; - - case FORMAT_SVGA_NONCOMPRESSED_1: - for (int m = MODE_FORMAT1_MIN; m <= MODE_FORMAT1_MAX; m ++) { - if (value & (0x1<<(31-(m-MODE_FORMAT1_MIN)))) { - modes.addRight(m); - nb ++; - } - } - break; - - case FORMAT_SVGA_NONCOMPRESSED_2: - for (int m = MODE_FORMAT2_MIN; m <= MODE_FORMAT2_MAX; m ++) { - if (value & (0x1<<(31-(m-MODE_FORMAT2_MIN)))) { - modes.addRight(m); - nb ++; - } - } - break; - - case FORMAT_STILL_IMAGE: - for (int m = MODE_FORMAT6_MIN; m <= MODE_FORMAT6_MAX; m ++) { - if (value & (0x1<<(31-(m-MODE_FORMAT6_MIN)))) { - modes.addRight(m); - nb ++; - } - } - break; - - case FORMAT_SCALABLE_IMAGE_SIZE: - for (int m = MODE_FORMAT7_MIN; m <= MODE_FORMAT7_MAX; m ++) { - if (value & (0x1<<(31-(m-MODE_FORMAT7_MIN)))) { - modes.addRight(m); - nb ++; - } - } - break; - } - - return nb; -} - -/*! - - Set the capture framerate for a given camera on the bus. - - \param framerate : The camera framerate. The current framerate of the camera - is given by getFramerate(). The camera supported framerates are given by - getFramerateSupported(). The allowed values given in - libdc1394/dc1394_control.h are: - - - FRAMERATE_1_875 = 32 for 1.875 fps, - - FRAMERATE_3_75 for 3.75 fps, - - FRAMERATE_7_5 for 7.5 fps, - - FRAMERATE_15 for 15 fps, - - FRAMERATE_30 for 30 fps, - - FRAMERATE_60 for 60 fps, - - FRAMERATE_120 for 120 fps, - - FRAMERATE_240 for 240 fps. - - \exception vpFrameGrabberException::settingError : If the required camera is - not present. - - \warning Has to be called after open() to be sure that a camera is detected. - - \sa setFormat(), setMode(), open(), getNumCameras(), setCamera() - -*/ -void -vp1394Grabber::setFramerate(int framerate) -{ - if (iso_transmission_started == true) { - - stopIsoTransmission(); - - for (unsigned int i=0; i < num_cameras; i++) - dc1394_dma_unlisten( handles[i], &cameras[i] ); - iso_transmission_started = false; - } - - this->pframerate[camera] = framerate; - - setup(); - startIsoTransmission(); -} - -/*! - - Query the actual capture framerate of a given camera. The camera supported - framerates are given by getFramerateSupported(). - - \warning Before requerying the actual framerate a handle must - be created by calling open(), and a camera must be connected. - - \param framerate : The camera capture framerate. - - \return true if the framerate was obtained, false if an error occurs. - - \exception vpFrameGrabberException::settingError : If the required camera is - not present. - - \sa setFramerate(), getFramerateSupported(), open(), getNumCameras(), - setCamera() - -*/ -void -vp1394Grabber::getFramerate(int & framerate) -{ - if (handle_created == false) { - close(); - vpERROR_TRACE("To set the shutter the handle must be created"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "To set the shutter the handle must be created") ); - } - if (camera_found == false) { - close(); - vpERROR_TRACE("To set the shutter a camera must be connected"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "To set the shutter a camera must be connected") ); - } - - if(dc1394_get_camera_misc_info(handles[camera], - cameras[camera].node, - &miscinfo) !=DC1394_SUCCESS) { - vpERROR_TRACE("Unable to get misc info"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "Unable to get misc info") ); - } - - framerate = miscinfo.framerate; -} - -/*! - - Query the available framerates for the given camera image format and mode - (see file libdc1394/dc1394_control.h). The framerate is only available if - format is either FORMAT_VGA_NONCOMPRESSED (format 0), - FORMAT_SVGA_NONCOMPRESSED_1 (format 1) or FORMAT_SVGA_NONCOMPRESSED_2 (format - 2). If format is equal to FORMAT_STILL_IMAGE (format 6) or - FORMAT_SCALABLE_IMAGE_SIZE (format 7), the framerate is not available. In - this case, we return 0. - - \warning Before requerying supported framerates for a given format and mode a - handle must be created by calling open(), and a camera must be connected. - - \param format : Camera image format. - \param mode : Camera mode. - \param framerates ; The list of supported camera framerates. - - \return The number of supported camera image framerates, 0 if an error - occurs. - - \exception vpFrameGrabberException::settingError : If the required camera is - not present. - - \sa getFormatSupported(), getModeSupported(), open(), getFramerate(), - setCamera() -*/ -int -vp1394Grabber::getFramerateSupported(int format, int mode, - vpList<int> & framerates) -{ - int nb = 0; // Number of supported framerates - - // Refresh the list of supported framerates - framerates.kill(); - - if (handle_created == false) { - close(); - vpERROR_TRACE("To set the shutter the handle must be created"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "To set the shutter the handle must be created") ); - } - if (camera_found == false) { - close(); - vpERROR_TRACE("To set the shutter a camera must be connected"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "To set the shutter a camera must be connected") ); - } - - switch(format) { - case FORMAT_VGA_NONCOMPRESSED: - case FORMAT_SVGA_NONCOMPRESSED_1: - case FORMAT_SVGA_NONCOMPRESSED_2: - { - - quadlet_t value; - if (dc1394_query_supported_framerates(handles[camera], - cameras[camera].node, - format, mode, - &value) != DC1394_SUCCESS) { - vpERROR_TRACE("Could not query supported frametates for format %d\n" - "and mode %d\n", format, mode); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "Could not query supported framerates") ); - } - - for (int f = FRAMERATE_MIN; f <= FRAMERATE_MAX; f ++) { - if (value & (0x1<<(31-(f-FRAMERATE_MIN)))) { - framerates.addRight(f); - nb ++; - } - } - } - break; - default: - // Framerate not available for: - // - FORMAT_STILL_IMAGE for the Format_6 - // - FORMAT_SCALABLE_IMAGE_SIZE for the Format_7 - return 0; - } - - return nb; -} - -/*! - - Converts the string containing the description of the format into the format - dentifier. - - \param format : The string describing the format given by Format(int) - - \return The camera capture format identifier, either : - - FORMAT_VGA_NONCOMPRESSED for the Format_0 - - FORMAT_SVGA_NONCOMPRESSED_1 for the Format_1 - - FORMAT_SVGA_NONCOMPRESSED_2 for the Format_2 - - FORMAT_STILL_IMAGE for the Format_6 - - FORMAT_SCALABLE_IMAGE_SIZE for the Format_7 - . - This method returns 0 if the string does not match to a format string. - - \sa convertFormat(int), convertMode(std::string), convertFramerate(std::string&) - -*/ -int vp1394Grabber::convertFormat(std::string format) -{ - for (int i = FORMAT_MIN; i <= FORMAT_MAX; i ++) { - // if (format.compare(0, format(i).length(), format(i)) == 0) { - if (format.compare(0, convertFormat(i).length(), convertFormat(i)) == 0) { - return i; - } - }; - - return 0; -} -/*! - - Converts the string containing the description of the mode into the mode - dentifier. - - \param mode : The string describing the mode given by Mode(int) - - \return The camera capture mode identifier. - - This method returns 0 if the string does not match to a mode string. - - \sa convertMode(int), convertFormat(std::string), convertFramerate(std::string) - -*/ -int vp1394Grabber::convertMode(std::string mode) -{ - for (int i = MODE_FORMAT0_MIN; i <= MODE_FORMAT0_MAX; i ++) { - if (mode.compare(convertMode(i)) == 0) - return i; - }; - for (int i = MODE_FORMAT1_MIN; i <= MODE_FORMAT1_MAX; i ++) { - if (mode.compare(convertMode(i)) == 0) - return i; - }; - for (int i = MODE_FORMAT2_MIN; i <= MODE_FORMAT2_MAX; i ++) { - if (mode.compare(convertMode(i)) == 0) - return i; - }; - for (int i = MODE_FORMAT6_MIN; i <= MODE_FORMAT6_MAX; i ++) { - if (mode.compare(convertMode(i)) == 0) - return i; - }; - for (int i = MODE_FORMAT7_MIN; i <= MODE_FORMAT7_MAX; i ++) { - if (mode.compare(convertMode(i)) == 0) - return i; - }; - for (int i = COLOR_FORMAT7_MIN; i <= COLOR_FORMAT7_MAX; i ++) { - if (mode.compare(convertMode(i)) == 0) - return i; - }; - - return 0; -} -/*! - - Converts the string containing the description of the framerate into the - framerate dentifier. - - \param framerate : The string describing the framerate given by - Framerate(int). - - \return The camera capture framerate identifier. - - This method returns 0 if the string does not match to a framerate string. - - \sa convertFramerate(int), convertFormat(std::string &), convertMode(std::string) - -*/ -int vp1394Grabber::convertFramerate(std::string framerate) -{ - for (int i = FRAMERATE_MIN; i <= FRAMERATE_MAX; i ++) { - if (framerate.compare(convertFramerate(i)) == 0) - return i; - }; - - return 0; -} - - -/*! - - Converts the format identifier into a string containing the description of - the format. - - \param format : The camera capture format, either : - - FORMAT_VGA_NONCOMPRESSED for the Format_0 - - FORMAT_SVGA_NONCOMPRESSED_1 for the Format_1 - - FORMAT_SVGA_NONCOMPRESSED_2 for the Format_2 - - FORMAT_STILL_IMAGE for the Format_6 - - FORMAT_SCALABLE_IMAGE_SIZE for the Format_7 - - \return A string describing the format, an empty string if the format is not - supported. - - \sa convertMode(), convertFramerate() - -*/ -std::string vp1394Grabber::convertFormat(int format) -{ - std::string _format; - if ((format >= FORMAT_MIN) && (format <= FORMAT_MAX)) { - switch (format) { - case FORMAT_VGA_NONCOMPRESSED: _format = strFormats[0]; break; - case FORMAT_SVGA_NONCOMPRESSED_1: _format = strFormats[1]; break; - case FORMAT_SVGA_NONCOMPRESSED_2: _format = strFormats[2]; break; - // 3 reserved formats - case FORMAT_SVGA_NONCOMPRESSED_2 + 1: _format = strFormats[3]; break; - case FORMAT_SVGA_NONCOMPRESSED_2 + 2: _format = strFormats[4]; break; - case FORMAT_SVGA_NONCOMPRESSED_2 + 3: _format = strFormats[5]; break; - - case FORMAT_STILL_IMAGE: _format = strFormats[6]; break; - case FORMAT_SCALABLE_IMAGE_SIZE: _format = strFormats[7]; break; - default: - break; - } - } - else { - std::cout << "The format " << format - << " is not supported by the camera" << std::endl; - _format = "Not Valid"; - } - - return _format; -} -/*! - - Converts the mode identifier into a string containing the description of the - mode. - - \param mode : The camera capture mode. - - \return A string describing the mode, an empty string if the mode is not - supported. - - \sa convertFormat(), convertFramerate() - -*/ -std::string vp1394Grabber::convertMode(int mode) -{ - std::string _mode; - - if ((mode >= MODE_FORMAT0_MIN) && (mode <= MODE_FORMAT0_MAX)) { - switch (mode) { - case MODE_160x120_YUV444: _mode = strModesInFormat0[0]; break; - case MODE_320x240_YUV422: _mode = strModesInFormat0[1]; break; - case MODE_640x480_YUV411: _mode = strModesInFormat0[2]; break; - case MODE_640x480_YUV422: _mode = strModesInFormat0[3]; break; - case MODE_640x480_RGB: _mode = strModesInFormat0[4]; break; - case MODE_640x480_MONO: _mode = strModesInFormat0[5]; break; - case MODE_640x480_MONO16: _mode = strModesInFormat0[6]; break; - default: break; - } - } - else if ((mode >= MODE_FORMAT1_MIN) && (mode <= MODE_FORMAT1_MAX)) { - switch (mode) { - case MODE_800x600_YUV422: _mode = strModesInFormat1[0]; break; - case MODE_800x600_RGB: _mode = strModesInFormat1[1]; break; - case MODE_800x600_MONO: _mode = strModesInFormat1[2]; break; - case MODE_1024x768_YUV422: _mode = strModesInFormat1[3]; break; - case MODE_1024x768_RGB: _mode = strModesInFormat1[4]; break; - case MODE_1024x768_MONO: _mode = strModesInFormat1[5]; break; - case MODE_800x600_MONO16: _mode = strModesInFormat1[6]; break; - case MODE_1024x768_MONO16: _mode = strModesInFormat1[7]; break; - default: break; - } - } - else if ((mode >= MODE_FORMAT2_MIN) && (mode <= MODE_FORMAT2_MAX)) { - switch (mode) { - case MODE_1280x960_YUV422: _mode = strModesInFormat2[0]; break; - case MODE_1280x960_RGB: _mode = strModesInFormat2[1]; break; - case MODE_1280x960_MONO: _mode = strModesInFormat2[2]; break; - case MODE_1600x1200_YUV422: _mode = strModesInFormat2[3]; break; - case MODE_1600x1200_RGB: _mode = strModesInFormat2[4]; break; - case MODE_1600x1200_MONO: _mode = strModesInFormat2[5]; break; - case MODE_1280x960_MONO16: _mode = strModesInFormat2[6]; break; - case MODE_1600x1200_MONO16: _mode = strModesInFormat2[7]; break; - default: break; - } - } - else if ((mode >= MODE_FORMAT6_MIN) && (mode <= MODE_FORMAT6_MAX)) { - switch (mode) { - case MODE_EXIF: _mode = strModesInFormat6[0]; break; - default: break; - } - } - else if ((mode >= MODE_FORMAT7_MIN) && (mode <= MODE_FORMAT7_MAX)) { - switch (mode) { - case MODE_FORMAT7_0: _mode = strModesInFormat7[0]; break; - case MODE_FORMAT7_1: _mode = strModesInFormat7[1]; break; - case MODE_FORMAT7_2: _mode = strModesInFormat7[2]; break; - case MODE_FORMAT7_3: _mode = strModesInFormat7[3]; break; - case MODE_FORMAT7_4: _mode = strModesInFormat7[4]; break; - case MODE_FORMAT7_5: _mode = strModesInFormat7[5]; break; - case MODE_FORMAT7_6: _mode = strModesInFormat7[6]; break; - case MODE_FORMAT7_7: _mode = strModesInFormat7[7]; break; - default: break; - } - } - else if ((mode >= COLOR_FORMAT7_MIN) && (mode <= COLOR_FORMAT7_MAX)) { - switch (mode) { - case COLOR_FORMAT7_MONO8: _mode = strColorsInFormat7[0]; break; - case COLOR_FORMAT7_YUV411: _mode = strColorsInFormat7[1]; break; - case COLOR_FORMAT7_YUV422: _mode = strColorsInFormat7[2]; break; - case COLOR_FORMAT7_YUV444: _mode = strColorsInFormat7[3]; break; - case COLOR_FORMAT7_RGB8: _mode = strColorsInFormat7[4]; break; - case COLOR_FORMAT7_MONO16: _mode = strColorsInFormat7[5]; break; - case COLOR_FORMAT7_RGB16: _mode = strColorsInFormat7[6]; break; - default: break; - } - } - else { - std::cout << "The mode " << mode << " is not supported by the camera" << std::endl; - _mode = "Not valid"; - } - - return _mode; -} - -/*! - - Converts the framerate identifier into a string - containing the description of the framerate. - - \param framerate : The camera capture framerate. - - \return A string describing the framerate, an empty string if the framerate - is not supported. - - \sa convertFormat(), convertMode() - -*/ -std::string vp1394Grabber::convertFramerate(int framerate) -{ - std::string _framerate; - - if ((framerate >= FRAMERATE_MIN) && (framerate <= FRAMERATE_MAX)) { - switch (framerate) { - case FRAMERATE_1_875: _framerate = strFramerates[0]; break; - case FRAMERATE_3_75: _framerate = strFramerates[1]; break; - case FRAMERATE_7_5: _framerate = strFramerates[2]; break; - case FRAMERATE_15: _framerate = strFramerates[3]; break; - case FRAMERATE_30: _framerate = strFramerates[4]; break; - case FRAMERATE_60: _framerate = strFramerates[5]; break; - default: break; - } - } - else { - std::cout << "The framerate " << framerate - << " is not supported by the camera" << std::endl; - _framerate = "Not valid"; - } - - return _framerate; - -} - -/*! - - Set the shutter for a given camera. - - \param shutter : The shutter value to apply to the camera. - - - \exception vpFrameGrabberException::settingError : If the required camera is - not present or if an error occurs. - - \warning Has to be called after open() to be sure that a camera is detected. - - \sa getShutter(), open(), getNumCameras(), setCamera() -*/ -void -vp1394Grabber::setShutter(unsigned int shutter) -{ - unsigned int min_shutter = 0; - unsigned int max_shutter = 0; - - - if (handle_created == false) { - close(); - vpERROR_TRACE("To set the shutter the handle must be created"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "To set the shutter the handle must be created") ); - } - if (camera_found == false) { - close(); - vpERROR_TRACE("To set the shutter a camera must be connected"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "To set the shutter a camera must be connected") ); - } - - if(dc1394_get_min_value(handles[camera], - cameras[camera].node, - FEATURE_SHUTTER, &min_shutter) !=DC1394_SUCCESS) { - close(); - vpERROR_TRACE("Unable to get min shutter value"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "Unable to get min shutter value") ); - } - - if(dc1394_get_max_value(handles[camera], - cameras[camera].node, - FEATURE_SHUTTER, &max_shutter) !=DC1394_SUCCESS) { - close(); - vpERROR_TRACE("Unable to get max shutter value"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "Unable to get max shutter value") ); - } - - if (shutter < min_shutter || shutter > max_shutter) { - vpCERROR << "The requested shutter " << shutter - << " must be comprised between " << min_shutter - << " and " << max_shutter << std::endl; - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "Cannot set shutter: bad value") ); - } - - if ( dc1394_set_shutter(handles[camera], - cameras[camera].node, - shutter) != DC1394_SUCCESS) { - vpERROR_TRACE("Unable to set shutter"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "Cannot set shutter") ); - } -} - -/*! - - Query the actual shutter value of a given camera and the bounded shutter - values. - - \warning Before requerying the shutter a handle must - be created by calling open(), and a camera must be connected. - - \param min_shutter : Minimal autorized shutter value. - - \param shutter : The current camera shutter value. This value is comprised - between \e min_shutter and \e max_shutter. - - \param max_shutter : Maximal autorized shutter value. - - - \exception vpFrameGrabberException::settingError : If the required camera is - not present or if an error occurs. - - \sa setShutter(), open(), getNumCameras(), setCamera() - -*/ -void -vp1394Grabber::getShutter(unsigned int &min_shutter, - unsigned int &shutter, - unsigned int &max_shutter) -{ - shutter = 0; - min_shutter = 0; - max_shutter = 0; - - if (handle_created == false) { - close(); - vpERROR_TRACE("To set the shutter the handle must be created"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "To set the shutter the handle must be created") ); - } - if (camera_found == false) { - close(); - vpERROR_TRACE("To set the shutter a camera must be connected"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "To set the shutter a camera must be connected") ); - } - if(dc1394_get_shutter(handles[camera], - cameras[camera].node, - &shutter) !=DC1394_SUCCESS) { - close(); - vpERROR_TRACE("Unable to get shutter value"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "Unable to get shutter value") ); - - } - - if(dc1394_get_min_value(handles[camera], - cameras[camera].node, - FEATURE_SHUTTER, &min_shutter) !=DC1394_SUCCESS) { - close(); - vpERROR_TRACE("Unable to get min shutter value"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "Unable to get min shutter value") ); - } - - if(dc1394_get_max_value(handles[camera], - cameras[camera].node, - FEATURE_SHUTTER, &max_shutter) !=DC1394_SUCCESS) { - close(); - vpERROR_TRACE("Unable to get max shutter value"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "Unable to get max shutter value") ); - } -} - -/*! - - Set the gain for a given camera. - - \warning Before setting the gain a handle must - be created by calling open(), and a camera must be connected. - - \param gain The gain value to apply to the camera. - - \exception vpFrameGrabberException::settingError : If the required camera is not present or if an error occurs. - - \sa getGain(), getNumCameras(), setCamera() -*/ -void -vp1394Grabber::setGain(unsigned int gain) -{ - unsigned int min_gain = 0; - unsigned int max_gain = 0; - - - if (handle_created == false) { - close(); - vpERROR_TRACE("To set the shutter the handle must be created"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "To set the shutter the handle must be created") ); - } - if (camera_found == false) { - close(); - vpERROR_TRACE("To set the shutter a camera must be connected"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "To set the shutter a camera must be connected") ); - } - if(dc1394_get_min_value(handles[camera], - cameras[camera].node, - FEATURE_GAIN, &min_gain) !=DC1394_SUCCESS) { - close(); - vpERROR_TRACE("Unable to get min gain value"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "Unable to get min gain value") ); - } - - if(dc1394_get_max_value(handles[camera], - cameras[camera].node, - FEATURE_GAIN, &max_gain) !=DC1394_SUCCESS) { - close(); - vpERROR_TRACE("Unable to get max gain value"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "Unable to get max gain value") ); - } - - if (gain < min_gain || gain > max_gain) { - vpCERROR << "The requested gain " << gain - << " must be comprised between " << min_gain - << " and " << max_gain << std::endl; - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "Cannot set shutter: bad value") ); - } - - if ( dc1394_set_gain(handles[camera], - cameras[camera].node, - gain) != DC1394_SUCCESS) { - vpERROR_TRACE("Unable to set gain"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "Cannot set gain") ); - } -} - -/*! - - Query the actual gain value of a given camera and the bounded gain - values. - - \warning Before requerying the gain a handle must - be created by calling open(), and a camera must be connected. - - \param min_gain : Minimal autorized gain value. - - \param gain : The current camera gain value. This value is comprised - between \e min_gain and \e max_gain. - - \param max_gain : Maximal autorized gain value. - - \exception vpFrameGrabberException::settingError :If the required camera is - not present or if an error occurs. - - \sa setGain(), open(), getNumCameras(), setCamera() - -*/ -void -vp1394Grabber::getGain(unsigned int &min_gain, - unsigned int &gain, - unsigned int &max_gain) -{ - gain = 0; - min_gain = 0; - max_gain = 0; - - if (handle_created == false) { - close(); - vpERROR_TRACE("To set the shutter the handle must be created"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "To set the shutter the handle must be created") ); - } - if (camera_found == false) { - close(); - vpERROR_TRACE("To set the shutter a camera must be connected"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "To set the shutter a camera must be connected") ); - } - - if(dc1394_get_gain(handles[camera], - cameras[camera].node, - &gain) !=DC1394_SUCCESS) { - close(); - vpERROR_TRACE("Unable to get gain value"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "Unable to get gain value") ); - - } - - if(dc1394_get_min_value(handles[camera], - cameras[camera].node, - FEATURE_GAIN, &min_gain) !=DC1394_SUCCESS) { - close(); - vpERROR_TRACE("Unable to get min gain value"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "Unable to get min gain value") ); - } - - if(dc1394_get_max_value(handles[camera], - cameras[camera].node, - FEATURE_GAIN, &max_gain) !=DC1394_SUCCESS) { - close(); - vpERROR_TRACE("Unable to get max gain value"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "Unable to get max gain value") ); - - } -} - -/*! - - Get the image width. It depends on the camera format setFormat() and mode - setMode(). The width of the images is only available after a call to open(). - - \param width : The image width, zero if the required camera is not available. - - \exception vpFrameGrabberException::settingError : If the required camera is - not present. - - \warning Has to be called after open() to be sure that a camera is detected. - - \sa getHeight(), setCamera() - -*/ -void vp1394Grabber::getWidth(unsigned int &width) -{ - if (camera >= num_cameras) { - width = 0; - close(); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "The required camera is not present") ); - } - - width = this->_width[camera]; - this->width = width; -} - -/*! - - Get the image height. It depends on the camera format setFormat() and mode - setMode(). The height of the images is only available after a call to - open(). - - \param height : The image height. - - \exception vpFrameGrabberException::settingError : If the required camera is - not present. - - \warning Has to be called after open() to be sure that a camera is detected. - - \sa getWidth(), getImageFormat(), close(), getNumCameras(), setCamera() - -*/ -void vp1394Grabber::getHeight(unsigned int &height) -{ - if (camera >= num_cameras) { - height = 0; - close(); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "The required camera is not present") ); - } - - height = this->_height[camera]; - this->height = height; -} - -/*! - - Query the number of cameras on the bus. - - \param cameras : The number of cameras found on the bus. - - -*/ -void -vp1394Grabber::getNumCameras(unsigned int &cameras) -{ - if (camera_found == false) { - vpCTRACE << "No camera found..."<< std::endl; - cameras = 0; - } - - cameras = num_cameras; -} - - -/*! - Initialize grey level image acquisition - - \param I : Image data structure (8 bits image) - -*/ -void -vp1394Grabber::open(vpImage<unsigned char> &I) -{ - - open(); - - // Get the actual camera format, mode and framerate - getFormat(pformat[camera]); - getMode(pmode[camera]); - getFramerate(pframerate[camera]); - - setup(); - startIsoTransmission(); - - unsigned int w, h; - getWidth( w ) ; - getHeight( h ) ; - - vpDEBUG_TRACE(10, "%d %d", h, w ) ; - - I.resize(h, w) ; - - init = true ; - -} - -/*! - Initialize color image (in RGBa format) acquisition - - \param I : Image data structure (RGBa format) - -*/ -void -vp1394Grabber::open(vpImage<vpRGBa> &I) -{ - - open(); - - // Get the actual camera format, mode and framerate - getFormat(pformat[camera]); - getMode(pmode[camera]); - getFramerate(pframerate[camera]); - - setup(); - startIsoTransmission(); - - unsigned int w, h; - getWidth( w ) ; - getHeight( h ) ; - - vpDEBUG_TRACE(10, "%d %d", h, w ) ; - - I.resize(h, w) ; - - init = true ; - -} - -/*! - Acquire a grey level image from a given camera. - - \param I : Image data structure (8 bits image) - - \exception vpFrameGrabberException::initializationError : If the device is - not openned. - - \sa getField(), setCamera() -*/ -void -vp1394Grabber::acquire(vpImage<unsigned char> &I) -{ - - if (init==false) - { - close(); - throw (vpFrameGrabberException(vpFrameGrabberException::initializationError, - "Initialization not done") ); - } - - int *bitmap = NULL ; - bitmap = dmaCapture(); - - unsigned int w, h; - getWidth( w ) ; - getHeight( h ) ; - - if ((I.getWidth() != w)||(I.getHeight() != h)) - I.resize(h, w) ; - - int size = I.getHeight()*I.getWidth(); - switch (image_format[camera]) - { - case MONO: - memcpy(I.bitmap, (unsigned char *) bitmap, size*sizeof(unsigned char)); - break; - case YUV411: { - vpImageConvert::YUV411ToGrey( (unsigned char *) bitmap, I.bitmap, size); - break; - } - case YUV422: { - vpImageConvert::YUV422ToGrey( (unsigned char *) bitmap, I.bitmap, size); - break; - } - case RGB: { - vpImageConvert::RGBToGrey((unsigned char *) bitmap, I.bitmap, size); - break; - } - case RGBa: { - vpImageConvert::RGBaToGrey((unsigned char *) bitmap, I.bitmap, size); - break; - } - default: - throw (vpFrameGrabberException(vpFrameGrabberException::otherError, - "Format conversion not implemented. Acquisition failed.") ); - break; - }; - - dmaDoneWithBuffer(); - -} - -/*! - Acquire a color image from a given camera. - - \param I : Image data structure (RGBa image) - - \exception vpFrameGrabberException::initializationError : If the device is - not openned. - - \sa getField(), setCamera() -*/ -void -vp1394Grabber::acquire(vpImage<vpRGBa> &I) -{ - - if (init==false) - { - close(); - throw (vpFrameGrabberException(vpFrameGrabberException::initializationError, - "Initialization not done") ); - } - - int *bitmap = NULL ; - bitmap = dmaCapture(); - - unsigned int w, h; - getWidth( w ) ; - getHeight( h ) ; - - if ((I.getWidth() != w)||(I.getHeight() != h)) - I.resize(h, w) ; - - int size = I.getHeight()*I.getWidth(); - switch (image_format[camera]) - { - case MONO: - vpImageConvert::GreyToRGBa((unsigned char *) bitmap, - (unsigned char *) I.bitmap, size); - break; - case YUV411: { - vpImageConvert::YUV411ToRGBa( (unsigned char *) bitmap, - (unsigned char *) I.bitmap, size); - break; - } - case YUV422: { - vpImageConvert::YUV422ToRGBa( (unsigned char *) bitmap, - (unsigned char *) I.bitmap, size); - break; - } - case RGB: { - vpImageConvert::RGBToRGBa((unsigned char *) bitmap, - (unsigned char *) I.bitmap, size); - break; - } - case RGBa: { - memcpy((unsigned char *) I.bitmap, (unsigned char *) bitmap, size); - break; - } - default: - throw (vpFrameGrabberException(vpFrameGrabberException::otherError, - "Format conversion not implemented. Acquisition failed.") ); - break; - }; - - dmaDoneWithBuffer(); - -} - - -/*! - - Open ohci and asign handle to it and get the camera nodes and - describe them as we find them. - - \exception vpFrameGrabberException::initializationError : If a raw1394 handle - can't be aquired. - - \sa close() -*/ -void -vp1394Grabber::open() -{ - //int num_nodes; - int num_ports = vp1394Grabber::MAX_PORTS; - struct raw1394_portinfo ports[vp1394Grabber::MAX_PORTS]; - raw1394handle_t raw_handle; - - if (handles == NULL) - handles = new raw1394handle_t [vp1394Grabber::MAX_CAMERAS]; - if (cameras == NULL) - cameras = new dc1394_cameracapture [vp1394Grabber::MAX_CAMERAS]; - if (cam_count == NULL) - cam_count = new int [vp1394Grabber::MAX_CAMERAS]; - if (pformat == NULL) - pformat = new int [vp1394Grabber::MAX_CAMERAS]; - if (pmode == NULL) - pmode = new int [vp1394Grabber::MAX_CAMERAS]; - if (pframerate == NULL) - pframerate = new int [vp1394Grabber::MAX_CAMERAS]; - if (_width == NULL) - _width = new int [vp1394Grabber::MAX_CAMERAS]; - if (_height == NULL) - _height = new int [vp1394Grabber::MAX_CAMERAS]; - if (image_format == NULL) - image_format = new vp1394ImageFormatType [vp1394Grabber::MAX_CAMERAS]; - - raw_handle = raw1394_new_handle(); - - if (raw_handle==NULL) { - close(); - vpERROR_TRACE("Unable to aquire a raw1394 handle\n\n" - "Please check \n" - " - if the kernel modules `ieee1394',`raw1394' and `ohci1394' are loaded \n" - " - if you have read/write access to /dev/raw1394\n\n"); - throw (vpFrameGrabberException(vpFrameGrabberException::initializationError, - "Unable to aquire a raw1394 handle") ); - } - - num_ports = raw1394_get_port_info(raw_handle, ports, num_ports); - raw1394_destroy_handle(raw_handle); - if (verbose) - printf("number of ports detected: %d\n", num_ports); - - if (num_ports < 1) { - close(); - throw (vpFrameGrabberException(vpFrameGrabberException::initializationError, - "no ports found") ); - } - - //num_nodes = raw1394_get_nodecount(raw_handle); - num_cameras = 0; - - /* get dc1394 handle to each port */ - for (int p = 0; p < num_ports; p++) { - - /* get the camera nodes and describe them as we find them */ - raw_handle = raw1394_new_handle(); - raw1394_set_port( raw_handle, p ); - - camera_nodes = NULL; - camera_nodes = dc1394_get_camera_nodes(raw_handle, &cam_count[p], 0); - raw1394_destroy_handle(raw_handle); - if (verbose) - fprintf(stdout, "%d camera(s) on port %d\n", cam_count[p], p); - - for (int i = 0; i < cam_count[p]; i++, num_cameras ++) { - handles[num_cameras] = dc1394_create_handle(p); - if (handles[num_cameras]==NULL) { - close(); - vpERROR_TRACE("Unable to aquire a raw1394 handle\n"); - vpERROR_TRACE("did you load the drivers?\n"); - throw (vpFrameGrabberException(vpFrameGrabberException::initializationError, - "Unable to aquire a raw1394 handle.") ); - } - cameras[num_cameras].node = camera_nodes[i]; - - } - if (cam_count[p]) - dc1394_free_camera_nodes(camera_nodes); - } - - if (num_cameras < 1) { - close(); - throw (vpFrameGrabberException(vpFrameGrabberException::initializationError, - "no cameras found") ); - } - vpDEBUG_TRACE(10, "%d cameras detected\n", num_cameras); - - camera_found = true; - - handle_created = true; - - // Get the actual camera format, mode and framerate - getFormat(pformat[camera]); - getMode(pmode[camera]); - getFramerate(pframerate[camera]); -} - -/*! - - Get the feature and set the dma capture. - - Set the camera to the specified format setFormat(), mode setMode() and - framerate setFramerate(). Considering the camera format and mode, updates - the captured image size. - - \exception vpFrameGrabberException::otherError : If unable to get feature set - or setup the camera. - - \sa setFormat(), setMode(), setFramerate(), getWidth(), getHeight() - -*/ -void -vp1394Grabber::setup() -{ - unsigned int channel; - unsigned int speed; - - if ( handle_created == true && camera_found == true) { - - for (unsigned int i = 0; i < num_cameras; i++) { - if (verbose) { - dc1394_feature_set features; - - if(dc1394_get_camera_feature_set(handles[i], - cameras[i].node, - &features) != DC1394_SUCCESS) { - close(); - - throw (vpFrameGrabberException(vpFrameGrabberException::otherError, - "Unable to get feature set") ); - } - else { - dc1394_print_feature_set(&features); - } - } - - // After setting the camera format and mode we update the image size - getImageCharacteristics(pformat[i], - pmode[i], - _width[i], - _height[i], - image_format[i]); - - if (dc1394_get_iso_channel_and_speed(handles[i], - cameras[i].node, - &channel, - &speed) != DC1394_SUCCESS) { - close(); - throw (vpFrameGrabberException(vpFrameGrabberException::otherError, - "Unable to get the iso channel number") ); - } - - if (pformat[i] == FORMAT_SCALABLE_IMAGE_SIZE) { - if( dc1394_dma_setup_format7_capture(handles[i], - cameras[i].node, - channel, - pmode[i], - speed, - USE_MAX_AVAIL, /*max packet size*/ - 0, 0, /* left, top */ - _width[i], - _height[i], - vp1394Grabber::NUM_BUFFERS, - vp1394Grabber::DROP_FRAMES, - device_name, - &cameras[i]) != DC1394_SUCCESS) { - close(); - - vpERROR_TRACE("Unable to setup camera in format 7 mode 0-\n" - "check line %d of %s to" - "make sure that the video mode,framerate and format are " - "supported by your camera.\n", - __LINE__,__FILE__); - - throw (vpFrameGrabberException(vpFrameGrabberException::otherError, - "Unable to setup camera in format 7 ") ); - - } - if (verbose) { - unsigned int qpp; // packet bytes - if (dc1394_query_format7_byte_per_packet(handles[i], - cameras[i].node, - pmode[i], - &qpp) != DC1394_SUCCESS) { - close(); - - throw (vpFrameGrabberException(vpFrameGrabberException::otherError, - "Unable to query format7 byte_per_packet ") ); - } - //std::cout << "Format 7: byte per packet : " << qpp << std::endl; - } - - } else { - - if (dc1394_dma_setup_capture(handles[i], - cameras[i].node, - channel, - pformat[i], - pmode[i], - speed, - pframerate[i], - vp1394Grabber::NUM_BUFFERS, - vp1394Grabber::DROP_FRAMES, - device_name, - &cameras[i]) != DC1394_SUCCESS) { - vpERROR_TRACE("Unable to setup camera- check line %d of %s to" - "make sure that the video mode,framerate and format are " - "supported by your camera.\n", - __LINE__,__FILE__); - close(); - - throw (vpFrameGrabberException(vpFrameGrabberException::otherError, - "Unable to setup camera ") ); - } - } - } - } -} - -/*! - - Gets the image size and coding format, depending on the camera image format - and the camera mode. - - \param _format : The camera capture format. - \param _mode : The camera capture mode. - \param width : Width of the image for the given camera capture format - and mode. - - \param height : Height of the image for the given camera capture format and - mode. - - \param image_format : Coding image format for the given camera capture - format and mode. - - \exception vpFrameGrabberException::otherError : If camera mode (see - setMode()) and the image format (see setFormat()) are incompatible. - - \sa setFormat(), setMode(), getWidth(), getHeight(), setCamera() -*/ -void -vp1394Grabber::getImageCharacteristics(int _format, int _mode, - int &width, int &height, - vp1394ImageFormatType &_image_format) -{ - switch(_format) - { - case FORMAT_VGA_NONCOMPRESSED: - switch(_mode) - { - case MODE_160x120_YUV444: - width = 160; height = 120; - _image_format = YUV444; - break; - case MODE_320x240_YUV422: - width = 320; height = 240; - _image_format = YUV422; - break; - case MODE_640x480_YUV411: - width = 640; height = 480; - _image_format = YUV411; - break; - case MODE_640x480_YUV422: - width = 640; height = 480; - _image_format = YUV422; - break; - case MODE_640x480_RGB: - width = 640; height = 480; - _image_format = RGB; - break; - case MODE_640x480_MONO: - width = 640; height = 480; - _image_format = MONO; - break; - case MODE_640x480_MONO16: - width = 640; height = 480; - _image_format = MONO; - break; - default: - close(); - vpERROR_TRACE("Error: camera image format and camera mode are uncompatible...\n"); - vpERROR_TRACE("format: %d and mode: %d\n", _format, _mode); - throw (vpFrameGrabberException(vpFrameGrabberException::otherError, - "Wrong mode for format 0") ); - break; - } - break; - case FORMAT_SVGA_NONCOMPRESSED_1: - switch(_mode) - { - case MODE_800x600_YUV422: - width = 800; height = 600; - _image_format = YUV422; - break; - case MODE_800x600_RGB: - width = 800; height = 600; - _image_format = RGB; - break; - case MODE_800x600_MONO: - width = 800; height = 600; - _image_format = MONO; - break; - case MODE_800x600_MONO16: - width = 800; height = 600; - _image_format = MONO16; - break; - case MODE_1024x768_YUV422: - width = 1024; height = 768; - _image_format = YUV422; - break; - case MODE_1024x768_RGB: - width = 1024; height = 768; - _image_format = RGB; - break; - case MODE_1024x768_MONO: - width = 1024; height = 768; - _image_format = MONO; - break; - case MODE_1024x768_MONO16: - width = 1024; height = 768; - _image_format = MONO16; - break; - default: - close(); - vpERROR_TRACE("Error: camera image format and camera mode are uncompatible...\n"); - vpERROR_TRACE("format: %d and mode: %d\n", _format, _mode); - throw (vpFrameGrabberException(vpFrameGrabberException::otherError, - "Wrong mode for format 1") ); - break; - } - break; - case FORMAT_SVGA_NONCOMPRESSED_2: - switch(_mode) - { - case MODE_1280x960_YUV422: - width = 1280; height = 960; - _image_format = YUV422; - break; - case MODE_1280x960_RGB: - width = 1280; height = 960; - _image_format = RGB; - break; - case MODE_1280x960_MONO: - width = 1280; height = 960; - _image_format = MONO; - break; - case MODE_1280x960_MONO16: - width = 1280; height = 960; - _image_format = MONO16; - break; - case MODE_1600x1200_YUV422: - width = 1600; height = 1200; - _image_format = YUV422; - break; - case MODE_1600x1200_RGB: - width = 1600; height = 1200; - _image_format = RGB; - break; - case MODE_1600x1200_MONO: - width = 1600; height = 1200; - _image_format = MONO; - break; - case MODE_1600x1200_MONO16: - width = 1600; height = 1200; - _image_format = MONO16; - break; - default: - close(); - vpERROR_TRACE("Error: camera image format and camera mode are uncompatible...\n"); - vpERROR_TRACE("format: %d and mode: %d\n", _format, _mode); - throw (vpFrameGrabberException(vpFrameGrabberException::otherError, - "Wrong mode for format 2") ); - break; - } - break; - case FORMAT_SCALABLE_IMAGE_SIZE: -#if 1 - switch(_mode) - { - case MODE_FORMAT7_0: - width = 656; height = 492; - _image_format = YUV422; - break; - - case MODE_FORMAT7_1: - width = 328; height = 492; - _image_format = MONO; - break; - case MODE_FORMAT7_2: - width = 656; height = 244; - _image_format = MONO; - break; - case MODE_FORMAT7_3: - case MODE_FORMAT7_4: - case MODE_FORMAT7_5: - case MODE_FORMAT7_6: - case MODE_FORMAT7_7: - width = 656; height = 244; - _image_format = MONO; - break; - } - - -#else - // Did not work. Even if subsampling is activated in MODE_FORMAT7_1, image - // max size is the size of the image without considering the subsampling - switch(_mode) - { - case MODE_FORMAT7_0: - // _width = 656; _height = 492; - _image_format = YUV422; - break; - - case MODE_FORMAT7_1: - // _width = 328; _height = 492; - _image_format = MONO; - break; - case MODE_FORMAT7_2: - // _width = 656; _height = 244; - _image_format = MONO; - break; - } - - // In format 7 we query set the image size to the maximal image size - if (dc1394_query_format7_max_image_size(handles[camera], - cameras[camera].node, - _mode, - &width, - &_eight) != DC1394_SUCCESS) { - close(); - vpERROR_TRACE("Unable to get maximal image size for format 7\n"); - throw (vpFrameGrabberException(vpFrameGrabberException::otherError, - "Unable to get maximal image size for format 7 ") ); - } - std::cout << "max width=" << width << " height: " << height << std::endl; -#endif - - break; - default: - close(); - vpERROR_TRACE("Error: camera image format and camera mode are uncompatible...\n"); - vpERROR_TRACE("format: %d and mode: %d\n", _format, _mode); - throw (vpFrameGrabberException(vpFrameGrabberException::otherError, - "Wrong format") ); - break; - } -} - - -/*! - - Captures a frame from the given camera using DMA (direct memory acces). Two - policies are available, either this fonction waits for a frame (waiting - mode), either it returns if no frame is available (polling mode). - - After you have finished with the frame, you must return the buffer to the - pool by calling dmaDoneWithBuffer(). - - \param waiting : Capture mode; true if you want to wait for an available - image (waiting mode), false to activate the polling mode. - - \return NULL if no frame is available, the address of the image buffer - otherwise. - - \exception vpFrameGrabberException::otherError : If no frame is available. - - \warning Has to be called after open() to be sure that a camera is detected. - - \sa dmaDoneWithBuffer(), getNumCameras(), setCamera() -*/ - -int* -vp1394Grabber::dmaCapture(bool waiting) -{ - - if (camera >= num_cameras) { - std::cout << "The required camera is not present..." - << std::endl; - return NULL; - } - - if ( handle_created == true && camera_found == true) { - if (waiting) { - if (num_cameras == 1) { - // Only one camera on the bus - if (dc1394_dma_single_capture(&cameras[camera]) != DC1394_SUCCESS) { - close(); - throw (vpFrameGrabberException(vpFrameGrabberException::otherError, - "No frame is available...") ); - return NULL; - } - } - else { - // More than one camera on the bus. - if (dc1394_dma_multi_capture(cameras, num_cameras) != DC1394_SUCCESS) { - close(); - throw (vpFrameGrabberException(vpFrameGrabberException::otherError, - "No frame is available...") ); - return NULL; - } - // std::cout << "-"; - } - } - else { - if (num_cameras == 1) { - // Only one camera on the bus - if (dc1394_dma_single_capture_poll(&cameras[camera]) != DC1394_SUCCESS) { - close(); - throw (vpFrameGrabberException(vpFrameGrabberException::otherError, - "No frame is available...") ); - return NULL; - } - } - else { - // More than one camera on the bus. - if (dc1394_dma_multi_capture_poll(cameras, num_cameras) - != DC1394_SUCCESS) { - close(); - throw (vpFrameGrabberException(vpFrameGrabberException::otherError, - "No frame is available...") ); - return NULL; - } - - } - } - } - - return cameras[camera].capture_buffer; -} - -/*! - - Return the buffer to the pool for the given camera. This allows the driver to - use the buffer previously handed to the user. - - \exception vpFrameGrabberException::settingError :If the required camera is - not present. - - \exception vpFrameGrabberException::otherError : If can't stop the dma - access. - - \warning Has to be called after open() to be sure that a camera is detected. - - \sa dmaCapture(), setCamera() - -*/ -void -vp1394Grabber::dmaDoneWithBuffer() -{ - - if (camera >= num_cameras) { - close(); - vpERROR_TRACE("The required camera is not present"); - throw (vpFrameGrabberException(vpFrameGrabberException::settingError, - "The required camera is not present") ); - } - - if ( handle_created == true && camera_found == true) { - if (dc1394_dma_done_with_buffer(&cameras[camera]) != DC1394_SUCCESS) { - throw (vpFrameGrabberException(vpFrameGrabberException::otherError, - "Can't done the dma") ); - } - } -} - - - -/*! - - Close the link between the camera and the acquisition program - -*/ -void -vp1394Grabber::close() -{ - if (iso_transmission_started == true) { - - stopIsoTransmission(); - - for (unsigned int i=0; i < num_cameras; i++) - dc1394_dma_unlisten( handles[i], &cameras[i] ); - iso_transmission_started = false; - } - if ((camera_found == true) && (dma_started == true)) { - for (unsigned int i=0; i < num_cameras; i++) - dc1394_dma_release_camera( handles[i], &cameras[i]); - camera_found = false; - dma_started = false; - } - if (handle_created == true) { - for (unsigned int i=0; i < num_cameras; i++) - dc1394_destroy_handle(handles[i]); - handle_created = false; - } - - if (handles != NULL) { delete [] handles; handles = NULL; } - if (cameras != NULL) { delete [] cameras; cameras = NULL; } - if (cam_count != NULL) { delete [] cam_count; cam_count = NULL; } - if (pformat != NULL) { delete [] pformat; pformat = NULL; } - if (pmode != NULL) { delete [] pmode; pmode = NULL; } - if (pframerate != NULL) { delete [] pframerate; pframerate = NULL; } - if (_width != NULL) { delete [] _width; _width = NULL; } - if (_height != NULL) { delete [] _height; _height = NULL; } - if (image_format != NULL) { delete [] image_format; image_format = NULL; } - -} -/*! - Start the transmission of the images for all the cameras on the bus. - - \exception vpFrameGrabberException::otherError : If Unable to start camera - iso transmission. - - \sa stopIsoTransmission() - -*/ -void vp1394Grabber::startIsoTransmission() -{ - if ( handle_created == true && camera_found == true) { - - for (unsigned int i = 0; i < num_cameras; i ++) { - if (dc1394_start_iso_transmission(handles[i], - cameras[i].node) !=DC1394_SUCCESS) { - close(); - throw (vpFrameGrabberException(vpFrameGrabberException::otherError, - "Unable to start camera iso transmission") ); - } - } - iso_transmission_started = true; - } -} - -/*! - - Stop the Iso transmission for all the cameras on the bus. - - \return true on success, false otherwise. - - \sa StartIsoTransmission() - -*/ -void vp1394Grabber::stopIsoTransmission() -{ - - if (iso_transmission_started == true) { - if (handle_created == true && camera_found == true) { - for (unsigned int i = 0; i < num_cameras; i ++) { - if (dc1394_stop_iso_transmission(handles[i], - cameras[i].node) != DC1394_SUCCESS) { - close(); - throw (vpFrameGrabberException(vpFrameGrabberException::otherError, - "Can't stop the camera") ); - } - - } - iso_transmission_started = false; - } - } -} - - -#endif -#endif diff --git a/src/device/framegrabber/1394/vp1394Grabber.h b/src/device/framegrabber/1394/vp1394Grabber.h deleted file mode 100644 index fad5e9369699bd41d43055f46a317dd4fe0fa715..0000000000000000000000000000000000000000 --- a/src/device/framegrabber/1394/vp1394Grabber.h +++ /dev/null @@ -1,249 +0,0 @@ -/**************************************************************************** - * - * $Id: vp1394Grabber.h 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: - * Firewire cameras video capture. - * - * Authors: - * Fabien Spindler - * - *****************************************************************************/ - -/*! - \file vp1394Grabber.h - \brief class for firewire cameras video capture. - - \warning This class needs at least libdc1394-1.0.0 and - libraw1394-1.1.0. These libraries are available from - http://sourceforge.net/projects/libdc1394 and - http://sourceforge.net/projects/libraw1394 . - - vp1394Grabber was tested with a Marlin F033C camera. This grabber is - not working with a PointGrey DragonFly 2 camera. Since libdc1394-1.x - is deprecated, you should better use vp1394TwoGrabber based on - libdc1394-2.x. - -*/ - -#ifndef vp1394Grabber_h -#define vp1394Grabber_h - -#include <visp/vpConfig.h> - -#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS - -#if defined(VISP_HAVE_DC1394_1) - -#include <string> - -#include <libraw1394/raw1394.h> -#include <libdc1394/dc1394_control.h> - -#include <visp/vpImage.h> -#include <visp/vpFrameGrabber.h> -#include <visp/vpRGBa.h> -#include <visp/vpList.h> - - - -/*! - \class vp1394Grabber - - \ingroup Framegrabber CameraDriver - - \brief Class for firewire ieee1394 video devices using libdc1394-1.x api - - \deprecated This class is deprecated. You should use - vp1394TwoGrabber class instead. - - Needs libraw1394-1.2.0 and libdc1394-1.1.0 or more recent versions - available on http://sourceforge.net. - - This class was tested with Marlin F033C and F131B cameras. This grabber is - not working with a PointGrey DragonFly 2 camera. Since libdc1394-1.x - is deprecated, you should better use vp1394TwoGrabber based on - libdc1394-2.x. - - The code below shows how to use this class. - \code -#include <visp/vpConfig.h> -#include <visp/vpImage.h> -#include <visp/vpImageIo.h> -#include <visp/vp1394Grabber.h> - -int main() -{ -#if defined(VISP_HAVE_DC1394_1) - vpImage<unsigned char> I; // Create a gray level image container - vp1394Grabber g; // Create a grabber based on libdc1394-1.x third party lib - g.setFormat(FORMAT_VGA_NONCOMPRESSED); // Format_0 - g.setMode(MODE_640x480_MONO); // Mode 5 - g.setFramerate(FRAMERATE_15); // 15 fps - - g.open(I); // Open the framegrabber - g.acquire(I); // Acquire an image - vpImageIo::write(I, "image.pgm"); // Write image on the disk -#endif -} - \endcode - - \author Fabien Spindler (Fabien.Spindler@irisa.fr), Irisa / Inria Rennes - -*/ -class VISP_EXPORT vp1394Grabber : public vpFrameGrabber -{ -public: - /*! \enum vp1394ImageFormatType - Supported image coding format. - */ - typedef enum { - YUV444, /*!< YUV 4:4:4 coding format (24 bits/pixel) */ - YUV422, /*!< YUV 4:2:2 coding format (16 bits/pixel) */ - YUV411, /*!< YUV 4:1:1 coding format (12 bits/pixel) */ - RGB, /*!< RGB coding format (24 bits/pixel) */ - RGBa, /*!< RGBa coding format (32 bits/pixel) */ - MONO, /*!< MONO8 coding format (8 bits/pixel) */ - MONO16 /*!< MONO16 coding format (16 bits/pixel) */ - } vp1394ImageFormatType; - - static const int DROP_FRAMES; // Number of frames to drop - static const int NUM_BUFFERS; // Number of buffers - static const int MAX_PORTS; // Port maximal number - static const int MAX_CAMERAS; // Maximal number of cameras on the bus - - static const char * strFormats[NUM_FORMATS]; - static const char * strModesInFormat0[NUM_FORMAT0_MODES]; - static const char * strModesInFormat1[NUM_FORMAT1_MODES]; - static const char * strModesInFormat2[NUM_FORMAT2_MODES]; - static const char * strModesInFormat6[NUM_FORMAT6_MODES]; - static const char * strModesInFormat7[NUM_MODE_FORMAT7]; - static const char * strColorsInFormat7[NUM_COLOR_FORMAT7]; - static const char * strFramerates[NUM_FRAMERATES]; - - -public: - vp_deprecated vp1394Grabber(); - vp_deprecated vp1394Grabber(vpImage<unsigned char> &I); - virtual ~vp1394Grabber(); - - void setCamera(unsigned int camera); - void getCamera(unsigned int &camera); - - void setFormat(int format); - void getFormat(int & format); - int getFormatSupported(vpList<int> & formats); - - void setMode(int mode); - void getMode(int & mode); - int getModeSupported(int format, vpList<int> & modes); - - void setFramerate(int framerate); - void getFramerate(int & framerate); - int getFramerateSupported(int format, int mode, vpList<int> & framerates); - - int convertFormat (std::string format); - int convertMode (std::string mode); - int convertFramerate(std::string framerate); - - std::string convertFormat (int format); - std::string convertMode (int mode); - std::string convertFramerate(int framerate); - - void setShutter(unsigned int shutter); - void getShutter(unsigned int &min_shutter, - unsigned int &shutter, - unsigned int &max_shutter); - - void setGain(unsigned int gain); - void getGain(unsigned int &min_gain, - unsigned int &gain, - unsigned int &max_gain); - - void open(vpImage<unsigned char> &I); - void acquire(vpImage<unsigned char> &I); - void open(vpImage<vpRGBa> &I); - void acquire(vpImage<vpRGBa> &I); - void close(); - - void getWidth (unsigned int &width); - void getHeight(unsigned int &height); - void getNumCameras(unsigned int &cameras); - - -private: - - void open(); - void setup(); - - void getImageCharacteristics(int _format, int _mode, - int &width, int &height, - vp1394ImageFormatType &imageformat); - int* dmaCapture(bool waiting = true); - void dmaDoneWithBuffer(); - - void startIsoTransmission(); - void stopIsoTransmission(); - -private: - bool iso_transmission_started; - bool handle_created; - bool camera_found; - bool camera_nodes_allocated; - bool dma_started; - unsigned int num_cameras; - /* declarations for libdc1394 */ - raw1394handle_t *handles; // MAX_CAMERAS - dc1394_cameracapture *cameras; // MAX_CAMERAS - nodeid_t *camera_nodes; - dc1394_miscinfo miscinfo; - int *cam_count; // MAX_CAMERAS - - /* declarations for video1394 */ - char device_name[FILENAME_MAX]; - - unsigned int camera; - // Camera settings - int *pformat; // MAX_CAMERAS - int *pmode; // MAX_CAMERAS - int *pframerate; // MAX_CAMERAS - bool verbose; - - // Image settings - int *_width; // MAX_CAMERAS - int *_height; // MAX_CAMERAS - vp1394ImageFormatType *image_format; // MAX_CAMERAS -} ; - -#endif -#endif -#endif diff --git a/src/device/framegrabber/1394/vp1394TwoGrabber.cpp b/src/device/framegrabber/1394/vp1394TwoGrabber.cpp index a5a6d45dcdb77c0e72032f72111864feafa06e96..f76e891dc5bbd1df0f16c0382b33919b53baa6b4 100644 --- a/src/device/framegrabber/1394/vp1394TwoGrabber.cpp +++ b/src/device/framegrabber/1394/vp1394TwoGrabber.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vp1394TwoGrabber.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: vp1394TwoGrabber.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -168,28 +168,20 @@ int main() */ vp1394TwoGrabber::vp1394TwoGrabber(bool reset) + : camera(NULL), cameras(NULL), num_cameras(0), camera_id(0), verbose(false), camIsOpen(NULL), + num_buffers(4), // ring buffer size + isDataModified(NULL), initialShutterMode(NULL), dataCam(NULL) + #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7 + , d(NULL), + list(NULL) + #endif { // protected members width = height = 0; // private members - num_cameras = 0; - cameras = NULL; - camera_id = 0; - verbose = false;//true; - camIsOpen = NULL; init = false; - cameras = NULL; -#ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7 - d = NULL; - list = NULL; -#endif - num_buffers = 4; // ring buffer size - isDataModified = NULL; - initialShutterMode = NULL; - dataCam = NULL; - reset = false; initialize(reset); @@ -220,7 +212,7 @@ vp1394TwoGrabber::~vp1394TwoGrabber() If multiples cameras are connected on the bus, select the camero to dial with. - \param camera_id : A camera identifier or GUID. By identifier, we + \param cam_id : A camera identifier or GUID. By identifier, we mean a value comprised between 0 (the first camera found on the bus) and the number of cameras found on the bus and returned by getNumCameras() minus 1. If two cameras are connected on the bus, @@ -332,24 +324,23 @@ int main() } \endcode - \sa setFormat(), setVideoMode(), setFramerate(), getNumCameras() */ void -vp1394TwoGrabber::setCamera(uint64_t camera_id) +vp1394TwoGrabber::setCamera(uint64_t cam_id) { // Suppose that if camera_id is a camera GUID, this value is greater // than the number of cameras connected to the bus - if (camera_id >= num_cameras) { + if (cam_id >= num_cameras) { // Check if camera_id is a camera guid bool is_guid = false; // check if the camera_id is a guid for (unsigned int i=0; i< num_cameras; i++) { if (cameras[i]->guid == camera_id) { - this->camera_id = i; - is_guid = true; - break; + this->camera_id = i; + is_guid = true; + break; } } if (is_guid == false) { @@ -362,7 +353,7 @@ vp1394TwoGrabber::setCamera(uint64_t camera_id) } } else { - this->camera_id = camera_id; + this->camera_id = cam_id; } // create a pointer to the working camera @@ -374,7 +365,7 @@ vp1394TwoGrabber::setCamera(uint64_t camera_id) Get the active camera identifier on the bus. - \param camera_id : The active camera identifier. The value is + \param cam_id : The active camera identifier. The value is comprised between 0 (the first camera) and the number of cameras found on the bus returned by getNumCameras() minus 1. @@ -385,10 +376,10 @@ vp1394TwoGrabber::setCamera(uint64_t camera_id) */ void -vp1394TwoGrabber::getCamera(uint64_t &camera_id) +vp1394TwoGrabber::getCamera(uint64_t &cam_id) { if (num_cameras) { - camera_id = this->camera_id; + cam_id = this->camera_id; } else { close(); @@ -434,7 +425,7 @@ vp1394TwoGrabber::getCamera() */ void -vp1394TwoGrabber::getNumCameras(unsigned int &ncameras) +vp1394TwoGrabber::getNumCameras(unsigned int &ncameras) const { if (! num_cameras) { vpCTRACE << "No camera found..."<< std::endl; @@ -452,7 +443,7 @@ vp1394TwoGrabber::getNumCameras(unsigned int &ncameras) */ unsigned int -vp1394TwoGrabber::getNumCameras() +vp1394TwoGrabber::getNumCameras() const { unsigned int ncameras = 0; if (! num_cameras) { @@ -1345,10 +1336,10 @@ vp1394TwoGrabber::isColorCodingSupported(vp1394TwoVideoModeType mode, \param top : Position of the upper left roi corner. - \param width : Roi width. If width is set to 0, uses the maximum + \param w : Roi width. If width is set to 0, uses the maximum allowed image width. - \param height : Roi height. If width is set to 0, uses the maximum + \param h : Roi height. If width is set to 0, uses the maximum allowed image height. @@ -1362,7 +1353,7 @@ vp1394TwoGrabber::isColorCodingSupported(vp1394TwoVideoModeType mode, */ void vp1394TwoGrabber::setFormat7ROI(unsigned int left, unsigned int top, - unsigned int width, unsigned int height) + unsigned int w, unsigned int h) { open(); if (! num_cameras) { @@ -1397,8 +1388,8 @@ vp1394TwoGrabber::setFormat7ROI(unsigned int left, unsigned int top, } #if 0 vpTRACE("left: %d top: %d width: %d height: %d", left, top, - width == 0 ? DC1394_USE_MAX_AVAIL: width, - height == 0 ? DC1394_USE_MAX_AVAIL : height); + width == 0 ? DC1394_USE_MAX_AVAIL: w, + height == 0 ? DC1394_USE_MAX_AVAIL : h); vpTRACE("max_width: %d max_height: %d", max_width, max_height); #endif @@ -1416,27 +1407,26 @@ vp1394TwoGrabber::setFormat7ROI(unsigned int left, unsigned int top, int32_t roi_width; int32_t roi_height; - if (width != 0) { + if (w != 0) { // Check if roi width is acceptable (ie roi is contained in the image) - if (width > (max_width - left)) - width = (max_width - left); - roi_width = (int32_t)width; + if (w > (max_width - left)) + w = (max_width - left); + roi_width = (int32_t)w; } else { roi_width = DC1394_USE_MAX_AVAIL; } - if (height != 0) { + if (h != 0) { // Check if roi height is acceptable (ie roi is contained in the image) - if (height > (max_height - top)) - height = (max_height - top); - roi_height = (int32_t)height; + if (h > (max_height - top)) + h = (max_height - top); + roi_height = (int32_t)h; } else { roi_height = DC1394_USE_MAX_AVAIL; } - if (dc1394_format7_set_roi(camera, _videomode, (dc1394color_coding_t) DC1394_QUERY_FROM_CAMERA, // color_coding DC1394_USE_MAX_AVAIL/*DC1394_QUERY_FROM_CAMERA*/, // bytes_per_packet @@ -1530,7 +1520,7 @@ vp1394TwoGrabber::initialize(bool reset) dc1394_reset_bus(cameras[0]); } - if (list != NULL) + // if (list != NULL) dc1394_camera_free_list (list); list = NULL; @@ -1771,7 +1761,7 @@ vp1394TwoGrabber::setRingBufferSize(unsigned int size) \sa setRingBufferSize() */ unsigned int -vp1394TwoGrabber::getRingBufferSize() +vp1394TwoGrabber::getRingBufferSize() const { return num_buffers; } @@ -1781,6 +1771,9 @@ vp1394TwoGrabber::getRingBufferSize() and max exposure time, but only for AVT cameras. In that case use setAutoShutter(unsigned int, unsigned int). + \param enable : Flag to enable or disable the auto shutter. If false, set the + shutter as manual. + \exception vpFrameGrabberException::initializationError : If no camera found on the bus. @@ -1813,7 +1806,7 @@ int main() \sa setAutoShutter(unsigned int, unsigned int), getAutoShutter() */ void -vp1394TwoGrabber::setAutoShutter() +vp1394TwoGrabber::setAutoShutter(bool enable) { if (! num_cameras) { close(); @@ -1822,6 +1815,14 @@ vp1394TwoGrabber::setAutoShutter() "No camera found") ); } + dc1394feature_mode_t mode; + if (enable) { + mode = DC1394_FEATURE_MODE_AUTO; + } + else { + mode = DC1394_FEATURE_MODE_MANUAL; + } + if (dc1394_feature_set_power(camera, DC1394_FEATURE_SHUTTER, DC1394_ON) != DC1394_SUCCESS) { // vpERROR_TRACE("Cannot set shutter on. \n"); @@ -1832,7 +1833,7 @@ vp1394TwoGrabber::setAutoShutter() if (dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, - DC1394_FEATURE_MODE_AUTO) + mode) != DC1394_SUCCESS) { // vpERROR_TRACE("Cannot set auto shutter. \n"); close(); @@ -1930,6 +1931,9 @@ vp1394TwoGrabber::getAutoShutter(unsigned int &minvalue, unsigned int &maxvalue) and max gain, but only for AVT cameras. In that case use setAutoGain(unsigned int, unsigned int). + \param enable : Flag to enable or disable the auto gain. If false, set the + gain as manual. + \exception vpFrameGrabberException::initializationError : If no camera found on the bus. @@ -1948,7 +1952,7 @@ int main() vp1394TwoGrabber g(false); // Don't reset the bus g.setVideoMode(vp1394TwoGrabber::vpVIDEO_MODE_FORMAT7_0 ); g.setColorCoding(vp1394TwoGrabber::vpCOLOR_CODING_MONO8); - g.setAutoGain(); // Enable auto gain + g.setAutoGain(true); // Enable auto gain g.setIsoTransmissionSpeed(vp1394TwoGrabber::vpISO_SPEED_800); // 1394b while(1) g.acquire(I); @@ -1962,7 +1966,7 @@ int main() \sa setAutoGain(unsigned int, unsigned int), getAutoGain() */ void -vp1394TwoGrabber::setAutoGain() +vp1394TwoGrabber::setAutoGain(bool enable) { if (! num_cameras) { close(); @@ -1971,7 +1975,15 @@ vp1394TwoGrabber::setAutoGain() "No camera found") ); } - if (dc1394_feature_set_power(camera, DC1394_FEATURE_SHUTTER, DC1394_ON) + dc1394feature_mode_t mode; + if (enable) { + mode = DC1394_FEATURE_MODE_AUTO; + } + else { + mode = DC1394_FEATURE_MODE_MANUAL; + } + + if (dc1394_feature_set_power(camera, DC1394_FEATURE_GAIN, DC1394_ON) != DC1394_SUCCESS) { // vpERROR_TRACE("Cannot set shutter on. \n"); close(); @@ -1981,7 +1993,7 @@ vp1394TwoGrabber::setAutoGain() if (dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, - DC1394_FEATURE_MODE_AUTO) + mode) != DC1394_SUCCESS) { // vpERROR_TRACE("Cannot set auto gain. \n"); close(); @@ -2924,7 +2936,7 @@ vp1394TwoGrabber::acquire(vpImage<vpRGBa> &I, Get the image width. It depends on the camera video mode setVideoMode(). The image size is only available after a call to open() or acquire(). - \param width : The image width, zero if the required camera is not available. + \param w : The image width, zero if the required camera is not available. \exception vpFrameGrabberException::initializationError : If no camera found on the bus. @@ -2935,7 +2947,7 @@ vp1394TwoGrabber::acquire(vpImage<vpRGBa> &I, \sa getHeight(), open(), acquire() */ -void vp1394TwoGrabber::getWidth(unsigned int &width) +void vp1394TwoGrabber::getWidth(unsigned int &w) { if (! num_cameras) { close(); @@ -2944,7 +2956,7 @@ void vp1394TwoGrabber::getWidth(unsigned int &width) "No camera found") ); } - width = this->width; + w = this->width; } /*! @@ -2981,7 +2993,7 @@ unsigned int vp1394TwoGrabber::getWidth() setVideoMode(). The image size is only available after a call to open() or acquire(). - \param height : The image height. + \param h : The image height. \exception vpFrameGrabberException::initializationError : If no camera found on the bus. @@ -2992,7 +3004,7 @@ unsigned int vp1394TwoGrabber::getWidth() \sa getWidth() */ -void vp1394TwoGrabber::getHeight(unsigned int &height) +void vp1394TwoGrabber::getHeight(unsigned int &h) { if (! num_cameras) { close(); @@ -3001,7 +3013,7 @@ void vp1394TwoGrabber::getHeight(unsigned int &height) "No camera found") ); } - height = this->height; + h = this->height; } /*! @@ -3096,8 +3108,8 @@ std::string vp1394TwoGrabber::videoMode2string(vp1394TwoVideoModeType videomode) _str = strVideoMode[_videomode - DC1394_VIDEO_MODE_MIN]; } else { - vpCERROR << "The video mode " << videomode - << " is not supported by the camera" << std::endl; + vpCERROR << "The video mode " << (int)videomode + << " is not supported by the camera" << std::endl; } return _str; @@ -3125,8 +3137,8 @@ std::string vp1394TwoGrabber::framerate2string(vp1394TwoFramerateType fps) _str = strFramerate[_fps - DC1394_FRAMERATE_MIN]; } else { - vpCERROR << "The framerate " << fps - << " is not supported by the camera" << std::endl; + vpCERROR << "The framerate " << (int)fps + << " is not supported by the camera" << std::endl; } return _str; @@ -3155,8 +3167,8 @@ std::string vp1394TwoGrabber::colorCoding2string(vp1394TwoColorCodingType colorc } else { - vpCERROR << "The color coding " << colorcoding - << " is not supported by the camera" << std::endl; + vpCERROR << "The color coding " << (int)colorcoding + << " is not supported by the camera" << std::endl; } return _str; @@ -3319,7 +3331,7 @@ void vp1394TwoGrabber::resetBus() dc1394_camera_free (camera); dc1394_free (d); d = NULL; - if (cameras != NULL) + //if (cameras != NULL) delete [] cameras; cameras = NULL ; #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7 @@ -3764,7 +3776,7 @@ vp1394TwoGrabber::getFramerateSupported(vp1394TwoVideoModeType mode, */ uint32_t vp1394TwoGrabber::getColorCodingSupported(vp1394TwoVideoModeType mode, - vpList<vp1394TwoColorCodingType> & codings) + vpList<vp1394TwoColorCodingType> & codings) { if (! num_cameras) { close(); diff --git a/src/device/framegrabber/1394/vp1394TwoGrabber.h b/src/device/framegrabber/1394/vp1394TwoGrabber.h index 123a1e724cdee39c87299f588a2f9f24f7f6c129..4422023f0ed21837e20be61c3e3f7a74cf3412f7 100644 --- a/src/device/framegrabber/1394/vp1394TwoGrabber.h +++ b/src/device/framegrabber/1394/vp1394TwoGrabber.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vp1394TwoGrabber.h 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: vp1394TwoGrabber.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -382,10 +382,10 @@ class VISP_EXPORT vp1394TwoGrabber : public vpFrameGrabber void getGuid(uint64_t &guid); void getHeight(unsigned int &height); unsigned int getHeight(); - void getNumCameras(unsigned int &ncameras); - unsigned int getNumCameras(); + void getNumCameras(unsigned int &ncameras) const; + unsigned int getNumCameras() const; unsigned int getParameterValue(vp1394TwoParametersType param); - unsigned int getRingBufferSize(); + unsigned int getRingBufferSize() const; void getVideoMode(vp1394TwoVideoModeType & videomode); uint32_t getVideoModeSupported(std::list<vp1394TwoVideoModeType> & videomodes); void getWidth(unsigned int &width); @@ -406,9 +406,9 @@ class VISP_EXPORT vp1394TwoGrabber : public vpFrameGrabber void resetBus(); - void setAutoGain(); + void setAutoGain(bool enable = true); void setAutoGain(unsigned int minvalue, unsigned int maxvalue); - void setAutoShutter(); + void setAutoShutter(bool enable = true); void setAutoShutter(unsigned int minvalue, unsigned int maxvalue); void setCamera(uint64_t camera); void setColorCoding(vp1394TwoColorCodingType coding); diff --git a/src/device/framegrabber/OpenCV/vpOpenCVGrabber.cpp b/src/device/framegrabber/OpenCV/vpOpenCVGrabber.cpp index f4e0c0ca21d07598fd9b8414b5ab7ebd025d18dd..47981f98f5e7c5626634338f17f23007e4674997 100644 --- a/src/device/framegrabber/OpenCV/vpOpenCVGrabber.cpp +++ b/src/device/framegrabber/OpenCV/vpOpenCVGrabber.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpOpenCVGrabber.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpOpenCVGrabber.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -58,17 +58,13 @@ Basic Constructor. */ vpOpenCVGrabber::vpOpenCVGrabber() + : capture(NULL), DeviceType(0), flip(false) { // public memebers init = false; // protected members width = height = 0; - - // private members - capture = NULL; - DeviceType = 0; - flip = false; } @@ -245,14 +241,14 @@ void vpOpenCVGrabber::setFramerate(const double framerate) \warning This function must be called after open() method. - \param width : The requested value of the captured image width. + \param w : The requested value of the captured image width. \exception vpFrameGrabberException::initializationError If no camera was found. */ -void vpOpenCVGrabber::setWidth(const unsigned int width) +void vpOpenCVGrabber::setWidth(const unsigned int w) { - if ( cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, width)) + if ( cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, w)) { close(); vpERROR_TRACE("Impossible to set the size of the grabber"); @@ -260,7 +256,7 @@ void vpOpenCVGrabber::setWidth(const unsigned int width) "Impossible to set the size of the grabber") ); } - this->width = width; + this->width = w; } /*! @@ -268,14 +264,14 @@ void vpOpenCVGrabber::setWidth(const unsigned int width) \warning This function must be called after open() method. - \param height : The requested value of the captured image height. + \param h : The requested value of the captured image height. \exception vpFrameGrabberException::initializationError If no camera was found. */ -void vpOpenCVGrabber::setHeight(const unsigned int height) +void vpOpenCVGrabber::setHeight(const unsigned int h) { - if ( cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, height)) + if ( cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, h)) { close(); vpERROR_TRACE("Impossible to set the size of the grabber"); @@ -283,7 +279,7 @@ void vpOpenCVGrabber::setHeight(const unsigned int height) "Impossible to set the size of the grabber") ); } - this->height = height; + this->height = h; } /*! diff --git a/src/device/framegrabber/OpenCV/vpOpenCVGrabber.h b/src/device/framegrabber/OpenCV/vpOpenCVGrabber.h index 61b10335c59f80ed71d6e6b40974588f76dc2fdb..d9f11e2bb7e47273be0318199d049c248d6df873 100644 --- a/src/device/framegrabber/OpenCV/vpOpenCVGrabber.h +++ b/src/device/framegrabber/OpenCV/vpOpenCVGrabber.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpOpenCVGrabber.h 4216 2013-04-17 09:06:18Z fspindle $ + * $Id: vpOpenCVGrabber.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/device/framegrabber/directshow/vpDirectShowDevice.cpp b/src/device/framegrabber/directshow/vpDirectShowDevice.cpp index 94536e6986ea92ecf8434fff67654fce0b44e47d..21de5903cde648bff141176b4004c59f767e0a27 100644 --- a/src/device/framegrabber/directshow/vpDirectShowDevice.cpp +++ b/src/device/framegrabber/directshow/vpDirectShowDevice.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDirectShowDevice.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpDirectShowDevice.cpp 4620 2014-01-27 21:28:32Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -120,5 +120,10 @@ bool vpDirectShowDevice::operator==(vpDirectShowDevice& dev) && devPath==dev.devPath; } +VISP_EXPORT std::ostream& operator<<(std::ostream& os, vpDirectShowDevice& dev) +{ + return os<<dev.name<<std::endl<<dev.desc<<std::endl<<dev.devPath; +} + #endif #endif diff --git a/src/device/framegrabber/directshow/vpDirectShowDevice.h b/src/device/framegrabber/directshow/vpDirectShowDevice.h index d3bc59cc66cc5b35906ad8722637644c0cfb3017..6f35fe237253e532f0191130c3ed10fabad53e02 100644 --- a/src/device/framegrabber/directshow/vpDirectShowDevice.h +++ b/src/device/framegrabber/directshow/vpDirectShowDevice.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDirectShowDevice.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpDirectShowDevice.h 4620 2014-01-27 21:28:32Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -79,10 +79,7 @@ public: bool operator==(vpDirectShowDevice& dev); - friend VISP_EXPORT std::ostream& operator<<(std::ostream& os, vpDirectShowDevice& dev) - { - return os<<dev.name<<std::endl<<dev.desc<<std::endl<<dev.devPath; - } + friend VISP_EXPORT std::ostream& operator<<(std::ostream& os, vpDirectShowDevice& dev); }; #endif #endif diff --git a/src/device/framegrabber/directshow/vpDirectShowGrabber.cpp b/src/device/framegrabber/directshow/vpDirectShowGrabber.cpp index f49bb4f2d128782a1a873b9009914d0091ad5bee..22355688b6c790f3b03f04d9d95e27468c2aa7d8 100644 --- a/src/device/framegrabber/directshow/vpDirectShowGrabber.cpp +++ b/src/device/framegrabber/directshow/vpDirectShowGrabber.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDirectShowGrabber.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpDirectShowGrabber.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/device/framegrabber/directshow/vpDirectShowGrabber.h b/src/device/framegrabber/directshow/vpDirectShowGrabber.h index ddc20276818330e537fe061c83195dfec59bb6f8..d360e26bde1913692d35b5314c074f7ed69a0d2f 100644 --- a/src/device/framegrabber/directshow/vpDirectShowGrabber.h +++ b/src/device/framegrabber/directshow/vpDirectShowGrabber.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDirectShowGrabber.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpDirectShowGrabber.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/device/framegrabber/directshow/vpDirectShowGrabberImpl.cpp b/src/device/framegrabber/directshow/vpDirectShowGrabberImpl.cpp index 807888968a11ea20b039f0b8d6c931c8e98403a1..c2c489336217588b511f9bd7465781a69496884b 100755 --- a/src/device/framegrabber/directshow/vpDirectShowGrabberImpl.cpp +++ b/src/device/framegrabber/directshow/vpDirectShowGrabberImpl.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDirectShowGrabberImpl.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpDirectShowGrabberImpl.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/device/framegrabber/directshow/vpDirectShowGrabberImpl.h b/src/device/framegrabber/directshow/vpDirectShowGrabberImpl.h index 7133ec925a9bab483c8b846c3666f9faf45c4cc7..6f07bde788f09f9107b66f211e9188bc1680856d 100755 --- a/src/device/framegrabber/directshow/vpDirectShowGrabberImpl.h +++ b/src/device/framegrabber/directshow/vpDirectShowGrabberImpl.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDirectShowGrabberImpl.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpDirectShowGrabberImpl.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/device/framegrabber/directshow/vpDirectShowSampleGrabberI.h b/src/device/framegrabber/directshow/vpDirectShowSampleGrabberI.h index da66cf353f9399c350d4f787310cb85f672bcf39..f233f3c1144abe119d4e4bda422fd369725c104e 100644 --- a/src/device/framegrabber/directshow/vpDirectShowSampleGrabberI.h +++ b/src/device/framegrabber/directshow/vpDirectShowSampleGrabberI.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDirectShowSampleGrabberI.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpDirectShowSampleGrabberI.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/device/framegrabber/disk/vpDiskGrabber.cpp b/src/device/framegrabber/disk/vpDiskGrabber.cpp index e31e6e4d192c546e7bc3601b9c650df4efb2528d..d1c78cd73e45da48baf5b3bed851e0ef0333a93f 100644 --- a/src/device/framegrabber/disk/vpDiskGrabber.cpp +++ b/src/device/framegrabber/disk/vpDiskGrabber.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDiskGrabber.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpDiskGrabber.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -47,22 +47,30 @@ Elementary constructor. */ vpDiskGrabber::vpDiskGrabber() + : image_number(0), image_step(1), number_of_zero(0), useGenericName(false) { setDirectory("/tmp"); setBaseName("I"); - setImageNumber(0); - setStep(1); - setNumberOfZero(0); setExtension("pgm"); init = false; - useGenericName = false; } -vpDiskGrabber::vpDiskGrabber(const char *genericName) +vpDiskGrabber::vpDiskGrabber(const char *generic_name) + : image_number(0), image_step(1), number_of_zero(0), useGenericName(false) { - strcpy(this->genericName, genericName); + setDirectory("/tmp"); + setBaseName("I"); + setExtension("pgm"); + + init = false; + if (strlen( generic_name ) >= FILENAME_MAX) { + throw(vpException(vpException::memoryAllocationError, + "Not enough memory to intialize the generic name")); + } + + strcpy(this->genericName, generic_name); useGenericName = true; } @@ -82,16 +90,13 @@ vpDiskGrabber::vpDiskGrabber(const char *dir, const char *basename, long number, int step, unsigned int noz, const char *ext) + : image_number(number), image_step(step), number_of_zero(noz), useGenericName(false) { setDirectory(dir); setBaseName(basename); - setImageNumber(number); - setStep(step); - setNumberOfZero(noz); setExtension(ext); init = false; - useGenericName = false; } void @@ -244,19 +249,19 @@ vpDiskGrabber::acquire(vpImage<float> &I) Acquire an image: read a pgm image from the disk. After this call, the image number is incremented considering the step. - \param I the read image - \param image_number The index of the desired image. + \param I : The image read from a file. + \param img_number : The number of the desired image. */ void -vpDiskGrabber::acquire(vpImage<unsigned char> &I, long image_number) +vpDiskGrabber::acquire(vpImage<unsigned char> &I, long img_number) { char name[FILENAME_MAX] ; if(useGenericName) - sprintf(name,genericName,image_number) ; + sprintf(name,genericName,img_number) ; else - sprintf(name,"%s/%s%0*ld.%s",directory,base_name,number_of_zero,image_number,extension) ; + sprintf(name,"%s/%s%0*ld.%s",directory,base_name,number_of_zero,img_number,extension) ; vpDEBUG_TRACE(2, "load: %s\n", name); @@ -270,19 +275,19 @@ vpDiskGrabber::acquire(vpImage<unsigned char> &I, long image_number) Acquire an image: read a ppm image from the disk. After this call, the image number is incremented considering the step. - \param I the read image - \param image_number The index of the desired image. + \param I : The image read from a file. + \param img_number : The number of the desired image. */ void -vpDiskGrabber::acquire(vpImage<vpRGBa> &I, long image_number) +vpDiskGrabber::acquire(vpImage<vpRGBa> &I, long img_number) { char name[FILENAME_MAX] ; if(useGenericName) - sprintf(name,genericName,image_number) ; + sprintf(name,genericName,img_number) ; else - sprintf(name,"%s/%s%0*ld.%s",directory,base_name,number_of_zero,image_number,extension) ; + sprintf(name,"%s/%s%0*ld.%s",directory,base_name,number_of_zero,img_number,extension) ; vpDEBUG_TRACE(2, "load: %s\n", name); @@ -298,19 +303,19 @@ vpDiskGrabber::acquire(vpImage<vpRGBa> &I, long image_number) Acquire an image: read a pfm image from the disk. After this call, the image number is incremented considering the step. - \param I the read image - \param image_number The index of the desired image. + \param I : The image read from a file. + \param img_number : The number of the desired image. */ void -vpDiskGrabber::acquire(vpImage<float> &I, long image_number) +vpDiskGrabber::acquire(vpImage<float> &I, long img_number) { char name[FILENAME_MAX] ; if(useGenericName) - sprintf(name,genericName,image_number) ; + sprintf(name,genericName,img_number) ; else - sprintf(name,"%s/%s%0*ld.%s",directory,base_name,number_of_zero,image_number,extension) ; + sprintf(name,"%s/%s%0*ld.%s",directory,base_name,number_of_zero,img_number,extension) ; vpDEBUG_TRACE(2, "load: %s\n", name); @@ -399,8 +404,13 @@ vpDiskGrabber::setNumberOfZero(unsigned int noz) } void -vpDiskGrabber::setGenericName(const char *genericName) +vpDiskGrabber::setGenericName(const char *generic_name) { - strcpy(this->genericName, genericName) ; + if (strlen( generic_name ) >= FILENAME_MAX) { + throw(vpException(vpException::memoryAllocationError, + "Not enough memory to intialize the generic name")); + } + + strcpy(this->genericName, generic_name) ; useGenericName = true; } diff --git a/src/device/framegrabber/disk/vpDiskGrabber.h b/src/device/framegrabber/disk/vpDiskGrabber.h index eb3b8cfbafc4e344e425accb97278fc1a46f0e78..a85b70ca186eb5a51f894cf20ef80ea7eccc29a4 100644 --- a/src/device/framegrabber/disk/vpDiskGrabber.h +++ b/src/device/framegrabber/disk/vpDiskGrabber.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDiskGrabber.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpDiskGrabber.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/device/framegrabber/generic-framegrabber/vpFrameGrabber.h b/src/device/framegrabber/generic-framegrabber/vpFrameGrabber.h index b9bfb74c1e5e6e76384f81270412b809f2eaad23..975adbd234566f5b2de27aee5e4b7b54e647be0b 100644 --- a/src/device/framegrabber/generic-framegrabber/vpFrameGrabber.h +++ b/src/device/framegrabber/generic-framegrabber/vpFrameGrabber.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFrameGrabber.h 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: vpFrameGrabber.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -121,6 +121,7 @@ public: inline unsigned int getWidth() const { return width ; } public: + vpFrameGrabber() : init(false), height(0), width(0) {}; virtual ~vpFrameGrabber() { ; } virtual void open(vpImage<unsigned char> &I) =0 ; diff --git a/src/device/framegrabber/generic-framegrabber/vpFrameGrabberException.h b/src/device/framegrabber/generic-framegrabber/vpFrameGrabberException.h index 772263d2c511887436c887db1b5e6bc7a400a293..1439f7ab2d8eefa2cf1de811219e86936dc1dc8d 100644 --- a/src/device/framegrabber/generic-framegrabber/vpFrameGrabberException.h +++ b/src/device/framegrabber/generic-framegrabber/vpFrameGrabberException.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFrameGrabberException.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFrameGrabberException.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -71,37 +71,32 @@ */ class VISP_EXPORT vpFrameGrabberException : public vpException { -public: - /*! + public: + /*! \brief Lists the possible error than can be emmited while calling vpFrameGrabber member */ - enum errorFrameGrabberCodeEnum + enum errorFrameGrabberCodeEnum { settingError, initializationError, otherError } ; -public: - vpFrameGrabberException (const int code, const char * msg) - : vpException(code, msg){ ; } - vpFrameGrabberException (const int code, const std::string & msg) - : vpException(code, msg){ ; } - vpFrameGrabberException (const int code) - : vpException(code){ ; } + public: + vpFrameGrabberException (const int id, const char* format, ...) + { + this->code = id; + va_list args; + va_start(args, format); + setMessage(format, args); + va_end (args); + } + vpFrameGrabberException (const int id, const std::string & msg) + : vpException(id, msg){ ; } + vpFrameGrabberException (const int id) + : vpException(id){ ; } }; - - - - #endif /* #ifndef __vpFrameGrabberException_H */ - - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ diff --git a/src/device/framegrabber/v4l2/vpV4l2Grabber.cpp b/src/device/framegrabber/v4l2/vpV4l2Grabber.cpp index 365f7c2418074371faf23a3acdc3e2cfd15fa2e0..ec0ce3d7fac70fdcdaf4485c31a84ae9e8079dc3 100644 --- a/src/device/framegrabber/v4l2/vpV4l2Grabber.cpp +++ b/src/device/framegrabber/v4l2/vpV4l2Grabber.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpV4l2Grabber.cpp 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpV4l2Grabber.cpp 4656 2014-02-07 17:21:28Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -919,11 +919,22 @@ vpV4l2Grabber::open() if (cap.capabilities & V4L2_CAP_STREAMING) fprintf(stdout, " Support streaming capture.\n"); else - fprintf(stdout, " Does not support streaming capture.\n"); + fprintf(stdout, " Does not support streaming capture\n"); if(cap.capabilities & V4L2_CAP_ASYNCIO) - fprintf(stdout, " Support asynchronous I/O methods.\n"); + fprintf(stdout, " Support asynchronous I/O methods\n"); else - fprintf(stdout, " Does not support asynchronous I/O methods.\n"); + fprintf(stdout, " Does not support asynchronous I/O methods\n"); + if(cap.capabilities & V4L2_CAP_TIMEPERFRAME) + fprintf(stdout, " Support time per frame field\n"); + else + fprintf(stdout, " Does not support time per frame field\n"); + // Get framerate + struct v4l2_streamparm streamparm; + streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + if (v4l2_ioctl(fd, VIDIOC_G_PARM, &streamparm) != -1) { + fprintf(stdout, " Current acquisition framerate: %d fps\n", + streamparm.parm.output.timeperframe.denominator); + } } getCapabilities(); diff --git a/src/device/framegrabber/v4l2/vpV4l2Grabber.h b/src/device/framegrabber/v4l2/vpV4l2Grabber.h index da741f4d570e7228feb6efb0177a668819c66483..3c672b86556deb879852a2493b83a7d137de7bfe 100644 --- a/src/device/framegrabber/v4l2/vpV4l2Grabber.h +++ b/src/device/framegrabber/v4l2/vpV4l2Grabber.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpV4l2Grabber.h 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: vpV4l2Grabber.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/device/kinect/vpKinect.cpp b/src/device/kinect/vpKinect.cpp index cfab762a013468ae6f9027d86bca29d5b16f430c..9fe7abe1778f4af113ad5a6b6b00a9c5737f2ca6 100644 --- a/src/device/kinect/vpKinect.cpp +++ b/src/device/kinect/vpKinect.cpp @@ -1,10 +1,10 @@ /**************************************************************************** * - * $Id: vpKinect.cpp 4329 2013-07-20 07:06:49Z fspindle $ + * $Id: vpKinect.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/device/kinect/vpKinect.h b/src/device/kinect/vpKinect.h index 5eaab28c569a87d92326204f2c35492987fc1e7c..d4b2d99b8968d20f0959d17eb9ca588642834d8f 100644 --- a/src/device/kinect/vpKinect.h +++ b/src/device/kinect/vpKinect.h @@ -1,10 +1,10 @@ /**************************************************************************** * - * $Id: vpKinect.h 4131 2013-02-11 20:45:31Z fspindle $ + * $Id: vpKinect.h 4574 2014-01-09 08:48:51Z fspindle $ * * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/device/laserscanner/sick/vpSickLDMRS.cpp b/src/device/laserscanner/sick/vpSickLDMRS.cpp index 86de3d627359f0a67add8fb37aa61befd2d4107d..78fdf6b098baea67b6f16de989df667301d45445 100644 --- a/src/device/laserscanner/sick/vpSickLDMRS.cpp +++ b/src/device/laserscanner/sick/vpSickLDMRS.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpSickLDMRS.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpSickLDMRS.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -39,22 +39,24 @@ * *****************************************************************************/ -#if ( defined(UNIX) && !defined(WIN32) ) +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) #include <visp/vpSickLDMRS.h> #include <visp/vpMath.h> #include <visp/vpDebug.h> #include <visp/vpTime.h> #include <sys/socket.h> +#include <sys/select.h> #include <netinet/in.h> #include <fcntl.h> #include <errno.h> #include <netdb.h> #include <string.h> -#include <strings.h> +//#include <strings.h> #include <math.h> #include <assert.h> #include <stdlib.h> +#include <limits.h> @@ -72,19 +74,18 @@ body messages. */ vpSickLDMRS::vpSickLDMRS() + : socket_fd(-1), body(NULL), vAngle(), time_offset(0), + isFirstMeasure(true), maxlen_body(104000) { ip = "131.254.12.119"; port = 12002; - body = new unsigned char [104000]; - isFirstMeasure = true; - time_offset = 0; + body = new unsigned char [maxlen_body]; vAngle.resize(4); // Vertical angle of the 4 layers vAngle[0] = vpMath::rad(-1.2); vAngle[1] = vpMath::rad(-0.4); vAngle[2] = vpMath::rad( 0.4); vAngle[3] = vpMath::rad( 1.2); - } /*! @@ -99,16 +100,16 @@ vpSickLDMRS::~vpSickLDMRS() /*! Initialize the connexion with the Sick LD-MRS laser scanner. - \param ip : Ethernet address of the laser. - \param port : Ethernet port of the laser. + \param ip_address : Ethernet address of the laser. + \param com_port : Ethernet port of the laser. \return true if the device was initialized, false otherwise. */ -bool vpSickLDMRS::setup(std::string ip, int port) +bool vpSickLDMRS::setup(std::string ip_address, int com_port) { - setIpAddress( ip ); - setPort( port ); + setIpAddress( ip_address ); + setPort( com_port ); return ( this->setup() ); } @@ -130,7 +131,8 @@ bool vpSickLDMRS::setup() fprintf(stderr, "Failed to create socket\n"); return false; } - bzero(&serv_addr, sizeof(serv_addr)); + //bzero(&serv_addr, sizeof(serv_addr)); + memset(&serv_addr, 0, sizeof(serv_addr)); serv_addr.sin_family = AF_INET; // Internet/IP serv_addr.sin_addr.s_addr = inet_addr(ip.c_str()); // IP address serv_addr.sin_port = htons(port); // server port @@ -266,6 +268,9 @@ bool vpSickLDMRS::measure(vpLaserScan laserscan[4]) double rDist; // radial distance in meters vpScanPoint scanPoint; + if (numPoints > USHRT_MAX-2) + throw(vpException (vpException::ioError, "Out of range number of point")); + for (int i=0; i < numPoints; i++) { ushortptr = (unsigned short *) (body+44+i*10); unsigned char layer = ((unsigned char) body[44+i*10])&0x0F; diff --git a/src/device/laserscanner/sick/vpSickLDMRS.h b/src/device/laserscanner/sick/vpSickLDMRS.h index b6fd478153308f42df68ed6852ff3571775fccad..062517c5536ec4fddd8403ba6dd7a5b26978de39 100644 --- a/src/device/laserscanner/sick/vpSickLDMRS.h +++ b/src/device/laserscanner/sick/vpSickLDMRS.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpSickLDMRS.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpSickLDMRS.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -43,17 +43,18 @@ #include <visp/vpConfig.h> -#if ( defined(UNIX) && !defined(WIN32) ) +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) #include <arpa/inet.h> #include <iostream> #include <vector> - +#include <string.h> #include <visp/vpScanPoint.h> #include <visp/vpLaserScan.h> #include <visp/vpLaserScanner.h> #include <visp/vpColVector.h> +#include <visp/vpException.h> /*! @@ -80,7 +81,7 @@ int main() { -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX std::string ip = "131.254.12.119"; vpSickLDMRS laser; @@ -98,7 +99,7 @@ int main() vpScanPoint p; for (unsigned int i=0; i < pointsInLayer.size(); i++) { - std::cout << pointsInLayer[i] << std::endl; + std::cout << pointsInLayer[i] << std::endl; } } } @@ -117,26 +118,42 @@ class VISP_EXPORT vpSickLDMRS : public vpLaserScanner }; vpSickLDMRS(); /*! Copy constructor. */ - vpSickLDMRS(const vpSickLDMRS &sick) : vpLaserScanner(sick) { + vpSickLDMRS(const vpSickLDMRS &sick) + : vpLaserScanner(sick), socket_fd(-1), body(NULL), vAngle(), time_offset(0), + isFirstMeasure(true), maxlen_body(104000) + { + *this = sick; + }; + virtual ~vpSickLDMRS(); + /*! Copy constructor. */ + vpSickLDMRS &operator=(const vpSickLDMRS &sick) + { socket_fd = sick.socket_fd; + vAngle = sick.vAngle; + time_offset = sick.time_offset; + isFirstMeasure = sick.isFirstMeasure; + maxlen_body = sick.maxlen_body; + if (body) delete [] body; body = new unsigned char [104000]; + memcpy(body, sick.body, maxlen_body); + return (*this); }; - virtual ~vpSickLDMRS(); + bool setup(std::string ip, int port); bool setup(); bool measure(vpLaserScan laserscan[4]); protected: -#ifdef WIN32 +#if defined(_WIN32) SOCKET socket_fd; #else int socket_fd; #endif - private: unsigned char *body; vpColVector vAngle; // constant vertical angle for each layer double time_offset; bool isFirstMeasure; + size_t maxlen_body; }; #endif diff --git a/src/device/laserscanner/vpLaserScan.h b/src/device/laserscanner/vpLaserScan.h index 6ca3763fa613a085d826a07d5dd516b42eaf0993..b2e57ae59ad5a367fcf385f793eb76364095c609 100644 --- a/src/device/laserscanner/vpLaserScan.h +++ b/src/device/laserscanner/vpLaserScan.h @@ -1,10 +1,10 @@ /**************************************************************************** * - * $Id: vpLaserScan.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpLaserScan.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. - * + * Copyright (C) 2005 - 2014 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. @@ -12,11 +12,11 @@ * 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 + * 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 @@ -26,7 +26,7 @@ * * 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. * @@ -67,17 +67,16 @@ class VISP_EXPORT vpLaserScan { public: /*! Default constructor that initialize all the internal variable to zero. */ - vpLaserScan() { - startTimestamp = 0; - endTimestamp = 0; - measurementId = 0; - numSteps = 0; - startAngle = 0; - stopAngle = 0; - numPoints = 0; + vpLaserScan() + : listScanPoints(), startTimestamp(0), endTimestamp(0), measurementId(0), + numSteps(0), startAngle(0), stopAngle(0), numPoints(0) + { } /*! Copy constructor. */ - vpLaserScan(const vpLaserScan &scan) { + vpLaserScan(const vpLaserScan &scan) + : listScanPoints(), startTimestamp(0), endTimestamp(0), measurementId(0), + numSteps(0), startAngle(0), stopAngle(0), numPoints(0) + { startTimestamp = scan.startTimestamp; endTimestamp = scan.endTimestamp; measurementId = scan.measurementId; @@ -103,32 +102,32 @@ class VISP_EXPORT vpLaserScan } /*! Specifies the id of former measurements and increases with every measurement. */ - inline void setMeasurementId(const unsigned short &measurementId) { - this->measurementId = measurementId; + inline void setMeasurementId(const unsigned short &id) { + this->measurementId = id; } /*! Start time of measurement. */ - inline void setStartTimestamp(const double &startTimestamp) { - this->startTimestamp = startTimestamp; + inline void setStartTimestamp(const double &start_timestamp) { + this->startTimestamp = start_timestamp; } /*! End time of measurement. */ - inline void setEndTimestamp(const double &endTimestamp) { - this->endTimestamp = endTimestamp; + inline void setEndTimestamp(const double &end_timestamp) { + this->endTimestamp = end_timestamp; } /*! Angular steps per scanner rotation. */ - inline void setNumSteps(const unsigned short &numSteps) { - this->numSteps = numSteps; + inline void setNumSteps(const unsigned short &num_steps) { + this->numSteps = num_steps; } /*! Start angle of the measurement in angular steps. */ - inline void setStartAngle(const short &startAngle) { - this->startAngle = startAngle; + inline void setStartAngle(const short &start_angle) { + this->startAngle = start_angle; } /*! Stop angle of the measurement in angular steps. */ - inline void setStopAngle(const short &stopAngle) { - this->stopAngle = stopAngle; + inline void setStopAngle(const short &stop_angle) { + this->stopAngle = stop_angle; } /*! Number of measured points of the measurement. */ - inline void setNumPoints(const unsigned short &numPoints) { - this->numPoints = numPoints; + inline void setNumPoints(const unsigned short &num_points) { + this->numPoints = num_points; } /*! Return the measurement start time. */ inline double getStartTimestamp() { diff --git a/src/device/laserscanner/vpLaserScanner.h b/src/device/laserscanner/vpLaserScanner.h index 5c986f4e525a36c58851a4b4e1460f50d11e01f9..bc30f0d71a49ea30085c50b5534559b757e6f195 100644 --- a/src/device/laserscanner/vpLaserScanner.h +++ b/src/device/laserscanner/vpLaserScanner.h @@ -1,10 +1,10 @@ /**************************************************************************** * - * $Id: vpLaserScanner.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpLaserScanner.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. - * + * Copyright (C) 2005 - 2014 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. @@ -12,11 +12,11 @@ * 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 + * 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 @@ -26,7 +26,7 @@ * * 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. * @@ -61,12 +61,11 @@ class VISP_EXPORT vpLaserScanner { public: /*! Default constructor that initialize all the internal variable to zero. */ - vpLaserScanner() { - ip = "null"; - port = 0; - }; + vpLaserScanner() : ip("null"), port(0) {}; /*! Copy constructor. */ - vpLaserScanner(const vpLaserScanner &scanner) { + vpLaserScanner(const vpLaserScanner &scanner) + : ip("null"), port(0) + { ip = scanner.ip; port = scanner.port; }; @@ -74,15 +73,15 @@ class VISP_EXPORT vpLaserScanner virtual ~vpLaserScanner() {}; /*! Set the Ethernet address of the laser. */ - void setIpAddress(std::string ip) { - this->ip = ip; + void setIpAddress(std::string ip_address) { + this->ip = ip_address; }; - + /*! Set the communication port. */ - void setPort(int port) { - this->port = port; + void setPort(int com_port) { + this->port = com_port; }; - + protected: std::string ip; int port; diff --git a/src/device/laserscanner/vpScanPoint.h b/src/device/laserscanner/vpScanPoint.h index 74e135b74d0ff796e60e20267d544958eedc83d1..cd8533e3437a3176c68fdbc77a2f608e1aa2450f 100644 --- a/src/device/laserscanner/vpScanPoint.h +++ b/src/device/laserscanner/vpScanPoint.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpScanPoint.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpScanPoint.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -44,6 +44,7 @@ #include <visp/vpMath.h> #include <ostream> +#include <sstream> #include <cmath> // std::fabs #include <limits> // numeric_limits #include <math.h> @@ -75,40 +76,38 @@ class /* VISP_EXPORT */ vpScanPoint // Note that here VISP_EXPORT should not be { public: /*! Default constructor. */ - inline vpScanPoint() { - this->rDist = 0; - this->hAngle = 0; - this->vAngle = 0; - } + inline vpScanPoint() : rDist(0), hAngle(0), vAngle(0) {} /*! Copy constructor. */ - inline vpScanPoint(const vpScanPoint &scanpoint) { + inline vpScanPoint(const vpScanPoint &scanpoint) : rDist(0), hAngle(0), vAngle(0) { this->rDist = scanpoint.rDist; this->hAngle = scanpoint.hAngle; this->vAngle = scanpoint.vAngle; } /*! Set the polar point coordinates. - \param rDist : Radial distance in meter. - \param hAngle : Horizontal angle in radian. - \param vAngle : Vertical angle in radian. + \param r_dist : Radial distance in meter. + \param h_angle : Horizontal angle in radian. + \param v_angle : Vertical angle in radian. */ - inline vpScanPoint(double rDist, double hAngle, double vAngle) { - this->rDist = rDist; - this->hAngle = hAngle; - this->vAngle = vAngle; + inline vpScanPoint(double r_dist, double h_angle, double v_angle) + : rDist(r_dist), hAngle(h_angle), vAngle(v_angle) + { + this->rDist = r_dist; + this->hAngle = h_angle; + this->vAngle = v_angle; } /*! Destructor that does nothing. */ inline virtual ~vpScanPoint() {}; /*! Set the polar point coordinates. - \param rDist : Radial distance in meter. - \param hAngle : Horizontal angle in radian. - \param vAngle : Vertical angle in radian. + \param r_dist : Radial distance in meter. + \param h_angle : Horizontal angle in radian. + \param v_angle : Vertical angle in radian. */ - inline void setPolar(double rDist, double hAngle, double vAngle) { - this->rDist = rDist; - this->hAngle = hAngle; - this->vAngle = vAngle; + inline void setPolar(double r_dist, double h_angle, double v_angle) { + this->rDist = r_dist; + this->hAngle = h_angle; + this->vAngle = v_angle; } /*! Return the radial distance in meter. @@ -250,13 +249,18 @@ std::cout << p << std::endl; */ inline std::ostream &operator << (std::ostream &s, const vpScanPoint &p) { - s.precision(10); - s << p.getRadialDist() << " " - << p.getHAngle() << " " - << p.getVAngle() << " " - << p.getX() << " " - << p.getY() << " " << p.getZ(); - return s; - } + std::ios_base::fmtflags original_flags = s.flags(); + + s.precision(10); + s << p.getRadialDist() << " " + << p.getHAngle() << " " + << p.getVAngle() << " " + << p.getX() << " " + << p.getY() << " " << p.getZ(); + + s.setf(original_flags); // restore s to standard state + + return s; +} #endif diff --git a/src/device/light/vpRingLight.cpp b/src/device/light/vpRingLight.cpp index d16a526aa816738340669e4cf21a94d0aa3fa5b4..2f02477b05cd9f723d490589f5318b2dadfe6ae4 100644 --- a/src/device/light/vpRingLight.cpp +++ b/src/device/light/vpRingLight.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRingLight.cpp 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpRingLight.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/device/light/vpRingLight.h b/src/device/light/vpRingLight.h index 6d349c37fd4c34cfbd6d9d7dee805a29b8dd191d..b1784f401abdee3c68e60bd93037a0d701a62eb5 100644 --- a/src/device/light/vpRingLight.h +++ b/src/device/light/vpRingLight.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRingLight.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRingLight.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/exceptions/vpException.cpp b/src/exceptions/vpException.cpp index c0af7b8b25c9a7e23f3fc258fdb1f99aad005bf0..c5eda2153f762d3744fd651c5d8fc1fb61bf6201 100644 --- a/src/exceptions/vpException.cpp +++ b/src/exceptions/vpException.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpException.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpException.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -44,44 +44,37 @@ \brief error that can be emited by the vp class and its derivates */ +#include <stdio.h> #include "visp/vpException.h" /* ------------------------------------------------------------------------- */ /* --- CONSTRUCTORS -------------------------------------------------------- */ /* ------------------------------------------------------------------------- */ - - -vpException::vpException (int _code) - : - code (_code), - message () - +vpException::vpException (int id) + : code (id), message () { - return ; } - -vpException::vpException (int _code, - const std::string & _msg) - : - code (_code), - message (_msg) - +vpException::vpException (int id, const std::string & msg) + : code (id), message (msg) { - return ; } - -vpException::vpException (int _code, - const char * _msg) - : - code (_code), - message (_msg) +vpException::vpException (int id, const char* format, ...) + : code (id), message () { - return ; + va_list args; + va_start(args, format); + setMessage(format, args); + va_end (args); } +vpException::vpException (const int id, const char* format, va_list args) + : code (id), message () +{ + setMessage(format, args); +} /* ------------------------------------------------------------------------ */ /* --- DESTRUCTORS -------------------------------------------------------- */ /* ------------------------------------------------------------------------ */ @@ -92,11 +85,19 @@ vpException::vpException (int _code, // { // } + +void vpException::setMessage(const char* format, va_list args) +{ + char buffer[1024]; + vsnprintf (buffer, 1024, format, args); + std::string msg(buffer); + message = msg; +} + /* ------------------------------------------------------------------------ */ /* --- ACCESSORS ---------------------------------------------------------- */ /* ------------------------------------------------------------------------ */ - const char *vpException::getMessage (void) { return (this->message) .c_str(); @@ -133,9 +134,8 @@ const char* vpException::what () const throw() /* --- OP << --------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */ -std::ostream & -operator << (std::ostream & os, - const vpException & error) +VISP_EXPORT std::ostream & +operator << (std::ostream & os, const vpException & error) { os << "Error [" << error.code << "]:\t" << error.message << std::endl; diff --git a/src/exceptions/vpException.h b/src/exceptions/vpException.h index e64558dbf2256782ed03fed1c3a4639d48fb93ae..d15124f7d04a67af0ae3c4125e953252b6c25b5d 100644 --- a/src/exceptions/vpException.h +++ b/src/exceptions/vpException.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpException.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpException.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -57,6 +57,7 @@ /* Classes standards. */ #include <iostream> /* Classe std::ostream. */ #include <string> /* Classe string. */ +#include <stdarg.h> /* --------------------------------------------------------------------- */ /* --- CLASS ----------------------------------------------------------- */ @@ -74,23 +75,23 @@ */ class VISP_EXPORT vpException : public std::exception { + protected: -private: + //! Contains the error code, see the errorCodeEnum table for details. + int code; - //! Contains the error code, see the errorCodeEnum table for details. - int code; + //! Contains an error message (can be empty) + std::string message; - //! Contains an error message (can be empty) - std::string message; + //! Set the message container + void setMessage(const char* format, va_list args); -private: + //! forbid the empty constructor (protected) + vpException(): code(notInitialized), message("") { }; - //! forbid the empty constructor (private) - vpException(); + public: -public: - - enum generalExceptionEnum + enum generalExceptionEnum { memoryAllocationError, memoryFreeError, @@ -105,42 +106,31 @@ public: notInitialized /*!< Used to indicate that a parameter is not initialized. */ } ; - vpException (const int code, const char * msg); - vpException (const int code, const std::string & msg); - vpException (const int code); + vpException (const int code, const char* format, va_list args); + vpException (const int code, const char* format, ...); + vpException (const int code, const std::string & msg); + vpException (const int code); - /*! - Basic destructor. Do nothing but implemented to fit the inheritance from - std::exception - */ - virtual ~vpException() throw() {} + /*! + Basic destructor. Do nothing but implemented to fit the inheritance from + std::exception + */ + virtual ~vpException() throw() {} - //! send the object code - int getCode (void); + //! send the object code + int getCode (void); - //! send a reference (constant) related the error message (can be empty) - const std::string &getStringMessage (void); - //! send a pointer on the array of \e char related to the error string. - //!Cannot be \e NULL. - const char *getMessage (void); + //! send a reference (constant) related the error message (can be empty) + const std::string &getStringMessage (void); + //! send a pointer on the array of \e char related to the error string. + //!Cannot be \e NULL. + const char *getMessage (void); - //! print the error structure - friend VISP_EXPORT std::ostream & operator << (std::ostream & os, - const vpException & art); + //! print the error structure + friend VISP_EXPORT std::ostream & operator << (std::ostream & os, const vpException & art); - const char* what () const throw(); + const char* what () const throw(); }; - - - - #endif /* #ifndef __vpException_H */ - - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ diff --git a/src/image/vpColor.cpp b/src/image/vpColor.cpp index 42e762aad5ecb4e9c56bbf058fbb5cec7cc40692..27598c61ec1b98b9f51e34937e261eb3d30d2604 100755 --- a/src/image/vpColor.cpp +++ b/src/image/vpColor.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpColor.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpColor.cpp 4620 2014-01-27 21:28:32Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -121,3 +121,25 @@ vpColor const vpColor::allColors[vpColor::nbColors] = { /*!< Predefined none color with R=G=B=0 and identifier vpColor::id_unknown. */ vpColor const vpColor::none = vpColor(0, 0, 0, id_unknown); +/*! + Compare two colors. + + Return true if the R,G,B components are the same. + + \param c1,c2 : Color to compare. +*/ +VISP_EXPORT bool operator==( const vpColor &c1, const vpColor &c2 ) { + return ( ( c1.R == c2.R ) && ( c1.G == c2.G ) && ( c1.B == c2.B) ); +} + +/*! + + Compare two colors. + + Return true if the R,G,B components are different. + + \param c1,c2 : Color to compare. +*/ +VISP_EXPORT bool operator!=( const vpColor &c1, const vpColor &c2 ) { + return ( ( c1.R != c2.R ) || ( c1.G != c2.G ) || ( c1.B == c2.B) ); +} diff --git a/src/image/vpColor.h b/src/image/vpColor.h index 5a6b7359f6391a095ae322ccfbf57f89e290ff38..db77d187dfbef544b7651b91f019e4633d70b335 100644 --- a/src/image/vpColor.h +++ b/src/image/vpColor.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpColor.h 4243 2013-05-07 07:58:55Z fspindle $ + * $Id: vpColor.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -194,33 +194,35 @@ class VISP_EXPORT vpColor : public vpRGBa /*! Construct a color from its RGB values. - \param R : Red component. - \param G : Green component. - \param B : Blue component. + \param r : Red component. + \param g : Green component. + \param b : Blue component. - \param id : The color identifier to indicate if this color is or + \param cid : The color identifier to indicate if this color is or not a predefined one. */ - inline vpColor(unsigned char R, unsigned char G, unsigned char B, - vpColor::vpColorIdentifier id=vpColor::id_unknown) - : vpRGBa(R, G, B), id(id) + inline vpColor(unsigned char r, unsigned char g, unsigned char b, + vpColor::vpColorIdentifier cid=vpColor::id_unknown) + : vpRGBa(r, g, b), id(cid) {}; + friend VISP_EXPORT bool operator==( const vpColor &c1, const vpColor &c2 ); + friend VISP_EXPORT bool operator!=( const vpColor &c1, const vpColor &c2 ); /*! Set a color from its RGB values. - \param R : Red component. - \param G : Green component. - \param B : Blue component. + \param r : Red component. + \param g : Green component. + \param b : Blue component. The color identifier is set to vpColor::id_unknown to indicate that this color is not a predefined one. */ - inline void setColor(unsigned char R, unsigned char G, unsigned char B) { - this->R = R; - this->G = G; - this->B = B; + inline void setColor(unsigned char r, unsigned char g, unsigned char b) { + this->R = r; + this->G = g; + this->B = b; this->A = 0; id = id_unknown; }; @@ -231,37 +233,10 @@ class VISP_EXPORT vpColor : public vpRGBa \param i : color indice */ - static inline vpColor getColor(const unsigned int &i) {return vpColor::allColors[i % vpColor::nbColors];}; + static inline vpColor getColor(const unsigned int &i) { + return vpColor::allColors[i % vpColor::nbColors]; + }; }; -/*! - Compare two colors. - - Return true if the R,G,B components are the same. - - \param c1,c2 : Color to compare. -*/ -VISP_EXPORT inline bool operator==( const vpColor &c1, const vpColor &c2 ) { - return ( ( c1.R == c2.R ) && ( c1.G == c2.G ) && ( c1.B == c2.B) ); -} - -/*! - - Compare two colors. - - Return true if the R,G,B components are different. - - \param c1,c2 : Color to compare. -*/ -VISP_EXPORT inline bool operator!=( const vpColor &c1, const vpColor &c2 ) { - return ( ( c1.R != c2.R ) || ( c1.G != c2.G ) || ( c1.B == c2.B) ); -} - #endif - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ diff --git a/src/image/vpImage.h b/src/image/vpImage.h index 08dd1a2301c56052d5fc0bf7c6ff82cde4ffb65f..e485d515d149b100e45b3d8ad2fd86e5572277f1 100644 --- a/src/image/vpImage.h +++ b/src/image/vpImage.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpImage.h 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: vpImage.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -135,7 +135,7 @@ public: //! set the size of the image void init(unsigned int height, unsigned int width, Type value) ; //! set the size of the image - void resize(const unsigned int height, const unsigned int width) ; + void resize(const unsigned int h, const unsigned int w) ; //! destructor void destroy() ; @@ -217,9 +217,11 @@ public: //! operator[] allows operation like I[i] = x. inline Type *operator[]( const unsigned int i) { return row[i];} + inline Type *operator[]( const int i) { return row[i];} //! operator[] allows operation like x = I[i] inline const Type *operator[](unsigned int i) const { return row[i];} + inline const Type *operator[](int i) const { return row[i];} /*! Get the value of an image point. @@ -287,9 +289,9 @@ public: vpImage<Type> operator-(const vpImage<Type> &B); //! Copy operator - void operator=(const vpImage<Type> &I) ; + vpImage<Type>& operator=(const vpImage<Type> &I) ; - void operator=(const Type &v); + vpImage<Type>& operator=(const Type &v); bool operator==(const vpImage<Type> &I); bool operator!=(const vpImage<Type> &I); @@ -331,21 +333,23 @@ private: /*! \brief Image initialisation - Allocate memory for an [height x width] image + Allocate memory for an [h x w] image. - Set all the element of the bitmap to value + \param w : Image width. + \param h : Image height. + \param value : Set all the element of the bitmap to \e value. \exception vpException::memoryAllocationError - \sa vpImage::init(height, width) + \sa vpImage::init(h, w) */ template<class Type> void -vpImage<Type>::init(unsigned int height, unsigned int width, Type value) +vpImage<Type>::init(unsigned int h, unsigned int w, Type value) { try { - init(height,width) ; + init(h,w) ; } catch(vpException me) { @@ -361,7 +365,10 @@ vpImage<Type>::init(unsigned int height, unsigned int width, Type value) /*! \brief Image initialization - Allocate memory for an [height x width] image + Allocate memory for an [h x w] image. + + \param w : Image width. + \param h : Image height. Element of the bitmap are not initialized @@ -374,10 +381,10 @@ vpImage<Type>::init(unsigned int height, unsigned int width, Type value) */ template<class Type> void -vpImage<Type>::init(unsigned int height, unsigned int width) +vpImage<Type>::init(unsigned int h, unsigned int w) { - if (height != this->height) { + if (h != this->height) { if (row != NULL) { vpDEBUG_TRACE(10,"Destruction row[]"); delete [] row; @@ -385,7 +392,7 @@ vpImage<Type>::init(unsigned int height, unsigned int width) } } - if ((height != this->height) || (width != this->width)) + if ((h != this->height) || (w != this->width)) { if (bitmap != NULL) { vpDEBUG_TRACE(10,"Destruction bitmap[]") ; @@ -394,14 +401,11 @@ vpImage<Type>::init(unsigned int height, unsigned int width) } } - - - this->width = width ; - this->height = height ; + this->width = w ; + this->height = h; npixels=width*height; - if (bitmap == NULL) bitmap = new Type[npixels] ; // vpERROR_TRACE("Allocate bitmap %p",bitmap) ; @@ -429,9 +433,12 @@ vpImage<Type>::init(unsigned int height, unsigned int width) /*! \brief Constructor - Allocate memory for an [height x width] image + Allocate memory for an [h x w] image. + + \param w : Image width. + \param h : Image height. - Element of the bitmap are set to zero + Element of the bitmap are set to zero. If the image has been already initialized, memory allocation is done only if the new image size is different, else we re-use the same @@ -442,20 +449,15 @@ vpImage<Type>::init(unsigned int height, unsigned int width) \sa vpImage::init(height, width) */ template<class Type> -vpImage<Type>::vpImage(unsigned int height, unsigned int width) +vpImage<Type>::vpImage(unsigned int h, unsigned int w) + : bitmap(NULL), display(NULL), npixels(0), width(0), height(0), row(NULL) { - bitmap = NULL ; - row = NULL ; - - display = NULL ; - this->height = this->width = 0 ; try { - init(height,width,0) ; + init(h,w,0) ; } - catch(vpException me) + catch(...) { - vpERROR_TRACE(" ") ; throw ; } } @@ -463,9 +465,11 @@ vpImage<Type>::vpImage(unsigned int height, unsigned int width) /*! \brief Constructor - Allocate memory for an [height x width] image + Allocate memory for an [height x width] image. - set all the element of the bitmap to value + \param w : Image width. + \param h : Image height. + \param value : Set all the element of the bitmap to value. If the image has been already initialized, memory allocation is done only if the new image size is different, else we re-use the same @@ -476,16 +480,12 @@ vpImage<Type>::vpImage(unsigned int height, unsigned int width) \sa vpImage::init(height, width, value) */ template<class Type> -vpImage<Type>::vpImage (unsigned int height, unsigned int width, Type value) +vpImage<Type>::vpImage (unsigned int h, unsigned int w, Type value) + : bitmap(NULL), display(NULL), npixels(0), width(0), height(0), row(NULL) { - bitmap = NULL ; - row = NULL ; - - display = NULL ; - this->height = this->width = 0 ; try { - init(height,width,value) ; + init(h,w,value) ; } catch(vpException me) { @@ -505,14 +505,8 @@ vpImage<Type>::vpImage (unsigned int height, unsigned int width, Type value) */ template<class Type> vpImage<Type>::vpImage() + : bitmap(NULL), display(NULL), npixels(0), width(0), height(0), row(NULL) { - bitmap = NULL ; - row = NULL ; - - display = NULL ; - - this->height = this->width = 0 ; - this->npixels = 0; } /*! @@ -520,6 +514,9 @@ vpImage<Type>::vpImage() Allocate memory for an [height x width] image + \param w : Image width. + \param h : Image height. + Element of the bitmap are not initialized If the image has been already initialized, memory allocation is done @@ -532,11 +529,11 @@ vpImage<Type>::vpImage() */ template<class Type> void -vpImage<Type>::resize(unsigned int height, unsigned int width) +vpImage<Type>::resize(unsigned int h, unsigned int w) { try { - init(height, width) ; + init(h, w) ; } catch(vpException me) { @@ -596,23 +593,13 @@ vpImage<Type>::~vpImage() */ template<class Type> vpImage<Type>::vpImage(const vpImage<Type>& I) + : bitmap(NULL), display(NULL), npixels(0), width(0), height(0), row(NULL) { - bitmap = NULL ; - row = NULL ; - /* we first have to set the initial values of the image because resize function calls init function that test the actual size of the image */ - this->width = 0; - this->height = 0; - this->npixels = 0; try { - //if (I.bitmap!=NULL) -// if(I.getHeight() != 0 || I.getWidth() != 0) - { - resize(I.getHeight(),I.getWidth()); - unsigned int i; - memcpy(bitmap, I.bitmap, I.npixels*sizeof(Type)) ; - for (i =0 ; i < this->height ; i++) row[i] = bitmap + i*this->width ; - } + resize(I.getHeight(),I.getWidth()); + memcpy(bitmap, I.bitmap, I.npixels*sizeof(Type)) ; + for (unsigned int i =0 ; i < this->height ; i++) row[i] = bitmap + i*this->width ; } catch(vpException me) { @@ -673,7 +660,7 @@ void vpImage<Type>::getMinMaxValue(Type &min, Type &max) const \brief Copy operator */ template<class Type> -void vpImage<Type>::operator=(const vpImage<Type> &I) +vpImage<Type> & vpImage<Type>::operator=(const vpImage<Type> &I) { /* we first have to set the initial values of the image because resize function calls init function that test the actual size of the image */ if(bitmap != NULL){ @@ -723,6 +710,7 @@ void vpImage<Type>::operator=(const vpImage<Type> &I) vpERROR_TRACE(" ") ; throw ; } + return (* this); } @@ -733,10 +721,12 @@ void vpImage<Type>::operator=(const vpImage<Type> &I) \warning = must be defined for \f$ <\f$ Type \f$ > \f$ */ template<class Type> -void vpImage<Type>::operator=(const Type &v) +vpImage<Type>& vpImage<Type>::operator=(const Type &v) { for (unsigned int i=0 ; i < npixels ; i++) bitmap[i] = v ; + + return *this; } /*! diff --git a/src/image/vpImageConvert.cpp b/src/image/vpImageConvert.cpp index f4f7b05325339ddb75904273066660eb034fd0b5..d01f315e158af0e26c2f4d8e4bed887d5539869a 100644 --- a/src/image/vpImageConvert.cpp +++ b/src/image/vpImageConvert.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpImageConvert.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: vpImageConvert.cpp 4661 2014-02-10 19:34:58Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -65,8 +65,7 @@ Convert a vpImage\<vpRGBa\> to a vpImage\<unsigned char\> \param dest : destination image */ void -vpImageConvert::convert(const vpImage<unsigned char> &src, - vpImage<vpRGBa> & dest) +vpImageConvert::convert(const vpImage<unsigned char> &src, vpImage<vpRGBa> & dest) { dest.resize(src.getHeight(), src.getWidth()) ; @@ -80,8 +79,7 @@ Convert a vpImage\<unsigned char\> to a vpImage\<vpRGBa\> \param dest : destination image */ void -vpImageConvert::convert(const vpImage<vpRGBa> &src, - vpImage<unsigned char> & dest) +vpImageConvert::convert(const vpImage<vpRGBa> &src, vpImage<unsigned char> & dest) { dest.resize(src.getHeight(), src.getWidth()) ; @@ -96,8 +94,7 @@ Convert a vpImage\<float\> to a vpImage\<unsigend char\> by renormalizing betwee \param dest : destination image */ void -vpImageConvert::convert(const vpImage<float> &src, - vpImage<unsigned char> &dest) +vpImageConvert::convert(const vpImage<float> &src, vpImage<unsigned char> &dest) { dest.resize(src.getHeight(), src.getWidth()) ; unsigned int max_xy = src.getWidth()*src.getHeight(); @@ -112,7 +109,7 @@ vpImageConvert::convert(const vpImage<float> &src, else if(val > 255) dest.bitmap[i] = 255; else - dest.bitmap[i] = (int)val; + dest.bitmap[i] = (unsigned char)val; } } @@ -122,8 +119,7 @@ Convert a vpImage\<unsigned char\> to a vpImage\<float\> by basic casting. \param dest : destination image */ void -vpImageConvert::convert(const vpImage<unsigned char> &src, - vpImage<float> &dest) +vpImageConvert::convert(const vpImage<unsigned char> &src, vpImage<float> &dest) { dest.resize(src.getHeight(), src.getWidth()) ; for (unsigned int i = 0; i < src.getHeight()*src.getWidth(); i++) @@ -136,8 +132,7 @@ Convert a vpImage\<double\> to a vpImage\<unsigend char\> by renormalizing betwe \param dest : destination image */ void -vpImageConvert::convert(const vpImage<double> &src, - vpImage<unsigned char> &dest) +vpImageConvert::convert(const vpImage<double> &src, vpImage<unsigned char> &dest) { dest.resize(src.getHeight(), src.getWidth()) ; unsigned int max_xy = src.getWidth()*src.getHeight(); @@ -152,7 +147,7 @@ vpImageConvert::convert(const vpImage<double> &src, else if(val > 255) dest.bitmap[i] = 255; else - dest.bitmap[i] = (int)val; + dest.bitmap[i] = (unsigned char)val; } } @@ -162,8 +157,7 @@ Convert a vpImage\<unsigned char\> to a vpImage\<double\> by basic casting. \param dest : destination image */ void -vpImageConvert::convert(const vpImage<unsigned char> &src, - vpImage<double> &dest) +vpImageConvert::convert(const vpImage<unsigned char> &src, vpImage<double> &dest) { dest.resize(src.getHeight(), src.getWidth()) ; for (unsigned int i = 0; i < src.getHeight()*src.getWidth(); i++) @@ -315,8 +309,7 @@ int main() \endcode */ void -vpImageConvert::convert(const IplImage* src, - vpImage<unsigned char> &dest, bool flip) +vpImageConvert::convert(const IplImage* src, vpImage<unsigned char> &dest, bool flip) { int nChannel = src->nChannels; int depth = src->depth; @@ -357,21 +350,21 @@ vpImageConvert::convert(const IplImage* src, } else { - if(nChannel == 1 && depth == 8){ + if(nChannel == 1 && depth == 8){ + dest.resize((unsigned int)height, (unsigned int)width) ; unsigned char* beginOutput = (unsigned char*)dest.bitmap; - dest.resize((unsigned int)height, (unsigned int)width) ; - for (int i =0 ; i < height ; i++){ - memcpy(beginOutput + lineStep * ( 4 * width * ( height - 1 - i ) ) , src->imageData + i*widthStep, - (size_t)width); - } - } - if(nChannel == 3 && depth == 8){ - dest.resize((unsigned int)height, (unsigned int)width) ; - //for (int i = 0 ; i < height ; i++){ - BGRToGrey((unsigned char*)src->imageData /*+ i*widthStep*/, - dest.bitmap /*+ i*width*/, (unsigned int)width, (unsigned int)height/*1*/, true); - //} + for (int i =0 ; i < height ; i++){ + memcpy(beginOutput + lineStep * ( 4 * width * ( height - 1 - i ) ) , src->imageData + i*widthStep, + (size_t)width); } + } + if(nChannel == 3 && depth == 8){ + dest.resize((unsigned int)height, (unsigned int)width) ; + //for (int i = 0 ; i < height ; i++){ + BGRToGrey((unsigned char*)src->imageData /*+ i*widthStep*/, + dest.bitmap /*+ i*width*/, (unsigned int)width, (unsigned int)height/*1*/, true); + //} + } } } @@ -502,8 +495,7 @@ int main() \endcode */ void -vpImageConvert::convert(const vpImage<unsigned char> & src, - IplImage* &dest) +vpImageConvert::convert(const vpImage<unsigned char> & src, IplImage* &dest) { unsigned int height = src.getHeight(); unsigned int width = src.getWidth(); @@ -577,8 +569,7 @@ int main() \endcode */ void -vpImageConvert::convert(const cv::Mat& src, - vpImage<vpRGBa>& dest, const bool flip) +vpImageConvert::convert(const cv::Mat& src, vpImage<vpRGBa>& dest, const bool flip) { if(src.type() == CV_8UC4){ dest.resize((unsigned int)src.rows, (unsigned int)src.cols); @@ -671,8 +662,7 @@ int main() \endcode */ void -vpImageConvert::convert(const cv::Mat& src, - vpImage<unsigned char>& dest, const bool flip) +vpImageConvert::convert(const cv::Mat& src, vpImage<unsigned char>& dest, const bool flip) { if(src.type() == CV_8UC1){ dest.resize((unsigned int)src.rows, (unsigned int)src.cols); @@ -754,8 +744,7 @@ int main() \endcode */ void -vpImageConvert::convert(const vpImage<vpRGBa> & src, - cv::Mat& dest) +vpImageConvert::convert(const vpImage<vpRGBa> & src, cv::Mat& dest) { cv::Mat vpToMat((int)src.getRows(), (int)src.getCols(), CV_8UC4, (void*)src.bitmap); @@ -809,8 +798,7 @@ int main() \endcode */ void -vpImageConvert::convert(const vpImage<unsigned char> & src, - cv::Mat& dest, const bool copyData) +vpImageConvert::convert(const vpImage<unsigned char> & src, cv::Mat& dest, const bool copyData) { if(copyData){ cv::Mat tmpMap((int)src.getRows(), (int)src.getCols(), CV_8UC1, (void*)src.bitmap); @@ -857,7 +845,7 @@ int main() \endcode */ void vpImageConvert::convert(const vpImage<unsigned char> & src, - yarp::sig::ImageOf< yarp::sig::PixelMono > *dest, const bool copyData) + yarp::sig::ImageOf< yarp::sig::PixelMono > *dest, const bool copyData) { if(copyData) { @@ -905,7 +893,7 @@ int main() \endcode */ void vpImageConvert::convert(const yarp::sig::ImageOf< yarp::sig::PixelMono > *src, - vpImage<unsigned char> & dest,const bool copyData ) + vpImage<unsigned char> & dest,const bool copyData) { dest.resize(src->height(),src->width()); if(copyData) @@ -948,7 +936,7 @@ int main() \endcode */ void vpImageConvert::convert(const vpImage<vpRGBa> & src, - yarp::sig::ImageOf< yarp::sig::PixelRgba > *dest, const bool copyData) + yarp::sig::ImageOf< yarp::sig::PixelRgba > *dest, const bool copyData) { if(copyData){ dest->resize(src.getWidth(),src.getHeight()); @@ -996,7 +984,7 @@ int main() \endcode */ void vpImageConvert::convert(const yarp::sig::ImageOf< yarp::sig::PixelRgba > *src, - vpImage<vpRGBa> & dest,const bool copyData) + vpImage<vpRGBa> & dest,const bool copyData) { dest.resize(src->height(),src->width()); if(copyData) @@ -1037,8 +1025,7 @@ int main() } \endcode */ -void vpImageConvert::convert(const vpImage<vpRGBa> & src, - yarp::sig::ImageOf< yarp::sig::PixelRgb > *dest) +void vpImageConvert::convert(const vpImage<vpRGBa> & src, yarp::sig::ImageOf< yarp::sig::PixelRgb > *dest) { dest->resize(src.getWidth(),src.getHeight()); for(unsigned int i = 0 ; i < src.getRows() ; i++){ @@ -1086,8 +1073,7 @@ int main() } \endcode */ -void vpImageConvert::convert(const yarp::sig::ImageOf< yarp::sig::PixelRgb > *src, - vpImage<vpRGBa> & dest) +void vpImageConvert::convert(const yarp::sig::ImageOf< yarp::sig::PixelRgb > *src, vpImage<vpRGBa> & dest) { dest.resize(src->height(),src->width()); for(int i = 0 ; i < src->height() ; i++){ @@ -1213,7 +1199,7 @@ void vpImageConvert::convertToJPEGBuffer(unsigned char *src, long unsigned int s \sa YUV422ToRGBa() */ void vpImageConvert::YUYVToRGBa(unsigned char* yuyv, unsigned char* rgba, - unsigned int width, unsigned int height) + unsigned int width, unsigned int height) { unsigned char *s; unsigned char *d; @@ -1269,7 +1255,7 @@ void vpImageConvert::YUYVToRGBa(unsigned char* yuyv, unsigned char* rgba, \sa YUV422ToRGB() */ void vpImageConvert::YUYVToRGB(unsigned char* yuyv, unsigned char* rgb, - unsigned int width, unsigned int height) + unsigned int width, unsigned int height) { unsigned char *s; unsigned char *d; @@ -1321,8 +1307,7 @@ void vpImageConvert::YUYVToRGB(unsigned char* yuyv, unsigned char* rgb, \sa YUV422ToGrey() */ -void vpImageConvert::YUYVToGrey(unsigned char* yuyv, unsigned char* grey, - unsigned int size) +void vpImageConvert::YUYVToGrey(unsigned char* yuyv, unsigned char* grey, unsigned int size) { unsigned int i=0,j=0; @@ -1341,9 +1326,7 @@ Convert YUV411 into RGB32 yuv411 : u y1 y2 v y3 y4 */ -void vpImageConvert::YUV411ToRGBa(unsigned char* yuv, - unsigned char* rgba, - unsigned int size) +void vpImageConvert::YUV411ToRGBa(unsigned char* yuv, unsigned char* rgba, unsigned int size) { #if 1 // std::cout << "call optimized ConvertYUV411ToRGBa()" << std::endl; @@ -1470,9 +1453,7 @@ void vpImageConvert::YUV411ToRGBa(unsigned char* yuv, \sa YUYVToRGBa() */ -void vpImageConvert::YUV422ToRGBa(unsigned char* yuv, - unsigned char* rgba, - unsigned int size) +void vpImageConvert::YUV422ToRGBa(unsigned char* yuv, unsigned char* rgba, unsigned int size) { #if 1 @@ -1552,12 +1533,8 @@ Convert YUV411 into Grey yuv411 : u y1 y2 v y3 y4 */ -void vpImageConvert::YUV411ToGrey(unsigned char* yuv, - unsigned char* grey, - unsigned int size) +void vpImageConvert::YUV411ToGrey(unsigned char* yuv, unsigned char* grey, unsigned int size) { - - unsigned int i=0,j=0; while( j < size*3/2) { @@ -1581,9 +1558,7 @@ void vpImageConvert::YUV411ToGrey(unsigned char* yuv, \sa YUYVToRGB() */ -void vpImageConvert::YUV422ToRGB(unsigned char* yuv, - unsigned char* rgb, - unsigned int size) +void vpImageConvert::YUV422ToRGB(unsigned char* yuv, unsigned char* rgb, unsigned int size) { #if 1 // std::cout << "call optimized convertYUV422ToRGB()" << std::endl; @@ -1661,9 +1636,7 @@ void vpImageConvert::YUV422ToRGB(unsigned char* yuv, \sa YUYVToGrey() */ -void vpImageConvert::YUV422ToGrey(unsigned char* yuv, - unsigned char* grey, - unsigned int size) +void vpImageConvert::YUV422ToGrey(unsigned char* yuv, unsigned char* grey, unsigned int size) { unsigned int i=0,j=0; @@ -1681,9 +1654,7 @@ Convert YUV411 into RGB yuv411 : u y1 y2 v y3 y4 */ -void vpImageConvert::YUV411ToRGB(unsigned char* yuv, - unsigned char* rgb, - unsigned int size) +void vpImageConvert::YUV411ToRGB(unsigned char* yuv, unsigned char* rgb, unsigned int size) { #if 1 // std::cout << "call optimized ConvertYUV411ToRGB()" << std::endl; @@ -1806,9 +1777,8 @@ void vpImageConvert::YUV411ToRGB(unsigned char* yuv, yuv420 : Y(NxM), U(N/2xM/2), V(N/2xM/2) */ -void vpImageConvert::YUV420ToRGBa(unsigned char* yuv, - unsigned char* rgba, - unsigned int width, unsigned int height) +void vpImageConvert::YUV420ToRGBa(unsigned char* yuv, unsigned char* rgba, + unsigned int width, unsigned int height) { // std::cout << "call optimized ConvertYUV420ToRGBa()" << std::endl; register int U, V, R, G, B, V2, U5, UV; @@ -1908,8 +1878,8 @@ void vpImageConvert::YUV420ToRGBa(unsigned char* yuv, */ void vpImageConvert::YUV420ToRGB(unsigned char* yuv, - unsigned char* rgb, - unsigned int width, unsigned int height) + unsigned char* rgb, + unsigned int width, unsigned int height) { // std::cout << "call optimized ConvertYUV420ToRGB()" << std::endl; register int U, V, R, G, B, V2, U5, UV; @@ -2005,9 +1975,7 @@ void vpImageConvert::YUV420ToRGB(unsigned char* yuv, yuv420 : Y(NxM), U(N/2xM/2), V(N/2xM/2) */ -void vpImageConvert::YUV420ToGrey(unsigned char* yuv, - unsigned char* grey, - unsigned int size) +void vpImageConvert::YUV420ToGrey(unsigned char* yuv, unsigned char* grey, unsigned int size) { for(unsigned int i=0 ; i < size ; i++) { @@ -2021,9 +1989,7 @@ void vpImageConvert::YUV420ToGrey(unsigned char* yuv, yuv444 : u y v */ -void vpImageConvert::YUV444ToRGBa(unsigned char* yuv, - unsigned char* rgba, - unsigned int size) +void vpImageConvert::YUV444ToRGBa(unsigned char* yuv, unsigned char* rgba, unsigned int size) { register int U, V, R, G, B, V2, U5, UV; register int Y; @@ -2062,9 +2028,7 @@ void vpImageConvert::YUV444ToRGBa(unsigned char* yuv, yuv444 : u y v */ -void vpImageConvert::YUV444ToRGB(unsigned char* yuv, - unsigned char* rgb, - unsigned int size) +void vpImageConvert::YUV444ToRGB(unsigned char* yuv, unsigned char* rgb, unsigned int size) { register int U, V, R, G, B, V2, U5, UV; register int Y; @@ -2103,9 +2067,7 @@ void vpImageConvert::YUV444ToRGB(unsigned char* yuv, yuv444 : u y v */ -void vpImageConvert::YUV444ToGrey(unsigned char* yuv, - unsigned char* grey, - unsigned int size) +void vpImageConvert::YUV444ToGrey(unsigned char* yuv, unsigned char* grey, unsigned int size) { yuv++; for(unsigned int i=0 ; i < size ; i++) @@ -2121,9 +2083,8 @@ void vpImageConvert::YUV444ToGrey(unsigned char* yuv, yuv420 : Y(NxM), V(N/2xM/2), U(N/2xM/2) */ -void vpImageConvert::YV12ToRGBa(unsigned char* yuv, - unsigned char* rgba, - unsigned int width, unsigned int height) +void vpImageConvert::YV12ToRGBa(unsigned char* yuv, unsigned char* rgba, + unsigned int width, unsigned int height) { // std::cout << "call optimized ConvertYV12ToRGBa()" << std::endl; register int U, V, R, G, B, V2, U5, UV; @@ -2222,9 +2183,8 @@ void vpImageConvert::YV12ToRGBa(unsigned char* yuv, yuv420 : Y(NxM), V(N/2xM/2), U(N/2xM/2) */ -void vpImageConvert::YV12ToRGB(unsigned char* yuv, - unsigned char* rgb, - unsigned int height, unsigned int width) +void vpImageConvert::YV12ToRGB(unsigned char* yuv, unsigned char* rgb, + unsigned int height, unsigned int width) { // std::cout << "call optimized ConvertYV12ToRGB()" << std::endl; register int U, V, R, G, B, V2, U5, UV; @@ -2320,9 +2280,8 @@ void vpImageConvert::YV12ToRGB(unsigned char* yuv, yuv420 : Y(NxM), V(N/4xM/4), U(N/4xM/4) */ -void vpImageConvert::YVU9ToRGBa(unsigned char* yuv, - unsigned char* rgba, - unsigned int width, unsigned int height) +void vpImageConvert::YVU9ToRGBa(unsigned char* yuv, unsigned char* rgba, + unsigned int width, unsigned int height) { // std::cout << "call optimized ConvertYVU9ToRGBa()" << std::endl; register int U, V, R, G, B, V2, U5, UV; @@ -2614,9 +2573,8 @@ void vpImageConvert::YVU9ToRGBa(unsigned char* yuv, yuv420 : Y(NxM), V(N/4xM/4), U(N/4xM/4) */ -void vpImageConvert::YVU9ToRGB(unsigned char* yuv, - unsigned char* rgb, - unsigned int height, unsigned int width) +void vpImageConvert::YVU9ToRGB(unsigned char* yuv, unsigned char* rgb, + unsigned int height, unsigned int width) { // std::cout << "call optimized ConvertYVU9ToRGB()" << std::endl; register int U, V, R, G, B, V2, U5, UV; @@ -2892,8 +2850,7 @@ void vpImageConvert::YVU9ToRGB(unsigned char* yuv, Convert RGB into RGBa */ -void vpImageConvert::RGBToRGBa(unsigned char* rgb, unsigned char* rgba, - unsigned int size) +void vpImageConvert::RGBToRGBa(unsigned char* rgb, unsigned char* rgba, unsigned int size) { unsigned char *pt_input = rgb; unsigned char *pt_end = rgb + 3*size; @@ -2912,8 +2869,7 @@ void vpImageConvert::RGBToRGBa(unsigned char* rgb, unsigned char* rgba, Convert RGB into RGBa */ -void vpImageConvert::RGBaToRGB(unsigned char* rgba, unsigned char* rgb, - unsigned int size) +void vpImageConvert::RGBaToRGB(unsigned char* rgba, unsigned char* rgb, unsigned int size) { unsigned char *pt_input = rgba; unsigned char *pt_end = rgba + 4*size; @@ -2932,8 +2888,7 @@ void vpImageConvert::RGBaToRGB(unsigned char* rgba, unsigned char* rgb, http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html */ -void vpImageConvert::RGBToGrey(unsigned char* rgb, unsigned char* grey, - unsigned int size) +void vpImageConvert::RGBToGrey(unsigned char* rgb, unsigned char* grey, unsigned int size) { unsigned char *pt_input = rgb; unsigned char* pt_end = rgb + size*3; @@ -2953,8 +2908,7 @@ void vpImageConvert::RGBToGrey(unsigned char* rgb, unsigned char* grey, http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html */ -void vpImageConvert::RGBaToGrey(unsigned char* rgba, unsigned char* grey, - unsigned int size) +void vpImageConvert::RGBaToGrey(unsigned char* rgba, unsigned char* grey, unsigned int size) { unsigned char *pt_input = rgba; unsigned char* pt_end = rgba + size*4; @@ -2974,8 +2928,7 @@ void vpImageConvert::RGBaToGrey(unsigned char* rgba, unsigned char* grey, */ void -vpImageConvert::GreyToRGBa(unsigned char* grey, - unsigned char* rgba, unsigned int size) +vpImageConvert::GreyToRGBa(unsigned char* grey, unsigned char* rgba, unsigned int size) { unsigned char *pt_input = grey; unsigned char *pt_end = grey + size; @@ -2998,8 +2951,7 @@ vpImageConvert::GreyToRGBa(unsigned char* grey, */ void -vpImageConvert::GreyToRGB(unsigned char* grey, - unsigned char* rgb, unsigned int size) +vpImageConvert::GreyToRGB(unsigned char* grey, unsigned char* rgb, unsigned int size) { unsigned char *pt_input = grey; unsigned char* pt_end = grey + size; @@ -3024,7 +2976,7 @@ vpImageConvert::GreyToRGB(unsigned char* grey, */ void vpImageConvert::BGRToRGBa(unsigned char * bgr, unsigned char * rgba, - unsigned int width, unsigned int height, bool flip) + unsigned int width, unsigned int height, bool flip) { //if we have to flip the image, we start from the end last scanline so the //step is negative @@ -3062,7 +3014,7 @@ vpImageConvert::BGRToRGBa(unsigned char * bgr, unsigned char * rgba, */ void vpImageConvert::BGRToGrey(unsigned char * bgr, unsigned char * grey, - unsigned int width, unsigned int height, bool flip) + unsigned int width, unsigned int height, bool flip) { //if we have to flip the image, we start from the end last scanline so the //step is negative @@ -3097,7 +3049,7 @@ vpImageConvert::BGRToGrey(unsigned char * bgr, unsigned char * grey, */ void vpImageConvert::RGBToRGBa(unsigned char * rgb, unsigned char * rgba, - unsigned int width, unsigned int height, bool flip) + unsigned int width, unsigned int height, bool flip) { //if we have to flip the image, we start from the end last scanline so the //step is negative @@ -3132,7 +3084,7 @@ vpImageConvert::RGBToRGBa(unsigned char * rgb, unsigned char * rgba, */ void vpImageConvert::RGBToGrey(unsigned char * rgb, unsigned char * grey, - unsigned int width, unsigned int height, bool flip) + unsigned int width, unsigned int height, bool flip) { //if we have to flip the image, we start from the end last scanline so the //step is negative @@ -3206,8 +3158,7 @@ void vpImageConvert::computeYCbCrLUT() */ -void vpImageConvert::YCbCrToRGB(unsigned char *ycbcr, unsigned char *rgb, - unsigned int size) +void vpImageConvert::YCbCrToRGB(unsigned char *ycbcr, unsigned char *rgb, unsigned int size) { unsigned char *cbv; unsigned char *crv; @@ -3265,8 +3216,7 @@ void vpImageConvert::YCbCrToRGB(unsigned char *ycbcr, unsigned char *rgb, */ -void vpImageConvert::YCbCrToRGBa(unsigned char *ycbcr, unsigned char *rgba, - unsigned int size) +void vpImageConvert::YCbCrToRGBa(unsigned char *ycbcr, unsigned char *rgba, unsigned int size) { unsigned char *cbv; unsigned char *crv; @@ -3321,9 +3271,7 @@ void vpImageConvert::YCbCrToRGBa(unsigned char *ycbcr, unsigned char *rgba, - In grey format, each pixel is coded using 8 bytes. */ -void vpImageConvert::YCbCrToGrey(unsigned char* yuv, - unsigned char* grey, - unsigned int size) +void vpImageConvert::YCbCrToGrey(unsigned char* yuv, unsigned char* grey, unsigned int size) { unsigned int i=0,j=0; @@ -3353,8 +3301,7 @@ void vpImageConvert::YCbCrToGrey(unsigned char* yuv, Byte 2: Blue */ -void vpImageConvert::YCrCbToRGB(unsigned char *ycrcb, unsigned char *rgb, - unsigned int size) +void vpImageConvert::YCrCbToRGB(unsigned char *ycrcb, unsigned char *rgb, unsigned int size) { unsigned char *cbv; unsigned char *crv; @@ -3410,8 +3357,7 @@ void vpImageConvert::YCrCbToRGB(unsigned char *ycrcb, unsigned char *rgb, */ -void vpImageConvert::YCrCbToRGBa(unsigned char *ycrcb, unsigned char *rgba, - unsigned int size) +void vpImageConvert::YCrCbToRGBa(unsigned char *ycrcb, unsigned char *rgba, unsigned int size) { unsigned char *cbv; unsigned char *crv; @@ -3485,10 +3431,10 @@ int main() \endcode */ void vpImageConvert::split(const vpImage<vpRGBa> &src, - vpImage<unsigned char>* pR, - vpImage<unsigned char>* pG, - vpImage<unsigned char>* pB, - vpImage<unsigned char>* pa) + vpImage<unsigned char>* pR, + vpImage<unsigned char>* pG, + vpImage<unsigned char>* pB, + vpImage<unsigned char>* pa) { register size_t n = src.getNumberOfPixel(); unsigned int height = src.getHeight(); @@ -3549,8 +3495,7 @@ void vpImageConvert::split(const vpImage<vpRGBa> &src, \param size : The image size or the number of pixels. */ -void vpImageConvert::MONO16ToGrey(unsigned char *grey16, unsigned char *grey, - unsigned int size) +void vpImageConvert::MONO16ToGrey(unsigned char *grey16, unsigned char *grey, unsigned int size) { register int i = (((int)size)<<1)-1; register int j = (int)size-1; @@ -3572,8 +3517,7 @@ void vpImageConvert::MONO16ToGrey(unsigned char *grey16, unsigned char *grey, \param size : The image size or the number of pixels. */ -void vpImageConvert::MONO16ToRGBa(unsigned char *grey16, unsigned char *rgba, - unsigned int size) +void vpImageConvert::MONO16ToRGBa(unsigned char *grey16, unsigned char *rgba, unsigned int size) { register int i = (((int)size)<<1)-1; register int j = (int)(size*4-1); diff --git a/src/image/vpImageConvert.h b/src/image/vpImageConvert.h index c43d62d3eb2a779e69d30f5d3ab2edf321a1d058..2a88695fd0d30bff10c942e641c6d5877129a656 100644 --- a/src/image/vpImageConvert.h +++ b/src/image/vpImageConvert.h @@ -1,9 +1,9 @@ /**************************************************************************** * -* $Id: vpImageConvert.h 4216 2013-04-17 09:06:18Z fspindle $ +* $Id: vpImageConvert.h 4604 2014-01-21 14:15:23Z fspindle $ * * This file is part of the ViSP software. -* Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +* Copyright (C) 2005 - 2014 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 @@ -71,7 +71,7 @@ # include <yarp/sig/Image.h> #endif -#ifdef WIN32 +#if defined(_WIN32) # include <windows.h> #endif diff --git a/src/image/vpImageException.h b/src/image/vpImageException.h index 7519545cabd6670c9629bcb3407ae509cd88cf48..79c7fe9b60cea82c38393b460591b3a9c543e86b 100644 --- a/src/image/vpImageException.h +++ b/src/image/vpImageException.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpImageException.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpImageException.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -73,12 +73,12 @@ */ class VISP_EXPORT vpImageException : public vpException { -public: - /*! + public: + /*! \brief Lists the possible error than can be emmited while calling vpImage member */ - enum errorImageCodeEnum + enum errorImageCodeEnum { ioError, noFileNameError, @@ -87,25 +87,19 @@ public: notInTheImage } ; -public: - vpImageException (const int code, const char * msg) - : vpException(code, msg){ ; } - vpImageException (const int code, const std::string & msg) - : vpException(code, msg){ ; } - vpImageException (const int code) - : vpException(code){ ; } - + public: + vpImageException (const int id, const char* format, ...) + { + this->code = id; + va_list args; + va_start(args, format); + setMessage(format, args); + va_end (args); + } + vpImageException (const int id, const std::string & msg) + : vpException(id, msg){ ; } + vpImageException (const int id) + : vpException(id){ ; } }; - - - - -#endif /* #ifndef __vpImageException_H */ - - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ +#endif diff --git a/src/image/vpImageFilter.cpp b/src/image/vpImageFilter.cpp index e659452ea9e2fa9ae89a8a204e5b3a44585fab7c..c74971b7a0bc8f83b9aea9eedcab1de948e2d68c 100644 --- a/src/image/vpImageFilter.cpp +++ b/src/image/vpImageFilter.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpImageFilter.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpImageFilter.cpp 4661 2014-02-10 19:34:58Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -43,7 +43,7 @@ #include <visp/vpImageConvert.h> #if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020101) #include <opencv2/imgproc/imgproc_c.h> -#elif defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100) +#elif defined(VISP_HAVE_OPENCV) #include <cv.h> #endif @@ -192,3 +192,480 @@ vpImageFilter:: canny(const vpImage<unsigned char>& Isrc, cvReleaseImage(&edges_ipl); } #endif + +/*! + Apply a separable filter. + */ +void vpImageFilter::filter(const vpImage<unsigned char> &I, vpImage<double>& GI, const double *filter,unsigned int size) +{ + vpImage<double> GIx ; + filterX(I, GIx,filter,size); + filterY(GIx, GI,filter,size); + GIx.destroy(); +} + +/*! + Apply a separable filter. + */ +void vpImageFilter::filter(const vpImage<double> &I, vpImage<double>& GI, const double *filter,unsigned int size) +{ + vpImage<double> GIx ; + filterX(I, GIx,filter,size); + filterY(GIx, GI,filter,size); + GIx.destroy(); +} + +void vpImageFilter::filterX(const vpImage<unsigned char> &I, vpImage<double>& dIx, const double *filter,unsigned int size) +{ + dIx.resize(I.getHeight(),I.getWidth()) ; + for (unsigned int i=0 ; i < I.getHeight() ; i++) + { + for (unsigned int j=0 ; j < (size-1)/2 ; j++) + { + dIx[i][j]=vpImageFilter::filterXLeftBorder(I,i,j,filter,size); + //dIx[i][j]=0; + } + for (unsigned int j=(size-1)/2 ; j < I.getWidth()-(size-1)/2 ; j++) + { + dIx[i][j]=vpImageFilter::filterX(I,i,j,filter,size); + } + for (unsigned int j=I.getWidth()-(size-1)/2 ; j < I.getWidth() ; j++) + { + dIx[i][j]=vpImageFilter::filterXRightBorder(I,i,j,filter,size); + //dIx[i][j]=0; + } + } +} +void vpImageFilter::filterX(const vpImage<double> &I, vpImage<double>& dIx, const double *filter,unsigned int size) +{ + dIx.resize(I.getHeight(),I.getWidth()) ; + for (unsigned int i=0 ; i < I.getHeight() ; i++) + { + for (unsigned int j=0 ; j < (size-1)/2 ; j++) + { + dIx[i][j]=vpImageFilter::filterXLeftBorder(I,i,j,filter,size); + //dIx[i][j]=0; + } + for (unsigned int j=(size-1)/2 ; j < I.getWidth()-(size-1)/2 ; j++) + { + dIx[i][j]=vpImageFilter::filterX(I,i,j,filter,size); + } + for (unsigned int j=I.getWidth()-(size-1)/2 ; j < I.getWidth() ; j++) + { + dIx[i][j]=vpImageFilter::filterXRightBorder(I,i,j,filter,size); + //dIx[i][j]=0; + } + } +} +void vpImageFilter::filterY(const vpImage<unsigned char> &I, vpImage<double>& dIy, const double *filter,unsigned int size) +{ + dIy.resize(I.getHeight(),I.getWidth()) ; + for (unsigned int i=0 ; i < (size-1)/2 ; i++) + { + for (unsigned int j=0 ; j < I.getWidth() ; j++) + { + dIy[i][j]=vpImageFilter::filterYTopBorder(I,i,j,filter,size); + } + } + for (unsigned int i=(size-1)/2 ; i < I.getHeight()-(size-1)/2 ; i++) + { + for (unsigned int j=0 ; j < I.getWidth() ; j++) + { + dIy[i][j]=vpImageFilter::filterY(I,i,j,filter,size); + } + } + for (unsigned int i=I.getHeight()-(size-1)/2 ; i < I.getHeight() ; i++) + { + for (unsigned int j=0 ; j < I.getWidth() ; j++) + { + dIy[i][j]=vpImageFilter::filterYBottomBorder(I,i,j,filter,size); + } + } +} +void vpImageFilter::filterY(const vpImage<double> &I, vpImage<double>& dIy, const double *filter,unsigned int size) +{ + dIy.resize(I.getHeight(),I.getWidth()) ; + for (unsigned int i=0 ; i < (size-1)/2 ; i++) + { + for (unsigned int j=0 ; j < I.getWidth() ; j++) + { + dIy[i][j]=vpImageFilter::filterYTopBorder(I,i,j,filter,size); + } + } + for (unsigned int i=(size-1)/2 ; i < I.getHeight()-(size-1)/2 ; i++) + { + for (unsigned int j=0 ; j < I.getWidth() ; j++) + { + dIy[i][j]=vpImageFilter::filterY(I,i,j,filter,size); + } + } + for (unsigned int i=I.getHeight()-(size-1)/2 ; i < I.getHeight() ; i++) + { + for (unsigned int j=0 ; j < I.getWidth() ; j++) + { + dIy[i][j]=vpImageFilter::filterYBottomBorder(I,i,j,filter,size); + } + } +} + +/*! + Apply a Gaussian blur to an image. + \param I : Input image. + \param GI : Filtered image. + \param size : Filter size. This value should be odd. + \param sigma : Gaussian standard deviation. If it is equal to zero or negative, it is computed from filter size as sigma = (size-1)/6. + \param normalize : Flag indicating whether to normalize the filter coefficients or not. + + */ +void vpImageFilter::gaussianBlur(const vpImage<unsigned char> &I, vpImage<double>& GI, unsigned int size, double sigma, bool normalize) +{ + double *fg=new double[(size+1)/2] ; + vpImageFilter::getGaussianKernel(fg, size, sigma, normalize) ; + vpImage<double> GIx ; + vpImageFilter::filterX(I, GIx,fg,size); + vpImageFilter::filterY(GIx, GI,fg,size); + GIx.destroy(); + delete[] fg; +} + +/*! + Return the coefficients of a Gaussian filter. + + \param filter : Pointer to the filter kernel that should refer to a (size+1)/2 array. + The first value refers to the central coefficient, the next one to the right coefficients. Left coefficients could be deduced by symmetry. + \param size : Filter size. This value should be odd. + \param sigma : Gaussian standard deviation. If it is equal to zero or negative, it is computed from filter size as sigma = (size-1)/6. + \param normalize : Flag indicating whether to normalize the filter coefficients or not. +*/ +void vpImageFilter::getGaussianKernel(double *filter, unsigned int size, double sigma, bool normalize) +{ + if (size%2 != 1) + throw (vpImageException(vpImageException::incorrectInitializationError, + "Bad Gaussian filter size")); + + if (sigma<= 0) + sigma = (size-1)/6.0; + + int middle = (int)(size-1)/2; + double sigma2 = vpMath::sqr(sigma); + for( int i=0; i<= middle; i++) + { + filter[i] = (1./(sigma*sqrt(2.*M_PI)))*exp(-(i*i)/(2.*sigma2)); + } + if (normalize) { + //renormalization + double sum=0; + for(int i=1; i<=middle; i++) + { + sum += 2*filter[i] ; + } + sum += filter[0]; + + for(int i=0; i<=middle; i++) + { + filter[i] = filter[i]/sum; + } + } +} + +/*! + Return the coefficients of a Gaussian derivative filter that may be used to compute spatial image derivatives after applying a Gaussian blur. + + \param filter : Pointer to the filter kernel that should refer to a (size+1)/2 array. + The first value refers to the central coefficient, the next one to the right coefficients. Left coefficients could be deduced by symmetry. + \param size : Filter size. This value should be odd. + \param sigma : Gaussian standard deviation. If it is equal to zero or negative, it is computed from filter size as sigma = (size-1)/6. + \param normalize : Flag indicating whether to normalize the filter coefficients or not. +*/ +void vpImageFilter::getGaussianDerivativeKernel(double *filter, unsigned int size, double sigma, bool normalize) +{ + if (size%2 != 1) + throw (vpImageException(vpImageException::incorrectInitializationError, + "Bad Gaussian filter size")); + + if (sigma<= 0) + sigma = (size-1)/6.0; + + int middle = (int)(size-1)/2; + double sigma2 = vpMath::sqr(sigma); + filter[0] = 0.; + for(int i=1; i<= middle; i++) + { + filter[i] = -(1./(sigma*sqrt(2.*M_PI)))*(exp(-((i+1)*(i+1))/(2.*sigma2))-exp(-((i-1)*(i-1))/(2.*sigma2)))/2.; + } + + if (normalize) { + double sum=0; + for(int i=1; i<=middle; i++) + { + sum += 2.*(1./(sigma*sqrt(2.*M_PI)))*exp(-(i*i)/(2.*sigma2)); + } + sum += (1./(sigma*sqrt(2.*M_PI))) ; + + for(int i=1; i<=middle; i++) + { + filter[i] = filter[i]/sum; + } + } +} + + +void vpImageFilter::getGradX(const vpImage<unsigned char> &I, vpImage<double>& dIx) +{ + dIx.resize(I.getHeight(),I.getWidth()) ; + //dIx=0; + for (unsigned int i=0 ; i < I.getHeight() ; i++) + { + for (unsigned int j=0 ; j < 3 ; j++) + { + dIx[i][j]=0; + } + for (unsigned int j=3 ; j < I.getWidth()-3 ; j++) + { + dIx[i][j]=vpImageFilter::derivativeFilterX(I,i,j); + } + for (unsigned int j=I.getWidth()-3 ; j < I.getWidth() ; j++) + { + dIx[i][j]=0; + } + } +} + +void vpImageFilter::getGradY(const vpImage<unsigned char> &I, vpImage<double>& dIy) +{ + dIy.resize(I.getHeight(),I.getWidth()) ; + //dIy=0; + for (unsigned int i=0 ; i < 3 ; i++) + { + for (unsigned int j=0 ; j < I.getWidth() ; j++) + { + dIy[i][j]=0; + } + } + for (unsigned int i=3 ; i < I.getHeight()-3 ; i++) + { + for (unsigned int j=0 ; j < I.getWidth() ; j++) + { + dIy[i][j]=vpImageFilter::derivativeFilterY(I,i,j); + } + } + for (unsigned int i=I.getHeight()-3 ; i < I.getHeight() ; i++) + { + for (unsigned int j=0 ; j < I.getWidth() ; j++) + { + dIy[i][j]=0; + } + } +} + +void vpImageFilter::getGradX(const vpImage<unsigned char> &I, vpImage<double>& dIx, const double *filter,unsigned int size) +{ + dIx.resize(I.getHeight(),I.getWidth()) ; + //#pragma omp parallel for + for (unsigned int i=0 ; i < I.getHeight() ; i++) + { + for (unsigned int j=0 ; j < (size-1)/2 ; j++) + { + dIx[i][j]=0; + } + for (unsigned int j=(size-1)/2 ; j < I.getWidth()-(size-1)/2 ; j++) + { + dIx[i][j]=vpImageFilter::derivativeFilterX(I,i,j,filter,size); + } + for (unsigned int j=I.getWidth()-(size-1)/2 ; j < I.getWidth() ; j++) + { + dIx[i][j]=0; + } + } +} +void vpImageFilter::getGradX(const vpImage<double> &I, vpImage<double>& dIx, const double *filter,unsigned int size) +{ + dIx.resize(I.getHeight(),I.getWidth()) ; + //dIx=0; + for (unsigned int i=0 ; i < I.getHeight() ; i++) + { + for (unsigned int j=0 ; j < (size-1)/2 ; j++) + { + dIx[i][j]=0; + } + for (unsigned int j=(size-1)/2 ; j < I.getWidth()-(size-1)/2 ; j++) + { + dIx[i][j]=vpImageFilter::derivativeFilterX(I,i,j,filter,size); + } + for (unsigned int j=I.getWidth()-(size-1)/2 ; j < I.getWidth() ; j++) + { + dIx[i][j]=0; + } + } +} + +void vpImageFilter::getGradY(const vpImage<unsigned char> &I, vpImage<double>& dIy, const double *filter,unsigned int size) +{ + dIy.resize(I.getHeight(),I.getWidth()) ; + //#pragma omp parallel for + for (unsigned int i=0 ; i < (size-1)/2 ; i++) + { + for (unsigned int j=0 ; j < I.getWidth() ; j++) + { + dIy[i][j]=0; + } + } + //#pragma omp parallel for + for (unsigned int i=(size-1)/2 ; i < I.getHeight()-(size-1)/2 ; i++) + { + for (unsigned int j=0 ; j < I.getWidth() ; j++) + { + dIy[i][j]=vpImageFilter::derivativeFilterY(I,i,j,filter,size); + } + } + //#pragma omp parallel for + for (unsigned int i=I.getHeight()-(size-1)/2 ; i < I.getHeight() ; i++) + { + for (unsigned int j=0 ; j < I.getWidth() ; j++) + { + dIy[i][j]=0; + } + } +} + +void vpImageFilter::getGradY(const vpImage<double> &I, vpImage<double>& dIy, const double *filter,unsigned int size) +{ + dIy.resize(I.getHeight(),I.getWidth()) ; + //dIy=0; + for (unsigned int i=0 ; i < (size-1)/2 ; i++) + { + for (unsigned int j=0 ; j < I.getWidth() ; j++) + { + dIy[i][j]=0; + } + } + for (unsigned int i=(size-1)/2 ; i < I.getHeight()-(size-1)/2 ; i++) + { + for (unsigned int j=0 ; j < I.getWidth() ; j++) + { + dIy[i][j]=vpImageFilter::derivativeFilterY(I,i,j,filter,size); + } + } + for (unsigned int i=I.getHeight()-(size-1)/2 ; i < I.getHeight() ; i++) + { + for (unsigned int j=0 ; j < I.getWidth() ; j++) + { + dIy[i][j]=0; + } + } +} + +/*! + Compute the gradient along X after applying a gaussian filter along Y. + \param I : Input image + \param dIx : Gradient along X. + \param gaussianKernel : Gaussian kernel which values should be computed using vpImageFilter::getGaussianKernel(). + \param gaussianDerivativeKernel : Gaussian derivative kernel which values should be computed using vpImageFilter::getGaussianDerivativeKernel(). + \param size : Size of the Gaussian and Gaussian derivative kernels. + */ +void vpImageFilter::getGradXGauss2D(const vpImage<unsigned char> &I, vpImage<double>& dIx, const double *gaussianKernel, const double *gaussianDerivativeKernel, unsigned int size) +{ + vpImage<double> GIy; + vpImageFilter::filterY(I, GIy, gaussianKernel, size); + vpImageFilter::getGradX(GIy, dIx, gaussianDerivativeKernel, size); +} + +/*! + Compute the gradient along Y after applying a gaussian filter along X. + \param I : Input image + \param dIy : Gradient along Y. + \param gaussianKernel : Gaussian kernel which values should be computed using vpImageFilter::getGaussianKernel(). + \param gaussianDerivativeKernel : Gaussian derivative kernel which values should be computed using vpImageFilter::getGaussianDerivativeKernel(). + \param size : Size of the Gaussian and Gaussian derivative kernels. + */ +void vpImageFilter::getGradYGauss2D(const vpImage<unsigned char> &I, vpImage<double>& dIy, const double *gaussianKernel, const double *gaussianDerivativeKernel,unsigned int size) +{ + vpImage<double> GIx; + vpImageFilter::filterX(I, GIx, gaussianKernel, size); + vpImageFilter::getGradY(GIx, dIy, gaussianDerivativeKernel, size); +} + +//operation pour pyramide gaussienne +void vpImageFilter::getGaussPyramidal(const vpImage<unsigned char> &I, vpImage<unsigned char>& GI) +{ + vpImage<unsigned char> GIx; +#ifdef VISP_HAVE_OPENCV + IplImage* imgsrc = NULL;//cvCreateImage(cvGetSize(imgign), IPL_DEPTH_8U, 1); + IplImage* imgdest = NULL;//cvCreateImage(cvGetSize(imgign), IPL_DEPTH_8U, 1); + imgsrc = cvCreateImage(cvSize((int)I.getWidth(),(int)I.getHeight()), IPL_DEPTH_8U, 1); + imgdest = cvCreateImage(cvSize((int)I.getWidth()/2,(int)I.getHeight()/2), IPL_DEPTH_8U, 1); + vpImageConvert::convert(I,imgsrc); + cvPyrDown( imgsrc, imgdest); + vpImageConvert::convert(imgdest,GI); + + cvReleaseImage(&imgsrc); + cvReleaseImage(&imgdest); + //vpImage<unsigned char> sGI;sGI=GI; + +#else + vpImageFilter::getGaussXPyramidal(I,GIx); + vpImageFilter::getGaussYPyramidal(GIx,GI); +#endif +} + +void vpImageFilter::getGaussXPyramidal(const vpImage<unsigned char> &I, vpImage<unsigned char>& GI) +{ +#if 0 + GI.resize(I.getHeight(),(int)((I.getWidth()+1.)/2.)) ; + for (unsigned int i=0 ; i < I.getHeight() ; i++) + { + GI[i][0]=I[i][0]; + for (unsigned int j=1 ; j < ((I.getWidth()+1.)/2.)-1 ; j++) + { + GI[i][j]=vpImageFilter::filterGaussXPyramidal(I,i,2*j); + } + GI[i][(int)((I.getWidth()+1.)/2.)-1]=I[i][2*((int)((I.getWidth()+1.)/2.)-1)]; + } +#else + unsigned int w = I.getWidth()/2; + + GI.resize(I.getHeight(), w) ; + for (unsigned int i=0 ; i < I.getHeight() ; i++) + { + GI[i][0]=I[i][0]; + for (unsigned int j=1 ; j < w-1 ; j++) + { + GI[i][j]=vpImageFilter::filterGaussXPyramidal(I,i,2*j); + } + GI[i][w-1]=I[i][2*w-1]; + } + +#endif +} +void vpImageFilter::getGaussYPyramidal(const vpImage<unsigned char> &I, vpImage<unsigned char>& GI) +{ + +#ifdef ORIG + GI.resize((int)((I.getHeight()+1.)/2.),I.getWidth()) ; + for (unsigned int j=0 ; j < I.getWidth() ; j++) + { + GI[0][j]=I[0][j]; + for (unsigned int i=1 ; i < ((I.getHeight()+1.)/2.)-1 ; i++) + { + GI[i][j]=vpImageFilter::filterGaussYPyramidal(I,2*i,j); + } + GI[(int)((I.getHeight()+1.)/2.)-1][j]=I[2*((int)((I.getHeight()+1.)/2.)-1)][j]; + } + +#else + unsigned int h = I.getHeight()/2; + + GI.resize(h, I.getWidth()) ; + for (unsigned int j=0 ; j < I.getWidth() ; j++) + { + GI[0][j]=I[0][j]; + for (unsigned int i=1 ; i < h-1 ; i++) + { + GI[i][j]=vpImageFilter::filterGaussYPyramidal(I,2*i,j); + } + GI[h-1][j]=I[2*h-1][j]; + } +#endif +} + + diff --git a/src/image/vpImageFilter.h b/src/image/vpImageFilter.h index db72daa6007525487b5fb1dddadb9cc745d57857..cb8c9cf6f2a20c776bba6baa6afa28174074c4e5 100644 --- a/src/image/vpImageFilter.h +++ b/src/image/vpImageFilter.h @@ -1,10 +1,10 @@ /**************************************************************************** * - * $Id: vpImageFilter.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpImageFilter.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. - * + * Copyright (C) 2005 - 2014 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. @@ -12,11 +12,11 @@ * 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 + * 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 @@ -26,7 +26,7 @@ * * 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. * @@ -72,16 +72,6 @@ class VISP_EXPORT vpImageFilter { public: - static void filter(const vpImage<double> &I, - vpImage<double>& Iu, - vpImage<double>& Iv, - const vpMatrix& M) ; - - - static void filter(const vpImage<unsigned char> &I, - vpImage<double>& If, - const vpMatrix& M) ; - #if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100) static void canny(const vpImage<unsigned char>& I, vpImage<unsigned char>& Ic, @@ -91,161 +81,368 @@ public: #endif /*! - Apply a 5x5 Gaussian filter to an image pixel. + Apply a 1x3 derivative filter to an image pixel. - \param fr : Image to filter - \param r : coordinates (row) of the pixel + \param I : Image to filter + \param r: coordinates (row) of the pixel \param c : coordinates (column) of the pixel */ template<class T> - static double - gaussianFilter(vpImage<T> & fr, - const unsigned int r, const unsigned int c) + static double derivativeFilterX(const vpImage<T> &I, + const unsigned int r, const unsigned int c) { - //filter Gaussien - return ( - 15.0 * fr[r][c] - + 12.0 * ( fr[r-1][c] + fr[r][c-1] + fr[r+1][c] + fr[r][c+1] ) - + 9.0 * ( fr[r-1][c-1] + fr[r+1][c-1] + fr[r-1][c+1] + fr[r+1][c+1]) - + 5.0 * ( fr[r-2][c] + fr[r][c-2] + fr[r+2][c] + fr[r][c+2] ) - + 4.0 * ( fr[r-2][c+1] + fr[r-2][c-1] + fr[r-1][c-2] + fr[r+1][c-2] + - fr[r+2][c-1] + fr[r+2][c+1] + fr[r-1][c+2] + fr[r+1][c+2] ) - + 2.0 * ( fr[r-2][c-2] + fr[r+2][c-2] + fr[r-2][c+2] + fr[r+2][c+2] ) - ) - /159.0; + return (2047.0 *(I[r][c+1] - I[r][c-1]) + +913.0 *(I[r][c+2] - I[r][c-2]) + +112.0 *(I[r][c+3] - I[r][c-3]))/8418.0; } - - /*! - Apply a 1x3 Derivative Filter to an image pixel. + Apply a 3x1 derivative filter to an image pixel. - \param fr : Image to filter - \param r: coordinates (row) of the pixel + \param I : Image to filter + \param r : coordinates (row) of the pixel \param c : coordinates (column) of the pixel */ template<class T> - static double - derivativeFilterX(vpImage<T> & fr, - const unsigned int r, const unsigned int c) + static double derivativeFilterY(const vpImage<T> &I, + const unsigned int r, const unsigned int c) { - return (2047.0 *(fr[r][c+1] - fr[r][c-1]) - +913.0 *(fr[r][c+2] - fr[r][c-2]) - +112.0 *(fr[r][c+3] - fr[r][c-3]))/8418.0; + return (2047.0 *(I[r+1][c] - I[r-1][c]) + +913.0 *(I[r+2][c] - I[r-2][c]) + +112.0 *(I[r+3][c] - I[r-3][c]))/8418.0; } /*! - Apply a 3x1 Derivative Filter to an image pixel. + Apply a 1 x size Derivative Filter in X to an image pixel. - \param fr : Image to filter + \param I : Image to filter \param r : coordinates (row) of the pixel \param c : coordinates (column) of the pixel + \param filter : coefficients of the filter to be initialized using vpImageFilter::getGaussianDerivativeKernel(). + \param size : size of the filter + + \sa vpImageFilter::getGaussianDerivativeKernel() */ + template<class T> - static double - derivativeFilterY(vpImage<T> & fr, - const unsigned int r, const unsigned int c) + static double derivativeFilterX(const vpImage<T> &I, + const unsigned int r, const unsigned int c, + const double *filter, const unsigned int size) { - return (2047.0 *(fr[r+1][c] - fr[r-1][c]) - +913.0 *(fr[r+2][c] - fr[r-2][c]) - +112.0 *(fr[r+3][c] - fr[r-3][c]))/8418.0; + unsigned int i; + double result; + + result = 0; + + for(i=1; i<=(size-1)/2; i++) + { + result += filter[i]*(I[r][c+i] - I[r][c-i]) ; + } + return result; } + + /*! - build a Gaussian Derivative filter + Apply a size x 1 Derivative Filter in Y to an image pixel. - \param filter : array (of size t/2) that contains the filter - \param t : size of the filter + \param I : Image to filter + \param r : coordinates (row) of the pixel + \param c : coordinates (column) of the pixel + \param filter : coefficients of the filter to be initialized using vpImageFilter::getGaussianDerivativeKernel(). + \param size : size of the filter - \warning filter has to be deallocated + \sa vpImageFilter::getGaussianDerivativeKernel() */ - static void - coefficientGaussianDerivative(double *filter, const unsigned int t) + template<class T> + static double derivativeFilterY(const vpImage<T> &I, + const unsigned int r, const unsigned int c, + const double *filter, const unsigned int size) { unsigned int i; - // double sigma; - if (filter == NULL) - filter = new double[t/2] ; + double result; - double s2 = vpMath::sqr((t-1)/6.0); + result = 0; - for(i=1; i<=(t-1)/2; i++) + for(i=1; i<=(size-1)/2; i++) { - filter[i] = (i/(s2*sqrt(2*M_PI)))*exp((i*i)/(-2*s2)); + result += filter[i]*(I[r+i][c] - I[r-i][c]) ; + } + return result; + } + + static void filter(const vpImage<double> &I, + vpImage<double>& Iu, + vpImage<double>& Iv, + const vpMatrix& M) ; + + + static void filter(const vpImage<unsigned char> &I, + vpImage<double>& If, + const vpMatrix& M) ; + + + static void filter(const vpImage<unsigned char> &I, vpImage<double>& GI, const double *filter,unsigned int size); + static void filter(const vpImage<double> &I, vpImage<double>& GI, const double *filter,unsigned int size); + + static inline unsigned char filterGaussXPyramidal(const vpImage<unsigned char> &I, unsigned int i, unsigned int j) + { + return (unsigned char)((1.*I[i][j-2]+4.*I[i][j-1]+6.*I[i][j]+4.*I[i][j+1]+1.*I[i][j+2])/16.); + } + static inline unsigned char filterGaussYPyramidal(const vpImage<unsigned char> &I, unsigned int i, unsigned int j) + { + return (unsigned char)((1.*I[i-2][j]+4.*I[i-1][j]+6.*I[i][j]+4.*I[i+1][j]+1.*I[i+2][j])/16.); + } + + static void filterX(const vpImage<unsigned char> &I, vpImage<double>& dIx, const double *filter,unsigned int size); + static void filterX(const vpImage<double> &I, vpImage<double>& dIx, const double *filter,unsigned int size); + static inline double filterX(const vpImage<unsigned char> &I, + unsigned int r, unsigned int c, + const double *filter,unsigned int size) + { + double result; + + result = 0; + + for(unsigned int i=1; i<=(size-1)/2; i++) + { + result += filter[i]*(I[r][c+i] + I[r][c-i]) ; } + return result+filter[0]*I[r][c]; + } + + + static inline double filterXLeftBorder(const vpImage<unsigned char> &I, + unsigned int r, unsigned int c, + const double *filter,unsigned int size) + { + double result; + + result = 0; + for(unsigned int i=1; i<=(size-1)/2; i++) + { + if(c>i) + result += filter[i]*(I[r][c+i] + I[r][c-i]) ; + else + result += filter[i]*(I[r][c+i] + I[r][i-c]) ; + } + return result+filter[0]*I[r][c]; } + static inline double filterXRightBorder(const vpImage<unsigned char> &I, + unsigned int r, unsigned int c, + const double *filter,unsigned int size) + { + double result; - /*! - Apply a 1 x size Derivative Filter in X to an image pixel. + result = 0; - \param I : Image to filter - \param r : coordinates (row) of the pixel - \param c : coordinates (column) of the pixel - \param filter : coefficients of the filter to be initialized using vpImageFilter::coefficientGaussianDerivative(). - \param size : size of the filter + for(unsigned int i=1; i<=(size-1)/2; i++) + { + if(c+i<I.getWidth()) + result += filter[i]*(I[r][c+i] + I[r][c-i]) ; + else + result += filter[i]*(I[r][2*I.getWidth()-c-i-1] + I[r][c-i]) ; + } + return result+filter[0]*I[r][c]; + } - \sa vpImageFilter::coefficientGaussianDerivative() - */ + static inline double filterX(const vpImage<double> &I, + unsigned int r, unsigned int c, + const double *filter,unsigned int size) + { + double result; - template<class T> - static double - derivativeFilterX(vpImage<T> &I, - const unsigned int r, const unsigned int c, - double *filter, const unsigned int size) + result = 0; + + for(unsigned int i=1; i<=(size-1)/2; i++) + { + result += filter[i]*(I[r][c+i] + I[r][c-i]) ; + } + return result+filter[0]*I[r][c]; + } + + static inline double filterXLeftBorder(const vpImage<double> &I, + unsigned int r, unsigned int c, + const double *filter,unsigned int size) { - unsigned int i; - double result; + double result; - result = 0; + result = 0; - for(i=1; i<=(size-1)/2; i++) - { - result += filter[i]*(I[r][c+i] - I[r][c-i]) ; - } - return result; + for(unsigned int i=1; i<=(size-1)/2; i++) + { + if(c>i) + result += filter[i]*(I[r][c+i] + I[r][c-i]) ; + else + result += filter[i]*(I[r][c+i] + I[r][i-c]) ; + } + return result+filter[0]*I[r][c]; } + static inline double filterXRightBorder(const vpImage<double> &I, + unsigned int r, unsigned int c, + const double *filter,unsigned int size) + { + double result; + result = 0; + for(unsigned int i=1; i<=(size-1)/2; i++) + { + if(c+i<I.getWidth()) + result += filter[i]*(I[r][c+i] + I[r][c-i]) ; + else + result += filter[i]*(I[r][2*I.getWidth()-c-i-1] + I[r][c-i]) ; + } + return result+filter[0]*I[r][c]; + } + + static void filterY(const vpImage<unsigned char> &I, vpImage<double>& dIx, const double *filter,unsigned int size); + static void filterY(const vpImage<double> &I, vpImage<double>& dIx, const double *filter,unsigned int size); + static inline double filterY(const vpImage<unsigned char> &I, + unsigned int r, unsigned int c, + const double *filter,unsigned int size) + { + double result; + + result = 0; + + for(unsigned int i=1; i<=(size-1)/2; i++) + { + result += filter[i]*(I[r+i][c] + I[r-i][c]) ; + } + return result+filter[0]*I[r][c]; + } + + double static inline filterYTopBorder(const vpImage<unsigned char> &I, unsigned int r, unsigned int c, const double *filter,unsigned int size) + { + double result; + + result = 0; + + for(unsigned int i=1; i<=(size-1)/2; i++) + { + if(r>i) + result += filter[i]*(I[r+i][c] + I[r-i][c]) ; + else + result += filter[i]*(I[r+i][c] + I[i-r][c]) ; + } + return result+filter[0]*I[r][c]; + } + + double static inline filterYBottomBorder(const vpImage<unsigned char> &I, unsigned int r, unsigned int c, const double *filter,unsigned int size) + { + double result; + + result = 0; + + for(unsigned int i=1; i<=(size-1)/2; i++) + { + if(r+i<I.getHeight()) + result += filter[i]*(I[r+i][c] + I[r-i][c]) ; + else + result += filter[i]*(I[2*I.getHeight()-r-i-1][c] + I[r-i][c]) ; + } + return result+filter[0]*I[r][c]; + } + + static inline double filterYTopBorder(const vpImage<double> &I, unsigned int r, unsigned int c, const double *filter,unsigned int size) + { + double result; + + result = 0; + + for(unsigned int i=1; i<=(size-1)/2; i++) + { + if(r>i) + result += filter[i]*(I[r+i][c] + I[r-i][c]) ; + else + result += filter[i]*(I[r+i][c] + I[i-r][c]) ; + } + return result+filter[0]*I[r][c]; + } + + static inline double filterYBottomBorder(const vpImage<double> &I, unsigned int r, unsigned int c, const double *filter,unsigned int size) + { + double result; + + result = 0; + + for(unsigned int i=1; i<=(size-1)/2; i++) + { + if(r+i<I.getHeight()) + result += filter[i]*(I[r+i][c] + I[r-i][c]) ; + else + result += filter[i]*(I[2*I.getHeight()-r-i-1][c] + I[r-i][c]) ; + } + return result+filter[0]*I[r][c]; + } + + static inline double filterY(const vpImage<double> &I, + unsigned int r, unsigned int c, + const double *filter,unsigned int size) + { + double result; + + result = 0; + + for(unsigned int i=1; i<=(size-1)/2; i++) + { + result += filter[i]*(I[r+i][c] + I[r-i][c]) ; + } + return result+filter[0]*I[r][c]; + } + + static void gaussianBlur(const vpImage<unsigned char> &I, vpImage<double>& GI, unsigned int size=7, double sigma=0., bool normalize=true); /*! - Apply a size x 1 Derivative Filter in Y to an image pixel. + Apply a 5x5 Gaussian filter to an image pixel. - \param I : Image to filter + \param fr : Image to filter \param r : coordinates (row) of the pixel \param c : coordinates (column) of the pixel - \param filter : coefficients of the filter to be initialized using vpImageFilter::coefficientGaussianDerivative(). - \param size : size of the filter - - \sa vpImageFilter::coefficientGaussianDerivative() */ template<class T> - static double - derivativeFilterY(vpImage<T> &I, - const unsigned int r, const unsigned int c, - double *filter, const unsigned int size) + static double gaussianFilter(const vpImage<T> & fr, + const unsigned int r, const unsigned int c) { - unsigned int i; - double result; - - result = 0; - - for(i=1; i<=(size-1)/2; i++) - { - result += filter[i]*(I[r+i][c] - I[r-i][c]) ; - } - return result; + //filter Gaussien + return ( + 15.0 * fr[r][c] + + 12.0 * ( fr[r-1][c] + fr[r][c-1] + fr[r+1][c] + fr[r][c+1] ) + + 9.0 * ( fr[r-1][c-1] + fr[r+1][c-1] + fr[r-1][c+1] + fr[r+1][c+1]) + + 5.0 * ( fr[r-2][c] + fr[r][c-2] + fr[r+2][c] + fr[r][c+2] ) + + 4.0 * ( fr[r-2][c+1] + fr[r-2][c-1] + fr[r-1][c-2] + fr[r+1][c-2] + + fr[r+2][c-1] + fr[r+2][c+1] + fr[r-1][c+2] + fr[r+1][c+2] ) + + 2.0 * ( fr[r-2][c-2] + fr[r+2][c-2] + fr[r-2][c+2] + fr[r+2][c+2] ) + ) + /159.0; } + //operation pour pyramide gaussienne + static void getGaussPyramidal(const vpImage<unsigned char> &I, vpImage<unsigned char>& GI); + static void getGaussXPyramidal(const vpImage<unsigned char> &I, vpImage<unsigned char>& GI); + static void getGaussYPyramidal(const vpImage<unsigned char> &I, vpImage<unsigned char>& GI); + + static void getGaussianKernel(double *filter, unsigned int size, double sigma=0., bool normalize=true); + static void getGaussianDerivativeKernel(double *filter, unsigned int size, double sigma=0., bool normalize=true); + + //fonction renvoyant le gradient en X de l'image I pour traitement pyramidal => dimension /2 + static void getGradX(const vpImage<unsigned char> &I, vpImage<double>& dIx); + static void getGradX(const vpImage<unsigned char> &I, vpImage<double>& dIx, const double *filter, unsigned int size); + static void getGradX(const vpImage<double> &I, vpImage<double>& dIx, const double *filter, unsigned int size); + static void getGradXGauss2D(const vpImage<unsigned char> &I, vpImage<double>& dIx, const double *gaussianKernel, + const double *gaussianDerivativeKernel, unsigned int size); + + //fonction renvoyant le gradient en Y de l'image I + static void getGradY(const vpImage<unsigned char> &I, vpImage<double>& dIy); + static void getGradY(const vpImage<unsigned char> &I, vpImage<double>& dIy, const double *filter, unsigned int size); + static void getGradY(const vpImage<double> &I, vpImage<double>& dIy, const double *filter, unsigned int size); + static void getGradYGauss2D(const vpImage<unsigned char> &I, vpImage<double>& dIy, const double *gaussianKernel, + const double *gaussianDerivativeKernel,unsigned int size); + } ; #endif - - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ diff --git a/src/image/vpImageIo.cpp b/src/image/vpImageIo.cpp index e93254ac936c14f45ce6c8e43ef4b0e8b665df14..c02bd4b83db1c0aafbc93246b0419a07d087a173 100644 --- a/src/image/vpImageIo.cpp +++ b/src/image/vpImageIo.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpImageIo.cpp 4315 2013-07-16 20:32:52Z fspindle $ + * $Id: vpImageIo.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -47,6 +47,7 @@ #include <visp/vpImage.h> #include <visp/vpImageIo.h> #include <visp/vpImageConvert.h> //image conversion +#include <visp/vpIoTools.h> const int vpImageIo::vpMAX_LEN = 100; @@ -276,6 +277,11 @@ std::string vpImageIo::getExtension(const std::string &filename) void vpImageIo::read(vpImage<unsigned char> &I, const char *filename) { + bool exist = vpIoTools::checkFilename(filename); + if (!exist) { + std::string message = "Cannot read file: \"" + std::string(filename) + "\" doesn't exist"; + throw (vpImageException(vpImageException::ioError, message)); + } bool try_opencv_reader = false; switch(getFormat(filename)){ @@ -314,9 +320,8 @@ vpImageIo::read(vpImage<unsigned char> &I, const char *filename) cv::Mat cvI = cv::imread(filename, CV_LOAD_IMAGE_GRAYSCALE); vpImageConvert::convert(cvI, I); #else - vpCERROR << "Cannot read file: Image format not supported..." << std::endl; - throw (vpImageException(vpImageException::ioError, - "Cannot read file: Image format not supported")) ; + std::string message = "Cannot read file \"" + std::string(filename) + "\": Image format not supported"; + throw (vpImageException(vpImageException::ioError, message)) ; #endif } } @@ -360,6 +365,12 @@ vpImageIo::read(vpImage<unsigned char> &I, const std::string filename) void vpImageIo::read(vpImage<vpRGBa> &I, const char *filename) { + bool exist = vpIoTools::checkFilename(filename); + if (!exist) { + std::string message = "Cannot read file: \"" + std::string(filename) + "\" doesn't exist"; + throw (vpImageException(vpImageException::ioError, message)); + } + bool try_opencv_reader = false; switch(getFormat(filename)){ @@ -398,9 +409,8 @@ vpImageIo::read(vpImage<vpRGBa> &I, const char *filename) cv::Mat cvI = cv::imread(filename, CV_LOAD_IMAGE_COLOR); vpImageConvert::convert(cvI, I); #else - vpCERROR << "Cannot read file: Image format not supported..." << std::endl; - throw (vpImageException(vpImageException::ioError, - "Cannot read file: Image format not supported")) ; + std::string message = "Cannot read file \"" + std::string(filename) + "\": Image format not supported"; + throw (vpImageException(vpImageException::ioError, message)) ; #endif } } @@ -774,9 +784,9 @@ vpImageIo::writePGM(const vpImage<vpRGBa> &I, const char *filename) } /*! - Read a PGM P5 file and initialize a scalar image. + Read a PFM P8 file and initialize a float image. - Read the contents of the portable gray pixmap (PGM P5) filename, allocate + Read the contents of the portable gray pixmap (PFM P8) filename, allocate memory for the corresponding image, and set the bitmap whith the content of the file. @@ -818,7 +828,7 @@ vpImageIo::readPFM(vpImage<float> &I, const char *filename) "couldn't read file")) ; } - // Read the first line with magic number P5 + // Read the first line with magic number P8 line = 0; err = fgets(str, vpMAX_LEN - 1, fd); @@ -834,9 +844,9 @@ vpImageIo::readPFM(vpImage<float> &I, const char *filename) if (strlen(str) < 3) { fclose (fd); - vpERROR_TRACE("\"%s\" is not a PGM file\n", filename) ; + vpERROR_TRACE("\"%s\" is not a PFM file\n", filename) ; throw (vpImageException(vpImageException::ioError, - "this is not a pfm file")) ; + "this is not a PFM file")) ; } str[2] = '\0'; @@ -845,7 +855,7 @@ vpImageIo::readPFM(vpImage<float> &I, const char *filename) fclose (fd); vpERROR_TRACE("\"%s\" is not a PFM file\n", filename) ; throw (vpImageException(vpImageException::ioError, - "this is not a pgm file")) ; + "this is not a PFM file")) ; } // Jump the possible comment, or empty line and read the following line @@ -855,11 +865,18 @@ vpImageIo::readPFM(vpImage<float> &I, const char *filename) if (err == NULL) { fprintf(stderr, "couldn't read line %d of file \"%s\"\n", line, filename); fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read content of PFM file")) ; } } while ((str[0] == '#') || (str[0] == '\n')); // Extract image size ierr = sscanf(str, "%d %d", &w, &h); + if (w > 100000 || h>100000) { + fclose (fd); + throw(vpException(vpException::badValue, "Bad image size")); + } + if(ierr == 1){// the norm allows to have the two values on two separated lines. do { err = fgets(str, vpMAX_LEN - 1, fd); @@ -867,6 +884,8 @@ vpImageIo::readPFM(vpImage<float> &I, const char *filename) if (err == NULL) { fprintf(stderr, "couldn't read line %d of file \"%s\"\n", line, filename); fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read content of PFM file")) ; } } while ((str[0] == '#') || (str[0] == '\n')); ierr = sscanf(str, "%d", &h); @@ -876,20 +895,20 @@ vpImageIo::readPFM(vpImage<float> &I, const char *filename) fclose (fd); vpERROR_TRACE("couldn't read line %d of file \"%s\"\n",line, filename) ; throw (vpImageException(vpImageException::ioError, - "couldn't read file")) ; + "Cannot read content of PFM file")) ; } if ((h != I.getHeight())||( w != I.getWidth())) { - try { I.resize(h,w) ; } catch(...) { - vpERROR_TRACE(" ") ; - throw ; + fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read content of PFM file")) ; } } @@ -900,7 +919,7 @@ vpImageIo::readPFM(vpImage<float> &I, const char *filename) fclose (fd); vpERROR_TRACE("couldn't read line %d of file \"%s\"\n",line, filename) ; throw (vpImageException(vpImageException::ioError, - "couldn't read file")) ; + "Cannot read content of PFM file")) ; } ierr = sscanf(str, "%d", &is255); @@ -908,7 +927,7 @@ vpImageIo::readPFM(vpImage<float> &I, const char *filename) fclose (fd); vpERROR_TRACE("couldn't read line %d of file \"%s\"\n", line, filename) ; throw (vpImageException(vpImageException::ioError, - "couldn't read file")) ; + "Cannot read content of PFM file")) ; } if (is255 != 255) @@ -916,7 +935,7 @@ vpImageIo::readPFM(vpImage<float> &I, const char *filename) fclose (fd); vpERROR_TRACE("MAX_VAL is not 255 in file \"%s\"\n", filename) ; throw (vpImageException(vpImageException::ioError, - "error reading pfm file")) ; + "Cannot read content of PFM file")) ; } unsigned int nbyte = I.getHeight()*I.getWidth(); @@ -925,12 +944,10 @@ vpImageIo::readPFM(vpImage<float> &I, const char *filename) fclose (fd); vpERROR_TRACE("couldn't read %d bytes in file \"%s\"\n", nbyte, filename) ; throw (vpImageException(vpImageException::ioError, - "error reading pfm file")) ; + "Cannot read content of PFM file")) ; } fclose (fd); - - } @@ -956,143 +973,189 @@ vpImageIo::readPGM(vpImage<unsigned char> &I, const char *filename) { FILE* fd = NULL; // File descriptor int ierr; - int line; - int is255; char* err ; char str[vpMAX_LEN]; - unsigned int w, h; + unsigned int magic=5, w=0, h=0, maxval=255; // Test the filename - if (filename == '\0') - { - vpERROR_TRACE("no filename") ; + if (filename == '\0') { throw (vpImageException(vpImageException::ioError, - " no filename")) ; - + "No filename")) ; } // Open the filename - fd = fopen(filename, "rb"); - if (fd == NULL) - { - vpERROR_TRACE("couldn't read file \"%s\"", filename) ; + if ((fd = fopen(filename, "rb")) == NULL) { throw (vpImageException(vpImageException::ioError, - "couldn't read file")) ; + "Cannot read file \"%s\"", filename)) ; } - // Read the first line with magic number P5 - line = 0; - - err = fgets(str, vpMAX_LEN - 1, fd); - line++; - if (err == NULL) - { + while ((err = fgets(str, vpMAX_LEN - 1, fd)) != NULL && ((str[0] == '#') || (str[0] == '\n'))) {}; + if (err == NULL) { fclose (fd); - vpERROR_TRACE("couldn't read line %d of file \"%s\"\n", line, filename) ; throw (vpImageException(vpImageException::ioError, - "couldn't read file")) ; + "Cannot read header of file \"%s\"", filename)); } - - if (strlen(str) < 3) - { + if ((ierr = sscanf(str, "P%u %u %u %u", &magic, &w, &h, &maxval)) == 0) { fclose (fd); - vpERROR_TRACE("\"%s\" is not a PGM file\n", filename) ; throw (vpImageException(vpImageException::ioError, - "this is not a pgm file")) ; + "Cannot read header of file \"%s\"", filename)); } - str[2] = '\0'; - if (strcmp(str, "P5") != 0) - { + if (magic != 5) { fclose (fd); - vpERROR_TRACE("\"%s\" is not a PGM file\n", filename) ; throw (vpImageException(vpImageException::ioError, - "this is not a pgm file")) ; + "\"%s\" is not a PGM P5 file", filename)); } - // Jump the possible comment, or empty line and read the following line - do { - err = fgets(str, vpMAX_LEN - 1, fd); - line++; + // Depending on ierr the line may contain: + // 1 : P5 + // 2 : P5 w + // 3 : P5 w h + // 4 : P5 w h maxval + + if (ierr == 1) { +// std::cout << "magic: " << magic << std::endl; + while ((err = fgets(str, vpMAX_LEN - 1, fd)) != NULL && ((str[0] == '#') || (str[0] == '\n'))) {}; if (err == NULL) { - fprintf(stderr, "couldn't read line %d of file \"%s\"\n", line, filename); fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); } - } while ((str[0] == '#') || (str[0] == '\n')); + if (((ierr = sscanf(str, "%u %u %u", &w, &h, &maxval)) == 0) || (ierr != 1 && ierr != 2 && ierr != 3)) { + fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); + } + // Depending on ierr the line may contain: + // 1 : w + // 2 : w h + // 3 : w h maxval + if (ierr == 1) { +// std::cout << "w: " << w << std::endl; + while ((err = fgets(str, vpMAX_LEN - 1, fd)) != NULL && ((str[0] == '#') || (str[0] == '\n'))) {}; + if (err == NULL) { + fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); + } + if (((ierr = sscanf(str, "%u %u", &h, &maxval)) == 0) || (ierr != 1 && ierr != 2)) { + fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); + } + if (ierr == 1) { +// std::cout << "h: " << h << std::endl; + while ((err = fgets(str, vpMAX_LEN - 1, fd)) != NULL && ((str[0] == '#') || (str[0] == '\n'))) {}; + if (err == NULL) { + fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); + } + if ((ierr = sscanf(str, "%u", &maxval)) != 1) { + fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); + } + } +// else { +// std::cout << "h: " << h << " maxval: " << maxval << std::endl; +// } + } + else if (ierr == 2) { +// std::cout << "w: " << w << " h: " << h << std::endl; - // Extract image size - ierr = sscanf(str, "%d %d", &w, &h); - if(ierr == 1){// the norm allows to have the two values on two separated lines. - do { - err = fgets(str, vpMAX_LEN - 1, fd); - line++; + while ((err = fgets(str, vpMAX_LEN - 1, fd)) != NULL && ((str[0] == '#') || (str[0] == '\n'))) {}; if (err == NULL) { - fprintf(stderr, "couldn't read line %d of file \"%s\"\n", line, filename); fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); } - } while ((str[0] == '#') || (str[0] == '\n')); - ierr = sscanf(str, "%d", &h); + if ((ierr = sscanf(str, "%u", &maxval)) != 1) { + fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); + } +// std::cout << "maxval: " << maxval << std::endl; + } +// else { +// std::cout << "w: " << w << " h: " << h << " maxval: " << maxval << std::endl; +// } } - if (ierr == EOF) - { - fclose (fd); - vpERROR_TRACE("couldn't read line %d of file \"%s\"\n",line, filename) ; - throw (vpImageException(vpImageException::ioError, - "couldn't read file")) ; + else if (ierr == 2) { +// std::cout << "magic: " << magic << " w: " << w << std::endl; + while ((err = fgets(str, vpMAX_LEN - 1, fd)) != NULL && ((str[0] == '#') || (str[0] == '\n'))) {}; + if (err == NULL) { + fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); + } + if (((ierr = sscanf(str, "%u %u", &h, &maxval)) == 0) || (ierr != 1 && ierr != 2)) { + fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); + } + if (ierr == 1) { +// std::cout << "h: " << h << std::endl; + while ((err = fgets(str, vpMAX_LEN - 1, fd)) != NULL && ((str[0] == '#') || (str[0] == '\n'))) {}; + if (err == NULL) { + fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); + } + if ((ierr = sscanf(str, "%u", &maxval)) != 1) { + fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); + } +// std::cout << "maxval: " << maxval << std::endl; + } +// else { +// std::cout << "h: " << h << " maxval: " << maxval << std::endl; +// } } - - if ((h != I.getHeight())||( w != I.getWidth())) - { - - try - { - I.resize(h,w) ; + else if (ierr == 3) { +// std::cout << "magic: " << magic << " w: " << w << " h: " << h << std::endl; + while ((err = fgets(str, vpMAX_LEN - 1, fd)) != NULL && ((str[0] == '#') || (str[0] == '\n'))) {}; + if (err == NULL) { + fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); } - catch(...) - { - vpERROR_TRACE(" ") ; - throw ; + if ((ierr = sscanf(str, "%u", &maxval)) != 1) { + fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); } +// std::cout << "maxval: " << maxval << std::endl; } +// else if (ierr == 4) { +// std::cout << "magic: " << magic << " w: " << w << " h: " << h << " maxval: " << maxval << std::endl; +// } - // Read 255 - err = fgets(str, vpMAX_LEN - 1, fd); - line++; - if (err == NULL) { + if (w > 100000 || h>100000) { fclose (fd); - vpERROR_TRACE("couldn't read line %d of file \"%s\"\n",line, filename) ; - throw (vpImageException(vpImageException::ioError, - "couldn't read file")) ; + throw(vpException(vpException::badValue, "Bad image size in \"%s\"", filename)); } - - ierr = sscanf(str, "%d", &is255); - if (ierr == EOF) { + if (maxval != 255) + { fclose (fd); - vpERROR_TRACE("couldn't read line %d of file \"%s\"\n", line, filename) ; throw (vpImageException(vpImageException::ioError, - "couldn't read file")) ; + "Bad maxval in \"%s\"", filename)); } - if (is255 != 255) - { - fclose (fd); - vpERROR_TRACE("MAX_VAL is not 255 in file \"%s\"\n", filename) ; - throw (vpImageException(vpImageException::ioError, - "error reading pgm file")) ; + if ((h != I.getHeight())||( w != I.getWidth())) { + I.resize(h,w) ; } unsigned int nbyte = I.getHeight()*I.getWidth(); - if (fread (I.bitmap, sizeof(unsigned char), nbyte, fd ) != nbyte) - { + size_t n; + if ((n = fread (I.bitmap, sizeof(unsigned char), nbyte, fd)) != nbyte) { fclose (fd); - vpERROR_TRACE("couldn't read %d bytes in file \"%s\"\n", nbyte, filename) ; throw (vpImageException(vpImageException::ioError, - "error reading pgm file")) ; + "Read only %d of %d bytes in file \"%s\"", n, nbyte, filename)); } fclose (fd); - - } @@ -1117,14 +1180,12 @@ vpImageIo::readPGM(vpImage<unsigned char> &I, const char *filename) void vpImageIo::readPGM(vpImage<vpRGBa> &I, const char *filename) { - try { vpImage<unsigned char> Itmp ; vpImageIo::readPGM(Itmp, filename) ; - vpImageConvert::convert(Itmp, I) ; } @@ -1190,132 +1251,180 @@ vpImageIo::readPPM(vpImage<unsigned char> &I, const char *filename) void vpImageIo::readPPM(vpImage<vpRGBa> &I, const char *filename) { - FILE* fd = NULL; // File descriptor int ierr; - int line; - int is255; char* err ; char str[vpMAX_LEN]; - unsigned int w, h; + unsigned int magic=5, w=0, h=0, maxval=255; // Test the filename - if (filename == '\0') - { - vpERROR_TRACE("no filename") ; + if (filename == '\0') { throw (vpImageException(vpImageException::ioError, - " no filename")) ; - + "No filename")) ; } // Open the filename - fd = fopen(filename, "rb"); - if (fd == NULL) - { - vpERROR_TRACE("couldn't read file \"%s\"", filename) ; + if ((fd = fopen(filename, "rb")) == NULL) { throw (vpImageException(vpImageException::ioError, - "couldn't read file")) ; + "Cannot read file \"%s\"", filename)) ; } - // Read the first line with magic number P5 - line = 0; - - err = fgets(str, vpMAX_LEN - 1, fd); - line++; - if (err == NULL) - { + while ((err = fgets(str, vpMAX_LEN - 1, fd)) != NULL && ((str[0] == '#') || (str[0] == '\n'))) {}; + if (err == NULL) { fclose (fd); - vpERROR_TRACE("couldn't read line %d of file \"%s\"\n", line, filename) ; throw (vpImageException(vpImageException::ioError, - "couldn't read file")) ; + "Cannot read header of file \"%s\"", filename)); } - - if (strlen(str) < 3) - { + if ((ierr = sscanf(str, "P%u %u %u %u", &magic, &w, &h, &maxval)) == 0) { fclose (fd); - vpERROR_TRACE("\"%s\" is not a PPM file\n", filename) ; throw (vpImageException(vpImageException::ioError, - "this is not a ppm file")) ; + "Cannot read header of file \"%s\"", filename)); } - str[2] = '\0'; - if (strcmp(str, "P6") != 0) - { + if (magic != 6) { fclose (fd); - vpERROR_TRACE("\"%s\" is not a PPM file\n", filename) ; throw (vpImageException(vpImageException::ioError, - "this is not a ppm file")) ; + "\"%s\" is not a PGM P6 file", filename)); } - // Jump the possible comment, or empty line and read the following line - do { - err = fgets(str, vpMAX_LEN - 1, fd); - line++; + // Depending on ierr the line may contain: + // 1 : P6 + // 2 : P6 w + // 3 : P6 w h + // 4 : P6 w h maxval + + if (ierr == 1) { +// std::cout << "magic: " << magic << std::endl; + while ((err = fgets(str, vpMAX_LEN - 1, fd)) != NULL && ((str[0] == '#') || (str[0] == '\n'))) {}; if (err == NULL) { - fprintf(stderr, "couldn't read line %d of file \"%s\"\n", line, filename); fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); } - } while ((str[0] == '#') || (str[0] == '\n')); + if (((ierr = sscanf(str, "%u %u %u", &w, &h, &maxval)) == 0) || (ierr != 1 && ierr != 2 && ierr != 3)) { + fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); + } + // Depending on ierr the line may contain: + // 1 : w + // 2 : w h + // 3 : w h maxval + if (ierr == 1) { +// std::cout << "w: " << w << std::endl; + while ((err = fgets(str, vpMAX_LEN - 1, fd)) != NULL && ((str[0] == '#') || (str[0] == '\n'))) {}; + if (err == NULL) { + fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); + } + if (((ierr = sscanf(str, "%u %u", &h, &maxval)) == 0) || (ierr != 1 && ierr != 2)) { + fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); + } + if (ierr == 1) { +// std::cout << "h: " << h << std::endl; + while ((err = fgets(str, vpMAX_LEN - 1, fd)) != NULL && ((str[0] == '#') || (str[0] == '\n'))) {}; + if (err == NULL) { + fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); + } + if ((ierr = sscanf(str, "%u", &maxval)) != 1) { + fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); + } + } +// else { +// std::cout << "h: " << h << " maxval: " << maxval << std::endl; +// } + } + else if (ierr == 2) { +// std::cout << "w: " << w << " h: " << h << std::endl; - // Extract image size - ierr = sscanf(str, "%d %d", &w, &h); - if(ierr == 1){// the norm allows to have the two values on two separated lines. - do { - err = fgets(str, vpMAX_LEN - 1, fd); - line++; + while ((err = fgets(str, vpMAX_LEN - 1, fd)) != NULL && ((str[0] == '#') || (str[0] == '\n'))) {}; if (err == NULL) { - fprintf(stderr, "couldn't read line %d of file \"%s\"\n", line, filename); fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); } - } while ((str[0] == '#') || (str[0] == '\n')); - ierr = sscanf(str, "%d", &h); + if ((ierr = sscanf(str, "%u", &maxval)) != 1) { + fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); + } +// std::cout << "maxval: " << maxval << std::endl; + } +// else { +// std::cout << "w: " << w << " h: " << h << " maxval: " << maxval << std::endl; +// } } - if (ierr == EOF) - { - fclose (fd); - vpERROR_TRACE("couldn't read line %d of file \"%s\"\n",line, filename) ; - throw (vpImageException(vpImageException::ioError, - "couldn't read file")) ; + else if (ierr == 2) { +// std::cout << "magic: " << magic << " w: " << w << std::endl; + while ((err = fgets(str, vpMAX_LEN - 1, fd)) != NULL && ((str[0] == '#') || (str[0] == '\n'))) {}; + if (err == NULL) { + fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); + } + if (((ierr = sscanf(str, "%u %u", &h, &maxval)) == 0) || (ierr != 1 && ierr != 2)) { + fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); + } + if (ierr == 1) { +// std::cout << "h: " << h << std::endl; + while ((err = fgets(str, vpMAX_LEN - 1, fd)) != NULL && ((str[0] == '#') || (str[0] == '\n'))) {}; + if (err == NULL) { + fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); + } + if ((ierr = sscanf(str, "%u", &maxval)) != 1) { + fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); + } +// std::cout << "maxval: " << maxval << std::endl; + } +// else { +// std::cout << "h: " << h << " maxval: " << maxval << std::endl; +// } } - - if ((h != I.getHeight())||( w != I.getWidth())) - { - - try - { - I.resize(h,w) ; + else if (ierr == 3) { +// std::cout << "magic: " << magic << " w: " << w << " h: " << h << std::endl; + while ((err = fgets(str, vpMAX_LEN - 1, fd)) != NULL && ((str[0] == '#') || (str[0] == '\n'))) {}; + if (err == NULL) { + fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); } - catch(...) - { - vpERROR_TRACE(" ") ; - throw ; + if ((ierr = sscanf(str, "%u", &maxval)) != 1) { + fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read header of file \"%s\"", filename)); } +// std::cout << "maxval: " << maxval << std::endl; } +// else if (ierr == 4) { +// std::cout << "magic: " << magic << " w: " << w << " h: " << h << " maxval: " << maxval << std::endl; +// } - // Read 255 - err = fgets(str, vpMAX_LEN - 1, fd); - line++; - if (err == NULL) { + if (w > 100000 || h>100000) { fclose (fd); - vpERROR_TRACE("couldn't read line %d of file \"%s\"\n",line, filename) ; - throw (vpImageException(vpImageException::ioError, - "couldn't read file")) ; + throw(vpException(vpException::badValue, "Bad image size in \"%s\"", filename)); } - - ierr = sscanf(str, "%d", &is255); - if (ierr == EOF) { + if (maxval != 255) + { fclose (fd); - vpERROR_TRACE("couldn't read line %d of file \"%s\"\n", line, filename) ; throw (vpImageException(vpImageException::ioError, - "couldn't read file")) ; + "Bad maxval in \"%s\"", filename)); } - if (is255 != 255) - { - fclose (fd); - vpERROR_TRACE("MAX_VAL is not 255 in file \"%s\"\n", filename) ; - throw (vpImageException(vpImageException::ioError, - "error reading ppm file")) ; + if ((h != I.getHeight())||( w != I.getWidth())) { + I.resize(h,w) ; } for(unsigned int i=0;i<I.getHeight();i++) @@ -1328,16 +1437,15 @@ vpImageIo::readPPM(vpImage<vpRGBa> &I, const char *filename) res |= fread(&v.B,sizeof(v.B),1,fd) ; if (res==0) { - fclose (fd); - vpERROR_TRACE("couldn't read bytes in file \"%s\"\n", filename) ; - throw (vpImageException(vpImageException::ioError, - "error reading ppm file")) ; + fclose (fd); + throw (vpImageException(vpImageException::ioError, + "Cannot read bytes in file \"%s\"\n", filename)); } I[i][j] = v ; } } - fclose(fd) ; + fclose (fd); } /*! diff --git a/src/image/vpImageIo.h b/src/image/vpImageIo.h index 69acede104dbb590bc116568b8725c276b502c02..f08f6d8f0098c6074b1e76285b58305d871cd923 100644 --- a/src/image/vpImageIo.h +++ b/src/image/vpImageIo.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpImageIo.h 4314 2013-07-16 17:41:21Z fspindle $ + * $Id: vpImageIo.h 4604 2014-01-21 14:15:23Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -56,7 +56,7 @@ #include <stdio.h> #include <iostream> -#ifdef WIN32 +#if defined(_WIN32) # include <windows.h> #endif @@ -89,10 +89,10 @@ int main() { vpImage<unsigned char> I; -#ifdef UNIX - std::string filename("/local/soft/ViSP/ViSP-images/Klimt/Klimt.ppm"); -#elif WIN32 +#if defined(_WIN32) std::string filename("C:/temp/ViSP-images/Klimt/Klimt.ppm"); +#else // UNIX + std::string filename("/local/soft/ViSP/ViSP-images/Klimt/Klimt.ppm"); #endif vpImageIo::read(I, filename); // Convert the color image in a gray level image diff --git a/src/image/vpImageMorphology.h b/src/image/vpImageMorphology.h index 8f0385fdac9a8f24c1786695f6676aa098b3e77a..076e0dc34bd20369fe4184bb2016d25bdceb645e 100644 --- a/src/image/vpImageMorphology.h +++ b/src/image/vpImageMorphology.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpImageMorphology.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpImageMorphology.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/image/vpImagePoint.cpp b/src/image/vpImagePoint.cpp index 6bffc2e47a4159265498303ba5d7c6ba96e43f73..8bd2415cc3e3418f1b909246c1c9ea9ea9afad35 100644 --- a/src/image/vpImagePoint.cpp +++ b/src/image/vpImagePoint.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpImagePoint.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpImagePoint.cpp 4640 2014-02-05 12:41:38Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -86,3 +86,318 @@ vpImagePoint::projection(const vpHomography& aHb) return ap; } + +/*! + + Operator +=. + + This operator can be used to compute the center of gravity of a set of image points. + + \code +#include <iostream> +#include <vector> +#include <visp/vpImagePoint.h> + +int main() +{ +std::vector<vpImagePoint> ip(2); + +ip[0].set_ij(100, 200); +ip[1].set_ij(300, 400); + +vpImagePoint cog(0,0); +for(unsigned int i=0; i<ip.size(); i++) + cog += ip[i]; +cog /= ip.size(); +std::cout << "cog: " << cog << std::endl; +} + \endcode + +*/ +vpImagePoint& vpImagePoint::operator+=(const vpImagePoint &ip) { + this->i += ip.i; + this->j += ip.j; + return *this; +} + +/*! + + Operator /=. + + This operator can be used to compute the center of gravity of a set of image points. + \code +#include <iostream> +#include <vector> +#include <visp/vpImagePoint.h> + +int main() +{ +std::vector<vpImagePoint> ip(2); + +ip[0].set_ij(100, 200); +ip[1].set_ij(300, 400); + +vpImagePoint cog(0,0); +for(unsigned int i=0; i<ip.size(); i++) + cog += ip[i]; +cog /= ip.size(); +std::cout << "cog: " << cog << std::endl; +} + \endcode + +*/ +vpImagePoint& vpImagePoint::operator/=(const double scale) { + this->i /= scale; + this->j /= scale; + return *this; +} + +/*! + \relates vpImagePoint + + Returns true if ip1 and ip2 are equal; otherwire returns false. + +*/ +VISP_EXPORT bool operator==( const vpImagePoint &ip1, const vpImagePoint &ip2 ) { + //return ( ( ip1.get_i() == ip2.get_i() ) && ( ip1.get_j() == ip2.get_j() ) ); + + double i1 = ip1.get_i(); + double j1 = ip1.get_j(); + double i2 = ip2.get_i(); + double j2 = ip2.get_j(); + + return ( + ( std::fabs(i1-i2) <= std::fabs(vpMath::maximum(i1, i2))*std::numeric_limits<double>::epsilon() ) + && + ( std::fabs(j1-j2) <= std::fabs(vpMath::maximum(j1, j2))*std::numeric_limits<double>::epsilon() ) + ); +} + +/*! + + \relates vpImagePoint + + Returns true if ip1 and ip2 are different; otherwire returns true. + +*/ +VISP_EXPORT bool operator!=( const vpImagePoint &ip1, const vpImagePoint &ip2 ) { + //return ( ( ip1.get_i() != ip2.get_i() ) || ( ip1.get_j() != ip2.get_j() ) ); + double i1 = ip1.get_i(); + double j1 = ip1.get_j(); + double i2 = ip2.get_i(); + double j2 = ip2.get_j(); + + return ( + ( std::fabs(i1-i2) > std::fabs(vpMath::maximum(i1, i2))*std::numeric_limits<double>::epsilon() ) + || + ( std::fabs(j1-j2) > std::fabs(vpMath::maximum(j1, j2))*std::numeric_limits<double>::epsilon() ) + ); +} + +/*! + + \relates vpImagePoint + + Returns a vpImagePoint wich is the sum of \f$ ip1 \f$ and \f$ ip2 \f$. + +*/ +VISP_EXPORT vpImagePoint operator+( const vpImagePoint &ip1, const vpImagePoint &ip2 ) { + return ( vpImagePoint(ip1.get_i()+ip2.get_i(), ip1.get_j()+ip2.get_j())); +} +/*! + + \relates vpImagePoint + + Returns a vpImagePoint wich is the sum of \f$ ip1 \f$ and \f$ ip2 \f$. + +*/ +VISP_EXPORT vpImagePoint operator+=( const vpImagePoint &ip1, const vpImagePoint &ip2 ) { + return ( vpImagePoint(ip1.get_i()+ip2.get_i(), ip1.get_j()+ip2.get_j())); +} +/*! + + \relates vpImagePoint + + Returns a vpImagePoint with an offset added to the two coordinates. + + \code +#include <iostream> +#include <visp/vpImagePoint.h> + +int main() +{ + vpImagePoint ip(100, 200); // Create an image point with coordinates i=100, j=200 + std::cout << "ip: " << ip << std::endl; // coordinates (100, 200) + std::cout << "ip+10: " << ip+10 << std::endl; // new coordinates (110, 210) + + return 0; +} + \endcode +*/ +VISP_EXPORT vpImagePoint operator+( const vpImagePoint &ip1, const int offset ) { + return ( vpImagePoint(ip1.get_i()+offset, ip1.get_j()+offset)); +} +/*! + + \relates vpImagePoint + + Returns a vpImagePoint with an offset added to the two coordinates. + + \code +#include <iostream> +#include <visp/vpImagePoint.h> + +int main() +{ + vpImagePoint ip(100, 200); // Create an image point with coordinates i=100, j=200 + std::cout << "ip: " << ip << std::endl; // coordinates (100, 200) + std::cout << "ip+12.34: " << ip+12.34 << std::endl; // new coordinates (112.34, 212.34) + + return 0; +} + \endcode +*/ +VISP_EXPORT vpImagePoint operator+( const vpImagePoint &ip1, const double offset ) { + return ( vpImagePoint(ip1.get_i()+offset, ip1.get_j()+offset)); +} + +/*! + + \relates vpImagePoint + + Returns a vpImagePoint wich is the difference between \f$ ip1 \f$ and \f$ ip2 \f$. + +*/ +VISP_EXPORT vpImagePoint operator-( const vpImagePoint &ip1, const vpImagePoint &ip2 ) { + return ( vpImagePoint(ip1.get_i()-ip2.get_i(), ip1.get_j()-ip2.get_j())); +} +/*! + + \relates vpImagePoint + + Returns a vpImagePoint with an offset substracted to the two coordinates. + + \code +#include <iostream> +#include <visp/vpImagePoint.h> + +int main() +{ + vpImagePoint ip(100, 200); // Create an image point with coordinates i=100, j=200 + std::cout << "ip: " << ip << std::endl; // coordinates (100, 200) + std::cout << "ip-10: " << ip-10 << std::endl; // new coordinates (90, 190) + + return 0; +} + \endcode +*/ +VISP_EXPORT vpImagePoint operator-( const vpImagePoint &ip1, const int offset ) { + return ( vpImagePoint(ip1.get_i()-offset, ip1.get_j()-offset)); +} +/*! + + \relates vpImagePoint + + Returns a vpImagePoint with an offset substracted to the two coordinates. + + \code +#include <iostream> +#include <visp/vpImagePoint.h> + +int main() +{ + vpImagePoint ip(100, 200); // Create an image point with coordinates i=100, j=200 + std::cout << "ip: " << ip << std::endl; // coordinates (100, 200) + std::cout << "ip-12.34: " << ip-12.34 << std::endl; // new coordinates (87.66, 187.66) + + return 0; +} + \endcode +*/ +VISP_EXPORT vpImagePoint operator-( const vpImagePoint &ip1, const double offset ) { + return ( vpImagePoint(ip1.get_i()-offset, ip1.get_j()-offset)); +} +/*! + + \relates vpImagePoint + + Returns a vpImagePoint with coordinates multiplied by a scale factor. + + \code +#include <iostream> +#include <visp/vpImagePoint.h> + +int main() +{ + vpImagePoint ip(100, 200); // Create an image point with coordinates i=100, j=200 + std::cout << "ip: " << ip << std::endl; // coordinates (100, 200) + std::cout << "ip*2: " << ip*2 << std::endl; // new coordinates (200, 400) + + return 0; +} + \endcode +*/ +VISP_EXPORT vpImagePoint operator*( const vpImagePoint &ip1, const double scale ) { + return ( vpImagePoint(ip1.get_i()*scale, ip1.get_j()*scale)); +} +/*! + + \relates vpImagePoint + + Returns a vpImagePoint with coordinates divided by a scale factor. + + \code +#include <iostream> +#include <visp/vpImagePoint.h> + +int main() +{ + vpImagePoint ip(100, 200); // Create an image point with coordinates i=100, j=200 + std::cout << "ip: " << ip << std::endl; // coordinates (100, 200) + std::cout << "ip/2: " << ip/2 << std::endl; // new coordinates (50, 100) + + return 0; +} + \endcode +*/ +VISP_EXPORT vpImagePoint operator/( const vpImagePoint &ip1, const double scale ) { + return ( vpImagePoint(ip1.get_i()/scale, ip1.get_j()/scale)); +} + +/*! + + \relates vpImagePoint + + Writes the image point coordinates \e ip to the stream \e os, and + returns a reference to the stream. Writes the first coordinate along + the \e i axis and then the second one along the \e j axis. The + coordinates are separated by a comma. + + The following code + \code +#include <iostream> + +#include <visp/vpImagePoint.h> +int main() +{ + vpImagePoint ip; + + ip.set_i(10); + ip.set_j(11.1); + + std::cout << "Image point with coordinates: " << ip << std::endl; + + return 0; +} + \endcode + + The previous sample code produces the output: + \verbatim +Image point with coordinates: 10, 11.1 + \endverbatim +*/ +VISP_EXPORT std::ostream& operator<< (std::ostream &os, const vpImagePoint& ip) + { + os << ip.get_i() << ", " << ip.get_j(); + return os; +} diff --git a/src/image/vpImagePoint.h b/src/image/vpImagePoint.h index 1b3e7f11ff766e2c7e4b1ec7780357dd9cc9306a..95350feabdd4d09a7aaf59fca4cf14440315d14a 100644 --- a/src/image/vpImagePoint.h +++ b/src/image/vpImagePoint.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpImagePoint.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpImagePoint.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -96,18 +96,12 @@ class VISP_EXPORT vpImagePoint Default constructor that initialize the coordinates of the image point to zero. */ - inline vpImagePoint() { - i = 0; - j = 0; - } + inline vpImagePoint() : i(0), j(0) {} /*! Default constructor that initialize the coordinates of the image - thanks to the parameters \f$ i \f$ and \f$ j \f$. + thanks to the parameters \f$ ii \f$ and \f$ jj \f$. */ - inline vpImagePoint(double i, double j) { - this->i = i; - this->j = j; - } + inline vpImagePoint(double ii, double jj) : i(ii), j(jj) {} /*! Copy constructor. @@ -115,15 +109,12 @@ class VISP_EXPORT vpImagePoint \param ip : An image point. */ - inline vpImagePoint(const vpImagePoint &ip) { - this->i = ip.i; - this->j = ip.j; - } + inline vpImagePoint(const vpImagePoint &ip) : i(ip.i), j(ip.j) {} //! Destructor. inline virtual ~vpImagePoint() { ; } /*! - + Copy operator. */ @@ -132,41 +123,63 @@ class VISP_EXPORT vpImagePoint this->j = ip.j; return *this; } + vpImagePoint& operator+=(const vpImagePoint &ip); + + /*! + + Operator -=. + + */ + inline vpImagePoint& operator-=(const vpImagePoint &ip) { + this->i -= ip.i; + this->j -= ip.j; + return *this; + } + vpImagePoint& operator/=(const double scale); + /*! + + Operator *=. +*/ + inline vpImagePoint& operator*=(const double scale) { + this->i *= scale; + this->j *= scale; + return *this; + } /*! Sets the point coordinate corresponding to the \f$ i \f$ axes in the frame (i,j). - \param i : The desired value for the coordinate along the \f$ i \f$ axes. + \param ii : The desired value for the coordinate along the \f$ i \f$ axes. \sa set_j(), set_u(), set_v() */ - inline void set_i(const double i) { this->i = i ; } + inline void set_i(const double ii) { this->i = ii ; } /*! Sets the point coordinate corresponding to the \f$ j \f$ axes in the frame (i,j). - \param j : The desired value for the coordinate along the \f$ j \f$ axes. + \param jj : The desired value for the coordinate along the \f$ j \f$ axes. \sa set_i(), set_u(), set_v() */ - inline void set_j(const double j) { this->j = j ; } + inline void set_j(const double jj) { this->j = jj ; } /*! Sets the point coordinates in the frame (i,j). - \param i : The desired value for the coordinate along the \f$ i \f$ axes. - \param j : The desired value for the coordinate along the \f$ j \f$ axes. + \param ii : The desired value for the coordinate along the \f$ i \f$ axes. + \param jj : The desired value for the coordinate along the \f$ j \f$ axes. \sa set_i(), set_j(), set_u(), set_v() */ - inline void set_ij(const double i, const double j) { - this->i = i ; - this->j = j ; + inline void set_ij(const double ii, const double jj) { + this->i = ii ; + this->j = jj ; } /*! @@ -276,268 +289,23 @@ class VISP_EXPORT vpImagePoint bool inRectangle( const vpRect &rect ) const; + friend VISP_EXPORT bool operator==( const vpImagePoint &ip1, const vpImagePoint &ip2 ); + friend VISP_EXPORT bool operator!=( const vpImagePoint &ip1, const vpImagePoint &ip2 ); + friend VISP_EXPORT vpImagePoint operator+=( const vpImagePoint &ip1, const vpImagePoint &ip2 ); + friend VISP_EXPORT vpImagePoint operator+( const vpImagePoint &ip1, const vpImagePoint &ip2 ); + friend VISP_EXPORT vpImagePoint operator+( const vpImagePoint &ip1, const int offset ); + friend VISP_EXPORT vpImagePoint operator+( const vpImagePoint &ip1, const double offset ); + friend VISP_EXPORT vpImagePoint operator-( const vpImagePoint &ip1, const vpImagePoint &ip2 ); + friend VISP_EXPORT vpImagePoint operator-( const vpImagePoint &ip1, const int offset ); + friend VISP_EXPORT vpImagePoint operator-( const vpImagePoint &ip1, const double offset ); + friend VISP_EXPORT vpImagePoint operator*( const vpImagePoint &ip1, const double scale ); + friend VISP_EXPORT vpImagePoint operator/( const vpImagePoint &ip1, const double scale ); + friend VISP_EXPORT std::ostream& operator<< (std::ostream &os, const vpImagePoint& ip); + vpImagePoint projection(const vpHomography& aHb); private: double i,j; }; -/*! - \relates vpImagePoint - - Returns true if ip1 and ip2 are equal; otherwire returns false. - -*/ -VISP_EXPORT inline bool operator==( const vpImagePoint &ip1, - const vpImagePoint &ip2 ) { - //return ( ( ip1.get_i() == ip2.get_i() ) && ( ip1.get_j() == ip2.get_j() ) ); - - double i1 = ip1.get_i(); - double j1 = ip1.get_j(); - double i2 = ip2.get_i(); - double j2 = ip2.get_j(); - - return ( - ( std::fabs(i1-i2) <= std::fabs(vpMath::maximum(i1, i2))*std::numeric_limits<double>::epsilon() ) - && - ( std::fabs(j1-j2) <= std::fabs(vpMath::maximum(j1, j2))*std::numeric_limits<double>::epsilon() ) - ); -} - -/*! - - \relates vpImagePoint - - Returns true if ip1 and ip2 are different; otherwire returns true. - -*/ -VISP_EXPORT inline bool operator!=( const vpImagePoint &ip1, - const vpImagePoint &ip2 ) { - //return ( ( ip1.get_i() != ip2.get_i() ) || ( ip1.get_j() != ip2.get_j() ) ); - double i1 = ip1.get_i(); - double j1 = ip1.get_j(); - double i2 = ip2.get_i(); - double j2 = ip2.get_j(); - - return ( - ( std::fabs(i1-i2) > std::fabs(vpMath::maximum(i1, i2))*std::numeric_limits<double>::epsilon() ) - || - ( std::fabs(j1-j2) > std::fabs(vpMath::maximum(j1, j2))*std::numeric_limits<double>::epsilon() ) - ); -} - -/*! - - \relates vpImagePoint - - Returns a vpImagePoint wich is the sum of \f$ ip1 \f$ and \f$ ip2 \f$. - -*/ -VISP_EXPORT inline vpImagePoint operator+( const vpImagePoint &ip1, - const vpImagePoint &ip2 ) { - return ( vpImagePoint(ip1.get_i()+ip2.get_i(), ip1.get_j()+ip2.get_j())); -} -/*! - - \relates vpImagePoint - - Returns a vpImagePoint with an offset added to the two coordinates. - - \code -#include <iostream> -#include <visp/vpImagePoint.h> - -int main() -{ - vpImagePoint ip(100, 200); // Create an image point with coordinates i=100, j=200 - std::cout << "ip: " << ip << std::endl; // coordinates (100, 200) - std::cout << "ip+10: " << ip+10 << std::endl; // new coordinates (110, 210) - - return 0; -} - \endcode -*/ -VISP_EXPORT inline vpImagePoint operator+( const vpImagePoint &ip1, - const int offset ) { - return ( vpImagePoint(ip1.get_i()+offset, ip1.get_j()+offset)); -} -/*! - - \relates vpImagePoint - - Returns a vpImagePoint with an offset added to the two coordinates. - - \code -#include <iostream> -#include <visp/vpImagePoint.h> - -int main() -{ - vpImagePoint ip(100, 200); // Create an image point with coordinates i=100, j=200 - std::cout << "ip: " << ip << std::endl; // coordinates (100, 200) - std::cout << "ip+12.34: " << ip+12.34 << std::endl; // new coordinates (112.34, 212.34) - - return 0; -} - \endcode -*/ -VISP_EXPORT inline vpImagePoint operator+( const vpImagePoint &ip1, - const double offset ) { - return ( vpImagePoint(ip1.get_i()+offset, ip1.get_j()+offset)); -} - -/*! - - \relates vpImagePoint - - Returns a vpImagePoint wich is the difference between \f$ ip1 \f$ and \f$ ip2 \f$. - -*/ -VISP_EXPORT inline vpImagePoint operator-( const vpImagePoint &ip1, - const vpImagePoint &ip2 ) { - return ( vpImagePoint(ip1.get_i()-ip2.get_i(), ip1.get_j()-ip2.get_j())); -} -/*! - - \relates vpImagePoint - - Returns a vpImagePoint with an offset substracted to the two coordinates. - - \code -#include <iostream> -#include <visp/vpImagePoint.h> - -int main() -{ - vpImagePoint ip(100, 200); // Create an image point with coordinates i=100, j=200 - std::cout << "ip: " << ip << std::endl; // coordinates (100, 200) - std::cout << "ip-10: " << ip-10 << std::endl; // new coordinates (90, 190) - - return 0; -} - \endcode -*/ -VISP_EXPORT inline vpImagePoint operator-( const vpImagePoint &ip1, - const int offset ) { - return ( vpImagePoint(ip1.get_i()-offset, ip1.get_j()-offset)); -} -/*! - - \relates vpImagePoint - - Returns a vpImagePoint with an offset substracted to the two coordinates. - - \code -#include <iostream> -#include <visp/vpImagePoint.h> - -int main() -{ - vpImagePoint ip(100, 200); // Create an image point with coordinates i=100, j=200 - std::cout << "ip: " << ip << std::endl; // coordinates (100, 200) - std::cout << "ip-12.34: " << ip-12.34 << std::endl; // new coordinates (87.66, 187.66) - - return 0; -} - \endcode -*/ -VISP_EXPORT inline vpImagePoint operator-( const vpImagePoint &ip1, - const double offset ) { - return ( vpImagePoint(ip1.get_i()-offset, ip1.get_j()-offset)); -} -/*! - - \relates vpImagePoint - - Returns a vpImagePoint with coordinates multiplied by a scale factor. - - \code -#include <iostream> -#include <visp/vpImagePoint.h> - -int main() -{ - vpImagePoint ip(100, 200); // Create an image point with coordinates i=100, j=200 - std::cout << "ip: " << ip << std::endl; // coordinates (100, 200) - std::cout << "ip*2: " << ip*2 << std::endl; // new coordinates (200, 400) - - return 0; -} - \endcode -*/ -VISP_EXPORT inline vpImagePoint operator*( const vpImagePoint &ip1, - const double scale ) { - return ( vpImagePoint(ip1.get_i()*scale, ip1.get_j()*scale)); -} -/*! - - \relates vpImagePoint - - Returns a vpImagePoint with coordinates divided by a scale factor. - - \code -#include <iostream> -#include <visp/vpImagePoint.h> - -int main() -{ - vpImagePoint ip(100, 200); // Create an image point with coordinates i=100, j=200 - std::cout << "ip: " << ip << std::endl; // coordinates (100, 200) - std::cout << "ip/2: " << ip/2 << std::endl; // new coordinates (50, 100) - - return 0; -} - \endcode -*/ -VISP_EXPORT inline vpImagePoint operator/( const vpImagePoint &ip1, - const double scale ) { - return ( vpImagePoint(ip1.get_i()/scale, ip1.get_j()/scale)); -} - -/*! - - \relates vpImagePoint - - Writes the image point coordinates \e ip to the stream \e os, and - returns a reference to the stream. Writes the first coordinate along - the \e i axis and then the second one along the \e j axis. The - coordinates are separated by a comma. - - The following code - \code -#include <iostream> - -#include <visp/vpImagePoint.h> -int main() -{ - vpImagePoint ip; - - ip.set_i(10); - ip.set_j(11.1); - - std::cout << "Image point with coordinates: " << ip << std::endl; - - return 0; -} - \endcode - - The previous sample code produces the output: - \verbatim -Image point with coordinates: 10, 11.1 - \endverbatim -*/ -VISP_EXPORT inline std::ostream& operator<< (std::ostream &os, - const vpImagePoint& ip) - { - os << ip.get_i() << ", " << ip.get_j(); - return os; -} - - #endif - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ diff --git a/src/image/vpImageTools.cpp b/src/image/vpImageTools.cpp index 59a4eef42031ddd12568b89c6e43ce7492c398e9..c0ea67ad690a528a62b152c916a272e05272952f 100644 --- a/src/image/vpImageTools.cpp +++ b/src/image/vpImageTools.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpImageTools.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpImageTools.cpp 4604 2014-01-21 14:15:23Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -74,18 +74,18 @@ \code #include <visp/vpImageTools.h> - #include <visp/vpImage.h> #include <visp/vpImageIo.h> int main() { vpImage<unsigned char> I; -#ifdef UNIX - std::string filename("/local/soft/ViSP/ViSP-images/Klimt/Klimt.pgm"); -#elif WIN32 - std::string filename("C:/temp/ViSP-images/Klimt/Klimt.pgm"); +#ifdef _WIN32 + std::string filename("C:/temp/ViSP-images/Klimt/Klimt.ppm"); +#else + std::string filename("/local/soft/ViSP/ViSP-images/Klimt/Klimt.ppm"); #endif + // Read an image from the disk vpImageIo::read(I, filename); diff --git a/src/image/vpImageTools.h b/src/image/vpImageTools.h index 4a9842733ee816242163e489a5b38f7a063dc237..e9723577a1a5f0648341933a25ff5d984d529230 100644 --- a/src/image/vpImageTools.h +++ b/src/image/vpImageTools.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpImageTools.h 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpImageTools.h 4604 2014-01-21 14:15:23Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -249,7 +249,11 @@ public: unsigned int nthreads; unsigned int threadid; public: - vpUndistortInternalType() {}; + vpUndistortInternalType() { + src = dst = NULL; + width = height = 0; + nthreads = threadid = 0; + }; vpUndistortInternalType(const vpUndistortInternalType<Type> &u) { src = u.src; dst = u.dst; @@ -548,6 +552,31 @@ void vpImageTools::flip(const vpImage<Type> &I, Flip vertically the input image. \param I : Input image which is flipped and modified in output. + + The following example shows how to use this function: + \code +#include <visp/vpImageTools.h> +#include <visp/vpImage.h> +#include <visp/vpImageIo.h> + +int main() +{ + vpImage<vpRGBa> I; +#ifdef _WIN32 + std::string filename("C:/temp/ViSP-images/Klimt/Klimt.ppm"); +#else + std::string filename("/local/soft/ViSP/ViSP-images/Klimt/Klimt.ppm"); +#endif + + // Read an image from the disk + vpImageIo::read(I, filename); + + // Flip the image + vpImageTools::flip(I); + + vpImageIo::write(I, "Klimt-flip.ppm"); // Write the image in a PGM P5 image file format +} + \endcode */ template<class Type> void vpImageTools::flip(vpImage<Type> &I) diff --git a/src/image/vpRGBa.cpp b/src/image/vpRGBa.cpp index 8360c08ce4ceb0ca4ca5144ff5cc430d99b74de8..297b320586f873876472acdce125428fc27d4f72 100644 --- a/src/image/vpRGBa.cpp +++ b/src/image/vpRGBa.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRGBa.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRGBa.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -58,25 +58,27 @@ \param v : Input color ( R = G = B = v ) */ -void +vpRGBa & vpRGBa::operator=(const unsigned char &v) { this->R = v; this->G = v; this->B = v; this->A = v; + return *this; } /*! Copy operator. */ -void +vpRGBa & vpRGBa::operator=(const vpRGBa &v) { this->R = v.R; this->G = v.G; this->B = v.B; this->A = v.A; + return *this; } /*! @@ -88,7 +90,7 @@ vpRGBa::operator=(const vpRGBa &v) \exception vpException::dimensionError : If v is not a 4 four dimention vector. */ -void +vpRGBa & vpRGBa::operator=(const vpColVector &v) { if (v.getRows() != 4) { @@ -99,6 +101,7 @@ vpRGBa::operator=(const vpColVector &v) G = (unsigned char)v[1]; B = (unsigned char)v[2]; A = (unsigned char)v[3]; + return *this; } /*! diff --git a/src/image/vpRGBa.h b/src/image/vpRGBa.h index 5307f17b3c3640ca338e07e97186b46f13460aa2..5566e5677197e67eeae132ee1993fbb0f1ec2bcd 100644 --- a/src/image/vpRGBa.h +++ b/src/image/vpRGBa.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRGBa.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRGBa.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -74,27 +74,22 @@ public: Build a black value. */ - inline vpRGBa() - : R(0), G(0), B(0), A(0) - { - }; + inline vpRGBa() : R(0), G(0), B(0), A(0) {}; /*! Constructor. Initialize the color with R, G, B, A values. - \param R : Red value. - \param G : Green value. - \param B : Blue value. - \param A : Additional value. + \param r : Red value. + \param g : Green value. + \param b : Blue value. + \param a : Additional value. */ - inline vpRGBa(const unsigned char &R, const unsigned char &G, - const unsigned char &B, const unsigned char &A=0) - : R(R), G(G), B(B), A(A) - { - }; + inline vpRGBa(const unsigned char &r, const unsigned char &g, + const unsigned char &b, const unsigned char &a=0) + : R(r), G(g), B(b), A(a) {}; /*! @@ -105,19 +100,13 @@ public: \param v : Value to set. */ - inline vpRGBa(const unsigned char &v) - : R(v), G(v), B(v), A(v) - { - }; + inline vpRGBa(const unsigned char &v) : R(v), G(v), B(v), A(v) {}; /*! Copy constructor. */ - inline vpRGBa(const vpRGBa &v) - { - *this = v ; - }; + inline vpRGBa(const vpRGBa &v) : R(v.R), G(v.G), B(v.B), A(v.A) {}; /*! Create a RGBa value from a 4 dimension column vector. @@ -128,14 +117,18 @@ public: A=v[3] */ - inline vpRGBa(const vpColVector &v) + inline vpRGBa(const vpColVector &v) : R(0), G(0), B(0), A(0) { - *this = v ; - } + *this = v; + }; + + // We cannot add here the following destructor without changing the hypothesis that the size of this class is 4. + // With the destructor it becomes 16 that does break a lot of things arround image conversions + // virtual ~vpRGBa() {}; // Not to implement - void operator=(const unsigned char &v) ; - void operator=(const vpRGBa &v) ; - void operator=(const vpColVector &v) ; + vpRGBa & operator=(const unsigned char &v) ; + vpRGBa & operator=(const vpRGBa &v) ; + vpRGBa & operator=(const vpColVector &v) ; bool operator==(const vpRGBa &v); bool operator!=(const vpRGBa &v); diff --git a/src/key-point/vpBasicKeyPoint.cpp b/src/key-point/vpBasicKeyPoint.cpp index 19e8dfb20b84de5a7c07a2843f02734316744f22..68ad68b1f71044aae478a024d210abed2548bd11 100644 --- a/src/key-point/vpBasicKeyPoint.cpp +++ b/src/key-point/vpBasicKeyPoint.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpBasicKeyPoint.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpBasicKeyPoint.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -42,23 +42,12 @@ #include <visp/vpBasicKeyPoint.h> -#include <vector> - /*! Basic constructor. */ vpBasicKeyPoint::vpBasicKeyPoint() + : referenceImagePointsList(), currentImagePointsList(), matchedReferencePoints(), _reference_computed(false) { - _reference_computed = false; - matchedReferencePoints.resize(0); - currentImagePointsList.resize(0); - referenceImagePointsList.resize(0); } -/* - * Local variables: - * c-basic-offset: 4 - * End: - */ - diff --git a/src/key-point/vpBasicKeyPoint.h b/src/key-point/vpBasicKeyPoint.h index 3cf81c00b5a27573dad2c337885e0308524644bd..375aa74911432fadecfa1b3ba63af7069fb2a2b8 100644 --- a/src/key-point/vpBasicKeyPoint.h +++ b/src/key-point/vpBasicKeyPoint.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpBasicKeyPoint.h 4303 2013-07-04 14:14:00Z fspindle $ + * $Id: vpBasicKeyPoint.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/key-point/vpFernClassifier.cpp b/src/key-point/vpFernClassifier.cpp index bfd3a784e0e32f9c5735161025b22c7e5afe9f01..f8035811e5e3016b9c03d51ffeb92a3946a57e40 100644 --- a/src/key-point/vpFernClassifier.cpp +++ b/src/key-point/vpFernClassifier.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFernClassifier.cpp 4303 2013-07-04 14:14:00Z fspindle $ + * $Id: vpFernClassifier.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -54,9 +54,14 @@ Basic constructor */ -vpFernClassifier::vpFernClassifier():vpBasicKeyPoint(), gen(0, 256, 5, true, 0.6, 1.5, -CV_PI/2, CV_PI/2, -CV_PI/2, CV_PI/2) +vpFernClassifier::vpFernClassifier() + : vpBasicKeyPoint(), + ldetector(), fernClassifier(), gen(0, 256, 5, true, 0.6, 1.5, -CV_PI/2, CV_PI/2, -CV_PI/2, CV_PI/2), + hasLearn(false), threshold(20), nbView(2000), dist(2), nbClassfier(100), ClassifierSize(11), + nbOctave(2), patchSize(32), radius(7), nbPoints(200), blurImage(true), radiusBlur(7), + sigmaBlur(1), nbMinPoint(10), curIplImg(NULL), objKeypoints(), modelROI_Ref(), modelROI(), + modelPoints(), imgKeypoints(), refPt(), curPt() { - init(); } /*! @@ -70,9 +75,14 @@ vpFernClassifier::vpFernClassifier():vpBasicKeyPoint(), gen(0, 256, 5, true, 0.6 \param _objectName : the name of the object to load */ vpFernClassifier::vpFernClassifier(const std::string& _dataFile, const std::string& _objectName) + : vpBasicKeyPoint(), + ldetector(), fernClassifier(), gen(0, 256, 5, true, 0.6, 1.5, -CV_PI/2, CV_PI/2, -CV_PI/2, CV_PI/2), + hasLearn(false), threshold(20), nbView(2000), dist(2), nbClassfier(100), ClassifierSize(11), + nbOctave(2), patchSize(32), radius(7), nbPoints(200), blurImage(true), radiusBlur(7), + sigmaBlur(1), nbMinPoint(10), curIplImg(NULL), objKeypoints(), modelROI_Ref(), modelROI(), + modelPoints(), imgKeypoints(), refPt(), curPt() { - init(); - this->load(_dataFile, _objectName); + this->load(_dataFile, _objectName); } /*! diff --git a/src/key-point/vpFernClassifier.h b/src/key-point/vpFernClassifier.h index 399cbc6c0aef597197b504020313bf62161bfb44..f840e3f2243e3abdb6cbc9933d5c45d7de2d395f 100644 --- a/src/key-point/vpFernClassifier.h +++ b/src/key-point/vpFernClassifier.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFernClassifier.h 4201 2013-04-08 08:20:47Z fspindle $ + * $Id: vpFernClassifier.h 4664 2014-02-16 16:17:54Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -73,13 +73,8 @@ image. The points of interests belonging to the model and the points detected in the current image are given in pixels thanks to the vpImagePoint class. - For more details about the Ferns Classifier and the point detector, see - - Mustafa Özuysal, Michael Calonder, Vincent Lepetit, Pascal Fua, "Fast - KeyPoint Recognition Using Random Ferns", IEEE Transactions on Pattern - Analysis and Machine Intelligence, 15 Jan. 2009. - - - Vincent Lepetit, Pascal Fua, “Towards Recognizing Feature Points Using - Classification Treesâ€, Technical Report IC/2004/74, EPFL, 2004. + For more details about the Ferns Classifier and the point detector, + see \cite Ozuysal10 and \cite Lepetit04c. To use this class, you first have to detect points in the model and train the associated Fern classifier. Then, for each new grabbed image, You can detect diff --git a/src/key-point/vpKeyPointSurf.cpp b/src/key-point/vpKeyPointSurf.cpp index 126fed3b4711c5c28f297f20a9cce4930fa9c155..7a7d8194bdc2f7a58fd5caacbe6368f634e7c3e5 100644 --- a/src/key-point/vpKeyPointSurf.cpp +++ b/src/key-point/vpKeyPointSurf.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpKeyPointSurf.cpp 4182 2013-03-27 13:20:58Z fspindle $ + * $Id: vpKeyPointSurf.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -56,9 +56,21 @@ #include <vector> #include <list> +double compareSURFDescriptors( const float* d1, const float* d2, double best, int length ); +int naiveNearestNeighbor( const float *vec, int laplacian, + const CvSeq *model_keypoints, + const CvSeq *model_descriptors ); +int naiveNearestNeighbor( const float *vec, + const CvSeq *ref_keypoints, + const CvSeq *ref_descriptors ); +void findPairs( const CvSeq* objectKeypoints, + const CvSeq* objectDescriptors, + const CvSeq* imageKeypoints, + const CvSeq* imageDescriptors, + std::vector<int>& ptpairs ); + // Compare two surf descriptors. -double compareSURFDescriptors( const float* d1, const float* d2, - double best, int length ) +double compareSURFDescriptors( const float* d1, const float* d2, double best, int length ) { double total_cost = 0; int i; @@ -79,8 +91,8 @@ double compareSURFDescriptors( const float* d1, const float* d2, //Find for a point candidate the most similar point in the reference point list. int naiveNearestNeighbor( const float *vec, int laplacian, - const CvSeq *model_keypoints, - const CvSeq *model_descriptors ) + const CvSeq *model_keypoints, + const CvSeq *model_descriptors ) { int length = (int)(model_descriptors->elem_size/(int)sizeof(float)); int i, neighbor = -1; @@ -115,8 +127,8 @@ int naiveNearestNeighbor( const float *vec, int laplacian, //Find for a point candidate the most similar point in the reference point list. int naiveNearestNeighbor( const float *vec, - const CvSeq *ref_keypoints, - const CvSeq *ref_descriptors ) + const CvSeq *ref_keypoints, + const CvSeq *ref_descriptors ) { int length = (int)(ref_descriptors->elem_size/(int)sizeof(float)); int i, neighbor = -1; @@ -149,10 +161,10 @@ int naiveNearestNeighbor( const float *vec, //Find all the matched points void findPairs( const CvSeq* objectKeypoints, - const CvSeq* objectDescriptors, - const CvSeq* imageKeypoints, - const CvSeq* imageDescriptors, - std::vector<int>& ptpairs ) + const CvSeq* objectDescriptors, + const CvSeq* imageKeypoints, + const CvSeq* imageDescriptors, + std::vector<int>& ptpairs ) { int i; CvSeqReader reader, kreader; @@ -187,18 +199,12 @@ void findPairs( const CvSeq* objectKeypoints, type to extended. */ -vpKeyPointSurf::vpKeyPointSurf():vpBasicKeyPoint() +vpKeyPointSurf::vpKeyPointSurf() + : vpBasicKeyPoint(), + storage(NULL), params(), storage_cur(NULL), image_keypoints(NULL), image_descriptors(NULL), + ref_keypoints(NULL), ref_descriptors(NULL), hessianThreshold(500), descriptorType(extendedDescriptor) { - descriptorType = extendedDescriptor; - hessianThreshold = 500; init(); - - image_keypoints = NULL; - image_descriptors = NULL; - ref_keypoints = NULL; - ref_descriptors = NULL; - - storage_cur = NULL; } /*! diff --git a/src/key-point/vpKeyPointSurf.h b/src/key-point/vpKeyPointSurf.h index 4002854ca5f0d66f07c767c712ddf552d5d16fdb..afea5383b88efcf2e5e55f1736137d1b1abebefc 100644 --- a/src/key-point/vpKeyPointSurf.h +++ b/src/key-point/vpKeyPointSurf.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpKeyPointSurf.h 4201 2013-04-08 08:20:47Z fspindle $ + * $Id: vpKeyPointSurf.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -83,7 +83,7 @@ The coordinates of the different reference points and matched points are given in pixel thanks to the class vpImagePoint. In this documentation we do not explain the SURF technics. So if you want to - learn more about it you can refere to the following article : + learn more about it you can refer to the following article : Herbert Bay, Tinne Tuytelaars and Luc Van Gool "SURF: Speeded Up Robust Features", Proceedings of the 9th European Conference on Computer Vision, Springer LNCS volume 3951, part 1, pp 404--417, @@ -188,6 +188,8 @@ int main() int main() {} #endif \endcode + + This class is also described in \ref tutorial-matching. */ class VISP_EXPORT vpKeyPointSurf : public vpBasicKeyPoint @@ -239,10 +241,10 @@ class VISP_EXPORT vpKeyPointSurf : public vpBasicKeyPoint Computer Vision, Springer LNCS volume 3951, part 1, pp 404--417, 2006. - \param hessianThreshold : Desired hessian threshold value. + \param hessian_threshold : Desired hessian threshold value. */ - void setHessianThreshold (double hessianThreshold) { - this->hessianThreshold = hessianThreshold; + void setHessianThreshold (double hessian_threshold) { + this->hessianThreshold = hessian_threshold; params = cvSURFParams(this->hessianThreshold, this->descriptorType); } ; @@ -250,10 +252,10 @@ class VISP_EXPORT vpKeyPointSurf : public vpBasicKeyPoint Sets the type of descriptors to use. - \param descriptorType : Type of descriptor to use. + \param descriptor_type : Type of descriptor to use. */ - void setDescriptorType (vpDescriptorType descriptorType) { - this->descriptorType = descriptorType; + void setDescriptorType (vpDescriptorType descriptor_type) { + this->descriptorType = descriptor_type; params = cvSURFParams(this->hessianThreshold, this->descriptorType); } ; diff --git a/src/key-point/vpPlanarObjectDetector.cpp b/src/key-point/vpPlanarObjectDetector.cpp index ddbdaf03e975b9e03300f6a0830d8a614c5024c9..71b4704e09451c7b6938731569ebfe2a875eabcb 100755 --- a/src/key-point/vpPlanarObjectDetector.cpp +++ b/src/key-point/vpPlanarObjectDetector.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpPlanarObjectDetector.cpp 4182 2013-03-27 13:20:58Z fspindle $ + * $Id: vpPlanarObjectDetector.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -60,13 +60,9 @@ */ vpPlanarObjectDetector::vpPlanarObjectDetector() + : fern(), homography(), H(), dst_corners(), isCorrect(false), ref_corners(), modelROI(), currentImagePoints(), + refImagePoints(), minNbMatching(10) { - isCorrect = false; - dst_corners.resize(0); - ref_corners.resize(0); - currentImagePoints.resize(0); - refImagePoints.resize(0); - minNbMatching = 10; } /*! @@ -78,19 +74,18 @@ vpPlanarObjectDetector::vpPlanarObjectDetector() */ vpPlanarObjectDetector::vpPlanarObjectDetector(const std::string& _dataFile, const std::string& _objectName) + : fern(), homography(), H(), dst_corners(), isCorrect(false), ref_corners(), modelROI(), currentImagePoints(), + refImagePoints(), minNbMatching(10) { - isCorrect = false; load(_dataFile, _objectName); } /*! - initialise stuff - + Initialise stuff. For the moment does nothing. */ void vpPlanarObjectDetector::init() { - } /*! diff --git a/src/key-point/vpPlanarObjectDetector.h b/src/key-point/vpPlanarObjectDetector.h index 2613dcf8168a25ea50c31da2cc84b3e1dfeaeb7a..72d3074e7f8fe63cfd0a223058fe3fc5e95a2000 100755 --- a/src/key-point/vpPlanarObjectDetector.h +++ b/src/key-point/vpPlanarObjectDetector.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpPlanarObjectDetector.h 4303 2013-07-04 14:14:00Z fspindle $ + * $Id: vpPlanarObjectDetector.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/math/kalman/vpKalmanFilter.cpp b/src/math/kalman/vpKalmanFilter.cpp index 336a6d7a881aa34430f04a1e5ddb1671d1b3d7d6..10067e505521749529a992e820d0af0dcfda9ab4 100644 --- a/src/math/kalman/vpKalmanFilter.cpp +++ b/src/math/kalman/vpKalmanFilter.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpKalmanFilter.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpKalmanFilter.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -53,20 +53,20 @@ /*! Initialize the Kalman filter. - \param size_state : Size of the state vector \f${\bf x}_{k}\f$ for one signal. + \param size_state_vector : Size of the state vector \f${\bf x}_{k}\f$ for one signal. - \param size_measure : Size of the measure vector \f${\bf z}_{k}\f$ + \param size_measure_vector : Size of the measure vector \f${\bf z}_{k}\f$ for one signal. - \param nsignal : Number of signal to filter. + \param n_signal : Number of signal to filter. */ void -vpKalmanFilter::init(unsigned int size_state, unsigned int size_measure, - unsigned int nsignal) +vpKalmanFilter::init(unsigned int size_state_vector, unsigned int size_measure_vector, + unsigned int n_signal) { - this->size_state = size_state; - this->size_measure = size_measure ; - this->nsignal = nsignal ; + this->size_state = size_state_vector; + this->size_measure = size_measure_vector ; + this->nsignal = n_signal ; F.resize(size_state*nsignal, size_state*nsignal) ; H.resize(size_measure*nsignal, size_state*nsignal) ; @@ -91,14 +91,9 @@ vpKalmanFilter::init(unsigned int size_state, unsigned int size_measure, */ vpKalmanFilter::vpKalmanFilter() + : iter(0), size_state(0), size_measure(0), nsignal(0), verbose_mode(false), + Xest(), Xpre(), F(), H(), R(), Q(), dt(-1), Ppre(), Pest(), W(), I() { - verbose(false); - // init_done = false ; - this->size_state = 0; - this->size_measure = 0 ; - this->nsignal = 0 ; - iter = 0 ; - dt = -1 ; } /*! @@ -106,17 +101,12 @@ vpKalmanFilter::vpKalmanFilter() The verbose mode is by default desactivated. - \param nsignal : Number of signal to filter. + \param n_signal : Number of signal to filter. */ -vpKalmanFilter::vpKalmanFilter(unsigned int nsignal) +vpKalmanFilter::vpKalmanFilter(unsigned int n_signal) + : iter(0), size_state(0), size_measure(0), nsignal(n_signal), verbose_mode(false), + Xest(), Xpre(), F(), H(), R(), Q(), dt(-1), Ppre(), Pest(), W(), I() { - verbose(false); - // init_done = false; - this->size_state = 0; - this->size_measure = 0 ; - this->nsignal = nsignal; - iter = 0 ; - dt = -1 ; } /*! @@ -124,17 +114,18 @@ vpKalmanFilter::vpKalmanFilter(unsigned int nsignal) The verbose mode is by default desactivated. - \param size_state : Size of the state vector \f${\bf x}_{(k)}\f$ for one signal. + \param size_state_vector : Size of the state vector \f${\bf x}_{(k)}\f$ for one signal. - \param size_measure : Size of the measure vector \f${\bf z}_{(k)}\f$ + \param size_measure_vector : Size of the measure vector \f${\bf z}_{(k)}\f$ for one signal. - \param nsignal : Number of signal to filter. + \param n_signal : Number of signal to filter. */ -vpKalmanFilter::vpKalmanFilter(unsigned int size_state, unsigned int size_measure, unsigned int nsignal) +vpKalmanFilter::vpKalmanFilter(unsigned int size_state_vector, unsigned int size_measure_vector, unsigned int n_signal) + : iter(0), size_state(0), size_measure(0), nsignal(0), verbose_mode(false), + Xest(), Xpre(), F(), H(), R(), Q(), dt(-1), Ppre(), Pest(), W(), I() { - verbose(false); - init( size_state, size_measure, nsignal) ; + init( size_state_vector, size_measure_vector, n_signal) ; } /*! diff --git a/src/math/kalman/vpKalmanFilter.h b/src/math/kalman/vpKalmanFilter.h index d7e1e08010cba28d7d72f694bdad043ca6f9df52..823dfe8a934e9e8cd164aa74e9fa1b8d80dabdb9 100644 --- a/src/math/kalman/vpKalmanFilter.h +++ b/src/math/kalman/vpKalmanFilter.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpKalmanFilter.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpKalmanFilter.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -128,18 +128,20 @@ protected : public: vpKalmanFilter() ; - vpKalmanFilter(unsigned int nsignal) ; - vpKalmanFilter(unsigned int size_state, unsigned int size_measure, unsigned int nsignal) ; + vpKalmanFilter(unsigned int n_signal) ; + vpKalmanFilter(unsigned int size_state, unsigned int size_measure, unsigned int n_signal) ; + /*! Destructor that does noting. */ + virtual ~vpKalmanFilter() {}; /*! Set the number of signal to filter. */ - void setNumberOfSignal(unsigned int nsignal) + void setNumberOfSignal(unsigned int n_signal) { - this->nsignal = nsignal; + this->nsignal = n_signal; } // int init() { return init_done ; } - void init(unsigned int size_state, unsigned int size_measure, unsigned int nsignal) ; + void init(unsigned int size_state, unsigned int size_measure, unsigned int n_signal) ; void prediction() ; void filtering(vpColVector &z) ; /*! diff --git a/src/math/kalman/vpLinearKalmanFilterInstantiation.cpp b/src/math/kalman/vpLinearKalmanFilterInstantiation.cpp index 492b4b8ab1248be099e3f250ddba83ba2b0ee058..dbd55d47eabd5a36f9e399faf1055e84deb5b36e 100644 --- a/src/math/kalman/vpLinearKalmanFilterInstantiation.cpp +++ b/src/math/kalman/vpLinearKalmanFilterInstantiation.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpLinearKalmanFilterInstantiation.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpLinearKalmanFilterInstantiation.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -62,7 +62,7 @@ \warning It is requiered to set the state model before using this method. - \param nsignal : Number of signal to filter. + \param n_signal : Number of signal to filter. \param sigma_state : Vector that contains the variance of the state noise. The dimension of this vector is equal to the state vector @@ -79,7 +79,7 @@ \param rho : Degree of correlation between successive accelerations. Values are in [0:1[. - \param dt : Sampling time \f$\Delta t\f$ expressed is + \param delta_t : Sampling time \f$\Delta t\f$ expressed is second. Depending on the filter modelization, this value may not be used. This is for example the case for the vpLinearKalmanFilterInstantiation::stateConstVelWithColoredNoise_MeasureVel model @@ -174,23 +174,23 @@ int main() \endcode */ void -vpLinearKalmanFilterInstantiation::initFilter(unsigned int nsignal, - vpColVector &sigma_state, - vpColVector &sigma_measure, - double rho, double dt) +vpLinearKalmanFilterInstantiation::initFilter(unsigned int n_signal, + vpColVector &sigma_state, + vpColVector &sigma_measure, + double rho, double delta_t) { switch (model) { case stateConstVelWithColoredNoise_MeasureVel: - initStateConstVelWithColoredNoise_MeasureVel(nsignal, sigma_state, + initStateConstVelWithColoredNoise_MeasureVel(n_signal, sigma_state, sigma_measure, rho); break; case stateConstVel_MeasurePos: - initStateConstVel_MeasurePos(nsignal, sigma_state, - sigma_measure, dt); + initStateConstVel_MeasurePos(n_signal, sigma_state, + sigma_measure, delta_t); break; case stateConstAccWithColoredNoise_MeasureVel: - initStateConstAccWithColoredNoise_MeasureVel(nsignal, sigma_state, - sigma_measure, rho, dt); + initStateConstAccWithColoredNoise_MeasureVel(n_signal, sigma_state, + sigma_measure, rho, delta_t); break; case unknown: vpERROR_TRACE("Kalman state model is not set") ; @@ -282,7 +282,7 @@ vpLinearKalmanFilterInstantiation::initFilter(unsigned int nsignal, \right] \f] - \param nsignal : Number of signal to filter. + \param n_signal : Number of signal to filter. \param sigma_state : Vector that fix the variance of the state covariance matrix \f$[\sigma^2_Q \; 0]^T\f$. The dimension of @@ -292,19 +292,19 @@ vpLinearKalmanFilterInstantiation::initFilter(unsigned int nsignal, noise. The dimension of this vector is equal to the number of signal to filter. - \param dt : Sampling time \f$\Delta t\f$ expressed is second. + \param delta_t : Sampling time \f$\Delta t\f$ expressed is second. */ void -vpLinearKalmanFilterInstantiation::initStateConstVel_MeasurePos(unsigned int nsignal, +vpLinearKalmanFilterInstantiation::initStateConstVel_MeasurePos(unsigned int n_signal, vpColVector &sigma_state, vpColVector &sigma_measure, - double dt ) + double delta_t ) { // init_done = true ; setStateModel(stateConstVel_MeasurePos); - init(size_state, size_measure, nsignal); + init(size_state, size_measure, n_signal); iter = 0; Pest = 0; @@ -313,12 +313,12 @@ vpLinearKalmanFilterInstantiation::initStateConstVel_MeasurePos(unsigned int nsi H = 0; R = 0; Q = 0; - this->dt = dt ; + this->dt = delta_t ; double dt2 = dt*dt ; double dt3 = dt2*dt ; - for (unsigned int i=0; i < size_measure*nsignal ; i++ ) { + for (unsigned int i=0; i < size_measure*n_signal ; i++ ) { // State model // | 1 dt | // F = | | @@ -443,7 +443,7 @@ vpLinearKalmanFilterInstantiation::initStateConstVel_MeasurePos(unsigned int nsi \right] \f] - \param nsignal : Number of signal to filter. + \param n_signal : Number of signal to filter. \param sigma_state : Vector that fix the variance of the state covariance matrix \f$[0 \; \sigma^2_Q]^T\f$. The dimension of @@ -505,7 +505,7 @@ int main() \endcode */ void -vpLinearKalmanFilterInstantiation::initStateConstVelWithColoredNoise_MeasureVel(unsigned int nsignal, +vpLinearKalmanFilterInstantiation::initStateConstVelWithColoredNoise_MeasureVel(unsigned int n_signal, vpColVector &sigma_state, vpColVector &sigma_measure, double rho) @@ -517,7 +517,7 @@ vpLinearKalmanFilterInstantiation::initStateConstVelWithColoredNoise_MeasureVel( setStateModel(stateConstVelWithColoredNoise_MeasureVel); - init(size_state, size_measure, nsignal); + init(size_state, size_measure, n_signal); iter = 0; Pest = 0; @@ -527,7 +527,7 @@ vpLinearKalmanFilterInstantiation::initStateConstVelWithColoredNoise_MeasureVel( R = 0; Q = 0; - for (unsigned int i=0; i < size_measure*nsignal ; i++ ) { + for (unsigned int i=0; i < size_measure*n_signal ; i++ ) { // State model // | 1 1 | // F = | | @@ -658,7 +658,7 @@ vpLinearKalmanFilterInstantiation::initStateConstVelWithColoredNoise_MeasureVel( \right] \f] - \param nsignal : Number of signal to filter. + \param n_signal : Number of signal to filter. \param sigma_state : Vector that fix the variance of the state covariance matrix \f$[0 \; \sigma^2_{Q_1} \; @@ -672,7 +672,7 @@ vpLinearKalmanFilterInstantiation::initStateConstVelWithColoredNoise_MeasureVel( \param rho : Degree of correlation between successive accelerations. Values are in [0:1[. - \param dt : Sampling time \f$\Delta t\f$ expressed is second. + \param delta_t : Sampling time \f$\Delta t\f$ expressed is second. \exception vpException::badValue : Bad rho value wich is not in [0:1[. @@ -728,11 +728,11 @@ int main() */ void -vpLinearKalmanFilterInstantiation::initStateConstAccWithColoredNoise_MeasureVel(unsigned int nsignal, +vpLinearKalmanFilterInstantiation::initStateConstAccWithColoredNoise_MeasureVel(unsigned int n_signal, vpColVector &sigma_state, vpColVector &sigma_measure, double rho, - double dt) + double delta_t) { if ((rho < 0) || (rho >= 1)) { vpERROR_TRACE("Bad rho value %g; should be in [0:1[", rho) ; @@ -740,7 +740,7 @@ vpLinearKalmanFilterInstantiation::initStateConstAccWithColoredNoise_MeasureVel( } setStateModel(stateConstAccWithColoredNoise_MeasureVel); - init(size_state, size_measure, nsignal); + init(size_state, size_measure, n_signal); iter = 0; Pest = 0; @@ -749,7 +749,7 @@ vpLinearKalmanFilterInstantiation::initStateConstAccWithColoredNoise_MeasureVel( H = 0; R = 0; Q = 0; - this->dt = dt; + this->dt = delta_t; // initialise les matrices decrivant les modeles for (unsigned int i=0; i < size_measure*nsignal ; i++ ) { // State model diff --git a/src/math/kalman/vpLinearKalmanFilterInstantiation.h b/src/math/kalman/vpLinearKalmanFilterInstantiation.h index 8429699533b7b17c8bb9506f58b73f90841cb7ce..5ff208bb0361f75af98f173a64b15741d825c232 100644 --- a/src/math/kalman/vpLinearKalmanFilterInstantiation.h +++ b/src/math/kalman/vpLinearKalmanFilterInstantiation.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpLinearKalmanFilterInstantiation.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpLinearKalmanFilterInstantiation.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -88,11 +88,12 @@ class VISP_EXPORT vpLinearKalmanFilterInstantiation : public vpKalmanFilter By default the state model is unknown and set to vpLinearKalmanFilterInstantiation::unknown. */ - vpLinearKalmanFilterInstantiation() : vpKalmanFilter() + vpLinearKalmanFilterInstantiation() : model(unknown) { - setStateModel(unknown); }; + /*! Destructor that does nothng. */ + virtual ~vpLinearKalmanFilterInstantiation() {}; /*! Return the current state model. */ @@ -155,8 +156,8 @@ int main() } \endcode */ -void vpLinearKalmanFilterInstantiation::setStateModel(vpStateModel model) { - this->model = model; +void vpLinearKalmanFilterInstantiation::setStateModel(vpStateModel mdl) { + this->model = mdl; switch(model) { case stateConstVel_MeasurePos: case stateConstVelWithColoredNoise_MeasureVel: diff --git a/src/math/matrix/vpColVector.cpp b/src/math/matrix/vpColVector.cpp index b765b2b9c0c4ab48d14c6495b8cd7a6fc99def52..f931cc8841ad1246cd91af33ee4614f647ac4c0c 100644 --- a/src/math/matrix/vpColVector.cpp +++ b/src/math/matrix/vpColVector.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpColVector.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpColVector.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -139,7 +139,7 @@ vpColVector::vpColVector (const vpRotationVector &v){ //! operator A = -A -vpColVector vpColVector::operator-() +vpColVector vpColVector::operator-() const { vpColVector A ; try { @@ -185,12 +185,10 @@ vpColVector vpColVector::operator*(double x) const */ vpColVector &vpColVector::operator=(const vpMatrix &m) { - - if (m.getCols() !=1) { vpTRACE(" m should be a 1 cols matrix ") ; - throw (vpException(vpException::dimensionError)," m should be a 1 cols matrix "); + throw (vpException(vpException::dimensionError,"m should be a 1 cols matrix ")); } try { diff --git a/src/math/matrix/vpColVector.h b/src/math/matrix/vpColVector.h index 3868f4e4c5d7505b4557cc87aed2ab926dddca26..3ec8895b97b6ee5e2e11b5b172bca715e23339e7 100644 --- a/src/math/matrix/vpColVector.h +++ b/src/math/matrix/vpColVector.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpColVector.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpColVector.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -121,7 +121,7 @@ public: //! operator multiplication by a scalar V = A * x vpColVector operator*(const double x) const; //! operator A = -A - vpColVector operator-() ; + vpColVector operator-() const; vpColVector rows(unsigned int first_row, unsigned int last_row) { @@ -175,20 +175,20 @@ public: */ inline void rad2deg() { - double rad2deg = 180.0/M_PI; + double r2d = 180.0/M_PI; for (unsigned int i=0; i < rowNum; i++) - (*this)[i] *= rad2deg; + (*this)[i] *= r2d; } /*! Convert a column vector containing angles in degrees into radians. */ inline void deg2rad() { - double deg2rad = M_PI/180.0; + double d2r = M_PI/180.0; for (unsigned int i=0; i < rowNum; i++) - (*this)[i] *= deg2rad; + (*this)[i] *= d2r; } /*! diff --git a/src/math/matrix/vpGEMM.h b/src/math/matrix/vpGEMM.h index c266fa6265240c4ede4312168d17c5c5466857aa..0360d0ea8556f25647ea1a7a3ec945154efc5a74 100644 --- a/src/math/matrix/vpGEMM.h +++ b/src/math/matrix/vpGEMM.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpGEMM.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpGEMM.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/math/matrix/vpMatrix.cpp b/src/math/matrix/vpMatrix.cpp index 674e6e4e336df113ca85aad8d08d059f93ba3aec..711b650533c3013a1b4f99fb708c2bae02b9205f 100644 --- a/src/math/matrix/vpMatrix.cpp +++ b/src/math/matrix/vpMatrix.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * -* $Id: vpMatrix.cpp 4210 2013-04-16 08:57:46Z fspindle $ +* $Id: vpMatrix.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. -* Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +* Copyright (C) 2005 - 2014 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 @@ -56,6 +56,7 @@ #include <visp/vpMatrix.h> #include <visp/vpMath.h> +#include <visp/vpHomography.h> #include <visp/vpTranslationVector.h> // Exception @@ -77,6 +78,10 @@ #include <cmath> // std::fabs #include <limits> // numeric_limits +#ifdef VISP_HAVE_GSL +#include <gsl/gsl_linalg.h> +#endif + #define DEBUG_LEVEL1 0 #define DEBUG_LEVEL2 0 @@ -109,8 +114,8 @@ Construction of the object matrix. Number of columns and rows are zero. */ vpMatrix::vpMatrix() + : rowNum(0), colNum(0), data(NULL), rowPtrs(NULL), dsize(0), trsize(0) { - init() ; } @@ -123,20 +128,25 @@ Initialize a matrix with 0. \param c : Matrix number of columns. */ vpMatrix::vpMatrix(unsigned int r, unsigned int c) + : rowNum(0), colNum(0), data(NULL), rowPtrs(NULL), dsize(0), trsize(0) { - init() ; resize(r, c); } +vpMatrix::vpMatrix(const vpHomography& H) + : rowNum(0), colNum(0), data(NULL), rowPtrs(NULL), dsize(0), trsize(0) +{ + (*this) = H; +} + /*! \brief submatrix constructor */ vpMatrix::vpMatrix(const vpMatrix &m, unsigned int r, unsigned int c, unsigned int nrows, unsigned int ncols) + : rowNum(0), colNum(0), data(NULL), rowPtrs(NULL), dsize(0), trsize(0) { - init() ; - if (((r + nrows) > m.rowNum) || ((c + ncols) > m.colNum)) { vpERROR_TRACE("\n\t\t SubvpMatrix larger than vpMatrix") ; @@ -149,9 +159,8 @@ vpMatrix::vpMatrix(const vpMatrix &m, //! copie constructor vpMatrix::vpMatrix(const vpMatrix& m) + : rowNum(0), colNum(0), data(NULL), rowPtrs(NULL), dsize(0), trsize(0) { - init() ; - resize(m.rowNum,m.colNum); memcpy(data,m.data,rowNum*colNum*sizeof(double)) ; @@ -222,8 +231,8 @@ void vpMatrix::resize(const unsigned int nrows, const unsigned int ncols, vpDEBUG_TRACE (25, "Recomputation this->trsize array values."); { - double **t= rowPtrs; - for (unsigned int i=0; i<dsize; i+=ncols) { *t++ = this->data + i; } + double **t_= rowPtrs; + for (unsigned int i=0; i<dsize; i+=ncols) { *t_++ = this->data + i; } } this->rowNum = nrows; this->colNum = ncols; @@ -332,6 +341,24 @@ vpMatrix::operator=(const vpMatrix &B) return *this; } +/*! +\brief Copy operator. +Allow operation such as A = H + +\param H : homography matrix to be copied. +*/ +vpMatrix & +vpMatrix::operator=(const vpHomography& H) +{ + init() ; + resize(3,3); + for(unsigned int i=0; i<3; i++) + for(unsigned int j=0; j<3; j++) + (*this)[i][j] = H[i][j]; + + return *this; +} + //! set all the element of the matrix A to x vpMatrix & vpMatrix::operator=(double x) @@ -441,6 +468,28 @@ vpMatrix vpMatrix::operator*(const vpMatrix &B) const return C; } +/*! + Allows to multiply a matrix by an homography. + Operation M = K * H (H is unchanged). + +*/ +vpMatrix vpMatrix::operator*(const vpHomography &H) const +{ + if (colNum != 3) + throw(vpException(vpMatrixException::dimensionError, "Cannot multiply the matrix by the homography; bad matrix size")); + vpMatrix M(rowNum, 3); + + for (unsigned int i=0;i<rowNum;i++){ + for (unsigned int j=0;j<3;j++) { + double s = 0; + for (unsigned int k=0;k<3;k++) s += (*this)[i][k] * H[k][j]; + M[i][j] = s; + } + } + + return M; +} + /*! Operation C = A*wA + B*wB @@ -859,7 +908,7 @@ vpMatrix::operator*(const vpTranslationVector &b) const if (rowNum != 3 || colNum != 3) { vpERROR_TRACE("vpMatrix mismatch in vpMatrix::operator*(const vpTranslationVector)") ; - throw(vpMatrixException::incorrectMatrixSizeError) ; + throw(vpMatrixException(vpMatrixException::incorrectMatrixSizeError, "vpMatrix mismatch in vpMatrix::operator*()")) ; } for (unsigned int j=0;j<3;j++) c[j]=0 ; @@ -1232,10 +1281,10 @@ void vpMatrix::transpose(vpMatrix & At )const{ for( unsigned int i = 0; i < colNum; i++ ) { - double * row = AtRowPtrs[i]; + double * row_ = AtRowPtrs[i]; double * col = rowPtrs[0]+i; for( unsigned int j = 0; j < rowNum; j++, col+=A_step ) - *(row++)=*col; + *(row_++)=*col; } } @@ -2380,7 +2429,7 @@ vpMatrix::insert(const vpMatrix &A, const vpMatrix &B, vpMatrix &C, const unsigned int r, const unsigned int c) { if( ( (r + B.getRows()) <= A.getRows() ) && - ( (c + B.getCols()) <= A.getRows() ) ){ + ( (c + B.getCols()) <= A.getCols() ) ){ try { C.resize(A.getRows(),A.getCols() ) ; } @@ -2573,8 +2622,10 @@ vpMatrix::createDiagonalMatrix(const vpColVector &A, vpMatrix &DA) /*! \brief std::cout a matrix */ -std::ostream &operator <<(std::ostream &s,const vpMatrix &m) +VISP_EXPORT std::ostream &operator <<(std::ostream &s,const vpMatrix &m) { + std::ios_base::fmtflags original_flags = s.flags(); + s.precision(10) ; for (unsigned int i=0;i<m.getRows();i++) { for (unsigned int j=0;j<m.getCols();j++){ @@ -2585,6 +2636,8 @@ std::ostream &operator <<(std::ostream &s,const vpMatrix &m) s << std::endl; } + s.flags(original_flags); // restore s to standard state + return s; } @@ -2622,6 +2675,8 @@ vpMatrix::print(std::ostream& s, unsigned int length, char const* intro) std::vector<std::string> values(m*n); std::ostringstream oss; std::ostringstream ossFixed; + std::ios_base::fmtflags original_flags = oss.flags(); + // ossFixed <<std::fixed; ossFixed.setf ( std::ios::fixed, std::ios::floatfield ); @@ -2690,6 +2745,8 @@ vpMatrix::print(std::ostream& s, unsigned int length, char const* intro) s <<std::endl; } + s.flags(original_flags); // restore s to standard state + return (int)(maxBefore+maxAfter); } @@ -2703,7 +2760,7 @@ d,e,f; g,h,i] */ std::ostream & vpMatrix:: -matlabPrint(std::ostream & os) +matlabPrint(std::ostream & os) const { unsigned int i,j; @@ -2732,7 +2789,7 @@ Print using the following way so that this output can be directly copied into MA ]) */ std::ostream & vpMatrix:: -maplePrint(std::ostream & os) +maplePrint(std::ostream & os) const { unsigned int i,j; @@ -2749,6 +2806,32 @@ maplePrint(std::ostream & os) return os; }; +/*! +\brief Print matrix in csv format. + +Print as comma separated values so that this output can be imported into any program which has a csv data import option: +0.939846, 0.0300754, 0.340272 +0.0300788, 0.984961, -0.170136 +-0.340272, 0.170136, 0.924807 +*/ +std::ostream & vpMatrix:: +csvPrint(std::ostream & os) const +{ + unsigned int i,j; + + for (i=0; i < this->getRows(); ++ i) + { + for (j=0; j < this->getCols(); ++ j) + { + os << (*this)[i][j]; + if (!(j==(this->getCols()-1))) + os << ", "; + } + os << std::endl; + } + return os; +}; + /*! \brief Print to be used as part of a C++ code later. @@ -2765,7 +2848,7 @@ the line vpMatrix A(6,7) (see example). each bytes of the double array. */ std::ostream & vpMatrix:: -cppPrint(std::ostream & os, const char * matrixName, bool octet) +cppPrint(std::ostream & os, const char * matrixName, bool octet) const { unsigned int i,j; @@ -2863,7 +2946,7 @@ See the Numerical Recipes in C page 43 for further explanations. double vpMatrix::detByLU() const { - double det(0); + double det_ = 0; // Test wether the matrix is squred if (rowNum == colNum) @@ -2884,10 +2967,10 @@ double vpMatrix::detByLU() const delete[]perm; // compute the determinant that is the product of the eigen values - det = (double) d; + det_ = (double) d; for(unsigned int i=0;i<rowNum;i++) { - det*=tmp[i][i]; + det_*=tmp[i][i]; } } @@ -2898,7 +2981,7 @@ double vpMatrix::detByLU() const } - return det ; + return det_ ; } @@ -3336,10 +3419,10 @@ vpMatrix::kernel(vpMatrix &kerA, double svThreshold) } // if (noyau == 1) { - double maxsv = 0 ; + maxsv = 0 ; for (i=0 ; i < ddl ; i++) if (fabs(sv[i]) > maxsv) maxsv = fabs(sv[i]) ; - unsigned int rank = 0 ; + rank = 0 ; for (i=0 ; i < ddl ; i++) if (fabs(sv[i]) > maxsv*svThreshold) rank++ ; vpMatrix cons(ddl,ddl) ; @@ -3412,14 +3495,14 @@ A.det(vpMatrix::LU_DECOMPOSITION ) << std::endl; */ double vpMatrix::det(vpDetMethod method) const { - double det = 0; + double det_ = 0; if ( method == LU_DECOMPOSITION ) { - det = this->detByLU(); + det_ = this->detByLU(); } - return (det); + return (det_); } @@ -3429,7 +3512,7 @@ Save a matrix to a file. \param filename : Absolute file name. \param M : Matrix to be saved. \param binary : If true the matrix is saved in a binary file, else a text file. -\param Header : Optional line that will be saved at the beginning of the file. +\param header : Optional line that will be saved at the beginning of the file. \return Returns true if no problem happened. @@ -3438,7 +3521,7 @@ less than if you save it in a binary file. */ bool vpMatrix::saveMatrix(const char *filename, const vpMatrix &M, - const bool binary, const char *Header) + const bool binary, const char *header) { std::fstream file; @@ -3459,10 +3542,10 @@ vpMatrix::saveMatrix(const char *filename, const vpMatrix &M, { unsigned int i = 0; file << "# "; - while (Header[i] != '\0') + while (header[i] != '\0') { - file << Header[i]; - if (Header[i] == '\n') + file << header[i]; + if (header[i] == '\n') file << "# "; i++; } @@ -3474,8 +3557,8 @@ vpMatrix::saveMatrix(const char *filename, const vpMatrix &M, else { int headerSize = 0; - while (Header[headerSize] != '\0') headerSize++; - file.write(Header,headerSize+1); + while (header[headerSize] != '\0') headerSize++; + file.write(header,headerSize+1); unsigned int matrixSize; matrixSize = M.getRows(); file.write((char*)&matrixSize,sizeof(int)); @@ -3497,21 +3580,119 @@ vpMatrix::saveMatrix(const char *filename, const vpMatrix &M, return true; } +/*! + Save a matrix in a YAML-formatted file. + + \param filename : absolute file name. + \param M : matrix to be saved in the file. + \param header : optional lines that will be saved at the beginning of the file. Should be YAML-formatted and will adapt to the indentation if any. + + \return Returns true if success. + + Here is an example of outputs. +\code +vpMatrix M(3,4); +vpMatrix::saveMatrixYAML("matrix.yml", M, "example: a YAML-formatted header"); +vpMatrix::saveMatrixYAML("matrixIndent.yml", M, "example:\n - a YAML-formatted header\n - with inner indentation"); +\endcode +Content of matrix.yml: +\code +example: a YAML-formatted header +rows: 3 +cols: 4 +data: + - [0, 0, 0, 0] + - [0, 0, 0, 0] + - [0, 0, 0, 0] +\endcode +Content of matrixIndent.yml: +\code +example: + - a YAML-formatted header + - with inner indentation +rows: 3 +cols: 4 +data: + - [0, 0, 0, 0] + - [0, 0, 0, 0] + - [0, 0, 0, 0] +\endcode + + \sa loadMatrixYAML() +*/ +bool vpMatrix::saveMatrixYAML(const char *filename, const vpMatrix &M, const char *header) +{ + std::fstream file; + + file.open(filename, std::fstream::out); + + if(!file) + { + file.close(); + return false; + } + + unsigned int i = 0; + bool inIndent = false; + std::string indent = ""; + bool checkIndent = true; + while (header[i] != '\0') + { + file << header[i]; + if(checkIndent) + { + if (inIndent) + { + if(header[i] == ' ') + indent += " "; + else if (indent.length() > 0) + checkIndent = false; + } + if (header[i] == '\n' || (inIndent && header[i] == ' ')) + inIndent = true; + else + inIndent = false; + } + i++; + } + + if(i != 0) + file << std::endl; + file << "rows: " << M.getRows() << std::endl; + file << "cols: " << M.getCols() << std::endl; + + if(indent.length() == 0) + indent = " "; + + file << "data: " << std::endl; + unsigned int j; + for(i=0;i<M.getRows();++i) + { + file << indent << "- ["; + for(j=0;j<M.getCols()-1;++j) + file << M[i][j] << ", "; + file << M[i][j] << "]" << std::endl; + } + + file.close(); + return true; +} + /*! - Load a matrix to a file. + Load a matrix from a file. \param filename : Absolute file name. \param M : Matrix to be loaded. \param binary : If true the matrix is loaded from a binary file, else from a text file. - \param Header : Header of the file loaded in this parameter. + \param header : header of the file loaded in this parameter. \return Returns true if no problem happened. */ bool vpMatrix::loadMatrix(const char *filename, vpMatrix &M, const bool binary, - char *Header) + char *header) { std::fstream file; @@ -3537,12 +3718,17 @@ vpMatrix::loadMatrix(const char *filename, vpMatrix &M, const bool binary, file.read(&c,1); h+=c; } - if (Header != NULL) - strncpy(Header, h.c_str(), h.size() + 1); + if (header != NULL) + strncpy(header, h.c_str(), h.size() + 1); unsigned int rows, cols; file >> rows; file >> cols; + + if (rows > std::numeric_limits<unsigned int>::max() + || cols > std::numeric_limits<unsigned int>::max()) + throw vpException(vpException::badValue, "Matrix exceed the max size."); + M.resize(rows,cols); double value; @@ -3564,8 +3750,8 @@ vpMatrix::loadMatrix(const char *filename, vpMatrix &M, const bool binary, file.read(&c,1); h+=c; } - if (Header != NULL) - strncpy(Header, h.c_str(), h.size() + 1); + if (header != NULL) + strncpy(header, h.c_str(), h.size() + 1); unsigned int rows, cols; file.read((char*)&rows,sizeof(unsigned int)); @@ -3589,6 +3775,88 @@ vpMatrix::loadMatrix(const char *filename, vpMatrix &M, const bool binary, } +/*! + Load a matrix from a YAML-formatted file. + + \param filename : absolute file name. + \param M : matrix to be loaded from the file. + \param header : header of the file is loaded in this parameter. + + \return Returns true on success. + + \sa saveMatrixYAML() + +*/ +bool +vpMatrix::loadMatrixYAML(const char *filename, vpMatrix &M, char *header) +{ + std::fstream file; + + file.open(filename, std::fstream::in); + + if(!file) + { + file.close(); + return false; + } + + unsigned int rows = 0,cols = 0; + std::string h; + std::string line,subs; + bool inheader = true; + unsigned int i=0, j; + unsigned int lineStart = 0; + + while ( getline (file,line) ) + { + if(inheader) + { + if(rows == 0 && line.compare(0,5,"rows:") == 0) + { + std::stringstream ss(line); + ss >> subs; + ss >> rows; + } + else if (cols == 0 && line.compare(0,5,"cols:") == 0) + { + std::stringstream ss(line); + ss >> subs; + ss >> cols; + } + else if (line.compare(0,5,"data:") == 0) + inheader = false; + else + h += line + "\n"; + } + else + { + // if i == 0, we just got out of the header: initialize matrix dimensions + if(i == 0) + { + if(rows == 0 || cols == 0) + { + file.close(); + return false; + } + M.resize(rows, cols); + // get indentation level which is common to all lines + lineStart = (unsigned int)line.find("[") + 1; + } + std::stringstream ss(line.substr(lineStart, line.find("]") - lineStart)); + j = 0; + while(getline(ss, subs, ',')) + M[i][j++] = atof(subs.c_str()); + i++; + } + } + + if (header != NULL) + strncpy(header, h.substr(0,h.length()-1).c_str(), h.size()); + + file.close(); + return true; +} + /*! Compute the exponential matrix of a square matrix. @@ -3607,6 +3875,21 @@ vpMatrix::expm() } else { +#ifdef VISP_HAVE_GSL + size_t size = rowNum * colNum; + double *b = new double [size]; + for (size_t i=0; i< size; i++) + b[i] = 0.; + gsl_matrix_view m = gsl_matrix_view_array(this->data, rowNum, colNum); + gsl_matrix_view em = gsl_matrix_view_array(b, rowNum, colNum); + gsl_linalg_exponential_ss(&m.matrix, &em.matrix, 0); + //gsl_matrix_fprintf(stdout, &em.matrix, "%g"); + vpMatrix expA(rowNum, colNum); + memcpy(expA.data, b, size * sizeof(double)); + + delete [] b; + return expA; +#else vpMatrix _expE(rowNum, colNum); vpMatrix _expD(rowNum, colNum); vpMatrix _expX(rowNum, colNum); @@ -3664,6 +3947,7 @@ vpMatrix::expm() exp=_expE; } return exp; +#endif } } @@ -3736,6 +4020,56 @@ vpMatrix subblock(const vpMatrix &M, unsigned int col, unsigned int row) return M_comp; } +/*! + \return The condition number, the ratio of the largest singular value of the matrix to the smallest. + */ +double vpMatrix::cond() +{ + vpMatrix v; + vpColVector w; + + vpMatrix M; + M = *this; + + M.svd(w, v); + double min=w[0]; + double max=w[0]; + for(unsigned int i=0;i<M.getCols();i++) + { + if(min>w[i])min=w[i]; + if(max<w[i])max=w[i]; + } + return max/min; +} + +/*! + Compute \f${\bf H} + \alpha * diag({\bf H})\f$ + \param H : input Matrix \f${\bf H}\f$. This matrix should be square. + \param alpha : Scalar \f$\alpha\f$ + \param HLM : Resulting operation. + */ +void vpMatrix::computeHLM(const vpMatrix &H, const double &alpha, vpMatrix &HLM) +{ + if(H.getCols() != H.getRows()) + { + vpTRACE("The matrix must be square"); + throw(vpMatrixException(vpMatrixException::incorrectMatrixSizeError, + "The matrix must be square" )); + } + HLM.resize(H.getRows(), H.getCols()); + + for(unsigned int i=0;i<H.getCols();i++) + { + for(unsigned int j=0;j<H.getCols();j++) + { + HLM[i][j]=H[i][j]; + if(i==j) + HLM[i][j]+= alpha*H[i][j]; + } + } + +} + #undef DEBUG_LEVEL1 #undef DEBUG_LEVEL2 diff --git a/src/math/matrix/vpMatrix.h b/src/math/matrix/vpMatrix.h index 6e574e4e5787a8a3bef23c1761e0f2a6aaa9ba2d..be6df84df4e7ecc954123b6fbb541b9214e4b250 100644 --- a/src/math/matrix/vpMatrix.h +++ b/src/math/matrix/vpMatrix.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMatrix.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMatrix.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -45,6 +45,7 @@ #define vpMatrix_H #include <visp/vpConfig.h> +#include <visp/vpException.h> #include <visp/vpTime.h> #ifdef VISP_HAVE_GSL @@ -63,6 +64,7 @@ class vpTranslationVector; class vpColVector; class vpTranslationVector; class vpRowVector; +class vpHomography; @@ -133,6 +135,8 @@ protected: vpMatrix(const vpMatrix &m, unsigned int r, unsigned int c, unsigned int nrows, unsigned int ncols) ; + vpMatrix(const vpHomography& H); + //! Destructor (Memory de-allocation) virtual ~vpMatrix(); @@ -176,50 +180,14 @@ protected: //@{ int print(std::ostream& s, unsigned int length, char const* intro=0); - std::ostream & matlabPrint(std::ostream & os); - std::ostream & maplePrint(std::ostream & os); - std::ostream & cppPrint(std::ostream & os, const char * matrixName = NULL, bool octet = false); + std::ostream & matlabPrint(std::ostream & os) const; + std::ostream & maplePrint(std::ostream & os) const; + std::ostream & csvPrint(std::ostream & os) const; + std::ostream & cppPrint(std::ostream & os, const char * matrixName = NULL, bool octet = false) const; void printSize() { std::cout << getRows() <<" x " << getCols() <<" " ; } //@} - static bool saveMatrix(const char *filename, const vpMatrix &M, const bool binary = false, const char *Header = ""); - static bool loadMatrix(const char *filename, vpMatrix &M, const bool binary = false, char *Header = NULL); - - /*! - Save a matrix to a file. - - \param filename : absolute file name - \param M : matrix to be saved - \param binary :If true the matrix is save in a binary file, else a text file. - \param Header : optional line that will be saved at the beginning of the file - - \return Returns true if no problem appends. - - Warning : If you save the matrix as in a text file the precision is less than if you save it in a binary file. - */ - static inline bool saveMatrix(std::string filename, const vpMatrix &M, - const bool binary = false, - const char *Header = "") - { - return vpMatrix::saveMatrix(filename.c_str(), M, binary, Header); - } - - /*! - Load a matrix to a file. - - \param filename : absolute file name - \param M : matrix to be loaded - \param binary :If true the matrix is load from a binary file, else from a text file. - \param Header : Header of the file is load in this parameter - - \return Returns true if no problem appends. - */ - static inline bool loadMatrix(std::string filename, vpMatrix &M, - const bool binary = false, char *Header = NULL) - { - return vpMatrix::loadMatrix(filename.c_str(), M, binary, Header); - } //--------------------------------- // Copy / assignment @@ -234,6 +202,8 @@ protected: //! Copy operator. Allow operation such as A = B vpMatrix &operator=(const vpMatrix &B); + //! Copy operator. Allow operation such as A = H + vpMatrix &operator=(const vpHomography &H); //! Set all the element of the matrix A to x vpMatrix &operator=(const double x); void diag(const vpColVector &A); @@ -245,24 +215,118 @@ protected: /** @name Access/modification operators */ //@{ //! write elements Aij (usage : A[i][j] = x ) - inline double *operator[](unsigned int n) { return rowPtrs[n]; } + inline double *operator[](unsigned int i) { return rowPtrs[i]; } //! read elements Aij (usage : x = A[i][j] ) - inline double *operator[](unsigned int n) const {return rowPtrs[n];} + inline double *operator[](unsigned int i) const {return rowPtrs[i];} //@} //--------------------------------- // Matrix operations (Static). - //--------------------------------- + //--------------------------------- - static void mult2Matrices(const vpMatrix &A, const vpMatrix &B, vpMatrix &C); static void add2Matrices(const vpMatrix &A, const vpMatrix &B, vpMatrix &C); static void add2WeightedMatrices(const vpMatrix &A, const double &wA, const vpMatrix &B,const double &wB, vpMatrix &C); - static void sub2Matrices(const vpMatrix &A, const vpMatrix &B, vpMatrix &C); - static void negateMatrix(const vpMatrix &A, vpMatrix &C); - static void multMatrixVector(const vpMatrix &A, const vpColVector &b, vpColVector &c); - static vpMatrix computeCovarianceMatrix(const vpMatrix &A, const vpColVector &x, const vpColVector &b); static vpMatrix computeCovarianceMatrix(const vpMatrix &A, const vpColVector &x, const vpColVector &b, const vpMatrix &w); + static void computeHLM(const vpMatrix &H, const double &alpha, vpMatrix &HLM); + + // Create a diagonal matrix with the element of a vector DAii = Ai + static void createDiagonalMatrix(const vpColVector &A, vpMatrix &DA) ; + // Insert matrix A in the current matrix at the given position (r, c). + void insert(const vpMatrix&A, const unsigned int r, const unsigned int c); + // Insert matrix B in matrix A at the given position (r, c). + static vpMatrix insert(const vpMatrix &A,const vpMatrix &B, const unsigned int r, const unsigned int c) ; + // Insert matrix B in matrix A (not modified) at the given position (r, c), the result is given in matrix C. + static void insert(const vpMatrix &A, const vpMatrix &B, vpMatrix &C, const unsigned int r, const unsigned int c) ; + + // Juxtapose to matrices C = [ A B ] + static vpMatrix juxtaposeMatrices(const vpMatrix &A,const vpMatrix &B) ; + // Juxtapose to matrices C = [ A B ] + static void juxtaposeMatrices(const vpMatrix &A,const vpMatrix &B, vpMatrix &C) ; + // Compute Kronecker product matrix + static void kron(const vpMatrix &m1, const vpMatrix &m2 , vpMatrix &out); + + // Compute Kronecker product matrix + static vpMatrix kron(const vpMatrix &m1, const vpMatrix &m2 ); + + /*! + Load a matrix from a file. + + \param filename : absolute file name + \param M : matrix to be loaded + \param binary :If true the matrix is loaded from a binary file, else from a text file. + \param Header : Header of the file is loaded in this parameter + + \return Returns true if no problem appends. + */ + static inline bool loadMatrix(std::string filename, vpMatrix &M, + const bool binary = false, char *Header = NULL) + { + return vpMatrix::loadMatrix(filename.c_str(), M, binary, Header); + } + static bool loadMatrix(const char *filename, vpMatrix &M, const bool binary = false, char *Header = NULL); + static void mult2Matrices(const vpMatrix &A, const vpMatrix &B, vpMatrix &C); + static void multMatrixVector(const vpMatrix &A, const vpColVector &b, vpColVector &c); + static void negateMatrix(const vpMatrix &A, vpMatrix &C); + /*! + Save a matrix to a file. + + \param filename : absolute file name + \param M : matrix to be saved + \param binary :If true the matrix is save in a binary file, else a text file. + \param Header : optional line that will be saved at the beginning of the file + + \return Returns true if no problem appends. + + Warning : If you save the matrix as in a text file the precision is less than if you save it in a binary file. + */ + static inline bool saveMatrix(std::string filename, const vpMatrix &M, + const bool binary = false, + const char *Header = "") + { + return vpMatrix::saveMatrix(filename.c_str(), M, binary, Header); + } + static bool saveMatrix(const char *filename, const vpMatrix &M, const bool binary = false, const char *Header = ""); + + /*! + Save a matrix in a YAML-formatted file. + + \param filename : absolute file name. + \param M : matrix to be saved in the file. + \param header : optional lines that will be saved at the beginning of the file. Should be YAML-formatted and will adapt to the indentation if any. + + \return Returns true if success. + + */ + static inline bool saveMatrixYAML(std::string filename, const vpMatrix &M, const char *header = "") + { + return vpMatrix::saveMatrixYAML(filename.c_str(), M, header); + } + static bool saveMatrixYAML(const char *filename, const vpMatrix &M, const char *header = ""); + /*! + Load a matrix from a YAML-formatted file. + + \param filename : absolute file name. + \param M : matrix to be loaded from the file. + \param header : Header of the file is loaded in this parameter. + + \return Returns true if no problem appends. + */ + static inline bool loadMatrixYAML(std::string filename, vpMatrix &M, char *header = NULL) + { + return vpMatrix::loadMatrixYAML(filename.c_str(), M, header); + } + static bool loadMatrixYAML(const char *filename, vpMatrix &M, char *header = NULL); + + + // Stack the matrix A below the current one, copy if not initialized this = [ this A ]^T + void stackMatrices(const vpMatrix &A); + //! Stack two Matrices C = [ A B ]^T + static vpMatrix stackMatrices(const vpMatrix &A,const vpMatrix &B) ; + //! Stack two Matrices C = [ A B ]^T + static void stackMatrices(const vpMatrix &A,const vpMatrix &B, vpMatrix &C) ; + static void sub2Matrices(const vpMatrix &A, const vpMatrix &B, vpMatrix &C); + //--------------------------------- // Matrix operations. @@ -275,6 +339,7 @@ protected: vpMatrix &operator-=(const vpMatrix &B); vpMatrix operator*(const vpMatrix &B) const; + vpMatrix operator*(const vpHomography &H) const; vpMatrix operator+(const vpMatrix &B) const; vpMatrix operator-(const vpMatrix &B) const; vpMatrix operator-() const; @@ -372,13 +437,6 @@ protected: vpMatrix kron(const vpMatrix &m1); //@} - // Compute Kronecker product matrix - static void kron(const vpMatrix &m1, const vpMatrix &m2 , vpMatrix &out); - - // Compute Kronecker product matrix - static vpMatrix kron(const vpMatrix &m1, const vpMatrix &m2 ); - - //------------------------------------------------- // Matrix inversion //------------------------------------------------- @@ -460,6 +518,7 @@ protected: vpColVector solveBySVD(const vpColVector &B) const ; unsigned int kernel(vpMatrix &KerA, double svThreshold=1e-6); + double cond(); //@} //------------------------------------------------- @@ -474,28 +533,6 @@ protected: void eigenValues(vpColVector &evalue, vpMatrix &evector); //@} - //! Stack two Matrices C = [ A B ]^T - static vpMatrix stackMatrices(const vpMatrix &A,const vpMatrix &B) ; - //! Stack two Matrices C = [ A B ]^T - static void stackMatrices(const vpMatrix &A,const vpMatrix &B, vpMatrix &C) ; - // Juxtapose to matrices C = [ A B ] - static vpMatrix juxtaposeMatrices(const vpMatrix &A,const vpMatrix &B) ; - // Juxtapose to matrices C = [ A B ] - static void juxtaposeMatrices(const vpMatrix &A,const vpMatrix &B, vpMatrix &C) ; - - // Create a diagonal matrix with the element of a vector DAii = Ai - static void createDiagonalMatrix(const vpColVector &A, vpMatrix &DA) ; - - // Stack the matrix A below the current one, copy if not initialized this = [ this A ]^T - void stackMatrices(const vpMatrix &A); - - // Insert matrix A in the current matrix at the given position (r, c). - void insert(const vpMatrix&A, const unsigned int r, const unsigned int c); - // Insert matrix B in matrix A at the given position (r, c). - static vpMatrix insert(const vpMatrix &A,const vpMatrix &B, const unsigned int r, const unsigned int c) ; - // Insert matrix B in matrix A (not modified) at the given position (r, c), the result is given in matrix C. - static void insert(const vpMatrix &A, const vpMatrix &B, vpMatrix &C, const unsigned int r, const unsigned int c) ; - // ------------------------- // Norms // ------------------------- diff --git a/src/math/matrix/vpMatrixException.h b/src/math/matrix/vpMatrixException.h index 60ba790d15d44f5140969def874727cf97ad2ebf..2d23f349c90cb545d4fc5b53918835c99f66ae02 100644 --- a/src/math/matrix/vpMatrixException.h +++ b/src/math/matrix/vpMatrixException.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMatrixException.h 4195 2013-04-05 08:28:41Z marchand $ + * $Id: vpMatrixException.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -68,12 +68,12 @@ */ class VISP_EXPORT vpMatrixException : public vpException { -public: - /*! + public: + /*! \brief Lists the possible error than can be emmited while calling vpMatrix member */ - enum errorCodeEnum + enum errorCodeEnum { //! error returns by a constructor constructionError, @@ -92,25 +92,20 @@ public: rankDeficient } ; -public: - vpMatrixException (const int code, const char * msg) - : vpException(code, msg){ ; } - vpMatrixException (const int code, const std::string & msg) - : vpException(code, msg){ ; } - vpMatrixException (const int code) - : vpException(code){ ; } - // vpMatrixException() : vpException() { ;} + public: + vpMatrixException (const int id, const char* format, ...) + { + this->code = id; + va_list args; + va_start(args, format); + setMessage(format, args); + va_end (args); + } + vpMatrixException (const int id, const std::string & msg) + : vpException(id, msg){ ; } + vpMatrixException (const int id) + : vpException(id){ ; } + // vpMatrixException() : vpException() { ;} }; - - - - -#endif /* #ifndef __vpMatrixException_ERROR_H */ - - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ +#endif diff --git a/src/math/matrix/vpMatrix_cholesky.cpp b/src/math/matrix/vpMatrix_cholesky.cpp index b3200842991697c27efeedc27ea27dca8bf785dd..ec4af3f496e163d8116c16b3010599b1ed790d03 100644 --- a/src/math/matrix/vpMatrix_cholesky.cpp +++ b/src/math/matrix/vpMatrix_cholesky.cpp @@ -3,7 +3,7 @@ * $Id: vpMatrix_lu.cpp 3530 2012-01-03 10:52:12Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -60,30 +60,27 @@ extern "C" int dpotri_(char *uplo, int *n, double *a, int *lda, int *info); #ifdef VISP_HAVE_LAPACK vpMatrix vpMatrix::inverseByCholeskyLapack() const{ - int rowNum = (int)this->getRows(); - int lda = (int)rowNum; //lda is the number of rows because we don't use a submatrix + int rowNum_ = (int)this->getRows(); + int lda = (int)rowNum_; //lda is the number of rows because we don't use a submatrix int info; vpMatrix A = *this; - dpotrf_((char*)"L",&rowNum,A.data,&lda,&info); + dpotrf_((char*)"L",&rowNum_,A.data,&lda,&info); if(info!=0) std::cout << "cholesky:dpotrf_:error" << std::endl; - dpotri_((char*)"L",&rowNum,A.data,&lda,&info); + dpotri_((char*)"L",&rowNum_,A.data,&lda,&info); if(info!=0){ std::cout << "cholesky:dpotri_:error" << std::endl; throw vpMatrixException::badValue; } - for(unsigned int i=0;i<A.getRows();i++) for(unsigned int j=0;j<A.getCols();j++) if(i>j) A[i][j] = A[j][i]; - return A; - } #endif @@ -102,9 +99,10 @@ int main() { vpMatrix A(4,4); - A[0][0] = 1/1.; A[0][1] = 1/2.; A[0][2] = 1/3.; A[0][3] = 1/4.; + // Symmetric matrix + A[0][0] = 1/1.; A[0][1] = 1/5.; A[0][2] = 1/6.; A[0][3] = 1/7.; A[1][0] = 1/5.; A[1][1] = 1/3.; A[1][2] = 1/3.; A[1][3] = 1/5.; - A[2][0] = 1/6.; A[2][1] = 1/4.; A[2][2] = 1/2.; A[2][3] = 1/6.; + A[2][0] = 1/6.; A[2][1] = 1/3.; A[2][2] = 1/2.; A[2][3] = 1/6.; A[3][0] = 1/7.; A[3][1] = 1/5.; A[3][2] = 1/6.; A[3][3] = 1/7.; // Compute the inverse diff --git a/src/math/matrix/vpMatrix_covariance.cpp b/src/math/matrix/vpMatrix_covariance.cpp index 12ebed274902429d4d949b44dc1394989176886d..9bb664424fa82ff75f05d504723083a9d7ea9047 100644 --- a/src/math/matrix/vpMatrix_covariance.cpp +++ b/src/math/matrix/vpMatrix_covariance.cpp @@ -3,7 +3,7 @@ * $Id: vpMatrix_lu.cpp 3530 2012-01-03 10:52:12Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/math/matrix/vpMatrix_lu.cpp b/src/math/matrix/vpMatrix_lu.cpp index 8833e6d878d338a824ee5944296f4dd772a69b16..d43710efa7fc95ca2c74ebf0ef60856b37d51ef2 100644 --- a/src/math/matrix/vpMatrix_lu.cpp +++ b/src/math/matrix/vpMatrix_lu.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMatrix_lu.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMatrix_lu.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -260,7 +260,13 @@ vpMatrix::inverseByLU() const unsigned int *perm = new unsigned int[rowNum]; int p; - A.LUDcmp(perm, p); + try { + A.LUDcmp(perm, p); + } + catch(vpException e) { + delete [] perm; + throw(e); + } vpColVector c_tmp(rowNum) ; for (j=1; j<=rowNum; j++) diff --git a/src/math/matrix/vpMatrix_qr.cpp b/src/math/matrix/vpMatrix_qr.cpp index 8708bed3ad4e4bdf8590f6c2a3ecfc3dfaf13c18..e56d02943a86d047d74d82e9e606d51ab2cd8b7b 100644 --- a/src/math/matrix/vpMatrix_qr.cpp +++ b/src/math/matrix/vpMatrix_qr.cpp @@ -3,7 +3,7 @@ * $Id: vpMatrix_lu.cpp 3530 2012-01-03 10:52:12Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -39,6 +39,7 @@ * *****************************************************************************/ +#include <algorithm> // for std::min and std::max #include <visp/vpConfig.h> #include <visp/vpMatrix.h> @@ -52,6 +53,7 @@ // Debug trace #include <visp/vpDebug.h> +int allocate_work(double** work); #ifdef VISP_HAVE_LAPACK extern "C" int dgeqrf_(int *m, int *n, double*a, int *lda, double *tau, double *work, int *lwork, int *info); @@ -63,18 +65,19 @@ extern "C" int dorgqr_(int *, int *, int *, double *, int *, extern "C" int dtrtri_(char *uplo, char *diag, int *n, double *a, int *lda, int *info); #endif -int allocate_work(double** work){ - int dimWork = (int)((*work)[0]); +int allocate_work(double** work) +{ + unsigned int dimWork = (unsigned int)((*work)[0]); delete[] *work; *work = new double[dimWork]; - return dimWork; + return (int)dimWork; } #ifdef VISP_HAVE_LAPACK vpMatrix vpMatrix::inverseByQRLapack() const{ - int rowNum = (int)this->getRows(); - int colNum = (int)this->getCols(); - int lda = (int)rowNum; //lda is the number of rows because we don't use a submatrix - int dimTau = std::min(rowNum,colNum); + int rowNum_ = (int)this->getRows(); + int colNum_ = (int)this->getCols(); + int lda = (int)rowNum_; //lda is the number of rows because we don't use a submatrix + int dimTau = std::min(rowNum_,colNum_); int dimWork = -1; double *tau = new double[dimTau]; double *work = new double[1]; @@ -85,8 +88,8 @@ vpMatrix vpMatrix::inverseByQRLapack() const{ try{ //1) Extract householder reflections (useful to compute Q) and R dgeqrf_( - &rowNum, //The number of rows of the matrix A. M >= 0. - &colNum, //The number of columns of the matrix A. N >= 0. + &rowNum_, //The number of rows of the matrix A. M >= 0. + &colNum_, //The number of columns of the matrix A. N >= 0. A.data, /*On entry, the M-by-N matrix A. On exit, the elements on and above the diagonal of the array contain the min(M,N)-by-N upper trapezoidal matrix R (R is @@ -110,8 +113,8 @@ vpMatrix vpMatrix::inverseByQRLapack() const{ dimWork = allocate_work(&work); dgeqrf_( - &rowNum, //The number of rows of the matrix A. M >= 0. - &colNum, //The number of columns of the matrix A. N >= 0. + &rowNum_, //The number of rows of the matrix A. M >= 0. + &colNum_, //The number of columns of the matrix A. N >= 0. A.data, /*On entry, the M-by-N matrix A. On exit, the elements on and above the diagonal of the array contain the min(M,N)-by-N upper trapezoidal matrix R (R is @@ -156,7 +159,6 @@ vpMatrix vpMatrix::inverseByQRLapack() const{ for(unsigned int j=0;j<C.getRows();j++) if(j>i) C[i][j] = 0.; - dimWork = -1; int ldc = lda; @@ -164,14 +166,14 @@ vpMatrix vpMatrix::inverseByQRLapack() const{ //get R^-1*tQ //C contains R^-1 //A contains Q - dormqr_((char*)"R", (char*)"T", &rowNum, &colNum, &dimTau, A.data, &lda, tau, C.data, &ldc, work, &dimWork, &info); + dormqr_((char*)"R", (char*)"T", &rowNum_, &colNum_, &dimTau, A.data, &lda, tau, C.data, &ldc, work, &dimWork, &info); if(info != 0){ std::cout << "dormqr_:Preparation"<< -info << "th element had an illegal value" << std::endl; throw vpMatrixException::badValue; } dimWork = allocate_work(&work); - dormqr_((char*)"R", (char*)"T", &rowNum, &colNum, &dimTau, A.data, &lda, tau, C.data, &ldc, work, &dimWork, &info); + dormqr_((char*)"R", (char*)"T", &rowNum_, &colNum_, &dimTau, A.data, &lda, tau, C.data, &ldc, work, &dimWork, &info); if(info != 0){ std::cout << "dormqr_:"<< -info << "th element had an illegal value" << std::endl; diff --git a/src/math/matrix/vpMatrix_svd.cpp b/src/math/matrix/vpMatrix_svd.cpp index f6783b594a76ea15940f4da39cf16e6502154cce..4a9184e9aae62f2dcf6dfa1020de4b0fc149225c 100644 --- a/src/math/matrix/vpMatrix_svd.cpp +++ b/src/math/matrix/vpMatrix_svd.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMatrix_svd.cpp 4210 2013-04-16 08:57:46Z fspindle $ + * $Id: vpMatrix_svd.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -297,8 +297,10 @@ void vpMatrix::svdNr(vpColVector& W, vpMatrix& V) g=c*g; z=pythag(f,h); rv1[j]=z; - c=f/z; - s=h/z; + if ((std::fabs(z) > epsilon) /*|| (fabs(z) > EPS_SVD)*/) { + c=f/z; + s=h/z; + } f=x*c+g*s; g=g*c-x*s; h=y*s; @@ -593,8 +595,7 @@ void vpMatrix::svdLapack(vpColVector& W, vpMatrix& V){ dgesdd_( (char*)"S", &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, work, &lwork, iwork, &info ); if( info > 0 ) { - std::cout << "The algorithm computing SVD failed to converge." << std::endl; - + vpTRACE("The algorithm computing SVD failed to converge."); } V=V.transpose(); diff --git a/src/math/matrix/vpRowVector.cpp b/src/math/matrix/vpRowVector.cpp index 03a4adc104b3dbecc1d8d70bd633399b2b1b93af..a7b70e40a0967435de476a44c671e51cabd6e69b 100644 --- a/src/math/matrix/vpRowVector.cpp +++ b/src/math/matrix/vpRowVector.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRowVector.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRowVector.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -150,7 +150,8 @@ vpRowVector vpRowVector::operator*(const vpMatrix &A) const if (colNum != A.getRows()) { vpERROR_TRACE("vpMatrix mismatch in vpRowVector/matrix multiply") ; - throw(vpMatrixException::incorrectMatrixSizeError) ; + throw(vpMatrixException(vpMatrixException::incorrectMatrixSizeError, + "vpMatrix mismatch in vpRowVector/matrix multiply")) ; } c = 0.0; diff --git a/src/math/matrix/vpRowVector.h b/src/math/matrix/vpRowVector.h index 562a1fa127124db7a099f3d65044509714547af3..8d049a45dff8746f2174d24e495fb40503c8e42d 100644 --- a/src/math/matrix/vpRowVector.h +++ b/src/math/matrix/vpRowVector.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRowVector.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRowVector.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/math/matrix/vpSubColVector.cpp b/src/math/matrix/vpSubColVector.cpp index 4141fe426a6e27f371e70003ca2d2dd52cc34e80..4b93b5f0b0c9861a22fefb9002451c5df7f12b92 100644 --- a/src/math/matrix/vpSubColVector.cpp +++ b/src/math/matrix/vpSubColVector.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpSubColVector.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpSubColVector.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -46,15 +46,9 @@ #include <visp/vpDebug.h> #include <stdlib.h> -vpSubColVector::vpSubColVector(){ - data=NULL; - parent=NULL; - rowPtrs=NULL; - rowNum=0; - colNum=0; - pRowNum=0; - dsize=0; - trsize=0; +vpSubColVector::vpSubColVector() + : pRowNum(0), parent(NULL) +{ } /*! @@ -63,7 +57,9 @@ vpSubColVector::vpSubColVector(){ \param offset : offset where subColVector start in the parent colVector \param nrows : size of the subColVector */ -vpSubColVector::vpSubColVector(vpColVector &v, const unsigned int & offset,const unsigned int & nrows){ +vpSubColVector::vpSubColVector(vpColVector &v, const unsigned int & offset, const unsigned int & nrows) + : pRowNum(0), parent(NULL) +{ init(v,offset,nrows); } diff --git a/src/math/matrix/vpSubColVector.h b/src/math/matrix/vpSubColVector.h index 055091e8234077dd52f9e3baecb922ef58e48f5d..59cd355c284c03a7d7184e2eedc190a06e891754 100644 --- a/src/math/matrix/vpSubColVector.h +++ b/src/math/matrix/vpSubColVector.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpSubColVector.h 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpSubColVector.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/math/matrix/vpSubMatrix.cpp b/src/math/matrix/vpSubMatrix.cpp index 9a6939c1e9e8bcca4a580b0d5781513cf35ee7c4..6ba81a2f45d1684ed5457eaa774f386f342a49ba 100644 --- a/src/math/matrix/vpSubMatrix.cpp +++ b/src/math/matrix/vpSubMatrix.cpp @@ -1,11 +1,11 @@ /**************************************************************************** * - * $Id: vpSubMatrix.cpp 4057 2013-01-05 13:10:29Z fspindle $ + * $Id: vpSubMatrix.cpp 4649 2014-02-07 14:57:11Z fspindle $ * - * Copyright (C) 2005 - 2013 Inria. All rights reserved. + * Copyright (C) 2005 - 2014 Inria. All rights reserved. * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -46,39 +46,35 @@ #include <visp/vpDebug.h> #include <stdlib.h> -vpSubMatrix::vpSubMatrix(){ - data=NULL; - parent=NULL; - rowPtrs=NULL; - rowNum=0; - colNum=0; - pRowNum=0; - pColNum=0; - dsize=0; - trsize=0; +vpSubMatrix::vpSubMatrix() + : pRowNum(0), pColNum(0), parent(NULL) +{ } /*! \brief Constructor \param m : parent matrix - \param row : row offset - \param col : col offset + \param row_offset : row offset + \param col_offset : col offset \param nrows : number of rows of the sub matrix \param ncols : number of columns of the sub matrix */ -vpSubMatrix::vpSubMatrix(vpMatrix &m, const unsigned int & row, const unsigned int &col , const unsigned int & nrows , const unsigned int & ncols){ - init(m,row,col,nrows,ncols); +vpSubMatrix::vpSubMatrix(vpMatrix &m, const unsigned int &row_offset, const unsigned int &col_offset, + const unsigned int & nrows, const unsigned int & ncols) + : pRowNum(0), pColNum(0), parent(NULL) +{ + init(m,row_offset,col_offset,nrows,ncols); } /*! \brief Initialisation of a sub matrix \param m : parent matrix - \param row : row offset - \param col : col offset + \param row_offset : row offset + \param col_offset : col offset \param nrows : number of rows of the sub matrix \param ncols : number of columns of the sub matrix */ -void vpSubMatrix::init(vpMatrix &m, const unsigned int & row, const unsigned int &col , const unsigned int & nrows , const unsigned int & ncols){ +void vpSubMatrix::init(vpMatrix &m, const unsigned int &row_offset, const unsigned int &col_offset , const unsigned int & nrows , const unsigned int & ncols){ if(! m.data){ vpERROR_TRACE("\n\t\t SubMatrix parent matrix is not allocated") ; @@ -86,7 +82,7 @@ void vpSubMatrix::init(vpMatrix &m, const unsigned int & row, const unsigned int "\n\t\t SubMatrix parent matrix is not allocated")) ; } - if(row+nrows <= m.getRows() && col+ncols <= m.getCols()){ + if(row_offset+nrows <= m.getRows() && col_offset+ncols <= m.getCols()){ data=m.data; parent =&m; rowNum = nrows; @@ -99,7 +95,7 @@ void vpSubMatrix::init(vpMatrix &m, const unsigned int & row, const unsigned int rowPtrs=(double**) malloc(nrows * sizeof(double*)); for(unsigned int r=0;r<nrows;r++) - rowPtrs[r]= m.data+col+(r+row)*pColNum; + rowPtrs[r]= m.data+col_offset+(r+row_offset)*pColNum; dsize = pRowNum*pColNum ; trsize =0 ; diff --git a/src/math/matrix/vpSubMatrix.h b/src/math/matrix/vpSubMatrix.h index b33af1bdb76a71c1180d7010a6d7c012c5e1c9c0..9dcae3e89a0e38f86b72357c73bec42b1d79765d 100644 --- a/src/math/matrix/vpSubMatrix.h +++ b/src/math/matrix/vpSubMatrix.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpSubMatrix.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpSubMatrix.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/math/matrix/vpSubRowVector.cpp b/src/math/matrix/vpSubRowVector.cpp index c206161152edcdbb092b5b6c5ff8940df3f359ee..935f0cb27685f170005c84250a700f8fc3a2f5d0 100644 --- a/src/math/matrix/vpSubRowVector.cpp +++ b/src/math/matrix/vpSubRowVector.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpSubRowVector.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpSubRowVector.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -46,16 +46,10 @@ #include <visp/vpDebug.h> #include <stdlib.h> - vpSubRowVector::vpSubRowVector(){ - data=NULL; - parent=NULL; - rowPtrs=NULL; - rowNum=0; - colNum=0; - pColNum=0; - dsize=0; - trsize=0; - } +vpSubRowVector::vpSubRowVector() + : pColNum(0), parent(NULL) +{ +} /*! \brief Constructor @@ -63,8 +57,10 @@ \param offset : offset where subRowVector start in the parent vector \param ncols : size of the subRowVector */ -vpSubRowVector::vpSubRowVector(vpRowVector &v, const unsigned int & offset,const unsigned int & ncols){ - init(v,offset,ncols); +vpSubRowVector::vpSubRowVector(vpRowVector &v, const unsigned int & offset,const unsigned int & ncols) + : pColNum(0), parent(NULL) +{ + init(v, offset, ncols); } /*! diff --git a/src/math/matrix/vpSubRowVector.h b/src/math/matrix/vpSubRowVector.h index 331220e4848373dc211910e207837bf2fb5f2389..eb91bfaa420a8ac19b6b16389c4e6698b2f093b9 100644 --- a/src/math/matrix/vpSubRowVector.h +++ b/src/math/matrix/vpSubRowVector.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpSubRowVector.h 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpSubRowVector.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/math/misc/vpHinkley.cpp b/src/math/misc/vpHinkley.cpp index 73b490aa3a8345fbc5468e5c5f4fa3627c04d4c1..d7d88939bf5b9f4d60f27d7db6a5a199b7f81c9e 100755 --- a/src/math/misc/vpHinkley.cpp +++ b/src/math/misc/vpHinkley.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpHinkley.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpHinkley.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -78,11 +78,8 @@ */ vpHinkley::vpHinkley() + : dmin2(0.1), alpha(0.2), nsignal(0), mean(0), Sk(0), Mk(0), Tk(0), Nk(0) { - init(); - - setAlpha(0.2); - setDelta(0.2); } /*! @@ -92,21 +89,18 @@ vpHinkley::vpHinkley() Call init() to initialise the Hinkley's test and set \f$\alpha\f$ and \f$\delta\f$ thresholds. - \param alpha : \f$\alpha\f$ is a predefined threshold. + \param alpha_val : \f$\alpha\f$ is a predefined threshold. - \param delta : \f$\delta\f$ denotes the jump minimal magnitude that + \param delta_val : \f$\delta\f$ denotes the jump minimal magnitude that we want to detect. \sa setAlpha(), setDelta() */ -vpHinkley::vpHinkley(double alpha, double delta) +vpHinkley::vpHinkley(double alpha_val, double delta_val) + : dmin2(delta_val/2.), alpha(alpha_val), nsignal(0), mean(0), Sk(0), Mk(0), Tk(0), Nk(0) { - init(); - - setAlpha(alpha); - setDelta(delta); } /*! @@ -114,21 +108,21 @@ vpHinkley::vpHinkley(double alpha, double delta) Call init() to initialise the Hinkley's test and set \f$\alpha\f$ and \f$\delta\f$ thresholds. - \param alpha : \f$\alpha\f$ is a predefined threshold. + \param alpha_val : \f$\alpha\f$ is a predefined threshold. - \param delta : \f$\delta\f$ denotes the jump minimal magnitude that + \param delta_val : \f$\delta\f$ denotes the jump minimal magnitude that we want to detect. \sa setAlpha(), setDelta() */ void -vpHinkley::init(double alpha, double delta) +vpHinkley::init(double alpha_val, double delta_val) { init(); - setAlpha(alpha); - setDelta(delta); + setAlpha(alpha_val); + setDelta(delta_val); } /*! @@ -178,9 +172,9 @@ void vpHinkley::setDelta(double delta) \sa setDelta() */ -void vpHinkley::setAlpha(double alpha) +void vpHinkley::setAlpha(double alpha_val) { - this->alpha = alpha; + this->alpha = alpha_val; } /*! diff --git a/src/math/misc/vpHinkley.h b/src/math/misc/vpHinkley.h index 197e6a17e8b3ac7ea39a0dfaad2f6dfb7c3c5996..97fad8379916e277e155049fffb05577c56e6b09 100755 --- a/src/math/misc/vpHinkley.h +++ b/src/math/misc/vpHinkley.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpHinkley.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpHinkley.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/math/misc/vpMath.cpp b/src/math/misc/vpMath.cpp index 692c83ffd270e5d661c18c993ad168b32362e649..ac637a1169ca617766b6d441cb45eb5d39c0d102 100644 --- a/src/math/misc/vpMath.cpp +++ b/src/math/misc/vpMath.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMath.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMath.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/math/misc/vpMath.h b/src/math/misc/vpMath.h index 2d991ea937ef5d7379d3997a055b9acad1031cc3..491fcf6a4aeeeea6d4bced41d78473309e1f31c3 100644 --- a/src/math/misc/vpMath.h +++ b/src/math/misc/vpMath.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMath.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMath.h 4604 2014-01-21 14:15:23Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -54,7 +54,7 @@ #include <math.h> -#ifdef WIN32 // Not defined in Microsoft math.h +#if defined(_WIN32) // Not defined in Microsoft math.h # ifndef M_PI # define M_PI 3.14159265358979323846f diff --git a/src/math/misc/vpNoise.cpp b/src/math/misc/vpNoise.cpp index 72553f880655d26e14ed9105e97248c5fc2b3890..d1616ae4bbdfe4bd1ec685f241f0cd29ea13b131 100644 --- a/src/math/misc/vpNoise.cpp +++ b/src/math/misc/vpNoise.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpNoise.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpNoise.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/math/misc/vpNoise.h b/src/math/misc/vpNoise.h index ac9289d7c95c8ee7b091ac412a693766d48269d2..0db43e4bf9b15b1ae2382a1e0d40f9b97ffb8a38 100644 --- a/src/math/misc/vpNoise.h +++ b/src/math/misc/vpNoise.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpNoise.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpNoise.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -71,37 +71,26 @@ */ class VISP_EXPORT vpUniRand { - - - /*unsigned*/ long a ; - /*unsigned*/ long m ; //2^31-1 - /*unsigned*/ long q ; //integer part of m/a - /*unsigned*/ long r ;//r=m mod a - double normalizer ; //we use a normalizer > m to ensure ans will never be 1 (it is the case if x = 739806647) - - -private: - void draw0(); -protected: - long x; - double draw1(); - void init() - { - a = 16807 ; - m = /*(unsigned long)*/2147483647 ; //2^31-1 - q = 127773 ; //integer part of m/a - r = 2836 ;//r=m mod a - //we use a normalizer > m to ensure ans will never be - // 1 (it is the case if x = 739806647) - normalizer = 2147484721.0 ; - } - -public: - vpUniRand(const long seed = 0):x((seed)? seed : 739806647) - { - init() ; - } - double operator()() {return draw1();} + /*unsigned*/ long a ; + /*unsigned*/ long m ; //2^31-1 + /*unsigned*/ long q ; //integer part of m/a + /*unsigned*/ long r ;//r=m mod a + double normalizer ; //we use a normalizer > m to ensure ans will never be 1 (it is the case if x = 739806647) + + private: + void draw0(); + protected: + long x; + double draw1(); + + public: + vpUniRand(const long seed = 0) + : a(16807), m(2147483647), q(127773), r(2836), normalizer(2147484721.0), x((seed)? seed : 739806647) + { + } + virtual ~vpUniRand() {}; + + double operator()() {return draw1();} }; @@ -117,12 +106,11 @@ public: \code #include <iostream> - #include <visp/vpNoise.h> int main() { - vpGaussRand noise(0.5, 0); + vpGaussRand noise(0.5, 10); for(int i=0; i< 10; i++) { std::cout << "noise " << i << ": " << noise() << std::endl; } @@ -132,38 +120,54 @@ int main() */ class vpGaussRand : public vpUniRand { - double mean; - double sigma; - -public: - - // Initialization - vpGaussRand() {init();mean=0;sigma=0;x=739806647;} - vpGaussRand(const double sqrtvariance, - const double _mean, - const long seed = 0):mean(_mean), sigma(sqrtvariance) - { - init() ; - mean = 0 ; - if (seed) x=seed; else x=739806647; - } - /*! - Set the standard deviation and mean for gaussian noise - - \param _s new standard deviation - \param _m new mean - */ - inline void setSigmaMean(const double _s, const double _m) {mean=_m;sigma=_s;} - /*! - Set the seed of the noise - - \param seed new seed - */ - inline void seed(const long seed) {x=seed;} - inline double operator()() {return sigma*gaussianDraw()+mean;} - -private : - double gaussianDraw(); + private : + double mean; + double sigma; + double gaussianDraw(); + + public: + + /*! + Default noise generator constructor. + */ + vpGaussRand() : vpUniRand(), mean(0), sigma(0) {} + + /*! + Gaussian noise random generator constructor. + + \param sigma_val : Standard deviation. + \param mean_val : Mean value. + \param noise_seed : Seed of the noise + */ + vpGaussRand(const double sigma_val, const double mean_val, const long noise_seed = 0) + : vpUniRand(noise_seed), mean(mean_val), sigma(sigma_val) {} + + /*! + Set the standard deviation and mean for gaussian noise. + + \param sigma_val : New standard deviation sigma. + \param mean_val : New mean value. + */ + void setSigmaMean(const double sigma_val, const double mean_val) { + this->mean = mean_val; + this->sigma = sigma_val; + } + + /*! + Set the seed of the noise. + + \param seed_val : New seed. + */ + void seed(const long seed_val) { + x=seed_val; + } + + /*! + Return a random value from the Gaussian noise generator. + */ + double operator()() { + return sigma*gaussianDraw()+mean; + } }; #endif diff --git a/src/math/robust/vpRansac.h b/src/math/robust/vpRansac.h index 5f4d1d347350395a87debb018bf64944aba3048e..b3029d905e8f3f54faa3e083e25933eba79bd334 100644 --- a/src/math/robust/vpRansac.h +++ b/src/math/robust/vpRansac.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRansac.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRansac.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -63,16 +63,7 @@ \brief This class is a generic implementation of the Ransac algorithm. It cannot be used alone. - Creation: june, 15 2005 - - RANSAC is described in : - - M.A. Fishler and R.C. Boles. "Random sample consensus: A paradigm for model - fitting with applications to image analysis and automated cartography". Comm. - Assoc. Comp, Mach., Vol 24, No 6, pp 381-395, 1981 - - Richard Hartley and Andrew Zisserman. "Multiple View Geometry in - Computer Vision". pp 101-113. Cambridge University Press, 2001 + RANSAC is described in \cite Fischler81 and \cite Hartley01a. The code of this class is inspired by : Peter Kovesi @@ -81,14 +72,9 @@ pk at csse uwa edu au http://www.csse.uwa.edu.au/~pk - \sa vpHomography - */ - - - template <class vpTransformation> class vpRansac { @@ -114,7 +100,7 @@ public: npts is the number of data points. \param s : The minimum number of samples from x required by fitting fn to - fit a model. + fit a model. Value should be greater or equal to 4. \param t : The distance threshold between data point and the model used to decide whether a point is an inlier or not. @@ -141,22 +127,22 @@ vpRansac<vpTransformation>::ransac(unsigned int npts, vpColVector &x, vpColVector &inliers, int consensus, double /* areaThreshold */, - const int maxNbumbersOfTrials - ) + const int maxNbumbersOfTrials) { - - -/* bool isplanar; */ -/* if (s == 4) isplanar = true; */ -/* else isplanar = false; */ + /* bool isplanar; */ + /* if (s == 4) isplanar = true; */ + /* else isplanar = false; */ double eps = 1e-6 ; double p = 0.99; // Desired probability of choosing at least one sample - // free from outliers + // free from outliers int maxTrials = maxNbumbersOfTrials; // Maximum number of trials before we give up. int maxDataTrials = 1000; // Max number of attempts to select a non-degenerate - // data set. + // data set. + + if (s<4) + s = 4; // Sentinel value allowing detection of solution failure. bool solutionFind = false ; @@ -184,7 +170,7 @@ vpRansac<vpTransformation>::ransac(unsigned int npts, vpColVector &x, { // Generate s random indicies in the range 1..npts for (unsigned int i=0 ; i < s ; i++) - ind[i] = (unsigned int)ceil(random()*npts) -1; + ind[i] = (unsigned int)ceil(random()*npts) -1; // Test that these points are not a degenerate configuration. degenerate = vpTransformation::degenerateConfiguration(x,ind) ; @@ -194,10 +180,10 @@ vpRansac<vpTransformation>::ransac(unsigned int npts, vpColVector &x, count = count + 1; if (count > maxDataTrials) { - delete [] ind; - vpERROR_TRACE("Unable to select a nondegenerate data set"); - throw(vpException(vpException::fatalError, "Unable to select a nondegenerate data set")); - //return false; //Useless after a throw() function + delete [] ind; + vpERROR_TRACE("Unable to select a nondegenerate data set"); + throw(vpException(vpException::fatalError, "Unable to select a nondegenerate data set")); + //return false; //Useless after a throw() function } } // Fit model to this random selection of data points. @@ -215,9 +201,9 @@ vpRansac<vpTransformation>::ransac(unsigned int npts, vpColVector &x, double resid = fabs(d[i]); if (resid < t) { - inliers[i] = 1 ; - ninliers++ ; - residual += fabs(d[i]); + inliers[i] = 1 ; + ninliers++ ; + residual += fabs(d[i]); } else inliers[i] = 0; } diff --git a/src/math/robust/vpRobust.cpp b/src/math/robust/vpRobust.cpp index d404fcf28a0ae86ff2ef906b5749ae464096a749..835574178b28b6946433dfc61ecdaa4f19c94419 100644 --- a/src/math/robust/vpRobust.cpp +++ b/src/math/robust/vpRobust.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRobust.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRobust.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -70,16 +70,14 @@ */ vpRobust::vpRobust(unsigned int n_data) + : normres(), sorted_normres(), sorted_residues(), NoiseThreshold(0.0017), sig_prev(0), it(0), swap(0), size(n_data) { vpCDEBUG(2) << "vpRobust constructor reached" << std::endl; - size=n_data; normres.resize(n_data); sorted_normres.resize(n_data); sorted_residues.resize(n_data); - it=0; - NoiseThreshold=0.0017; //Can not be more accurate than 1 pixel - + // NoiseThreshold=0.0017; //Can not be more accurate than 1 pixel } /*! @@ -354,7 +352,7 @@ vpRobust::simultMEstimator(vpColVector &residues) double sigma=0; // Standard Deviation unsigned int n_data = residues.getRows(); - vpColVector normres(n_data); // Normalized Residue + vpColVector norm_res(n_data); // Normalized Residue vpColVector w(n_data); vpCDEBUG(2) << "vpRobust MEstimator reached. No. data = " << n_data @@ -366,14 +364,14 @@ vpRobust::simultMEstimator(vpColVector &residues) // Normalize residues for(unsigned int i=0; i<n_data; i++) - normres[i] = (fabs(residues[i]- med)); + norm_res[i] = (fabs(residues[i]- med)); // Check for various methods. // For Huber compute Simultaneous scale estimate // For Others use MAD calculated on first iteration if(it==0) { - normmedian = select(normres, 0, n_data-1, ind_med/*(int)n_data/2*/); + normmedian = select(norm_res, 0, n_data-1, ind_med/*(int)n_data/2*/); // 1.48 keeps scale estimate consistent for a normal probability dist. sigma = 1.4826*normmedian; // Median Absolute Deviation } @@ -390,10 +388,9 @@ vpRobust::simultMEstimator(vpColVector &residues) sigma= NoiseThreshold; } - vpCDEBUG(2) << "MAD and C computed" << std::endl; - psiHuber(sigma, normres,w); + psiHuber(sigma, norm_res,w); sig_prev = sigma; diff --git a/src/math/robust/vpRobust.h b/src/math/robust/vpRobust.h index 39168c0434c954b5083f926c6514a0e87ce79e15..b6849689c797e77da8d89626bd5443793796c5ce 100644 --- a/src/math/robust/vpRobust.h +++ b/src/math/robust/vpRobust.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRobust.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRobust.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/math/robust/vpScale.cpp b/src/math/robust/vpScale.cpp index 15e3758f949c4c7f89bb8c3e1fabfb16cdddf974..dff1b375f96df150fab441e2494e803e51d423eb 100644 --- a/src/math/robust/vpScale.cpp +++ b/src/math/robust/vpScale.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpScale.cpp 4312 2013-07-16 15:12:42Z ayol $ + * $Id: vpScale.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -60,14 +60,11 @@ //! Constructor vpScale::vpScale() + : bandwidth(0.02), dimension(1), kernel_type(EPANECHNIKOV) { #if (DEBUG_LEVEL2) std::cout << "vpScale constructor reached" << std::endl; #endif - bandwidth = 0.02; - dimension = 1; - kernel_type = EPANECHNIKOV; - #if (DEBUG_LEVEL2) std::cout << "vpScale constructor finished" << std::endl; #endif @@ -75,31 +72,23 @@ vpScale::vpScale() } //! Constructor -vpScale::vpScale(double kernel_bandwidth, - int dimension=1, int kernel_type=EPANECHNIKOV) +vpScale::vpScale(double kernel_bandwidth, int dim=1, int type=EPANECHNIKOV) + : bandwidth(kernel_bandwidth), dimension(dim), kernel_type(type) + { #if (DEBUG_LEVEL2) std::cout << "vpScale constructor reached" << std::endl; #endif - - bandwidth = kernel_bandwidth; - this->dimension = (unsigned)dimension; - this->kernel_type = kernel_type; - #if (DEBUG_LEVEL2) std::cout << "vpScale constructor finished" << std::endl; #endif - } //! Destructor vpScale::~vpScale() { - } - - // Calculate the modes of the density for the distribution // and their associated errors double diff --git a/src/math/robust/vpScale.h b/src/math/robust/vpScale.h index 9c9c6dd90a72de3544fbab3c2d6e1604df89a2ad..a39029c1f52ffe75a5599f137b389a6fea3da734 100644 --- a/src/math/robust/vpScale.h +++ b/src/math/robust/vpScale.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpScale.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpScale.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/math/spline/vpBSpline.cpp b/src/math/spline/vpBSpline.cpp index f0ef2887c872646b5bcc3e9520f3f359d6a888f5..c78e194db1f83d286abb2b5caa39fc0d74652cc1 100644 --- a/src/math/spline/vpBSpline.cpp +++ b/src/math/spline/vpBSpline.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpBSpline.cpp 4303 2013-07-04 14:14:00Z fspindle $ + * $Id: vpBSpline.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -49,8 +49,9 @@ compute cubic B-Spline. */ vpBSpline::vpBSpline() + : controlPoints(), knots(), p(3), // By default : p=3 for clubic spline + crossingPoints() { - p = 3; //By default : clubic spline } /*! @@ -58,6 +59,8 @@ vpBSpline::vpBSpline() */ vpBSpline::vpBSpline(const vpBSpline &bspline) + : controlPoints(), knots(), p(3), // By default : p=3 for clubic spline + crossingPoints() { controlPoints = bspline.controlPoints; knots = bspline.knots; diff --git a/src/math/spline/vpBSpline.h b/src/math/spline/vpBSpline.h index cb7d93d603df92b68b75313e02dbf951487f5d55..c1c371f8521a4f69a6bde8d2e24c255fdc2c38f6 100644 --- a/src/math/spline/vpBSpline.h +++ b/src/math/spline/vpBSpline.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpBSpline.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpBSpline.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -168,9 +168,9 @@ class VISP_EXPORT vpBSpline /*! Sets the degree of the B-Spline. - \param p : the degree of the B-Spline. + \param degree : the degree of the B-Spline. */ - inline void set_p(unsigned int p) {this->p = p;} + inline void set_p(unsigned int degree) {this->p = degree;} /*! diff --git a/src/math/spline/vpNurbs.cpp b/src/math/spline/vpNurbs.cpp index 163a2887dd975dbae8a73003850e78b545b685ae..a413915030d003ca914046060e62b15610b5305a 100644 --- a/src/math/spline/vpNurbs.cpp +++ b/src/math/spline/vpNurbs.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpNurbs.cpp 4303 2013-07-04 14:14:00Z fspindle $ + * $Id: vpNurbs.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -64,6 +64,7 @@ inline double distance(const vpImagePoint &iP1, const double w1, const vpImagePo compute cubic NURBS. */ vpNurbs::vpNurbs() + : weights() { p = 3; } @@ -71,7 +72,7 @@ vpNurbs::vpNurbs() /*! Copy constructor. */ -vpNurbs::vpNurbs(const vpNurbs &nurbs) : vpBSpline(nurbs) +vpNurbs::vpNurbs(const vpNurbs &nurbs) : vpBSpline(nurbs), weights() { weights = nurbs.weights; } @@ -691,13 +692,19 @@ vpNurbs::removeCurveKnot(double u, unsigned int r, unsigned int num, double TOL) The result of the method is composed by a knot vector, a set of control points and a set of associated weights. \param l_crossingPoints : The list of data points which have to be interpolated. - \param l_p : Degree of the NURBS basis functions. + \param l_p : Degree of the NURBS basis functions. This value need to be > 0. \param l_knots : The knot vector \param l_controlPoints : the list of control points. \param l_weights : the list of weights. */ void vpNurbs::globalCurveInterp(std::vector<vpImagePoint> &l_crossingPoints, unsigned int l_p, std::vector<double> &l_knots, std::vector<vpImagePoint> &l_controlPoints, std::vector<double> &l_weights) { + if (l_p == 0) { + //vpERROR_TRACE("Bad degree of the NURBS basis functions"); + throw(vpException(vpException::badValue, + "Bad degree of the NURBS basis functions")) ; + } + l_knots.clear(); l_controlPoints.clear(); l_weights.clear(); @@ -786,8 +793,8 @@ void vpNurbs::globalCurveInterp(vpList<vpMeSite> &l_crossingPoints) l_crossingPoints.next(); while(!l_crossingPoints.outside()) { - vpMeSite s = l_crossingPoints.value(); - vpImagePoint pt(s.ifloat,s.jfloat); + s = l_crossingPoints.value(); + pt.set_ij(s.ifloat,s.jfloat); if (vpImagePoint::distance(pt_1,pt) >= 10) { v_crossingPoints.push_back(pt); @@ -890,11 +897,10 @@ void vpNurbs::globalCurveApprox(std::vector<vpImagePoint> &l_crossingPoints, uns d = (double)(m+1)/(double)(l_n-l_p+1); - double i; double alpha; for(unsigned int j = 1; j <= l_n-l_p; j++) { - i = floor(j*d); + double i = floor(j*d); alpha = j*d-i; l_knots.push_back((1.0-alpha)*ubar[(unsigned int)i-1]+alpha*ubar[(unsigned int)i]); } diff --git a/src/math/spline/vpNurbs.h b/src/math/spline/vpNurbs.h index f896637b6babd6568e400317178061df6e3f875e..f0d5fdb674c6fee39d432fb524feb12caa04c6b9 100644 --- a/src/math/spline/vpNurbs.h +++ b/src/math/spline/vpNurbs.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpNurbs.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpNurbs.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/math/transformation/vpExponentialMap.cpp b/src/math/transformation/vpExponentialMap.cpp index 2a66fe844852ee3452bb50f8ca7926877f10de9b..128df2245fe113c8bec358cf473b18b9be3bac64 100644 --- a/src/math/transformation/vpExponentialMap.cpp +++ b/src/math/transformation/vpExponentialMap.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpExponentialMap.cpp 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpExponentialMap.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/math/transformation/vpExponentialMap.h b/src/math/transformation/vpExponentialMap.h index 0ab20ef8bb4bfd556dc5d9781953aab28ae67b13..f8ed340d9efe1d1bab1e1cf4cf169558fec66421 100644 --- a/src/math/transformation/vpExponentialMap.h +++ b/src/math/transformation/vpExponentialMap.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpExponentialMap.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpExponentialMap.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/math/transformation/vpForceTwistMatrix.cpp b/src/math/transformation/vpForceTwistMatrix.cpp index 550c8f09902815f8f7c1d0e6d28eb2675b0b57cb..96b3acad657253d13f7403f211ec2e812bd11ba7 100644 --- a/src/math/transformation/vpForceTwistMatrix.cpp +++ b/src/math/transformation/vpForceTwistMatrix.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpForceTwistMatrix.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpForceTwistMatrix.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -162,16 +162,16 @@ vpForceTwistMatrix::vpForceTwistMatrix(const vpHomogeneousMatrix &M) : vpMatrix( Initialize a force/torque twist transformation matrix from a translation vector \e t and a rotation vector with \f$\theta u \f$ parametrization. - \param t : Translation vector. + \param tv : Translation vector. \param thetau : \f$\theta u\f$ rotation vector. */ -vpForceTwistMatrix::vpForceTwistMatrix(const vpTranslationVector &t, - const vpThetaUVector &thetau) : vpMatrix() +vpForceTwistMatrix::vpForceTwistMatrix(const vpTranslationVector &tv, + const vpThetaUVector &thetau) : vpMatrix() { init() ; - buildFrom(t, thetau) ; + buildFrom(tv, thetau) ; } /*! @@ -179,16 +179,16 @@ vpForceTwistMatrix::vpForceTwistMatrix(const vpTranslationVector &t, Initialize a force/torque twist transformation matrix from a translation vector \e t and a rotation matrix R. - \param t : Translation vector. + \param tv : Translation vector. \param R : Rotation matrix. */ -vpForceTwistMatrix::vpForceTwistMatrix(const vpTranslationVector &t, +vpForceTwistMatrix::vpForceTwistMatrix(const vpTranslationVector &tv, const vpRotationMatrix &R) { init() ; - buildFrom(t,R) ; + buildFrom(tv,R) ; } /*! @@ -365,17 +365,17 @@ vpForceTwistMatrix::operator*(const vpColVector &H) const Build a force/torque twist transformation matrix from a translation vector \e t and a rotation matrix M. - \param t : Translation vector. + \param tv : Translation vector. \param R : Rotation matrix. */ vpForceTwistMatrix -vpForceTwistMatrix::buildFrom(const vpTranslationVector &t, - const vpRotationMatrix &R) +vpForceTwistMatrix::buildFrom(const vpTranslationVector &tv, + const vpRotationMatrix &R) { unsigned int i, j; - vpMatrix skewaR = t.skew(t)*R ; + vpMatrix skewaR = tv.skew(tv)*R ; for (i=0 ; i < 3 ; i++) { for (j=0 ; j < 3 ; j++) { @@ -392,18 +392,18 @@ vpForceTwistMatrix::buildFrom(const vpTranslationVector &t, Initialize a force/torque twist transformation matrix from a translation vector \e t and a rotation vector with \f$\theta u \f$ parametrization. - \param t : Translation vector. + \param tv : Translation vector. \param thetau : \f$\theta u\f$ rotation vector. */ vpForceTwistMatrix -vpForceTwistMatrix::buildFrom(const vpTranslationVector &t, - const vpThetaUVector &thetau) +vpForceTwistMatrix::buildFrom(const vpTranslationVector &tv, + const vpThetaUVector &thetau) { vpRotationMatrix R ; R.buildFrom(thetau) ; - buildFrom(t,R) ; + buildFrom(tv,R) ; return (*this) ; } @@ -421,12 +421,12 @@ vpForceTwistMatrix::buildFrom(const vpTranslationVector &t, vpForceTwistMatrix vpForceTwistMatrix::buildFrom(const vpHomogeneousMatrix &M) { - vpTranslationVector t ; + vpTranslationVector tv ; vpRotationMatrix R ; M.extract(R) ; - M.extract(t) ; + M.extract(tv) ; - buildFrom(t, R) ; + buildFrom(tv, R) ; return (*this) ; } diff --git a/src/math/transformation/vpForceTwistMatrix.h b/src/math/transformation/vpForceTwistMatrix.h index e337a132ef1d52dc7a77641fb007436e053bfe92..33a797a2f058837146527b1b45def59b1b7a9c1b 100644 --- a/src/math/transformation/vpForceTwistMatrix.h +++ b/src/math/transformation/vpForceTwistMatrix.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpForceTwistMatrix.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpForceTwistMatrix.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/math/transformation/vpHomogeneousMatrix.cpp b/src/math/transformation/vpHomogeneousMatrix.cpp index 3dc2428041e296e763fa1d43a966075106c01836..db8ca5d5e988b8d9d4fb243c0b0ac7cd014c70d7 100644 --- a/src/math/transformation/vpHomogeneousMatrix.cpp +++ b/src/math/transformation/vpHomogeneousMatrix.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpHomogeneousMatrix.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpHomogeneousMatrix.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -86,11 +86,11 @@ vpHomogeneousMatrix::init() } -vpHomogeneousMatrix::vpHomogeneousMatrix(const vpTranslationVector &t, - const vpQuaternionVector &q) +vpHomogeneousMatrix::vpHomogeneousMatrix(const vpTranslationVector &tv, + const vpQuaternionVector &q) { init(); - buildFrom(t,q); + buildFrom(tv,q); } /*! @@ -111,19 +111,19 @@ vpHomogeneousMatrix::vpHomogeneousMatrix(const vpHomogeneousMatrix &M) : vpMatri *this = M ; } -vpHomogeneousMatrix::vpHomogeneousMatrix(const vpTranslationVector &t, +vpHomogeneousMatrix::vpHomogeneousMatrix(const vpTranslationVector &tv, const vpThetaUVector &tu) : vpMatrix() { init() ; - buildFrom(t,tu) ; + buildFrom(tv,tu) ; } -vpHomogeneousMatrix::vpHomogeneousMatrix(const vpTranslationVector &t, +vpHomogeneousMatrix::vpHomogeneousMatrix(const vpTranslationVector &tv, const vpRotationMatrix &R) : vpMatrix() { init() ; insert(R) ; - insert(t) ; + insert(tv) ; } vpHomogeneousMatrix::vpHomogeneousMatrix(const vpPoseVector &p) : vpMatrix() @@ -145,20 +145,20 @@ vpHomogeneousMatrix::vpHomogeneousMatrix(const double tx, } void -vpHomogeneousMatrix::buildFrom(const vpTranslationVector &t, +vpHomogeneousMatrix::buildFrom(const vpTranslationVector &tv, const vpThetaUVector &tu) { insert(tu) ; - insert(t) ; + insert(tv) ; } void -vpHomogeneousMatrix::buildFrom(const vpTranslationVector &t, +vpHomogeneousMatrix::buildFrom(const vpTranslationVector &tv, const vpRotationMatrix &R) { init() ; insert(R) ; - insert(t) ; + insert(tv) ; } @@ -166,17 +166,17 @@ void vpHomogeneousMatrix::buildFrom(const vpPoseVector &p) { - vpTranslationVector t(p[0],p[1],p[2]) ; + vpTranslationVector tv(p[0],p[1],p[2]) ; vpThetaUVector tu(p[3],p[4],p[5]) ; insert(tu) ; - insert(t) ; + insert(tv) ; } -void vpHomogeneousMatrix::buildFrom(const vpTranslationVector &t, +void vpHomogeneousMatrix::buildFrom(const vpTranslationVector &tv, const vpQuaternionVector &q) { - insert(t); + insert(tv); insert(q); } @@ -189,10 +189,10 @@ vpHomogeneousMatrix::buildFrom(const double tx, const double tuz) { vpRotationMatrix R(tux, tuy, tuz) ; - vpTranslationVector t(tx, ty, tz) ; + vpTranslationVector tv(tx, ty, tz) ; insert(R) ; - insert(t) ; + insert(tv) ; } /*! @@ -308,11 +308,11 @@ vpHomogeneousMatrix::extract(vpRotationMatrix &R) const Extract the translation vector from the homogeneous matrix. */ void -vpHomogeneousMatrix::extract(vpTranslationVector &t) const +vpHomogeneousMatrix::extract(vpTranslationVector &tv) const { - t[0] = (*this)[0][3] ; - t[1] = (*this)[1][3] ; - t[2] = (*this)[2][3] ; + tv[0] = (*this)[0][3] ; + tv[1] = (*this)[1][3] ; + tv[2] = (*this)[2][3] ; } /*! Extract the rotation as a Theta U vector. @@ -481,7 +481,7 @@ vpHomogeneousMatrix::inverse(vpHomogeneousMatrix &M) const void vpHomogeneousMatrix::save(std::ofstream &f) const { - if (f != NULL) + if (! f.fail()) { f << *this ; } @@ -514,12 +514,12 @@ vpHomogeneousMatrix::save(std::ofstream &f) const void vpHomogeneousMatrix::load(std::ifstream &f) { - if (f != NULL) + if (! f.fail()) { for (unsigned int i=0 ; i < 4 ; i++) for (unsigned int j=0 ; j < 4 ; j++) { - f>> (*this)[i][j] ; + f >> (*this)[i][j] ; } } else diff --git a/src/math/transformation/vpHomogeneousMatrix.h b/src/math/transformation/vpHomogeneousMatrix.h index 43c7b5f20f15f7ac3fd40937ce875f27ad702901..9d1abda13a13e89dc835a7de32168aa02a176fc2 100644 --- a/src/math/transformation/vpHomogeneousMatrix.h +++ b/src/math/transformation/vpHomogeneousMatrix.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpHomogeneousMatrix.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpHomogeneousMatrix.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/math/transformation/vpPoseVector.cpp b/src/math/transformation/vpPoseVector.cpp index b265652795a066fbecc85ddd2fa6c60f14e5a9e4..bb472e20a2e6758edfd759fa0ddc1b5438fde7f8 100644 --- a/src/math/transformation/vpPoseVector.cpp +++ b/src/math/transformation/vpPoseVector.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpPoseVector.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpPoseVector.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -119,15 +119,15 @@ vpPoseVector::vpPoseVector(const double tx, u]^\top\f$ from a translation vector \f$ \bf t \f$ and a \f$\Theta \bf u\f$ vector. - \param t : Translation vector \f$ \bf t \f$. + \param tv : Translation vector \f$ \bf t \f$. \param tu : \f$\Theta \bf u\f$ rotation vector. */ -vpPoseVector::vpPoseVector(const vpTranslationVector& t, +vpPoseVector::vpPoseVector(const vpTranslationVector& tv, const vpThetaUVector& tu) { init() ; - buildFrom(t,tu) ; + buildFrom(tv,tu) ; } /*! @@ -136,17 +136,17 @@ vpPoseVector::vpPoseVector(const vpTranslationVector& t, u]^\top\f$ from a translation vector \f$ \bf t \f$ and a rotation matrix \f$ \bf R \f$. - \param t : Translation vector \f$ \bf t \f$. + \param tv : Translation vector \f$ \bf t \f$. \param R : Rotation matrix \f$ \bf R \f$ from which \f$\Theta \bf u\f$ vector is extracted to initialise the pose vector. */ -vpPoseVector::vpPoseVector(const vpTranslationVector& t, +vpPoseVector::vpPoseVector(const vpTranslationVector& tv, const vpRotationMatrix& R) { init() ; - buildFrom(t,R) ; + buildFrom(tv,R) ; } /*! @@ -180,8 +180,8 @@ vpPoseVector vpPoseVector::buildFrom(const vpHomogeneousMatrix& M) { vpRotationMatrix R ; M.extract(R) ; - vpTranslationVector t ; M.extract(t) ; - buildFrom(t,R) ; + vpTranslationVector tv ; M.extract(tv) ; + buildFrom(tv,R) ; return *this ; } @@ -191,18 +191,18 @@ vpPoseVector::buildFrom(const vpHomogeneousMatrix& M) from a translation vector \f$ \bf t \f$ and a \f$\Theta \bf u\f$ vector. - \param t : Translation vector \f$ \bf t \f$. + \param tv : Translation vector \f$ \bf t \f$. \param tu : \f$\Theta \bf u\f$ rotation vector. \return The build pose vector. */ vpPoseVector -vpPoseVector::buildFrom(const vpTranslationVector& t, +vpPoseVector::buildFrom(const vpTranslationVector& tv, const vpThetaUVector& tu) { for (unsigned int i =0 ; i < 3 ; i++) { - (*this)[i] = t[i] ; + (*this)[i] = tv[i] ; (*this)[i+3] = tu[i] ; } return *this ; @@ -214,7 +214,7 @@ vpPoseVector::buildFrom(const vpTranslationVector& t, from a translation vector \f$ \bf t \f$ and a rotation matrix \f$ \bf R \f$. - \param t : Translation vector \f$ \bf t \f$. + \param tv : Translation vector \f$ \bf t \f$. \param R : Rotation matrix \f$ \bf R \f$ from which \f$\Theta \bf u\f$ vector is extracted to initialise the pose vector. @@ -222,13 +222,13 @@ vpPoseVector::buildFrom(const vpTranslationVector& t, \return The build pose vector. */ vpPoseVector -vpPoseVector::buildFrom(const vpTranslationVector& t, +vpPoseVector::buildFrom(const vpTranslationVector& tv, const vpRotationMatrix& R) { vpThetaUVector tu ; tu.buildFrom(R) ; - buildFrom(t,tu) ; + buildFrom(tv,tu) ; return *this ; } @@ -276,7 +276,7 @@ vpPoseVector::print() void vpPoseVector::save(std::ofstream &f) const { - if (f != NULL) + if (! f.fail()) { f << *this ; } @@ -301,18 +301,18 @@ vpPoseVector::save(std::ofstream &f) const void vpPoseVector::load(std::ifstream &f) { - if (f != NULL) + if (! f.fail()) + { + for (unsigned int i=0 ; i < 6 ; i++) { - for (unsigned int i=0 ; i < 6 ; i++) - { - f>> (*this)[i] ; - } + f >> (*this)[i] ; } + } else - { - vpERROR_TRACE("\t\t file not open " ); - throw(vpException(vpException::ioError, "\t\t file not open")) ; - } + { + vpERROR_TRACE("\t\t file not open " ); + throw(vpException(vpException::ioError, "\t\t file not open")) ; + } } diff --git a/src/math/transformation/vpPoseVector.h b/src/math/transformation/vpPoseVector.h index dd502301f471835b81a0366525b0bce8c86caebe..607fdcdd6e50a4a7dd9a8d02114d07c76dca2f82 100644 --- a/src/math/transformation/vpPoseVector.h +++ b/src/math/transformation/vpPoseVector.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpPoseVector.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpPoseVector.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/math/transformation/vpQuaternionVector.cpp b/src/math/transformation/vpQuaternionVector.cpp index 07beeca3413b3bd2b4c8a116a25073b04a493789..f00cab04692f4468c6812f5e2082b1293a6830e4 100644 --- a/src/math/transformation/vpQuaternionVector.cpp +++ b/src/math/transformation/vpQuaternionVector.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpQuaternionVector.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpQuaternionVector.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -54,14 +54,13 @@ const double vpQuaternionVector::minimum = 0.0001; \file vpQuaternionVector.cpp \brief Defines a quaternion and common operations on it. */ -vpQuaternionVector::vpQuaternionVector() : vpRotationVector(4) { } //! Constructor from doubles. -vpQuaternionVector::vpQuaternionVector(const double x, const double y, - const double z,const double w) +vpQuaternionVector::vpQuaternionVector(const double x_, const double y_, + const double z_,const double w_) : vpRotationVector(4) { - set(x, y, z, w); + set(x_, y_, z_, w_); } /*! @@ -74,30 +73,21 @@ vpQuaternionVector::vpQuaternionVector(const vpRotationMatrix &R) { buildFrom(R); } -/*! - Copy constructor. - \param q : quaternion to construct from. -*/ -vpQuaternionVector::vpQuaternionVector(const vpQuaternionVector &q) - : vpRotationVector(4) -{ - for(unsigned int i=0;i<size();i++) (*this)[i]=q.r[i]; -} - + /*! Manually change values of a quaternion. - \param x : x quaternion parameter. - \param y : y quaternion parameter. - \param z : z quaternion parameter. - \param w : w quaternion parameter. + \param x_ : x quaternion parameter. + \param y_ : y quaternion parameter. + \param z_ : z quaternion parameter. + \param w_ : w quaternion parameter. */ -void vpQuaternionVector::set(const double x, const double y, - const double z,const double w) +void vpQuaternionVector::set(const double x_, const double y_, + const double z_,const double w_) { - r[0]=x; - r[1]=y; - r[2]=z; - r[3]=w; + r[0]=x_; + r[1]=y_; + r[2]=z_; + r[3]=w_; } @@ -144,13 +134,6 @@ vpQuaternionVector vpQuaternionVector::operator* ( vpQuaternionVector &rq) { w() * rq.w() - x() * rq.x() - y() * rq.y() - z() * rq.z()); } -//! Copy operator. Allow operation such as Q = q. -vpQuaternionVector &vpQuaternionVector::operator=( vpQuaternionVector &q) -{ - for(unsigned int i=0;i<size();i++) (*this)[i]=q.r[i]; - return *this; -} - /*! Constructs a quaternion from a rotation matrix. diff --git a/src/math/transformation/vpQuaternionVector.h b/src/math/transformation/vpQuaternionVector.h index a98224bbc666f97b48812be9ccea4935cfcb672e..a41a41ff79ec0f4df8d424230f32aa71de911428 100644 --- a/src/math/transformation/vpQuaternionVector.h +++ b/src/math/transformation/vpQuaternionVector.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpQuaternionVector.h 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpQuaternionVector.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -82,9 +82,11 @@ private: static const double minimum; public: - vpQuaternionVector() ; + /*! Default constructor that initialize all the angles to zero. */ + vpQuaternionVector() : vpRotationVector(4) {} + /*! Copy constructor. */ + vpQuaternionVector(const vpQuaternionVector &q) : vpRotationVector(q) {} vpQuaternionVector(const double x, const double y, const double z,const double w) ; - vpQuaternionVector(const vpQuaternionVector &q); vpQuaternionVector(const vpRotationMatrix &R); void buildFrom(const vpRotationMatrix& R); @@ -104,8 +106,7 @@ public: vpQuaternionVector operator-( vpQuaternionVector &q) ; vpQuaternionVector operator-() ; vpQuaternionVector operator*(const double l) ; - vpQuaternionVector operator* ( vpQuaternionVector &rq) ; - vpQuaternionVector &operator=( vpQuaternionVector &q); + vpQuaternionVector operator*( vpQuaternionVector &rq) ; } ; #endif diff --git a/src/math/transformation/vpRotationMatrix.cpp b/src/math/transformation/vpRotationMatrix.cpp index f3894e97cef075fa2deb5e267178fe330e067ef5..b1fe772bb9421cbe2a4e52eb4defaf366e792e80 100644 --- a/src/math/transformation/vpRotationMatrix.cpp +++ b/src/math/transformation/vpRotationMatrix.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRotationMatrix.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRotationMatrix.cpp 4620 2014-01-27 21:28:32Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -456,7 +456,7 @@ vpRotationMatrix::inverse(vpRotationMatrix &M) const //! std::cout an rotation matrix [thetaU] -std::ostream &operator <<(std::ostream &s,const vpRotationMatrix &R) +VISP_EXPORT std::ostream &operator <<(std::ostream &s,const vpRotationMatrix &R) { for (unsigned int i=0; i<3; i++) { diff --git a/src/math/transformation/vpRotationMatrix.h b/src/math/transformation/vpRotationMatrix.h index 04b47d9667a549c707baa1835f7e216fcb30dfd7..dfbad694508aece704b0888ebe80dc2e6171aed2 100644 --- a/src/math/transformation/vpRotationMatrix.h +++ b/src/math/transformation/vpRotationMatrix.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRotationMatrix.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRotationMatrix.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/math/transformation/vpRotationVector.cpp b/src/math/transformation/vpRotationVector.cpp index 6c95e25ff643d59feab2bc91b4318be14959eb05..5829b3ed209a8e8dd6ffc0f66a25b6ccd7ade41c 100644 --- a/src/math/transformation/vpRotationVector.cpp +++ b/src/math/transformation/vpRotationVector.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRotationVector.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRotationVector.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -97,8 +97,9 @@ Rxyz rotation vector: 0 \endcode */ -std::ostream &operator <<(std::ostream &s,const vpRotationVector &m) +VISP_EXPORT std::ostream &operator <<(std::ostream &s,const vpRotationVector &m) { + std::ios::fmtflags original_flags( s.flags() ); s.precision(10) ; for (unsigned int i=0; i < m.size(); i++) @@ -106,12 +107,15 @@ std::ostream &operator <<(std::ostream &s,const vpRotationVector &m) s << std::endl; + // Restore ostream format + s.flags(original_flags); + return s; } -void vpRotationVector::init(const unsigned int size){ - this->_size = size; +void vpRotationVector::init(const unsigned int vector_size){ + this->_size = vector_size; r = new double[this->_size]; std::fill(r,r+this->_size,0.); } @@ -119,9 +123,3 @@ void vpRotationVector::init(const unsigned int size){ vpRotationVector::~vpRotationVector(){ delete[] r; } - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ diff --git a/src/math/transformation/vpRotationVector.h b/src/math/transformation/vpRotationVector.h index 118b41ab5ce0b747128cd1d6dad39c076eaace93..965ee37d2d27142e1ca97b3a09e0651333f9d147 100644 --- a/src/math/transformation/vpRotationVector.h +++ b/src/math/transformation/vpRotationVector.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRotationVector.h 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpRotationVector.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -83,11 +83,10 @@ int main() std::cout << "Rxyz rotation vector: " << r << std::endl; - double rx = r[1]; // Get the value of the angle around x axis - double ry = r[2]; // Get the value of the angle around y axis - double rz = r[3]; // Get the value of the angle around z axis + double rx = r[0]; // Get the value of the angle around x axis + double ry = r[1]; // Get the value of the angle around y axis + double rz = r[2]; // Get the value of the angle around z axis } - \endcode */ @@ -100,18 +99,29 @@ protected: unsigned int _size; void init(const unsigned int size); public: - //! Constructor that constructs a vector of size 3 initialize three vector values to zero. - vpRotationVector() { - init(3); + //! Constructor that constructs a vector of size 3 and initialize all values to zero. + vpRotationVector() + : r(NULL), _size(0) + { + init(3); } - - //! Constructor that constructs a vector of size n initialize three vector values to zero. - vpRotationVector(const unsigned int n) { - init(n); + //! Constructor that constructs a vector of size n and initialize all values to zero. + vpRotationVector(const unsigned int n) + : r(NULL), _size(n) + { + init(n); + } + /*! + Copy operator. + */ + vpRotationVector(const vpRotationVector &v) + : r(NULL), _size(0) + { + *this = v; } - - ~vpRotationVector(); + + virtual ~vpRotationVector(); /*! Operator that allows to set the value of an element of the rotation @@ -124,7 +134,19 @@ public: */ inline const double &operator [](unsigned int n) const { return *(r+n); } - + /*! + Affectation of two vectors. + */ + vpRotationVector &operator=(const vpRotationVector &v) + { + init(v.size()); + for (unsigned int i=0; i<_size; i++) + { + r[i] = v.r[i] ; + } + return *this; + } + /*! Returns the size of the rotation vector */ unsigned int size() const; @@ -132,8 +154,7 @@ public: // Transpose of the rotation vector. vpRowVector t() const; - friend VISP_EXPORT std::ostream &operator << (std::ostream &s, - const vpRotationVector &m); + friend VISP_EXPORT std::ostream &operator << (std::ostream &s, const vpRotationVector &m); } ; diff --git a/src/math/transformation/vpRxyzVector.cpp b/src/math/transformation/vpRxyzVector.cpp index 6fe57a9ad52898e38859a50912f62c356d52adc3..cc2218ebbbeced06f55104b9531996d10106778e 100644 --- a/src/math/transformation/vpRxyzVector.cpp +++ b/src/math/transformation/vpRxyzVector.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRxyzVector.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRxyzVector.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -51,27 +51,6 @@ */ -/*! - Affectation of two vectors. -*/ -vpRxyzVector & -vpRxyzVector::operator=(const vpRxyzVector &m) -{ - - for (int i=0; i<3; i++) - { - r[i] = m.r[i] ; - } - return *this; -} - - -//! Copy constructor. -vpRxyzVector::vpRxyzVector(const vpRxyzVector &m) : vpRotationVector() -{ - *this = m ; -} - /*! Constructor that initialize \f$R_{xyz}=(\varphi,\theta,\psi)\f$ Euler angles from a rotation matrix. diff --git a/src/math/transformation/vpRxyzVector.h b/src/math/transformation/vpRxyzVector.h index a52f2f6d7ac38b9202a6e414b62c2bb7ec5f99dd..ec1f258ab2bc4c192d1ec28343a45cfd431b7291 100644 --- a/src/math/transformation/vpRxyzVector.h +++ b/src/math/transformation/vpRxyzVector.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRxyzVector.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRxyzVector.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -155,12 +155,11 @@ class VISP_EXPORT vpRxyzVector : public vpRotationVector friend class vpThetaUVector; public: - //! Default constructor. Initialize the angles to zero. - vpRxyzVector() { ; } - - // Copy constructor. - vpRxyzVector(const vpRxyzVector &m); - + /*! Default constructor that initialize all the angles to zero. */ + vpRxyzVector() {} + /*! Copy constructor. */ + vpRxyzVector(const vpRxyzVector &rxyz) : vpRotationVector(rxyz) {} + /*! Constructor from 3 angles (in radian). \param phi : \f$\varphi\f$ angle around the \f$x\f$ axis. @@ -176,9 +175,6 @@ class VISP_EXPORT vpRxyzVector : public vpRotationVector // initialize a Rxyz vector from a ThetaU vector vpRxyzVector(const vpThetaUVector& tu) ; - // Affectation of two vectors. - vpRxyzVector &operator=(const vpRxyzVector &m); - /*! Construction from 3 angles (in radian). \param phi : \f$\varphi\f$ angle around the \f$x\f$ axis. @@ -201,9 +197,3 @@ class VISP_EXPORT vpRxyzVector : public vpRotationVector } ; #endif - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ diff --git a/src/math/transformation/vpRzyxVector.cpp b/src/math/transformation/vpRzyxVector.cpp index d2e5b18b95b31030117f31c8e6d374a1fcad8a60..abeab6c93b1581c986a702e39986904f7de4ba00 100644 --- a/src/math/transformation/vpRzyxVector.cpp +++ b/src/math/transformation/vpRzyxVector.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRzyxVector.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRzyxVector.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -51,29 +51,6 @@ */ - -/*! - Affectation of two vectors. -*/ -vpRzyxVector & -vpRzyxVector::operator=(const vpRzyxVector &m) -{ - - for (int i=0; i<3; i++) - { - r[i] = m.r[i] ; - } - return *this; -} - - -//! Copy constructor. -vpRzyxVector::vpRzyxVector(const vpRzyxVector &m) : vpRotationVector() -{ - *this = m ; -} - - /*! Constructor that initialize \f$R_{zyx}=(\varphi,\theta,\psi)\f$ Euler angles from a rotation matrix. diff --git a/src/math/transformation/vpRzyxVector.h b/src/math/transformation/vpRzyxVector.h index 5d2af9bd8f56b9dcae66229948f6fef0bb27905c..329c4b4965de5258b0dc28afbde5ee6c9195f541 100644 --- a/src/math/transformation/vpRzyxVector.h +++ b/src/math/transformation/vpRzyxVector.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRzyxVector.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRzyxVector.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -154,11 +154,10 @@ class VISP_EXPORT vpRzyxVector : public vpRotationVector friend class vpThetaUVector; public: - //! Default constructor. Initialize the angles to zero. - vpRzyxVector() { ; } - - // Copy constructor. - vpRzyxVector(const vpRzyxVector &m); + /*! Default constructor that initialize all the angles to zero. */ + vpRzyxVector() {} + /*! Copy constructor. */ + vpRzyxVector(const vpRzyxVector &rzyx) : vpRotationVector(rzyx) {} /*! Constructor from 3 angles (in radian). @@ -173,10 +172,7 @@ public: vpRzyxVector(const vpRotationMatrix& R) ; // initialize a Rzyx vector from a ThetaU vector - vpRzyxVector(const vpThetaUVector& tu) ; - - // Affectation of two vectors. - vpRzyxVector &operator=(const vpRzyxVector &m); + vpRzyxVector(const vpThetaUVector& tu) ; /*! Construction from 3 angles (in radian). diff --git a/src/math/transformation/vpRzyzVector.cpp b/src/math/transformation/vpRzyzVector.cpp index 63c1f3f69602efdf42d3c8cae61c846c2c2a7187..d0d0eb2fb61a79db98076d30e9c5a4fd2654ff00 100644 --- a/src/math/transformation/vpRzyzVector.cpp +++ b/src/math/transformation/vpRzyzVector.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRzyzVector.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRzyzVector.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -51,28 +51,6 @@ Rzyz(phi,theta,psi) = Rot(z,phi)Rot(y,theta)Rot(z,psi) */ - -/*! - Affectation of two vectors. -*/ -vpRzyzVector & -vpRzyzVector::operator=(const vpRzyzVector &m) -{ - - for (int i=0; i<3; i++) - { - r[i] = m.r[i] ; - } - return *this; -} - - -//! Copy constructor. -vpRzyzVector::vpRzyzVector(const vpRzyzVector &m) : vpRotationVector() -{ - *this = m ; -} - /*! Constructor that initialize \f$R_{zyz}=(\varphi,\theta,\psi)\f$ Euler angles from a rotation matrix. @@ -83,7 +61,6 @@ vpRzyzVector::vpRzyzVector(const vpRotationMatrix& R) buildFrom(R) ; } - /*! Constructor that initialize \f$R_{zyz}=(\varphi,\theta,\psi)\f$ Euler angles vector from a \f$\theta u\f$ vector. @@ -144,11 +121,30 @@ vpRzyzVector::buildFrom(const vpThetaUVector& tu) return *this ; } +/*! + + Initialize each element of the vector to the same angle value \e v. + + \param v : Angle value to set for each element of the vector. + +\code +#include <visp/vpMath.h> +#include <visp/vpRzyzVector.h> + +int main() +{ + vpRzyzVector r; + // Initialise the rotation vector + r = vpMath::rad( 45.f); // All the 3 angles are set to 45 degrees +} +\endcode +*/ +vpRzyzVector &vpRzyzVector::operator=(double v) +{ + for (int i=0; i< 3; i++) + r[i] = v; -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ + return *this; +} diff --git a/src/math/transformation/vpRzyzVector.h b/src/math/transformation/vpRzyzVector.h index 801f04c473f9f46af63dfaa979593ea5dedc52d5..90865e95aa611b135c647236a9220ef604135682 100644 --- a/src/math/transformation/vpRzyzVector.h +++ b/src/math/transformation/vpRzyzVector.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRzyzVector.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRzyzVector.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -153,12 +153,11 @@ class VISP_EXPORT vpRzyzVector : public vpRotationVector friend class vpThetaUVector; public: - //! Default constructor. Initialize the angles to zero. - vpRzyzVector() { ; } + /*! Default constructor that initialize all the angles to zero. */ + vpRzyzVector() {} + /*! Copy constructor. */ + vpRzyzVector(const vpRzyzVector &rzyz) : vpRotationVector(rzyz) {} - // Copy constructor. - vpRzyzVector(const vpRzyzVector &m); - /*! Constructor from 3 angles (in radian). \param phi : \f$\varphi\f$ angle around the \f$z\f$ axis. @@ -174,9 +173,6 @@ class VISP_EXPORT vpRzyzVector : public vpRotationVector // initialize a Rzyz vector from a ThetaU vector vpRzyzVector(const vpThetaUVector& tu); - // Affectation of two vectors. - vpRzyzVector &operator=(const vpRzyzVector &m); - /*! Construction from 3 angles (in radian). \param phi : \f$\varphi\f$ angle around the \f$z\f$ axis. @@ -195,11 +191,9 @@ class VISP_EXPORT vpRzyzVector : public vpRotationVector // convert a ThetaU vector into a Rzyz vector vpRzyzVector buildFrom(const vpThetaUVector& R) ; + + vpRzyzVector &operator=(double x) ; + } ; #endif -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ diff --git a/src/math/transformation/vpThetaUVector.cpp b/src/math/transformation/vpThetaUVector.cpp index 4e5b6905901d06207f92c8c89c0212a4147b63ce..84f4176a22823674a892c99615e6295fe0aadd51 100644 --- a/src/math/transformation/vpThetaUVector.cpp +++ b/src/math/transformation/vpThetaUVector.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * -* $Id: vpThetaUVector.cpp 4056 2013-01-05 13:04:42Z fspindle $ +* $Id: vpThetaUVector.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. -* Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +* Copyright (C) 2005 - 2014 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 @@ -54,28 +54,6 @@ rotation const double vpThetaUVector::minimum = 0.0001; -/*! -Affectation of two \f$\theta {\bf u}\f$ vector. -*/ -vpThetaUVector & -vpThetaUVector::operator=(const vpThetaUVector &m) -{ - for (int i=0; i<3; i++) - { - r[i] = m.r[i] ; - } - return *this; -} - - -/*! -Copy constructor. -*/ -vpThetaUVector::vpThetaUVector(const vpThetaUVector &m) : vpRotationVector() -{ - *this = m ; -} - /*! Initialize a \f$\theta {\bf u}\f$ vector from an homogeneous matrix. */ @@ -271,7 +249,7 @@ vpThetaUVector::buildFrom(const vpRxyzVector& rxyz) return *this ; } -/*! +/*! Initialize each element of the \f$\theta {\bf u}\f$ vector to the same angle value \e v. @@ -327,8 +305,3 @@ vpThetaUVector::extract(double &theta, vpColVector &u) const } #undef vpDEBUG_LEVEL1 -/* -* Local variables: -* c-basic-offset: 2 -* End: -*/ diff --git a/src/math/transformation/vpThetaUVector.h b/src/math/transformation/vpThetaUVector.h index 43e2f5f961f8c19cd46de28a8d43c38c15324b9a..27b1331f912f09f8d6e5f6c8c2cefde2c4354620 100644 --- a/src/math/transformation/vpThetaUVector.h +++ b/src/math/transformation/vpThetaUVector.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpThetaUVector.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpThetaUVector.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -148,10 +148,10 @@ private: public: - // constructor - vpThetaUVector() { ; } - // copy constructor - vpThetaUVector(const vpThetaUVector &tu) ; + /*! Default constructor that initialize all the angles to zero. */ + vpThetaUVector() {} + /*! Copy constructor. */ + vpThetaUVector(const vpThetaUVector &tu) : vpRotationVector(tu) {} // constructor initialize a Theta U vector from a homogeneous matrix vpThetaUVector(const vpHomogeneousMatrix & M) ; @@ -181,8 +181,6 @@ public: // convert an Rxyz vector into Theta U vector vpThetaUVector buildFrom(const vpRxyzVector &xyz) ; - // copy operator - vpThetaUVector &operator=(const vpThetaUVector &tu); vpThetaUVector &operator=(double x) ; // extract the angle and the axis from the ThetaU representation diff --git a/src/math/transformation/vpTranslationVector.cpp b/src/math/transformation/vpTranslationVector.cpp index 46e35fac39a8c67afa940f0ee05a1652057f2a91..9222e97906d70a4bcd1feca4190ea52739d07383 100644 --- a/src/math/transformation/vpTranslationVector.cpp +++ b/src/math/transformation/vpTranslationVector.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpTranslationVector.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpTranslationVector.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -82,7 +82,7 @@ vpTranslationVector::vpTranslationVector(const double tx, /*! Copy constructor. - \param t : Translation vector to copy. + \param tv : Translation vector to copy. \code vpTranslationVector t1(1,2,3); // Create and initialize a translation vector @@ -91,7 +91,7 @@ vpTranslationVector::vpTranslationVector(const double tx, \endcode */ -vpTranslationVector::vpTranslationVector (const vpTranslationVector &t) : vpColVector(t) +vpTranslationVector::vpTranslationVector (const vpTranslationVector &tv) : vpColVector(tv) { } @@ -114,7 +114,7 @@ vpTranslationVector::set(const double tx, /*! Operator that allows to add two translation vectors. - \param t : Translation vector to add. + \param tv : Translation vector to add. \return The sum of the current translation vector (*this) and the one to add. \code @@ -129,11 +129,11 @@ vpTranslationVector::set(const double tx, */ vpTranslationVector -vpTranslationVector::operator+(const vpTranslationVector &t) const +vpTranslationVector::operator+(const vpTranslationVector &tv) const { vpTranslationVector sum ; - for (unsigned int i=0;i<3;i++) sum[i] = (*this)[i]+t[i] ; + for (unsigned int i=0;i<3;i++) sum[i] = (*this)[i]+tv[i] ; return sum; } @@ -141,7 +141,7 @@ vpTranslationVector::operator+(const vpTranslationVector &t) const /*! Operator that allows to substract two translation vectors. - \param t : Translation vector to substract. + \param tv : Translation vector to substract. \return The substraction of the current translation vector (*this) and the one to substract. \code @@ -156,11 +156,11 @@ vpTranslationVector::operator+(const vpTranslationVector &t) const */ vpTranslationVector -vpTranslationVector::operator-(const vpTranslationVector &t) const +vpTranslationVector::operator-(const vpTranslationVector &tv) const { vpTranslationVector sub ; - for (unsigned int i=0;i<3;i++) sub[i] = (*this)[i]-t[i] ; + for (unsigned int i=0;i<3;i++) sub[i] = (*this)[i]-tv[i] ; return sub; } @@ -182,13 +182,13 @@ vpTranslationVector::operator-(const vpTranslationVector &t) const */ vpTranslationVector vpTranslationVector::operator-() const //negate { - vpTranslationVector t ; - for (unsigned int i=0;i<dsize;i++) - { - *(t.data + i) = -*(data + i) ; - } + vpTranslationVector tv ; + for (unsigned int i=0;i<dsize;i++) + { + *(tv.data + i) = -*(data + i) ; + } - return t; + return tv; } /*! @@ -208,18 +208,18 @@ vpTranslationVector vpTranslationVector::operator-() const //negate */ vpTranslationVector vpTranslationVector::operator*(const double x) const { - vpTranslationVector t ; - for (unsigned int i=0;i<dsize;i++) - { - *(t.data + i) = (*(data + i)) * x ; - } + vpTranslationVector tv ; + for (unsigned int i=0;i<dsize;i++) + { + *(tv.data + i) = (*(data + i)) * x ; + } - return t; + return tv; } /*! Copy operator. - \param t : Translation vector to copy + \param tv : Translation vector to copy \return A copy of t. \code @@ -230,10 +230,10 @@ vpTranslationVector vpTranslationVector::operator*(const double x) const // t2 is now equal to t1 : 1, 2, 3 \endcode */ -vpTranslationVector &vpTranslationVector::operator=(const vpTranslationVector &t) +vpTranslationVector &vpTranslationVector::operator=(const vpTranslationVector &tv) { - unsigned int k = t.rowNum ; + unsigned int k = tv.rowNum ; if (rowNum != k){ try { resize(k); @@ -245,7 +245,7 @@ vpTranslationVector &vpTranslationVector::operator=(const vpTranslationVector &t } } - memcpy(data, t.data, rowNum*sizeof(double)) ; + memcpy(data, tv.data, rowNum*sizeof(double)) ; return *this; } diff --git a/src/math/transformation/vpTranslationVector.h b/src/math/transformation/vpTranslationVector.h index 53d4e552e182a7ffaacf02bf628bbb9c879de79e..16c5d06f34de3a9fed58265f8a55afdb16eb22ef 100644 --- a/src/math/transformation/vpTranslationVector.h +++ b/src/math/transformation/vpTranslationVector.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpTranslationVector.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpTranslationVector.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/math/transformation/vpVelocityTwistMatrix.cpp b/src/math/transformation/vpVelocityTwistMatrix.cpp index 3bf506756e814136fb263247b2441570b408f986..add5bec6568b3d147fd76e614d1d37a8a1939893 100644 --- a/src/math/transformation/vpVelocityTwistMatrix.cpp +++ b/src/math/transformation/vpVelocityTwistMatrix.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpVelocityTwistMatrix.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpVelocityTwistMatrix.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -146,16 +146,16 @@ vpVelocityTwistMatrix::vpVelocityTwistMatrix(const vpHomogeneousMatrix &M) : vpM Initialize a velocity twist transformation matrix from a translation vector \e t and a rotation vector with \f$\theta u \f$ parametrization. - \param t : Translation vector. + \param tv : Translation vector. \param thetau : \f$\theta u\f$ rotation vector. */ -vpVelocityTwistMatrix::vpVelocityTwistMatrix(const vpTranslationVector &t, +vpVelocityTwistMatrix::vpVelocityTwistMatrix(const vpTranslationVector &tv, const vpThetaUVector &thetau) : vpMatrix() { init() ; - buildFrom(t, thetau) ; + buildFrom(tv, thetau) ; } /*! @@ -163,16 +163,16 @@ vpVelocityTwistMatrix::vpVelocityTwistMatrix(const vpTranslationVector &t, Initialize a velocity twist transformation matrix from a translation vector \e t and a rotation matrix M. - \param t : Translation vector. + \param tv : Translation vector. \param R : Rotation matrix. */ -vpVelocityTwistMatrix::vpVelocityTwistMatrix(const vpTranslationVector &t, +vpVelocityTwistMatrix::vpVelocityTwistMatrix(const vpTranslationVector &tv, const vpRotationMatrix &R) { init() ; - buildFrom(t,R) ; + buildFrom(tv,R) ; } /*! @@ -313,17 +313,18 @@ vpVelocityTwistMatrix::operator*(const vpColVector &v) const vpColVector c(6); if (6 != v.getRows()) - { - vpERROR_TRACE("vpVelocityTwistMatrix mismatch in vpVelocityTwistMatrix/vector multiply") ; - throw(vpMatrixException::incorrectMatrixSizeError) ; - } + { + vpERROR_TRACE("vpVelocityTwistMatrix mismatch in vpVelocityTwistMatrix/vector multiply") ; + throw(vpMatrixException(vpMatrixException::incorrectMatrixSizeError, + "Mismatch in vpVelocityTwistMatrix/vector multiply")) ; + } c = 0.0; for (unsigned int i=0;i<6;i++) { for (unsigned int j=0;j<6;j++) { { - c[i]+=rowPtrs[i][j] * v[j]; + c[i]+=rowPtrs[i][j] * v[j]; } } } @@ -337,26 +338,26 @@ vpVelocityTwistMatrix::operator*(const vpColVector &v) const Build a velocity twist transformation matrix from a translation vector \e t and a rotation matrix M. - \param t : Translation vector. + \param tv : Translation vector. \param R : Rotation matrix. */ vpVelocityTwistMatrix -vpVelocityTwistMatrix::buildFrom(const vpTranslationVector &t, +vpVelocityTwistMatrix::buildFrom(const vpTranslationVector &tv, const vpRotationMatrix &R) { unsigned int i, j; - vpMatrix skewaR = t.skew(t)*R ; + vpMatrix skewaR = tv.skew(tv)*R ; for (i=0 ; i < 3 ; i++) for (j=0 ; j < 3 ; j++) - { - (*this)[i][j] = R[i][j] ; - (*this)[i+3][j+3] = R[i][j] ; - (*this)[i][j+3] = skewaR[i][j] ; + { + (*this)[i][j] = R[i][j] ; + (*this)[i+3][j+3] = R[i][j] ; + (*this)[i][j+3] = skewaR[i][j] ; - } + } return (*this) ; } @@ -365,18 +366,18 @@ vpVelocityTwistMatrix::buildFrom(const vpTranslationVector &t, Initialize a velocity twist transformation matrix from a translation vector \e t and a rotation vector with \f$\theta u \f$ parametrization. - \param t : Translation vector. + \param tv : Translation vector. \param thetau : \f$\theta u\f$ rotation vector. */ vpVelocityTwistMatrix -vpVelocityTwistMatrix::buildFrom(const vpTranslationVector &t, +vpVelocityTwistMatrix::buildFrom(const vpTranslationVector &tv, const vpThetaUVector &thetau) { vpRotationMatrix R ; R.buildFrom(thetau) ; - buildFrom(t,R) ; + buildFrom(tv,R) ; return (*this) ; } @@ -395,12 +396,12 @@ vpVelocityTwistMatrix::buildFrom(const vpTranslationVector &t, vpVelocityTwistMatrix vpVelocityTwistMatrix::buildFrom(const vpHomogeneousMatrix &M) { - vpTranslationVector t ; + vpTranslationVector tv ; vpRotationMatrix R ; M.extract(R) ; - M.extract(t) ; + M.extract(tv) ; - buildFrom(t, R) ; + buildFrom(tv, R) ; return (*this) ; } @@ -438,7 +439,7 @@ vpVelocityTwistMatrix::extract( vpRotationMatrix &R) const //! extract the translation vector from the twist matrix void -vpVelocityTwistMatrix::extract(vpTranslationVector &t) const +vpVelocityTwistMatrix::extract(vpTranslationVector &tv) const { vpRotationMatrix R;extract(R); vpMatrix skTR(3,3); @@ -447,9 +448,9 @@ vpVelocityTwistMatrix::extract(vpTranslationVector &t) const skTR[i][j] = (*this)[i][j+3]; vpMatrix skT = skTR*R.t(); - t[0] = skT[2][1]; - t[1] = skT[0][2]; - t[2] = skT[1][0]; + tv[0] = skT[2][1]; + tv[1] = skT[0][2]; + tv[2] = skT[1][0]; } /* diff --git a/src/math/transformation/vpVelocityTwistMatrix.h b/src/math/transformation/vpVelocityTwistMatrix.h index b8d0221eac5140bdc1f57e6571eb5c035bd1269b..1ca88bc486caed47ae1990ee4210b8ffbe2d3497 100644 --- a/src/math/transformation/vpVelocityTwistMatrix.h +++ b/src/math/transformation/vpVelocityTwistMatrix.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpVelocityTwistMatrix.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpVelocityTwistMatrix.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/network/vpClient.cpp b/src/network/vpClient.cpp index fb887c2734d8756e566b2a14b493b16265263f01..66e5e2a304c982bb0598bfe920856a349e4ab9e0 100644 --- a/src/network/vpClient.cpp +++ b/src/network/vpClient.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpClient.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpClient.cpp 4661 2014-02-10 19:34:58Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -42,8 +42,9 @@ #include <visp/vpClient.h> -vpClient::vpClient() : vpNetwork() -{} +vpClient::vpClient() : vpNetwork(), numberOfAttempts(0) +{ +} /*! Disconnect the client from all the servers, and close the sockets. @@ -82,7 +83,7 @@ bool vpClient::connectToHostname(const std::string &hostname, const unsigned int serv.socketFileDescriptorReceptor = socket( AF_INET, SOCK_STREAM, 0 ); -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX if ( serv.socketFileDescriptorReceptor < 0){ #else if ( serv.socketFileDescriptorReceptor == INVALID_SOCKET){ @@ -117,7 +118,7 @@ bool vpClient::connectToIP(const std::string &ip, const unsigned int &port_serv) serv.socketFileDescriptorReceptor = socket( AF_INET, SOCK_STREAM, 0 ); -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX if ( serv.socketFileDescriptorReceptor < 0){ #else if ( serv.socketFileDescriptorReceptor == INVALID_SOCKET){ @@ -144,9 +145,9 @@ void vpClient::deconnect(const unsigned int &index) { if(index < receptor_list.size()) { -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX shutdown( receptor_list[index].socketFileDescriptorReceptor, SHUT_RDWR ); -#else // WIN32 +#else // _WIN32 shutdown( receptor_list[index].socketFileDescriptorReceptor, SD_BOTH ); #endif receptor_list.erase(receptor_list.begin()+(int)index); @@ -159,9 +160,9 @@ void vpClient::deconnect(const unsigned int &index) void vpClient::stop() { for(unsigned int i = 0 ; i < receptor_list.size() ; i++){ -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX shutdown( receptor_list[i].socketFileDescriptorReceptor, SHUT_RDWR ); -#else // WIN32 +#else // _WIN32 shutdown( receptor_list[i].socketFileDescriptorReceptor, SD_BOTH ); #endif receptor_list.erase(receptor_list.begin()+(int)i); @@ -184,7 +185,7 @@ bool vpClient::connectServer(vpNetwork::vpReceptor &serv) numberOfAttempts = 15; unsigned int ind = 1; - int connectionResult; + int connectionResult=-1; while(ind <= numberOfAttempts){ std::cout << "Attempt number " << ind << "..." << std::endl; diff --git a/src/network/vpClient.h b/src/network/vpClient.h index 2197739eea5ec74bf522c7c150165c29e108ba53..0f457799a2ae37dde13bd3bbb809ac1798baa310 100644 --- a/src/network/vpClient.h +++ b/src/network/vpClient.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpClient.h 4303 2013-07-04 14:14:00Z fspindle $ + * $Id: vpClient.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/network/vpNetwork.cpp b/src/network/vpNetwork.cpp index 579e79e2ed03dd76ef46306e720c76ff2e00cd0f..7f8e57c0132ec53ae656cf493bd1eba4e1e0ecda 100644 --- a/src/network/vpNetwork.cpp +++ b/src/network/vpNetwork.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpNetwork.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpNetwork.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -43,19 +43,15 @@ #include <visp/vpNetwork.h> vpNetwork::vpNetwork() -{ - separator = "[*@*]"; - beginning = "[*start*]"; - end = "[*end*]"; - param_sep = "[*|*]"; - max_size_message = 999999; - - tv_sec = 0; - tv_usec = 10; + : emitter(), receptor_list(), readFileDescriptor(), socketMax(0), request_list(), + max_size_message(999999), separator("[*@*]"), beginning("[*start*]"), end("[*end*]"), + param_sep("[*|*]"), currentMessageReceived(), tv(), tv_sec(0), tv_usec(10), + verboseMode(false) +{ + tv.tv_sec = tv_sec; + tv.tv_usec = tv_usec; - verboseMode = false; - -#ifdef WIN32 +#if defined(_WIN32) //Enable the sockets to be used //Note that: if we were using "winsock.h" instead of "winsock2.h" we would had to use: //WSAStartup(MAKEWORD(1,0), &WSAData); @@ -66,7 +62,7 @@ vpNetwork::vpNetwork() vpNetwork::~vpNetwork() { -#ifdef WIN32 +#if defined(_WIN32) WSACleanup(); #endif } @@ -135,7 +131,7 @@ void vpNetwork::print(const char *id) \param name : Name of the receptor. - \return Index of the receptor. + \return Index of the receptor, or -1 if an error occurs. */ int vpNetwork::getReceptorIndex(const char *name) { @@ -146,7 +142,8 @@ int vpNetwork::getReceptorIndex(const char *name) std::string noSuchHostMessage( "ERROR, " ); noSuchHostMessage.append( name ); noSuchHostMessage.append( ": no such host\n" ); - vpERROR_TRACE( noSuchHostMessage.c_str(), "vpClient::getReceptorIndex()" ); + vpERROR_TRACE( noSuchHostMessage.c_str(), "vpNetwork::getReceptorIndex()" ); + return -1; } std::string ip = inet_ntoa(*(in_addr *)server->h_addr); @@ -216,11 +213,12 @@ int vpNetwork::sendRequestTo(vpRequest &req, const unsigned int &dest) message += end; int flags = 0; -#if ! defined(APPLE) && ! defined(WIN32) +//#if ! defined(APPLE) && ! defined(SOLARIS) && ! defined(_WIN32) +#if defined(__linux__) flags = MSG_NOSIGNAL; // Only for Linux #endif -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX int value = sendto(receptor_list[dest].socketFileDescriptorReceptor, message.c_str(), message.size(), flags, (sockaddr*) &receptor_list[dest].receptorAddress,receptor_list[dest].receptorAddressSize); #else @@ -689,17 +687,17 @@ int vpNetwork::_receiveRequestOnce() for(unsigned int i=0; i<receptor_list.size(); i++){ if(FD_ISSET((unsigned int)receptor_list[i].socketFileDescriptorReceptor,&readFileDescriptor)){ char *buf = new char [max_size_message]; -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX numbytes=recv(receptor_list[i].socketFileDescriptorReceptor, buf, max_size_message, 0); #else numbytes=recv((unsigned int)receptor_list[i].socketFileDescriptorReceptor, buf, (int)max_size_message, 0); #endif - - + if(numbytes <= 0) { std::cout << "Disconnected : " << inet_ntoa(receptor_list[i].receptorAddress.sin_addr) << std::endl; receptor_list.erase(receptor_list.begin()+(int)i); + delete [] buf; return numbytes; } else if(numbytes > 0){ @@ -768,7 +766,7 @@ int vpNetwork::_receiveRequestOnceFrom(const unsigned int &receptorEmitting) else{ if(FD_ISSET((unsigned int)receptor_list[receptorEmitting].socketFileDescriptorReceptor,&readFileDescriptor)){ char *buf = new char [max_size_message]; -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX numbytes=recv(receptor_list[receptorEmitting].socketFileDescriptorReceptor, buf, max_size_message, 0); #else numbytes=recv((unsigned int)receptor_list[receptorEmitting].socketFileDescriptorReceptor, buf, (int)max_size_message, 0); @@ -777,6 +775,7 @@ int vpNetwork::_receiveRequestOnceFrom(const unsigned int &receptorEmitting) { std::cout << "Disconnected : " << inet_ntoa(receptor_list[receptorEmitting].receptorAddress.sin_addr) << std::endl; receptor_list.erase(receptor_list.begin()+(int)receptorEmitting); + delete [] buf; return numbytes; } else if(numbytes > 0){ diff --git a/src/network/vpNetwork.h b/src/network/vpNetwork.h index 8a8407708e601aaca6f1e9ec93bd48896af13ffb..4be624c6b6253687f149d50b64f7cc23ab0f7b30 100644 --- a/src/network/vpNetwork.h +++ b/src/network/vpNetwork.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpNetwork.h 4135 2013-02-13 16:48:19Z fspindle $ + * $Id: vpNetwork.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -50,7 +50,7 @@ #include <string.h> #include <iostream> -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX # include <unistd.h> # include <sys/socket.h> # include <netinet/in.h> @@ -85,7 +85,7 @@ class VISP_EXPORT vpNetwork protected: struct vpReceptor{ -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX int socketFileDescriptorReceptor; socklen_t receptorAddressSize; #else @@ -94,15 +94,24 @@ protected: #endif struct sockaddr_in receptorAddress; std::string receptorIP; + + vpReceptor() : socketFileDescriptorReceptor(0), receptorAddressSize(), receptorAddress(), receptorIP() {} }; struct vpEmitter{ - struct sockaddr_in emitterAdress; -#ifdef UNIX + struct sockaddr_in emitterAddress; +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX int socketFileDescriptorEmitter; #else SOCKET socketFileDescriptorEmitter; #endif + vpEmitter() : emitterAddress(), socketFileDescriptorEmitter(0) + { + emitterAddress.sin_family = AF_INET; + emitterAddress.sin_addr.s_addr = INADDR_ANY; + emitterAddress.sin_port = 0; + socketFileDescriptorEmitter = 0; + } }; //######## PARAMETERS ######## @@ -112,7 +121,7 @@ protected: vpEmitter emitter; std::vector<vpReceptor> receptor_list; fd_set readFileDescriptor; -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX int socketMax; #else SOCKET socketMax; @@ -305,7 +314,7 @@ int vpNetwork::receive(T* object, const unsigned int &sizeOfObject) else{ for(unsigned int i=0; i<receptor_list.size(); i++){ if(FD_ISSET((unsigned int)receptor_list[i].socketFileDescriptorReceptor,&readFileDescriptor)){ -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX numbytes = recv(receptor_list[i].socketFileDescriptorReceptor, (char*)(void*)object, sizeOfObject, 0); #else numbytes = recv((unsigned int)receptor_list[i].socketFileDescriptorReceptor, (char*)(void*)object, (int)sizeOfObject, 0); @@ -378,7 +387,7 @@ int vpNetwork::receiveFrom(T* object, const unsigned int &receptorEmitting, cons } else{ if(FD_ISSET((unsigned int)receptor_list[receptorEmitting].socketFileDescriptorReceptor,&readFileDescriptor)){ -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX numbytes = recv(receptor_list[receptorEmitting].socketFileDescriptorReceptor, (char*)(void*)object, sizeOfObject, 0); #else numbytes = recv((unsigned int)receptor_list[receptorEmitting].socketFileDescriptorReceptor, (char*)(void*)object, (int)sizeOfObject, 0); @@ -426,11 +435,12 @@ int vpNetwork::send(T* object, const unsigned int &sizeOfObject) } int flags = 0; -#if ! defined(APPLE) && ! defined(WIN32) +//#if ! defined(APPLE) && ! defined(SOLARIS) && ! defined(_WIN32) +#if defined(__linux__) flags = MSG_NOSIGNAL; // Only for Linux #endif -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX return sendto(receptor_list[0].socketFileDescriptorReceptor, (const char*)(void*)object, sizeOfObject, flags, (sockaddr*) &receptor_list[0].receptorAddress,receptor_list[0].receptorAddressSize); #else @@ -472,11 +482,12 @@ int vpNetwork::sendTo(T* object, const unsigned int &dest, const unsigned int &s } int flags = 0; -#if ! defined(APPLE) && ! defined(WIN32) +//#if ! defined(APPLE) && ! defined(SOLARIS) && ! defined(_WIN32) +#if defined(__linux__) flags = MSG_NOSIGNAL; // Only for Linux #endif -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX return sendto(receptor_list[dest].socketFileDescriptorReceptor, (const char*)(void*)object, sizeOfObject, flags, (sockaddr*) &receptor_list[dest].receptorAddress,receptor_list[dest].receptorAddressSize); #else diff --git a/src/network/vpRequest.cpp b/src/network/vpRequest.cpp index b300c787cc596688c7c2dd5109f3d40e0a53e255..4195c39a66974eb2d56d1b83188165a4a889dc41 100644 --- a/src/network/vpRequest.cpp +++ b/src/network/vpRequest.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRequest.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRequest.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -42,6 +42,7 @@ #include <visp/vpRequest.h> vpRequest::vpRequest() + : request_id(""), listOfParams() {} vpRequest::~vpRequest() diff --git a/src/network/vpRequest.h b/src/network/vpRequest.h index 0a0ea6bf3a820427adb5ca4f196d56b6b543c9c1..a155160535f318f3bd58632b749def0c7742dda2 100644 --- a/src/network/vpRequest.h +++ b/src/network/vpRequest.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRequest.h 4303 2013-07-04 14:14:00Z fspindle $ + * $Id: vpRequest.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/network/vpServer.cpp b/src/network/vpServer.cpp index 2d85309366c78ce12ed4459515d04e83b12c80e5..01647acc34f818a0230c8f687e39877ff8e6c4a6 100644 --- a/src/network/vpServer.cpp +++ b/src/network/vpServer.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpServer.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpServer.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -45,11 +45,11 @@ /*! Construct a server on the machine launching it. */ -vpServer::vpServer( ) : vpNetwork(), started(false) +vpServer::vpServer( ) : adress(), port(0), started(false), max_clients(10) { int protocol = 0; emitter.socketFileDescriptorEmitter = socket(AF_INET, SOCK_STREAM, protocol); -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX if (emitter.socketFileDescriptorEmitter < 0) #else if (emitter.socketFileDescriptorEmitter == INVALID_SOCKET) @@ -57,12 +57,12 @@ vpServer::vpServer( ) : vpNetwork(), started(false) { vpERROR_TRACE( "vpServer::vpServer(), cannot open socket." ); } - emitter.emitterAdress.sin_family = AF_INET; - emitter.emitterAdress.sin_addr.s_addr = INADDR_ANY; - emitter.emitterAdress.sin_port = 0; + emitter.emitterAddress.sin_family = AF_INET; + emitter.emitterAddress.sin_addr.s_addr = INADDR_ANY; + emitter.emitterAddress.sin_port = 0; - adress = inet_ntoa(emitter.emitterAdress.sin_addr); - port = emitter.emitterAdress.sin_port; + adress = inet_ntoa(emitter.emitterAddress.sin_addr); + port = emitter.emitterAddress.sin_port; } /*! @@ -70,11 +70,11 @@ vpServer::vpServer( ) : vpNetwork(), started(false) \param port_serv : server's port. */ -vpServer::vpServer( const int &port_serv ) : vpNetwork(), started(false) +vpServer::vpServer( const int &port_serv ) : adress(), port(0), started(false), max_clients(10) { int protocol = 0; emitter.socketFileDescriptorEmitter = socket(AF_INET, SOCK_STREAM, protocol); -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX if (emitter.socketFileDescriptorEmitter < 0) #else if (emitter.socketFileDescriptorEmitter == INVALID_SOCKET) @@ -82,11 +82,11 @@ vpServer::vpServer( const int &port_serv ) : vpNetwork(), started(false) { vpERROR_TRACE( "vpServer::vpServer(const int &port_serv), cannot open socket." ); } - emitter.emitterAdress.sin_family = AF_INET; - emitter.emitterAdress.sin_addr.s_addr = INADDR_ANY; //inet_addr("127.0.0.1");; - emitter.emitterAdress.sin_port = htons( (unsigned short)port_serv ); + emitter.emitterAddress.sin_family = AF_INET; + emitter.emitterAddress.sin_addr.s_addr = INADDR_ANY; //inet_addr("127.0.0.1");; + emitter.emitterAddress.sin_port = htons( (unsigned short)port_serv ); - adress = inet_ntoa(emitter.emitterAdress.sin_addr); + adress = inet_ntoa(emitter.emitterAddress.sin_addr); port = port_serv; } @@ -96,11 +96,12 @@ vpServer::vpServer( const int &port_serv ) : vpNetwork(), started(false) \param adress_serv : server's adress. \param port_serv : server's port. */ -vpServer::vpServer( const std::string &adress_serv,const int &port_serv ) : vpNetwork(), started(false) +vpServer::vpServer( const std::string &adress_serv,const int &port_serv ) + : adress(), port(0), started(false), max_clients(10) { int protocol = 0; emitter.socketFileDescriptorEmitter = socket(AF_INET, SOCK_STREAM, protocol); -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX if (emitter.socketFileDescriptorEmitter < 0) #else if (emitter.socketFileDescriptorEmitter == INVALID_SOCKET) @@ -108,9 +109,9 @@ vpServer::vpServer( const std::string &adress_serv,const int &port_serv ) : vpNe { vpERROR_TRACE( "vpServer::vpServer(const std::string &adress_serv,const int &port_serv), cannot open socket." ); } - emitter.emitterAdress.sin_family = AF_INET; - emitter.emitterAdress.sin_addr.s_addr = inet_addr(adress_serv.c_str()); - emitter.emitterAdress.sin_port = htons( (unsigned short)port_serv ); + emitter.emitterAddress.sin_family = AF_INET; + emitter.emitterAddress.sin_addr.s_addr = inet_addr(adress_serv.c_str()); + emitter.emitterAddress.sin_port = htons( (unsigned short)port_serv ); adress = adress_serv; port = port_serv; @@ -121,14 +122,14 @@ vpServer::vpServer( const std::string &adress_serv,const int &port_serv ) : vpNe */ vpServer::~vpServer() { -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX close( emitter.socketFileDescriptorEmitter ); #else //Win32 closesocket( (unsigned)emitter.socketFileDescriptorEmitter ); #endif for(unsigned int i = 0 ; i < receptor_list.size() ; i++) -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX close( receptor_list[i].socketFileDescriptorReceptor ); #else //Win32 closesocket( (unsigned)receptor_list[i].socketFileDescriptorReceptor ); @@ -143,11 +144,11 @@ vpServer::~vpServer() */ bool vpServer::start() { - int serverStructLength = sizeof(emitter.emitterAdress); -#ifdef UNIX - int bindResult = bind( emitter.socketFileDescriptorEmitter, (struct sockaddr *) &emitter.emitterAdress, (unsigned)serverStructLength ); + int serverStructLength = sizeof(emitter.emitterAddress); +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX + int bindResult = bind( emitter.socketFileDescriptorEmitter, (struct sockaddr *) &emitter.emitterAddress, (unsigned)serverStructLength ); #else //Win32 - int bindResult = bind( (unsigned)emitter.socketFileDescriptorEmitter, (struct sockaddr *) &emitter.emitterAdress, serverStructLength ); + int bindResult = bind( (unsigned)emitter.socketFileDescriptorEmitter, (struct sockaddr *) &emitter.emitterAddress, serverStructLength ); #endif @@ -176,7 +177,7 @@ bool vpServer::start() } #endif // SO_NOSIGPIPE -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX listen( emitter.socketFileDescriptorEmitter, (int)max_clients ); #else //Win32 listen( (unsigned)emitter.socketFileDescriptorEmitter, (int)max_clients ); @@ -230,13 +231,13 @@ bool vpServer::checkForConnections() if(FD_ISSET((unsigned int)emitter.socketFileDescriptorEmitter,&readFileDescriptor)){ vpNetwork::vpReceptor client; client.receptorAddressSize = sizeof(client.receptorAddress); -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX client.socketFileDescriptorReceptor = accept(emitter.socketFileDescriptorEmitter,(struct sockaddr*) &client.receptorAddress, &client.receptorAddressSize); #else //Win32 client.socketFileDescriptorReceptor = accept((unsigned int)emitter.socketFileDescriptorEmitter,(struct sockaddr*) &client.receptorAddress, &client.receptorAddressSize); #endif -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX if((client.socketFileDescriptorReceptor) == -1) #else if((client.socketFileDescriptorReceptor) == INVALID_SOCKET) @@ -253,7 +254,7 @@ bool vpServer::checkForConnections() for(unsigned int i=0; i<receptor_list.size(); i++){ if(FD_ISSET((unsigned int)receptor_list[i].socketFileDescriptorReceptor,&readFileDescriptor)){ char deco; -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX int numbytes = recv(receptor_list[i].socketFileDescriptorReceptor, &deco, 1, MSG_PEEK); #else //Win32 int numbytes = recv((unsigned int)receptor_list[i].socketFileDescriptorReceptor, &deco, 1, MSG_PEEK); diff --git a/src/network/vpServer.h b/src/network/vpServer.h index 5adf80704c15a35f20549a2966063ffc58033698..b1873e2cea824fc70ffeabcd275a4e7734760a74 100644 --- a/src/network/vpServer.h +++ b/src/network/vpServer.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpServer.h 4303 2013-07-04 14:14:00Z fspindle $ + * $Id: vpServer.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/robot/real-robot/afma4/vpAfma4.cpp b/src/robot/real-robot/afma4/vpAfma4.cpp index 66c2751f47d73df4b1e5787643cbbc17dd2f2534..32ee3c9d46e13d21a6e3a6c2f0189823b27cf06c 100644 --- a/src/robot/real-robot/afma4/vpAfma4.cpp +++ b/src/robot/real-robot/afma4/vpAfma4.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpAfma4.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpAfma4.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -69,6 +69,7 @@ const unsigned int vpAfma4::njoint = 4; */ vpAfma4::vpAfma4() + : _a1(0), _d3(0), _d4(0), _etc(), _erc(), _eMc() { // Set the default parameters in case of the config files on the NAS // at Inria are not available. @@ -148,7 +149,7 @@ vpAfma4::init (void) */ vpHomogeneousMatrix -vpAfma4::getForwardKinematics(const vpColVector & q) +vpAfma4::getForwardKinematics(const vpColVector & q) const { vpHomogeneousMatrix fMc; fMc = get_fMc(q); @@ -186,7 +187,7 @@ vpAfma4::getForwardKinematics(const vpColVector & q) \sa getForwardKinematics(const vpColVector & q) */ vpHomogeneousMatrix -vpAfma4::get_fMc (const vpColVector & q) +vpAfma4::get_fMc (const vpColVector & q) const { vpHomogeneousMatrix fMc; get_fMc(q, fMc); @@ -221,7 +222,7 @@ vpAfma4::get_fMc (const vpColVector & q) */ void -vpAfma4::get_fMc(const vpColVector & q, vpHomogeneousMatrix & fMc) +vpAfma4::get_fMc(const vpColVector & q, vpHomogeneousMatrix & fMc) const { // Compute the direct geometric model: fMe = transformation between @@ -269,7 +270,7 @@ vpAfma4::get_fMc(const vpColVector & q, vpHomogeneousMatrix & fMc) */ void -vpAfma4::get_fMe(const vpColVector & q, vpHomogeneousMatrix & fMe) +vpAfma4::get_fMe(const vpColVector & q, vpHomogeneousMatrix & fMe) const { double q1 = q[0]; // rot touret double q2 = q[1]; // vertical translation @@ -320,7 +321,7 @@ vpAfma4::get_fMe(const vpColVector & q, vpHomogeneousMatrix & fMe) */ void -vpAfma4::get_cMe(vpHomogeneousMatrix &cMe) +vpAfma4::get_cMe(vpHomogeneousMatrix &cMe) const { cMe = this->_eMc.inverse(); } @@ -335,7 +336,7 @@ vpAfma4::get_cMe(vpHomogeneousMatrix &cMe) */ void -vpAfma4::get_cVe(vpVelocityTwistMatrix &cVe) +vpAfma4::get_cVe(vpVelocityTwistMatrix &cVe) const { vpHomogeneousMatrix cMe ; get_cMe(cMe) ; @@ -364,7 +365,7 @@ vpAfma4::get_cVe(vpVelocityTwistMatrix &cVe) */ void -vpAfma4::get_cVf(const vpColVector & q, vpVelocityTwistMatrix &cVf) +vpAfma4::get_cVf(const vpColVector & q, vpVelocityTwistMatrix &cVf) const { vpHomogeneousMatrix fMc, cMf ; get_fMc(q, fMc) ; @@ -375,8 +376,6 @@ vpAfma4::get_cVf(const vpColVector & q, vpVelocityTwistMatrix &cVf) return; } - - /*! Get the robot jacobian expressed in the end-effector frame: @@ -414,7 +413,7 @@ vpAfma4::get_cVf(const vpColVector & q, vpVelocityTwistMatrix &cVf) \sa get_fJe() */ void -vpAfma4::get_eJe(const vpColVector &q, vpMatrix &eJe) +vpAfma4::get_eJe(const vpColVector &q, vpMatrix &eJe) const { double q4 = q[2]; // pan double q5 = q[3]; // tilt @@ -468,7 +467,7 @@ vpAfma4::get_eJe(const vpColVector &q, vpMatrix &eJe) */ void -vpAfma4::get_fJe(const vpColVector &q, vpMatrix &fJe) +vpAfma4::get_fJe(const vpColVector &q, vpMatrix &fJe) const { fJe.resize(6,4) ; @@ -524,7 +523,7 @@ vpAfma4::get_fJe(const vpColVector &q, vpMatrix &fJe) \sa get_eJe() and get_fJe() */ -void vpAfma4::get_fJe_inverse(const vpColVector &q, vpMatrix &fJe_inverse) +void vpAfma4::get_fJe_inverse(const vpColVector &q, vpMatrix &fJe_inverse) const { fJe_inverse.resize(4, 6) ; fJe_inverse = 0; @@ -560,7 +559,7 @@ void vpAfma4::get_fJe_inverse(const vpColVector &q, vpMatrix &fJe_inverse) */ vpColVector -vpAfma4::getJointMin() +vpAfma4::getJointMin() const { vpColVector qmin(4); for (unsigned int i=0; i < 4; i ++) @@ -577,7 +576,7 @@ vpAfma4::getJointMin() */ vpColVector -vpAfma4::getJointMax() +vpAfma4::getJointMax() const { vpColVector qmax(4); for (unsigned int i=0; i < 4; i ++) @@ -596,7 +595,7 @@ vpAfma4::getJointMax() \param os : Output stream. \param afma4 : Robot parameters. */ -std::ostream & operator << (std::ostream & os, +VISP_EXPORT std::ostream & operator << (std::ostream & os, const vpAfma4 & afma4) { vpRotationMatrix eRc; @@ -649,9 +648,3 @@ std::ostream & operator << (std::ostream & os, return os; } - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ diff --git a/src/robot/real-robot/afma4/vpAfma4.h b/src/robot/real-robot/afma4/vpAfma4.h index 4acab0cd0c6a6a3ad6270573d47ef5003578c7af..376314a65fddc8058939eae38ff3518a32f319bf 100644 --- a/src/robot/real-robot/afma4/vpAfma4.h +++ b/src/robot/real-robot/afma4/vpAfma4.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpAfma4.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpAfma4.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -113,28 +113,29 @@ class VISP_EXPORT vpAfma4 { public: vpAfma4(); + /*! Destructor that does nothing. */ + virtual ~vpAfma4() {}; void init (void); - vpHomogeneousMatrix getForwardKinematics(const vpColVector & q); + vpHomogeneousMatrix getForwardKinematics(const vpColVector & q) const; /* int getInverseKinematics(const vpHomogeneousMatrix & fMc, */ /* vpColVector & q, const bool &nearest=true); */ - vpHomogeneousMatrix get_fMc (const vpColVector & q); - void get_fMe(const vpColVector & q, vpHomogeneousMatrix & fMe); - void get_fMc(const vpColVector & q, vpHomogeneousMatrix & fMc); - - void get_cMe(vpHomogeneousMatrix &cMe) ; - void get_cVe(vpVelocityTwistMatrix &cVe) ; - void get_cVf(const vpColVector & q, vpVelocityTwistMatrix &cVf); - void get_eJe(const vpColVector &q, vpMatrix &eJe) ; - void get_fJe(const vpColVector &q, vpMatrix &fJe) ; - void get_fJe_inverse(const vpColVector &q, vpMatrix &fJe_inverse) ; - - friend VISP_EXPORT std::ostream & operator << (std::ostream & os, - const vpAfma4 & afma4); - - vpColVector getJointMin(); - vpColVector getJointMax(); + vpHomogeneousMatrix get_fMc (const vpColVector & q) const; + void get_fMe(const vpColVector & q, vpHomogeneousMatrix & fMe) const; + void get_fMc(const vpColVector & q, vpHomogeneousMatrix & fMc) const; + + void get_cMe(vpHomogeneousMatrix &cMe) const; + void get_cVe(vpVelocityTwistMatrix &cVe) const; + void get_cVf(const vpColVector & q, vpVelocityTwistMatrix &cVf) const; + void get_eJe(const vpColVector &q, vpMatrix &eJe) const; + void get_fJe(const vpColVector &q, vpMatrix &fJe) const; + void get_fJe_inverse(const vpColVector &q, vpMatrix &fJe_inverse) const; + + friend VISP_EXPORT std::ostream & operator << (std::ostream & os, const vpAfma4 & afma4); + + vpColVector getJointMin() const; + vpColVector getJointMax() const; public: diff --git a/src/robot/real-robot/afma4/vpRobotAfma4.cpp b/src/robot/real-robot/afma4/vpRobotAfma4.cpp index d79c9d7cd4b943eacb0c894cb43e4e6a6ec25b53..731a35792c5dbda2c03cdd05de36c6593c090dc1 100644 --- a/src/robot/real-robot/afma4/vpRobotAfma4.cpp +++ b/src/robot/real-robot/afma4/vpRobotAfma4.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRobotAfma4.cpp 4107 2013-02-06 10:04:49Z fspindle $ + * $Id: vpRobotAfma4.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -554,7 +554,7 @@ vpRobotAfma4::getPowerState(void) */ void -vpRobotAfma4::get_cVe(vpVelocityTwistMatrix &cVe) +vpRobotAfma4::get_cVe(vpVelocityTwistMatrix &cVe) const { vpHomogeneousMatrix cMe ; vpAfma4::get_cMe(cMe) ; @@ -572,7 +572,7 @@ vpRobotAfma4::get_cVe(vpVelocityTwistMatrix &cVe) */ void -vpRobotAfma4::get_cVf(vpVelocityTwistMatrix &cVf) +vpRobotAfma4::get_cVf(vpVelocityTwistMatrix &cVf) const { double position[this->njoint]; double timestamp; @@ -604,7 +604,7 @@ vpRobotAfma4::get_cVf(vpVelocityTwistMatrix &cVf) */ void -vpRobotAfma4::get_cMe(vpHomogeneousMatrix &cMe) +vpRobotAfma4::get_cMe(vpHomogeneousMatrix &cMe) const { vpAfma4::get_cMe(cMe) ; } diff --git a/src/robot/real-robot/afma4/vpRobotAfma4.h b/src/robot/real-robot/afma4/vpRobotAfma4.h index e61dea0eb7df9d1ec59fada69aa6aa01370ace68..b7d19e0f6a135b00e784f4eee894a60f91ba785b 100644 --- a/src/robot/real-robot/afma4/vpRobotAfma4.h +++ b/src/robot/real-robot/afma4/vpRobotAfma4.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRobotAfma4.h 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpRobotAfma4.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -251,11 +251,11 @@ public: /* Methode publiques */ vpColVector getVelocity (const vpRobot::vpControlFrameType frame); vpColVector getVelocity (const vpRobot::vpControlFrameType frame, double ×tamp); - void get_cMe(vpHomogeneousMatrix &cMe) ; - void get_cVe(vpVelocityTwistMatrix &cVe) ; - void get_cVf(vpVelocityTwistMatrix &cVf) ; - void get_eJe(vpMatrix &eJe) ; - void get_fJe(vpMatrix &fJe) ; + void get_cMe(vpHomogeneousMatrix &cMe) const; + void get_cVe(vpVelocityTwistMatrix &cVe) const; + void get_cVf(vpVelocityTwistMatrix &cVf) const; + void get_eJe(vpMatrix &eJe); + void get_fJe(vpMatrix &fJe); void init (void); diff --git a/src/robot/real-robot/afma4/vpServolens.cpp b/src/robot/real-robot/afma4/vpServolens.cpp index 1fe21d8fbf14812e8e6b5960d336376a065869af..1104be29907175fcfadbc2b30b6348d07de054a8 100644 --- a/src/robot/real-robot/afma4/vpServolens.cpp +++ b/src/robot/real-robot/afma4/vpServolens.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpServolens.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpServolens.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -49,7 +49,7 @@ */ -#if defined(UNIX) +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX #include <unistd.h> #include <termios.h> @@ -71,9 +71,8 @@ \sa open() */ -vpServolens::vpServolens() +vpServolens::vpServolens() : remfd(0), isinit(false) { - isinit = false; } /*! @@ -84,10 +83,8 @@ vpServolens::vpServolens() \sa open() */ -vpServolens::vpServolens(const char *port) +vpServolens::vpServolens(const char *port) : remfd(0), isinit(false) { - isinit = false; - this->open(port); } @@ -131,7 +128,7 @@ vpServolens::open(const char *port) "Cannot open Servolens serial port."); } - // Lecture des paramètres courants de la liaison série. + // Lecture des parametres courants de la liaison serie. if (tcgetattr(this->remfd, &info) < 0) { ::close(this->remfd); vpERROR_TRACE ("Error using TCGETS in ioctl."); @@ -144,11 +141,11 @@ vpServolens::open(const char *port) // 9600 bauds, 1 bit de stop, parite paire, 7 bits de donnee // - // Traitement sur les caractères recus + // Traitement sur les caracteres recus info.c_iflag = 0; info.c_iflag |= INLCR; - // Traitement sur les caractères envoyés sur la RS232. + // Traitement sur les caracteres envoyes sur la RS232. info.c_oflag = 0; // idem // Traitement des lignes @@ -159,7 +156,7 @@ vpServolens::open(const char *port) info.c_cflag |= CREAD; // Validation reception info.c_cflag |= B9600 | CS7 | PARENB; // 9600 baus, 7 data, parite paire - // Caractères immédiatement disponibles. + // Caracteres immediatement disponibles. // info.c_cc[VMIN] = 1; // info.c_cc[VTIME] = 0; @@ -210,7 +207,7 @@ vpServolens::close() with Servolens. */ void -vpServolens::reset() +vpServolens::reset() const { if (!isinit) { vpERROR_TRACE ("Cannot dial with Servolens."); @@ -248,7 +245,7 @@ vpServolens::reset() \sa open() */ void -vpServolens::init() +vpServolens::init() const { if (!isinit) { vpERROR_TRACE ("Cannot dial with Servolens."); @@ -283,7 +280,7 @@ vpServolens::init() */ void -vpServolens::enableCmdComplete(vpServoType servo, bool active) +vpServolens::enableCmdComplete(vpServoType servo, bool active) const { if (!isinit) { vpERROR_TRACE ("Cannot dial with Servolens."); @@ -331,7 +328,7 @@ vpServolens::enableCmdComplete(vpServoType servo, bool active) */ void -vpServolens::enablePrompt(bool active) +vpServolens::enablePrompt(bool active) const { if (!isinit) { vpERROR_TRACE ("Cannot dial with Servolens."); @@ -358,7 +355,7 @@ vpServolens::enablePrompt(bool active) with Servolens. */ void -vpServolens::setController(vpControllerType controller) +vpServolens::setController(vpControllerType controller) const { if (!isinit) { vpERROR_TRACE ("Cannot dial with Servolens."); @@ -399,7 +396,7 @@ vpServolens::setController(vpControllerType controller) */ void -vpServolens::setAutoIris(bool enable) +vpServolens::setAutoIris(bool enable) const { if (!isinit) { vpERROR_TRACE ("Cannot dial with Servolens."); @@ -427,7 +424,7 @@ vpServolens::setAutoIris(bool enable) */ void -vpServolens::setPosition(vpServoType servo, unsigned int position) +vpServolens::setPosition(vpServoType servo, unsigned int position) const { if (!isinit) { vpERROR_TRACE ("Cannot dial with Servolens."); @@ -442,15 +439,15 @@ vpServolens::setPosition(vpServoType servo, unsigned int position) this->wait(); */ -#if FINSERVO +#ifdef FINSERVO /* envoie des commandes pour qu'en fin de mouvement servolens renvoie */ /* une commande de fin de mouvement (ex: ZF, FF, DF). */ this->enableCommandComplete(); #endif /* FINSERVO */ // 08/08/00 Fabien S. - Correction de la consigne demandee - // pour prendre en compte l'erreur entre la consigne demandée - // et la consigne mesurée. + // pour prendre en compte l'erreur entre la consigne demandee + // et la consigne mesuree. // A la consigne du zoom on retranche 1. // A la consigne du focus on ajoute 1. // A la consigne du iris on ajoute 1. @@ -488,13 +485,13 @@ vpServolens::setPosition(vpServoType servo, unsigned int position) break; } /* envoie de la commande */ -#if PRINT +#ifdef PRINT printf("\ncommande: %s", commande); #endif this->write(commande); -#if FINSERVO +#ifdef FINSERVO /* on attend la fin du mouvement des objectifs */ this->wait(servo); /* on attend les codes ZF, FF, DF */ #endif @@ -511,7 +508,7 @@ vpServolens::setPosition(vpServoType servo, unsigned int position) */ bool -vpServolens::getPosition(vpServoType servo, unsigned int &position) +vpServolens::getPosition(vpServoType servo, unsigned int &position) const { if (!isinit) { vpERROR_TRACE ("Cannot dial with Servolens."); @@ -634,7 +631,7 @@ vpServolens::getPosition(vpServoType servo, unsigned int &position) int main() { -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX vpServolens servolens("/dev/ttyS0"); vpImage<unsigned char> I(240, 320); @@ -649,7 +646,7 @@ vpServolens::getPosition(vpServoType servo, unsigned int &position) */ vpCameraParameters -vpServolens::getCameraParameters(vpImage<unsigned char> &I) +vpServolens::getCameraParameters(vpImage<unsigned char> &I) const { if (!isinit) { vpERROR_TRACE ("Cannot dial with Servolens."); @@ -697,7 +694,7 @@ vpServolens::getCameraParameters(vpImage<unsigned char> &I) with Servolens. */ char -vpServolens::wait() +vpServolens::wait() const { if (!isinit) { vpERROR_TRACE ("Cannot dial with Servolens."); @@ -732,7 +729,7 @@ vpServolens::wait() */ void -vpServolens::wait(vpServoType servo) +vpServolens::wait(vpServoType servo) const { if (!isinit) { vpERROR_TRACE ("Cannot dial with Servolens."); @@ -798,7 +795,7 @@ vpServolens::wait(vpServoType servo) with Servolens. */ bool -vpServolens::read(char *c, long timeout_s) +vpServolens::read(char *c, long timeout_s) const { if (!isinit) { vpERROR_TRACE ("Cannot dial with Servolens."); @@ -835,7 +832,7 @@ vpServolens::read(char *c, long timeout_s) with Servolens. */ void -vpServolens::write(const char *s) +vpServolens::write(const char *s) const { if (!isinit) { vpERROR_TRACE ("Cannot dial with Servolens."); @@ -874,7 +871,7 @@ vpServolens::write(const char *s) */ bool -vpServolens::clean(const char *in, char *out) +vpServolens::clean(const char *in, char *out) const { short nb_car, i=0; bool error = false; diff --git a/src/robot/real-robot/afma4/vpServolens.h b/src/robot/real-robot/afma4/vpServolens.h index f7e98de4aa79780db191838654da7bafd32626cb..fcf4e64a2739255d62a2af30f29cddfc420c1d59 100644 --- a/src/robot/real-robot/afma4/vpServolens.h +++ b/src/robot/real-robot/afma4/vpServolens.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpServolens.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpServolens.h 4604 2014-01-21 14:15:23Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -45,7 +45,7 @@ #include <visp/vpConfig.h> -#if defined(UNIX) +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) /*! @@ -120,39 +120,34 @@ class VISP_EXPORT vpServolens void open(const char *port="/dev/ttyS0"); void close(); - void reset(); + void reset() const; - void setController(vpControllerType controller); - void setAutoIris(bool enable); - void setPosition(vpServoType servo, unsigned int position); - bool getPosition(vpServoType servo, unsigned int &position); - vpCameraParameters getCameraParameters(vpImage<unsigned char> &I); + void setController(vpControllerType controller) const; + void setAutoIris(bool enable) const; + void setPosition(vpServoType servo, unsigned int position) const; + bool getPosition(vpServoType servo, unsigned int &position) const; + vpCameraParameters getCameraParameters(vpImage<unsigned char> &I) const; - void enablePrompt(bool active); + void enablePrompt(bool active) const; private: - void init(); + void init() const; - void enableCmdComplete(vpServoType servo, bool active); + void enableCmdComplete(vpServoType servo, bool active) const; - char wait(); - void wait(vpServoType servo); + char wait() const; + void wait(vpServoType servo) const; - bool read(char *c, long timeout_s); - void write(const char *s); + bool read(char *c, long timeout_s) const; + void write(const char *s) const; - bool clean(const char *in, char *out); + bool clean(const char *in, char *out) const; int remfd; // file pointer of the host's tty bool isinit; }; -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ #endif #endif diff --git a/src/robot/real-robot/afma6/vpAfma6.cpp b/src/robot/real-robot/afma6/vpAfma6.cpp index 67879f29b246092d6b321e0d380c09825640b090..38008ff1b2f6198719d0abdd6790781cb8d969f1 100644 --- a/src/robot/real-robot/afma6/vpAfma6.cpp +++ b/src/robot/real-robot/afma6/vpAfma6.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpAfma6.cpp 4210 2013-04-16 08:57:46Z fspindle $ + * $Id: vpAfma6.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -68,70 +68,70 @@ static const char *opt_Afma6[] = {"JOINT_MAX","JOINT_MIN","LONG_56","COUPL_56", NULL}; const char * const vpAfma6::CONST_AFMA6_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Afma6/current/include/const_Afma6.cnf"; #else = "/udd/fspindle/robot/Afma6/current/include/const_Afma6.cnf"; #endif const char * const vpAfma6::CONST_EMC_CCMOP_WITHOUT_DISTORTION_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Afma6/current/include/const_eMc_ccmop_without_distortion_Afma6.cnf"; #else = "/udd/fspindle/robot/Afma6/current/include/const_eMc_ccmop_without_distortion_Afma6.cnf"; #endif const char * const vpAfma6::CONST_EMC_CCMOP_WITH_DISTORTION_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Afma6/current/include/const_eMc_ccmop_with_distortion_Afma6.cnf"; #else = "/udd/fspindle/robot/Afma6/current/include/const_eMc_ccmop_with_distortion_Afma6.cnf"; #endif const char * const vpAfma6::CONST_EMC_GRIPPER_WITHOUT_DISTORTION_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Afma6/current/include/const_eMc_gripper_without_distortion_Afma6.cnf"; #else = "/udd/fspindle/robot/Afma6/current/include/const_eMc_gripper_without_distortion_Afma6.cnf"; #endif const char * const vpAfma6::CONST_EMC_GRIPPER_WITH_DISTORTION_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Afma6/current/include/const_eMc_gripper_with_distortion_Afma6.cnf"; #else = "/udd/fspindle/robot/Afma6/current/include/const_eMc_gripper_with_distortion_Afma6.cnf"; #endif const char * const vpAfma6::CONST_EMC_VACUUM_WITHOUT_DISTORTION_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Afma6/current/include/const_eMc_vacuum_without_distortion_Afma6.cnf"; #else = "/udd/fspindle/robot/Afma6/current/include/const_eMc_vacuum_without_distortion_Afma6.cnf"; #endif const char * const vpAfma6::CONST_EMC_VACUUM_WITH_DISTORTION_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Afma6/current/include/const_eMc_vacuum_with_distortion_Afma6.cnf"; #else = "/udd/fspindle/robot/Afma6/current/include/const_eMc_vacuum_with_distortion_Afma6.cnf"; #endif const char * const vpAfma6::CONST_EMC_GENERIC_WITHOUT_DISTORTION_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Afma6/current/include/const_eMc_generic_without_distortion_Afma6.cnf"; #else = "/udd/fspindle/robot/Afma6/current/include/const_eMc_generic_without_distortion_Afma6.cnf"; #endif const char * const vpAfma6::CONST_EMC_GENERIC_WITH_DISTORTION_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Afma6/current/include/const_eMc_generic_with_distortion_Afma6.cnf"; #else = "/udd/fspindle/robot/Afma6/current/include/const_eMc_generic_with_distortion_Afma6.cnf"; #endif const char * const vpAfma6::CONST_CAMERA_AFMA6_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Afma6/current/include/const_camera_Afma6.xml"; #else = "/udd/fspindle/robot/Afma6/current/include/const_camera_Afma6.xml"; @@ -154,6 +154,9 @@ const unsigned int vpAfma6::njoint = 6; */ vpAfma6::vpAfma6() + : _coupl_56(0), _long_56(0), _etc(), _erc(), _eMc(), + tool_current(vpAfma6::defaultTool), + projModel(vpCameraParameters::perspectiveProjWithoutDistortion) { // Set the default parameters in case of the config files on the NAS // at Inria are not available. @@ -237,15 +240,15 @@ vpAfma6::init (const char * paramAfma6, \param tool : Camera in use. - \param projModel : Projection model of the camera. + \param proj_model : Projection model of the camera. */ void vpAfma6::init (vpAfma6::vpAfma6ToolType tool, - vpCameraParameters::vpCameraParametersProjType projModel) + vpCameraParameters::vpCameraParametersProjType proj_model) { - this->projModel = projModel; + this->projModel = proj_model; #ifdef VISP_HAVE_ACCESS_TO_NAS // Read the robot parameters from files @@ -254,19 +257,19 @@ vpAfma6::init (vpAfma6::vpAfma6ToolType tool, case vpAfma6::TOOL_CCMOP: { switch(projModel) { case vpCameraParameters::perspectiveProjWithoutDistortion : -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_CCMOP_WITHOUT_DISTORTION_FILENAME); -#else // WIN32 +#else // _WIN32 _snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_CCMOP_WITHOUT_DISTORTION_FILENAME); #endif break; case vpCameraParameters::perspectiveProjWithDistortion : -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_CCMOP_WITH_DISTORTION_FILENAME); -#else // WIN32 +#else // _WIN32 _snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_CCMOP_WITH_DISTORTION_FILENAME); #endif @@ -277,19 +280,19 @@ vpAfma6::init (vpAfma6::vpAfma6ToolType tool, case vpAfma6::TOOL_GRIPPER: { switch(projModel) { case vpCameraParameters::perspectiveProjWithoutDistortion : -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_GRIPPER_WITHOUT_DISTORTION_FILENAME); -#else // WIN32 +#else // _WIN32 _snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_GRIPPER_WITHOUT_DISTORTION_FILENAME); #endif break; case vpCameraParameters::perspectiveProjWithDistortion : -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_GRIPPER_WITH_DISTORTION_FILENAME); -#else // WIN32 +#else // _WIN32 _snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_GRIPPER_WITH_DISTORTION_FILENAME); #endif @@ -300,19 +303,19 @@ vpAfma6::init (vpAfma6::vpAfma6ToolType tool, case vpAfma6::TOOL_VACUUM: { switch(projModel) { case vpCameraParameters::perspectiveProjWithoutDistortion : -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_VACUUM_WITHOUT_DISTORTION_FILENAME); -#else // WIN32 +#else // _WIN32 _snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_VACUUM_WITHOUT_DISTORTION_FILENAME); #endif break; case vpCameraParameters::perspectiveProjWithDistortion : -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_VACUUM_WITH_DISTORTION_FILENAME); -#else // WIN32 +#else // _WIN32 _snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_VACUUM_WITH_DISTORTION_FILENAME); #endif @@ -323,19 +326,19 @@ vpAfma6::init (vpAfma6::vpAfma6ToolType tool, case vpAfma6::TOOL_GENERIC_CAMERA: { switch(projModel) { case vpCameraParameters::perspectiveProjWithoutDistortion : -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_GENERIC_WITHOUT_DISTORTION_FILENAME); -#else // WIN32 +#else // _WIN32 _snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_GENERIC_WITHOUT_DISTORTION_FILENAME); #endif break; case vpCameraParameters::perspectiveProjWithDistortion : -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_GENERIC_WITH_DISTORTION_FILENAME); -#else // WIN32 +#else // _WIN32 _snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_GENERIC_WITH_DISTORTION_FILENAME); #endif @@ -382,6 +385,7 @@ vpAfma6::init (vpAfma6::vpAfma6ToolType tool, _etc[2] = 0.2286; // tz break; } + break; } case vpAfma6::TOOL_GRIPPER: { switch(projModel) { @@ -402,6 +406,7 @@ vpAfma6::init (vpAfma6::vpAfma6ToolType tool, _etc[2] = 0.1642; // tz break; } + break; } case vpAfma6::TOOL_VACUUM: { switch(projModel) { @@ -422,6 +427,7 @@ vpAfma6::init (vpAfma6::vpAfma6ToolType tool, _etc[2] = 0.1658; // tz break; } + break; } case vpAfma6::TOOL_GENERIC_CAMERA: { switch(projModel) { @@ -436,6 +442,7 @@ vpAfma6::init (vpAfma6::vpAfma6ToolType tool, _etc[2] = 0; // tz break; } + break; } } vpRotationMatrix eRc(_erc); @@ -472,7 +479,7 @@ vpAfma6::init (vpAfma6::vpAfma6ToolType tool, */ vpHomogeneousMatrix -vpAfma6::getForwardKinematics(const vpColVector & q) +vpAfma6::getForwardKinematics(const vpColVector & q) const { vpHomogeneousMatrix fMc; fMc = get_fMc(q); @@ -555,7 +562,7 @@ int main() */ int vpAfma6::getInverseKinematics(const vpHomogeneousMatrix & fMc, - vpColVector & q, const bool &nearest, const bool &verbose) + vpColVector & q, const bool &nearest, const bool &verbose) const { vpHomogeneousMatrix fMe; double q_[2][6],d[2],t; @@ -735,7 +742,7 @@ vpAfma6::getInverseKinematics(const vpHomogeneousMatrix & fMc, \sa getForwardKinematics(const vpColVector & q) */ vpHomogeneousMatrix -vpAfma6::get_fMc (const vpColVector & q) +vpAfma6::get_fMc (const vpColVector & q) const { vpHomogeneousMatrix fMc; get_fMc(q, fMc); @@ -763,7 +770,7 @@ vpAfma6::get_fMc (const vpColVector & q) */ void -vpAfma6::get_fMc(const vpColVector & q, vpHomogeneousMatrix & fMc) +vpAfma6::get_fMc(const vpColVector & q, vpHomogeneousMatrix & fMc) const { // Compute the direct geometric model: fMe = transformation between @@ -797,7 +804,7 @@ vpAfma6::get_fMc(const vpColVector & q, vpHomogeneousMatrix & fMc) */ void -vpAfma6::get_fMe(const vpColVector & q, vpHomogeneousMatrix & fMe) +vpAfma6::get_fMe(const vpColVector & q, vpHomogeneousMatrix & fMe) const { double q0 = q[0]; // meter double q1 = q[1]; // meter @@ -851,7 +858,7 @@ vpAfma6::get_fMe(const vpColVector & q, vpHomogeneousMatrix & fMe) */ void -vpAfma6::get_cMe(vpHomogeneousMatrix &cMe) +vpAfma6::get_cMe(vpHomogeneousMatrix &cMe) const { cMe = this->_eMc.inverse(); } @@ -866,7 +873,7 @@ vpAfma6::get_cMe(vpHomogeneousMatrix &cMe) */ void -vpAfma6::get_cVe(vpVelocityTwistMatrix &cVe) +vpAfma6::get_cVe(vpVelocityTwistMatrix &cVe) const { vpHomogeneousMatrix cMe ; get_cMe(cMe) ; @@ -889,40 +896,41 @@ vpAfma6::get_cVe(vpVelocityTwistMatrix &cVe) */ void -vpAfma6::get_eJe(const vpColVector &q, vpMatrix &eJe) +vpAfma6::get_eJe(const vpColVector &q, vpMatrix &eJe) const { eJe.resize(6,6) ; - double s3,c3,s4,c4,s5,c5 ; + double s4,c4,s5,c5,s6,c6 ; - s3=sin(q[3]); c3=cos(q[3]); - s4=sin(q[4]); c4=cos(q[4]); - s5=sin(q[5]); c5=cos(q[5]); + s4=sin(q[3]); c4=cos(q[3]); + s5=sin(q[4]); c5=cos(q[4]); + s6=sin(q[5]-this->_coupl_56*q[4]); c6=cos(q[5]-this->_coupl_56*q[4]); eJe = 0; - eJe[0][0] = s3*s4*c5+c3*s5; - eJe[0][1] = -c3*s4*c5+s3*s5; - eJe[0][2] = c4*c5; - eJe[0][3] = - this->_long_56*s4*c5; + eJe[0][0] = s4*s5*c6+c4*s6; + eJe[0][1] = -c4*s5*c6+s4*s6; + eJe[0][2] = c5*c6; + eJe[0][3] = - this->_long_56*s5*c6; - eJe[1][0] = -s3*s4*s5+c3*c5; - eJe[1][1] = c3*s4*s5+s3*c5; - eJe[1][2] = -c4*s5; - eJe[1][3] = this->_long_56*s4*s5; + eJe[1][0] = -s4*s5*s6+c4*c6; + eJe[1][1] = c4*s5*s6+s4*c6; + eJe[1][2] = -c5*s6; + eJe[1][3] = this->_long_56*s5*s6; - eJe[2][0] = -s3*c4; - eJe[2][1] = c3*c4; - eJe[2][2] = s4; - eJe[2][3] = this->_long_56*c4; + eJe[2][0] = -s4*c5; + eJe[2][1] = c4*c5; + eJe[2][2] = s5; + eJe[2][3] = this->_long_56*c5; - eJe[3][3] = c4*c5; - eJe[3][4] = s5; + eJe[3][3] = c5*c6; + eJe[3][4] = s6; - eJe[4][3] = -c4*s5; - eJe[4][4] = c5; + eJe[4][3] = -c5*s6; + eJe[4][4] = c6; - eJe[5][3] = s4; + eJe[5][3] = s5; + eJe[5][4] = -this->_coupl_56; eJe[5][5] = 1; return; @@ -939,12 +947,13 @@ vpAfma6::get_eJe(const vpColVector &q, vpMatrix &eJe) 1 & 0 & 0 & -Ls4 & 0 & 0 \\ 0 & 1 & 0 & Lc4 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ - 0 & 0 & 0 & 0 & c4 & -s4c5 \\ - 0 & 0 & 0 & 0 & s4 & c4c5 \\ - 0 & 0 & 0 & 1 & 0 & s5 \\ + 0 & 0 & 0 & 0 & c4+\gamma s4c5 & -s4c5 \\ + 0 & 0 & 0 & 0 & s4-\gamma c4c5 & c4c5 \\ + 0 & 0 & 0 & 1 & -gamma s5 & s5 \\ \end{array} \right) \f] + where \f$\gamma\f$ is the coupling factor between join 5 and 6. \param q : Articular joint position of the robot. q[0], q[1], q[2] correspond to the first 3 translations expressed in meter, while @@ -956,7 +965,7 @@ vpAfma6::get_eJe(const vpColVector &q, vpMatrix &eJe) */ void -vpAfma6::get_fJe(const vpColVector &q, vpMatrix &fJe) +vpAfma6::get_fJe(const vpColVector &q, vpMatrix &fJe) const { fJe.resize(6,6) ; @@ -964,8 +973,8 @@ vpAfma6::get_fJe(const vpColVector &q, vpMatrix &fJe) // block superieur gauche fJe[0][0] = fJe[1][1] = fJe[2][2] = 1 ; - double s4 = sin(q[4]) ; - double c4 = cos(q[4]) ; + double s4 = sin(q[3]) ; + double c4 = cos(q[3]) ; // block superieur droit @@ -973,13 +982,18 @@ vpAfma6::get_fJe(const vpColVector &q, vpMatrix &fJe) fJe[1][3] = this->_long_56*c4 ; - double s5 = sin(q[5]) ; - double c5 = cos(q[5]) ; + double s5 = sin(q[4]) ; + double c5 = cos(q[4]) ; // block inferieur droit fJe[3][4] = c4 ; fJe[3][5] = -s4*c5 ; fJe[4][4] = s4 ; fJe[4][5] = c4*c5 ; fJe[5][3] = 1 ; fJe[5][5] = s5 ; + // coupling between joint 5 and 6 + fJe[3][4] += this->_coupl_56*s4*c5; + fJe[4][4] += -this->_coupl_56*c4*c5; + fJe[5][4] += -this->_coupl_56*s5; + return; } @@ -993,7 +1007,7 @@ vpAfma6::get_fJe(const vpColVector &q, vpMatrix &fJe) */ vpColVector -vpAfma6::getJointMin() +vpAfma6::getJointMin() const { vpColVector qmin(6); for (unsigned int i=0; i < 6; i ++) @@ -1010,7 +1024,7 @@ vpAfma6::getJointMin() */ vpColVector -vpAfma6::getJointMax() +vpAfma6::getJointMax() const { vpColVector qmax(6); for (unsigned int i=0; i < 6; i ++) @@ -1025,7 +1039,7 @@ vpAfma6::getJointMax() \return Coupling factor between join 5 and 6. */ double -vpAfma6::getCoupl56() +vpAfma6::getCoupl56() const { return _coupl_56; } @@ -1037,7 +1051,7 @@ vpAfma6::getCoupl56() \return Distance between join 5 and 6. */ double -vpAfma6::getLong56() +vpAfma6::getLong56() const { return _long_56; } @@ -1233,7 +1247,7 @@ int main() void vpAfma6::getCameraParameters (vpCameraParameters &cam, const unsigned int &image_width, - const unsigned int &image_height) + const unsigned int &image_height) const { #if defined(VISP_HAVE_XML2) && defined (VISP_HAVE_ACCESS_TO_NAS) vpXmlParserCamera parser; @@ -1451,7 +1465,7 @@ int main() */ void vpAfma6::getCameraParameters (vpCameraParameters &cam, - const vpImage<unsigned char> &I) + const vpImage<unsigned char> &I) const { getCameraParameters(cam,I.getWidth(),I.getHeight()); } @@ -1500,7 +1514,7 @@ int main() void vpAfma6::getCameraParameters (vpCameraParameters &cam, - const vpImage<vpRGBa> &I) + const vpImage<vpRGBa> &I) const { getCameraParameters(cam,I.getWidth(),I.getHeight()); } @@ -1515,7 +1529,7 @@ vpAfma6::getCameraParameters (vpCameraParameters &cam, \param os : Output stream. \param afma6 : Robot parameters. */ -std::ostream & operator << (std::ostream & os, +VISP_EXPORT std::ostream & operator << (std::ostream & os, const vpAfma6 & afma6) { vpRotationMatrix eRc; @@ -1568,8 +1582,4 @@ std::ostream & operator << (std::ostream & os, return os; } -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ + diff --git a/src/robot/real-robot/afma6/vpAfma6.h b/src/robot/real-robot/afma6/vpAfma6.h index 4351f36aea949cef76b01f9741e3605a0138e29d..0b5f173ee3cac44f41efdd6db9c63e843c447153 100644 --- a/src/robot/real-robot/afma6/vpAfma6.h +++ b/src/robot/real-robot/afma6/vpAfma6.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpAfma6.h 4191 2013-04-01 07:46:05Z fspindle $ + * $Id: vpAfma6.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -118,6 +118,8 @@ class VISP_EXPORT vpAfma6 public: vpAfma6(); + /*! Destructor that does nothing. */ + virtual ~vpAfma6() {}; void init (void); #ifdef VISP_HAVE_ACCESS_TO_NAS @@ -127,45 +129,45 @@ class VISP_EXPORT vpAfma6 vpCameraParameters::vpCameraParametersProjType projModel = vpCameraParameters::perspectiveProjWithoutDistortion); - vpHomogeneousMatrix getForwardKinematics(const vpColVector & q); + vpHomogeneousMatrix getForwardKinematics(const vpColVector & q) const; int getInverseKinematics(const vpHomogeneousMatrix & fMc, - vpColVector & q, const bool &nearest=true, const bool &verbose=false); - vpHomogeneousMatrix get_fMc (const vpColVector & q); - void get_fMe(const vpColVector & q, vpHomogeneousMatrix & fMe); - void get_fMc(const vpColVector & q, vpHomogeneousMatrix & fMc); + vpColVector & q, const bool &nearest=true, + const bool &verbose=false) const; + vpHomogeneousMatrix get_fMc (const vpColVector & q) const; + void get_fMe(const vpColVector & q, vpHomogeneousMatrix & fMe) const; + void get_fMc(const vpColVector & q, vpHomogeneousMatrix & fMc) const; - void get_cMe(vpHomogeneousMatrix &cMe) ; - void get_cVe(vpVelocityTwistMatrix &cVe) ; - void get_eJe(const vpColVector &q, vpMatrix &eJe) ; - void get_fJe(const vpColVector &q, vpMatrix &fJe) ; + void get_cMe(vpHomogeneousMatrix &cMe) const; + void get_cVe(vpVelocityTwistMatrix &cVe) const; + void get_eJe(const vpColVector &q, vpMatrix &eJe) const; + void get_fJe(const vpColVector &q, vpMatrix &fJe) const; #ifdef VISP_HAVE_ACCESS_TO_NAS void parseConfigFile (const char * filename); #endif //! Get the current tool type - vpAfma6ToolType getToolType(){ + vpAfma6ToolType getToolType() const { return tool_current; }; //! Get the current camera model projection type - vpCameraParameters::vpCameraParametersProjType getCameraParametersProjType(){ + vpCameraParameters::vpCameraParametersProjType getCameraParametersProjType() const{ return projModel; }; void getCameraParameters(vpCameraParameters &cam, - const unsigned int &image_width, - const unsigned int &image_height); + const unsigned int &image_width, + const unsigned int &image_height) const; void getCameraParameters(vpCameraParameters &cam, - const vpImage<unsigned char> &I); - void getCameraParameters(vpCameraParameters &cam, const vpImage<vpRGBa> &I); + const vpImage<unsigned char> &I) const; + void getCameraParameters(vpCameraParameters &cam, const vpImage<vpRGBa> &I) const; - friend VISP_EXPORT std::ostream & operator << (std::ostream & os, - const vpAfma6 & afma6); + friend VISP_EXPORT std::ostream & operator << (std::ostream & os, const vpAfma6 & afma6); - vpColVector getJointMin(); - vpColVector getJointMax(); - double getCoupl56(); - double getLong56(); + vpColVector getJointMin() const; + vpColVector getJointMax() const; + double getCoupl56() const; + double getLong56() const; protected: //! Set the current tool type diff --git a/src/robot/real-robot/afma6/vpRobotAfma6.cpp b/src/robot/real-robot/afma6/vpRobotAfma6.cpp index 40479e3594b9f8beaaf793aff44771d18a04f173..ba60fa50602bf192216e9329ad849c04a2da0691 100644 --- a/src/robot/real-robot/afma6/vpRobotAfma6.cpp +++ b/src/robot/real-robot/afma6/vpRobotAfma6.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRobotAfma6.cpp 4107 2013-02-06 10:04:49Z fspindle $ + * $Id: vpRobotAfma6.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -649,7 +649,7 @@ vpRobotAfma6::getPowerState(void) */ void -vpRobotAfma6::get_cVe(vpVelocityTwistMatrix &cVe) +vpRobotAfma6::get_cVe(vpVelocityTwistMatrix &cVe) const { vpHomogeneousMatrix cMe ; vpAfma6::get_cMe(cMe) ; @@ -668,7 +668,7 @@ vpRobotAfma6::get_cVe(vpVelocityTwistMatrix &cVe) */ void -vpRobotAfma6::get_cMe(vpHomogeneousMatrix &cMe) +vpRobotAfma6::get_cMe(vpHomogeneousMatrix &cMe) const { vpAfma6::get_cMe(cMe) ; } diff --git a/src/robot/real-robot/afma6/vpRobotAfma6.h b/src/robot/real-robot/afma6/vpRobotAfma6.h index 6713b36c1d7e80d37854e55b06690b182f8425f5..f7b48b0dd7a147b7d31e0a6f834b66e6c7ab68e4 100644 --- a/src/robot/real-robot/afma6/vpRobotAfma6.h +++ b/src/robot/real-robot/afma6/vpRobotAfma6.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRobotAfma6.h 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpRobotAfma6.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -294,10 +294,10 @@ public: /* Methode publiques */ vpColVector getVelocity (const vpRobot::vpControlFrameType frame); vpColVector getVelocity (const vpRobot::vpControlFrameType frame, double ×tamp); - void get_cMe(vpHomogeneousMatrix &_cMe) ; - void get_cVe(vpVelocityTwistMatrix &_cVe) ; - void get_eJe(vpMatrix &_eJe) ; - void get_fJe(vpMatrix &_fJe) ; + void get_cMe(vpHomogeneousMatrix &_cMe) const; + void get_cVe(vpVelocityTwistMatrix &_cVe) const; + void get_eJe(vpMatrix &_eJe); + void get_fJe(vpMatrix &_fJe); void init (void); void init (vpAfma6::vpAfma6ToolType tool, diff --git a/src/robot/real-robot/biclops/vpBiclops.cpp b/src/robot/real-robot/biclops/vpBiclops.cpp index b30fdbf97b44992442c6bf6a3bffcc498c9c243b..92a2baec474241fe7b2e6981374786fa8bc502a5 100644 --- a/src/robot/real-robot/biclops/vpBiclops.cpp +++ b/src/robot/real-robot/biclops/vpBiclops.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpBiclops.cpp 4321 2013-07-17 19:26:03Z fspindle $ + * $Id: vpBiclops.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -77,7 +77,7 @@ const float vpBiclops::speedLimit = (float)(M_PI/3.0); /*!< Maximum speed (in ra \sa get_fMc(const vpColVector &, vpHomogeneousMatrix &) */ void -vpBiclops::computeMGD (const vpColVector & q, vpHomogeneousMatrix & fMc) +vpBiclops::computeMGD (const vpColVector & q, vpHomogeneousMatrix & fMc) const { vpHomogeneousMatrix fMe = get_fMe(q); fMc = fMe * cMe_.inverse(); @@ -98,7 +98,7 @@ vpBiclops::computeMGD (const vpColVector & q, vpHomogeneousMatrix & fMc) */ void -vpBiclops::get_fMc (const vpColVector &q, vpHomogeneousMatrix &fMc) +vpBiclops::get_fMc (const vpColVector &q, vpHomogeneousMatrix &fMc) const { vpHomogeneousMatrix fMe = get_fMe(q); fMc = fMe * cMe_.inverse(); @@ -123,7 +123,7 @@ vpBiclops::get_fMc (const vpColVector &q, vpHomogeneousMatrix &fMc) \sa get_fMc(const vpColVector &) */ vpHomogeneousMatrix -vpBiclops::computeMGD (const vpColVector & q) +vpBiclops::computeMGD (const vpColVector & q) const { vpHomogeneousMatrix fMc; @@ -143,7 +143,7 @@ vpBiclops::computeMGD (const vpColVector & q) */ vpHomogeneousMatrix -vpBiclops::get_fMc (const vpColVector & q) +vpBiclops::get_fMc (const vpColVector & q) const { vpHomogeneousMatrix fMc; @@ -163,7 +163,7 @@ vpBiclops::get_fMc (const vpColVector & q) */ vpHomogeneousMatrix -vpBiclops::get_fMe (const vpColVector & q) +vpBiclops::get_fMe (const vpColVector & q) const { vpHomogeneousMatrix fMe; @@ -243,7 +243,7 @@ vpBiclops::get_fMe (const vpColVector & q) */ void -vpBiclops::computeMGD (const vpColVector &q, vpPoseVector &fvc) +vpBiclops::computeMGD (const vpColVector &q, vpPoseVector &fvc) const { vpHomogeneousMatrix fMc; @@ -264,7 +264,7 @@ vpBiclops::computeMGD (const vpColVector &q, vpPoseVector &fvc) */ void -vpBiclops::get_fMc (const vpColVector &q, vpPoseVector &fvc) +vpBiclops::get_fMc (const vpColVector &q, vpPoseVector &fvc) const { vpHomogeneousMatrix fMc; @@ -285,6 +285,7 @@ vpBiclops::get_fMc (const vpColVector &q, vpPoseVector &fvc) */ vpBiclops::vpBiclops (void) + : dh_model_(DH1), cMe_() { init(); } @@ -300,6 +301,7 @@ vpBiclops::vpBiclops (void) void vpBiclops::init () { + dh_model_ = DH1; set_cMe(); return ; } @@ -309,10 +311,8 @@ vpBiclops::init () /* --- DISPLAY ----------------------------------------------------------- */ /* ----------------------------------------------------------------------- */ -std::ostream & operator << (std::ostream & os, - const vpBiclops & /*constant*/) +VISP_EXPORT std::ostream & operator << (std::ostream & os, const vpBiclops & /*constant*/) { - os << "Geometric parameters: " << std::endl << "h: " @@ -333,7 +333,7 @@ std::ostream & operator << (std::ostream & os, */ void -vpBiclops::get_cVe(vpVelocityTwistMatrix &cVe) +vpBiclops::get_cVe(vpVelocityTwistMatrix &cVe) const { cVe.buildFrom(cMe_) ; } @@ -386,10 +386,8 @@ vpBiclops::set_cMe() */ void -vpBiclops::get_eJe(const vpColVector &q, vpMatrix &eJe) +vpBiclops::get_eJe(const vpColVector &q, vpMatrix &eJe) const { - - eJe.resize(6,2) ; if (q.getRows() != 2) { @@ -428,9 +426,8 @@ vpBiclops::get_eJe(const vpColVector &q, vpMatrix &eJe) */ void -vpBiclops::get_fJe(const vpColVector &q, vpMatrix &fJe) +vpBiclops::get_fJe(const vpColVector &q, vpMatrix &fJe) const { - if (q.getRows() != 2) { vpERROR_TRACE("Bad dimension for biclops articular vector"); throw(vpException(vpException::dimensionError, "Bad dimension for biclops articular vector")); @@ -456,4 +453,3 @@ vpBiclops::get_fJe(const vpColVector &q, vpMatrix &fJe) fJe[5][0] = 1; } } - diff --git a/src/robot/real-robot/biclops/vpBiclops.h b/src/robot/real-robot/biclops/vpBiclops.h index 2c6ee8d78ea1426acdb02a41a585467fd21cfc7e..2461b4d0583c24d98598a025bd909b31f8ac4dc2 100644 --- a/src/robot/real-robot/biclops/vpBiclops.h +++ b/src/robot/real-robot/biclops/vpBiclops.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpBiclops.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpBiclops.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -140,12 +140,14 @@ protected: public: vpBiclops (void); - void init (void); + /*! Destructor that does nothing. */ + virtual ~vpBiclops() {}; - void computeMGD (const vpColVector &q, vpHomogeneousMatrix & fMc); + void init (void); - vpHomogeneousMatrix computeMGD (const vpColVector & q); - void computeMGD (const vpColVector &q, vpPoseVector &fvc); + void computeMGD (const vpColVector &q, vpHomogeneousMatrix & fMc) const; + vpHomogeneousMatrix computeMGD (const vpColVector & q) const; + void computeMGD (const vpColVector &q, vpPoseVector &fvc) const; /*! Return the tranformation \f${^c}{\bf M}_e\f$ between the camera frame and the end @@ -156,20 +158,20 @@ public: return cMe_; } - void get_cVe(vpVelocityTwistMatrix &_cVe) ; - void get_fMc (const vpColVector &q, vpHomogeneousMatrix &fMc); - void get_fMc (const vpColVector &q, vpPoseVector &fvc); - vpHomogeneousMatrix get_fMc (const vpColVector &q); - vpHomogeneousMatrix get_fMe (const vpColVector &q); + void get_cVe(vpVelocityTwistMatrix &_cVe) const; + void get_fMc (const vpColVector &q, vpHomogeneousMatrix &fMc) const; + void get_fMc (const vpColVector &q, vpPoseVector &fvc) const; + vpHomogeneousMatrix get_fMc (const vpColVector &q) const; + vpHomogeneousMatrix get_fMe (const vpColVector &q) const; - void get_eJe(const vpColVector &q, vpMatrix &eJe); - void get_fJe(const vpColVector &q, vpMatrix &fJe); + void get_eJe(const vpColVector &q, vpMatrix &eJe) const; + void get_fJe(const vpColVector &q, vpMatrix &fJe) const; /*! Return the Denavit Hartenberg representation used to model the head. \sa vpBiclops::DenavitHartenbergModel */ - inline vpBiclops::DenavitHartenbergModel getDenavitHartenbergModel() + inline vpBiclops::DenavitHartenbergModel getDenavitHartenbergModel() const { return dh_model_; } @@ -192,8 +194,7 @@ public: dh_model_ = m; } - friend std::ostream & operator << (std::ostream & os, - const vpBiclops & constant); + friend VISP_EXPORT std::ostream & operator << (std::ostream & os, const vpBiclops & constant); }; diff --git a/src/robot/real-robot/biclops/vpRobotBiclops.cpp b/src/robot/real-robot/biclops/vpRobotBiclops.cpp index 5c58fe0593c71870f3383f82ca064ab66ea2f869..f1ef8fb5d46aac741c94dfac1a0f5c244df76bfa 100644 --- a/src/robot/real-robot/biclops/vpRobotBiclops.cpp +++ b/src/robot/real-robot/biclops/vpRobotBiclops.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRobotBiclops.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRobotBiclops.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -127,6 +127,8 @@ vpRobotBiclops::vpRobotBiclops () pthread_mutex_init (&vpShm_mutex, NULL); pthread_mutex_init (&vpEndThread_mutex, NULL); pthread_mutex_init (&vpMeasure_mutex, NULL); + + positioningVelocity = defaultPositioningVelocity ; } /*! @@ -175,8 +177,9 @@ vpRobotBiclops::vpRobotBiclops (const char * filename) // Initialize the mutex dedicated to she shm protection pthread_mutex_init (&vpShm_mutex, NULL); pthread_mutex_init (&vpEndThread_mutex, NULL); - pthread_mutex_init (&vpMeasure_mutex -, NULL); + pthread_mutex_init (&vpMeasure_mutex, NULL); + + positioningVelocity = defaultPositioningVelocity ; init(); @@ -275,8 +278,6 @@ vpRobotBiclops::init () vpRobotBiclops::robotAlreadyCreated = true; - positioningVelocity = defaultPositioningVelocity ; - // Initialize previous articular position to manage getDisplacement() q_previous.resize(vpBiclops::ndof); q_previous = 0; @@ -670,7 +671,7 @@ vpRobotBiclops::stopMotion(void) */ void -vpRobotBiclops::get_cVe(vpVelocityTwistMatrix &cVe) +vpRobotBiclops::get_cVe(vpVelocityTwistMatrix &cVe) const { vpHomogeneousMatrix cMe ; cMe = vpBiclops::get_cMe() ; @@ -688,7 +689,7 @@ vpRobotBiclops::get_cVe(vpVelocityTwistMatrix &cVe) */ void -vpRobotBiclops::get_cMe(vpHomogeneousMatrix &cMe) +vpRobotBiclops::get_cMe(vpHomogeneousMatrix &cMe) const { cMe = vpBiclops::get_cMe() ; } @@ -1279,16 +1280,19 @@ vpRobotBiclops::readPositionFile(const char *filename, vpColVector &q) // skip lines begining with # for comments if (fgets (line, 100, pt_f) != NULL) { if ( strncmp (line, "#", 1) != 0) { - // this line is not a comment - if ( fscanf (pt_f, "%s", line) != EOF) { - if ( strcmp (line, head) == 0) - end = true; // robot position was found - } - else - return (false); // end of file without position + // this line is not a comment + if ( fscanf (pt_f, "%s", line) != EOF) { + if ( strcmp (line, head) == 0) + end = true; // robot position was found + } + else { + fclose(pt_f); + return (false); // end of file without position + } } } else { + fclose(pt_f); return (false);// end of file } @@ -1298,6 +1302,7 @@ vpRobotBiclops::readPositionFile(const char *filename, vpColVector &q) double q1,q2; // Read positions if (fscanf(pt_f, "%lf %lf", &q1, &q2) == EOF) { + fclose(pt_f); std::cout << "Cannot read joint positions." << std::endl; return false; } diff --git a/src/robot/real-robot/biclops/vpRobotBiclops.h b/src/robot/real-robot/biclops/vpRobotBiclops.h index c402d226dce4a77d97f546c691775566addbfcf4..cc749a4900a112617cb6aeccabaa71f545030af0 100644 --- a/src/robot/real-robot/biclops/vpRobotBiclops.h +++ b/src/robot/real-robot/biclops/vpRobotBiclops.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRobotBiclops.h 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpRobotBiclops.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -136,8 +136,8 @@ public: void init (void); - void get_cMe(vpHomogeneousMatrix &_cMe) ; - void get_cVe(vpVelocityTwistMatrix &_cVe) ; + void get_cMe(vpHomogeneousMatrix &_cMe) const; + void get_cVe(vpVelocityTwistMatrix &_cVe) const; void get_eJe(vpMatrix &_eJe) ; void get_fJe(vpMatrix &_fJe) ; diff --git a/src/robot/real-robot/biclops/vpRobotBiclopsController.cpp b/src/robot/real-robot/biclops/vpRobotBiclopsController.cpp index 57ac29ca9870fe5be8931b6241459adef55caaca..1be2483f3261223aa7ec352b96ad744e94030fb1 100644 --- a/src/robot/real-robot/biclops/vpRobotBiclopsController.cpp +++ b/src/robot/real-robot/biclops/vpRobotBiclopsController.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRobotBiclopsController.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRobotBiclopsController.cpp 4604 2014-01-21 14:15:23Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -41,7 +41,7 @@ #include <signal.h> #include <string.h> -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX # include <unistd.h> #endif #include <visp/vpConfig.h> @@ -89,6 +89,7 @@ vpRobotBiclopsController::vpRobotBiclopsController() shm.q_dot[i] = 0.; shm.actual_q[i] = 0.; shm.jointLimit[i] = false; + shm.status[i] = STOP; } } diff --git a/src/robot/real-robot/biclops/vpRobotBiclopsController.h b/src/robot/real-robot/biclops/vpRobotBiclopsController.h index f8236e6b8880e6abeb12f8204dddc3532cea411f..b615ccf804b69fa55d94de99b3ec5930da6c4f59 100644 --- a/src/robot/real-robot/biclops/vpRobotBiclopsController.h +++ b/src/robot/real-robot/biclops/vpRobotBiclopsController.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRobotBiclopsController.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRobotBiclopsController.h 4604 2014-01-21 14:15:23Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -61,7 +61,7 @@ #include "Biclops.h" // Contrib for Biclops robot #include "PMDUtils.h" // Contrib for Biclops robot -#ifdef WIN32 +#if defined(_WIN32) class VISP_EXPORT Biclops; //needed for dll creation #endif diff --git a/src/robot/real-robot/cycab/vpRobotCycab.cpp b/src/robot/real-robot/cycab/vpRobotCycab.cpp deleted file mode 100644 index 4d2b0ab36bf840ef4c70e6ba730fab0bf20a417e..0000000000000000000000000000000000000000 --- a/src/robot/real-robot/cycab/vpRobotCycab.cpp +++ /dev/null @@ -1,295 +0,0 @@ -/**************************************************************************** - * - * $Id: vpRobotCycab.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: - * Interface for the car-like Cycab mobile robot. - * - * Authors: - * Fabien Spindler - * - *****************************************************************************/ - -#include <visp/vpConfig.h> -#include <visp/vpRobotCycab.h> - -#ifdef VISP_HAVE_CYCAB - -/*! - Initialize the client to be able to communicate with the Cycab server. - - By default, the steering mode is set such as only the front steering - angle is controlled. - - To change this behavior, use setDualSteering(true) function. -*/ -vpRobotCycab::vpRobotCycab() -{ -#ifdef VISP_HAVE_CYCABTK_OLD - // Old low level controller based on Syndex (obsolete) - end = false; - cycab = NULL; - sprintf(servername, "cycab-hf1"); - cycab = new EtherCycab(servername, <R); - if (!cycab->doInitialization(&end, 50, 0, false)) { - printf("ERROR: Can't connect to %s\n", servername); - exit(-1); - } - cycab->releaseSecurity(); - printf("Control limits : phi in [%f:%f], V in [%f:%f]\n", - cycab->minAllowedSteering(), - cycab->maxAllowedSteering(), - cycab->minAllowedSpeed(), - cycab->maxAllowedSpeed()); -#elif defined VISP_HAVE_CYCABTK - // New low level controller based on Syndex (to use) - std::string name = "cycab"; - CycabCarCommand cycab_command; - setDualSteering(false); - store.connect(); - cycab_commandId = store.lookupVariable( name + cycabCarCommandSuffix ); - cycab_stateId = store.lookupVariable( name + cycabStateSuffix ); - store.writeVariable( cycab_commandId, cycab_command ); -#endif -} - -/*! - Close the connection with the Cycab server. -*/ -vpRobotCycab::~vpRobotCycab() -{ -#ifdef VISP_HAVE_CYCABTK_OLD - if (cycab != NULL) delete cycab; - cycab = NULL; -#endif -} - -/*! - Set the steering mode. - - \param dual : If false, only the front steering angle is - conntrolled. If true, front and read steering angles are controlled. - -*/ -void vpRobotCycab::setDualSteering(bool dual) -{ - dualSteering = dual; -} - -/*! - Send the command to the cycab server. - - \param v : Velocity in m/s. - \param phi : Front steering angle in rad. - */ -void vpRobotCycab::setCommand(double v, double phi) -{ -#ifdef VISP_HAVE_CYCABTK_OLD - // Old low level controller based on Syndex (obsolete) - cycab->sendCommands(v, phi); -#elif defined VISP_HAVE_CYCABTK - // New low level controller based on Syndex (to use) - CycabCarCommand cycab_command; - store.readVariable( cycab_commandId, cycab_command ); - cycab_command.v = v; - cycab_command.phi = phi; - cycab_command.manualDriving = false; - cycab_command.dualSteering = dualSteering; - store.writeVariable( cycab_commandId, cycab_command ); -#endif -} - -/*! - Get measures from odometry. - - \param vmean : Measured mean velocity in m/s. This value is computed by considering - the mean velocity between rear-left and rear-right wheel velocities. - - \param phi : Measured front steering angle in rad. - -*/ -void vpRobotCycab::getOdometry(double &vmean, double &phi) -{ - double timestamp; - getOdometry(vmean, phi, timestamp); -} - -/*! - Get measures from odometry. - - \param v : Measured mean velocity in m/s. This value is computed by considering - the mean velocity between rear-left and rear-right wheel velocities. - - \param phi : Measured front steering angle in rad. - - \param timestamp : Time stamp in milli second associates to the measured - values of \e vmean and \e phi. -*/ -void vpRobotCycab::getOdometry(double &vmean, double &phi, double ×tamp) -{ - vmean = 0.; - phi=0.; - timestamp=0.; - -#ifdef VISP_HAVE_CYCABTK_OLD - // Old low level controller based on Syndex (obsolete) - Record rec; - double dsl,dsr,lphi,ltime; - cycab->waitUpdate(); - cycab->getState(&rec, &dsl, &dsr, &lphi, <ime); - // printf("Ktate %f : phi %f vl %f vr %f\n\t",ltime, - // lphi,rec.vmsec[REAR][LEFT],rec.vmsec[REAR][RIGHT]); - // calculate speed - vmean = (rec.vmsec[REAR][LEFT] + rec.vmsec[REAR][RIGHT])*0.5; - phi = lphi; - timestamp = ltime; -#elif defined VISP_HAVE_CYCABTK - // New low level controller based on Syndex (to use) - CycabState cycab_state; - store.readVariable(cycab_stateId, cycab_state); - vmean = (cycab_state.v_rear_left + cycab_state.v_rear_right)*0.5; - //printf("vl %f vr %f\n", cycab_state.v_rear_left, cycab_state.v_rear_right); - phi = cycab_state.phi_front; - timeval tp = store.getTimestamp(cycab_stateId); - timestamp = 1000.0*tp.tv_sec + tp.tv_usec/1000.0; -#endif -} -/*! - Get measures from odometry. - - \param vfl : Measured front-left wheel velocity in m/s. - \param vfr : Measured front-right wheel velocity in m/s. - \param vrl : Measured rear-left wheel velocity in m/s. - \param vrr : Measured rear-right wheel velocity in m/s. - - \param phi : Measured front steering angle in rad. - -*/ -void vpRobotCycab::getOdometry(double &vfl, double &vfr, - double &vrl, double &vrr, - double &phi) -{ - double timestamp; - getOdometry(vfl, vfr, vrl, vrr, phi, timestamp); -} - -/*! - Get measures from odometry. - - \param vfl : Measured front-left wheel velocity in m/s. - \param vfr : Measured front-right wheel velocity in m/s. - \param vrl : Measured rear-left wheel velocity in m/s. - \param vrr : Measured rear-right wheel velocity in m/s. - - \param phi : Measured front steering angle in rad. - - \param timestamp : Time stamp in milli second associates to the measured - values of \e vmean and \e phi. -*/ -void vpRobotCycab::getOdometry(double &vfl, double &vfr, - double &vrl, double &vrr, - double &phi, double ×tamp) -{ - vfr = vfr = vrl = vrr = 0.; - phi=0.; - timestamp=0.; - -#ifdef VISP_HAVE_CYCABTK_OLD - // Old low level controller based on Syndex (obsolete) - Record rec; - double dsl,dsr,lphi,ltime; - cycab->waitUpdate(); - cycab->getState(&rec, &dsl, &dsr, &lphi, <ime); - // printf("Ktate %f : phi %f vl %f vr %f\n\t",ltime, - // lphi,rec.vmsec[REAR][LEFT],rec.vmsec[REAR][RIGHT]); - // calculate speed - vfl = rec.vmsec[FRONT][LEFT]; - vfr = rec.vmsec[FRONT][RIGHT]; - vrl = rec.vmsec[REAR][LEFT]; - vrr = rec.vmsec[REAR][RIGHT]; - phi = lphi; - timestamp = ltime; -#elif defined VISP_HAVE_CYCABTK - // New low level controller based on Syndex (to use) - CycabState cycab_state; - store.readVariable(cycab_stateId, cycab_state); - vfl = cycab_state.v_front_left; - vfr = cycab_state.v_front_right; - vrl = cycab_state.v_rear_left; - vrr = cycab_state.v_rear_right; - - phi = cycab_state.phi_front; - timeval tp = store.getTimestamp(cycab_stateId); - timestamp = 1000.0*tp.tv_sec + tp.tv_usec/1000.0; -#endif -} - -/*! - Get the joystick positions. - - \param x : Joystick left/right position. - \param y : Joystick front/rear position. - */ -void vpRobotCycab::getJoystickPosition(double &x, double &y) -{ - double timestamp; - getJoystickPosition(x, y, timestamp); -} - -/*! - Get the joystick positions. - - \param x : Joystick left/right position. - \param y : Joystick front/rear position. - \param timestamp : Time stamp in milli second associates to the measured - values of \e x and \e y. - */ -void vpRobotCycab::getJoystickPosition(double &x, double &y, double ×tamp) -{ -#ifdef VISP_HAVE_CYCABTK_OLD - // Old low level controller based on Syndex (obsolete) - x = 0.; - y = 0.; - timestamp = 0.; -#elif defined VISP_HAVE_CYCABTK - // New low level controller based on Syndex (to use) - CycabState cycab_state; - store.readVariable(cycab_stateId, cycab_state); - x = cycab_state.joy_x; - y = cycab_state.joy_y; - timeval tp = store.getTimestamp(cycab_stateId); - timestamp = 1000.0*tp.tv_sec + tp.tv_usec/1000.0; -#endif -} - - -#endif diff --git a/src/robot/real-robot/cycab/vpRobotCycab.h b/src/robot/real-robot/cycab/vpRobotCycab.h deleted file mode 100644 index d83b32d4a29dceb302580c7cb01b16e2b5c6f2c3..0000000000000000000000000000000000000000 --- a/src/robot/real-robot/cycab/vpRobotCycab.h +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** - * - * $Id: vpRobotCycab.h 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: - * Interface for the car-like Cycab mobile robot. - * - * Authors: - * Fabien Spindler - * - *****************************************************************************/ -#ifndef vpRobotCycab_h -#define vpRobotCycab_h - -/*! - - \file vpRobotCycab.h - - Interface for the car-like Cycab mobile robot. - -*/ - -/*! - - \class vpRobotCycab - - \ingroup Cycab RobotDriver - - \brief Interface for the car-like Cycab mobile robot. - -*/ - -#include <visp/vpConfig.h> - -#ifdef VISP_HAVE_CYCAB - -#ifdef VISP_HAVE_CYCABTK_OLD -// Old low level controller based on Syndex (obsolete) -# include <EtherCycab/EtherCycab.hpp> -#elif defined VISP_HAVE_CYCABTK -// New low level controller based on Syndex (to use) -# include <hugr.hpp> -# include <CycabStructs.hpp> - -using namespace hugr; - -#endif //VISP_HAVE_CYCABTK_OLD - -class VISP_EXPORT vpRobotCycab -{ - public: - vpRobotCycab(); - virtual ~vpRobotCycab(); - - void setDualSteering(bool dual); - void setCommand(double v, double phi); - void getOdometry(double &vmean, double &phi); - void getOdometry(double &vmean, double &phi, double ×tamp); - void getOdometry(double &vfl, double &vfr, double &vrl, double &vrr, - double &phi); - void getOdometry(double &vfl, double &vfr, double &vrl, double &vrr, - double &phi, double ×tamp); - void getJoystickPosition(double &x, double &y); - void getJoystickPosition(double &x, double &y, double ×tamp); - - private: - bool dualSteering; -#ifdef VISP_HAVE_CYCABTK_OLD - // Old low level controller based on Syndex (obsolete) - bool end; - LockedTimeReq LTR; - char servername[1024]; - EtherCycab *cycab; -#elif defined VISP_HAVE_CYCABTK - // New low level controller based on Syndex (to use) - Store store; - VariableId cycab_stateId, cycab_commandId; -#endif -}; - -#endif -#endif diff --git a/src/robot/real-robot/pioneer/vpPioneer.h b/src/robot/real-robot/pioneer/vpPioneer.h index da99e5086dd72bb735a8669b4edef9575ed33ab1..9dc27277328180f3afe22dcc9e6ec615698cb40f 100644 --- a/src/robot/real-robot/pioneer/vpPioneer.h +++ b/src/robot/real-robot/pioneer/vpPioneer.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpPioneer.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpPioneer.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/robot/real-robot/pioneer/vpPioneerPan.h b/src/robot/real-robot/pioneer/vpPioneerPan.h index 969c9afbfdb84adb9aa0af5f759e2d6f6df6e230..5d1f6d986677bee43e60b26bc2ab2920e9dc4fae 100644 --- a/src/robot/real-robot/pioneer/vpPioneerPan.h +++ b/src/robot/real-robot/pioneer/vpPioneerPan.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpPioneerPan.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpPioneerPan.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -102,7 +102,7 @@ public: /*! Create a pioneer mobile robot equiped with a pan head. */ - vpPioneerPan() : vpUnicycle() + vpPioneerPan() : mMp_(), pMe_() { double q = 0; // Initial position of the pan axis set_mMp(); diff --git a/src/robot/real-robot/pioneer/vpRobotPioneer.cpp b/src/robot/real-robot/pioneer/vpRobotPioneer.cpp index 4d3888e0ab7eaa3712247156cf2d14e531229eae..bd72577e67a19cab2670b729ea202b28de4953ae 100644 --- a/src/robot/real-robot/pioneer/vpRobotPioneer.cpp +++ b/src/robot/real-robot/pioneer/vpRobotPioneer.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRobotPioneer.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRobotPioneer.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/robot/real-robot/pioneer/vpRobotPioneer.h b/src/robot/real-robot/pioneer/vpRobotPioneer.h index 77190e2017adc1999a4ed1456099e71161b47efd..a18e1982795ca6695bfe8397543398d000aade91 100644 --- a/src/robot/real-robot/pioneer/vpRobotPioneer.h +++ b/src/robot/real-robot/pioneer/vpRobotPioneer.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRobotPioneer.h 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpRobotPioneer.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/robot/real-robot/pioneer/vpUnicycle.h b/src/robot/real-robot/pioneer/vpUnicycle.h index fb3012c5612a2aeff52fa99dffece3df79fab5cb..eb4328da9e7404a270150a7ac5e708a535fc009b 100644 --- a/src/robot/real-robot/pioneer/vpUnicycle.h +++ b/src/robot/real-robot/pioneer/vpUnicycle.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpUnicycle.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpUnicycle.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -63,7 +63,7 @@ public: /*! Default constructor that does nothing. */ - vpUnicycle() + vpUnicycle() : cMe_(), eJe_() { }; /*! diff --git a/src/robot/real-robot/ptu46/vpPtu46.cpp b/src/robot/real-robot/ptu46/vpPtu46.cpp index 3b2fb96bf4f2e97ad6d411b562f37bf8cc92a735..2fea9f60eb6cb32e6448bb2f33192c0c06846184 100644 --- a/src/robot/real-robot/ptu46/vpPtu46.cpp +++ b/src/robot/real-robot/ptu46/vpPtu46.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpPtu46.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpPtu46.cpp 4620 2014-01-27 21:28:32Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -55,10 +55,6 @@ #include <math.h> #include <visp/vpMath.h> - - - - /* ------------------------------------------------------------------------ */ /* --- COMPUTE ------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */ @@ -80,7 +76,7 @@ const float vpPtu46::h = 0.068f; /*<! Vertical offset from last joint to */ void -vpPtu46::computeMGD (const vpColVector & q, vpHomogeneousMatrix & fMc) +vpPtu46::computeMGD (const vpColVector & q, vpHomogeneousMatrix & fMc) const { if (q.getRows() != 2) { vpERROR_TRACE("Bad dimension for ptu-46 articular vector"); @@ -131,7 +127,7 @@ vpPtu46::computeMGD (const vpColVector & q, vpHomogeneousMatrix & fMc) */ vpHomogeneousMatrix -vpPtu46::computeMGD (const vpColVector & q) +vpPtu46::computeMGD (const vpColVector & q) const { vpHomogeneousMatrix fMc; @@ -150,7 +146,7 @@ vpPtu46::computeMGD (const vpColVector & q) */ void -vpPtu46::computeMGD (const vpColVector & q, vpPoseVector & r) +vpPtu46::computeMGD (const vpColVector & q, vpPoseVector & r) const { vpHomogeneousMatrix fMc; @@ -195,10 +191,8 @@ vpPtu46::init () /* --- DISPLAY ----------------------------------------------------------- */ /* ----------------------------------------------------------------------- */ -std::ostream & operator << (std::ostream & os, - const vpPtu46 & /* constant */) +VISP_EXPORT std::ostream & operator << (std::ostream & os, const vpPtu46 & /* constant */) { - os << "Geometric parameters: " << std::endl << "L: " @@ -221,7 +215,7 @@ std::ostream & operator << (std::ostream & os, */ void -vpPtu46::get_cVe(vpVelocityTwistMatrix &cVe) +vpPtu46::get_cVe(vpVelocityTwistMatrix &cVe) const { vpHomogeneousMatrix cMe ; get_cMe(cMe) ; @@ -239,7 +233,7 @@ vpPtu46::get_cVe(vpVelocityTwistMatrix &cVe) */ void -vpPtu46::get_cMe(vpHomogeneousMatrix &cMe) +vpPtu46::get_cMe(vpHomogeneousMatrix &cMe) const { vpHomogeneousMatrix eMc ; @@ -279,7 +273,7 @@ vpPtu46::get_cMe(vpHomogeneousMatrix &cMe) */ void -vpPtu46::get_eJe(const vpColVector &q, vpMatrix &eJe) +vpPtu46::get_eJe(const vpColVector &q, vpMatrix &eJe) const { @@ -298,7 +292,6 @@ vpPtu46::get_eJe(const vpColVector &q, vpMatrix &eJe) eJe[3][0] = c2; eJe[4][1] = 1; eJe[5][0] = s2; - } /*! @@ -311,7 +304,7 @@ vpPtu46::get_eJe(const vpColVector &q, vpMatrix &eJe) */ void -vpPtu46::get_fJe(const vpColVector &q, vpMatrix &fJe) +vpPtu46::get_fJe(const vpColVector &q, vpMatrix &fJe) const { if (q.getRows() != 2) { @@ -330,12 +323,3 @@ vpPtu46::get_fJe(const vpColVector &q, vpMatrix &fJe) fJe[4][1] = -c1; fJe[5][0] = 1; } - - - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ - diff --git a/src/robot/real-robot/ptu46/vpPtu46.h b/src/robot/real-robot/ptu46/vpPtu46.h index 076a506b7848ebf39599baa1121c2808561ada40..554fe89f840e55b79e2125eed06aeaf70428aba6 100644 --- a/src/robot/real-robot/ptu46/vpPtu46.h +++ b/src/robot/real-robot/ptu46/vpPtu46.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpPtu46.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpPtu46.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -93,20 +93,21 @@ public: /* Constants */ public: /* Methodes publiques */ vpPtu46 (void); - void init (void); + /*! Destructor that does nothing. */ + virtual ~vpPtu46() {}; - void computeMGD (const vpColVector &q, vpHomogeneousMatrix & fMc); + void init (void); - vpHomogeneousMatrix computeMGD (const vpColVector & q); - void computeMGD (const vpColVector & q, vpPoseVector & r); + void computeMGD (const vpColVector &q, vpHomogeneousMatrix & fMc) const; + vpHomogeneousMatrix computeMGD (const vpColVector & q) const; + void computeMGD (const vpColVector & q, vpPoseVector & r) const; - void get_cMe(vpHomogeneousMatrix &_cMe) ; - void get_cVe(vpVelocityTwistMatrix &_cVe) ; - void get_eJe(const vpColVector &q, vpMatrix &eJe); - void get_fJe(const vpColVector &q, vpMatrix &fJe); + void get_cMe(vpHomogeneousMatrix &_cMe) const; + void get_cVe(vpVelocityTwistMatrix &_cVe) const; + void get_eJe(const vpColVector &q, vpMatrix &eJe) const; + void get_fJe(const vpColVector &q, vpMatrix &fJe) const; - friend VISP_EXPORT std::ostream & operator << (std::ostream & os, - const vpPtu46 & constant); + friend VISP_EXPORT std::ostream & operator << (std::ostream & os, const vpPtu46 & constant); }; diff --git a/src/robot/real-robot/ptu46/vpRobotPtu46.cpp b/src/robot/real-robot/ptu46/vpRobotPtu46.cpp index 2f8d2fd2a8545c2556a0f282ce125a0c36d647df..0edcb335cb8afc2284451ab2aef26673f03aa328 100644 --- a/src/robot/real-robot/ptu46/vpRobotPtu46.cpp +++ b/src/robot/real-robot/ptu46/vpRobotPtu46.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRobotPtu46.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRobotPtu46.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -235,7 +235,7 @@ vpRobotPtu46::stopMotion(void) */ void -vpRobotPtu46::get_cVe(vpVelocityTwistMatrix &cVe) +vpRobotPtu46::get_cVe(vpVelocityTwistMatrix &cVe) const { vpHomogeneousMatrix cMe ; vpPtu46::get_cMe(cMe) ; @@ -253,7 +253,7 @@ vpRobotPtu46::get_cVe(vpVelocityTwistMatrix &cVe) */ void -vpRobotPtu46::get_cMe(vpHomogeneousMatrix &cMe) +vpRobotPtu46::get_cMe(vpHomogeneousMatrix &cMe) const { vpPtu46::get_cMe(cMe) ; } diff --git a/src/robot/real-robot/ptu46/vpRobotPtu46.h b/src/robot/real-robot/ptu46/vpRobotPtu46.h index 4f7ccbfbdc86180a1509011f9cba706f78a4bb19..a5702d0e1fab3dc7882ad79337312d3c76253d73 100644 --- a/src/robot/real-robot/ptu46/vpRobotPtu46.h +++ b/src/robot/real-robot/ptu46/vpRobotPtu46.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRobotPtu46.h 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpRobotPtu46.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -112,8 +112,8 @@ public: vpRobotPtu46 (vpRobotPtu46 * pub); virtual ~vpRobotPtu46 (void); - void get_cMe(vpHomogeneousMatrix &_cMe) ; - void get_cVe(vpVelocityTwistMatrix &_cVe) ; + void get_cMe(vpHomogeneousMatrix &_cMe) const; + void get_cVe(vpVelocityTwistMatrix &_cVe) const; void get_eJe(vpMatrix &_eJe); void get_fJe(vpMatrix &_fJe); diff --git a/src/robot/real-robot/viper/vpRobotViper650.cpp b/src/robot/real-robot/viper/vpRobotViper650.cpp index 461f80e550544582b03b318596dc4e923500b3d1..f5795447f99a4c36db69040b47e11ebe85b919eb 100644 --- a/src/robot/real-robot/viper/vpRobotViper650.cpp +++ b/src/robot/real-robot/viper/vpRobotViper650.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRobotViper650.cpp 4218 2013-04-17 09:55:47Z fspindle $ + * $Id: vpRobotViper650.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -679,7 +679,7 @@ void \sa powerOn(), powerOff() */ bool - vpRobotViper650::getPowerState(void) + vpRobotViper650::getPowerState(void) const { InitTry; bool status = false; @@ -712,7 +712,7 @@ bool */ void - vpRobotViper650::get_cVe(vpVelocityTwistMatrix &cVe) + vpRobotViper650::get_cVe(vpVelocityTwistMatrix &cVe) const { vpHomogeneousMatrix cMe ; vpViper650::get_cMe(cMe) ; @@ -732,7 +732,7 @@ void */ void - vpRobotViper650::get_cMe(vpHomogeneousMatrix &cMe) + vpRobotViper650::get_cMe(vpHomogeneousMatrix &cMe) const { vpViper650::get_cMe(cMe) ; } @@ -861,7 +861,7 @@ void \sa setPositioningVelocity() */ double - vpRobotViper650::getPositioningVelocity (void) + vpRobotViper650::getPositioningVelocity (void) const { return positioningVelocity; } @@ -1992,7 +1992,7 @@ bool return false; fprintf(fd, "\ -#Viper - Position - Version 1.0\n\ +#Viper650 - Position - Version 1.00\n\ #\n\ # R: A B C D E F\n\ # Joint position in degrees\n\ @@ -2167,7 +2167,7 @@ void */ void - vpRobotViper650::biasForceTorqueSensor() + vpRobotViper650::biasForceTorqueSensor() const { InitTry; @@ -2224,7 +2224,7 @@ int main() */ void - vpRobotViper650::getForceTorque(vpColVector &H) + vpRobotViper650::getForceTorque(vpColVector &H) const { InitTry; @@ -2245,7 +2245,7 @@ void \sa disbleJoint6Limits() */ -void vpRobotViper650::enableJoint6Limits() +void vpRobotViper650::enableJoint6Limits() const { InitTry; Try( PrimitiveREMOVE_JOINT6_LIMITS_Viper650(0) ); @@ -2267,7 +2267,7 @@ void vpRobotViper650::enableJoint6Limits() \sa enableJoint6Limits() */ -void vpRobotViper650::disableJoint6Limits() +void vpRobotViper650::disableJoint6Limits() const { InitTry; Try( PrimitiveREMOVE_JOINT6_LIMITS_Viper650(1) ); diff --git a/src/robot/real-robot/viper/vpRobotViper650.h b/src/robot/real-robot/viper/vpRobotViper650.h index 3b363bbed951b66890cf471b4bebc5c2aac57cf8..c28f8b5fb845127045f947a06762b3391d67b81e 100644 --- a/src/robot/real-robot/viper/vpRobotViper650.h +++ b/src/robot/real-robot/viper/vpRobotViper650.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRobotViper650.h 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpRobotViper650.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -336,22 +336,22 @@ public: /* Methode publiques */ virtual ~vpRobotViper650 (void); // Force/Torque control - void biasForceTorqueSensor(); + void biasForceTorqueSensor() const; - void disableJoint6Limits(); - void enableJoint6Limits(); + void disableJoint6Limits() const; + void enableJoint6Limits() const; /*! \return The control mode indicating if the robot is in automatic, manual (usage of the dead man switch) or emergnecy stop mode. */ - vpControlModeType getControlMode() { + vpControlModeType getControlMode() const { return controlMode; } void getDisplacement(vpRobot::vpControlFrameType frame, vpColVector &displacement); - void getForceTorque(vpColVector &H); + void getForceTorque(vpColVector &H) const; void getPosition (const vpRobot::vpControlFrameType frame, vpColVector &position); @@ -364,8 +364,8 @@ public: /* Methode publiques */ vpPoseVector &position, double ×tamp); - double getPositioningVelocity (void); - bool getPowerState(); + double getPositioningVelocity (void) const; + bool getPowerState() const; double getTime () const; void getVelocity (const vpRobot::vpControlFrameType frame, @@ -376,23 +376,23 @@ public: /* Methode publiques */ vpColVector getVelocity (const vpRobot::vpControlFrameType frame); vpColVector getVelocity (const vpRobot::vpControlFrameType frame, double ×tamp); - void get_cMe(vpHomogeneousMatrix &cMe) ; - void get_cVe(vpVelocityTwistMatrix &cVe) ; - void get_eJe(vpMatrix &eJe) ; - void get_fJe(vpMatrix &fJe) ; + void get_cMe(vpHomogeneousMatrix &cMe) const; + void get_cVe(vpVelocityTwistMatrix &cVe) const; + void get_eJe(vpMatrix &eJe); + void get_fJe(vpMatrix &fJe); void init (void); void init (vpViper650::vpToolType tool, vpCameraParameters::vpCameraParametersProjType projModel = vpCameraParameters::perspectiveProjWithoutDistortion); - void move(const char *filename) ; + void move(const char *filename); - void powerOn() ; - void powerOff() ; + void powerOn(); + void powerOff(); - static bool readPosFile(const char *filename, vpColVector &q) ; - static bool savePosFile(const char *filename, const vpColVector &q) ; + static bool readPosFile(const char *filename, vpColVector &q); + static bool savePosFile(const char *filename, const vpColVector &q); // Position control void setPosition(const vpRobot::vpControlFrameType frame, @@ -409,7 +409,7 @@ public: /* Methode publiques */ void setVelocity (const vpRobot::vpControlFrameType frame, const vpColVector & velocity); - void stopMotion() ; + void stopMotion(); private: void getArticularDisplacement(vpColVector &displacement); diff --git a/src/robot/real-robot/viper/vpRobotViper850.cpp b/src/robot/real-robot/viper/vpRobotViper850.cpp index d422612dc43c9eb9f63419ae072ad8b0f13b8333..f68efb584ba1a48a38f718efe63609d36de74a07 100644 --- a/src/robot/real-robot/viper/vpRobotViper850.cpp +++ b/src/robot/real-robot/viper/vpRobotViper850.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRobotViper850.cpp 4218 2013-04-17 09:55:47Z fspindle $ + * $Id: vpRobotViper850.cpp 4594 2014-01-20 15:08:07Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -218,6 +218,8 @@ vpRobotViper850::vpRobotViper850 (bool verbose) } positioningVelocity = defaultPositioningVelocity ; + maxRotationVelocity_joint6 = maxRotationVelocity; + vpRobotViper850::robotAlreadyCreated = true; return ; @@ -680,7 +682,7 @@ void \sa powerOn(), powerOff() */ bool - vpRobotViper850::getPowerState(void) + vpRobotViper850::getPowerState(void) const { InitTry; bool status = false; @@ -713,7 +715,7 @@ bool */ void - vpRobotViper850::get_cVe(vpVelocityTwistMatrix &cVe) + vpRobotViper850::get_cVe(vpVelocityTwistMatrix &cVe) const { vpHomogeneousMatrix cMe ; vpViper850::get_cMe(cMe) ; @@ -733,7 +735,7 @@ void */ void - vpRobotViper850::get_cMe(vpHomogeneousMatrix &cMe) + vpRobotViper850::get_cMe(vpHomogeneousMatrix &cMe) const { vpViper850::get_cMe(cMe) ; } @@ -862,7 +864,7 @@ void \sa setPositioningVelocity() */ double - vpRobotViper850::getPositioningVelocity (void) + vpRobotViper850::getPositioningVelocity (void) const { return positioningVelocity; } @@ -1537,8 +1539,15 @@ void vpRobotViper850::setVelocity(const vpRobot::vpControlFrameType frame, case vpRobot::ARTICULAR_FRAME : { vpColVector vel_max(6); - for (unsigned int i=0; i<6; i++) - vel_max[i] = getMaxRotationVelocity(); + if (getMaxRotationVelocity() == getMaxRotationVelocityJoint6()) { + for (unsigned int i=0; i<6; i++) + vel_max[i] = getMaxRotationVelocity(); + } + else { + for (unsigned int i=0; i<5; i++) + vel_max[i] = getMaxRotationVelocity(); + vel_max[5] = getMaxRotationVelocityJoint6(); + } vel_sat = vpRobot::saturateVelocities(vel, vel_max, true); } @@ -2006,7 +2015,7 @@ bool return false; fprintf(fd, "\ -#Viper - Position - Version 1.0\n\ +#Viper850 - Position - Version 1.00\n\ #\n\ # R: A B C D E F\n\ # Joint position in degrees\n\ @@ -2181,7 +2190,7 @@ void */ void - vpRobotViper850::biasForceTorqueSensor() + vpRobotViper850::biasForceTorqueSensor() const { InitTry; @@ -2238,7 +2247,7 @@ int main() */ void - vpRobotViper850::getForceTorque(vpColVector &H) + vpRobotViper850::getForceTorque(vpColVector &H) const { InitTry; @@ -2280,7 +2289,7 @@ void \sa openGripper() */ -void vpRobotViper850::closeGripper() +void vpRobotViper850::closeGripper() const { InitTry; Try( PrimitiveGripper_Viper850(0) ); @@ -2298,7 +2307,7 @@ void vpRobotViper850::closeGripper() \sa disbleJoint6Limits() */ -void vpRobotViper850::enableJoint6Limits() +void vpRobotViper850::enableJoint6Limits() const { InitTry; Try( PrimitiveREMOVE_JOINT6_LIMITS_Viper850(0) ); @@ -2320,7 +2329,7 @@ void vpRobotViper850::enableJoint6Limits() \sa enableJoint6Limits() */ -void vpRobotViper850::disableJoint6Limits() +void vpRobotViper850::disableJoint6Limits() const { InitTry; Try( PrimitiveREMOVE_JOINT6_LIMITS_Viper850(1) ); @@ -2333,5 +2342,59 @@ void vpRobotViper850::disableJoint6Limits() } } +/*! + + Set the maximal rotation velocity that can be sent to the robot during a velocity control. + + \param w_max : Maximum rotation velocity expressed in rad/s. +*/ + +void +vpRobotViper850::setMaxRotationVelocity (double w_max) +{ + vpRobot::setMaxRotationVelocity(w_max); + setMaxRotationVelocityJoint6(w_max); + + return; +} + +/*! + + Set the maximal rotation velocity on joint 6 that is used only during velocity joint control. + + This function affects only the velocities that are sent as joint velocities. + + \code + vpRobotViper850 robot; + robot.setMaxRotationVelocity( vpMath::rad(20) ); + robot.setMaxRotationVelocityJoint6( vpMath::rad(50) ); + + robot.setRobotState(vpRobot::STATE_VELOCITY_CONTROL); + robot.setVelocity(ARTICULAR_FRAME, v); + \endcode + + + \param w6_max : Maximum rotation velocity expressed in rad/s on joint 6. +*/ + +void +vpRobotViper850::setMaxRotationVelocityJoint6 (const double w6_max) +{ + maxRotationVelocity_joint6 = w6_max; + return; +} + +/*! + + Get the maximal rotation velocity on joint 6 that is used only during velocity joint control. + + \return Maximum rotation velocity on joint 6 expressed in rad/s. +*/ +double +vpRobotViper850::getMaxRotationVelocityJoint6() const +{ + return maxRotationVelocity_joint6; +} + #endif diff --git a/src/robot/real-robot/viper/vpRobotViper850.h b/src/robot/real-robot/viper/vpRobotViper850.h index 161f778cca932679bc5e713911cb22da8dc4c06a..5d5d7d006fedcd9a31d15fdd8bc5e5e5b261051d 100644 --- a/src/robot/real-robot/viper/vpRobotViper850.h +++ b/src/robot/real-robot/viper/vpRobotViper850.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRobotViper850.h 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpRobotViper850.h 4594 2014-01-20 15:08:07Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -336,12 +336,12 @@ public: /* Methode publiques */ virtual ~vpRobotViper850 (void); // Force/Torque control - void biasForceTorqueSensor(); + void biasForceTorqueSensor() const; - void closeGripper(); + void closeGripper() const; - void disableJoint6Limits(); - void enableJoint6Limits(); + void disableJoint6Limits() const; + void enableJoint6Limits() const; void getDisplacement(vpRobot::vpControlFrameType frame, vpColVector &displacement); @@ -349,12 +349,13 @@ public: /* Methode publiques */ \return The control mode indicating if the robot is in automatic, manual (usage of the dead man switch) or emergnecy stop mode. */ - vpControlModeType getControlMode() { + vpControlModeType getControlMode() const { return controlMode; } - void getForceTorque(vpColVector &H); + void getForceTorque(vpColVector &H) const; + double getMaxRotationVelocityJoint6() const; void getPosition (const vpRobot::vpControlFrameType frame, vpColVector &position); void getPosition (const vpRobot::vpControlFrameType frame, @@ -364,8 +365,8 @@ public: /* Methode publiques */ void getPosition (const vpRobot::vpControlFrameType frame, vpPoseVector &position, double ×tamp); - double getPositioningVelocity (void); - bool getPowerState(); + double getPositioningVelocity (void) const; + bool getPowerState() const; void getVelocity (const vpRobot::vpControlFrameType frame, vpColVector & velocity); @@ -377,10 +378,10 @@ public: /* Methode publiques */ double getTime() const; - void get_cMe(vpHomogeneousMatrix &cMe) ; - void get_cVe(vpVelocityTwistMatrix &cVe) ; - void get_eJe(vpMatrix &eJe) ; - void get_fJe(vpMatrix &fJe) ; + void get_cMe(vpHomogeneousMatrix &cMe) const; + void get_cVe(vpVelocityTwistMatrix &cVe) const; + void get_eJe(vpMatrix &eJe); + void get_fJe(vpMatrix &fJe); void init (void); void init (vpViper850::vpToolType tool, @@ -397,6 +398,9 @@ public: /* Methode publiques */ static bool readPosFile(const char *filename, vpColVector &q) ; static bool savePosFile(const char *filename, const vpColVector &q) ; + void setMaxRotationVelocity(double w_max); + void setMaxRotationVelocityJoint6(double w6_max); + // Position control void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &position) ; @@ -418,6 +422,8 @@ public: /* Methode publiques */ private: void getArticularDisplacement(vpColVector &displacement); void getCameraDisplacement(vpColVector &displacement); + + double maxRotationVelocity_joint6; }; diff --git a/src/robot/real-robot/viper/vpViper.cpp b/src/robot/real-robot/viper/vpViper.cpp index b3bbae7d7f261f6ef57654be0bc667d1f6ca758a..250410c89fefbfccf30aefab94862f30689c9617 100644 --- a/src/robot/real-robot/viper/vpViper.cpp +++ b/src/robot/real-robot/viper/vpViper.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpViper.cpp 4206 2013-04-13 07:29:06Z fspindle $ + * $Id: vpViper.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -68,6 +68,7 @@ const unsigned int vpViper::njoint = 6; */ vpViper::vpViper() + : eMc(), etc(), erc(), a1(0), d1(0), a2(), a3(), d4(0), d6(0), c56(0), joint_max(), joint_min() { // Default values are initialized @@ -125,7 +126,7 @@ vpViper::vpViper() */ vpHomogeneousMatrix -vpViper::getForwardKinematics(const vpColVector & q) +vpViper::getForwardKinematics(const vpColVector & q) const { vpHomogeneousMatrix fMc; fMc = get_fMc(q); @@ -148,7 +149,7 @@ vpViper::getForwardKinematics(const vpColVector & q) \return true if the joint position is in the joint limits. false otherwise. */ bool -vpViper::convertJointPositionInLimits(unsigned int joint, const double &q, double &q_mod, const bool &verbose) +vpViper::convertJointPositionInLimits(unsigned int joint, const double &q, double &q_mod, const bool &verbose) const { double eps = 0.01; if (q >= joint_min[joint]-eps && q <= joint_max[joint]+eps ) { @@ -228,7 +229,7 @@ vpViper::convertJointPositionInLimits(unsigned int joint, const double &q, doubl */ unsigned int -vpViper::getInverseKinematicsWrist(const vpHomogeneousMatrix & fMw, vpColVector & q, const bool &verbose) +vpViper::getInverseKinematicsWrist(const vpHomogeneousMatrix & fMw, vpColVector & q, const bool &verbose) const { vpColVector q_sol[8]; @@ -573,14 +574,14 @@ vpViper::getInverseKinematicsWrist(const vpHomogeneousMatrix & fMw, vpColVector */ unsigned int -vpViper::getInverseKinematics(const vpHomogeneousMatrix & fMc, vpColVector & q, const bool &verbose) +vpViper::getInverseKinematics(const vpHomogeneousMatrix & fMc, vpColVector & q, const bool &verbose) const { vpHomogeneousMatrix fMw; vpHomogeneousMatrix wMe; - vpHomogeneousMatrix eMc; + vpHomogeneousMatrix eMc_; this->get_wMe(wMe); - this->get_eMc(eMc); - fMw = fMc * eMc.inverse() * wMe.inverse(); + this->get_eMc(eMc_); + fMw = fMc * eMc_.inverse() * wMe.inverse(); return (getInverseKinematicsWrist(fMw, q, verbose)); } @@ -611,7 +612,7 @@ vpViper::getInverseKinematics(const vpHomogeneousMatrix & fMc, vpColVector & q, */ vpHomogeneousMatrix -vpViper::get_fMc (const vpColVector & q) +vpViper::get_fMc (const vpColVector & q) const { vpHomogeneousMatrix fMc; get_fMc(q, fMc); @@ -641,7 +642,7 @@ vpViper::get_fMc (const vpColVector & q) \sa get_fMe(), get_eMc() */ void -vpViper::get_fMc(const vpColVector & q, vpHomogeneousMatrix & fMc) +vpViper::get_fMc(const vpColVector & q, vpHomogeneousMatrix & fMc) const { // Compute the direct geometric model: fMe = transformation between @@ -728,7 +729,7 @@ int main() */ void -vpViper::get_fMe(const vpColVector & q, vpHomogeneousMatrix & fMe) +vpViper::get_fMe(const vpColVector & q, vpHomogeneousMatrix & fMe) const { double q1 = q[0]; double q2 = q[1]; @@ -824,7 +825,7 @@ vpViper::get_fMe(const vpColVector & q, vpHomogeneousMatrix & fMe) */ void -vpViper::get_fMw(const vpColVector & q, vpHomogeneousMatrix & fMw) +vpViper::get_fMw(const vpColVector & q, vpHomogeneousMatrix & fMw) const { double q1 = q[0]; double q2 = q[1]; @@ -857,7 +858,6 @@ vpViper::get_fMw(const vpColVector & q, vpHomogeneousMatrix & fMw) double c23 = cos(q2+q3); double s23 = sin(q2+q3); - fMw[0][0] = c1*(c23*(c4*c5*c6-s4*s6)-s23*s5*c6)-s1*(s4*c5*c6+c4*s6); fMw[1][0] = -s1*(c23*(-c4*c5*c6+s4*s6)+s23*s5*c6)+c1*(s4*c5*c6+c4*s6); fMw[2][0] = s23*(s4*s6-c4*c5*c6)-c23*s5*c6; @@ -890,7 +890,7 @@ vpViper::get_fMw(const vpColVector & q, vpHomogeneousMatrix & fMw) */ void -vpViper::get_wMe(vpHomogeneousMatrix & wMe) +vpViper::get_wMe(vpHomogeneousMatrix & wMe) const { // Set the rotation as identity wMe.setIdentity(); @@ -905,15 +905,15 @@ vpViper::get_wMe(vpHomogeneousMatrix & wMe) the camera frame. This transformation is constant and correspond to the extrinsic camera parameters estimated by calibration. - \param eMc : Transformation between the the + \param eMc_ : Transformation between the the end-effector frame and the camera frame. \sa get_cMe() */ void -vpViper::get_eMc(vpHomogeneousMatrix &eMc) +vpViper::get_eMc(vpHomogeneousMatrix &eMc_) const { - eMc = this->eMc; + eMc_ = this->eMc; } /*! @@ -928,7 +928,7 @@ vpViper::get_eMc(vpHomogeneousMatrix &eMc) \sa get_eMc() */ void -vpViper::get_cMe(vpHomogeneousMatrix &cMe) +vpViper::get_cMe(vpHomogeneousMatrix &cMe) const { cMe = this->eMc.inverse(); } @@ -949,7 +949,7 @@ vpViper::get_cMe(vpHomogeneousMatrix &cMe) */ void -vpViper::get_cVe(vpVelocityTwistMatrix &cVe) +vpViper::get_cVe(vpVelocityTwistMatrix &cVe) const { vpHomogeneousMatrix cMe ; get_cMe(cMe) ; @@ -982,7 +982,7 @@ vpViper::get_cVe(vpVelocityTwistMatrix &cVe) \sa get_fJw() */ void -vpViper::get_eJe(const vpColVector &q, vpMatrix &eJe) +vpViper::get_eJe(const vpColVector &q, vpMatrix &eJe) const { vpMatrix V(6,6); V = 0; @@ -1068,7 +1068,7 @@ vpViper::get_eJe(const vpColVector &q, vpMatrix &eJe) */ void -vpViper::get_fJw(const vpColVector &q, vpMatrix &fJw) +vpViper::get_fJw(const vpColVector &q, vpMatrix &fJw) const { double q1 = q[0]; double q2 = q[1]; @@ -1174,7 +1174,7 @@ vpViper::get_fJw(const vpColVector &q, vpMatrix &fJw) \sa get_fJw */ void -vpViper::get_fJe(const vpColVector &q, vpMatrix &fJe) +vpViper::get_fJe(const vpColVector &q, vpMatrix &fJe) const { vpMatrix V(6,6); V = 0; @@ -1216,7 +1216,7 @@ vpViper::get_fJe(const vpColVector &q, vpMatrix &fJe) */ vpColVector -vpViper::getJointMin() +vpViper::getJointMin() const { return joint_min; } @@ -1229,7 +1229,7 @@ vpViper::getJointMin() */ vpColVector -vpViper::getJointMax() +vpViper::getJointMax() const { return joint_max; } @@ -1245,13 +1245,11 @@ vpViper::getJointMax() */ double -vpViper::getCoupl56() +vpViper::getCoupl56() const { return c56; } - - /*! Print on the output stream \e os the robot parameters (joint @@ -1261,7 +1259,7 @@ vpViper::getCoupl56() \param os : Output stream. \param viper : Robot parameters. */ -std::ostream & operator << (std::ostream & os, const vpViper & viper) +VISP_EXPORT std::ostream & operator << (std::ostream & os, const vpViper & viper) { vpRotationMatrix eRc; viper.eMc.extract(eRc); @@ -1302,8 +1300,3 @@ std::ostream & operator << (std::ostream & os, const vpViper & viper) return os; } -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ diff --git a/src/robot/real-robot/viper/vpViper.h b/src/robot/real-robot/viper/vpViper.h index a2b0a0f6956f9c406cc389aa160f4eabc691e06a..e67984c63f60b7f2c3017ed355cdd88a1cfb3a7a 100644 --- a/src/robot/real-robot/viper/vpViper.h +++ b/src/robot/real-robot/viper/vpViper.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpViper.h 4191 2013-04-01 07:46:05Z fspindle $ + * $Id: vpViper.h 4620 2014-01-27 21:28:32Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -114,31 +114,30 @@ class VISP_EXPORT vpViper vpViper(); virtual ~vpViper() {}; - vpHomogeneousMatrix getForwardKinematics(const vpColVector & q); - unsigned int getInverseKinematicsWrist(const vpHomogeneousMatrix & fMw, vpColVector & q, const bool &verbose=false); - unsigned int getInverseKinematics(const vpHomogeneousMatrix & fMc, vpColVector & q, const bool &verbose=false); - vpHomogeneousMatrix get_fMc (const vpColVector & q); - void get_fMw(const vpColVector & q, vpHomogeneousMatrix & fMw); - void get_wMe(vpHomogeneousMatrix & wMe); - void get_eMc(vpHomogeneousMatrix & eMc); - void get_fMe(const vpColVector & q, vpHomogeneousMatrix & fMe); - void get_fMc(const vpColVector & q, vpHomogeneousMatrix & fMc); - - void get_cMe(vpHomogeneousMatrix &cMe) ; - void get_cVe(vpVelocityTwistMatrix &cVe) ; - void get_fJw(const vpColVector &q, vpMatrix &fJw) ; - void get_fJe(const vpColVector &q, vpMatrix &fJe) ; - void get_eJe(const vpColVector &q, vpMatrix &eJe) ; - - friend VISP_EXPORT std::ostream & operator << (std::ostream & os, - const vpViper & viper); - - vpColVector getJointMin(); - vpColVector getJointMax(); - double getCoupl56(); + vpHomogeneousMatrix getForwardKinematics(const vpColVector & q) const; + unsigned int getInverseKinematicsWrist(const vpHomogeneousMatrix & fMw, vpColVector & q, const bool &verbose=false) const; + unsigned int getInverseKinematics(const vpHomogeneousMatrix & fMc, vpColVector & q, const bool &verbose=false) const; + vpHomogeneousMatrix get_fMc (const vpColVector & q) const; + void get_fMw(const vpColVector & q, vpHomogeneousMatrix & fMw) const; + void get_wMe(vpHomogeneousMatrix & wMe) const; + void get_eMc(vpHomogeneousMatrix & eMc) const; + void get_fMe(const vpColVector & q, vpHomogeneousMatrix & fMe) const; + void get_fMc(const vpColVector & q, vpHomogeneousMatrix & fMc) const; + + void get_cMe(vpHomogeneousMatrix &cMe) const; + void get_cVe(vpVelocityTwistMatrix &cVe) const; + void get_fJw(const vpColVector &q, vpMatrix &fJw) const; + void get_fJe(const vpColVector &q, vpMatrix &fJe) const; + void get_eJe(const vpColVector &q, vpMatrix &eJe) const; + + friend VISP_EXPORT std::ostream & operator << (std::ostream & os, const vpViper & viper); + + vpColVector getJointMin() const; + vpColVector getJointMax() const; + double getCoupl56() const; private: - bool convertJointPositionInLimits(unsigned int joint, const double &q, double &q_mod, const bool &verbose=false); + bool convertJointPositionInLimits(unsigned int joint, const double &q, double &q_mod, const bool &verbose=false) const; public: static const unsigned int njoint; ///< Number of joint. @@ -160,15 +159,7 @@ class VISP_EXPORT vpViper // Software joint limits in radians vpColVector joint_max; // Maximal value of the joints vpColVector joint_min; // Minimal value of the joints - - }; -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ - #endif diff --git a/src/robot/real-robot/viper/vpViper650.cpp b/src/robot/real-robot/viper/vpViper650.cpp index 0535055f70cab0bb7071c93822b0302b21739125..0e8c2df6ca48fcf0cf4b131d0acb428e6c038338 100644 --- a/src/robot/real-robot/viper/vpViper650.cpp +++ b/src/robot/real-robot/viper/vpViper650.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpViper650.cpp 4210 2013-04-16 08:57:46Z fspindle $ + * $Id: vpViper650.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -57,56 +57,56 @@ static const char *opt_viper650[] = {"CAMERA", "eMc_ROT_XYZ","eMc_TRANS_XYZ", NULL}; const char * const vpViper650::CONST_EMC_MARLIN_F033C_WITHOUT_DISTORTION_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Viper650/current/include/const_eMc_MarlinF033C_without_distortion_Viper650.cnf"; #else = "/udd/fspindle/robot/Viper650/current/include/const_eMc_MarlinF033C_without_distortion_Viper650.cnf"; #endif const char * const vpViper650::CONST_EMC_MARLIN_F033C_WITH_DISTORTION_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Viper650/current/include/const_eMc_MarlinF033C_with_distortion_Viper650.cnf"; #else = "/udd/fspindle/robot/Viper650/current/include/const_eMc_MarlinF033C_with_distortion_Viper650.cnf"; #endif const char * const vpViper650::CONST_EMC_PTGREY_FLEA2_WITHOUT_DISTORTION_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Viper650/current/include/const_eMc_PTGreyFlea2_without_distortion_Viper650.cnf"; #else = "/udd/fspindle/robot/Viper650/current/include/const_eMc_PTGreyFlea2_without_distortion_Viper650.cnf"; #endif const char * const vpViper650::CONST_EMC_PTGREY_FLEA2_WITH_DISTORTION_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Viper650/current/include/const_eMc_PTGreyFlea2_with_distortion_Viper650.cnf"; #else = "/udd/fspindle/robot/Viper650/current/include/const_eMc_PTGreyFlea2_with_distortion_Viper650.cnf"; #endif const char * const vpViper650::CONST_EMC_SCHUNK_GRIPPER_WITHOUT_DISTORTION_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Viper650/current/include/const_eMc_schunk_gripper_without_distortion_Viper650.cnf"; #else = "/udd/fspindle/robot/Viper650/current/include/const_eMc_schunk_gripper_without_distortion_Viper650.cnf"; #endif const char * const vpViper650::CONST_EMC_SCHUNK_GRIPPER_WITH_DISTORTION_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Viper650/current/include/const_eMc_schunk_gripper_with_distortion_Viper650.cnf"; #else = "/udd/fspindle/robot/Viper650/current/include/const_eMc_schunk_gripper_with_distortion_Viper650.cnf"; #endif const char * const vpViper650::CONST_EMC_GENERIC_WITHOUT_DISTORTION_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Viper650/current/include/const_eMc_generic_without_distortion_Viper650.cnf"; #else = "/udd/fspindle/robot/Viper650/current/include/const_eMc_generic_without_distortion_Viper650.cnf"; #endif const char * const vpViper650::CONST_EMC_GENERIC_WITH_DISTORTION_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Viper650/current/include/const_eMc_generic_with_distortion_Viper650.cnf"; #else = "/udd/fspindle/robot/Viper650/current/include/const_eMc_generic_with_distortion_Viper650.cnf"; @@ -114,7 +114,7 @@ const char * const vpViper650::CONST_EMC_GENERIC_WITH_DISTORTION_FILENAME const char * const vpViper650::CONST_CAMERA_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Viper650/current/include/const_camera_Viper650.xml"; #else = "/udd/fspindle/robot/Viper650/current/include/const_camera_Viper650.xml"; @@ -139,6 +139,7 @@ const vpViper650::vpToolType vpViper650::defaultTool = vpViper650::TOOL_PTGREY_F */ vpViper650::vpViper650() + : tool_current(vpViper650::defaultTool), projModel(vpCameraParameters::perspectiveProjWithoutDistortion) { // Denavit Hartenberg parameters a1 = 0.075; @@ -209,15 +210,15 @@ vpViper650::init (const char *camera_extrinsic_parameters) \param tool : Camera in use. - \param projModel : Projection model of the camera. + \param proj_model : Projection model of the camera. */ void vpViper650::init (vpViper650::vpToolType tool, - vpCameraParameters::vpCameraParametersProjType projModel) + vpCameraParameters::vpCameraParametersProjType proj_model) { - this->projModel = projModel; + this->projModel = proj_model; #ifdef VISP_HAVE_ACCESS_TO_NAS // Read the robot parameters from files @@ -226,19 +227,19 @@ vpViper650::init (vpViper650::vpToolType tool, case vpViper650::TOOL_MARLIN_F033C_CAMERA: { switch(projModel) { case vpCameraParameters::perspectiveProjWithoutDistortion : -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_MARLIN_F033C_WITHOUT_DISTORTION_FILENAME); -#else // WIN32 +#else // _WIN32 _snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_MARLIN_F033C_WITHOUT_DISTORTION_FILENAME); #endif break; case vpCameraParameters::perspectiveProjWithDistortion : -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_MARLIN_F033C_WITH_DISTORTION_FILENAME); -#else // WIN32 +#else // _WIN32 _snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_MARLIN_F033C_WITH_DISTORTION_FILENAME); #endif @@ -249,19 +250,19 @@ vpViper650::init (vpViper650::vpToolType tool, case vpViper650::TOOL_PTGREY_FLEA2_CAMERA: { switch(projModel) { case vpCameraParameters::perspectiveProjWithoutDistortion : -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_PTGREY_FLEA2_WITHOUT_DISTORTION_FILENAME); -#else // WIN32 +#else // _WIN32 _snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_PTGREY_FLEA2_WITHOUT_DISTORTION_FILENAME); #endif break; case vpCameraParameters::perspectiveProjWithDistortion : -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_PTGREY_FLEA2_WITH_DISTORTION_FILENAME); -#else // WIN32 +#else // _WIN32 _snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_PTGREY_FLEA2_WITH_DISTORTION_FILENAME); #endif @@ -272,19 +273,19 @@ vpViper650::init (vpViper650::vpToolType tool, case vpViper650::TOOL_SCHUNK_GRIPPER_CAMERA: { switch(projModel) { case vpCameraParameters::perspectiveProjWithoutDistortion : -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_SCHUNK_GRIPPER_WITHOUT_DISTORTION_FILENAME); -#else // WIN32 +#else // _WIN32 _snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_SCHUNK_GRIPPER_WITHOUT_DISTORTION_FILENAME); #endif break; case vpCameraParameters::perspectiveProjWithDistortion : -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_SCHUNK_GRIPPER_WITH_DISTORTION_FILENAME); -#else // WIN32 +#else // _WIN32 _snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_SCHUNK_GRIPPER_WITH_DISTORTION_FILENAME); #endif @@ -295,19 +296,19 @@ vpViper650::init (vpViper650::vpToolType tool, case vpViper650::TOOL_GENERIC_CAMERA: { switch(projModel) { case vpCameraParameters::perspectiveProjWithoutDistortion : -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_GENERIC_WITHOUT_DISTORTION_FILENAME); -#else // WIN32 +#else // _WIN32 _snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_GENERIC_WITHOUT_DISTORTION_FILENAME); #endif break; case vpCameraParameters::perspectiveProjWithDistortion : -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_GENERIC_WITH_DISTORTION_FILENAME); -#else // WIN32 +#else // _WIN32 _snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_GENERIC_WITH_DISTORTION_FILENAME); #endif @@ -354,6 +355,7 @@ vpViper650::init (vpViper650::vpToolType tool, etc[2] = 0.1022; // tz break; } + break; } case vpViper650::TOOL_PTGREY_FLEA2_CAMERA: case vpViper650::TOOL_SCHUNK_GRIPPER_CAMERA: { @@ -375,6 +377,7 @@ vpViper650::init (vpViper650::vpToolType tool, etc[2] = 0.078; // tz break; } + break; } case vpViper650::TOOL_GENERIC_CAMERA: { // Set eMc to identity @@ -389,6 +392,7 @@ vpViper650::init (vpViper650::vpToolType tool, etc[2] = 0; // tz break; } + break; } } vpRotationMatrix eRc(erc); @@ -574,7 +578,7 @@ int main() void vpViper650::getCameraParameters (vpCameraParameters &cam, const unsigned int &image_width, - const unsigned int &image_height) + const unsigned int &image_height) const { #if defined(VISP_HAVE_XML2) && defined (VISP_HAVE_ACCESS_TO_NAS) vpXmlParserCamera parser; @@ -796,7 +800,7 @@ int main() */ void vpViper650::getCameraParameters (vpCameraParameters &cam, - const vpImage<unsigned char> &I) + const vpImage<unsigned char> &I) const { getCameraParameters(cam,I.getWidth(),I.getHeight()); } @@ -866,15 +870,7 @@ int main() void vpViper650::getCameraParameters (vpCameraParameters &cam, - const vpImage<vpRGBa> &I) + const vpImage<vpRGBa> &I) const { getCameraParameters(cam,I.getWidth(),I.getHeight()); } - - - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ diff --git a/src/robot/real-robot/viper/vpViper650.h b/src/robot/real-robot/viper/vpViper650.h index 883a6634aedd11e3db82b45ed99419c944f76f55..b19a7aaa439736f5b0cd994f2a11926afbdc1732 100644 --- a/src/robot/real-robot/viper/vpViper650.h +++ b/src/robot/real-robot/viper/vpViper650.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpViper650.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpViper650.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -111,19 +111,19 @@ class VISP_EXPORT vpViper650: public vpViper //! Get the current camera model projection type - vpCameraParameters::vpCameraParametersProjType getCameraParametersProjType(){ + vpCameraParameters::vpCameraParametersProjType getCameraParametersProjType() const { return projModel; }; void getCameraParameters(vpCameraParameters &cam, const unsigned int &image_width, - const unsigned int &image_height); + const unsigned int &image_height) const; void getCameraParameters(vpCameraParameters &cam, - const vpImage<unsigned char> &I); - void getCameraParameters(vpCameraParameters &cam, const vpImage<vpRGBa> &I); + const vpImage<unsigned char> &I) const; + void getCameraParameters(vpCameraParameters &cam, const vpImage<vpRGBa> &I) const; //! Get the current tool type - vpToolType getToolType(){ + vpToolType getToolType() const{ return tool_current; }; diff --git a/src/robot/real-robot/viper/vpViper850.cpp b/src/robot/real-robot/viper/vpViper850.cpp index f465ee8f2243e5229b835da1328f49f5755cecf4..3a29dc4cac44825cd0f0fce58fc1ad6cfc1f6d2a 100644 --- a/src/robot/real-robot/viper/vpViper850.cpp +++ b/src/robot/real-robot/viper/vpViper850.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpViper850.cpp 4210 2013-04-16 08:57:46Z fspindle $ + * $Id: vpViper850.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -57,56 +57,56 @@ static const char *opt_viper850[] = {"CAMERA", "eMc_ROT_XYZ","eMc_TRANS_XYZ", NULL}; const char * const vpViper850::CONST_EMC_MARLIN_F033C_WITHOUT_DISTORTION_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Viper850/current/include/const_eMc_MarlinF033C_without_distortion_Viper850.cnf"; #else = "/udd/fspindle/robot/Viper850/current/include/const_eMc_MarlinF033C_without_distortion_Viper850.cnf"; #endif const char * const vpViper850::CONST_EMC_MARLIN_F033C_WITH_DISTORTION_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Viper850/current/include/const_eMc_MarlinF033C_with_distortion_Viper850.cnf"; #else = "/udd/fspindle/robot/Viper850/current/include/const_eMc_MarlinF033C_with_distortion_Viper850.cnf"; #endif const char * const vpViper850::CONST_EMC_PTGREY_FLEA2_WITHOUT_DISTORTION_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Viper850/current/include/const_eMc_PTGreyFlea2_without_distortion_Viper850.cnf"; #else = "/udd/fspindle/robot/Viper850/current/include/const_eMc_PTGreyFlea2_without_distortion_Viper850.cnf"; #endif const char * const vpViper850::CONST_EMC_PTGREY_FLEA2_WITH_DISTORTION_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Viper850/current/include/const_eMc_PTGreyFlea2_with_distortion_Viper850.cnf"; #else = "/udd/fspindle/robot/Viper850/current/include/const_eMc_PTGreyFlea2_with_distortion_Viper850.cnf"; #endif const char * const vpViper850::CONST_EMC_SCHUNK_GRIPPER_WITHOUT_DISTORTION_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Viper850/current/include/const_eMc_schunk_gripper_without_distortion_Viper850.cnf"; #else = "/udd/fspindle/robot/Viper850/current/include/const_eMc_schunk_gripper_without_distortion_Viper850.cnf"; #endif const char * const vpViper850::CONST_EMC_SCHUNK_GRIPPER_WITH_DISTORTION_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Viper850/current/include/const_eMc_schunk_gripper_with_distortion_Viper850.cnf"; #else = "/udd/fspindle/robot/Viper850/current/include/const_eMc_schunk_gripper_with_distortion_Viper850.cnf"; #endif const char * const vpViper850::CONST_EMC_GENERIC_WITHOUT_DISTORTION_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Viper850/current/include/const_eMc_generic_without_distortion_Viper850.cnf"; #else = "/udd/fspindle/robot/Viper850/current/include/const_eMc_generic_without_distortion_Viper850.cnf"; #endif const char * const vpViper850::CONST_EMC_GENERIC_WITH_DISTORTION_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Viper850/current/include/const_eMc_generic_with_distortion_Viper850.cnf"; #else = "/udd/fspindle/robot/Viper850/current/include/const_eMc_generic_with_distortion_Viper850.cnf"; @@ -114,7 +114,7 @@ const char * const vpViper850::CONST_EMC_GENERIC_WITH_DISTORTION_FILENAME const char * const vpViper850::CONST_CAMERA_FILENAME -#ifdef WIN32 +#if defined(_WIN32) = "Z:/robot/Viper850/current/include/const_camera_Viper850.xml"; #else = "/udd/fspindle/robot/Viper850/current/include/const_camera_Viper850.xml"; @@ -139,6 +139,8 @@ const vpViper850::vpToolType vpViper850::defaultTool = vpViper850::TOOL_PTGREY_F */ vpViper850::vpViper850() + : tool_current(vpViper850::defaultTool), projModel(vpCameraParameters::perspectiveProjWithoutDistortion) + { // Denavit Hartenberg parameters a1 = 0.075; @@ -209,15 +211,15 @@ vpViper850::init (const char *camera_extrinsic_parameters) \param tool : Camera in use. - \param projModel : Projection model of the camera. + \param proj_model : Projection model of the camera. */ void vpViper850::init (vpViper850::vpToolType tool, - vpCameraParameters::vpCameraParametersProjType projModel) + vpCameraParameters::vpCameraParametersProjType proj_model) { - this->projModel = projModel; + this->projModel = proj_model; #ifdef VISP_HAVE_ACCESS_TO_NAS // Read the robot parameters from files @@ -226,19 +228,19 @@ vpViper850::init (vpViper850::vpToolType tool, case vpViper850::TOOL_MARLIN_F033C_CAMERA: { switch(projModel) { case vpCameraParameters::perspectiveProjWithoutDistortion : -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_MARLIN_F033C_WITHOUT_DISTORTION_FILENAME); -#else // WIN32 +#else // _WIN32 _snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_MARLIN_F033C_WITHOUT_DISTORTION_FILENAME); #endif break; case vpCameraParameters::perspectiveProjWithDistortion : -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_MARLIN_F033C_WITH_DISTORTION_FILENAME); -#else // WIN32 +#else // _WIN32 _snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_MARLIN_F033C_WITH_DISTORTION_FILENAME); #endif @@ -249,19 +251,19 @@ vpViper850::init (vpViper850::vpToolType tool, case vpViper850::TOOL_PTGREY_FLEA2_CAMERA: { switch(projModel) { case vpCameraParameters::perspectiveProjWithoutDistortion : -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_PTGREY_FLEA2_WITHOUT_DISTORTION_FILENAME); -#else // WIN32 +#else // _WIN32 _snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_PTGREY_FLEA2_WITHOUT_DISTORTION_FILENAME); #endif break; case vpCameraParameters::perspectiveProjWithDistortion : -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_PTGREY_FLEA2_WITH_DISTORTION_FILENAME); -#else // WIN32 +#else // _WIN32 _snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_PTGREY_FLEA2_WITH_DISTORTION_FILENAME); #endif @@ -272,19 +274,19 @@ vpViper850::init (vpViper850::vpToolType tool, case vpViper850::TOOL_SCHUNK_GRIPPER_CAMERA: { switch(projModel) { case vpCameraParameters::perspectiveProjWithoutDistortion : -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_SCHUNK_GRIPPER_WITHOUT_DISTORTION_FILENAME); -#else // WIN32 +#else // _WIN32 _snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_SCHUNK_GRIPPER_WITHOUT_DISTORTION_FILENAME); #endif break; case vpCameraParameters::perspectiveProjWithDistortion : -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_SCHUNK_GRIPPER_WITH_DISTORTION_FILENAME); -#else // WIN32 +#else // _WIN32 _snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_SCHUNK_GRIPPER_WITH_DISTORTION_FILENAME); #endif @@ -295,19 +297,19 @@ vpViper850::init (vpViper850::vpToolType tool, case vpViper850::TOOL_GENERIC_CAMERA: { switch(projModel) { case vpCameraParameters::perspectiveProjWithoutDistortion : -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_GENERIC_WITHOUT_DISTORTION_FILENAME); -#else // WIN32 +#else // _WIN32 _snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_GENERIC_WITHOUT_DISTORTION_FILENAME); #endif break; case vpCameraParameters::perspectiveProjWithDistortion : -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_GENERIC_WITH_DISTORTION_FILENAME); -#else // WIN32 +#else // _WIN32 _snprintf(filename_eMc, FILENAME_MAX, "%s", CONST_EMC_GENERIC_WITH_DISTORTION_FILENAME); #endif @@ -354,6 +356,7 @@ vpViper850::init (vpViper850::vpToolType tool, etc[2] = 0.1022; // tz break; } + break; } case vpViper850::TOOL_PTGREY_FLEA2_CAMERA: case vpViper850::TOOL_SCHUNK_GRIPPER_CAMERA: { @@ -375,6 +378,7 @@ vpViper850::init (vpViper850::vpToolType tool, etc[2] = 0.078; // tz break; } + break; } case vpViper850::TOOL_GENERIC_CAMERA: { // Set eMc to identity @@ -389,6 +393,7 @@ vpViper850::init (vpViper850::vpToolType tool, etc[2] = 0; // tz break; } + break; } } vpRotationMatrix eRc(erc); @@ -574,7 +579,7 @@ int main() void vpViper850::getCameraParameters (vpCameraParameters &cam, const unsigned int &image_width, - const unsigned int &image_height) + const unsigned int &image_height) const { #if defined(VISP_HAVE_XML2) && defined (VISP_HAVE_ACCESS_TO_NAS) vpXmlParserCamera parser; @@ -796,7 +801,7 @@ int main() */ void vpViper850::getCameraParameters (vpCameraParameters &cam, - const vpImage<unsigned char> &I) + const vpImage<unsigned char> &I) const { getCameraParameters(cam,I.getWidth(),I.getHeight()); } @@ -866,15 +871,7 @@ int main() void vpViper850::getCameraParameters (vpCameraParameters &cam, - const vpImage<vpRGBa> &I) + const vpImage<vpRGBa> &I) const { getCameraParameters(cam,I.getWidth(),I.getHeight()); } - - - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ diff --git a/src/robot/real-robot/viper/vpViper850.h b/src/robot/real-robot/viper/vpViper850.h index a9d1a3437279555acb8a7ab1cacc42ac3cf627e0..8418cf0efa3239e1ec2a5e56e4ecf61b330f20e7 100644 --- a/src/robot/real-robot/viper/vpViper850.h +++ b/src/robot/real-robot/viper/vpViper850.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpViper850.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpViper850.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -111,19 +111,19 @@ class VISP_EXPORT vpViper850: public vpViper //! Get the current camera model projection type - vpCameraParameters::vpCameraParametersProjType getCameraParametersProjType(){ + vpCameraParameters::vpCameraParametersProjType getCameraParametersProjType() const{ return projModel; }; void getCameraParameters(vpCameraParameters &cam, const unsigned int &image_width, - const unsigned int &image_height); + const unsigned int &image_height) const; void getCameraParameters(vpCameraParameters &cam, - const vpImage<unsigned char> &I); - void getCameraParameters(vpCameraParameters &cam, const vpImage<vpRGBa> &I); + const vpImage<unsigned char> &I) const; + void getCameraParameters(vpCameraParameters &cam, const vpImage<vpRGBa> &I) const; //! Get the current tool type - vpToolType getToolType(){ + vpToolType getToolType() const { return tool_current; }; diff --git a/src/robot/robot/vpRobot.cpp b/src/robot/robot/vpRobot.cpp index 9b1945c9c85a0114268bc49ed72c562779c87545..1f331bcab55ecec85faae1386dc01c702dbe66da 100644 --- a/src/robot/robot/vpRobot.cpp +++ b/src/robot/robot/vpRobot.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRobot.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRobot.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -53,14 +53,50 @@ const double vpRobot::maxRotationVelocityDefault = 0.7; vpRobot::vpRobot (void) : + stateRobot(vpRobot::STATE_STOP), frameRobot(vpRobot::CAMERA_FRAME), maxTranslationVelocity (maxTranslationVelocityDefault), - maxRotationVelocity (maxRotationVelocityDefault) + maxRotationVelocity (maxRotationVelocityDefault), + nDof(0), + eJe(), eJeAvailable(false), fJe(), fJeAvailable(false), areJointLimitsAvailable(false), + qmin(NULL), qmax(NULL), verbose_(true) { - frameRobot = vpRobot::CAMERA_FRAME; - stateRobot = vpRobot::STATE_STOP ; - verbose_ = true; } +vpRobot::vpRobot (const vpRobot &robot) + : + stateRobot(vpRobot::STATE_STOP), frameRobot(vpRobot::CAMERA_FRAME), + maxTranslationVelocity (maxTranslationVelocityDefault), + maxRotationVelocity (maxRotationVelocityDefault), + nDof(0), + eJe(), eJeAvailable(false), fJe(), fJeAvailable(false), areJointLimitsAvailable(false), + qmin(NULL), qmax(NULL), verbose_(true) +{ + *this = robot; +} + +/*! Copy operator. */ +vpRobot & vpRobot::operator=(const vpRobot &robot) +{ + stateRobot = robot.stateRobot; + frameRobot = robot.frameRobot; + maxTranslationVelocity = robot.maxTranslationVelocity; + maxRotationVelocity = robot.maxRotationVelocity; + nDof = robot.nDof; + eJe = robot.eJe; + eJeAvailable = robot.eJeAvailable; + fJe= robot.fJe; + fJeAvailable = robot.fJeAvailable; + areJointLimitsAvailable = robot.areJointLimitsAvailable; + qmin = new double [nDof]; + qmax = new double [nDof]; + for (int i = 0; i< nDof; i++) { + qmin[i] = robot.qmin[i]; + qmax[i] = robot.qmax[i]; + } + verbose_ = robot.verbose_; + + return (*this); +} /*! Saturate velocities. diff --git a/src/robot/robot/vpRobot.h b/src/robot/robot/vpRobot.h index 70bbb1f14c196b2e452b3c9b28dcfebdf5687d37..7839599ff60cd2c18486317650f02a19269e1a68 100644 --- a/src/robot/robot/vpRobot.h +++ b/src/robot/robot/vpRobot.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRobot.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRobot.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -116,13 +116,14 @@ protected: public: vpRobot (void); + vpRobot (const vpRobot &robot); virtual ~vpRobot() { ; } //---------- Jacobian ----------------------------- //! Get the robot Jacobian expressed in the end-effector frame - virtual void get_eJe(vpMatrix &_eJe) = 0 ; + virtual void get_eJe(vpMatrix &_eJe) = 0 ; //! Get the robot Jacobian expressed in the robot reference (or world) frame. - virtual void get_fJe(vpMatrix &_fJe) = 0 ; + virtual void get_fJe(vpMatrix &_fJe) = 0 ; //! Get a displacement (frame as to ve specified) between two successive position control. virtual void getDisplacement(const vpRobot::vpControlFrameType frame, @@ -136,10 +137,12 @@ public: // Return the robot position (frame has to be specified). vpColVector getPosition (const vpRobot::vpControlFrameType frame); - virtual vpRobotStateType getRobotState (void) { return stateRobot ; } + virtual vpRobotStateType getRobotState (void) const { return stateRobot ; } virtual void init() = 0 ; + vpRobot & operator=(const vpRobot &robot); + static vpColVector saturateVelocities(const vpColVector &v_in, const vpColVector &v_max, bool verbose=false); void setMaxRotationVelocity (const double maxVr); @@ -156,7 +159,7 @@ public: protected: vpControlFrameType setRobotFrame (vpRobot::vpControlFrameType newFrame); - vpControlFrameType getRobotFrame (void) { return frameRobot ; } + vpControlFrameType getRobotFrame (void) const { return frameRobot ; } } ; #endif diff --git a/src/robot/robot/vpRobotException.h b/src/robot/robot/vpRobotException.h index 969f385194a7271f668c950270d0d7e6ce536d1b..7fb9a36c72a5d697a442ea41d771e73f162c762f 100644 --- a/src/robot/robot/vpRobotException.h +++ b/src/robot/robot/vpRobotException.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRobotException.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRobotException.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -70,85 +70,78 @@ */ class VISP_EXPORT vpRobotException : public vpException { -public: - /*! + public: + /*! \brief Lists the possible error than can be emmited while calling vpRobot member */ - enum errorRobotCodeEnum + enum errorRobotCodeEnum { - /** Erreur lancee par le constructor. */ - constructionError, - - /** Erreur lancee lors de la construction d'un objet CRobot - * correspondant a un robot reel si l'objet de la classe en - * question doit etre unique. */ - uniqueRobotError, - - /** Erreur lancee par les fonctions de commande si le - * robot n'est pas dans le bon etat au moment du passage - * d'ordre. */ - wrongStateError, - - /** Erreur lancee par les fonctions de changement d'etat - * si le changement demandee n'est pas possible. */ - stateModificationError, - - /** Erreur generee lors d'un retour non nulle d'une fonction - * de communication de la lib Afma6. */ - communicationError, - - /** Erreur lancee apres un appel a une fonction de la lib - * bas-niveau de control de l'afma6 ayant renvoye une erreur. */ - lowLevelError, - - /** Erreur lancee par la fonction de parsing des parametres du - * robot, si le fichier donne en entree n'est pas valide. - */ - readingParametersError, - - /** Erreur lancee par les methodes d'une classe qui necessite - * un appel a une fonction d'initialisation apres la - * construction si l'init n'a pas ete fait. */ - notInitializedError, - - /** Erreur lancee par les fonctions decrites dans lAPI mais - * pas completement implementee. Dans ce cas, la fonction - * affiche simplement un message d'erreur avant de sortir - * par le 'throw'. - */ - notImplementedError, - /** Position is out of range. - */ - positionOutOfRangeError + /** Erreur lancee par le constructor. */ + constructionError, + + /** Erreur lancee lors de la construction d'un objet CRobot + * correspondant a un robot reel si l'objet de la classe en + * question doit etre unique. */ + uniqueRobotError, + + /** Erreur lancee par les fonctions de commande si le + * robot n'est pas dans le bon etat au moment du passage + * d'ordre. */ + wrongStateError, + + /** Erreur lancee par les fonctions de changement d'etat + * si le changement demandee n'est pas possible. */ + stateModificationError, + + /** Erreur generee lors d'un retour non nulle d'une fonction + * de communication de la lib Afma6. */ + communicationError, + + /** Erreur lancee apres un appel a une fonction de la lib + * bas-niveau de control de l'afma6 ayant renvoye une erreur. */ + lowLevelError, + + /** Erreur lancee par la fonction de parsing des parametres du + * robot, si le fichier donne en entree n'est pas valide. + */ + readingParametersError, + + /** Erreur lancee par les methodes d'une classe qui necessite + * un appel a une fonction d'initialisation apres la + * construction si l'init n'a pas ete fait. */ + notInitializedError, + + /** Erreur lancee par les fonctions decrites dans lAPI mais + * pas completement implementee. Dans ce cas, la fonction + * affiche simplement un message d'erreur avant de sortir + * par le 'throw'. + */ + notImplementedError, + /** Position is out of range. + */ + positionOutOfRangeError } ; -public: - vpRobotException (const int code, const char * msg) - : vpException(code, msg) + public: + vpRobotException (const int id, const char* format, ...) { + this->code = id; + va_list args; + va_start(args, format); + setMessage(format, args); + va_end (args); } - vpRobotException (const int code, const std::string & msg) - : vpException(code, msg) + vpRobotException (const int id, const std::string & msg) + : vpException(id, msg) + { + } + vpRobotException (const int id) + : vpException(id) { } - vpRobotException (const int code) - : vpException(code) - { - } - -}; - - - - - -#endif /* #ifndef __vpRobotException_H */ +}; -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ +#endif diff --git a/src/robot/robot/vpRobotTemplate.cpp b/src/robot/robot/vpRobotTemplate.cpp index 3a77f0ee75beb0169d4e9081f0ca4e185cca10a7..441da2247258033f61b216d75b81edcd90cd64f4 100644 --- a/src/robot/robot/vpRobotTemplate.cpp +++ b/src/robot/robot/vpRobotTemplate.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRobotTemplate.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRobotTemplate.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/robot/robot/vpRobotTemplate.h b/src/robot/robot/vpRobotTemplate.h index aac9e9eaf11965a8b069ea0493b90cb38b7e123e..8d527b8ae4388a901c378c77d424511ecb55f826 100644 --- a/src/robot/robot/vpRobotTemplate.h +++ b/src/robot/robot/vpRobotTemplate.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRobotTemplate.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRobotTemplate.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/robot/simulator-robot/arms/CMakeRobotArmsList.cmake b/src/robot/simulator-robot/arms/CMakeRobotArmsList.cmake index d4a4ca203145b6846d67615744bddc719544aa8c..4cf0a103fcf2b89f0fcc63ae08a0e266ff62890a 100644 --- a/src/robot/simulator-robot/arms/CMakeRobotArmsList.cmake +++ b/src/robot/simulator-robot/arms/CMakeRobotArmsList.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeRobotArmsList.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeRobotArmsList.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/src/robot/simulator-robot/vpRobotCamera.cpp b/src/robot/simulator-robot/vpRobotCamera.cpp index a17d410cc38ca5e4ee3b2376a9c2ffecd3958c28..b9b206f93ed8fe38f3191999d1f3c0659d4482d9 100644 --- a/src/robot/simulator-robot/vpRobotCamera.cpp +++ b/src/robot/simulator-robot/vpRobotCamera.cpp @@ -3,7 +3,7 @@ * $Id: vpRobotCamera.cpp 2456 2010-01-07 10:33:12Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -72,6 +72,7 @@ */ vpRobotCamera::vpRobotCamera() + : cMw_() { init() ; } @@ -118,7 +119,7 @@ vpRobotCamera::~vpRobotCamera() */ void -vpRobotCamera::get_cVe(vpVelocityTwistMatrix &cVe) +vpRobotCamera::get_cVe(vpVelocityTwistMatrix &cVe) const { vpVelocityTwistMatrix cVe_; cVe = cVe_; @@ -128,13 +129,13 @@ vpRobotCamera::get_cVe(vpVelocityTwistMatrix &cVe) Get the robot jacobian expressed in the end-effector frame. For that simple robot the Jacobian is the identity. - \param eJe : A 6 by 6 matrix representing the robot jacobian \f$ {^e}{\bf + \param eJe_ : A 6 by 6 matrix representing the robot jacobian \f$ {^e}{\bf J}_e\f$ expressed in the end-effector frame. */ void -vpRobotCamera::get_eJe(vpMatrix &eJe) +vpRobotCamera::get_eJe(vpMatrix &eJe_) { - eJe = this->eJe ; + eJe_ = this->eJe ; } /*! diff --git a/src/robot/simulator-robot/vpRobotCamera.h b/src/robot/simulator-robot/vpRobotCamera.h index 34016109b7b90a3249e0b8ebd95083c1272a864f..4c34837cf37a33d0eff91b8a4405bc59f81e2934 100644 --- a/src/robot/simulator-robot/vpRobotCamera.h +++ b/src/robot/simulator-robot/vpRobotCamera.h @@ -3,7 +3,7 @@ * $Id: vpRobotCamera.h 2456 2010-01-07 10:33:12Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -116,8 +116,8 @@ public: vpRobotCamera() ; virtual ~vpRobotCamera() ; - void get_cVe(vpVelocityTwistMatrix &cVe); - void get_eJe(vpMatrix &eJe) ; + void get_cVe(vpVelocityTwistMatrix &cVe) const; + void get_eJe(vpMatrix &eJe); void getPosition(vpHomogeneousMatrix &cMw) const ; void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q); diff --git a/src/robot/simulator-robot/vpRobotSimulator.cpp b/src/robot/simulator-robot/vpRobotSimulator.cpp index 41c906959f5899276a1527bfc01fa3b675510d90..92cf1ec747b80cf6f6d51ec18a94d024bc89fc9d 100644 --- a/src/robot/simulator-robot/vpRobotSimulator.cpp +++ b/src/robot/simulator-robot/vpRobotSimulator.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRobotSimulator.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRobotSimulator.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -46,7 +46,6 @@ /*! Basic constructor that sets the sampling time by default to 40ms. */ -vpRobotSimulator::vpRobotSimulator() : vpRobot() +vpRobotSimulator::vpRobotSimulator() : vpRobot(), delta_t_(0.040f) { - setSamplingTime(0.040f); } diff --git a/src/robot/simulator-robot/vpRobotSimulator.h b/src/robot/simulator-robot/vpRobotSimulator.h index 9b9663e4663a8e41e570bb6c0a716262509d9ee2..7c193b90e36d06068557aae75fc04a6289cb098f 100644 --- a/src/robot/simulator-robot/vpRobotSimulator.h +++ b/src/robot/simulator-robot/vpRobotSimulator.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRobotSimulator.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRobotSimulator.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/robot/simulator-robot/vpRobotWireFrameSimulator.cpp b/src/robot/simulator-robot/vpRobotWireFrameSimulator.cpp index ebce5539e381561c7ba151c109ff2a212e19fd46..2749c10ada952ab86e9db214dc330dc67699f964 100644 --- a/src/robot/simulator-robot/vpRobotWireFrameSimulator.cpp +++ b/src/robot/simulator-robot/vpRobotWireFrameSimulator.cpp @@ -3,7 +3,7 @@ * $Id: vpRobotWireFrameSimulator.cpp 3530 2012-01-03 10:52:12Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -43,14 +43,24 @@ -#if defined(WIN32) || defined(VISP_HAVE_PTHREAD) +#if defined(_WIN32) || defined(VISP_HAVE_PTHREAD) #include <visp/vpRobotWireFrameSimulator.h> #include <visp/vpSimulatorViper850.h> /*! Basic constructor */ -vpRobotWireFrameSimulator::vpRobotWireFrameSimulator():vpWireFrameSimulator(), vpRobotSimulator() +vpRobotWireFrameSimulator::vpRobotWireFrameSimulator() + : vpWireFrameSimulator(), vpRobotSimulator(), + I(), tcur(0), tprev(0), robotArms(NULL), size_fMi(8), fMi(NULL), artCoord(), artVel(), velocity(), + /* thread(), attr(), */ mutex_fMi(), mutex_artVel(), mutex_artCoord(), mutex_velocity(), mutex_display(), + displayBusy(false), robotStop(false), jointLimit(false), jointLimitArt(false), singularityManagement(true), + cameraParam(), +#if defined(VISP_HAVE_DISPLAY) + display(), +#endif + displayType(MODEL_3D), displayAllowed(true), constantSamplingTimeMode(false), + setVelocityCalled(false), verbose_(false) { setSamplingTime(0.010); velocity.resize(6); @@ -59,48 +69,37 @@ vpRobotWireFrameSimulator::vpRobotWireFrameSimulator():vpWireFrameSimulator(), v #if defined(VISP_HAVE_DISPLAY) display.init(I, 0, 0,"The External view"); #endif - robotStop = false; - jointLimit = false; - displayBusy = false; - displayType = MODEL_3D; - displayAllowed = true; - singularityManagement = true; - robotArms = NULL; - - constantSamplingTimeMode = false; - setVelocityCalled = false; - - verbose_ = false; + //pid_t pid = getpid(); // setpriority (PRIO_PROCESS, pid, 19); } /*! Default constructor. - \param display : When true, enables the display of the external view. + \param do_display : When true, enables the display of the external view. */ -vpRobotWireFrameSimulator::vpRobotWireFrameSimulator(bool display) : vpWireFrameSimulator(), vpRobotSimulator() +vpRobotWireFrameSimulator::vpRobotWireFrameSimulator(bool do_display) + : vpWireFrameSimulator(), vpRobotSimulator(), + I(), tcur(0), tprev(0), robotArms(NULL), size_fMi(8), fMi(NULL), artCoord(), artVel(), velocity(), + /* thread(), attr(), */ mutex_fMi(), mutex_artVel(), mutex_artCoord(), mutex_velocity(), mutex_display(), + displayBusy(false), robotStop(false), jointLimit(false), jointLimitArt(false), singularityManagement(true), + cameraParam(), +#if defined(VISP_HAVE_DISPLAY) + display(), +#endif + displayType(MODEL_3D), displayAllowed(do_display), constantSamplingTimeMode(false), + setVelocityCalled(false), verbose_(false) { setSamplingTime(0.010); velocity.resize(6); I.resize(480,640); I = 255; - displayAllowed = display; #if defined(VISP_HAVE_DISPLAY) - if (display) + if (do_display) this->display.init(I, 0, 0,"The External view"); #endif - robotStop = false; - jointLimit = false; - displayBusy = false; - displayType = MODEL_3D; - singularityManagement = true; - robotArms = NULL; - - constantSamplingTimeMode = false; - setVelocityCalled = false; - + //pid_t pid = getpid(); // setpriority (PRIO_PROCESS, pid, 19); } @@ -121,15 +120,15 @@ vpRobotWireFrameSimulator::~vpRobotWireFrameSimulator() It exists several default scenes you can use. Use the vpSceneObject and the vpSceneDesiredObject attributes to use them in this method. The corresponding files are stored in the "data" folder which is in the ViSP build directory. \param obj : Type of scene used to display the object at the current position. - \param desiredObject : Type of scene used to display the object at the desired pose (in the internal view). + \param desired_object : Type of scene used to display the object at the desired pose (in the internal view). */ void -vpRobotWireFrameSimulator::initScene(const vpSceneObject &obj, const vpSceneDesiredObject &desiredObject) +vpRobotWireFrameSimulator::initScene(const vpSceneObject &obj, const vpSceneDesiredObject &desired_object) { if(displayCamera){ free_Bound_scene (&(this->camera)); } - vpWireFrameSimulator::initScene(obj, desiredObject); + vpWireFrameSimulator::initScene(obj, desired_object); if(displayCamera){ free_Bound_scene (&(this->camera)); } @@ -144,15 +143,15 @@ vpRobotWireFrameSimulator::initScene(const vpSceneObject &obj, const vpSceneDesi It is also possible to use a vrml (.wrl) file. \param obj : Path to the scene file you want to use. - \param desiredObject : Path to the scene file you want to use. + \param desired_object : Path to the scene file you want to use. */ void -vpRobotWireFrameSimulator::initScene(const char* obj, const char* desiredObject) +vpRobotWireFrameSimulator::initScene(const char* obj, const char* desired_object) { if(displayCamera){ free_Bound_scene (&(this->camera)); } - vpWireFrameSimulator::initScene(obj, desiredObject); + vpWireFrameSimulator::initScene(obj, desired_object); if(displayCamera){ free_Bound_scene (&(this->camera)); } @@ -206,12 +205,12 @@ vpRobotWireFrameSimulator::initScene(const char* obj) According to the initialisation method you used, the current position and maybee the desired position of the object are displayed. - \param I : The image where the internal view is displayed. + \param I_ : The image where the internal view is displayed. \warning : The objects are displayed thanks to overlays. The image I is not modified. */ void -vpRobotWireFrameSimulator::getInternalView(vpImage<vpRGBa> &I) +vpRobotWireFrameSimulator::getInternalView(vpImage<vpRGBa> &I_) { if (!sceneInitialized) @@ -224,13 +223,13 @@ vpRobotWireFrameSimulator::getInternalView(vpImage<vpRGBa> &I) if( (std::fabs(px_int-1.) > vpMath::maximum(px_int,1.)*std::numeric_limits<double>::epsilon()) && (std::fabs(py_int-1) > vpMath::maximum(py_int,1.)*std::numeric_limits<double>::epsilon())) { - u = (double)I.getWidth()/(2*px_int); - v = (double)I.getHeight()/(2*py_int); + u = (double)I_.getWidth()/(2*px_int); + v = (double)I_.getHeight()/(2*py_int); } else { - u = (double)I.getWidth()/(vpMath::minimum(I.getWidth(),I.getHeight())); - v = (double)I.getHeight()/(vpMath::minimum(I.getWidth(),I.getHeight())); + u = (double)I_.getWidth()/(vpMath::minimum(I_.getWidth(),I_.getHeight())); + v = (double)I_.getHeight()/(vpMath::minimum(I_.getWidth(),I_.getHeight())); } float o44c[4][4],o44cd[4][4],x,y,z; @@ -255,7 +254,7 @@ vpRobotWireFrameSimulator::getInternalView(vpImage<vpRGBa> &I) add_vwstack ("start","vup", o44c[1][0],o44c[1][1],o44c[1][2]); add_vwstack ("start","window", -u, u, -v, v); if (displayObject) - display_scene(id,this->scene,I, curColor); + display_scene(id,this->scene,I_, curColor); add_vwstack ("start","cop", o44cd[3][0],o44cd[3][1],o44cd[3][2]); x = o44cd[2][0] + o44cd[3][0]; @@ -267,8 +266,8 @@ vpRobotWireFrameSimulator::getInternalView(vpImage<vpRGBa> &I) add_vwstack ("start","window", -u, u, -v, v); if (displayDesiredObject) { - if (desiredObject == D_TOOL) display_scene(o44cd,desiredScene,I, vpColor::red); - else display_scene(id,desiredScene,I, desColor); + if (desiredObject == D_TOOL) display_scene(o44cd,desiredScene,I_, vpColor::red); + else display_scene(id,desiredScene,I_, desColor); } delete[] fMit; set_displayBusy(false); @@ -279,12 +278,12 @@ vpRobotWireFrameSimulator::getInternalView(vpImage<vpRGBa> &I) According to the initialisation method you used, the current position and maybee the desired position of the object are displayed. - \param I : The image where the internal view is displayed. + \param I_ : The image where the internal view is displayed. \warning : The objects are displayed thanks to overlays. The image I is not modified. */ void -vpRobotWireFrameSimulator::getInternalView(vpImage<unsigned char> &I) +vpRobotWireFrameSimulator::getInternalView(vpImage<unsigned char> &I_) { if (!sceneInitialized) @@ -302,8 +301,8 @@ vpRobotWireFrameSimulator::getInternalView(vpImage<unsigned char> &I) } else { - u = (double)I.getWidth()/(vpMath::minimum(I.getWidth(),I.getHeight())); - v = (double)I.getHeight()/(vpMath::minimum(I.getWidth(),I.getHeight())); + u = (double)I_.getWidth()/(vpMath::minimum(I_.getWidth(),I_.getHeight())); + v = (double)I_.getHeight()/(vpMath::minimum(I_.getWidth(),I_.getHeight())); } float o44c[4][4],o44cd[4][4],x,y,z; @@ -329,7 +328,7 @@ vpRobotWireFrameSimulator::getInternalView(vpImage<unsigned char> &I) add_vwstack ("start","window", -u, u, -v, v); if (displayObject) { - display_scene(id,this->scene,I, curColor); + display_scene(id,this->scene,I_, curColor); } add_vwstack ("start","cop", o44cd[3][0],o44cd[3][1],o44cd[3][2]); @@ -342,8 +341,8 @@ vpRobotWireFrameSimulator::getInternalView(vpImage<unsigned char> &I) add_vwstack ("start","window", -u, u, -v, v); if (displayDesiredObject) { - if (desiredObject == D_TOOL) display_scene(o44cd,desiredScene,I, vpColor::red); - else display_scene(id,desiredScene,I, desColor); + if (desiredObject == D_TOOL) display_scene(o44cd,desiredScene,I_, vpColor::red); + else display_scene(id,desiredScene,I_, desColor); } delete[] fMit; set_displayBusy(false); diff --git a/src/robot/simulator-robot/vpRobotWireFrameSimulator.h b/src/robot/simulator-robot/vpRobotWireFrameSimulator.h index 106f7c62837e39dc4d40a13581e9c3e37612b4a1..7a4435ecc90fed61dabe41cc688938e2bf35ae55 100644 --- a/src/robot/simulator-robot/vpRobotWireFrameSimulator.h +++ b/src/robot/simulator-robot/vpRobotWireFrameSimulator.h @@ -3,7 +3,7 @@ * $Id: vpRobotWireFrameSimulator.h 3530 2012-01-03 10:52:12Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -51,10 +51,10 @@ -#if defined(WIN32) || defined(VISP_HAVE_PTHREAD) +#if defined(_WIN32) || defined(VISP_HAVE_PTHREAD) #include <cmath> // std::fabs #include <limits> // numeric_limits -#if defined(WIN32) +#if defined(_WIN32) # include <windows.h> #elif defined(VISP_HAVE_PTHREAD) # include <pthread.h> @@ -121,14 +121,14 @@ class VISP_EXPORT vpRobotWireFrameSimulator : protected vpWireFrameSimulator, pu /*! The velocity in the current frame (articular, camera or reference)*/ vpColVector velocity; - #if defined(WIN32) - HANDLE hThread; - HANDLE mutex_fMi; +#if defined(_WIN32) + HANDLE hThread; + HANDLE mutex_fMi; HANDLE mutex_artVel; HANDLE mutex_artCoord; HANDLE mutex_velocity; HANDLE mutex_display; - #elif defined(VISP_HAVE_PTHREAD) +#elif defined(VISP_HAVE_PTHREAD) pthread_t thread; pthread_attr_t attr; pthread_mutex_t mutex_fMi; @@ -136,7 +136,7 @@ class VISP_EXPORT vpRobotWireFrameSimulator : protected vpWireFrameSimulator, pu pthread_mutex_t mutex_artCoord; pthread_mutex_t mutex_velocity; pthread_mutex_t mutex_display; - #endif +#endif bool displayBusy; @@ -260,11 +260,11 @@ class VISP_EXPORT vpRobotWireFrameSimulator : protected vpWireFrameSimulator, pu /*! Set the desired position of the robot's camera relative to the object. - \param cdMo : The desired pose of the camera. + \param cdMo_ : The desired pose of the camera. */ - void setDesiredCameraPosition(const vpHomogeneousMatrix cdMo) + void setDesiredCameraPosition(const vpHomogeneousMatrix cdMo_) { - this->vpWireFrameSimulator::setDesiredCameraPosition(cdMo); + this->vpWireFrameSimulator::setDesiredCameraPosition(cdMo_); } /*! @@ -276,11 +276,11 @@ class VISP_EXPORT vpRobotWireFrameSimulator : protected vpWireFrameSimulator, pu /*! Set the external camera point of view. - \param camMf : The pose of the external camera relative to the world reference frame. + \param camMf_ : The pose of the external camera relative to the world reference frame. */ - void setExternalCameraPosition(const vpHomogeneousMatrix camMf) + void setExternalCameraPosition(const vpHomogeneousMatrix camMf_) { - this->vpWireFrameSimulator::setExternalCameraPosition(camMf); + this->vpWireFrameSimulator::setExternalCameraPosition(camMf_); } /*! Specify the thickness of the graphics drawings. @@ -321,15 +321,15 @@ class VISP_EXPORT vpRobotWireFrameSimulator : protected vpWireFrameSimulator, pu /*! Set the pose between the object and the fixed world frame. - \param fMo : The pose between the object and the fixed world frame. + \param fMo_ : The pose between the object and the fixed world frame. */ - void set_fMo(const vpHomogeneousMatrix &fMo) {this->fMo = fMo;} + void set_fMo(const vpHomogeneousMatrix &fMo_) {this->fMo = fMo_;} protected: /*! Function used to launch the thread which moves the robot. */ - #if defined(WIN32) + #if defined(_WIN32) static DWORD WINAPI launcher( LPVOID lpParam ) { ((vpRobotWireFrameSimulator *)lpParam)->updateArticularPosition(); @@ -357,7 +357,7 @@ class VISP_EXPORT vpRobotWireFrameSimulator : protected vpWireFrameSimulator, pu void initDisplay() {;} virtual void initArms() = 0; - #if defined(WIN32) + #if defined(_WIN32) vpColVector get_artCoord() const { WaitForSingleObject(mutex_artCoord,INFINITE); vpColVector artCoordTmp (6); diff --git a/src/robot/simulator-robot/vpSimulatorAfma6.cpp b/src/robot/simulator-robot/vpSimulatorAfma6.cpp index b318cab99d31ab7c5a76d92b6c55c5ee054b9272..8283073f3f47f3ad023a89dce45cace48154aee5 100644 --- a/src/robot/simulator-robot/vpSimulatorAfma6.cpp +++ b/src/robot/simulator-robot/vpSimulatorAfma6.cpp @@ -3,7 +3,7 @@ * $Id: vpSimulatorAfma6.cpp 2595 2010-06-02 08:50:59Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -42,7 +42,7 @@ #include <visp/vpConfig.h> -#if defined(WIN32) || defined(VISP_HAVE_PTHREAD) +#if defined(_WIN32) || defined(VISP_HAVE_PTHREAD) #include <visp/vpSimulatorAfma6.h> #include <visp/vpTime.h> #include <visp/vpImagePoint.h> @@ -59,14 +59,17 @@ const double vpSimulatorAfma6::defaultPositioningVelocity = 25.0; /*! Basic constructor */ -vpSimulatorAfma6::vpSimulatorAfma6():vpRobotWireFrameSimulator(), vpAfma6() +vpSimulatorAfma6::vpSimulatorAfma6() + : vpRobotWireFrameSimulator(), vpAfma6(), + q_prev_getdis(), first_time_getdis(true), positioningVelocity(defaultPositioningVelocity), + zeroPos(), reposPos(), toolCustom(false), arm_dir() { init(); initDisplay(); tcur = vpTime::measureTimeMs(); - #if defined(WIN32) + #if defined(_WIN32) mutex_fMi = CreateMutex(NULL,FALSE,NULL); mutex_artVel = CreateMutex(NULL,FALSE,NULL); mutex_artCoord = CreateMutex(NULL,FALSE,NULL); @@ -101,17 +104,20 @@ vpSimulatorAfma6::vpSimulatorAfma6():vpRobotWireFrameSimulator(), vpAfma6() /*! Constructor used to enable or disable the external view of the robot. - \param display : When true, enables the display of the external view. + \param do_display : When true, enables the display of the external view. */ -vpSimulatorAfma6::vpSimulatorAfma6(bool display):vpRobotWireFrameSimulator(display) +vpSimulatorAfma6::vpSimulatorAfma6(bool do_display) + : vpRobotWireFrameSimulator(do_display), + q_prev_getdis(), first_time_getdis(true), positioningVelocity(defaultPositioningVelocity), + zeroPos(), reposPos(), toolCustom(false), arm_dir() { init(); initDisplay(); tcur = vpTime::measureTimeMs(); - #if defined(WIN32) + #if defined(_WIN32) mutex_fMi = CreateMutex(NULL,FALSE,NULL); mutex_artVel = CreateMutex(NULL,FALSE,NULL); mutex_artCoord = CreateMutex(NULL,FALSE,NULL); @@ -150,7 +156,7 @@ vpSimulatorAfma6::~vpSimulatorAfma6() { robotStop = true; - #if defined(WIN32) + #if defined(_WIN32) WaitForSingleObject(hThread,INFINITE); CloseHandle(hThread); CloseHandle(mutex_fMi); @@ -276,16 +282,22 @@ vpSimulatorAfma6::initDisplay() \param tool : Tool to use. Note that the generic camera is not handled. - \param projModel : Projection model associated to the camera. + \param proj_model : Projection model associated to the camera. \sa vpCameraParameters, init() */ void vpSimulatorAfma6::init (vpAfma6::vpAfma6ToolType tool, - vpCameraParameters::vpCameraParametersProjType projModel) + vpCameraParameters::vpCameraParametersProjType proj_model) { - this->projModel = projModel; - + this->projModel = proj_model; + unsigned int name_length = 30; // the size of this kind of string "/afma6_tool_vacuum.bnd" + if (arm_dir.size() > FILENAME_MAX) + throw vpException (vpException::dimensionError, "Cannot initialize Afma6 simulator"); + unsigned int full_length = (unsigned int)arm_dir.size() + name_length; + if (full_length > FILENAME_MAX) + throw vpException (vpException::dimensionError, "Cannot initialize Afma6 simulator"); + // Use here default values of the robot constant parameters. switch (tool) { case vpAfma6::TOOL_CCMOP: { @@ -302,11 +314,12 @@ vpSimulatorAfma6::init (vpAfma6::vpAfma6ToolType tool, { while (get_displayBusy()) vpTime::wait(2); free_Bound_scene (&(robotArms[5])); - char name_arm[FILENAME_MAX]; + char *name_arm = new char [full_length]; strcpy(name_arm, arm_dir.c_str()); strcat(name_arm,"/afma6_tool_ccmop.bnd"); set_scene(name_arm, robotArms+5, 1.0); set_displayBusy(false); + delete [] name_arm; } break; } @@ -324,11 +337,12 @@ vpSimulatorAfma6::init (vpAfma6::vpAfma6ToolType tool, { while (get_displayBusy()) vpTime::wait(2); free_Bound_scene (&(robotArms[5])); - char name_arm[FILENAME_MAX]; + char *name_arm = new char [full_length]; strcpy(name_arm, arm_dir.c_str()); strcat(name_arm,"/afma6_tool_gripper.bnd"); set_scene(name_arm, robotArms+5, 1.0); set_displayBusy(false); + delete [] name_arm; } break; } @@ -346,11 +360,14 @@ vpSimulatorAfma6::init (vpAfma6::vpAfma6ToolType tool, { while (get_displayBusy()) vpTime::wait(2); free_Bound_scene (&(robotArms[5])); - char name_arm[FILENAME_MAX]; + + char *name_arm = new char [full_length]; + strcpy(name_arm, arm_dir.c_str()); strcat(name_arm,"/afma6_tool_vacuum.bnd"); set_scene(name_arm, robotArms+5, 1.0); set_displayBusy(false); + delete [] name_arm; } break; } @@ -412,6 +429,7 @@ vpSimulatorAfma6::getCameraParameters (vpCameraParameters &cam, } break; } + case vpAfma6::TOOL_GENERIC_CAMERA: case vpAfma6::TOOL_VACUUM: { std::cout << "The generic camera is not handled in vpSimulatorAfma6.cpp" << std::endl; break; @@ -427,30 +445,30 @@ vpSimulatorAfma6::getCameraParameters (vpCameraParameters &cam, Get the current intrinsic camera parameters obtained by calibration. \param cam : In output, camera parameters to fill. - \param I : A B&W image send by the current camera in use. + \param I_ : A B&W image send by the current camera in use. \warning The image size must be : 640x480 ! */ void vpSimulatorAfma6::getCameraParameters (vpCameraParameters &cam, - const vpImage<unsigned char> &I) + const vpImage<unsigned char> &I_) { - getCameraParameters(cam,I.getWidth(),I.getHeight()); + getCameraParameters(cam,I_.getWidth(),I_.getHeight()); } /*! Get the current intrinsic camera parameters obtained by calibration. \param cam : In output, camera parameters to fill. - \param I : A B&W image send by the current camera in use. + \param I_ : A B&W image send by the current camera in use. \warning The image size must be : 640x480 ! */ void vpSimulatorAfma6::getCameraParameters (vpCameraParameters &cam, - const vpImage<vpRGBa> &I) + const vpImage<vpRGBa> &I_) { - getCameraParameters(cam,I.getWidth(),I.getHeight()); + getCameraParameters(cam,I_.getWidth(),I_.getHeight()); } @@ -722,7 +740,7 @@ vpSimulatorAfma6::compute_fMi() // fMit[7] = fMit[6] * cMe; vpAfma6::get_fMc(q,fMit[7]); - #if defined(WIN32) + #if defined(_WIN32) WaitForSingleObject(mutex_fMi,INFINITE); for (int i = 0; i < 8; i++) fMi[i] = fMit[i]; @@ -970,24 +988,24 @@ vpSimulatorAfma6::computeArticularVelocity() { case vpRobot::CAMERA_FRAME : { - vpMatrix eJe; + vpMatrix eJe_; vpVelocityTwistMatrix eVc(_eMc); - vpAfma6::get_eJe(articularCoordinates,eJe); - eJe = eJe.pseudoInverse(); + vpAfma6::get_eJe(articularCoordinates,eJe_); + eJe_ = eJe_.pseudoInverse(); if (singularityManagement) - singularityTest(articularCoordinates,eJe); - articularVelocity = eJe*eVc*velocityframe; + singularityTest(articularCoordinates,eJe_); + articularVelocity = eJe_*eVc*velocityframe; set_artVel (articularVelocity); break; } case vpRobot::REFERENCE_FRAME : { - vpMatrix fJe; - vpAfma6::get_fJe(articularCoordinates,fJe); - fJe = fJe.pseudoInverse(); + vpMatrix fJe_; + vpAfma6::get_fJe(articularCoordinates,fJe_); + fJe_ = fJe_.pseudoInverse(); if (singularityManagement) - singularityTest(articularCoordinates,fJe); - articularVelocity = fJe*velocityframe; + singularityTest(articularCoordinates,fJe_); + articularVelocity = fJe_*velocityframe; set_artVel (articularVelocity); break; } @@ -1095,10 +1113,10 @@ vpSimulatorAfma6::getVelocity (const vpRobot::vpControlFrameType frame, vpColVec { case vpRobot::CAMERA_FRAME : { - vpMatrix eJe; + vpMatrix eJe_; vpVelocityTwistMatrix cVe(_eMc); - vpAfma6::get_eJe(articularCoordinates,eJe); - vel = cVe*eJe*articularVelocity; + vpAfma6::get_eJe(articularCoordinates,eJe_); + vel = cVe*eJe_*articularVelocity; break ; } case vpRobot::ARTICULAR_FRAME : @@ -1108,9 +1126,9 @@ vpSimulatorAfma6::getVelocity (const vpRobot::vpControlFrameType frame, vpColVec } case vpRobot::REFERENCE_FRAME : { - vpMatrix fJe; - vpAfma6::get_fJe(articularCoordinates,fJe); - vel = fJe*articularVelocity; + vpMatrix fJe_; + vpAfma6::get_fJe(articularCoordinates,fJe_); + vel = fJe_*articularVelocity; break ; } case vpRobot::MIXT_FRAME : @@ -1126,6 +1144,29 @@ vpSimulatorAfma6::getVelocity (const vpRobot::vpControlFrameType frame, vpColVec } } +/*! + Get the robot time stamped velocities. + + \param frame : Frame in wich velocities are mesured. + + \param vel : Measured velocities. Translations are expressed in m/s + and rotations in rad/s. + + \param timestamp : Unix time in second since January 1st 1970. + + \warning In camera frame, reference frame and mixt frame, the representation + of the rotation is ThetaU. In that cases, \f$velocity = [\dot x, \dot y, \dot + z, \dot {\theta U}_x, \dot {\theta U}_y, \dot {\theta U}_z]\f$. + + \sa getVelocity(const vpRobot::vpControlFrameType frame, vpColVector & vel) +*/ +void +vpSimulatorAfma6::getVelocity (const vpRobot::vpControlFrameType frame, vpColVector & vel, double ×tamp) +{ + timestamp = vpTime::measureTimeSecond(); + getVelocity(frame, vel); +} + /*! Get the robot velocities. @@ -1171,12 +1212,33 @@ int main() vpColVector vpSimulatorAfma6::getVelocity (vpRobot::vpControlFrameType frame) { - vpColVector velocity(6); - getVelocity (frame, velocity); + vpColVector vel(6); + getVelocity (frame, vel); - return velocity; + return vel; } +/*! + Get the time stamped robot velocities. + + \param frame : Frame in wich velocities are mesured. + + \param timestamp : Unix time in second since January 1st 1970. + + \return Measured velocities. Translations are expressed in m/s + and rotations in rad/s. + + \sa getVelocity(vpRobot::vpControlFrameType frame) +*/ +vpColVector +vpSimulatorAfma6::getVelocity (vpRobot::vpControlFrameType frame, double ×tamp) +{ + timestamp = vpTime::measureTimeSecond(); + vpColVector vel(6); + getVelocity (frame, vel); + + return vel; +} void vpSimulatorAfma6::findHighestPositioningSpeed(vpColVector &q) @@ -1299,10 +1361,10 @@ vpSimulatorAfma6::setPosition(const vpRobot::vpControlFrameType frame,const vpCo vpRotationMatrix cRc2(rxyz); vpHomogeneousMatrix cMc2(txyz, cRc2); - vpHomogeneousMatrix fMc; - vpAfma6::get_fMc(articularCoordinates, fMc); + vpHomogeneousMatrix fMc_; + vpAfma6::get_fMc(articularCoordinates, fMc_); - vpHomogeneousMatrix fMc2 = fMc * cMc2; + vpHomogeneousMatrix fMc2 = fMc_ * cMc2; do { @@ -1372,13 +1434,13 @@ vpSimulatorAfma6::setPosition(const vpRobot::vpControlFrameType frame,const vpCo } vpRotationMatrix fRc(rxyz); - vpHomogeneousMatrix fMc(txyz, fRc); + vpHomogeneousMatrix fMc_(txyz, fRc); do { articularCoordinates = get_artCoord(); qdes = articularCoordinates; - nbSol = getInverseKinematics(fMc, qdes, true, verbose_); + nbSol = getInverseKinematics(fMc_, qdes, true, verbose_); setVelocityCalled = true; if (nbSol > 0) { @@ -1606,8 +1668,8 @@ int main() } \endcode - \sa setPosition(const vpRobot::vpControlFrameType frame, const - vpColVector & r) + \sa getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q, double ×tamp) + \sa setPosition(const vpRobot::vpControlFrameType frame, const vpColVector & r) */ void @@ -1631,20 +1693,20 @@ vpSimulatorAfma6::getPosition(const vpRobot::vpControlFrameType frame, vpColVect case vpRobot::REFERENCE_FRAME: { - vpHomogeneousMatrix fMc; - vpAfma6::get_fMc (get_artCoord(), fMc); + vpHomogeneousMatrix fMc_; + vpAfma6::get_fMc (get_artCoord(), fMc_); vpRotationMatrix fRc; - fMc.extract(fRc); + fMc_.extract(fRc); vpRxyzVector rxyz(fRc); vpTranslationVector txyz; - fMc.extract(txyz); + fMc_.extract(txyz); for (unsigned int i=0; i <3; i++) { q[i] = txyz[i]; - q[i+3] = rxyz[i]; + q[i+3] = rxyz[i]; } break ; } @@ -1660,6 +1722,39 @@ vpSimulatorAfma6::getPosition(const vpRobot::vpControlFrameType frame, vpColVect } } +/*! + + Get the current time stamped position of the robot. + + \param frame : Control frame type in which to get the position, either : + - in the camera cartesien frame, + - joint (articular) coordinates of each axes + - in a reference or fixed cartesien frame attached to the robot base + - in a mixt cartesien frame (translation in reference + frame, and rotation in camera frame) + + \param q : Measured position of the robot: + - in camera cartesien frame, a 6 dimension vector, set to 0. + + - in articular, a 6 dimension vector corresponding to the joint + position of each dof in radians. + + - in reference frame, a 6 dimension vector, the first 3 values correspond to + the translation tx, ty, tz in meters (like a vpTranslationVector), and the + last 3 values to the rx, ry, rz rotation (like a vpRxyzVector). The code + below show how to convert this position into a vpHomogenousMatrix: + + \param timestamp : Unix time in second since January 1st 1970. + + \sa getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q) + */ +void +vpSimulatorAfma6::getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q, double ×tamp) +{ + timestamp = vpTime::measureTimeSecond(); + getPosition(frame, q); +} + /*! Get the current position of the robot. @@ -1672,8 +1767,7 @@ vpSimulatorAfma6::getPosition(const vpRobot::vpControlFrameType frame, vpColVect \sa getPosition(const vpRobot::vpControlFrameType frame, vpColVector &) */ void -vpSimulatorAfma6::getPosition (const vpRobot::vpControlFrameType frame, - vpPoseVector &position) +vpSimulatorAfma6::getPosition (const vpRobot::vpControlFrameType frame, vpPoseVector &position) { vpColVector posRxyz; //recupere position en Rxyz @@ -1690,6 +1784,24 @@ vpSimulatorAfma6::getPosition (const vpRobot::vpControlFrameType frame, } } +/*! + + Get the current time stamped position of the robot. + + Similar as getPosition(const vpRobot::vpControlFrameType frame, vpColVector &, double &) + + The difference is here that the position is returned using a ThetaU + representation. + + */ +void +vpSimulatorAfma6::getPosition(const vpRobot::vpControlFrameType frame, + vpPoseVector &position, double ×tamp) +{ + timestamp = vpTime::measureTimeSecond(); + getPosition(frame, position); +} + /*! This method enables to set the minimum and maximum joint limits for all the six axis of the robot. The three first values have to be given in meter and the others in radian. @@ -1943,7 +2055,6 @@ robot.setPosition(vpRobot::ARTICULAR_FRAME, q); // Move to the joint position bool vpSimulatorAfma6::readPosFile(const char *filename, vpColVector &q) { - FILE * fd ; fd = fopen(filename, "r") ; if (fd == NULL) @@ -1958,15 +2069,16 @@ vpSimulatorAfma6::readPosFile(const char *filename, vpColVector &q) // Saut des lignes commencant par # if (fgets (line, FILENAME_MAX, fd) != NULL) { if ( strncmp (line, "#", 1) != 0) { - // La ligne n'est pas un commentaire - if ( strncmp (line, head, sizeof(head)-1) == 0) { - sortie = true; // Position robot trouvee. - } -// else -// return (false); // fin fichier sans position robot. + // La ligne n'est pas un commentaire + if ( strncmp (line, head, sizeof(head)-1) == 0) { + sortie = true; // Position robot trouvee. + } + // else + // return (false); // fin fichier sans position robot. } } else { + fclose(fd) ; return (false); /* fin fichier */ } @@ -1975,10 +2087,14 @@ vpSimulatorAfma6::readPosFile(const char *filename, vpColVector &q) // Lecture des positions q.resize(njoint); - sscanf(line, "%s %lf %lf %lf %lf %lf %lf", - dummy, - &q[0], &q[1], &q[2], - &q[3], &q[4], &q[5]); + int ret = sscanf(line, "%s %lf %lf %lf %lf %lf %lf", + dummy, + &q[0], &q[1], &q[2], &q[3], &q[4], &q[5]); + + if (ret != 7) { + fclose(fd) ; + return false; + } // converts rotations from degrees into radians //q.deg2rad(); @@ -2105,15 +2221,15 @@ vpSimulatorAfma6::get_cVe(vpVelocityTwistMatrix &cVe) To compute \f$^e{\bf J}_e\f$, we communicate with the low level controller to get the joint position of the robot. - \param eJe : Robot jacobian \f$^e{\bf J}_e\f$ expressed in the + \param eJe_ : Robot jacobian \f$^e{\bf J}_e\f$ expressed in the end-effector frame. */ void -vpSimulatorAfma6::get_eJe(vpMatrix &eJe) +vpSimulatorAfma6::get_eJe(vpMatrix &eJe_) { try { - vpAfma6::get_eJe(get_artCoord(), eJe) ; + vpAfma6::get_eJe(get_artCoord(), eJe_) ; } catch(...) { @@ -2129,16 +2245,16 @@ vpSimulatorAfma6::get_eJe(vpMatrix &eJe) To compute \f$^f{\bf J}_e\f$, we communicate with the low level controller to get the joint position of the robot. - \param fJe : Robot jacobian \f$^f{\bf J}_e\f$ expressed in the + \param fJe_ : Robot jacobian \f$^f{\bf J}_e\f$ expressed in the reference frame. */ void -vpSimulatorAfma6::get_fJe(vpMatrix &fJe) +vpSimulatorAfma6::get_fJe(vpMatrix &fJe_) { try { vpColVector articularCoordinates = get_artCoord(); - vpAfma6::get_fJe(articularCoordinates, fJe) ; + vpAfma6::get_fJe(articularCoordinates, fJe_) ; } catch(...) { @@ -2182,26 +2298,39 @@ void vpSimulatorAfma6::initArms() { // set scene_dir from #define VISP_SCENE_DIR if it exists - std::string scene_dir; + std::string scene_dir_; if (vpIoTools::checkDirectory(VISP_SCENES_DIR) == true) // directory exists - scene_dir = VISP_SCENES_DIR; + scene_dir_ = VISP_SCENES_DIR; else { try { - scene_dir = vpIoTools::getenv("VISP_SCENES_DIR"); - std::cout << "The simulator uses data from VISP_SCENES_DIR=" << scene_dir << std::endl; + scene_dir_ = vpIoTools::getenv("VISP_SCENES_DIR"); + std::cout << "The simulator uses data from VISP_SCENES_DIR=" << scene_dir_ << std::endl; } catch (...) { std::cout << "Cannot get VISP_SCENES_DIR environment variable" << std::endl; } } - char name_cam[FILENAME_MAX]; + unsigned int name_length = 30; // the size of this kind of string "/afma6_arm2.bnd" + if (scene_dir_.size() > FILENAME_MAX) + throw vpException (vpException::dimensionError, "Cannot initialize Afma6 simulator"); + unsigned int full_length = (unsigned int)scene_dir_.size() + name_length; + if (full_length > FILENAME_MAX) + throw vpException (vpException::dimensionError, "Cannot initialize Afma6 simulator"); + + char *name_cam = new char [full_length]; - strcpy(name_cam, scene_dir.c_str()); + strcpy(name_cam, scene_dir_.c_str()); strcat(name_cam,"/camera.bnd"); set_scene(name_cam,&camera,cameraFactor); - char name_arm[FILENAME_MAX]; + if (arm_dir.size() > FILENAME_MAX) + throw vpException (vpException::dimensionError, "Cannot initialize Afma6 simulator"); + full_length = (unsigned int)arm_dir.size() + name_length; + if (full_length > FILENAME_MAX) + throw vpException (vpException::dimensionError, "Cannot initialize Afma6 simulator"); + + char *name_arm = new char [full_length]; strcpy(name_arm, arm_dir.c_str()); strcat(name_arm,"/afma6_gate.bnd"); set_scene(name_arm, robotArms, 1.0); @@ -2250,14 +2379,17 @@ vpSimulatorAfma6::initArms() // sceneInitialized = true; // displayObject = true; displayCamera = true; + + delete [] name_cam; + delete [] name_arm; } void -vpSimulatorAfma6::getExternalImage(vpImage<vpRGBa> &I) +vpSimulatorAfma6::getExternalImage(vpImage<vpRGBa> &I_) { bool changed = false; - vpHomogeneousMatrix displacement = navigation(I,changed); + vpHomogeneousMatrix displacement = navigation(I_,changed); //if (displacement[2][3] != 0) if (std::fabs(displacement[2][3]) > std::numeric_limits<double>::epsilon()) @@ -2274,13 +2406,13 @@ vpSimulatorAfma6::getExternalImage(vpImage<vpRGBa> &I) if( (std::fabs(px_ext-1.) > vpMath::maximum(px_ext,1.)*std::numeric_limits<double>::epsilon()) && (std::fabs(py_ext-1) > vpMath::maximum(py_ext,1.)*std::numeric_limits<double>::epsilon())) { - u = (double)I.getWidth()/(2*px_ext); - v = (double)I.getHeight()/(2*py_ext); + u = (double)I_.getWidth()/(2*px_ext); + v = (double)I_.getHeight()/(2*py_ext); } else { - u = (double)I.getWidth()/(vpMath::minimum(I.getWidth(),I.getHeight())); - v = (double)I.getHeight()/(vpMath::minimum(I.getWidth(),I.getHeight())); + u = (double)I_.getWidth()/(vpMath::minimum(I_.getWidth(),I_.getHeight())); + v = (double)I_.getHeight()/(vpMath::minimum(I_.getWidth(),I_.getHeight())); } float w44o[4][4],w44cext[4][4],x,y,z; @@ -2300,22 +2432,22 @@ vpSimulatorAfma6::getExternalImage(vpImage<vpRGBa> &I) get_fMi(fMit); vp2jlc_matrix(vpHomogeneousMatrix(0,0,0,0,0,0),w44o); - display_scene(w44o,robotArms[0],I, curColor); + display_scene(w44o,robotArms[0],I_, curColor); vp2jlc_matrix(fMit[0],w44o); - display_scene(w44o,robotArms[1],I, curColor); + display_scene(w44o,robotArms[1],I_, curColor); vp2jlc_matrix(fMit[2],w44o); - display_scene(w44o,robotArms[2],I, curColor); + display_scene(w44o,robotArms[2],I_, curColor); vp2jlc_matrix(fMit[3],w44o); - display_scene(w44o,robotArms[3],I, curColor); + display_scene(w44o,robotArms[3],I_, curColor); vp2jlc_matrix(fMit[4],w44o); - display_scene(w44o,robotArms[4],I, curColor); + display_scene(w44o,robotArms[4],I_, curColor); vp2jlc_matrix(fMit[5],w44o); - display_scene(w44o,robotArms[5],I, curColor); + display_scene(w44o,robotArms[5],I_, curColor); if (displayCamera) { @@ -2324,13 +2456,13 @@ vpSimulatorAfma6::getExternalImage(vpImage<vpRGBa> &I) cMe = cMe.inverse(); cMe = fMit[6] * cMe; vp2jlc_matrix(cMe,w44o); - display_scene(w44o,camera, I, camColor); + display_scene(w44o,camera, I_, camColor); } if (displayObject) { vp2jlc_matrix(fMo,w44o); - display_scene(w44o,scene,I, curColor); + display_scene(w44o,scene,I_, curColor); } } @@ -2345,24 +2477,24 @@ vpSimulatorAfma6::getExternalImage(vpImage<vpRGBa> &I) \f${^f}{\bf M}_c = {^f}{\bf M}_o \; ({^c}{\bf M}_o)^{-1}\f$, and from the inverse kinematics set the joint positions \f${\bf q}\f$ that corresponds to the \f${^f}{\bf M}_c\f$ transformation. - \param cMo : the desired pose of the camera. + \param cMo_ : the desired pose of the camera. \return false if the robot kinematics is not able to reach the cMo position. */ bool -vpSimulatorAfma6::initialiseCameraRelativeToObject(const vpHomogeneousMatrix &cMo) +vpSimulatorAfma6::initialiseCameraRelativeToObject(const vpHomogeneousMatrix &cMo_) { vpColVector stop(6); bool status = true; stop = 0; set_artVel(stop); set_velocity(stop); - vpHomogeneousMatrix fMc; - fMc = fMo * cMo.inverse(); + vpHomogeneousMatrix fMc_; + fMc_ = fMo * cMo_.inverse(); vpColVector articularCoordinates = get_artCoord(); - int nbSol = getInverseKinematics(fMc, articularCoordinates, true, verbose_); + int nbSol = getInverseKinematics(fMc_, articularCoordinates, true, verbose_); if (nbSol == 0) { status = false; @@ -2389,10 +2521,10 @@ vpSimulatorAfma6::initialiseCameraRelativeToObject(const vpHomogeneousMatrix &cM \f${^f}{\bf M}_o = {^f}{\bf M}_c \; {^c}{\bf M}_o\f$ where \f$ {^f}{\bf M}_c = f({\bf q})\f$ with \f${\bf q}\f$ the robot joint position - \param cMo : the desired pose of the camera. + \param cMo_ : the desired pose of the camera. */ void -vpSimulatorAfma6::initialiseObjectRelativeToCamera(const vpHomogeneousMatrix &cMo) +vpSimulatorAfma6::initialiseObjectRelativeToCamera(const vpHomogeneousMatrix &cMo_) { vpColVector stop(6); stop = 0; @@ -2400,21 +2532,21 @@ vpSimulatorAfma6::initialiseObjectRelativeToCamera(const vpHomogeneousMatrix &cM set_velocity(stop); vpHomogeneousMatrix fMit[8]; get_fMi(fMit); - fMo = fMit[7] * cMo; + fMo = fMit[7] * cMo_; } /*! This method enable to move the robot with respect to the initialized object. The robot trajectory is a straight line from the current position to the one corresponding to the desired pose (3D visual servoing). - \param cdMo : the desired pose of the camera wrt. the object + \param cdMo_ : the desired pose of the camera wrt. the object \param Iint : pointer to the image where the internal view is displayed \param errMax : maximum error to consider the pose is reached \return True is the pose is reached, False else */ bool -vpSimulatorAfma6::setPosition(const vpHomogeneousMatrix &cdMo, vpImage<unsigned char> *Iint, const double &errMax) +vpSimulatorAfma6::setPosition(const vpHomogeneousMatrix &cdMo_, vpImage<unsigned char> *Iint, const double &errMax) { // get rid of max velocity double vMax = getMaxTranslationVelocity(); @@ -2430,7 +2562,6 @@ vpSimulatorAfma6::setPosition(const vpHomogeneousMatrix &cdMo, vpImage<unsigned double t; vpVelocityTwistMatrix cVe; - vpMatrix eJe; unsigned int i,iter=0; while((iter++<300) & (err.euclideanNorm()>errMax)) @@ -2446,7 +2577,7 @@ vpSimulatorAfma6::setPosition(const vpHomogeneousMatrix &cdMo, vpImage<unsigned } // update pose error - cdMc = cdMo*get_cMo().inverse(); + cdMc = cdMo_*get_cMo().inverse(); cdMc.extract(cdRc); cdMc.extract(cdTc); cdTUc.buildFrom(cdRc); diff --git a/src/robot/simulator-robot/vpSimulatorAfma6.h b/src/robot/simulator-robot/vpSimulatorAfma6.h index f515bd4dd69df2176e477c33cbc9930cc6b74cec..c2e86813539d2f8938dff97e73d974f2f260ddee 100644 --- a/src/robot/simulator-robot/vpSimulatorAfma6.h +++ b/src/robot/simulator-robot/vpSimulatorAfma6.h @@ -3,7 +3,7 @@ * $Id: vpSimulatorAfma6.h 2598 2010-06-02 09:20:22Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -52,7 +52,7 @@ #include <string> -#if defined(WIN32) || defined(VISP_HAVE_PTHREAD) +#if defined(_WIN32) || defined(VISP_HAVE_PTHREAD) /*! \class vpSimulatorAfma6 @@ -209,11 +209,14 @@ public: void getDisplacement(const vpRobot::vpControlFrameType frame, vpColVector &displacement); void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q); - void getPosition (const vpRobot::vpControlFrameType frame, - vpPoseVector &position); + void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q, double ×tamp); + void getPosition(const vpRobot::vpControlFrameType frame, vpPoseVector &position); + void getPosition(const vpRobot::vpControlFrameType frame, vpPoseVector &position, double ×tamp); double getPositioningVelocity (void){return positioningVelocity;} void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q); + void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q, double ×tamp); vpColVector getVelocity (const vpRobot::vpControlFrameType frame); + vpColVector getVelocity (const vpRobot::vpControlFrameType frame, double ×tamp); void get_cMe(vpHomogeneousMatrix &cMe); void get_cVe(vpVelocityTwistMatrix &cVe); @@ -240,7 +243,7 @@ public: const double pos5, const double pos6); void setPosition(const char *filename); - void setPositioningVelocity (const double velocity) {positioningVelocity = velocity;} + void setPositioningVelocity (const double vel) {positioningVelocity = vel;} bool setPosition(const vpHomogeneousMatrix &cdMo, vpImage<unsigned char> *Iint=NULL, const double &errMax = 0.001); vpRobot::vpRobotStateType setRobotState (const vpRobot::vpRobotStateType newState); @@ -255,7 +258,7 @@ protected: void findHighestPositioningSpeed(vpColVector &q); void getExternalImage(vpImage<vpRGBa> &I); inline void get_fMi(vpHomogeneousMatrix *fMit) { -#if defined(WIN32) +#if defined(_WIN32) WaitForSingleObject(mutex_fMi,INFINITE); for (int i = 0; i < 8; i++) fMit[i] = fMi[i]; diff --git a/src/robot/simulator-robot/vpSimulatorCamera.cpp b/src/robot/simulator-robot/vpSimulatorCamera.cpp index af70bb3c9bce50c1b1b7fd586419aa90f4766698..f88eda38bdf6005445906c2c37a8b9a57c3c4fcd 100644 --- a/src/robot/simulator-robot/vpSimulatorCamera.cpp +++ b/src/robot/simulator-robot/vpSimulatorCamera.cpp @@ -3,7 +3,7 @@ * $Id: vpSimulatorCamera.cpp 2456 2010-01-07 10:33:12Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -57,7 +57,7 @@ world frame and camera frame to identity. */ -vpSimulatorCamera::vpSimulatorCamera() +vpSimulatorCamera::vpSimulatorCamera() : wMc_() { init() ; } @@ -104,7 +104,7 @@ vpSimulatorCamera::~vpSimulatorCamera() */ void -vpSimulatorCamera::get_cVe(vpVelocityTwistMatrix &cVe) +vpSimulatorCamera::get_cVe(vpVelocityTwistMatrix &cVe) const { vpVelocityTwistMatrix cVe_; cVe = cVe_; @@ -114,13 +114,13 @@ vpSimulatorCamera::get_cVe(vpVelocityTwistMatrix &cVe) Get the robot jacobian expressed in the end-effector frame. For that simple robot the Jacobian is the identity. - \param eJe : A 6 by 6 matrix representing the robot jacobian \f$ {^e}{\bf + \param eJe_ : A 6 by 6 matrix representing the robot jacobian \f$ {^e}{\bf J}_e\f$ expressed in the end-effector frame. Yhis matrix is equal to identity. */ void -vpSimulatorCamera::get_eJe(vpMatrix &eJe) +vpSimulatorCamera::get_eJe(vpMatrix &eJe_) { - eJe = this->eJe ; + eJe_ = this->eJe ; } /*! diff --git a/src/robot/simulator-robot/vpSimulatorCamera.h b/src/robot/simulator-robot/vpSimulatorCamera.h index 942cc320d3451607b563663a09b74a5763221632..70f22cf6254fde534a0d37f79ad443e6635463f9 100644 --- a/src/robot/simulator-robot/vpSimulatorCamera.h +++ b/src/robot/simulator-robot/vpSimulatorCamera.h @@ -3,7 +3,7 @@ * $Id: vpSimulatorCamera.h 2456 2010-01-07 10:33:12Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -117,7 +117,7 @@ public: virtual ~vpSimulatorCamera() ; public: - void get_cVe(vpVelocityTwistMatrix &cVe); + void get_cVe(vpVelocityTwistMatrix &cVe) const; void get_eJe(vpMatrix &eJe); void getPosition(vpHomogeneousMatrix &wMc) const; diff --git a/src/robot/simulator-robot/vpSimulatorPioneer.cpp b/src/robot/simulator-robot/vpSimulatorPioneer.cpp index a3b3e7c2add16cbb40c81aaf00d5ba5475672c79..eb664593fbcc1813b66c7c14c1124aa948ba559f 100644 --- a/src/robot/simulator-robot/vpSimulatorPioneer.cpp +++ b/src/robot/simulator-robot/vpSimulatorPioneer.cpp @@ -3,7 +3,7 @@ * $Id: vpSimulatorPioneer.cpp 2456 2010-01-07 10:33:12Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -58,6 +58,7 @@ */ vpSimulatorPioneer::vpSimulatorPioneer() + : wMc_(), wMe_(), xm_(0), ym_(0), theta_(0) { init() ; } @@ -98,13 +99,13 @@ vpSimulatorPioneer::~vpSimulatorPioneer() Get the robot jacobian expressed in the end-effector frame. The jacobian expression is given in vpPioneer class. - \param eJe : A 6 by 2 matrix representing the robot jacobian \f$ {^e}{\bf + \param _eJe : A 6 by 2 matrix representing the robot jacobian \f$ {^e}{\bf J}_e\f$ expressed in the end-effector frame. */ void -vpSimulatorPioneer::get_eJe(vpMatrix &eJe) +vpSimulatorPioneer::get_eJe(vpMatrix &_eJe) { - eJe = vpUnicycle::get_eJe(); + _eJe = vpUnicycle::get_eJe(); } diff --git a/src/robot/simulator-robot/vpSimulatorPioneer.h b/src/robot/simulator-robot/vpSimulatorPioneer.h index d7854605b5e91d6130b402693de98c057d62e7eb..1357e2b72ec0ef148e537c1a5fdbc38ee8803370 100644 --- a/src/robot/simulator-robot/vpSimulatorPioneer.h +++ b/src/robot/simulator-robot/vpSimulatorPioneer.h @@ -3,7 +3,7 @@ * $Id: vpSimulatorPioneer.h 2456 2010-01-07 10:33:12Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/robot/simulator-robot/vpSimulatorPioneerPan.cpp b/src/robot/simulator-robot/vpSimulatorPioneerPan.cpp index 791333f5b4164e02e522faff6ea5c6f2cf45bfab..25c82817dc4163674d6e5455da46ab7ae34b3576 100644 --- a/src/robot/simulator-robot/vpSimulatorPioneerPan.cpp +++ b/src/robot/simulator-robot/vpSimulatorPioneerPan.cpp @@ -3,7 +3,7 @@ * $Id: vpSimulatorPioneerPan.cpp 2456 2010-01-07 10:33:12Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -62,7 +62,7 @@ setSamplingTime(). */ -vpSimulatorPioneerPan::vpSimulatorPioneerPan() +vpSimulatorPioneerPan::vpSimulatorPioneerPan() : wMc_(), wMm_(), xm_(0), ym_(0), theta_(0), q_pan_() { init() ; } @@ -107,13 +107,13 @@ vpSimulatorPioneerPan::~vpSimulatorPioneerPan() Get the robot jacobian expressed in the end-effector frame. The jacobian expression is given in vpPioneerPan class. - \param eJe : A 6 by 3 matrix representing the robot jacobian \f$ {^e}{\bf + \param _eJe : A 6 by 3 matrix representing the robot jacobian \f$ {^e}{\bf J}_e\f$ expressed in the end-effector frame. */ void -vpSimulatorPioneerPan::get_eJe(vpMatrix &eJe) +vpSimulatorPioneerPan::get_eJe(vpMatrix &_eJe) { - eJe = vpUnicycle::get_eJe(); + _eJe = vpUnicycle::get_eJe(); } /*! diff --git a/src/robot/simulator-robot/vpSimulatorPioneerPan.h b/src/robot/simulator-robot/vpSimulatorPioneerPan.h index c3facc8da855564082a12192bc7245bebedfabb3..d01e5d591d86b577dfdfeff6a3d4b767f1f7a86e 100644 --- a/src/robot/simulator-robot/vpSimulatorPioneerPan.h +++ b/src/robot/simulator-robot/vpSimulatorPioneerPan.h @@ -3,7 +3,7 @@ * $Id: vpSimulatorPioneerPan.h 2456 2010-01-07 10:33:12Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/robot/simulator-robot/vpSimulatorViper850.cpp b/src/robot/simulator-robot/vpSimulatorViper850.cpp index 91c966cfe70ddb81b27b5934a8b2e07416ba0bb8..364cea4017044c28828d368f91e5bcb7820ccddb 100644 --- a/src/robot/simulator-robot/vpSimulatorViper850.cpp +++ b/src/robot/simulator-robot/vpSimulatorViper850.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpSimulatorViper850.cpp 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpSimulatorViper850.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -50,21 +50,24 @@ #include <cmath> // std::fabs #include <limits> // numeric_limits #include <string> -#if defined(WIN32) || defined(VISP_HAVE_PTHREAD) +#if defined(_WIN32) || defined(VISP_HAVE_PTHREAD) const double vpSimulatorViper850::defaultPositioningVelocity = 25.0; /*! Basic constructor */ -vpSimulatorViper850::vpSimulatorViper850():vpRobotWireFrameSimulator(), vpViper850() +vpSimulatorViper850::vpSimulatorViper850() + : vpRobotWireFrameSimulator(), vpViper850(), + q_prev_getdis(), first_time_getdis(true), positioningVelocity(defaultPositioningVelocity), + zeroPos(), reposPos(), toolCustom(false), arm_dir() { init(); initDisplay(); tcur = vpTime::measureTimeMs(); - #if defined(WIN32) + #if defined(_WIN32) mutex_fMi = CreateMutex(NULL,FALSE,NULL); mutex_artVel = CreateMutex(NULL,FALSE,NULL); mutex_artCoord = CreateMutex(NULL,FALSE,NULL); @@ -99,17 +102,20 @@ vpSimulatorViper850::vpSimulatorViper850():vpRobotWireFrameSimulator(), vpViper8 /*! Constructor used to enable or disable the external view of the robot. - \param display : When true, enables the display of the external view. + \param do_display : When true, enables the display of the external view. */ -vpSimulatorViper850::vpSimulatorViper850(bool display):vpRobotWireFrameSimulator(display) +vpSimulatorViper850::vpSimulatorViper850(bool do_display) + : vpRobotWireFrameSimulator(do_display), + q_prev_getdis(), first_time_getdis(true), positioningVelocity(defaultPositioningVelocity), + zeroPos(), reposPos(), toolCustom(false), arm_dir() { init(); initDisplay(); tcur = vpTime::measureTimeMs(); - #if defined(WIN32) + #if defined(_WIN32) mutex_fMi = CreateMutex(NULL,FALSE,NULL); mutex_artVel = CreateMutex(NULL,FALSE,NULL); mutex_artCoord = CreateMutex(NULL,FALSE,NULL); @@ -148,7 +154,7 @@ vpSimulatorViper850::~vpSimulatorViper850() { robotStop = true; - #if defined(WIN32) + #if defined(_WIN32) WaitForSingleObject(hThread,INFINITE); CloseHandle(hThread); CloseHandle(mutex_fMi); @@ -276,15 +282,15 @@ vpSimulatorViper850::initDisplay() \param tool : Tool to use. - \param projModel : Projection model associated to the camera. + \param proj_model : Projection model associated to the camera. \sa vpCameraParameters, init() */ void vpSimulatorViper850::init (vpViper850::vpToolType tool, - vpCameraParameters::vpCameraParametersProjType projModel) + vpCameraParameters::vpCameraParametersProjType proj_model) { - this->projModel = projModel; + this->projModel = proj_model; // Use here default values of the robot constant parameters. switch (tool) { @@ -383,30 +389,30 @@ vpSimulatorViper850::getCameraParameters (vpCameraParameters &cam, Get the current intrinsic camera parameters obtained by calibration. \param cam : In output, camera parameters to fill. - \param I : A B&W image send by the current camera in use. + \param I_ : A B&W image send by the current camera in use. \warning The image size must be : 640x480 ! */ void vpSimulatorViper850::getCameraParameters (vpCameraParameters &cam, - const vpImage<unsigned char> &I) + const vpImage<unsigned char> &I_) { - getCameraParameters(cam,I.getWidth(),I.getHeight()); + getCameraParameters(cam,I_.getWidth(),I_.getHeight()); } /*! Get the current intrinsic camera parameters obtained by calibration. \param cam : In output, camera parameters to fill. - \param I : A B&W image send by the current camera in use. + \param I_ : A B&W image send by the current camera in use. \warning The image size must be : 640x480 ! */ void vpSimulatorViper850::getCameraParameters (vpCameraParameters &cam, - const vpImage<vpRGBa> &I) + const vpImage<vpRGBa> &I_) { - getCameraParameters(cam,I.getWidth(),I.getHeight()); + getCameraParameters(cam,I_.getWidth(),I_.getHeight()); } @@ -689,7 +695,7 @@ vpSimulatorViper850::compute_fMi() // fMit[7] = fMit[6] * cMe; vpViper::get_fMc(q,fMit[7]); - #if defined(WIN32) + #if defined(_WIN32) WaitForSingleObject(mutex_fMi,INFINITE); for (int i = 0; i < 8; i++) fMi[i] = fMit[i]; @@ -937,24 +943,24 @@ vpSimulatorViper850::computeArticularVelocity() { case vpRobot::CAMERA_FRAME : { - vpMatrix eJe; + vpMatrix eJe_; vpVelocityTwistMatrix eVc(eMc); - vpViper850::get_eJe(articularCoordinates,eJe); - eJe = eJe.pseudoInverse(); + vpViper850::get_eJe(articularCoordinates,eJe_); + eJe_ = eJe_.pseudoInverse(); if (singularityManagement) - singularityTest(articularCoordinates,eJe); - articularVelocity = eJe*eVc*velocityframe; + singularityTest(articularCoordinates,eJe_); + articularVelocity = eJe_*eVc*velocityframe; set_artVel (articularVelocity); break; } case vpRobot::REFERENCE_FRAME : { - vpMatrix fJe; - vpViper850::get_fJe(articularCoordinates,fJe); - fJe = fJe.pseudoInverse(); + vpMatrix fJe_; + vpViper850::get_fJe(articularCoordinates,fJe_); + fJe_ = fJe_.pseudoInverse(); if (singularityManagement) - singularityTest(articularCoordinates,fJe); - articularVelocity = fJe*velocityframe; + singularityTest(articularCoordinates,fJe_); + articularVelocity = fJe_*velocityframe; set_artVel (articularVelocity); break; } @@ -1062,10 +1068,10 @@ vpSimulatorViper850::getVelocity (const vpRobot::vpControlFrameType frame, vpCol { case vpRobot::CAMERA_FRAME : { - vpMatrix eJe; + vpMatrix eJe_; vpVelocityTwistMatrix cVe(eMc); - vpViper850::get_eJe(articularCoordinates,eJe); - vel = cVe*eJe*articularVelocity; + vpViper850::get_eJe(articularCoordinates,eJe_); + vel = cVe*eJe_*articularVelocity; break ; } case vpRobot::ARTICULAR_FRAME : @@ -1075,9 +1081,9 @@ vpSimulatorViper850::getVelocity (const vpRobot::vpControlFrameType frame, vpCol } case vpRobot::REFERENCE_FRAME : { - vpMatrix fJe; - vpViper850::get_fJe(articularCoordinates,fJe); - vel = fJe*articularVelocity; + vpMatrix fJe_; + vpViper850::get_fJe(articularCoordinates,fJe_); + vel = fJe_*articularVelocity; break ; } case vpRobot::MIXT_FRAME : @@ -1093,6 +1099,29 @@ vpSimulatorViper850::getVelocity (const vpRobot::vpControlFrameType frame, vpCol } } +/*! + Get the robot time stamped velocities. + + \param frame : Frame in wich velocities are mesured. + + \param vel : Measured velocities. Translations are expressed in m/s + and rotations in rad/s. + + \param timestamp : Unix time in second since January 1st 1970. + + \warning In camera frame, reference frame and mixt frame, the representation + of the rotation is ThetaU. In that cases, \f$velocity = [\dot x, \dot y, \dot + z, \dot {\theta U}_x, \dot {\theta U}_y, \dot {\theta U}_z]\f$. + + \sa getVelocity(const vpRobot::vpControlFrameType frame, vpColVector & vel) +*/ +void +vpSimulatorViper850::getVelocity (const vpRobot::vpControlFrameType frame, vpColVector & vel, double ×tamp) +{ + timestamp = vpTime::measureTimeSecond(); + getVelocity(frame, vel); +} + /*! Get the robot velocities. @@ -1138,12 +1167,33 @@ int main() vpColVector vpSimulatorViper850::getVelocity (vpRobot::vpControlFrameType frame) { - vpColVector velocity(6); - getVelocity (frame, velocity); + vpColVector vel(6); + getVelocity (frame, vel); - return velocity; + return vel; } +/*! + Get the time stamped robot velocities. + + \param frame : Frame in wich velocities are mesured. + + \param timestamp : Unix time in second since January 1st 1970. + + \return Measured velocities. Translations are expressed in m/s + and rotations in rad/s. + + \sa getVelocity(vpRobot::vpControlFrameType frame) +*/ +vpColVector +vpSimulatorViper850::getVelocity (vpRobot::vpControlFrameType frame, double ×tamp) +{ + timestamp = vpTime::measureTimeSecond(); + vpColVector vel(6); + getVelocity (frame, vel); + + return vel; +} void vpSimulatorViper850::findHighestPositioningSpeed(vpColVector &q) @@ -1266,10 +1316,10 @@ vpSimulatorViper850::setPosition(const vpRobot::vpControlFrameType frame,const v vpRotationMatrix cRc2(rxyz); vpHomogeneousMatrix cMc2(txyz, cRc2); - vpHomogeneousMatrix fMc; - vpViper850::get_fMc(articularCoordinates, fMc); + vpHomogeneousMatrix fMc_; + vpViper850::get_fMc(articularCoordinates, fMc_); - vpHomogeneousMatrix fMc2 = fMc * cMc2; + vpHomogeneousMatrix fMc2 = fMc_ * cMc2; do { @@ -1339,13 +1389,13 @@ vpSimulatorViper850::setPosition(const vpRobot::vpControlFrameType frame,const v } vpRotationMatrix fRc(rxyz); - vpHomogeneousMatrix fMc(txyz, fRc); + vpHomogeneousMatrix fMc_(txyz, fRc); do { articularCoordinates = get_artCoord(); qdes = articularCoordinates; - nbSol = getInverseKinematics(fMc, qdes, verbose_); + nbSol = getInverseKinematics(fMc_, qdes, verbose_); if (nbSol > 0) { error = qdes - articularCoordinates; @@ -1573,8 +1623,8 @@ int main() } \endcode - \sa setPosition(const vpRobot::vpControlFrameType frame, const - vpColVector & r) + \sa getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q, double ×tamp) + \sa setPosition(const vpRobot::vpControlFrameType frame, const vpColVector & r) */ void @@ -1598,15 +1648,15 @@ vpSimulatorViper850::getPosition(const vpRobot::vpControlFrameType frame, vpColV case vpRobot::REFERENCE_FRAME: { - vpHomogeneousMatrix fMc; - vpViper::get_fMc (get_artCoord(), fMc); + vpHomogeneousMatrix fMc_; + vpViper::get_fMc (get_artCoord(), fMc_); vpRotationMatrix fRc; - fMc.extract(fRc); + fMc_.extract(fRc); vpRxyzVector rxyz(fRc); vpTranslationVector txyz; - fMc.extract(txyz); + fMc_.extract(txyz); for (unsigned int i=0; i <3; i++) { @@ -1627,6 +1677,39 @@ vpSimulatorViper850::getPosition(const vpRobot::vpControlFrameType frame, vpColV } } +/*! + + Get the current time stamped position of the robot. + + \param frame : Control frame type in which to get the position, either : + - in the camera cartesien frame, + - joint (articular) coordinates of each axes + - in a reference or fixed cartesien frame attached to the robot base + - in a mixt cartesien frame (translation in reference + frame, and rotation in camera frame) + + \param q : Measured position of the robot: + - in camera cartesien frame, a 6 dimension vector, set to 0. + + - in articular, a 6 dimension vector corresponding to the joint + position of each dof in radians. + + - in reference frame, a 6 dimension vector, the first 3 values correspond to + the translation tx, ty, tz in meters (like a vpTranslationVector), and the + last 3 values to the rx, ry, rz rotation (like a vpRxyzVector). The code + below show how to convert this position into a vpHomogenousMatrix: + + \param timestamp : Unix time in second since January 1st 1970. + + \sa getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q) + */ +void +vpSimulatorViper850::getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q, double ×tamp) +{ + timestamp = vpTime::measureTimeSecond(); + getPosition(frame, q); +} + /*! Get the current position of the robot. @@ -1640,7 +1723,7 @@ vpSimulatorViper850::getPosition(const vpRobot::vpControlFrameType frame, vpColV */ void vpSimulatorViper850::getPosition (const vpRobot::vpControlFrameType frame, - vpPoseVector &position) + vpPoseVector &position) { vpColVector posRxyz; //recupere position en Rxyz @@ -1657,6 +1740,24 @@ vpSimulatorViper850::getPosition (const vpRobot::vpControlFrameType frame, } } +/*! + + Get the current time stamped position of the robot. + + Similar as getPosition(const vpRobot::vpControlFrameType frame, vpColVector &, double &) + + The difference is here that the position is returned using a ThetaU + representation. + + */ +void +vpSimulatorViper850::getPosition(const vpRobot::vpControlFrameType frame, + vpPoseVector &position, double ×tamp) +{ + timestamp = vpTime::measureTimeSecond(); + getPosition(frame, position); +} + /*! This method enables to set the minimum and maximum joint limits for all the six axis of the robot. All the values have to be given in radian. @@ -1954,7 +2055,6 @@ int main() bool vpSimulatorViper850::readPosFile(const char *filename, vpColVector &q) { - FILE * fd ; fd = fopen(filename, "r") ; if (fd == NULL) @@ -1969,27 +2069,30 @@ vpSimulatorViper850::readPosFile(const char *filename, vpColVector &q) // Saut des lignes commencant par # if (fgets (line, FILENAME_MAX, fd) != NULL) { if ( strncmp (line, "#", 1) != 0) { - // La ligne n'est pas un commentaire - if ( strncmp (line, head, sizeof(head)-1) == 0) { - sortie = true; // Position robot trouvee. - } -// else -// return (false); // fin fichier sans position robot. + // La ligne n'est pas un commentaire + if ( strncmp (line, head, sizeof(head)-1) == 0) { + sortie = true; // Position robot trouvee. + } + // else + // return (false); // fin fichier sans position robot. } } else { + fclose(fd) ; return (false); /* fin fichier */ } - } while ( sortie != true ); // Lecture des positions q.resize(njoint); - sscanf(line, "%s %lf %lf %lf %lf %lf %lf", - dummy, - &q[0], &q[1], &q[2], - &q[3], &q[4], &q[5]); + int ret = sscanf(line, "%s %lf %lf %lf %lf %lf %lf", + dummy, + &q[0], &q[1], &q[2], &q[3], &q[4], &q[5]); + if (ret != 7) { + fclose(fd) ; + return false; + } // converts rotations from degrees into radians q.deg2rad(); @@ -2110,15 +2213,15 @@ vpSimulatorViper850::get_cVe(vpVelocityTwistMatrix &cVe) To compute \f$^e{\bf J}_e\f$, we communicate with the low level controller to get the joint position of the robot. - \param eJe : Robot jacobian \f$^e{\bf J}_e\f$ expressed in the + \param eJe_ : Robot jacobian \f$^e{\bf J}_e\f$ expressed in the end-effector frame. */ void -vpSimulatorViper850::get_eJe(vpMatrix &eJe) +vpSimulatorViper850::get_eJe(vpMatrix &eJe_) { try { - vpViper850::get_eJe(get_artCoord(), eJe) ; + vpViper850::get_eJe(get_artCoord(), eJe_) ; } catch(...) { @@ -2134,16 +2237,16 @@ vpSimulatorViper850::get_eJe(vpMatrix &eJe) To compute \f$^f{\bf J}_e\f$, we communicate with the low level controller to get the joint position of the robot. - \param fJe : Robot jacobian \f$^f{\bf J}_e\f$ expressed in the + \param fJe_ : Robot jacobian \f$^f{\bf J}_e\f$ expressed in the reference frame. */ void -vpSimulatorViper850::get_fJe(vpMatrix &fJe) +vpSimulatorViper850::get_fJe(vpMatrix &fJe_) { try { vpColVector articularCoordinates = get_artCoord(); - vpViper850::get_fJe(articularCoordinates, fJe) ; + vpViper850::get_fJe(articularCoordinates, fJe_) ; } catch(...) { @@ -2187,26 +2290,40 @@ void vpSimulatorViper850::initArms() { // set scene_dir from #define VISP_SCENE_DIR if it exists - std::string scene_dir; + std::string scene_dir_; if (vpIoTools::checkDirectory(VISP_SCENES_DIR) == true) // directory exists - scene_dir = VISP_SCENES_DIR; + scene_dir_ = VISP_SCENES_DIR; else { try { - scene_dir = vpIoTools::getenv("VISP_SCENES_DIR"); - std::cout << "The simulator uses data from VISP_SCENES_DIR=" << scene_dir << std::endl; + scene_dir_ = vpIoTools::getenv("VISP_SCENES_DIR"); + std::cout << "The simulator uses data from VISP_SCENES_DIR=" << scene_dir_ << std::endl; } catch (...) { std::cout << "Cannot get VISP_SCENES_DIR environment variable" << std::endl; } } - char name_cam[FILENAME_MAX]; + unsigned int name_length = 30; // the size of this kind of string "/viper850_arm2.bnd" + if (scene_dir_.size() > FILENAME_MAX) + throw vpException (vpException::dimensionError, "Cannot initialize Viper850 simulator"); - strcpy(name_cam, scene_dir.c_str()); + unsigned int full_length = (unsigned int)scene_dir_.size() + name_length; + if (full_length > FILENAME_MAX) + throw vpException (vpException::dimensionError, "Cannot initialize Viper850 simulator"); + + char *name_cam = new char [full_length]; + + strcpy(name_cam, scene_dir_.c_str()); strcat(name_cam,"/camera.bnd"); set_scene(name_cam,&camera,cameraFactor); - char name_arm[FILENAME_MAX]; + if (arm_dir.size() > FILENAME_MAX) + throw vpException (vpException::dimensionError, "Cannot initialize Viper850 simulator"); + full_length = (unsigned int)arm_dir.size() + name_length; + if (full_length > FILENAME_MAX) + throw vpException (vpException::dimensionError, "Cannot initialize Viper850 simulator"); + + char *name_arm = new char [full_length]; strcpy(name_arm, arm_dir.c_str()); strcat(name_arm,"/viper850_arm1.bnd"); set_scene(name_arm, robotArms, 1.0); @@ -2241,14 +2358,17 @@ vpSimulatorViper850::initArms() // sceneInitialized = true; // displayObject = true; displayCamera = true; + + delete [] name_cam; + delete [] name_arm; } void -vpSimulatorViper850::getExternalImage(vpImage<vpRGBa> &I) +vpSimulatorViper850::getExternalImage(vpImage<vpRGBa> &I_) { bool changed = false; - vpHomogeneousMatrix displacement = navigation(I,changed); + vpHomogeneousMatrix displacement = navigation(I_,changed); //if (displacement[2][3] != 0) if (std::fabs(displacement[2][3]) > std::numeric_limits<double>::epsilon()) @@ -2265,13 +2385,13 @@ vpSimulatorViper850::getExternalImage(vpImage<vpRGBa> &I) if( (std::fabs(px_ext-1.) > vpMath::maximum(px_ext,1.)*std::numeric_limits<double>::epsilon()) && (std::fabs(py_ext-1) > vpMath::maximum(py_ext,1.)*std::numeric_limits<double>::epsilon())) { - u = (double)I.getWidth()/(2*px_ext); - v = (double)I.getHeight()/(2*py_ext); + u = (double)I_.getWidth()/(2*px_ext); + v = (double)I_.getHeight()/(2*py_ext); } else { - u = (double)I.getWidth()/(vpMath::minimum(I.getWidth(),I.getHeight())); - v = (double)I.getHeight()/(vpMath::minimum(I.getWidth(),I.getHeight())); + u = (double)I_.getWidth()/(vpMath::minimum(I_.getWidth(),I_.getHeight())); + v = (double)I_.getHeight()/(vpMath::minimum(I_.getWidth(),I_.getHeight())); } float w44o[4][4],w44cext[4][4],x,y,z; @@ -2291,22 +2411,22 @@ vpSimulatorViper850::getExternalImage(vpImage<vpRGBa> &I) get_fMi(fMit); vp2jlc_matrix(vpHomogeneousMatrix(0,0,0,0,0,0),w44o); - display_scene(w44o,robotArms[0],I, curColor); + display_scene(w44o,robotArms[0],I_, curColor); vp2jlc_matrix(fMit[0],w44o); - display_scene(w44o,robotArms[1],I, curColor); + display_scene(w44o,robotArms[1],I_, curColor); vp2jlc_matrix(fMit[1],w44o); - display_scene(w44o,robotArms[2],I, curColor); + display_scene(w44o,robotArms[2],I_, curColor); vp2jlc_matrix(fMit[2],w44o); - display_scene(w44o,robotArms[3],I, curColor); + display_scene(w44o,robotArms[3],I_, curColor); vp2jlc_matrix(fMit[3],w44o); - display_scene(w44o,robotArms[4],I, curColor); + display_scene(w44o,robotArms[4],I_, curColor); vp2jlc_matrix(fMit[6],w44o); - display_scene(w44o,robotArms[5],I, curColor); + display_scene(w44o,robotArms[5],I_, curColor); if (displayCamera) { @@ -2315,13 +2435,13 @@ vpSimulatorViper850::getExternalImage(vpImage<vpRGBa> &I) cMe = cMe.inverse(); cMe = fMit[6] * cMe; vp2jlc_matrix(cMe,w44o); - display_scene(w44o,camera, I, camColor); + display_scene(w44o,camera, I_, camColor); } if (displayObject) { vp2jlc_matrix(fMo,w44o); - display_scene(w44o,scene,I, curColor); + display_scene(w44o,scene,I_, curColor); } } @@ -2336,23 +2456,23 @@ vpSimulatorViper850::getExternalImage(vpImage<vpRGBa> &I) \f${^f}{\bf M}_c = {^f}{\bf M}_o \; ({^c}{\bf M}{_o})^{-1}\f$, and from the inverse kinematics set the joint positions \f${\bf q}\f$ that corresponds to the \f${^f}{\bf M}_c\f$ transformation. - \param cMo : the desired pose of the camera. + \param cMo_ : the desired pose of the camera. \return false if the robot kinematics is not able to reach the cMo position. */ bool -vpSimulatorViper850::initialiseCameraRelativeToObject(const vpHomogeneousMatrix &cMo) +vpSimulatorViper850::initialiseCameraRelativeToObject(const vpHomogeneousMatrix &cMo_) { vpColVector stop(6); bool status = true; stop = 0; set_artVel(stop); set_velocity(stop); - vpHomogeneousMatrix fMc; - fMc = fMo * cMo.inverse(); + vpHomogeneousMatrix fMc_; + fMc_ = fMo * cMo_.inverse(); vpColVector articularCoordinates = get_artCoord(); - unsigned int nbSol = getInverseKinematics(fMc, articularCoordinates, verbose_); + unsigned int nbSol = getInverseKinematics(fMc_, articularCoordinates, verbose_); if (nbSol == 0) { status = false; @@ -2379,10 +2499,10 @@ vpSimulatorViper850::initialiseCameraRelativeToObject(const vpHomogeneousMatrix \f${^f}{\bf M}_o = {^f}{\bf M}_c \; {^c}{\bf M}_o\f$ where \f$ {^f}{\bf M}_c = f({\bf q})\f$ with \f${\bf q}\f$ the robot joint position - \param cMo : the desired pose of the camera. + \param cMo_ : the desired pose of the camera. */ void -vpSimulatorViper850::initialiseObjectRelativeToCamera(const vpHomogeneousMatrix &cMo) +vpSimulatorViper850::initialiseObjectRelativeToCamera(const vpHomogeneousMatrix &cMo_) { vpColVector stop(6); stop = 0; @@ -2390,7 +2510,7 @@ vpSimulatorViper850::initialiseObjectRelativeToCamera(const vpHomogeneousMatrix set_velocity(stop); vpHomogeneousMatrix fMit[8]; get_fMi(fMit); - fMo = fMit[7] * cMo; + fMo = fMit[7] * cMo_; } #endif diff --git a/src/robot/simulator-robot/vpSimulatorViper850.h b/src/robot/simulator-robot/vpSimulatorViper850.h index c20c1a6b885f9d11c6366dc9f52f96e96fc6917e..6cccdcacb49564c9110c45b8833729d86a707d79 100644 --- a/src/robot/simulator-robot/vpSimulatorViper850.h +++ b/src/robot/simulator-robot/vpSimulatorViper850.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpSimulatorViper850.h 4252 2013-05-14 13:44:49Z fspindle $ + * $Id: vpSimulatorViper850.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -52,7 +52,7 @@ #include <visp/vpRobotWireFrameSimulator.h> #include <visp/vpViper850.h> #include <string> -#if defined(WIN32) || defined(VISP_HAVE_PTHREAD) +#if defined(_WIN32) || defined(VISP_HAVE_PTHREAD) /*! \class vpSimulatorViper850 @@ -236,13 +236,15 @@ class VISP_EXPORT vpSimulatorViper850 : public vpRobotWireFrameSimulator, public vpColVector &displacement); void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q); - void getPosition (const vpRobot::vpControlFrameType frame, - vpPoseVector &position); + void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q, double ×tamp); + void getPosition(const vpRobot::vpControlFrameType frame, vpPoseVector &position); + void getPosition(const vpRobot::vpControlFrameType frame, vpPoseVector &position, double ×tamp); double getPositioningVelocity (void){return positioningVelocity;} - void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q); + void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q, double ×tamp); vpColVector getVelocity (const vpRobot::vpControlFrameType frame); + vpColVector getVelocity (const vpRobot::vpControlFrameType frame, double ×tamp); void get_cMe(vpHomogeneousMatrix &cMe); void get_cVe(vpVelocityTwistMatrix &cVe); @@ -269,7 +271,7 @@ class VISP_EXPORT vpSimulatorViper850 : public vpRobotWireFrameSimulator, public const double pos5, const double pos6); void setPosition(const char *filename); - void setPositioningVelocity (const double velocity) {positioningVelocity = velocity;} + void setPositioningVelocity (const double vel) {positioningVelocity = vel;} vpRobot::vpRobotStateType setRobotState (const vpRobot::vpRobotStateType newState); void setVelocity (const vpRobot::vpControlFrameType frame, const vpColVector & velocity); @@ -283,7 +285,7 @@ protected: void getExternalImage(vpImage<vpRGBa> &I); inline void get_fMi(vpHomogeneousMatrix *fMit) { -#if defined(WIN32) +#if defined(_WIN32) WaitForSingleObject(mutex_fMi,INFINITE); for (int i = 0; i < 8; i++) fMit[i] = fMi[i]; diff --git a/src/servo/vpAdaptativeGain.cpp b/src/servo/vpAdaptativeGain.cpp deleted file mode 100644 index 62918d4ebaad8ec76697694dc18318054cf5f51a..0000000000000000000000000000000000000000 --- a/src/servo/vpAdaptativeGain.cpp +++ /dev/null @@ -1,360 +0,0 @@ -/**************************************************************************** - * - * $Id: vpAdaptativeGain.cpp 4317 2013-07-17 09:40:17Z 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: - * Adaptative gain. - * - * Authors: - * Nicolas Mansard - * - *****************************************************************************/ -/*! - \file vpAdaptativeGain.cpp - - \brief Adaptative gain. The content of this file is deprecated. You - should better use vpAdaptiveGain. - -*/ - -#include <visp/vpConfig.h> - -#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS - -/* --- VISP --- */ -#include <visp/vpAdaptativeGain.h> -#include <visp/vpColVector.h> -#include <visp/vpDebug.h> - -#include <iostream> -#include <cmath> // std::fabs -#include <limits> // numeric_limits - -const double vpAdaptativeGain::DEFAULT_LAMBDA_ZERO = 1.666; -const double vpAdaptativeGain::DEFAULT_LAMBDA_INFINI = 0.1666; -const double vpAdaptativeGain::DEFAULT_LAMBDA_PENTE = 1.666; - -/* -------------------------------------------------------------------------- */ -/* --- CONSTRUCTION --------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -/*! - \deprecated This class is deprecated. You should use - vpAdaptive class instead. - Basic constructor which initializes the parameters with a default value. -*/ -vpAdaptativeGain:: -vpAdaptativeGain (void) - : - coeff_a (), - coeff_b (), - coeff_c () -{ - vpDEBUG_TRACE (10, "# Entree constructeur par default."); - this ->initFromVoid (); - - vpDEBUG_TRACE (10, "# Sortie constructeur par default."); - return; -} - -/* -------------------------------------------------------------------------- */ -/* --- INIT ----------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -/*! - Initializes the parameters to have a constant gain. - Thus \f$ a = 0 \f$, \f$ b = 1 \f$ and \f$ c = lambda \f$ - - \param lambda : the expected constant gain. -*/ -void vpAdaptativeGain:: -initFromConstant (const double lambda) -{ - vpDEBUG_TRACE (10, "# Entree."); - - this ->coeff_a = 0; - this ->coeff_b = 1; - this ->coeff_c = lambda; - - vpDEBUG_TRACE (10, "# Sortie."); - return; -} - - -/*! - Initializes the parameters with the default value : - - \f$ lambda(0) = 1.666 \f$ - - \f$ lambda(inf) = 0.1666 \f$ - - \f$ lambda'(0) = 1.666 \f$ -*/ -void vpAdaptativeGain:: -initFromVoid (void) -{ - vpDEBUG_TRACE (10, "# Entree."); - - this ->initStandard (vpAdaptativeGain::DEFAULT_LAMBDA_ZERO, - vpAdaptativeGain::DEFAULT_LAMBDA_INFINI, - vpAdaptativeGain::DEFAULT_LAMBDA_PENTE); - - vpDEBUG_TRACE (10, "# Sortie."); - return; -} - - -/*! - Computes the parameters thanks to the given \f$ lambda(0)\f$, \f$ lambda(inf)\f$ and \f$ lambda'(0)\f$. - - \f$ lambda(0)\f$ represents the gain in 0, \f$ lambda(inf)\f$ represents the gain to infinity and \f$ lambda'(0)\f$ represents the slope in 0. - - \param en_zero : the expected gain in 0. - \param en_infini : the expected gain to infinity. - \param pente_en_zero : the expected slope in 0. -*/ -void vpAdaptativeGain:: -initStandard (const double en_zero, - const double en_infini, - const double pente_en_zero) -{ - vpDEBUG_TRACE (10, "# Entree."); - - this ->coeff_a = en_zero - en_infini; - //if (0 == this ->coeff_a) - if (std::fabs(this ->coeff_a) <= std::numeric_limits<double>::epsilon()) - { - this ->coeff_b = 0; - } - else - { - this ->coeff_b = pente_en_zero / ( this ->coeff_a); - } - this ->coeff_c = en_infini; - - vpDEBUG_TRACE (10, "# Sortie :a,b,c= %.3f,%.3f,%.3f.", - this ->coeff_a, this ->coeff_b, this ->coeff_c); - return; -} - - - -/* -------------------------------------------------------------------------- */ -/* --- MODIFICATOR ---------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -/*! - Sets the parameters in order to obtain a constant gain equal to the gain in 0. - - \return It returns the value of the computed constant gain. -*/ -double vpAdaptativeGain:: -setConstant (void) -{ - vpDEBUG_TRACE (10, "# Entree."); - - double res = this ->coeff_a + this ->coeff_c; - - this ->coeff_a = 0; - this ->coeff_b = 1; - this ->coeff_c = res; - - vpDEBUG_TRACE (10, "# Sortie: %.3f.", res); - return res; -} - -/* -------------------------------------------------------------------------- */ -/* --- VALEUR --------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -/*! - Computes the value of the adaptive gain \f$\lambda\f$ corresponding to - the norm of the task function. The formula is the following: - - \f[\lambda = a * exp(-b*val_e) + c\f] - - \param val_e : Norm of the task function \f$\mid s - s^*\mid\f$. - - \return It returns the value of the computed gain. -*/ -double vpAdaptativeGain:: -value_const (const double val_e) const -{ - vpDEBUG_TRACE (10, "# Entree."); - - double res = this ->coeff_a * exp (- this ->coeff_b * val_e) - + this ->coeff_c; - - vpDEBUG_TRACE (10, "# Sortie: %.3f.", res); - return res; -} - -/*! - Gets the value of the gain at infinity (ie the value of \f$ c \f$). - - \return It returns the value of the gain at infinity (ie the value of \f$ c \f$). - */ -double vpAdaptativeGain:: -limitValue_const (void) const -{ - vpDEBUG_TRACE (10, "# Entree."); - - double res = this ->coeff_c; - - vpDEBUG_TRACE (10, "# Sortie: %.3f.", res); - return res; -} - - - -/*! - Computes the value of the adaptive gain \f$\lambda\f$ corresponding to - the norm of the task function and stores it as a parameter of the class. - The formula used for the gain computation is the following: - - \f[\lambda = a * exp(-b*val_e) + c\f] - - \param val_e : Norm of the task function \f$\mid s - s^*\mid\f$. - - \return It returns the value of the computed gain. -*/ -double vpAdaptativeGain:: -value (const double val_e) const -{ - vpDEBUG_TRACE (10, "# Entree."); - - this ->lambda = this ->value_const (val_e); - - vpDEBUG_TRACE (10, "# Sortie: %.3f.", this ->lambda); - return lambda; -} - - -/*! - Gets the value of the gain at infinity (ie the value of \f$ c \f$)and stores it - as a parameter of the class. - - \return It returns the value of the gain at infinity (ie the value of \f$ c \f$). - */ -double vpAdaptativeGain:: -limitValue (void) const -{ - vpDEBUG_TRACE (10, "# Entree."); - - this ->lambda = this ->limitValue_const (); - - vpDEBUG_TRACE (10, "# Sortie: %.3f.", this ->lambda); - return lambda; -} - -/* -------------------------------------------------------------------------- */ -/* --- ACCESSORS ------------------------------------------------------------ */ -/* -------------------------------------------------------------------------- */ - - - -// double vpAdaptativeGain:: -// getLastValue (void) const -// { -// return this ->lambda; -// } - -/*! - Operator which calls the value(double val_e) method with \e val_e in parameter in order - to compute the adaptative gain corresponding to \e val_e. - - \param val_e : Norm of the task function \f$\mid s - s^*\mid\f$. - - \return It returns the value of the computed gain. -*/ -double vpAdaptativeGain:: -operator() (const double val_e) const -{ - return this ->value (val_e); -} - -/*! - Gets the value of the gain at infinity (ie the value of \f$ c \f$). - - \return It returns the value of the gain at infinity (ie the value of \f$ c \f$). - */ -double vpAdaptativeGain:: -operator() (void) const -{ - return this ->limitValue (); -} - -/*! - Operator which calls the value(double val_e) method with the infinity norm of \e e in parameter in order - to compute the adaptative gain corresponding to \f$ |e| \f$. - - \param e : the task function \f$\mid s - s^*\mid\f$. - - \return It returns the value of the computed gain. -*/ -double vpAdaptativeGain:: -operator() (const vpColVector & e) const -{ - return this ->value (e .infinityNorm()); -} - - -// double operator() (double val_e) const; -// double operator() (const CColVector & e) const; - -/* -------------------------------------------------------------------------- */ -/* --- OUTPUT --------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - - - -/*! - Prints the adaptative gain coefficients. It prints the gain in 0, - the gain to infinity and the slope in 0. - - \param os : The stream where to print the adaptative gain parameters. - \param lambda : The adaptative gain containing the parameters to print. -*/ -std::ostream& -operator<< (std::ostream &os, const vpAdaptativeGain& lambda) -{ - os << "Zero= " << lambda .coeff_a + lambda .coeff_c - << "\tInf= " << lambda .coeff_c - << "\tDeriv= " << lambda .coeff_a * lambda .coeff_b; - - return os; -} - -#endif - -/* - * Local variables: - * c-basic-offset: 4 - * End: - */ diff --git a/src/servo/vpAdaptativeGain.h b/src/servo/vpAdaptativeGain.h deleted file mode 100644 index 7b638911953303bfb8a349bbf673338ae5597b8a..0000000000000000000000000000000000000000 --- a/src/servo/vpAdaptativeGain.h +++ /dev/null @@ -1,190 +0,0 @@ -/**************************************************************************** - * - * $Id: vpAdaptativeGain.h 4317 2013-07-17 09:40:17Z 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: - * Adaptative gain. - * - * Authors: - * Nicolas Mansard - * - *****************************************************************************/ -/*! - \file vpAdaptativeGain.h - - \brief Adaptative gain. The content of this file is deprecated. You - should better use vpAdaptiveGain. -*/ - -#ifndef __VP_ADAPTATIVE_GAIN_H -#define __VP_ADAPTATIVE_GAIN_H - -#include <visp/vpConfig.h> -#include <iostream> - -#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS - -class vpColVector; -/*! - \class vpAdaptativeGain - - \ingroup VsTask - - \brief Adaptative gain computation. - - \deprecated This class is deprecated. You should use - vpAdaptive class instead. - - The formula used to compute the gain is the following : - - \f[ lambda (x) = a * exp (-b*x) + c \f] - - where \f$ a \f$, \f$ b \f$ and \f$ c \f$ are parameters which must be set - and \f$ x \f$ is the vector error of the task. - - By default, the parameters are set with default values: - \f[ a = lambda(0) - lambda(inf) \f] - \f[ b = lambda'(0) / a \f] - \f[ c = lambda(inf) \f] - - with \f$ lambda(0) = 1.666 \f$, \f$ lambda(inf) = 0.1666 \f$ and \f$ lambda'(0) = 1.666 \f$. - - \f$ lambda(0)\f$ represents the gain in 0, \f$ lambda(inf)\f$ represents the gain to infinity and \f$ lambda'(0)\f$ represents the slope in 0. - -*/ - -class VISP_EXPORT vpAdaptativeGain -{ - -public: /* constantes */ - - static const double DEFAULT_LAMBDA_ZERO; - static const double DEFAULT_LAMBDA_INFINI; - static const double DEFAULT_LAMBDA_PENTE; - - -private: /* Attributs*/ - /* Coefficient de la fonction de calcul de lambda. - * lambda (x) = a * exp (-b*x) + c. */ - double coeff_a; - double coeff_b; - double coeff_c; - - /* Derniere valeur calculee. */ - mutable double lambda; - - - -public: /* Methodes*/ - - /* --- CONSTRUCTOR -------------------------------------------------------- */ - - vp_deprecated vpAdaptativeGain (void); - - /* --- INIT --------------------------------------------------------------- */ - void initFromConstant (double lambda); - void initFromVoid (void); - void initStandard (double en_zero, - double en_infini, - double pente_en_zero); - - - /* --- MODIFIORS ---------------------------------------------------------- */ - double setConstant (void); - - - /* --- COMPUTE ------------------------------------------------------------ */ - /* \brief Calcule la valeur de lambda au point courrant. - * - * Determine la valeur du lambda adaptatif en fonction de la valeur - * de la norme de la fonction de tache e par extrapolation exponentielle. - * La fonction est : (en_infini - en_zero) * exp (-pente * ||e|| ) + en_infini. - * On a bien : - * - lambda(10^5) = en_infini ; - * - lambda(0) = en_zero ; - * - lambda(x ~ 0) ~ - pente * x + en_zero. - * \param val_e: valeur de la norme de l'erreur. - * \return: valeur de gain au point courrant. - */ - double value_const (double val_e) const; - - /* \brief Calcule la valeur de lambda au point courrant et stockage du - * resultat. - * - * La fonction calcule la valeur de lambda d'apres la valeur de la norme - * de l'erreur, comme le fait la fonction valeur_const. - * La fonction non constante stocke de plus le resultat dans this ->lambda. - * \param val_e: valeur de la norme de l'erreur. - * \return: valeur de gain au point courrant. - */ - double value (double val_e) const; - - double limitValue_const (void) const; - - double limitValue (void) const; - - /* --- ACCESSORS ---------------------------------------------------------- */ - - /*! - Gets the last adaptative gain value which was stored in the class. - - \return It returns the last adaptative gain value which was stored in the class. - */ - inline double getLastValue (void) const {return this ->lambda;} - - double operator() (double val_e) const; - - /* \brief Lance la fonction valeur avec la norme INFINIE du vecteur. */ - double operator() (const vpColVector & e) const; - - /* \brief Idem function limitValue. */ - double operator() (void) const; - - - /* --- IOSTREAM ----------------------------------------------------------- */ - - friend VISP_EXPORT std::ostream& operator<< (std::ostream &os, - const vpAdaptativeGain& lambda); -}; - -#endif - -#endif /* __VP_ADAPTATIVE_GAIN_H */ - - - - -/* - * Local variables: - * c-basic-offset: 4 - * End: - */ diff --git a/src/servo/vpAdaptiveGain.cpp b/src/servo/vpAdaptiveGain.cpp index 283fbf38164aea1519c46fcfecfeb0ebc23894ea..1e65445370cf1ddb7d533e55637690cf4dbc522e 100644 --- a/src/servo/vpAdaptiveGain.cpp +++ b/src/servo/vpAdaptiveGain.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpAdaptiveGain.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpAdaptiveGain.cpp 4641 2014-02-05 12:42:03Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -52,22 +52,26 @@ #include <limits> // numeric_limits const double vpAdaptiveGain::DEFAULT_LAMBDA_ZERO = 1.666; -const double vpAdaptiveGain::DEFAULT_LAMBDA_INFINI = 0.1666; -const double vpAdaptiveGain::DEFAULT_LAMBDA_PENTE = 1.666; +const double vpAdaptiveGain::DEFAULT_LAMBDA_INFINITY = 0.1666; +const double vpAdaptiveGain::DEFAULT_LAMBDA_SLOPE = 1.666; /* -------------------------------------------------------------------------- */ /* --- CONSTRUCTION --------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ /*! - Basic constructor which initializes the parameters with a default value. + Basic constructor which initializes all the parameters with their default value: + - \f$ \lambda(0) = 1.666 \f$ using vpAdaptiveGain::DEFAULT_LAMBDA_ZERO + - \f$ \lambda(\infty) = 0.1666 \f$ using vpAdaptiveGain::DEFAULT_LAMBDA_INFINITY + - \f$ {\dot \lambda}(0) = 1.666 \f$ using vpAdaptiveGain::DEFAULT_LAMBDA_SLOPE + */ -vpAdaptiveGain:: -vpAdaptiveGain (void) +vpAdaptiveGain::vpAdaptiveGain () : coeff_a (), coeff_b (), - coeff_c () + coeff_c (), + lambda(1.) { vpDEBUG_TRACE (10, "# Entree constructeur par default."); this ->initFromVoid (); @@ -76,24 +80,45 @@ vpAdaptiveGain (void) return; } +/*! + Constructor that initializes the gain as constant. In that case \f$\lambda(x) = c\f$. + + \param c : Value of the constant gain. +*/ +vpAdaptiveGain::vpAdaptiveGain (double c) +{ + initFromConstant(c); +} + +/*! + Constructor that initializes the gain as adaptive. + + \param gain_at_zero : the expected gain when \f$x=0\f$: \f$\lambda(0)\f$. + \param gain_at_infinity : the expected gain when \f$x=\infty\f$: \f$\lambda(\infty)\f$. + \param slope_at_zero : the expected slope of \f$\lambda(x)\f$ when \f$x=0\f$: \f${\dot \lambda}(0)\f$. + +*/ +vpAdaptiveGain::vpAdaptiveGain (double gain_at_zero, double gain_at_infinity, double slope_at_zero) +{ + initStandard(gain_at_zero, gain_at_infinity, slope_at_zero); +} + /* -------------------------------------------------------------------------- */ /* --- INIT ----------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ /*! - Initializes the parameters to have a constant gain. - Thus \f$ a = 0 \f$, \f$ b = 1 \f$ and \f$ c = lambda \f$ - - \param lambda : the expected constant gain. + Initializes the parameters to have a constant gain. In that case \f$\lambda(x) = c\f$. + + \param c : Value of the constant gain. */ -void vpAdaptiveGain:: -initFromConstant (const double lambda) +void vpAdaptiveGain::initFromConstant (const double c) { vpDEBUG_TRACE (10, "# Entree."); this ->coeff_a = 0; this ->coeff_b = 1; - this ->coeff_c = lambda; + this ->coeff_c = c; vpDEBUG_TRACE (10, "# Sortie."); return; @@ -102,18 +127,17 @@ initFromConstant (const double lambda) /*! Initializes the parameters with the default value : - - \f$ lambda(0) = 1.666 \f$ - - \f$ lambda(inf) = 0.1666 \f$ - - \f$ lambda'(0) = 1.666 \f$ + - \f$ \lambda(0) = 1.666 \f$ using vpAdaptiveGain::DEFAULT_LAMBDA_ZERO + - \f$ \lambda(\infty) = 0.1666 \f$ using vpAdaptiveGain::DEFAULT_LAMBDA_INFINITY + - \f$ {\dot \lambda}(0) = 1.666 \f$ using vpAdaptiveGain::DEFAULT_LAMBDA_SLOPE */ -void vpAdaptiveGain:: -initFromVoid (void) +void vpAdaptiveGain::initFromVoid (void) { vpDEBUG_TRACE (10, "# Entree."); this ->initStandard (vpAdaptiveGain::DEFAULT_LAMBDA_ZERO, - vpAdaptiveGain::DEFAULT_LAMBDA_INFINI, - vpAdaptiveGain::DEFAULT_LAMBDA_PENTE); + vpAdaptiveGain::DEFAULT_LAMBDA_INFINITY, + vpAdaptiveGain::DEFAULT_LAMBDA_SLOPE); vpDEBUG_TRACE (10, "# Sortie."); return; @@ -121,22 +145,19 @@ initFromVoid (void) /*! - Computes the parameters thanks to the given \f$ lambda(0)\f$, \f$ lambda(inf)\f$ and \f$ lambda'(0)\f$. - - \f$ lambda(0)\f$ represents the gain in 0, \f$ lambda(inf)\f$ represents the gain to infinity and \f$ lambda'(0)\f$ represents the slope in 0. + Set the parameters \f$\lambda(0), \lambda(\infty), {\dot \lambda}(0)\f$ used to compute \f$\lambda(x)\f$. - \param en_zero : the expected gain in 0. - \param en_infini : the expected gain to infinity. - \param pente_en_zero : the expected slope in 0. + \param gain_at_zero : the expected gain when \f$x=0\f$: \f$\lambda(0)\f$. + \param gain_at_infinity : the expected gain when \f$x=\infty\f$: \f$\lambda(\infty)\f$. + \param slope_at_zero : the expected slope of \f$\lambda(x)\f$ when \f$x=0\f$: \f${\dot \lambda}(0)\f$. */ -void vpAdaptiveGain:: -initStandard (const double en_zero, - const double en_infini, - const double pente_en_zero) +void vpAdaptiveGain::initStandard (const double gain_at_zero, + const double gain_at_infinity, + const double slope_at_zero) { vpDEBUG_TRACE (10, "# Entree."); - this ->coeff_a = en_zero - en_infini; + this ->coeff_a = gain_at_zero - gain_at_infinity; //if (0 == this ->coeff_a) if (std::fabs(this ->coeff_a) <= std::numeric_limits<double>::epsilon()) { @@ -144,9 +165,9 @@ initStandard (const double en_zero, } else { - this ->coeff_b = pente_en_zero / ( this ->coeff_a); + this ->coeff_b = slope_at_zero / ( this ->coeff_a); } - this ->coeff_c = en_infini; + this ->coeff_c = gain_at_infinity; vpDEBUG_TRACE (10, "# Sortie :a,b,c= %.3f,%.3f,%.3f.", this ->coeff_a, this ->coeff_b, this ->coeff_c); @@ -160,12 +181,12 @@ initStandard (const double en_zero, /* -------------------------------------------------------------------------- */ /*! - Sets the parameters in order to obtain a constant gain equal to the gain in 0. + Sets the internal parameters \f$a,b,c\f$ in order to obtain a constant gain equal to + the gain in 0 set through the parameter \f$\lambda(0)\f$. - \return It returns the value of the computed constant gain. + \return It returns the value of the constant gain \f$\lambda(0)\f$. */ -double vpAdaptiveGain:: -setConstant (void) +double vpAdaptiveGain::setConstant (void) { vpDEBUG_TRACE (10, "# Entree."); @@ -184,34 +205,32 @@ setConstant (void) /* -------------------------------------------------------------------------- */ /*! - Computes the value of the adaptive gain \f$\lambda\f$ corresponding to - the norm of the task function. The formula is the following: + Computes the value of the adaptive gain \f$\lambda(x)\f$ using: - \f[\lambda = a * exp(-b*val_e) + c\f] + \f[\lambda(x) = a * exp(-b*x) + c\f] - \param val_e : Norm of the task function \f$\mid s - s^*\mid\f$. + \param x : Input value to consider. During a visual servo this value can be the euclidian + norm \f$||s - s^*||\f$ or the infinity norm \f$||s - s^*||_{\infty}\f$ of the task function. \return It returns the value of the computed gain. */ -double vpAdaptiveGain:: -value_const (const double val_e) const +double vpAdaptiveGain::value_const (const double x) const { vpDEBUG_TRACE (10, "# Entree."); - double res = this ->coeff_a * exp (- this ->coeff_b * val_e) - + this ->coeff_c; + double res = this ->coeff_a * exp (- this ->coeff_b * x) + this ->coeff_c; vpDEBUG_TRACE (10, "# Sortie: %.3f.", res); return res; } /*! - Gets the value of the gain at infinity (ie the value of \f$ c \f$). + Gets the value of the gain at infinity (ie the value of \f$ \lambda(\infty) = c \f$). + Similar to limitValue() except that here the value is not stored as a parameter of the class. - \return It returns the value of the gain at infinity (ie the value of \f$ c \f$). + \return It returns the value of the gain at infinity. */ -double vpAdaptiveGain:: -limitValue_const (void) const +double vpAdaptiveGain::limitValue_const (void) const { vpDEBUG_TRACE (10, "# Entree."); @@ -221,25 +240,23 @@ limitValue_const (void) const return res; } +/*! + Computes the value of the adaptive gain \f$\lambda(x)\f$ using: + \f[\lambda(x) = a * exp(-b*x) + c\f] -/*! - Computes the value of the adaptive gain \f$\lambda\f$ corresponding to - the norm of the task function and stores it as a parameter of the class. - The formula used for the gain computation is the following: + This value is stored as a parameter of the class. - \f[\lambda = a * exp(-b*val_e) + c\f] + \param x : Input value to consider. During a visual servo this value can be the euclidian + norm \f$||s - s^*||\f$ or the infinity norm \f$||s - s^*||_{\infty}\f$ of the task function. - \param val_e : Norm of the task function \f$\mid s - s^*\mid\f$. - \return It returns the value of the computed gain. -*/ -double vpAdaptiveGain:: -value (const double val_e) const + */ +double vpAdaptiveGain::value (const double x) const { vpDEBUG_TRACE (10, "# Entree."); - this ->lambda = this ->value_const (val_e); + this ->lambda = this ->value_const (x); vpDEBUG_TRACE (10, "# Sortie: %.3f.", this ->lambda); return lambda; @@ -247,13 +264,12 @@ value (const double val_e) const /*! - Gets the value of the gain at infinity (ie the value of \f$ c \f$)and stores it + Gets the value of the gain at infinity (ie the value of \f$\lambda(\infty) = c \f$) and stores it as a parameter of the class. - \return It returns the value of the gain at infinity (ie the value of \f$ c \f$). + \return It returns the value of the gain at infinity. */ -double vpAdaptiveGain:: -limitValue (void) const +double vpAdaptiveGain:: limitValue (void) const { vpDEBUG_TRACE (10, "# Entree."); @@ -276,42 +292,42 @@ limitValue (void) const // } /*! - Operator which calls the value(double val_e) method with \e val_e in parameter in order - to compute the adaptive gain corresponding to \e val_e. + Operator that computes \f$\lambda(x)\f$. - \param val_e : Norm of the task function \f$\mid s - s^*\mid\f$. - + \param x : Input value to consider. During a visual servo this value can be the euclidian + norm \f$||s - s^*||\f$ or the infinity norm \f$||s - s^*||_{\infty}\f$ of the task function. + \return It returns the value of the computed gain. + + \sa value() */ -double vpAdaptiveGain:: -operator() (const double val_e) const +double vpAdaptiveGain::operator() (const double x) const { - return this ->value (val_e); + return this ->value (x); } /*! - Gets the value of the gain at infinity (ie the value of \f$ c \f$). + Gets the value of the gain at infinity (ie the value of \f$\lambda(\infty) = c \f$). - \return It returns the value of the gain at infinity (ie the value of \f$ c \f$). + \return It returns the value of the gain at infinity. + + \sa limitValue() */ -double vpAdaptiveGain:: -operator() (void) const +double vpAdaptiveGain::operator() (void) const { return this ->limitValue (); } /*! - Operator which calls the value(double val_e) method with the infinity norm of \e e in parameter in order - to compute the adaptive gain corresponding to \f$ |e| \f$. + Operator which computes \f$\lambda({||x||}_{\infty})\f$. - \param e : the task function \f$\mid s - s^*\mid\f$. + \param x : Input vector to consider. \return It returns the value of the computed gain. */ -double vpAdaptiveGain:: -operator() (const vpColVector & e) const +double vpAdaptiveGain::operator() (const vpColVector & x) const { - return this ->value (e .infinityNorm()); + return this ->value (x .infinityNorm()); } @@ -325,14 +341,12 @@ operator() (const vpColVector & e) const /*! - Prints the adaptive gain coefficients. It prints the gain in 0, - the gain to infinity and the slope in 0. + Prints the adaptive gain parameters \f$\lambda(0), \lambda(\infty), {\dot \lambda}(0)\f$. \param os : The stream where to print the adaptive gain parameters. \param lambda : The adaptive gain containing the parameters to print. */ -std::ostream& -operator<< (std::ostream &os, const vpAdaptiveGain& lambda) +VISP_EXPORT std::ostream& operator<< (std::ostream &os, const vpAdaptiveGain& lambda) { os << "Zero= " << lambda .coeff_a + lambda .coeff_c << "\tInf= " << lambda .coeff_c @@ -340,11 +354,3 @@ operator<< (std::ostream &os, const vpAdaptiveGain& lambda) return os; } - - - -/* - * Local variables: - * c-basic-offset: 4 - * End: - */ diff --git a/src/servo/vpAdaptiveGain.h b/src/servo/vpAdaptiveGain.h index aa28a122102b9aae8715c7b1191eb4e34d59d8a1..766cc8dc086195fe949255764191162ef963f0de 100644 --- a/src/servo/vpAdaptiveGain.h +++ b/src/servo/vpAdaptiveGain.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpAdaptiveGain.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpAdaptiveGain.h 4641 2014-02-05 12:42:03Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -59,19 +59,18 @@ class vpColVector; The formula used to compute the gain is the following : - \f[ lambda (x) = a * exp (-b*x) + c \f] + \f[ \lambda (x) = a * exp (-b*x) + c \f] - where \f$ a \f$, \f$ b \f$ and \f$ c \f$ are parameters which must be set - and \f$ x \f$ is the vector error of the task. + where \f$ a \f$, \f$ b \f$ and \f$ c \f$ are constant parameters and \f$ x \f$ is the entry to consider. - By default, the parameters are set with default values: - \f[ a = lambda(0) - lambda(inf) \f] - \f[ b = lambda'(0) / a \f] - \f[ c = lambda(inf) \f] + The parameters \f$a,b,c\f$ are not set directly. They are computed from three other parameters + \f$\lambda(0), \lambda(\infty), {\dot \lambda}(0)\f$ that are more intuitive to tune: + \f[ a = \lambda(0) - \lambda(\infty) \f] + \f[ b = {\dot \lambda}(0) / a \f] + \f[ c = \lambda(\infty) \f] - with \f$ lambda(0) = 1.666 \f$, \f$ lambda(inf) = 0.1666 \f$ and \f$ lambda'(0) = 1.666 \f$. - - \f$ lambda(0)\f$ represents the gain in 0, \f$ lambda(inf)\f$ represents the gain to infinity and \f$ lambda'(0)\f$ represents the slope in 0. + where \f$ \lambda(0)\f$ represents the gain when \f$x=0\f$, \f$ \lambda(\infty)\f$ represents the gain when \f$x=\infty\f$ + and \f$ {\dot \lambda}(0)\f$ represents the slope of \f$\lambda(x)\f$ when \f$x=0\f$. */ @@ -81,8 +80,8 @@ class VISP_EXPORT vpAdaptiveGain public: /* constantes */ static const double DEFAULT_LAMBDA_ZERO; - static const double DEFAULT_LAMBDA_INFINI; - static const double DEFAULT_LAMBDA_PENTE; + static const double DEFAULT_LAMBDA_INFINITY; + static const double DEFAULT_LAMBDA_SLOPE; private: /* Attributs*/ @@ -101,14 +100,19 @@ public: /* Methodes*/ /* --- CONSTRUCTOR -------------------------------------------------------- */ - vpAdaptiveGain (void); + vpAdaptiveGain (); + vpAdaptiveGain (double c); + vpAdaptiveGain (double gain_at_zero, + double gain_at_infinity, + double slope_at_zero); + /* --- INIT --------------------------------------------------------------- */ - void initFromConstant (double lambda); + void initFromConstant (double c); void initFromVoid (void); - void initStandard (double en_zero, - double en_infini, - double pente_en_zero); + void initStandard (double gain_at_zero, + double gain_at_infinity, + double slope_at_zero); /* --- MODIFIORS ---------------------------------------------------------- */ @@ -128,7 +132,7 @@ public: /* Methodes*/ * \param val_e: valeur de la norme de l'erreur. * \return: valeur de gain au point courrant. */ - double value_const (double val_e) const; + double value_const (double x) const; /* \brief Calcule la valeur de lambda au point courrant et stockage du * resultat. @@ -139,7 +143,7 @@ public: /* Methodes*/ * \param val_e: valeur de la norme de l'erreur. * \return: valeur de gain au point courrant. */ - double value (double val_e) const; + double value (double x) const; double limitValue_const (void) const; @@ -152,12 +156,12 @@ public: /* Methodes*/ \return It returns the last adaptive gain value which was stored in the class. */ - inline double getLastValue (void) const {return this ->lambda;} + inline double getLastValue (void) const {return this ->lambda;} - double operator() (double val_e) const; + double operator() (double x) const; /* \brief Lance la fonction valeur avec la norme INFINIE du vecteur. */ - double operator() (const vpColVector & e) const; + double operator() (const vpColVector & x) const; /* \brief Idem function limitValue. */ double operator() (void) const; @@ -165,17 +169,7 @@ public: /* Methodes*/ /* --- IOSTREAM ----------------------------------------------------------- */ - friend VISP_EXPORT std::ostream& operator<< (std::ostream &os, - const vpAdaptiveGain& lambda); + friend VISP_EXPORT std::ostream& operator<< (std::ostream &os, const vpAdaptiveGain& lambda); }; #endif /* __VP_ADAPTIVE_GAIN_H */ - - - - -/* - * Local variables: - * c-basic-offset: 4 - * End: - */ diff --git a/src/servo/vpServo.cpp b/src/servo/vpServo.cpp index 0e378b3a6e2b55dc85107d73e5b5cf109eeaefe1..02127dd5a77ff02ef3b2d3b0732017302bd17012 100644 --- a/src/servo/vpServo.cpp +++ b/src/servo/vpServo.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpServo.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpServo.cpp 4674 2014-02-17 15:34:41Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -58,30 +58,46 @@ /*! - Default constructor. - - By default: - - - the interaction matrix \f$ L \f$ is computed with the desired - features \f$ s^*\f$ (\f$ L=L_{s^*}\f$). With - setInteractionMatrixType() you can also use the interaction matrix - with the current visual features \f$L_s\f$, or the mean \f$(L_s / - 2 + L_{s^*} / 2)\f$. - - - the control law is build from the pseudo inverse of the - interaction matrix \f$ v = - \lambda \; L^+ \; e\f$. With - setInteractionMatrixType() can also set the usage of the transpose - \f$ v = \lambda \; L^t \; e\f$ . + Default constructor that initializes the following settings: + - No control law is specified. The user has to call setServo() to specify the control law. + - In the control law, the interaction matrix \f${\widehat {\bf L}}_e \f$ is computed with the desired + features \f${\bf s}^*\f$. Using setInteractionMatrixType() you can also compute the + interaction matrix with the current visual features, or from the mean + \f$\left({\widehat {\bf L}}_s + {\widehat {\bf L}}_{s^*}\right)/2\f$. + - In the control law the pseudo inverse will be used. The method setInteractionMatrixType() + allows to use the transpose instead. */ vpServo::vpServo() + : L(), error(), J1(), J1p(), s(), sStar(), e1(), e(), q_dot(), v(), servoType(vpServo::NONE), + rankJ1(0), featureList(), desiredFeatureList(), featureSelectionList(), lambda(), signInteractionMatrix(1), + interactionMatrixType(DESIRED), inversionType(PSEUDO_INVERSE), cVe(), init_cVe(false), + cVf(), init_cVf(false), fVe(), init_fVe(false), eJe(), init_eJe(false), fJe(), init_fJe(false), + errorComputed(false), interactionMatrixComputed(false), dim_task(0), taskWasKilled(false), + forceInteractionMatrixComputation(false), WpW(), I_WpW(), sv(), mu(4.) { - init() ; } +/*! + Constructor that allows to choose the visual servoing control law. + \param servo_type : Visual servoing control law. -vpServo::vpServo(vpServoType _servoType) + The other settings are the following: + - In the control law, the interaction matrix \f${\widehat {\bf L}}_e \f$ is computed with the desired + features \f${\bf s}^*\f$. Using setInteractionMatrixType() you can also compute the + interaction matrix with the current visual features, or from the mean + \f$\left({\widehat {\bf L}}_s + {\widehat {\bf L}}_{s^*}\right)/2\f$. + - In the control law the pseudo inverse will be used. The method setInteractionMatrixType() + allows to use the transpose instead. + + */ +vpServo::vpServo(vpServoType servo_type) + : L(), error(), J1(), J1p(), s(), sStar(), e1(), e(), q_dot(), v(), servoType(servo_type), + rankJ1(0), featureList(), desiredFeatureList(), featureSelectionList(), lambda(), signInteractionMatrix(1), + interactionMatrixType(DESIRED), inversionType(PSEUDO_INVERSE), cVe(), init_cVe(false), + cVf(), init_cVf(false), fVe(), init_fVe(false), eJe(), init_eJe(false), fJe(), init_fJe(false), + errorComputed(false), interactionMatrixComputed(false), dim_task(0), taskWasKilled(false), + forceInteractionMatrixComputation(false), WpW(), I_WpW(), sv(), mu(4) { - setServo(_servoType); } /*! @@ -108,24 +124,19 @@ vpServo::~vpServo() /*! - Initialize the servo. - - By default: + Initialize the servo with the following settings: - - the interaction matrix \f$ L \f$ is computed with the desired - features \f$ s^*\f$ (\f$ L=L_{s^*}\f$). With - setInteractionMatrixType() you can also use the interaction matrix - with the current visual features \f$L_s\f$, or the mean \f$(L_s / - 2 + L_{s^*} / 2)\f$. + - No control law is specified. The user has to call setServo() to specify the control law. + - In the control law, the interaction matrix \f${\widehat {\bf L}}_e \f$ is computed with the desired + features \f${\bf s}^*\f$. Using setInteractionMatrixType() you can also compute the + interaction matrix with the current visual features, or from the mean + \f$\left({\widehat {\bf L}}_s + {\widehat {\bf L}}_{s^*}\right)/2\f$. + - In the control law the pseudo inverse will be used. The method setInteractionMatrixType() + allows to use the transpose instead. - - the control law is build from the pseudo inverse of the - interaction matrix \f$ v = - \lambda \; L^+ \; e\f$. With - setInteractionMatrixType() can also set the usage of the transpose - \f$ v = \lambda \; L^t \; e\f$ . */ -void - vpServo::init() +void vpServo::init() { // type of visual servoing servoType = vpServo::NONE ; @@ -140,9 +151,9 @@ void dim_task = 0 ; - featureList.kill() ; - desiredFeatureList.kill() ; - featureSelectionList.kill(); + featureList.clear() ; + desiredFeatureList.clear() ; + featureSelectionList.clear(); signInteractionMatrix = 1 ; @@ -155,6 +166,8 @@ void taskWasKilled = false; forceInteractionMatrixComputation = false; + + rankJ1 = 0; } /*! @@ -173,56 +186,46 @@ void \endcode */ -void - vpServo::kill() +void vpServo::kill() { if (taskWasKilled == false) { // kill the current and desired feature lists - featureList.front() ; - desiredFeatureList.front() ; - while (!featureList.outside()) { - vpBasicFeature *s_ptr = NULL; - - // current list - s_ptr= featureList.value() ; - if (s_ptr->getDeallocate() == vpBasicFeature::vpServo) - { - delete s_ptr ; - s_ptr = NULL ; + // current list + for(std::list<vpBasicFeature *>::iterator it = featureList.begin(); it != featureList.end(); ++it) { + if ((*it)->getDeallocate() == vpBasicFeature::vpServo) { + delete (*it) ; + (*it) = NULL ; } - + } //desired list - s_ptr= desiredFeatureList.value() ; - if (s_ptr->getDeallocate() == vpBasicFeature::vpServo) - { - // s_ptr->print() ; - delete s_ptr ; - s_ptr = NULL ; + for(std::list<vpBasicFeature *>::iterator it = desiredFeatureList.begin(); it != desiredFeatureList.end(); ++it) { + if ((*it)->getDeallocate() == vpBasicFeature::vpServo) { + delete (*it) ; + (*it) = NULL ; } - - desiredFeatureList.next() ; - featureList.next() ; } - featureList.kill() ; - desiredFeatureList.kill() ; + + featureList.clear() ; + desiredFeatureList.clear() ; taskWasKilled = true; } } -void - vpServo::setServo(vpServoType _servoType) +/*! + Set the visual servoing control law. + \param servo_type : Control law that will be considered. + See vpServo::vpServoType to see the possible values. + */ +void vpServo::setServo(const vpServoType &servo_type) { - - servoType = _servoType ; + this->servoType = servo_type ; if ((servoType==EYEINHAND_CAMERA) ||(servoType==EYEINHAND_L_cVe_eJe)) signInteractionMatrix = 1 ; else signInteractionMatrix = -1 ; - - // when the control is directly compute in the camera frame // we relieve the end-user to initialize cVa and aJe if (servoType==EYEINHAND_CAMERA) @@ -233,7 +236,6 @@ void _eJe.eye(6) ; set_eJe(_eJe) ; }; - } @@ -241,16 +243,7 @@ void Prints on \e os stream information about the task: - \param displayLevel : If vpServo::ALL prints - - Type of control law (eye-in-hand, eye-to-hand) - - Control frame (camera frame, joint space) - - List of current visual features : s - - List of desired visual features : s* - - Interaction Matrix Ls - - Error vector (s-s*) - - Gain of the controller - - \param displayLevel : If vpServo::MINIMUM prints only the error vector (s-s*). + \param displayLevel : Indicates which are the task informations to print. See vpServo::vpServoPrintType for more details. \param os : Output stream. */ @@ -259,11 +252,8 @@ void { switch (displayLevel) { - case vpServo::ALL: - { - os << "Visual servoing task: " <<std::endl ; os << "Type of control law " <<std::endl ; @@ -295,30 +285,21 @@ void } os << "List of visual features : s" <<std::endl ; - for (featureList.front(), - featureSelectionList.front() ; - !featureList.outside() ; - featureList.next(), - featureSelectionList.next() ) + std::list<vpBasicFeature *>::const_iterator it_s; + std::list<vpBasicFeature *>::const_iterator it_s_star; + std::list<unsigned int>::const_iterator it_select; + + for (it_s = featureList.begin(), it_select = featureSelectionList.begin(); it_s != featureList.end(); ++it_s, ++it_select) { - vpBasicFeature *s ; - s = featureList.value(); os << "" ; - s->print(featureSelectionList.value()) ; + (*it_s)->print( (*it_select) ) ; } - os << "List of desired visual features : s*" <<std::endl ; - for (desiredFeatureList.front(), - featureSelectionList.front() ; - !desiredFeatureList.outside() ; - desiredFeatureList.next(), - featureSelectionList.next() ) + for (it_s_star = desiredFeatureList.begin(), it_select = featureSelectionList.begin(); it_s_star != desiredFeatureList.end(); ++it_s_star, ++it_select) { - vpBasicFeature *s ; - s = desiredFeatureList.value(); os << "" ; - s->print(featureSelectionList.value()) ; + (*it_s_star)->print( (*it_select) ) ; } os <<"Interaction Matrix Ls "<<std::endl ; @@ -327,7 +308,9 @@ void os << L << std::endl; } else - {os << "not yet computed "<<std::endl ;} + { + os << "not yet computed "<<std::endl ; + } os <<"Error vector (s-s*) "<<std::endl ; if (errorComputed) @@ -335,7 +318,9 @@ void os << error.t() << std::endl; } else - {os << "not yet computed "<<std::endl ;} + { + os << "not yet computed "<<std::endl ; + } os << "Gain : " << lambda <<std::endl ; @@ -377,33 +362,28 @@ void case vpServo::FEATURE_CURRENT: { os << "List of visual features : s" <<std::endl ; - for (featureList.front(), - featureSelectionList.front() ; - !featureList.outside() ; - featureList.next(), - featureSelectionList.next() ) + + std::list<vpBasicFeature *>::const_iterator it_s; + std::list<unsigned int>::const_iterator it_select; + + for (it_s = featureList.begin(), it_select = featureSelectionList.begin(); it_s != featureList.end(); ++it_s, ++it_select) { - vpBasicFeature *s ; - s = featureList.value(); os << "" ; - s->print(featureSelectionList.value()) ; + (*it_s)->print( (*it_select) ) ; } - break; } case vpServo::FEATURE_DESIRED: { os << "List of desired visual features : s*" <<std::endl ; - for (desiredFeatureList.front(), - featureSelectionList.front() ; - !desiredFeatureList.outside() ; - desiredFeatureList.next(), - featureSelectionList.next() ) + + std::list<vpBasicFeature *>::const_iterator it_s_star; + std::list<unsigned int>::const_iterator it_select; + + for (it_s_star = desiredFeatureList.begin(), it_select = featureSelectionList.begin(); it_s_star != desiredFeatureList.end(); ++it_s_star, ++it_select) { - vpBasicFeature *s ; - s = desiredFeatureList.value(); os << "" ; - s->print(featureSelectionList.value()) ; + (*it_s_star)->print( (*it_select) ) ; } break; } @@ -415,12 +395,12 @@ void case vpServo::INTERACTION_MATRIX: { os <<"Interaction Matrix Ls "<<std::endl ; - if (interactionMatrixComputed) - { + if (interactionMatrixComputed) { os << L << std::endl; } - else - {os << "not yet computed "<<std::endl ;} + else { + os << "not yet computed "<<std::endl ; + } break; } @@ -429,33 +409,76 @@ void { os <<"Error vector (s-s*) "<<std::endl ; - if (errorComputed) - { os << error.t() << std::endl; } - else - {os << "not yet computed "<<std::endl ;} + if (errorComputed) { + os << error.t() << std::endl; + } + else { + os << "not yet computed "<<std::endl ; + } break; } } } -//! create a new set of 2 features in the task -void - vpServo::addFeature(vpBasicFeature& s, vpBasicFeature &s_star, unsigned int select) +/*! + Add a new set of 2 features \f$\bf s\f$ and \f${\bf s}^*\f$ in the task. + + \param s_cur : Current visual feature denoted \f$\bf s\f$. + \param s_star : Desired visual feature denoted \f${\bf s}^*\f$. + \param select : Feature selector. By default all the features in \e s and \e s_star are used, + but is is possible to specify which one is used in case of multiple features. + + The following sample code explain how to use this method to add a visual feature point \f$(x,y)\f$: + \code + vpFeaturePoint s, s_star; + ... + vpServo task; + task.addFeature(s, s_star); + \endcode + + For example to use only the \f$x\f$ visual feature, the previous code becomes: + \code + vpFeaturePoint s, s_star; + ... + vpServo task; + task.addFeature(s, s_star, vpFeaturePoint::selectX()); + \endcode + + */ +void vpServo::addFeature(vpBasicFeature& s_cur, vpBasicFeature &s_star, unsigned int select) { - featureList += &s ; - desiredFeatureList += &s_star ; - featureSelectionList+= select ; + featureList.push_back( &s_cur ); + desiredFeatureList.push_back( &s_star ); + featureSelectionList.push_back( select ); } /*! - \brief create a new visual features in the task - (the desired feature is then null) -*/ -void - vpServo::addFeature(vpBasicFeature& s, unsigned int select) + Add a new features \f$\bf s\f$ in the task. The desired visual feature denoted \f${\bf s}^*\f$ is equal to zero. + + \param s_cur : Current visual feature denoted \f$\bf s\f$. + \param select : Feature selector. By default all the features in \e s are used, + but is is possible to specify which one is used in case of multiple features. + + The following sample code explain how to use this method to add a \f$\theta {\bf u} =(\theta u_x, \theta u_y, \theta u_z)\f$ feature: + \code + vpFeatureThetaU s(vpFeatureThetaU::cRcd); + ... + vpServo task; + task.addFeature(s); + \endcode + + For example to use only the \f$\theta u_x\f$ feature, the previous code becomes: + \code + vpFeatureThetaU s(vpFeatureThetaU::cRcd); + ... + vpServo task; + task.addFeature(s, vpFeatureThetaU::selectTUx); + \endcode + */ +void vpServo::addFeature(vpBasicFeature& s_cur, unsigned int select) { - featureList += &s ; + featureList.push_back( &s_cur ); // in fact we have a problem with s_star that is not defined // by the end user. @@ -472,51 +495,41 @@ void // vpServo must deallocate the memory (see ~vpServo and kill() ) vpBasicFeature *s_star ; - s_star = s.duplicate() ; + s_star = s_cur.duplicate() ; s_star->init() ; s_star->setDeallocate(vpBasicFeature::vpServo) ; - desiredFeatureList += s_star ; - featureSelectionList+= select ; + desiredFeatureList.push_back( s_star ); + featureSelectionList.push_back( select ); } -//! get the task dimension -unsigned int - vpServo::getDimension() +//! Return the task dimension. +unsigned int vpServo::getDimension() const { + unsigned int dim = 0 ; + std::list<vpBasicFeature *>::const_iterator it_s; + std::list<unsigned int>::const_iterator it_select; - featureList.front() ; - featureSelectionList.front() ; - - dim_task =0 ; - while (!featureList.outside()) + for (it_s = featureList.begin(), it_select = featureSelectionList.begin(); it_s != featureList.end(); ++it_s, ++it_select) { - vpBasicFeature *s_ptr = NULL; - s_ptr= featureList.value() ; - unsigned int select = (unsigned int)featureSelectionList.value() ; - - dim_task += (unsigned int)s_ptr->getDimension(select) ; - - featureSelectionList.next() ; - featureList.next() ; + dim += (*it_s)->getDimension(*it_select) ; } - return dim_task ; + return dim; } -void - vpServo::setInteractionMatrixType(const vpServoIteractionMatrixType &_interactionMatrixType, const vpServoInversionType &_interactionMatrixInversion) +void vpServo::setInteractionMatrixType(const vpServoIteractionMatrixType &interactionMatrix_type, + const vpServoInversionType &interactionMatrixInversion) { - interactionMatrixType = _interactionMatrixType ; - inversionType = _interactionMatrixInversion ; + this->interactionMatrixType = interactionMatrix_type ; + this->inversionType = interactionMatrixInversion ; } -static void - computeInteractionMatrixFromList (/*const*/ vpList<vpBasicFeature *> & featureList, - /*const*/ vpList<unsigned int> & featureSelectionList, - vpMatrix & L) +static void computeInteractionMatrixFromList (const std::list<vpBasicFeature *> & featureList, + const std::list<unsigned int> & featureSelectionList, + vpMatrix & L) { if (featureList.empty()) { @@ -539,7 +552,10 @@ static void * initialized to dim 1.*/ unsigned int rowL = L.getRows(); const unsigned int colL = 6; - if (0 == rowL) { rowL = 1; L .resize(rowL, colL);} + if (0 == rowL) { + rowL = 1; + L .resize(rowL, colL); + } /* vectTmp is used to store the return values of functions get_s() and * error(). */ @@ -551,27 +567,29 @@ static void * is out of the vector-array range.*/ unsigned int cursorL = 0; - for (featureList.front() ,featureSelectionList.front() ; - !featureList.outside(); - featureSelectionList.next(),featureList.next() ) - { - vpBasicFeature * sPTR = featureList.value() ; - const unsigned int select = featureSelectionList.value() ; + std::list<vpBasicFeature *>::const_iterator it; + std::list<unsigned int>::const_iterator it_select; + for (it = featureList.begin(), it_select = featureSelectionList.begin(); it != featureList.end(); ++it, ++it_select) + { /* Get s. */ - matrixTmp = sPTR->interaction(select); + matrixTmp = (*it)->interaction( *it_select ); rowMatrixTmp = matrixTmp .getRows(); colMatrixTmp = matrixTmp .getCols(); /* Check the matrix L size, and realloc if needed. */ - while (rowMatrixTmp + cursorL > rowL) - { rowL *= 2; L .resize (rowL,colL,false); vpDEBUG_TRACE(15,"Realloc!"); } + while (rowMatrixTmp + cursorL > rowL) { + rowL *= 2; + L.resize (rowL,colL,false); + vpDEBUG_TRACE(15,"Realloc!"); + } /* Copy the temporarily matrix into L. */ - for (unsigned int k = 0; k < rowMatrixTmp; ++k, ++cursorL) - for (unsigned int j = 0; j < colMatrixTmp; ++j) - { L[cursorL][j] = matrixTmp[k][j]; } - + for (unsigned int k = 0; k < rowMatrixTmp; ++k, ++cursorL) { + for (unsigned int j = 0; j < colMatrixTmp; ++j) { + L[cursorL][j] = matrixTmp[k][j]; + } + } } L.resize (cursorL,colL,false); @@ -582,14 +600,12 @@ static void /*! - Compute the interaction matrix related to the set of visual features. + Compute and return the interaction matrix related to the set of visual features. - \return Ls + \return The interaction matrix \f${\widehat {\bf L}}_e\f$ used in the control law specified using setServo(). */ -vpMatrix - vpServo::computeInteractionMatrix() +vpMatrix vpServo::computeInteractionMatrix() { - try { switch (interactionMatrixType) @@ -671,15 +687,13 @@ vpMatrix /*! - Compute the error \f$(s - s^*)\f$ between the current set of visual - features \f$s\f$ and the desired set of visual features \f$s^*\f$. + Compute the error \f$\bf e =(s - s^*)\f$ between the current set of visual + features \f$\bf s\f$ and the desired set of visual features \f$\bf s^*\f$. - \return The error \f$(s - s^*)\f$. To access to the computed error - you can also use the public vpServo::error class member. + \return The error vector \f$\bf e\f$. */ -vpColVector - vpServo::computeError() +vpColVector vpServo::computeError() { if (featureList.empty()) { @@ -732,19 +746,17 @@ vpColVector unsigned int cursorError = 0; /* For each cell of the list, copy value of s, s_star and error. */ - for (featureList.front(), - desiredFeatureList.front(), - featureSelectionList.front() ; + std::list<vpBasicFeature *>::const_iterator it_s; + std::list<vpBasicFeature *>::const_iterator it_s_star; + std::list<unsigned int>::const_iterator it_select; - !featureList.outside() ; - - featureList.next(), - desiredFeatureList.next(), - featureSelectionList.next() ) + for (it_s = featureList.begin(), it_s_star = desiredFeatureList.begin(), it_select = featureSelectionList.begin(); + it_s != featureList.end(); + ++it_s, ++it_s_star, ++it_select) { - current_s = featureList.value() ; - desired_s = desiredFeatureList.value() ; - unsigned int select = featureSelectionList.value() ; + current_s = (*it_s); + desired_s = (*it_s_star); + unsigned int select = (*it_select); /* Get s, and store it in the s vector. */ vectTmp = current_s->get_s(select); @@ -753,22 +765,27 @@ vpColVector { dimS *= 2; s .resize (dimS,false); vpDEBUG_TRACE(15,"Realloc!"); } for (unsigned int k = 0; k < dimVectTmp; ++k) { s[cursorS++] = vectTmp[k]; } - /* Get s_star, and store it in the s vector. */ vectTmp = desired_s->get_s(select); dimVectTmp = vectTmp .getRows(); - while (dimVectTmp + cursorSStar > dimSStar) - { dimSStar *= 2; sStar .resize (dimSStar,false); } - for (unsigned int k = 0; k < dimVectTmp; ++k) - { sStar[cursorSStar++] = vectTmp[k]; } + while (dimVectTmp + cursorSStar > dimSStar) { + dimSStar *= 2; + sStar.resize (dimSStar,false); + } + for (unsigned int k = 0; k < dimVectTmp; ++k) { + sStar[cursorSStar++] = vectTmp[k]; + } /* Get error, and store it in the s vector. */ vectTmp = current_s->error(*desired_s, select) ; dimVectTmp = vectTmp .getRows(); - while (dimVectTmp + cursorError > dimError) - { dimError *= 2; error .resize (dimError,false); } - for (unsigned int k = 0; k < dimVectTmp; ++k) - { error[cursorError++] = vectTmp[k]; } + while (dimVectTmp + cursorError > dimError) { + dimError *= 2; + error.resize (dimError,false); + } + for (unsigned int k = 0; k < dimVectTmp; ++k) { + error[cursorError++] = vectTmp[k]; + } } /* If too much memory has been allocated, realloc. */ @@ -792,8 +809,7 @@ vpColVector return error ; } -bool - vpServo::testInitialization() +bool vpServo::testInitialization() { switch (servoType) { @@ -827,8 +843,7 @@ bool return false ; } -bool - vpServo::testUpdated() +bool vpServo::testUpdated() { switch (servoType) { @@ -863,26 +878,197 @@ bool return false ; } /*! - \brief compute the desired control law - Compute the control law according to the equation: + Compute the control law specified using setServo(). See vpServo::vpServoType for more + details concerning the control laws that are available. The \ref tutorial-ibvs and \ref tutorial-boost-vs + are also useful to illustrate the usage of this function. + + The general form of the control law is the following: + \f[ - -\lambda {\bf W^+W\widehat J_s^+(s-s^*)} + {\bf \dot q} = \pm \lambda {{\bf \widehat J}_e}^+ {\bf e} \f] - or + + where : + - \f${\bf \dot q}\f$ is the resulting velocity command to apply to the robot. + - the sign of the control law depends on the eye in hand or eye to hand configuration. + - \f$\bf J\f$ is the Jacobian of the task. It is function of the interaction matrix and of the robot + Jacobian. + - \f$\bf e = (s-s^*)\f$ is the error to regulate. + + To ensure continuous sequencing the computeControlLaw(double) function can be used. It will ensure that + the velocities that are computed are continuous. +*/ +vpColVector vpServo::computeControlLaw() +{ + static int iteration =0; + + try + { + vpVelocityTwistMatrix cVa ; // Twist transformation matrix + vpMatrix aJe ; // Jacobian + + if (iteration==0) + { + if (testInitialization() == false) { + vpERROR_TRACE("All the matrices are not correctly initialized") ; + throw(vpServoException(vpServoException::servoError, + "Cannot compute control law " + "All the matrices are not correctly" + "initialized")) ; + } + } + if (testUpdated() == false) { + vpERROR_TRACE("All the matrices are not correctly updated") ; + } + + // test if all the required initialization have been done + switch (servoType) + { + case NONE : + vpERROR_TRACE("No control law have been yet defined") ; + throw(vpServoException(vpServoException::servoError, + "No control law have been yet defined")) ; + break ; + case EYEINHAND_CAMERA: + case EYEINHAND_L_cVe_eJe: + case EYETOHAND_L_cVe_eJe: + + cVa = cVe ; + aJe = eJe ; + + init_cVe = false ; + init_eJe = false ; + break ; + case EYETOHAND_L_cVf_fVe_eJe: + cVa = cVf*fVe ; + aJe = eJe ; + init_fVe = false ; + init_eJe = false ; + break ; + case EYETOHAND_L_cVf_fJe : + cVa = cVf ; + aJe = fJe ; + init_fJe = false ; + break ; + } + + computeInteractionMatrix() ; + computeError() ; + + // compute task Jacobian + J1 = L*cVa*aJe ; + + // handle the eye-in-hand eye-to-hand case + J1 *= signInteractionMatrix ; + + // pseudo inverse of the task Jacobian + // and rank of the task Jacobian + // the image of J1 is also computed to allows the computation + // of the projection operator + vpMatrix imJ1t, imJ1 ; + bool imageComputed = false ; + + if (inversionType==PSEUDO_INVERSE) + { + rankJ1 = J1.pseudoInverse(J1p, sv, 1e-6, imJ1, imJ1t) ; + + imageComputed = true ; + } + else + J1p = J1.t() ; + + if (rankJ1 == L.getCols()) + { + /* if no degrees of freedom remains (rank J1 = ndof) + WpW = I, multiply by WpW is useless + */ + e1 = J1p*error ;// primary task + + WpW.resize(J1.getCols(), J1.getCols()) ; + WpW.setIdentity() ; + } + else + { + if (imageComputed!=true) + { + vpMatrix Jtmp ; + // image of J1 is computed to allows the computation + // of the projection operator + rankJ1 = J1.pseudoInverse(Jtmp, sv, 1e-6, imJ1, imJ1t) ; + imageComputed = true ; + } + WpW = imJ1t*imJ1t.t() ; + +#ifdef DEBUG + std::cout << "rank J1 " << rankJ1 <<std::endl ; + std::cout << "imJ1t"<<std::endl << imJ1t ; + std::cout << "imJ1"<<std::endl << imJ1 ; + + std::cout << "WpW" <<std::endl <<WpW ; + std::cout << "J1" <<std::endl <<J1 ; + std::cout << "J1p" <<std::endl <<J1p ; +#endif + e1 = WpW*J1p*error ; + } + e = - lambda(e1) * e1 ; + + vpMatrix I ; + + I.resize(J1.getCols(),J1.getCols()) ; + I.setIdentity() ; + + I_WpW = (I - WpW) ; + } + catch(vpMatrixException me) + { + vpERROR_TRACE("Caught a matrix related error") ; + std::cout << me << std::endl ; + throw me; + } + catch(vpException me) + { + vpERROR_TRACE("Error caught") ; + std::cout << me << std::endl ; + throw me ; + } + + iteration++ ; + return e ; +} + +/*! + Compute the control law specified using setServo(). See vpServo::vpServoType for more + details concerning the control laws that are available. The \ref tutorial-boost-vs is also useful to + illustrate the usage of this function. + + To the general form of the control law given in computeControlLaw(), we add here an additional term that comes from + the task sequencing approach described in \cite Mansard07e equation (17). This additional term allows to compute + continuous velocities by avoiding abrupt changes in the command. + + The form of the control law considered here is the following: + \f[ - -\lambda {\bf\widehat J_s^+(s-s^*)} + {\bf \dot q} = \pm \lambda {{\bf \widehat J}_e}^+ {\bf e} \mp \lambda {{\bf \widehat J}_{e(0)}}^+ {{\bf e}(0)} \exp(-\mu t) \f] - if the dimension of the task is equal to number of available degrees of freedom (in that case \f${\bf W^+W = I}\f$) - in this equation Js is function of the interaction matrix and of the robot - Jacobian. It is also built according to the chosen configuration eye-in-hand - or eye-to-hand (see vpServo::setServo method) + where : + - \f${\bf \dot q}\f$ is the resulting continuous velocity command to apply to the robot. + - the sign of the control law depends on the eye in hand or eye to hand configuration. + - \f$\bf J\f$ is the Jacobian of the task. It is function of the interaction matrix and of the robot + Jacobian. + - \f$\bf e = (s-s^*)\f$ is the error to regulate. + - \f$t\f$ is the time given as parameter of this method. + - \f$\mu\f$ is a gain that is set by default to 4 and that could be modified using setMu(). + - \f${\bf \widehat J}_{e(0)}^+ {\bf e}(0)\f$ is the value of \f${\bf \widehat J}_e^+ {\bf e}\f$ when \f$t=0\f$. + This value is internally stored either at the first call of this method, or when \e t parameter is set to 0. + + \param t : Time in second. When set to zero, \f${{\bf \widehat J}_{e(0)}}^+ {{\bf e}(0)}\f$ is refreshed internally. */ -vpColVector - vpServo::computeControlLaw() +vpColVector vpServo::computeControlLaw(double t) { static int iteration =0; + static vpColVector e1_initial; try { @@ -891,24 +1077,188 @@ vpColVector if (iteration==0) { - if (testInitialization() == true) - { - } - else - { - vpERROR_TRACE("All the matrices are not correctly initialized") ; - throw(vpServoException(vpServoException::servoError, + if (testInitialization() == false) { + vpERROR_TRACE("All the matrices are not correctly initialized") ; + throw(vpServoException(vpServoException::servoError, "Cannot compute control law " "All the matrices are not correctly" "initialized")) ; - } + } + } + if (testUpdated() == false) { + vpERROR_TRACE("All the matrices are not correctly updated") ; + } + + // test if all the required initialization have been done + switch (servoType) + { + case NONE : + vpERROR_TRACE("No control law have been yet defined") ; + throw(vpServoException(vpServoException::servoError, + "No control law have been yet defined")) ; + break ; + case EYEINHAND_CAMERA: + case EYEINHAND_L_cVe_eJe: + case EYETOHAND_L_cVe_eJe: + + cVa = cVe ; + aJe = eJe ; + + init_cVe = false ; + init_eJe = false ; + break ; + case EYETOHAND_L_cVf_fVe_eJe: + cVa = cVf*fVe ; + aJe = eJe ; + init_fVe = false ; + init_eJe = false ; + break ; + case EYETOHAND_L_cVf_fJe : + cVa = cVf ; + aJe = fJe ; + init_fJe = false ; + break ; + } + + computeInteractionMatrix() ; + computeError() ; + + // compute task Jacobian + J1 = L*cVa*aJe ; + + // handle the eye-in-hand eye-to-hand case + J1 *= signInteractionMatrix ; + + // pseudo inverse of the task Jacobian + // and rank of the task Jacobian + // the image of J1 is also computed to allows the computation + // of the projection operator + vpMatrix imJ1t, imJ1 ; + bool imageComputed = false ; + + if (inversionType==PSEUDO_INVERSE) + { + rankJ1 = J1.pseudoInverse(J1p, sv, 1e-6, imJ1, imJ1t) ; + + imageComputed = true ; } - if (testUpdated() == true) + else + J1p = J1.t() ; + + if (rankJ1 == L.getCols()) { - // os << " Init OK " << std::endl ; + /* if no degrees of freedom remains (rank J1 = ndof) + WpW = I, multiply by WpW is useless + */ + e1 = J1p*error ;// primary task + + WpW.resize(J1.getCols(), J1.getCols()) ; + WpW.setIdentity() ; } else { + if (imageComputed!=true) + { + vpMatrix Jtmp ; + // image of J1 is computed to allows the computation + // of the projection operator + rankJ1 = J1.pseudoInverse(Jtmp, sv, 1e-6, imJ1, imJ1t) ; + imageComputed = true ; + } + WpW = imJ1t*imJ1t.t() ; + +#ifdef DEBUG + std::cout << "rank J1 " << rankJ1 <<std::endl ; + std::cout << "imJ1t"<<std::endl << imJ1t ; + std::cout << "imJ1"<<std::endl << imJ1 ; + + std::cout << "WpW" <<std::endl <<WpW ; + std::cout << "J1" <<std::endl <<J1 ; + std::cout << "J1p" <<std::endl <<J1p ; +#endif + e1 = WpW*J1p*error ; + } + + // memorize the initial e1 value if the function is called the first time or if the time given as parameter is equal to 0. + if (iteration==0 || std::fabs(t) < std::numeric_limits<double>::epsilon()) { + e1_initial = e1; + } + + e = - lambda(e1) * e1 + lambda(e1) * e1_initial*exp(-mu*t); + + vpMatrix I ; + + I.resize(J1.getCols(), J1.getCols()) ; + I.setIdentity() ; + + I_WpW = (I - WpW) ; + } + catch(vpMatrixException me) + { + vpERROR_TRACE("Caught a matrix related error") ; + std::cout << me << std::endl ; + throw me; + } + catch(vpException me) + { + vpERROR_TRACE("Error caught") ; + std::cout << me << std::endl ; + throw me ; + } + + iteration++ ; + return e ; +} + +/*! + Compute the control law specified using setServo(). See vpServo::vpServoType for more + details concerning the control laws that are available. + + To the general form of the control law given in computeControlLaw(), we add here an additional term that comes from + the task sequencing approach described in \cite Mansard07e equation (17). This additional term allows to compute + continuous velocities by avoiding abrupt changes in the command. + + The form of the control law considered here is the following: + + \f[ + {\bf \dot q} = \pm \lambda {{\bf \widehat J}_e}^+ {\bf e} + \left({\bf \dot e}(0) \mp \lambda {{\bf \widehat J}_{e(0)}}^+ {{\bf e}(0)}\right) \exp(-\mu t) + \f] + + where : + - \f${\bf \dot q}\f$ is the resulting continuous velocity command to apply to the robot. + - the sign of the control law depends on the eye in hand or eye to hand configuration. + - \f$\bf J\f$ is the Jacobian of the task. It is function of the interaction matrix and of the robot + Jacobian. + - \f$\bf e = (s-s^*)\f$ is the error to regulate. + - \f$t\f$ is the time given as parameter of this method. + - \f$\mu\f$ is a gain that is set by default to 4 and that could be modified using setMu(). + - \f${\bf \widehat J}_{e(0)}^+ {\bf e}(0)\f$ is the value of \f${\bf \widehat J}_e^+ {\bf e}\f$ when \f$t=0\f$. + This value is internally stored either at the first call of this method, or when \e t parameter is set to 0. + + \param t : Time in second. When set to zero, \f${{\bf \widehat J}_{e(0)}}^+ {{\bf e}(0)}\f$ is refreshed internally. + \param e_dot_init : Initial value of \f${\bf \dot e}(0)\f$. +*/ +vpColVector vpServo::computeControlLaw(double t, const vpColVector &e_dot_init) +{ + static int iteration =0; + static vpColVector e1_initial; + + try + { + vpVelocityTwistMatrix cVa ; // Twist transformation matrix + vpMatrix aJe ; // Jacobian + + if (iteration==0) + { + if (testInitialization() == false) { + vpERROR_TRACE("All the matrices are not correctly initialized") ; + throw(vpServoException(vpServoException::servoError, + "Cannot compute control law " + "All the matrices are not correctly" + "initialized")) ; + } + } + if (testUpdated() == false) { vpERROR_TRACE("All the matrices are not correctly updated") ; } @@ -971,8 +1321,8 @@ vpColVector if (rankJ1 == L.getCols()) { /* if no degrees of freedom remains (rank J1 = ndof) - WpW = I, multiply by WpW is useless - */ + WpW = I, multiply by WpW is useless + */ e1 = J1p*error ;// primary task WpW.resize(J1.getCols(), J1.getCols()) ; @@ -981,13 +1331,13 @@ vpColVector else { if (imageComputed!=true) - { - vpMatrix Jtmp ; - // image of J1 is computed to allows the computation - // of the projection operator + { + vpMatrix Jtmp ; + // image of J1 is computed to allows the computation + // of the projection operator rankJ1 = J1.pseudoInverse(Jtmp, sv, 1e-6, imJ1, imJ1t) ; - imageComputed = true ; - } + imageComputed = true ; + } WpW = imJ1t*imJ1t.t() ; #ifdef DEBUG @@ -1001,11 +1351,17 @@ vpColVector #endif e1 = WpW*J1p*error ; } - e = - lambda(e1) * e1 ; + + // memorize the initial e1 value if the function is called the first time or if the time given as parameter is equal to 0. + if (iteration==0 || std::fabs(t) < std::numeric_limits<double>::epsilon()) { + e1_initial = e1; + } + + e = - lambda(e1) * e1 + (e_dot_init + lambda(e1) * e1_initial)*exp(-mu*t); vpMatrix I ; - I.resize(J1.getCols(),J1.getCols()) ; + I.resize(J1.getCols(), J1.getCols()) ; I.setIdentity() ; I_WpW = (I - WpW) ; @@ -1029,28 +1385,35 @@ vpColVector /*! - Compute the secondary task according to the projection operator. - See equation (7) of the IEEE RA magazine, dec 2005 paper. + Compute and return the secondary task vector according to the projection operator \f${\bf I-W^+W}\f$. For more details, + see equation(7) in the paper \cite Marchand05b. - \warning computeControlLaw() must be call prior to this function. + \param de2dt : Value of \f$\frac{\partial {\bf e_2}}{\partial t}\f$ the derivative of the secondary task \f${\bf e}_2\f$. - Compute the vector: - \f[ - + ({\bf I-W^+W})\frac{\partial {\bf e_2}}{\partial t} + \return The secondary task vector: \f[ + ({\bf I-W^+W})\frac{\partial {\bf e_2}}{\partial t} \f] - to be added to the primary task + + Note that the secondary task vector need than to be added to the primary task which can be in the general case written as: \f[ - -\lambda {\bf W^+W\widehat J_s^+(s-s^*)} + -\lambda {\bf W^+W {\widehat {\bf J}}_e^+({\bf s-s^*})} \f] - which is computed using the computeControlLaw() method. - \warning The projection operator \f$ \bf W^+W \f$ is computed in - computeControlLaw() which must be called prior to this function. + \warning computeControlLaw() must be call prior to this function since it updates the projection operator \f$ \bf W^+W \f$. + + The following sample code shows how to use this method: + \code + vpColVector v; // Velocity applied to the robot + vpColVector de2dt; + vpServo task; + ... + v = task.computeControlLaw(); // Compute the primary task + v += task.secondaryTask(de2dt) // Compute and add the secondary task + \endcode \sa computeControlLaw() */ -vpColVector - vpServo::secondaryTask(vpColVector &de2dt) +vpColVector vpServo::secondaryTask(const vpColVector &de2dt) { if (rankJ1 == L.getCols()) { @@ -1077,28 +1440,38 @@ vpColVector } /*! - Compute the secondary task according to the projection operator. - See equation (7) of the IEEE RA magazine, dec 2005 paper. + Compute and return the secondary task vector according to the projection operator \f${\bf I-W^+W}\f$. For more details, + see equation(7) in the paper \cite Marchand05b. - \warning computeControlLaw() must be call prior to this function. + \param e2 : Value of the secondary task \f${\bf e}_2\f$. + \param de2dt : Value of \f$\frac{\partial {\bf e_2}}{\partial t}\f$ the derivative of the secondary task \f${\bf e}_2\f$. - Compute the vector: + \return The secondary task vector: \f[ -\lambda ({\bf I-W^+W}) {\bf e_2} + ({\bf I-W^+W})\frac{\partial {\bf e_2}}{\partial t} \f] - to be added to the primary task + + Note that the secondary task vector need than to be added to the primary task which can be in the general case written as: \f[ - -\lambda {\bf W^+W\widehat J_s^+(s-s^*)} + -\lambda {\bf W^+W {\widehat {\bf J}}_e^+({\bf s-s^*})} \f] - which is computed using computeControlLaw() method - \warning The projection operator \f$ \bf W^+W \f$ is computed in - computeControlLaw() which must be called prior to this function. + \warning computeControlLaw() must be call prior to this function since it updates the projection operator \f$ \bf W^+W \f$. + + The following sample code shows how to use this method: + \code + vpColVector v; // Velocity applied to the robot + vpColVector e2; + vpColVector de2dt; + vpServo task; + ... + v = task.computeControlLaw(); // Compute the primary task + v += task.secondaryTask(e2, de2dt) // Compute and add the secondary task + \endcode \sa computeControlLaw() */ -vpColVector - vpServo::secondaryTask(vpColVector &e2, vpColVector &de2dt) +vpColVector vpServo::secondaryTask(const vpColVector &e2, const vpColVector &de2dt) { if (rankJ1 == L.getCols()) { @@ -1127,9 +1500,91 @@ vpColVector } } +/*! + Return the projection operator \f${\bf I}-{\bf W}^+{\bf W}\f$. This operator is updated + after a call of computeControlLaw(). + +\code + vpServo task; + ... + vpColVector v = task.computeControlLaw(); // Compute the velocity corresponding to the visual servoing + vpMatrix I_WpW = task.getI_WpW(); // Get the projection operator +\endcode + \sa getWpW() + */ +vpMatrix vpServo::getI_WpW() const +{ + return I_WpW; +} -/* - * Local variables: - * c-basic-offset: 2 - * End: +/*! + Return the task jacobian \f$J\f$. The task jacobian is updated after a call of computeControlLaw(). + + In the general case, the task jacobian is given by \f${\bf J} = {\widehat {\bf L}} {^c}{\bf V}_a {^a}{\bf J}_e\f$. +\code + vpServo task; + ... + vpColVector v = task.computeControlLaw(); // Compute the velocity corresponding to the visual servoing + vpMatrix J = task.getTaskJacobian(); // Get the task jacobian used to compute v +\endcode + \sa getTaskJacobianPseudoInverse(), getInteractionMatrix() */ +vpMatrix vpServo::getTaskJacobian() const +{ + return J1; +} +/*! + Return the pseudo inverse of the task jacobian \f$J\f$. + + In the general case, the task jacobian is given by \f${\bf J} = {\widehat {\bf L}} {^c}{\bf V}_a {^a}{\bf J}_e\f$. + + The task jacobian and its pseudo inverse are updated after a call of computeControlLaw(). + + \return Pseudo inverse \f${J}^{+}\f$ of the task jacobian. +\code + vpServo task; + ... + vpColVector v = task.computeControlLaw(); // Compute the velocity corresponding to the visual servoing + vpMatrix Jp = task.getTaskJacobianPseudoInverse(); // Get the pseudo inverse of task jacobian used to compute v +\endcode + + \sa getTaskJacobian() + */ +vpMatrix vpServo::getTaskJacobianPseudoInverse() const +{ + return J1p; +} +/*! + Return the rank of the task jacobian. The rank is updated after a call of computeControlLaw(). + +\code + vpServo task; + ... + vpColVector v = task.computeControlLaw(); // Compute the velocity corresponding to the visual servoing + unsigned int rank = task.getTaskRank(); // Get the rank of the task jacobian +\endcode + */ +unsigned int vpServo::getTaskRank() const +{ + return rankJ1; +} + +/*! + Return the projection operator \f${\bf W}^+{\bf W}\f$. This operator is updated + after a call of computeControlLaw(). + + When the dimension of the task is equal to the number of degrees of freedom available + \f${\bf W^+W = I}\f$. + +\code + vpServo task; + ... + vpColVector v = task.computeControlLaw(); // Compute the velocity corresponding to the visual servoing + vpMatrix WpW = task.getWpW(); // Get the projection operator +\endcode + \sa getI_WpW() + */ +vpMatrix vpServo::getWpW() const +{ + return WpW; +} diff --git a/src/servo/vpServo.h b/src/servo/vpServo.h index 38fb6600ef4e52d06e5e9fa13456a388c7b0e275..cb8720cdb5d1ff35f51fcb98195aefeaa2a9d817 100644 --- a/src/servo/vpServo.h +++ b/src/servo/vpServo.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpServo.h 4276 2013-06-25 12:36:48Z fspindle $ + * $Id: vpServo.h 4674 2014-02-17 15:34:41Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -50,12 +50,12 @@ \brief Class required to compute the visual servoing control law */ +#include <list> + #include <visp/vpMatrix.h> #include <visp/vpVelocityTwistMatrix.h> #include <visp/vpBasicFeature.h> #include <visp/vpServoException.h> - -#include <visp/vpList.h> #include <visp/vpAdaptiveGain.h> @@ -63,7 +63,7 @@ \class vpServo \ingroup VsTask - \brief Class required to compute the visual servoing control law descbribed + Class required to compute the visual servoing control law descbribed in \cite Chaumette06a and \cite Chaumette07a. \warning To avoid potential memory leaks, it is mendatory to call @@ -72,6 +72,8 @@ vpServoException::notKilledProperly. To learn how to use this class, we suggest first to follow the \ref tutorial-ibvs. + The \ref tutorial-simu-robot-pioneer and \ref tutorial-boost-vs are also useful + for advanced usage of this class. The example below shows how to build a position-based visual servo from 3D visual features \f$s=({^{c^*}}t_c,\theta u)\f$. In that @@ -159,137 +161,91 @@ public: typedef enum { NONE, + /*!< No control law is specified. */ EYEINHAND_CAMERA, + /*!< Eye in hand visual servoing with the following control law + \f[{\bf v}_c = -\lambda {\widehat {\bf L}}^{+}_{e} {\bf e}\f] + where camera velocities are computed. */ EYEINHAND_L_cVe_eJe, + /*!< Eye in hand visual servoing with the following control law + \f[{\dot {\bf q}} = -\lambda \left( {{\widehat {\bf L}}_{e} {^c}{\bf V}_e {^e}{\bf J}_e} \right)^{+} {\bf e}\f] + where joint velocities are computed. */ EYETOHAND_L_cVe_eJe, + /*!< Eye to hand visual servoing with the following control law + \f[{\dot {\bf q}} = \lambda \left( {{\widehat {\bf L}}_{e} {^c}{\bf V}_e {^e}{\bf J}_e} \right)^{+} {\bf e}\f] + where joint velocities are computed. */ EYETOHAND_L_cVf_fVe_eJe, + /*!< Eye to hand visual servoing with the following control law + \f[{\dot {\bf q}} = \lambda \left( {{\widehat {\bf L}}_{e} {^c}{\bf V}_f {^f}{\bf V}_e {^e}{\bf J}_e} \right)^{+} {\bf e}\f] + where joint velocities are computed. */ EYETOHAND_L_cVf_fJe + /*!< Eye to hand visual servoing with the following control law + \f[{\dot {\bf q}} = \lambda \left( {{\widehat {\bf L}}_{e} {^c}{\bf V}_f {^f}{\bf J}_e} \right)^{+} {\bf e}\f] + where joint velocities are computed. */ } vpServoType; typedef enum { CURRENT, + /*!< In the control law (see vpServo::vpServoType), uses the interaction matrix \f${\widehat {\bf L}}_s \f$computed using the current features \f$\bf s\f$. */ DESIRED, + /*!< In the control law (see vpServo::vpServoType), uses the interaction matrix \f${\widehat {\bf L}}_{s^*} \f$computed using the desired features \f${\bf s}^*\f$. */ MEAN, + /*!< In the control law (see vpServo::vpServoType), uses the interaction matrix \f${\widehat {\bf L}} = \left({\widehat {\bf L}}_s + {\widehat {\bf L}}_{s^*}\right)/2 \f$. */ USER_DEFINED + /*!< In the control law (see vpServo::vpServoType), uses an interaction matrix set by the user. */ } vpServoIteractionMatrixType; typedef enum { - TRANSPOSE, - PSEUDO_INVERSE + TRANSPOSE, /*!< In the control law (see vpServo::vpServoType), uses the transpose instead of the pseudo inverse. */ + PSEUDO_INVERSE /*!< In the control law (see vpServo::vpServoType), uses the pseudo inverse. */ } vpServoInversionType; typedef enum { ALL, /*!< Print all the task information. */ CONTROLLER, /*!< Print the type of controller law. */ - ERROR_VECTOR, /*!< Print the error vector \f$(s-s^*)\f$. */ - FEATURE_CURRENT, /*!< Print the current features \f$s\f$. */ - FEATURE_DESIRED, /*!< Print the desired features \f$s^*\f$. */ + ERROR_VECTOR, /*!< Print the error vector \f$\bf e = (s-s^*)\f$. */ + FEATURE_CURRENT, /*!< Print the current features \f$\bf s\f$. */ + FEATURE_DESIRED, /*!< Print the desired features \f${\bf s}^*\f$. */ GAIN, /*!< Print the gain \f$\lambda\f$. */ INTERACTION_MATRIX, /*!< Print the interaction matrix. */ - MINIMUM /*!< Same as vpServoPrintType::ERROR_VECTOR. */ + MINIMUM /*!< Same as vpServo::vpServoPrintType::ERROR_VECTOR. */ } vpServoPrintType; public: // default constructor vpServo(); - //! constructor with Choice of the visual servoing control law - vpServo(vpServoType _servoType) ; - //! destructor + // constructor with Choice of the visual servoing control law + vpServo(vpServoType servoType) ; + // destructor virtual ~vpServo() ; - /*! - Return the velocity twist matrix used to transform a velocity skew vector from end-effector frame into the camera frame. - */ - vpVelocityTwistMatrix get_cVe() const { return cVe; } - /*! - Return the velocity twist matrix used to transform a velocity skew vector from robot fixed frame (also called world or base frame) into the camera frame. - */ - vpVelocityTwistMatrix get_cVf() const { return cVf; } - /*! - Return the velocity twist matrix used to transform a velocity skew vector from robot end-effector frame into the fixed frame (also called world or base frame). - */ - vpVelocityTwistMatrix set_fVe() const { return fVe; } - /*! - Return the robot jacobian expressed in the end-effector frame. - */ - vpMatrix get_eJe() const { return eJe; } - /*! - Return the robot jacobian expressed in the robot fixed frame (also called world or base frame). - */ - vpMatrix get_fJe() const { return fJe; } - - //! destruction (memory deallocation if required) - void kill() ; - - //! Choice of the visual servoing control law - void setServo(vpServoType _servo_type) ; - - void set_cVe(vpVelocityTwistMatrix &_cVe) { cVe = _cVe ; init_cVe = true ; } - void set_cVf(vpVelocityTwistMatrix &_cVf) { cVf = _cVf ; init_cVf = true ; } - void set_fVe(vpVelocityTwistMatrix &_fVe) { fVe = _fVe ; init_fVe = true ; } - - void set_cVe(vpHomogeneousMatrix &cMe) { cVe.buildFrom(cMe); init_cVe=true ;} - void set_cVf(vpHomogeneousMatrix &cMf) { cVf.buildFrom(cMf); init_cVf=true ;} - void set_fVe(vpHomogeneousMatrix &fMe) { fVe.buildFrom(fMe); init_fVe=true ;} - - void set_eJe(vpMatrix &_eJe) { eJe = _eJe ; init_eJe = true ; } - void set_fJe(vpMatrix &_fJe) { fJe = _fJe ; init_fJe = true ; } - - - //! Set the type of the interaction matrix (current, mean, desired, user). - void setInteractionMatrixType(const vpServoIteractionMatrixType &interactionMatrixType, - const vpServoInversionType &interactionMatrixInversion=PSEUDO_INVERSE) ; - - /*! - Set a variable which enable to compute the interaction matrix for each iteration. - \param forceInteractionMatrixComputation: If true it forces the interaction matrix computation even if it is already done. - */ - void setForceInteractionMatrixComputation(bool forceInteractionMatrixComputation) {this->forceInteractionMatrixComputation = forceInteractionMatrixComputation;} - - //! set the gain lambda - void setLambda(double _lambda) { lambda .initFromConstant (_lambda) ; } - void setLambda(const double at_zero, - const double at_infinity, - const double deriv_at_zero) - { lambda .initStandard (at_zero, at_infinity, deriv_at_zero) ; } - void setLambda(const vpAdaptiveGain& _l){lambda=_l;} - - //! create a new ste of two visual features + // create a new ste of two visual features void addFeature(vpBasicFeature& s, vpBasicFeature& s_star, - const unsigned int select=vpBasicFeature::FEATURE_ALL) ; - //! create a new ste of two visual features + const unsigned int select=vpBasicFeature::FEATURE_ALL) ; + // create a new ste of two visual features void addFeature(vpBasicFeature& s, - const unsigned int select=vpBasicFeature::FEATURE_ALL) ; + const unsigned int select=vpBasicFeature::FEATURE_ALL) ; + + // compute the desired control law + vpColVector computeControlLaw() ; + // compute the desired control law + vpColVector computeControlLaw(double t) ; + vpColVector computeControlLaw(double t, const vpColVector &e_dot_init); - //! compute the interaction matrix related to the set of visual features - vpMatrix computeInteractionMatrix() ; // compute the error between the current set of visual features and // the desired set of visual features vpColVector computeError() ; - //! compute the desired control law - vpColVector computeControlLaw() ; - //! test if all the initialization are correct if true control law can - //! be computed - bool testInitialization() ; - //! test if all the update are correct if true control law can - //! be computed - bool testUpdated() ; - - - //! Add a secondary task. - vpColVector secondaryTask(vpColVector &de2dt) ; - //! Add a secondary task. - vpColVector secondaryTask(vpColVector &e2, vpColVector &de2dt) ; - - //! Return the task dimension. - unsigned int getDimension() ; + // compute the interaction matrix related to the set of visual features + vpMatrix computeInteractionMatrix() ; + // Return the task dimension. + unsigned int getDimension() const ; /*! - Return the error \f$(s - s^*)\f$ between the current set of visual features - \f$s\f$ and the desired set of visual features \f$s^*\f$. + Return the error \f$\bf e = (s - s^*)\f$ between the current set of visual features + \f$\bf s\f$ and the desired set of visual features \f$\bf s^*\f$. The error vector is updated after a call of computeError() or computeControlLaw(). \code vpServo task; @@ -303,129 +259,203 @@ public: return error ; } /* - Return the interaction matrix \f$L\f$ used to compute the task jacobian \f$J_1\f$. - The interaction matrix is updated after a call to computeInteractionMatrix() or computeControlLaw(). - -\code - vpServo task; - ... - vpColVector v = task.computeControlLaw(); // Compute the velocity corresponding to the visual servoing - vpMatrix L = task.getInteractionMatrix(); // Get the interaction matrix used to compute v -\endcode - \sa getTaskJacobian() - */ - inline vpMatrix getInteractionMatrix() + Return the interaction matrix \f$L\f$ used to compute the task jacobian \f$J_1\f$. + The interaction matrix is updated after a call to computeInteractionMatrix() or computeControlLaw(). + + \code + vpServo task; + ... + vpColVector v = task.computeControlLaw(); // Compute the velocity corresponding to the visual servoing + vpMatrix L = task.getInteractionMatrix(); // Get the interaction matrix used to compute v + \endcode + \sa getTaskJacobian() + */ + inline vpMatrix getInteractionMatrix() const { return L; } + vpMatrix getI_WpW() const; /*! - Return the projection operator \f${\bf I}-{\bf W}^+{\bf W}\f$. This operator is updated - after a call of computeControlLaw(). - -\code - vpServo task; - ... - vpColVector v = task.computeControlLaw(); // Compute the velocity corresponding to the visual servoing - vpMatrix I_WpW = task.getI_WpW(); // Get the projection operator -\endcode - \sa getWpW() - */ - inline vpMatrix getI_WpW() const - { - return I_WpW; - } - /*! - Return the visual servo type. - */ + Return the visual servo type. + */ inline vpServoType getServoType() const { return servoType; } + + vpMatrix getTaskJacobian() const; + vpMatrix getTaskJacobianPseudoInverse() const; + unsigned int getTaskRank() const; + /*! - Return the task jacobian \f$J_1\f$. The task jacobian is updated after a call of computeControlLaw(). + Get task singular values. - In the general case, the task jacobian is given by \f$J_1 = L {^c}V_a {^a}J_e\f$. -\code - vpServo task; - ... - vpColVector v = task.computeControlLaw(); // Compute the velocity corresponding to the visual servoing - vpMatrix J1 = task.getTaskJacobian(); // Get the task jacobian used to compute v -\endcode - \sa getTaskJacobianPseudoInverse(), getInteractionMatrix() - */ - inline vpMatrix getTaskJacobian() const + \return Singular values that relies on the task jacobian pseudo inverse. + */ + inline vpColVector getTaskSingularValues() const { - return J1; + return sv; } + + vpMatrix getWpW() const; + + /*! + Return the velocity twist matrix used to transform a velocity skew vector from end-effector frame into the camera frame. + */ + vpVelocityTwistMatrix get_cVe() const { return cVe; } + /*! + Return the velocity twist matrix used to transform a velocity skew vector from robot fixed frame (also called world or base frame) into the camera frame. + */ + vpVelocityTwistMatrix get_cVf() const { return cVf; } + /*! + Return the velocity twist matrix used to transform a velocity skew vector from robot end-effector frame into the fixed frame (also called world or base frame). + */ + vpVelocityTwistMatrix get_fVe() const { return fVe; } + /*! + Return the robot jacobian expressed in the end-effector frame. + */ + vpMatrix get_eJe() const { return eJe; } /*! - Return the pseudo inverse of the task jacobian \f$J_1\f$. The task jacobian - and its pseudo inverse are updated after a call of computeControlLaw(). + Return the robot jacobian expressed in the robot fixed frame (also called world or base frame). + */ + vpMatrix get_fJe() const { return fJe; } - \return Pseudo inverse \f${J_1}^{+}\f$ of the task jacobian. -\code - vpServo task; - ... - vpColVector v = task.computeControlLaw(); // Compute the velocity corresponding to the visual servoing - vpMatrix J1p = task.getTaskJacobianPseudoInverse(); // Get the pseudo inverse of task jacobian used to compute v -\endcode + // destruction (memory deallocation if required) + void kill() ; + + void print(const vpServo::vpServoPrintType display_level=ALL, + std::ostream &os = std::cout) ; + + // Add a secondary task. + vpColVector secondaryTask(const vpColVector &de2dt) ; + // Add a secondary task. + vpColVector secondaryTask(const vpColVector &e2, const vpColVector &de2dt) ; + + /*! + Set a variable which enables to compute the interaction matrix at each iteration. + + When the interaction matrix is computed from the desired features \f${\bf s}^*\f$ which are in general constant, + the interaction matrix \f${\widehat {\bf L}}_{s^*}\f$ is computed just at the first iteration of the servo loop. + Sometimes, when the desired features are time dependent \f${{\bf s}(t)}^*\f$ or varying, the interaction matrix + need to be computed at each iteration of the servo loop. This method allows to force the computation of + \f${\widehat {\bf L}}\f$ in this particular case. + + \param force_computation: If true it forces the interaction matrix computation even if it is already done. - \sa getTaskJacobian() */ - inline vpMatrix getTaskJacobianPseudoInverse() const + void setForceInteractionMatrixComputation(bool force_computation) { - return J1p; + this->forceInteractionMatrixComputation = force_computation; } + /*! - Return the rank of the task jacobian. The rank is updated after a call of computeControlLaw(). + Set the interaction matrix type (current, desired, mean or user defined) and how its inverse is computed. + \param interactionMatrixType : The interaction matrix type. See vpServo::vpServoIteractionMatrixType for + more details. + \param interactionMatrixInversion : How is the inverse computed. See vpServo::vpServoInversionType for + more details. + */ + void setInteractionMatrixType(const vpServoIteractionMatrixType &interactionMatrixType, + const vpServoInversionType &interactionMatrixInversion=PSEUDO_INVERSE) ; -\code - vpServo task; - ... - vpColVector v = task.computeControlLaw(); // Compute the velocity corresponding to the visual servoing - double rank = task.getTaskRank(); // Get the rank of the task jacobian -\endcode - */ - inline double getTaskRank() const + /*! + Set the gain \f$\lambda\f$ used in the control law (see vpServo::vpServoType) as constant. + + The usage of an adaptive gain allows to reduce the convergence time, see setLambda(const vpAdaptiveGain&). + + \param c : Constant gain. Values are in general between 0.1 and 1. Higher is the gain, higher are the velocities + that may be applied to the robot. + */ + void setLambda(double c) { - return rankJ1; + lambda .initFromConstant (c) ; } /*! - Get task singular values. + Set the gain \f$\lambda\f$ used in the control law (see vpServo::vpServoType) as adaptive. + Value of \f$\lambda\f$ that is used in computeControlLaw() depend on the infinity norm of the task Jacobian. - \return Singular values that relies on the task jacobian pseudo inverse. - */ - inline vpColVector getTaskSingularValues() + The usage of an adaptive gain rather than a constant gain allows to reduce the convergence time. + + \param gain_at_zero : the expected gain when \f$x=0\f$: \f$\lambda(0)\f$. + \param gain_at_infinity : the expected gain when \f$x=\infty\f$: \f$\lambda(\infty)\f$. + \param slope_at_zero : the expected slope of \f$\lambda(x)\f$ when \f$x=0\f$: \f${\dot \lambda}(0)\f$. + + For more details on these parameters see vpAdaptiveGain class. + */ + void setLambda(const double gain_at_zero, + const double gain_at_infinity, + const double slope_at_zero) { - return sv; + lambda .initStandard (gain_at_zero, gain_at_infinity, slope_at_zero) ; } + /*! + Set the gain \f$\lambda\f$ used in the control law (see vpServo::vpServoType) as adaptive. + Value of \f$\lambda\f$ that is used in computeControlLaw() depend on the infinity norm of the task Jacobian. + The usage of an adaptive gain rather than a constant gain allows to reduce the convergence time. + \sa vpAdaptiveGain + */ + void setLambda(const vpAdaptiveGain& l){lambda=l;} /*! - Return the projection operator \f${\bf W}^+{\bf W}\f$. This operator is updated - after a call of computeControlLaw(). + Set the value of the parameter \f$\mu\f$ used to ensure the continuity of the velocities + computed using computeControlLaw(double). -\code - vpServo task; - ... - vpColVector v = task.computeControlLaw(); // Compute the velocity corresponding to the visual servoing - vpMatrix WpW = task.getWpW(); // Get the projection operator -\endcode - \sa getI_WpW() + A recommended value is 4. */ - inline vpMatrix getWpW() const - { - return WpW; - } + void setMu(double mu_){this->mu=mu_;} + // Choice of the visual servoing control law + void setServo(const vpServoType &servo_type) ; + + /*! + Set the velocity twist matrix used to transform a velocity skew vector from end-effector frame into the camera frame. + */ + void set_cVe(const vpVelocityTwistMatrix &cVe_) { this->cVe = cVe_ ; init_cVe = true ; } + /*! + Set the velocity twist matrix used to transform a velocity skew vector from end-effector frame into the camera frame. + */ + void set_cVe(const vpHomogeneousMatrix &cMe) { cVe.buildFrom(cMe); init_cVe=true ;} + /*! + Set the velocity twist matrix used to transform a velocity skew vector from robot fixed frame (also called world or base frame) into the camera frame. + */ + void set_cVf(const vpVelocityTwistMatrix &cVf_) { this->cVf = cVf_ ; init_cVf = true ; } + /*! + Set the velocity twist matrix used to transform a velocity skew vector from robot fixed frame (also called world or base frame) into the camera frame. + */ + void set_cVf(const vpHomogeneousMatrix &cMf) { cVf.buildFrom(cMf); init_cVf=true ;} + /*! + Set the velocity twist matrix used to transform a velocity skew vector from robot end-effector frame into the fixed frame (also called world or base frame). + */ + void set_fVe(const vpVelocityTwistMatrix &fVe_) { this->fVe = fVe_ ; init_fVe = true ; } + /*! + Set the velocity twist matrix used to transform a velocity skew vector from robot end-effector frame into the fixed frame (also called world or base frame). + */ + void set_fVe(const vpHomogeneousMatrix &fMe) { fVe.buildFrom(fMe); init_fVe=true ;} + /*! + Set the robot jacobian expressed in the end-effector frame. + */ + void set_eJe(const vpMatrix &eJe_) { this->eJe = eJe_ ; init_eJe = true ; } + /*! + Set the robot jacobian expressed in the robot fixed frame (also called world or base frame). + */ + void set_fJe(const vpMatrix &fJe_) { this->fJe = fJe_ ; init_fJe = true ; } - void print(const vpServo::vpServoPrintType display_level=ALL, - std::ostream &os = std::cout) ; -protected: - //! basic initialization + /*! + Test if all the initialization are correct. If true, the control law can be computed. + */ + bool testInitialization() ; + /*! + Test if all the update are correct. If true control law can be computed. + */ + bool testUpdated() ; + + protected: + //! Basic initialization. void init() ; -public: + public: //! Interaction matrix vpMatrix L ; //! Error \f$(s - s^*)\f$ between the current set of visual features @@ -449,7 +479,6 @@ public: //! Task \f$e = e_1 + (I-{J_1}^{+} J_1) e_2\f$ vpColVector e ; - //! Articular velocity vpColVector q_dot ; //! Camera velocity @@ -461,15 +490,15 @@ public: //! Rank of the task Jacobian unsigned int rankJ1 ; - //! List of visual features (produce \f$s\f$) - vpList<vpBasicFeature *> featureList ; - //! List of desired visual features (produce \f$s^*\f$) - vpList<vpBasicFeature *> desiredFeatureList ; + //! List of current visual features \f$\bf s\f$. + std::list<vpBasicFeature *> featureList ; + //! List of desired visual features \f$\bf s^*\f$. + std::list<vpBasicFeature *> desiredFeatureList ; //! List of selection among visual features - //! used for selection of a subset of each visual feature if required - vpList<unsigned int> featureSelectionList ; + //! used for selection of a subset of each visual feature if required. + std::list<unsigned int> featureSelectionList ; - //! Gain + //! Gain used in the control law. vpAdaptiveGain lambda ; //! Sign of the interaction +/- 1 (1 for eye-in-hand, -1 for @@ -478,21 +507,21 @@ public: //! Type of the interaction matrox (current, mean, desired, user) vpServoIteractionMatrixType interactionMatrixType ; //! Indicates if the transpose or the pseudo inverse of the - //!interaction matrix should be used to compute the task + //! interaction matrix should be used to compute the task. vpServoInversionType inversionType ; -protected: + protected: /* Twist transformation matrix */ - //! Twist transformation matrix between Re and Rc + //! Twist transformation matrix between Re and Rc. vpVelocityTwistMatrix cVe ; bool init_cVe ; - //! Twist transformation matrix between Rf and Rc + //! Twist transformation matrix between Rf and Rc. vpVelocityTwistMatrix cVf ; bool init_cVf ; - //! Twist transformation matrix between Re and Rf + //! Twist transformation matrix between Re and Rf. vpVelocityTwistMatrix fVe ; bool init_fVe ; @@ -511,29 +540,26 @@ protected: Task building */ - //! true if the error has been computed + //! true if the error has been computed. bool errorComputed ; - //! true if the interaction matrix has been computed + //! true if the interaction matrix has been computed. bool interactionMatrixComputed ; - //! dimension of the task + //! Dimension of the task updated during computeControlLaw(). unsigned int dim_task ; - bool taskWasKilled; // flag to indicate if the task was killed + //! Flag to indicate if the task was killed + bool taskWasKilled; //! Force the interaction matrix computation even if it is already done. bool forceInteractionMatrixComputation; - //! projection operators WpW + //! Projection operators \f$\bf WpW\f$. vpMatrix WpW ; - //! projection operators I-WpW + //! Projection operators \f$\bf I-WpW\f$. vpMatrix I_WpW ; - vpColVector sv ; // singular values from the pseudo inverse -} ; + //! Singular values from the pseudo inverse. + vpColVector sv ; + double mu; +} ; #endif - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ diff --git a/src/servo/vpServoData.cpp b/src/servo/vpServoData.cpp index 9ec92ef2e8b3a179f7505aec1e86cca7564b3594..183bcc285fb03fffbd31c74dbdbe87fc0079382f 100644 --- a/src/servo/vpServoData.cpp +++ b/src/servo/vpServoData.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpServoData.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpServoData.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/servo/vpServoData.h b/src/servo/vpServoData.h index e0fd793444905eb4be0db5979d0513744f329910..1f5ab8a67558fe2b91e3a25ba7c3125be29b2bc1 100644 --- a/src/servo/vpServoData.h +++ b/src/servo/vpServoData.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpServoData.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpServoData.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -81,15 +81,17 @@ private: public: #ifndef DOXYGEN_SHOULD_SKIP_THIS - vpServoData(const vpServoData &) { - throw vpException(vpException::functionNotImplementedError,"Not implemented!"); + vpServoData(const vpServoData &sd) + : velocityFile(), errorFile(), errorNormFile(), sFile(), + sStarFile(), vNormFile(), cmDeg(false) { + *this = sd; } - void operator=(const vpServoData &){ + vpServoData & operator=(const vpServoData &) { throw vpException(vpException::functionNotImplementedError,"Not implemented!"); } #endif - vpServoData() { ; } + vpServoData() : velocityFile(), errorFile(), errorNormFile(), sFile(), sStarFile(), vNormFile(), cmDeg(false) { ; } virtual ~vpServoData() { ; } //! velocity output in cm and deg diff --git a/src/servo/vpServoDisplay.cpp b/src/servo/vpServoDisplay.cpp index 5178bec3ac6c8ba71d22d8cab437aa22b22c2204..b0f39606e5fac9b9e0cc1d2554e1621ad2a5fbea 100644 --- a/src/servo/vpServoDisplay.cpp +++ b/src/servo/vpServoDisplay.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpServoDisplay.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpServoDisplay.cpp 4645 2014-02-05 17:44:06Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -80,34 +80,27 @@ \param thickness : Thickness of the feature representation. */ -void -vpServoDisplay::display(vpServo &s, - const vpCameraParameters &cam, - vpImage<unsigned char> &I, - vpColor currentColor, - vpColor desiredColor, - unsigned int thickness) +void vpServoDisplay::display(const vpServo &s, + const vpCameraParameters &cam, + const vpImage<unsigned char> &I, + vpColor currentColor, + vpColor desiredColor, + unsigned int thickness) { + std::list<vpBasicFeature *>::const_iterator it_s; + std::list<vpBasicFeature *>::const_iterator it_s_star; - - - for (s.featureList.front(), - s.desiredFeatureList.front() ; - !s.featureList.outside() ; - s.featureList.next(), - s.desiredFeatureList.next() ) + for (it_s = s.featureList.begin(), it_s_star = s.desiredFeatureList.begin(); + it_s != s.featureList.end(); + ++it_s, ++it_s_star) { - vpBasicFeature *s_ptr = NULL; - if (desiredColor != vpColor::none) { // desired list - s_ptr = s.desiredFeatureList.value() ; - s_ptr->display(cam, I, desiredColor, thickness ) ; + (*it_s_star)->display(cam, I, desiredColor, thickness ) ; } if (currentColor != vpColor::none) { // current list - s_ptr = s.featureList.value() ; - s_ptr->display(cam, I, currentColor, thickness ) ; + (*it_s)->display(cam, I, currentColor, thickness ) ; } } // vpDisplay::flush(I) ; @@ -134,40 +127,28 @@ vpServoDisplay::display(vpServo &s, */ void -vpServoDisplay::display(vpServo &s, +vpServoDisplay::display(const vpServo &s, const vpCameraParameters &cam, - vpImage<vpRGBa> &I, + const vpImage<vpRGBa> &I, vpColor currentColor, vpColor desiredColor, - unsigned int thickness) + unsigned int thickness) { + std::list<vpBasicFeature *>::const_iterator it_s; + std::list<vpBasicFeature *>::const_iterator it_s_star; - - - for (s.featureList.front(), - s.desiredFeatureList.front() ; - !s.featureList.outside() ; - s.featureList.next(), - s.desiredFeatureList.next() ) + for (it_s = s.featureList.begin(), it_s_star = s.desiredFeatureList.begin(); + it_s != s.featureList.end(); + ++it_s, ++it_s_star) { - vpBasicFeature *s_ptr = NULL; - if (desiredColor != vpColor::none) { // desired list - s_ptr = s.desiredFeatureList.value() ; - s_ptr->display(cam, I, desiredColor, thickness ) ; + (*it_s_star)->display(cam, I, desiredColor, thickness ) ; } if (currentColor != vpColor::none) { // current list - s_ptr = s.featureList.value() ; - s_ptr->display(cam, I, currentColor, thickness ) ; + (*it_s)->display(cam, I, currentColor, thickness ) ; } } // vpDisplay::flush(I) ; } - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ diff --git a/src/servo/vpServoDisplay.h b/src/servo/vpServoDisplay.h index eb4cd373fd7d7f225c4e3e35f57b9ce9c34b0489..130f8433836a7c921643e0c9b780af5466a71938 100644 --- a/src/servo/vpServoDisplay.h +++ b/src/servo/vpServoDisplay.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpServoDisplay.h 4062 2013-01-09 10:30:06Z fspindle $ + * $Id: vpServoDisplay.h 4645 2014-02-05 17:44:06Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -65,15 +65,15 @@ class VISP_EXPORT vpServoDisplay { public: - static void display(vpServo &s, + static void display(const vpServo &s, const vpCameraParameters &cam, - vpImage<unsigned char> &I, + const vpImage<unsigned char> &I, vpColor currentColor = vpColor::green, vpColor desiredColor = vpColor::red, unsigned int thickness=1) ; - static void display(vpServo &s, + static void display(const vpServo &s, const vpCameraParameters &cam, - vpImage<vpRGBa> &I, + const vpImage<vpRGBa> &I, vpColor currentColor = vpColor::green, vpColor desiredColor = vpColor::red, unsigned int thickness=1) ; diff --git a/src/servo/vpServoException.h b/src/servo/vpServoException.h index 164d88c29f74cd96ae49e9942043f4167cfc382f..f74fc67614a5ee2b4cc1fa9eaee9031452fda55f 100644 --- a/src/servo/vpServoException.h +++ b/src/servo/vpServoException.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpServoException.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpServoException.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -64,13 +64,13 @@ */ class VISP_EXPORT vpServoException : public vpException { -public: - /*! + public: + /*! \brief Lists the possible error than can be emmited while calling vpServo member */ - enum errorServoCodeEnum + enum errorServoCodeEnum { //! Current or desired feature list is empty noFeatureError, @@ -82,25 +82,20 @@ public: servoError } ; -public: - vpServoException (const int code, const char * msg) - : vpException(code, msg){ ; } - vpServoException (const int code, const std::string & msg) - : vpException(code, msg){ ; } - vpServoException (const int code) - : vpException(code){ ; } + public: + vpServoException (const int id, const char* format, ...) + { + this->code = id; + va_list args; + va_start(args, format); + setMessage(format, args); + va_end (args); + } + vpServoException (const int id, const std::string & msg) + : vpException(id, msg){ ; } + vpServoException (const int id) + : vpException(id){ ; } }; - - - - -#endif /* #ifndef __vpServoException_ERROR_H */ - - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ +#endif diff --git a/src/simulator/coin-simulator/vpAR.cpp b/src/simulator/coin-simulator/vpAR.cpp index 36dd8810bfb0a7af1431765a4268afa5aa955ded..48698e28ee43a3f4e4ae02b2f0421b5ef9b8a966 100644 --- a/src/simulator/coin-simulator/vpAR.cpp +++ b/src/simulator/coin-simulator/vpAR.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpAR.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpAR.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/coin-simulator/vpAR.h b/src/simulator/coin-simulator/vpAR.h index 6233e3616a16ce49bae951328642606fbb156d66..47ca36008182fc3d6d98eefc9e5a91f6edf77697 100644 --- a/src/simulator/coin-simulator/vpAR.h +++ b/src/simulator/coin-simulator/vpAR.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpAR.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpAR.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/coin-simulator/vpProjectionDisplay.cpp b/src/simulator/coin-simulator/vpProjectionDisplay.cpp index 42035d69152ece01cfcf22af0d7244ee7e3e7a21..b4fe61b96964c4d51780bbf16c861b2f1fe76653 100644 --- a/src/simulator/coin-simulator/vpProjectionDisplay.cpp +++ b/src/simulator/coin-simulator/vpProjectionDisplay.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpProjectionDisplay.cpp 4238 2013-05-06 13:29:30Z fspindle $ + * $Id: vpProjectionDisplay.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/coin-simulator/vpProjectionDisplay.h b/src/simulator/coin-simulator/vpProjectionDisplay.h index bbd645d52a30cf5a8bac92f9eb9c2dcd7789b675..6c137692de43043e5c467e2d7360c4257d72279a 100644 --- a/src/simulator/coin-simulator/vpProjectionDisplay.h +++ b/src/simulator/coin-simulator/vpProjectionDisplay.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpProjectionDisplay.h 4238 2013-05-06 13:29:30Z fspindle $ + * $Id: vpProjectionDisplay.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -96,8 +96,25 @@ public: static int internalView() { return 0x01 ; } static int externalView() { return 0x02 ; } - vpProjectionDisplay() { init() ;} - vpProjectionDisplay(int select) { init(select) ;} + /*! Default constructor. */ + vpProjectionDisplay() + : Icam(), Iext(), +#if defined (VISP_HAVE_DISPLAY) + dIcam(), dIext(), +#endif + listFp(), o(), x(), y(), z(), traj() + { + init(); + } + vpProjectionDisplay(int select) + : Icam(), Iext(), +#if defined (VISP_HAVE_DISPLAY) + dIcam(), dIext(), +#endif + listFp(), o(), x(), y(), z(), traj() + { + init(select) ; + } void insert( vpForwardProjection &fp) ; void display(vpImage<unsigned char> &I, diff --git a/src/simulator/coin-simulator/vpSimulator.cpp b/src/simulator/coin-simulator/vpSimulator.cpp index 68671f242b11998a42d6ebb1a7f38848f166e2d7..d5b031e810daa374d21fecec7420553fddb0e586 100644 --- a/src/simulator/coin-simulator/vpSimulator.cpp +++ b/src/simulator/coin-simulator/vpSimulator.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpSimulator.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: vpSimulator.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -291,6 +291,24 @@ vpSimulator::init() offScreenRenderer = NULL ; bufferView = NULL; get = 1 ; + typeImage = grayImage; + mainThread = NULL; + scene = NULL; + internalRoot = NULL; + externalRoot = NULL; + internalCamera = NULL; + externalCamera = NULL; + internalCameraPosition = NULL; + extrenalCameraPosition = NULL; + internalCameraObject = NULL; +#if defined(VISP_HAVE_SOWIN) + // mainWindow = ?; +#elif defined(VISP_HAVE_SOQT) + mainWindow = NULL; +#elif defined(VISP_HAVE_SOXT) + // mainWindow = ?; +#endif + } void vpSimulator::kill() diff --git a/src/simulator/coin-simulator/vpSimulator.h b/src/simulator/coin-simulator/vpSimulator.h index bdc9d88c7f0c22118255574117a1497cbf491d37..6f1c4d410dfe95024a41dda59e23ccdf9f45ac0c 100644 --- a/src/simulator/coin-simulator/vpSimulator.h +++ b/src/simulator/coin-simulator/vpSimulator.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpSimulator.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpSimulator.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/coin-simulator/vpSimulatorException.h b/src/simulator/coin-simulator/vpSimulatorException.h index 5a97ef49bc8f9eff008b1fff4868afc5e9d29f33..887b749d4ebc743b40ec864ad908fca98848a3b7 100644 --- a/src/simulator/coin-simulator/vpSimulatorException.h +++ b/src/simulator/coin-simulator/vpSimulatorException.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpSimulatorException.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpSimulatorException.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -73,12 +73,12 @@ */ class VISP_EXPORT vpSimulatorException : public vpException { -public: - /*! + public: + /*! \brief Lists the possible error than can be emmited while calling vpSimulator member */ - enum errorSimulatorCodeEnum + enum errorSimulatorCodeEnum { ioError, noFileNameError, @@ -87,25 +87,20 @@ public: badInitializationError } ; -public: - vpSimulatorException (const int code, const char * msg) - : vpException(code, msg){ ; } - vpSimulatorException (const int code, const std::string & msg) - : vpException(code, msg){ ; } - vpSimulatorException (const int code) - : vpException(code){ ; } + public: + vpSimulatorException (const int id, const char* format, ...) + { + this->code = id; + va_list args; + va_start(args, format); + setMessage(format, args); + va_end (args); + } + vpSimulatorException (const int id, const std::string & msg) + : vpException(id, msg){ ; } + vpSimulatorException (const int id) + : vpException(id){ ; } }; - - - - -#endif /* #ifndef __vpSimulatorException_H */ - - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ +#endif diff --git a/src/simulator/coin-simulator/vpViewer.cpp b/src/simulator/coin-simulator/vpViewer.cpp index cd5b6d0b21d35235c34421018d3132c1ed9cfb64..69e66e6508ce2d2c88ef68ca8ce297a2555e4072 100644 --- a/src/simulator/coin-simulator/vpViewer.cpp +++ b/src/simulator/coin-simulator/vpViewer.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpViewer.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpViewer.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/coin-simulator/vpViewer.h b/src/simulator/coin-simulator/vpViewer.h index 97ef3586f3d51f64e8c2f70aeb85df6480c05789..c02bc4d18ae9f2ce43c0816778ca97482832e479 100644 --- a/src/simulator/coin-simulator/vpViewer.h +++ b/src/simulator/coin-simulator/vpViewer.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpViewer.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpViewer.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/image-simulator/vpImageSimulator.cpp b/src/simulator/image-simulator/vpImageSimulator.cpp index 2c60c48ef7718a83f29b9b4a21e36c9b0a5652e3..c9d56e8a4fa12669885a44976add6efdb5c0952f 100644 --- a/src/simulator/image-simulator/vpImageSimulator.cpp +++ b/src/simulator/image-simulator/vpImageSimulator.cpp @@ -3,7 +3,7 @@ * $Id: vpPose.h 2453 2010-01-07 10:01:10Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -59,6 +59,12 @@ By default the class uses colored images. */ vpImageSimulator::vpImageSimulator(const vpColorPlan &col) + : cMt(), interp(SIMPLE), normal_obj(), normal_Cam(), normal_Cam_optim(), + distance(1.), visible_result(1.), visible(false), X0_2_optim(NULL), + euclideanNorm_u(0.), euclideanNorm_v(0.), vbase_u(), vbase_v(), + vbase_u_optim(NULL), vbase_v_optim(NULL), Xinter_optim(NULL), T1(), T2(), + colorI(col), Ig(), Ic(), rect(), cleanPrevImage(false), + setBackgroundTexture(false), bgColor(vpColor::white), focal() { for(int i=0;i<4;i++) X[i].resize(3); @@ -84,12 +90,6 @@ vpImageSimulator::vpImageSimulator(const vpColorPlan &col) vbase_u_optim = new double[3]; vbase_v_optim = new double[3]; Xinter_optim = new double[3]; - - colorI = col; - interp = SIMPLE; - bgColor = vpColor::white; - cleanPrevImage = false; - setBackgroundTexture = false; } @@ -97,6 +97,12 @@ vpImageSimulator::vpImageSimulator(const vpColorPlan &col) Copy constructor */ vpImageSimulator::vpImageSimulator(const vpImageSimulator &text) + : cMt(), interp(SIMPLE), normal_obj(), normal_Cam(), normal_Cam_optim(), + distance(1.), visible_result(1.), visible(false), X0_2_optim(NULL), + euclideanNorm_u(0.), euclideanNorm_v(0.), vbase_u(), vbase_v(), + vbase_u_optim(NULL), vbase_v_optim(NULL), Xinter_optim(NULL), T1(), T2(), + colorI(GRAY_SCALED), Ig(), Ic(), rect(), cleanPrevImage(false), + setBackgroundTexture(false), bgColor(vpColor::white), focal() { for(int i=0;i<4;i++) { @@ -1423,12 +1429,12 @@ vpImageSimulator::getImage(vpImage<vpRGBa> &I, /*! Enable to set the position of the 3D plane relative to the virtual camera. - \param _cMt : The pose of the plane relative to the virtual camera. + \param cMt_ : The pose of the plane relative to the virtual camera. */ void -vpImageSimulator::setCameraPosition(const vpHomogeneousMatrix &_cMt) +vpImageSimulator::setCameraPosition(const vpHomogeneousMatrix &cMt_) { - cMt = _cMt; + cMt = cMt_; vpRotationMatrix R; cMt.extract(R); @@ -1457,8 +1463,9 @@ vpImageSimulator::setCameraPosition(const vpHomogeneousMatrix &_cMt) if (angle > 0) visible=true; - else + else { visible=false; + } if(visible) { @@ -1500,12 +1507,12 @@ vpImageSimulator::setCameraPosition(const vpHomogeneousMatrix &_cMt) } void -vpImageSimulator::initPlan(vpColVector* _X) +vpImageSimulator::initPlan(vpColVector* X_) { for (unsigned int i = 0; i < 4; i++) { - X[i]=_X[i]; - pt[i].setWorldCoordinates(_X[i][0],_X[i][1],_X[i][2]); + X[i]=X_[i]; + pt[i].setWorldCoordinates(X_[i][0],X_[i][1],X_[i][2]); } normal_obj=vpColVector::crossProd(X[1]-X[0],X[3]-X[0]); @@ -1526,14 +1533,14 @@ vpImageSimulator::initPlan(vpColVector* _X) - \f$ X[3] \f$ :Bottom left corner. \param I : The image which is projected. - \param _X : table of the 3D coordinates corresponding to the image corners. + \param X_ : table of the 3D coordinates corresponding to the image corners. */ void -vpImageSimulator::init(const vpImage<unsigned char> &I,vpColVector* _X) +vpImageSimulator::init(const vpImage<unsigned char> &I,vpColVector* X_) { Ig = I; vpImageConvert::convert(I,Ic); - initPlan(_X); + initPlan(X_); } /*! @@ -1547,14 +1554,14 @@ vpImageSimulator::init(const vpImage<unsigned char> &I,vpColVector* _X) - \f$ X[3] \f$ :Bottom left corner. \param I : The image which is projected. - \param _X : table of the 3D coordinates corresponding to the image corners. + \param X_ : table of the 3D coordinates corresponding to the image corners. */ void -vpImageSimulator::init(const vpImage<vpRGBa> &I,vpColVector* _X) +vpImageSimulator::init(const vpImage<vpRGBa> &I,vpColVector* X_) { Ic = I; vpImageConvert::convert(I,Ig); - initPlan(_X); + initPlan(X_); } /*! @@ -1568,14 +1575,14 @@ vpImageSimulator::init(const vpImage<vpRGBa> &I,vpColVector* _X) - \f$ X[3] \f$ :Bottom left corner. \param file_image : The adress of an image file. - \param _X : table of the 3D coordinates corresponding to the image corners. + \param X_ : table of the 3D coordinates corresponding to the image corners. */ void -vpImageSimulator::init(const char* file_image,vpColVector* _X) +vpImageSimulator::init(const char* file_image,vpColVector* X_) { vpImageIo::read(Ig,file_image); vpImageIo::read(Ic,file_image); - initPlan(_X); + initPlan(X_); } /*! @@ -1589,21 +1596,21 @@ vpImageSimulator::init(const char* file_image,vpColVector* _X) - \f$ X[3] \f$ :Bottom left corner. \param I : The image which is projected. - \param _X : Vector of the 3D coordinates in the object frame (oX, oY, oZ) + \param X_ : Vector of the 3D coordinates in the object frame (oX, oY, oZ) corresponding to the image corners. */ void -vpImageSimulator::init(const vpImage<unsigned char> &I, const std::vector<vpPoint>& _X) +vpImageSimulator::init(const vpImage<unsigned char> &I, const std::vector<vpPoint>& X_) { - if(_X.size() != 4){ + if(X_.size() != 4){ throw vpException(vpException::dimensionError, "the vector must contains 4 points to initialise the simulator"); } vpColVector Xvec[4]; for(unsigned int i=0; i<4; ++i){ Xvec[i].resize(3); - Xvec[i][0] = _X[i].get_oX(); - Xvec[i][1] = _X[i].get_oY(); - Xvec[i][2] = _X[i].get_oZ(); + Xvec[i][0] = X_[i].get_oX(); + Xvec[i][1] = X_[i].get_oY(); + Xvec[i][2] = X_[i].get_oZ(); } Ig = I; @@ -1613,7 +1620,7 @@ vpImageSimulator::init(const vpImage<unsigned char> &I, const std::vector<vpPoin /*! Initialise the image thanks to an image \f$ I \f$ and a table of vector containing the 3D coordinates of the image's corners. - \throw vpException::dimensionError if the _X vector is not of size 4. + \throw vpException::dimensionError if the X_ vector is not of size 4. - \f$ X[0] \f$ :Top left corner. - \f$ X[1] \f$ :Top right corner. @@ -1621,21 +1628,21 @@ vpImageSimulator::init(const vpImage<unsigned char> &I, const std::vector<vpPoin - \f$ X[3] \f$ :Bottom left corner. \param I : The image which is projected. - \param _X : Vector of the 3D coordinates in the object frame (oX, oY, oZ) + \param X_ : Vector of the 3D coordinates in the object frame (oX, oY, oZ) corresponding to the image corners. */ void -vpImageSimulator::init(const vpImage<vpRGBa> &I, const std::vector<vpPoint>& _X) +vpImageSimulator::init(const vpImage<vpRGBa> &I, const std::vector<vpPoint>& X_) { - if(_X.size() != 4){ + if(X_.size() != 4){ throw vpException(vpException::dimensionError, "the vector must contains 4 points to initialise the simulator"); } vpColVector Xvec[4]; for(unsigned int i=0; i<4; ++i){ Xvec[i].resize(3); - Xvec[i][0] = _X[i].get_oX(); - Xvec[i][1] = _X[i].get_oY(); - Xvec[i][2] = _X[i].get_oZ(); + Xvec[i][0] = X_[i].get_oX(); + Xvec[i][1] = X_[i].get_oY(); + Xvec[i][2] = X_[i].get_oZ(); } Ic = I; @@ -1645,7 +1652,7 @@ vpImageSimulator::init(const vpImage<vpRGBa> &I, const std::vector<vpPoint>& _X) /*! Initialise the image thanks to an image whose adress is given by \f$ file_image \f$ and a table of vector containing the 3D coordinates of the image's corners. - \throw vpException::dimensionError if the _X vector is not of size 4. + \throw vpException::dimensionError if the X_ vector is not of size 4. - \f$ X[0] \f$ :Top left corner. - \f$ X[1] \f$ :Top right corner. @@ -1653,21 +1660,21 @@ vpImageSimulator::init(const vpImage<vpRGBa> &I, const std::vector<vpPoint>& _X) - \f$ X[3] \f$ :Bottom left corner. \param file_image : The adress of an image file. - \param _X : Vector of the 3D coordinates in the object frame (oX, oY, oZ) + \param X_ : Vector of the 3D coordinates in the object frame (oX, oY, oZ) corresponding to the image corners. */ void -vpImageSimulator::init(const char* file_image, const std::vector<vpPoint>& _X) +vpImageSimulator::init(const char* file_image, const std::vector<vpPoint>& X_) { - if(_X.size() != 4){ + if(X_.size() != 4){ throw vpException(vpException::dimensionError, "the vector must contains 4 points to initialise the simulator"); } vpColVector Xvec[4]; for(unsigned int i=0; i<4; ++i){ Xvec[i].resize(3); - Xvec[i][0] = _X[i].get_oX(); - Xvec[i][1] = _X[i].get_oY(); - Xvec[i][2] = _X[i].get_oZ(); + Xvec[i][0] = X_[i].get_oX(); + Xvec[i][1] = X_[i].get_oY(); + Xvec[i][2] = X_[i].get_oZ(); } vpImageIo::read(Ig,file_image); @@ -1951,3 +1958,18 @@ vpImageSimulator::getRoi(const unsigned int &Iwidth, rectangle.setLeft(left); rectangle.setRight(right); } + +std::vector<vpColVector> +vpImageSimulator::get3DcornersTextureRectangle() +{ + std::vector<vpColVector> X_; + for (int i=0; i<4; i++) + X_.push_back(X[i]); + return X_; +} + +VISP_EXPORT std::ostream& operator<< (std::ostream &os, const vpImageSimulator& /*ip*/) +{ + os << ""; + return os; +} diff --git a/src/simulator/image-simulator/vpImageSimulator.h b/src/simulator/image-simulator/vpImageSimulator.h index d9357ef42d3994b3c0ff8e231fd4fc98b3267ae4..01f99ea5d9d12d9eefc69110adff69d979681f16 100644 --- a/src/simulator/image-simulator/vpImageSimulator.h +++ b/src/simulator/image-simulator/vpImageSimulator.h @@ -3,7 +3,7 @@ * $Id: vpPose.h 2453 2010-01-07 10:01:10Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -210,17 +210,17 @@ class VISP_EXPORT vpImageSimulator //creation du plan a partir de ses coordonnees 3D ds repere objet et de son image texture - void init(const vpImage<unsigned char> &I,vpColVector* _X); - void init(const vpImage<vpRGBa> &I,vpColVector* _X); - void init(const char* file_image,vpColVector* _X); - void init(const vpImage<unsigned char> &I, const std::vector<vpPoint>& _X); - void init(const vpImage<vpRGBa> &I, const std::vector<vpPoint>& _X); - void init(const char* file_image, const std::vector<vpPoint>& _X); + void init(const vpImage<unsigned char> &I,vpColVector* X); + void init(const vpImage<vpRGBa> &I,vpColVector* X); + void init(const char* file_image,vpColVector* X); + void init(const vpImage<unsigned char> &I, const std::vector<vpPoint>& X); + void init(const vpImage<vpRGBa> &I, const std::vector<vpPoint>& X); + void init(const char* file_image, const std::vector<vpPoint>& X); //projection du plan par cMo => creation des deux triangles definissant projection du plan sur plan image (coord en metre) - void setCameraPosition(const vpHomogeneousMatrix &_cMt); + void setCameraPosition(const vpHomogeneousMatrix &cMt); - void setInterpolationType (const vpInterpolationType interp) {this->interp = interp;} + void setInterpolationType (const vpInterpolationType interplt) {this->interp = interplt;} void getImage(vpImage<unsigned char> &I, const vpCameraParameters &cam); void getImage(vpImage<vpRGBa> &I, const vpCameraParameters &cam); @@ -242,6 +242,10 @@ class VISP_EXPORT vpImageSimulator std::list <vpImageSimulator> &list, const vpCameraParameters &cam); + std::vector<vpColVector> get3DcornersTextureRectangle(); + + friend VISP_EXPORT std::ostream& operator<< (std::ostream &os, const vpImageSimulator& /*ip*/); + /*! As it can be time consuming to reset all the image to a default baground value, this function enable to reset only the pixel which changed the previous time. @@ -278,7 +282,7 @@ class VISP_EXPORT vpImageSimulator #endif private: - void initPlan(vpColVector* _X); + void initPlan(vpColVector* X); //result = plan est visible. //ie: un plan est oriente dans si normal_plan.focal < 0 => plan est visible sinon invisible. @@ -307,12 +311,6 @@ class VISP_EXPORT vpImageSimulator const vpCameraParameters &cam, vpPoint* pt, vpRect &rect); }; -VISP_EXPORT inline std::ostream& operator<< (std::ostream &os, const vpImageSimulator& /*ip*/) -{ - os << ""; - return os; -} - #endif diff --git a/src/simulator/ogre-simulator/vpAROgre.cpp b/src/simulator/ogre-simulator/vpAROgre.cpp index bcedcc320d24d7659d3821c62d407261aa533c5d..79a2fc9cdc1edc7e498102b296e6fd7c22c5acbf 100644 --- a/src/simulator/ogre-simulator/vpAROgre.cpp +++ b/src/simulator/ogre-simulator/vpAROgre.cpp @@ -1,10 +1,10 @@ /**************************************************************************** * - * $Id: vpAROgre.cpp 4251 2013-05-14 12:19:56Z fspindle $ + * $Id: vpAROgre.cpp 4604 2014-01-21 14:15:23Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. - * + * Copyright (C) 2005 - 2014 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. @@ -12,11 +12,11 @@ * 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 + * 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 @@ -26,7 +26,7 @@ * * 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. * @@ -72,8 +72,8 @@ telling Ogre where to look for renderer plugins. */ -vpAROgre::vpAROgre(const vpCameraParameters &cam, - unsigned int width, unsigned int height, +vpAROgre::vpAROgre(const vpCameraParameters &cam, + unsigned int width, unsigned int height, const char *resourcePath, const char *pluginsPath) : mRoot(0), mCamera(0), mSceneMgr(0), mWindow(0) #ifdef VISP_HAVE_OIS @@ -96,12 +96,16 @@ vpAROgre::vpAROgre(const vpCameraParameters &cam, windowHidden = false; mshowConfigDialog = true; mOptionnalResourceLocation.clear(); - + name = "ViSP - Augmented Reality"; + + mBackground = NULL; + mBackgroundHeight = 0; + mBackgroundWidth = 0; } /*! - Initialisation of Ogre with a grey level background. + Initialisation of Ogre with a grey level background. Load the plugins that are specified in the plugins.cfg or plugins_d.cfg files. These files are located in @@ -109,27 +113,27 @@ vpAROgre::vpAROgre(const vpCameraParameters &cam, Note that plugins.cfg file is always considered under Unix platforms. The file plugins_d.cfg is only considered under Windows when the build type is Debug. - + Load also the resources that are defined in the resources.cfg file. This file is located in VISP_HAVE_OGRE_RESOURCES_PATH folder that is defined in vpConfig.h. - - Create also the grey level background used to display the image. + + Create also the grey level background used to display the image. \param I : Image that is displayed in the background. \param bufferedKeys : If true, use of buffered input for the keyboard (see Ogre documentation). Note that this parameter is only useful if OIS is used. - - \param hidden : If true, the created window will be hidden. + + \param hidden : If true, the created window will be hidden. Note that this functionnality requires Ogre3D 1.8.1 at least. - + \exception vpException::ioError : If the required plugins.cfg / plugins_d.cfg or resources.cfg files are not accessible. */ void vpAROgre::init(vpImage<unsigned char> &I, - bool + bool #ifdef VISP_HAVE_OIS bufferedKeys #endif @@ -138,21 +142,21 @@ void vpAROgre::init(vpImage<unsigned char> &I, { mBackgroundWidth = I.getWidth(); mBackgroundHeight = I.getHeight(); - + init( #ifdef VISP_HAVE_OIS bufferedKeys, #else false, #endif - hidden + hidden ); // Create the background image which will come from the grabber createBackground(I); } /*! - Initialisation of Ogre with a color background. + Initialisation of Ogre with a color background. Load the plugins that are specified in the plugins.cfg or plugins_d.cfg files. These files are located in @@ -160,27 +164,27 @@ void vpAROgre::init(vpImage<unsigned char> &I, Note that plugins.cfg file is always considered under Unix platforms. The file plugins_d.cfg is only considered under Windows when the build type is Debug. - + Load also the resources that are defined in the resources.cfg file. This file is located in VISP_HAVE_OGRE_RESOURCES_PATH folder that is defined in vpConfig.h. - - Create also a color background used to display the image. + + Create also a color background used to display the image. \param I : Image that is displayed in the background. \param bufferedKeys : If true, use of buffered input for the keyboard (see Ogre documentation). Note that this parameter is only useful if OIS is used. - - \param hidden : If true, the created window will be hidden. + + \param hidden : If true, the created window will be hidden. Note that this functionnality requires Ogre3D 1.8.1 at least. - + \exception vpException::ioError : If the required plugins.cfg / plugins_d.cfg or resources.cfg files are not accessible. */ void vpAROgre::init(vpImage<vpRGBa> &I, - bool + bool #ifdef VISP_HAVE_OIS bufferedKeys #endif @@ -189,7 +193,7 @@ void vpAROgre::init(vpImage<vpRGBa> &I, { mBackgroundWidth = I.getWidth(); mBackgroundHeight = I.getHeight(); - + init( #ifdef VISP_HAVE_OIS bufferedKeys, @@ -203,7 +207,7 @@ void vpAROgre::init(vpImage<vpRGBa> &I, } /*! - Initialisation of Ogre. + Initialisation of Ogre. Load the plugins that are specified in the plugins.cfg or plugins_d.cfg files. These files are located in @@ -211,22 +215,22 @@ void vpAROgre::init(vpImage<vpRGBa> &I, Note that plugins.cfg file is always considered under Unix platforms. The file plugins_d.cfg is only considered under Windows when the build type is Debug. - + Load also the resources that are defined in the resources.cfg file. This file is located in VISP_HAVE_OGRE_RESOURCES_PATH folder that is defined in vpConfig.h. - + \param bufferedKeys : If true, use of buffered input for the keyboard (see Ogre documentation). Note that this parameter is only useful if OIS is used. - - \param hidden : If true, the created window will be hidden. + + \param hidden : If true, the created window will be hidden. Note that this functionnality requires Ogre3D 1.8.1 at least. - + \exception vpException::ioError : If the required plugins.cfg / plugins_d.cfg or resources.cfg files are not accessible. */ -void vpAROgre::init(bool +void vpAROgre::init(bool #ifdef VISP_HAVE_OIS bufferedKeys #endif @@ -234,20 +238,20 @@ void vpAROgre::init(bool ) { // Create the root -#if defined(NDEBUG) || !defined(WIN32) +#if defined(NDEBUG) || !defined(_WIN32) std::string pluginFile = mPluginsPath+"/plugins.cfg"; #else std::string pluginFile = mPluginsPath+"/plugins_d.cfg"; #endif if(!vpIoTools::checkFilename(pluginFile)){ - std::string errorMsg = "Error: the requested plugins file \"" + std::string errorMsg = "Error: the requested plugins file \"" + pluginFile + "\" doesn't exist."; std::cout << errorMsg << std::endl; throw (vpException(vpException::ioError, errorMsg)); } std::cout << "######################### Load plugin file: " << pluginFile << std::endl; - + if(Ogre::Root::getSingletonPtr() == NULL) mRoot = new Ogre::Root(pluginFile, "ogre.cfg", "Ogre.log"); else @@ -266,7 +270,7 @@ void vpAROgre::init(bool Ogre::ConfigFile cf; std::string resourceFile = mResourcePath+"/resources.cfg"; if(!vpIoTools::checkFilename(resourceFile)){ - std::string errorMsg = "Error: the requested resource file \"" + std::string errorMsg = "Error: the requested resource file \"" + resourceFile + "\" doesn't exist."; std::cout << errorMsg << std::endl; @@ -297,7 +301,7 @@ void vpAROgre::init(bool for(std::list<std::string>::const_iterator iter = mOptionnalResourceLocation.begin(); iter != mOptionnalResourceLocation.end(); ++iter){ Ogre::ResourceGroupManager::getSingleton().addResourceLocation(*iter, "FileSystem", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); } - + // Create the window bool canInit = true; if(mshowConfigDialog){ @@ -309,30 +313,30 @@ void vpAROgre::init(bool if(!mRoot->restoreConfig()) canInit = false; } - + if(!mRoot->isInitialised()){ if(!canInit){ //We set the default renderer system const Ogre::RenderSystemList& lRenderSystemList = mRoot->getAvailableRenderers(); if( lRenderSystemList.size() == 0 ) - throw "ConfigDialog aborted"; // Exit the application on cancel - + throw "ConfigDialog aborted"; // Exit the application on cancel + Ogre::RenderSystem *lRenderSystem = lRenderSystemList.at(0); std::cout << "Using " << lRenderSystem->getName() << " as renderer." << std::endl; mRoot->setRenderSystem(lRenderSystem); } - - mRoot->initialise(false); + + mRoot->initialise(false); } - - bool fullscreen = false; + + bool fullscreen = false; Ogre::NameValuePairList misc; Ogre::ConfigOptionMap config = mRoot->getRenderSystem()->getConfigOptions(); Ogre::ConfigOptionMap::const_iterator it = config.begin(); - + while( it != config.end() ){ Ogre::String leftconf = (*it).first; Ogre::String rightconf = (*it).second.currentValue; - + if(leftconf == "Video Mode"){ if(canInit) sscanf(rightconf.c_str(), "%d %*s %d", &mWindowWidth, &mWindowHeight); @@ -350,19 +354,19 @@ void vpAROgre::init(bool } else misc[leftconf] = rightconf; - + it++; } - + // With Ogre version >= 1.8.1 we hide the window - if( hidden && ((OGRE_VERSION_MAJOR << 16 | OGRE_VERSION_MINOR << 8 | OGRE_VERSION_PATCH) >= (1 << 16 | 8 << 8 | 1)) ){ + if( hidden ){ +#if ( OGRE_VERSION >= (1 << 16 | 8 << 8 | 1) ) misc["hidden"] = "true"; windowHidden = true; - mWindow = mRoot->createRenderWindow(name, mWindowWidth, mWindowHeight, fullscreen, &misc); +#endif } - else - mWindow = mRoot->createRenderWindow(name, mWindowWidth, mWindowHeight, fullscreen, &misc); - + mWindow = mRoot->createRenderWindow(name, mWindowWidth, mWindowHeight, fullscreen, &misc); + // Initialise resources Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); //----------------------------------------------------- @@ -374,12 +378,12 @@ void vpAROgre::init(bool // ST_EXTERIOR_REAL_FAR = paging landscape // ST_INTERIOR = Quake3 BSP //----------------------------------------------------- - + mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC); - + // Create the camera createCamera(); - + // Create a viewport Ogre::Viewport* viewPort = mWindow->addViewport(mCamera); // Ogre::Viewport* viewPort = mCamera->getViewport(); @@ -408,7 +412,7 @@ void vpAROgre::init(bool windowHndStr << windowHnd; pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str())); // Let the user use the keyboard elsewhere -#if defined (UNIX) +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX pl.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("false"))); #endif @@ -420,12 +424,12 @@ void vpAROgre::init(bool if ( !bufferedKeys ) mKeyboard->setEventCallback ( this); #endif - // Initialise a render to texture to be able to retrieve a screenshot + // Initialise a render to texture to be able to retrieve a screenshot Ogre::TexturePtr Texture = Ogre::TextureManager::getSingleton().createManual("rtf", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,Ogre::TEX_TYPE_2D, mWindow->getWidth(),mWindow->getHeight(), 0, Ogre::PF_R8G8B8A8, Ogre::TU_RENDERTARGET); - - - + + + // Ogre::TexturePtr Texture = Ogre::TextureManager::getSingleton().createManual("rtf", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,Ogre::TEX_TYPE_2D, // 640,480, 0, Ogre::PF_R8G8B8A8, Ogre::TU_RENDERTARGET); Ogre::RenderTexture* RTarget = Texture->getBuffer()->getRenderTarget(); @@ -507,7 +511,7 @@ bool vpAROgre::frameEnded(const Ogre::FrameEvent& evt) else return result; } -/*! +/*! Function telling what to do before each frame. This method is called before every frame rendered by Ogre. @@ -558,7 +562,7 @@ void vpAROgre::windowClosed(Ogre::RenderWindow* rw) \param I : Grey level image to show in background. \param cMw : Camera pose as an homogeneous matrix. */ -bool vpAROgre::renderOneFrame(const vpImage<unsigned char> &I, +bool vpAROgre::renderOneFrame(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMw) { // Update the background to match the situation @@ -576,7 +580,7 @@ bool vpAROgre::renderOneFrame(const vpImage<unsigned char> &I, \param I : RGBa image to show in background. \param cMw : Camera pose as an homogeneous matrix. */ -bool vpAROgre::renderOneFrame(const vpImage<vpRGBa> &I, +bool vpAROgre::renderOneFrame(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMw) { // Update the background to match the situation @@ -594,7 +598,7 @@ bool vpAROgre::renderOneFrame(const vpImage<vpRGBa> &I, \param I : Grey level image to show in background. \param cMw : Camera pose as an homogeneous matrix. */ -void vpAROgre::display(const vpImage<unsigned char> &I, +void vpAROgre::display(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMw) { // Display on Ogre Window @@ -635,7 +639,7 @@ bool vpAROgre::continueRendering(void) Set the camera intrinsic parameters */ void vpAROgre::setCameraParameters(const vpCameraParameters &cameraP ) -{ +{ mcam = cameraP; } @@ -657,7 +661,7 @@ void vpAROgre::load(const std::string &name, const std::string &model) \param wTo : New position of the node (translation between object frame and world frame). */ -void vpAROgre::setPosition(const std::string &name, +void vpAROgre::setPosition(const std::string &name, const vpTranslationVector &wTo) { // Reset the position @@ -686,7 +690,7 @@ void vpAROgre::setRotation(const std::string &name, const vpRotationMatrix &wRo) // Get the node in its original position mSceneMgr->getSceneNode(name)->resetOrientation(); // Apply the new rotation - Ogre::Matrix3 rotationOgre + Ogre::Matrix3 rotationOgre = Ogre::Matrix3( (Ogre::Real)wRo[0][0], (Ogre::Real)wRo[0][1], (Ogre::Real)wRo[0][2], (Ogre::Real)wRo[1][0], (Ogre::Real)wRo[1][1], (Ogre::Real)wRo[1][2], (Ogre::Real)wRo[2][0], (Ogre::Real)wRo[2][1], (Ogre::Real)wRo[2][2]); @@ -699,18 +703,18 @@ void vpAROgre::setRotation(const std::string &name, const vpRotationMatrix &wRo) \param name : Name of the SceneNode to rotate. \param wRo : The rotation matrix representing the rotation to apply. */ -void vpAROgre::addRotation(const std::string &name, +void vpAROgre::addRotation(const std::string &name, const vpRotationMatrix &wRo) { - // Apply the new rotation - Ogre::Matrix3 rotationOgre + // Apply the new rotation + Ogre::Matrix3 rotationOgre = Ogre::Matrix3( (Ogre::Real)wRo[0][0], (Ogre::Real)wRo[0][1], (Ogre::Real)wRo[0][2], (Ogre::Real)wRo[1][0], (Ogre::Real)wRo[1][1], (Ogre::Real)wRo[1][2], (Ogre::Real)wRo[2][0], (Ogre::Real)wRo[2][1], (Ogre::Real)wRo[2][2]); Ogre::Quaternion q(rotationOgre); mSceneMgr->getSceneNode(name)->rotate(q); - - + + } /*! @@ -721,7 +725,7 @@ void vpAROgre::addRotation(const std::string &name, translation to apply. */ -void vpAROgre::setPosition(const std::string &name, +void vpAROgre::setPosition(const std::string &name, const vpHomogeneousMatrix &wMo) { // Extract the position and orientation data @@ -808,14 +812,22 @@ void vpAROgre::createBackground(vpImage<unsigned char> & /* I */) // Pointer to the dynamic texture Ogre::TexturePtr dynTexPtr = Ogre::TextureManager::getSingleton().getByName("BackgroundTexture"); - - // Get the pixel buffer +//#if ( OGRE_VERSION >= (1 << 16 | 9 << 8 | 0) ) +// .dynamicCast<Ogre::Texture>();// Get the pixel buffer +//#else +// ; +//#endif mPixelBuffer = dynTexPtr->getBuffer(); // Material to apply the texture to the background - Ogre::MaterialPtr Backgroundmaterial + Ogre::MaterialPtr Backgroundmaterial = Ogre::MaterialManager::getSingleton().create("BackgroundMaterial", - Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); + Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); +//#if ( OGRE_VERSION >= (1 << 16 | 9 << 8 | 0) ) +// .dynamicCast<Ogre::Material>(); +//#else +// ; +//#endif Ogre::Technique *Backgroundtechnique = Backgroundmaterial->createTechnique(); Backgroundtechnique->createPass(); Backgroundmaterial->getTechnique(0)->getPass(0)->setLightingEnabled(false); @@ -873,15 +885,26 @@ void vpAROgre::createBackground(vpImage<vpRGBa> & /* I */) // Pointer to the dynamic texture - Ogre::TexturePtr dynTexPtr = Ogre::TextureManager::getSingleton().getByName("BackgroundTexture"); + Ogre::TexturePtr dynTexPtr = + Ogre::TextureManager::getSingleton().getByName("BackgroundTexture"); +//#if ( OGRE_VERSION >= (1 << 16 | 9 << 8 | 0) ) +// .dynamicCast<Ogre::Texture>();// Get the pixel buffer +//#else +// ; +//#endif // Get the pixel buffer mPixelBuffer = dynTexPtr->getBuffer(); // Material to apply the texture to the background - Ogre::MaterialPtr Backgroundmaterial + Ogre::MaterialPtr Backgroundmaterial = Ogre::MaterialManager::getSingleton().create("BackgroundMaterial", - Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); + Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); +//#if ( OGRE_VERSION >= (1 << 16 | 9 << 8 | 0) ) +// .dynamicCast<Ogre::Material>(); +//#else +// ; +//#endif Ogre::Technique *Backgroundtechnique = Backgroundmaterial->createTechnique(); Backgroundtechnique->createPass(); Backgroundmaterial->getTechnique(0)->getPass(0)->setLightingEnabled(false); @@ -930,8 +953,8 @@ void vpAROgre::updateCameraProjection(void) py = (Ogre::Real)mcam.get_py(); u0 = (Ogre::Real)mcam.get_u0(); v0 = (Ogre::Real)mcam.get_v0(); - Ogre::Matrix4 Projection - = Ogre::Matrix4( (Ogre::Real)(2.0*px/mBackgroundWidth), 0, (Ogre::Real)(2.0*(u0/mBackgroundWidth)-1.0), 0, + Ogre::Matrix4 Projection + = Ogre::Matrix4( (Ogre::Real)(2.0*px/mBackgroundWidth), 0, (Ogre::Real)(2.0*(u0/mBackgroundWidth)-1.0), 0, 0, (Ogre::Real)(2.0*py/mBackgroundHeight), (Ogre::Real)(2.0*(v0/mBackgroundHeight)-1.0),0, 0, 0, (Ogre::Real)(-1.0*f_p_n/f_m_n), (Ogre::Real)(-2.0*f*n/f_m_n), 0, 0, -1.0, 0); @@ -944,7 +967,7 @@ void vpAROgre::updateCameraProjection(void) void vpAROgre::updateBackgroundTexture(const vpImage<unsigned char> &I) { // Inspired from Ogre wiki : http://www.ogre3d.org/tikiwiki/Creating+dynamic+textures - // Lock the pixel buffer and get a pixel box. HBL_DISCARD is to use for best + // Lock the pixel buffer and get a pixel box. HBL_DISCARD is to use for best // performance than HBL_NORMAL mPixelBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD); // Lock the buffer const Ogre::PixelBox& pixelBox = mPixelBuffer->getCurrentLock(); @@ -963,7 +986,7 @@ void vpAROgre::updateBackgroundTexture(const vpImage<unsigned char> &I) void vpAROgre::updateBackgroundTexture(const vpImage<vpRGBa> &I) { // Inspired from Ogre wiki : http://www.ogre3d.org/tikiwiki/Creating+dynamic+textures - // Lock the pixel buffer and get a pixel box. HBL_DISCARD is to use for best + // Lock the pixel buffer and get a pixel box. HBL_DISCARD is to use for best // performance than HBL_NORMAL mPixelBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD); // Lock the buffer const Ogre::PixelBox& pixelBox = mPixelBuffer->getCurrentLock(); @@ -977,18 +1000,18 @@ void vpAROgre::updateBackgroundTexture(const vpImage<vpRGBa> &I) // *pDest++=I[i][mBackgroundWidth-j].B; // Blue component // *pDest++=I[i][mBackgroundWidth-j].G; // Green component // *pDest++=I[i][mBackgroundWidth-j].R; // Red component - + *pDest++=I[i][j].B; // Blue component *pDest++=I[i][j].G; // Green component *pDest++=I[i][j].R; // Red component - + *pDest++ = 255; // Alpha component } } #else // if texture in RGBa format which is the format of the input image memcpy(pDest, I.bitmap, mBackgroundHeight*mBackgroundWidth*sizeof(vpRGBa)); #endif - + // Unlock the pixel buffer mPixelBuffer->unlock(); } @@ -999,7 +1022,7 @@ void vpAROgre::updateBackgroundTexture(const vpImage<vpRGBa> &I) void vpAROgre::updateCameraParameters (const vpHomogeneousMatrix &cMw) { // The matrix is given to Ogre with some changes to fit with the world projection - Ogre::Matrix4 ModelView + Ogre::Matrix4 ModelView // = Ogre::Matrix4( (Ogre::Real)-cMo[0][0], (Ogre::Real)-cMo[0][1], (Ogre::Real)-cMo[0][2], (Ogre::Real)-cMo[0][3], = Ogre::Matrix4( (Ogre::Real)cMw[0][0], (Ogre::Real)cMw[0][1], (Ogre::Real)cMw[0][2], (Ogre::Real)cMw[0][3], (Ogre::Real)-cMw[1][0], (Ogre::Real)-cMw[1][1], (Ogre::Real)-cMw[1][2], (Ogre::Real)-cMw[1][3], @@ -1018,6 +1041,11 @@ void vpAROgre::getRenderingOutput(vpImage<vpRGBa> &I, const vpHomogeneousMatrix { updateCameraParameters(cMo); Ogre::TexturePtr dynTexPtr = Ogre::TextureManager::getSingleton().getByName("rtf"); +//#if ( OGRE_VERSION >= (1 << 16 | 9 << 8 | 0) ) +// .dynamicCast<Ogre::Texture>(); +//#else +// ; +//#endif Ogre::RenderTexture* RTarget = dynTexPtr->getBuffer()->getRenderTarget(); mWindow->update(); RTarget->update(); @@ -1032,7 +1060,7 @@ void vpAROgre::getRenderingOutput(vpImage<vpRGBa> &I, const vpHomogeneousMatrix #if 1 // if texture in BGRa format for(unsigned int i=0; i<I.getHeight(); i++){ for(unsigned int j=0; j<I.getWidth(); j++){ - // Color Image + // Color Image I[i][j].B = *pDest++; // Blue component I[i][j].G = *pDest++; // Green component I[i][j].R = *pDest++; // Red component diff --git a/src/simulator/ogre-simulator/vpAROgre.h b/src/simulator/ogre-simulator/vpAROgre.h index 1c1c5f07115495b7a1b67590b7b84d796a98178b..42dd1839a592bcc5b00409f784ff9a2303bd945b 100644 --- a/src/simulator/ogre-simulator/vpAROgre.h +++ b/src/simulator/ogre-simulator/vpAROgre.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpAROgre.h 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpAROgre.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpArit.c b/src/simulator/wireframe-simulator/core/vpArit.c index f804f4b9cf0e84d3392e2800f1f151ae34af9902..62f7f5fbd470966e3f5ce90a27611890d2e7e964 100755 --- a/src/simulator/wireframe-simulator/core/vpArit.c +++ b/src/simulator/wireframe-simulator/core/vpArit.c @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpArit.c 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpArit.c 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpArit.h b/src/simulator/wireframe-simulator/core/vpArit.h index b0790fe3b31096231e10641eab8821be77b1d9ff..6424b1cd32a016a3ed166937915be59ac5870a4c 100755 --- a/src/simulator/wireframe-simulator/core/vpArit.h +++ b/src/simulator/wireframe-simulator/core/vpArit.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpArit.h 4310 2013-07-08 08:48:34Z fspindle $ + * $Id: vpArit.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpAritio.c b/src/simulator/wireframe-simulator/core/vpAritio.c index efd96a9562436d44fe3a1b7252412d2e5b111bbe..80d935148892e6b6b32a4c44d456f9aa3044efcf 100755 --- a/src/simulator/wireframe-simulator/core/vpAritio.c +++ b/src/simulator/wireframe-simulator/core/vpAritio.c @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpAritio.c 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpAritio.c 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpBound.c b/src/simulator/wireframe-simulator/core/vpBound.c index 11904bd3647762d045904b6baa330f14fee8d5f4..2eb3980976661148e0b4e9a1d602ddf447e4949d 100755 --- a/src/simulator/wireframe-simulator/core/vpBound.c +++ b/src/simulator/wireframe-simulator/core/vpBound.c @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpBound.c 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpBound.c 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpBound.h b/src/simulator/wireframe-simulator/core/vpBound.h index ae03f6528d790cb22a7c0e44f876d103853e3649..d05b2a9b1035721b6282d4410713d9f094e79a1f 100755 --- a/src/simulator/wireframe-simulator/core/vpBound.h +++ b/src/simulator/wireframe-simulator/core/vpBound.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpBound.h 4332 2013-07-22 14:23:46Z fspindle $ + * $Id: vpBound.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpBoundio.c b/src/simulator/wireframe-simulator/core/vpBoundio.c index 0f191a98ae3b13d79f457ec7cc4191beb641cbf4..c27cc5949848144495370b032abb3dda36dae384 100755 --- a/src/simulator/wireframe-simulator/core/vpBoundio.c +++ b/src/simulator/wireframe-simulator/core/vpBoundio.c @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpBoundio.c 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpBoundio.c 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpCgiconstants.h b/src/simulator/wireframe-simulator/core/vpCgiconstants.h index f01ad4ee24cb09d1c2716fd3eb416feb5228d95e..c4b9727ecea3a2462da99bca541520521aa3b991 100755 --- a/src/simulator/wireframe-simulator/core/vpCgiconstants.h +++ b/src/simulator/wireframe-simulator/core/vpCgiconstants.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpCgiconstants.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpCgiconstants.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpCgidefs.h b/src/simulator/wireframe-simulator/core/vpCgidefs.h index b01bdc205b69b20787160a385ffcb09e36368291..7ed5c3b64294b4ded270aadc52c0ef90ba001fbd 100755 --- a/src/simulator/wireframe-simulator/core/vpCgidefs.h +++ b/src/simulator/wireframe-simulator/core/vpCgidefs.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpCgidefs.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpCgidefs.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpClipping.c b/src/simulator/wireframe-simulator/core/vpClipping.c index ea7c833ed7c227b51107ed67c3e6acda5ea7e8cf..b36a3c33dca6b4f8270a04d7ffbd1207f72ba00f 100755 --- a/src/simulator/wireframe-simulator/core/vpClipping.c +++ b/src/simulator/wireframe-simulator/core/vpClipping.c @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpClipping.c 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpClipping.c 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpDisplay.c b/src/simulator/wireframe-simulator/core/vpDisplay.c index a1458c703ceddb8841d21f015a5842694c994ba9..ca80982f6651f5ce60ea5f92acd80c660455e078 100755 --- a/src/simulator/wireframe-simulator/core/vpDisplay.c +++ b/src/simulator/wireframe-simulator/core/vpDisplay.c @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDisplay.c 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpDisplay.c 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpImstack.h b/src/simulator/wireframe-simulator/core/vpImstack.h index 99eda9251dfbd873b1c49ae31f568f3b4ac36584..1fa1061f735ab18e97a4e701316baa79d9cdd944 100755 --- a/src/simulator/wireframe-simulator/core/vpImstack.h +++ b/src/simulator/wireframe-simulator/core/vpImstack.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpImstack.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpImstack.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpKeyword.c b/src/simulator/wireframe-simulator/core/vpKeyword.c index 72cdb7f2d1f11c118b9d415c34d9972c3b26a9f1..8337e5752e88b4bf69d905caac7c26d1d2456c83 100755 --- a/src/simulator/wireframe-simulator/core/vpKeyword.c +++ b/src/simulator/wireframe-simulator/core/vpKeyword.c @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpKeyword.c 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpKeyword.c 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpKeyword.h b/src/simulator/wireframe-simulator/core/vpKeyword.h index 0cfd08ff5bc48b730e49235646d4881ebf856d7f..f75bf11d747f176fda2a694beafae9fc43065639 100644 --- a/src/simulator/wireframe-simulator/core/vpKeyword.h +++ b/src/simulator/wireframe-simulator/core/vpKeyword.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpKeyword.h 4332 2013-07-22 14:23:46Z fspindle $ + * $Id: vpKeyword.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpLex.c b/src/simulator/wireframe-simulator/core/vpLex.c index 366dfc3a2fe3f5c78c81558bf154fdf349dbacb1..630570c8c75dbcf056a7f861de0dfcdb118dccc8 100755 --- a/src/simulator/wireframe-simulator/core/vpLex.c +++ b/src/simulator/wireframe-simulator/core/vpLex.c @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpLex.c 4303 2013-07-04 14:14:00Z fspindle $ + * $Id: vpLex.c 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -239,9 +239,9 @@ void close_lex (void) #define ECHO printf ("%c", *(mysptr)) -#define CURC (*mysptr) /* caractere courant */ -#define NEXTC (*(mysptr+1)) /* caractere suivant */ -#define PREVC (*(mysptr-1)) /* caractere precedent */ +#define CURC (*((signed char *)mysptr)) /* caractere courant */ +#define NEXTC (*((signed char *)mysptr+1)) /* caractere suivant */ +#define PREVC (*((signed char *)mysptr-1)) /* caractere precedent */ /* @@ -341,6 +341,7 @@ printf("mytext %s, myfloat %f\n",mytext,myfloat); */ return (T_FLOAT); } + break; case 'E' : /* lecture exposant */ case 'e' : mysptr++; @@ -437,179 +438,180 @@ string : int lexecho (FILE *f, int token) { lex_loop : - for (; chtbl[(int)CURC] == SPCT; mysptr++) /* saute les espaces */ - fwrite (mysptr, 1, 1, f); - - switch (chtbl[(int)CURC]) { - - case NULT : - mytext = mysptr; /* sauvegarde le jeton */ - mysptr++; - if (token != *mytext) - fwrite (mytext, 1, 1, f); - return (*mytext); - break; - case EOBT : - next_source (); - goto lex_loop; - break; - case EOFT : - mytext = mysptr; /* sauvegarde le jeton */ - return (T_EOF); - break; - case EOLT : - fwrite (mysptr, 1, 1, f); - if (mysptr == lastline) next_source (); - else mysptr++; - mylineno++; - myline = mysptr; - goto lex_loop; - break; - case CMTT : - fwrite (mysptr, 1, 1, f); - mytext = mysptr; /* sauvegarde le jeton */ - mysptr++; - if (CURC != '*') - return (*mytext); - fwrite (mysptr, 1, 1, f); - mysptr++; + for (; chtbl[(int)CURC] == SPCT; mysptr++) /* saute les espaces */ + fwrite (mysptr, 1, 1, f); + + switch (chtbl[(int)CURC]) { + + case NULT : + mytext = mysptr; /* sauvegarde le jeton */ + mysptr++; + if (token != *mytext) + fwrite (mytext, 1, 1, f); + return (*mytext); + break; + case EOBT : + next_source (); + goto lex_loop; + break; + case EOFT : + mytext = mysptr; /* sauvegarde le jeton */ + return (T_EOF); + break; + case EOLT : + fwrite (mysptr, 1, 1, f); + if (mysptr == lastline) next_source (); + else mysptr++; + mylineno++; + myline = mysptr; + goto lex_loop; + break; + case CMTT : + fwrite (mysptr, 1, 1, f); + mytext = mysptr; /* sauvegarde le jeton */ + mysptr++; + if (CURC != '*') + return (*mytext); + fwrite (mysptr, 1, 1, f); + mysptr++; comment : - for (; iscmtt((int)CURC); mysptr++) - fwrite (mysptr, 1, 1, f); - switch (chtbl[(int)CURC]) { - case EOBT : - next_source (); - goto comment; - break; - case EOFT : - lexerr ("start", lex_errtbl[E_CMT_EOF], NULL); - return (T_EOF); - break; - case EOLT : - fwrite (mysptr, 1, 1, f); - if (mysptr == lastline) next_source (); - else mysptr++; - mylineno++; - myline = mysptr; - goto comment; - break; - case CMTT : - fwrite (mysptr, 1, 1, f); - if (PREVC == '*') { /* veritable fin */ - mysptr++; - goto lex_loop; - } - mysptr++; /* pseudo fin */ - goto comment; - break; - } - break; - case IDNT : - mytext = mysptr; /* sauvegarde le jeton */ - mysptr++; - for (; isidnt((int)CURC); mysptr++); - mylength = (int)(mysptr - mytext); - if (token != get_symbol (mytext, mylength)) - fwrite (mytext, mylength, 1, f); - return (get_symbol (mytext, mylength)); - break; - case INTT : - mytext = mysptr; /* sauvegarde le jeton */ + for (; iscmtt((int)CURC); mysptr++) + fwrite (mysptr, 1, 1, f); + switch (chtbl[(int)CURC]) { + case EOBT : + next_source (); + goto comment; + break; + case EOFT : + lexerr ("start", lex_errtbl[E_CMT_EOF], NULL); + return (T_EOF); + break; + case EOLT : + fwrite (mysptr, 1, 1, f); + if (mysptr == lastline) next_source (); + else mysptr++; + mylineno++; + myline = mysptr; + goto comment; + break; + case CMTT : + fwrite (mysptr, 1, 1, f); + if (PREVC == '*') { /* veritable fin */ + mysptr++; + goto lex_loop; + } + mysptr++; /* pseudo fin */ + goto comment; + break; + } + break; + case IDNT : + mytext = mysptr; /* sauvegarde le jeton */ + mysptr++; + for (; isidnt((int)CURC); mysptr++); + mylength = (int)(mysptr - mytext); + if (token != get_symbol (mytext, mylength)) + fwrite (mytext, mylength, 1, f); + return (get_symbol (mytext, mylength)); + break; + case INTT : + mytext = mysptr; /* sauvegarde le jeton */ int_part : - mysptr++; - for (; isintt((int)CURC); mysptr++); - switch (CURC) { - case '.' : /* lecture fraction */ + mysptr++; + for (; isintt((int)CURC); mysptr++); + switch (CURC) { + case '.' : /* lecture fraction */ float_part : - mysptr++; - for (; isintt((int)CURC); mysptr++); - if (CURC != 'E' && CURC != 'e') { - if (token != T_FLOAT) - fwrite (mytext, mysptr - mytext, 1, f); - return (T_FLOAT); - } - case 'E' : /* lecture exposant */ - case 'e' : - mysptr++; - if (isintt((int)CURC)) mysptr++; - else if (issgnt((int)CURC) && isintt((int)NEXTC)) mysptr +=2; - else { - mysptr--; - if (token != T_FLOAT) - fwrite (mytext, mysptr - mytext, 1, f); - return (T_FLOAT); - } - for (; isintt((int)CURC); mysptr++); - if (token != T_FLOAT) - fwrite (mytext, mysptr - mytext, 1, f); - return (T_FLOAT); - break; - default : - if (token != T_INT) - fwrite (mytext, mysptr - mytext, 1, f); - return (T_INT); - break; - } - break; - case FPTT : - mytext = mysptr; /* sauvegarde le jeton */ - mysptr++; - if (! isintt((int)CURC)) { /* pas de fraction */ - if (token != *mytext) - fwrite (mytext, 1, 1, f); - return (*mytext); - } - goto float_part; - break; - case SGNT : - mytext = mysptr; /* sauvegarde le jeton */ - mysptr++; - if (isintt((int)CURC)) goto int_part; - if (isfptt((int)CURC) && isintt((int)NEXTC)) goto float_part; - if (token != *mytext) - fwrite (mytext, 1, 1, f); - return (*mytext); - break; - case STGT : - fwrite (mysptr, 1, 1, f); - mytext = mysptr; /* sauvegarde le jeton */ - mysptr++; + mysptr++; + for (; isintt((int)CURC); mysptr++); + if (CURC != 'E' && CURC != 'e') { + if (token != T_FLOAT) + fwrite (mytext, mysptr - mytext, 1, f); + return (T_FLOAT); + } + break; + case 'E' : /* lecture exposant */ + case 'e' : + mysptr++; + if (isintt((int)CURC)) mysptr++; + else if (issgnt((int)CURC) && isintt((int)NEXTC)) mysptr +=2; + else { + mysptr--; + if (token != T_FLOAT) + fwrite (mytext, mysptr - mytext, 1, f); + return (T_FLOAT); + } + for (; isintt((int)CURC); mysptr++); + if (token != T_FLOAT) + fwrite (mytext, mysptr - mytext, 1, f); + return (T_FLOAT); + break; + default : + if (token != T_INT) + fwrite (mytext, mysptr - mytext, 1, f); + return (T_INT); + break; + } + break; + case FPTT : + mytext = mysptr; /* sauvegarde le jeton */ + mysptr++; + if (! isintt((int)CURC)) { /* pas de fraction */ + if (token != *mytext) + fwrite (mytext, 1, 1, f); + return (*mytext); + } + goto float_part; + break; + case SGNT : + mytext = mysptr; /* sauvegarde le jeton */ + mysptr++; + if (isintt((int)CURC)) goto int_part; + if (isfptt((int)CURC) && isintt((int)NEXTC)) goto float_part; + if (token != *mytext) + fwrite (mytext, 1, 1, f); + return (*mytext); + break; + case STGT : + fwrite (mysptr, 1, 1, f); + mytext = mysptr; /* sauvegarde le jeton */ + mysptr++; string : - for (; isstgt((int)CURC); mysptr++) - fwrite (mysptr, 1, 1, f); - switch (chtbl[(int)CURC]) { - case EOBT : - next_source (); - goto comment; - break; - case EOFT : - lexerr ("start", lex_errtbl[E_STG_EOF], NULL); - return (T_EOF); - break; - case EOLT : - lexerr ("start", lex_errtbl[E_STG_EOL], NULL); - return ('\n'); - break; - case STGT : - fwrite (mysptr, 1, 1, f); - if (PREVC != '\\') { /* veritable fin */ - mytext++; - mylength = (int)(mysptr - mytext); - mysptr++; - return (T_STRING); - } - mysptr++; /* pseudo fin */ - goto string; - break; - } - break; - default : - fwrite (mysptr, 1, 1, f); - mysptr++; - goto lex_loop; - break; - } - return (T_EOF); + for (; isstgt((int)CURC); mysptr++) + fwrite (mysptr, 1, 1, f); + switch (chtbl[(int)CURC]) { + case EOBT : + next_source (); + goto comment; + break; + case EOFT : + lexerr ("start", lex_errtbl[E_STG_EOF], NULL); + return (T_EOF); + break; + case EOLT : + lexerr ("start", lex_errtbl[E_STG_EOL], NULL); + return ('\n'); + break; + case STGT : + fwrite (mysptr, 1, 1, f); + if (PREVC != '\\') { /* veritable fin */ + mytext++; + mylength = (int)(mysptr - mytext); + mysptr++; + return (T_STRING); + } + mysptr++; /* pseudo fin */ + goto string; + break; + } + break; + default : + fwrite (mysptr, 1, 1, f); + mysptr++; + goto lex_loop; + break; + } + return (T_EOF); } @@ -689,11 +691,7 @@ static void next_source (void) while ((*--bot = *--top) != EOL); myline = mysptr = bot + 1; - //if ((size = read (fds, buf, BUFSIZE)) < 0) { - if ((size = fread (buf,sizeof (char), BUFSIZE,fds)) < 0) { - perror (source); - exit (1); - } + size = fread (buf,sizeof (char), BUFSIZE,fds); if (size == 0) { topbuf = buf + 1; *buf = EOF; diff --git a/src/simulator/wireframe-simulator/core/vpLex.h b/src/simulator/wireframe-simulator/core/vpLex.h index f213fa4eaebcd1788bd24dfc1a77adfff4477cd1..495ed7308294c216dcecd7ac32b3250aae2e9328 100644 --- a/src/simulator/wireframe-simulator/core/vpLex.h +++ b/src/simulator/wireframe-simulator/core/vpLex.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpLex.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpLex.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpMy.h b/src/simulator/wireframe-simulator/core/vpMy.h index 941382cb42cc6cf9b80f8de996b2a0799f5a0369..ac303f78c32e5fb5e80b0066eb877290b45da2b7 100755 --- a/src/simulator/wireframe-simulator/core/vpMy.h +++ b/src/simulator/wireframe-simulator/core/vpMy.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMy.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMy.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpMyio.c b/src/simulator/wireframe-simulator/core/vpMyio.c index da4008c314f01b4eefed3542c9227b172e44d039..986dcf40b453072908536faa230b8074f606e8dd 100755 --- a/src/simulator/wireframe-simulator/core/vpMyio.c +++ b/src/simulator/wireframe-simulator/core/vpMyio.c @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMyio.c 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMyio.c 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -107,7 +107,14 @@ void fscanf_string (char **str) lexerr ("start", "string expected", NULL); if (*str == NULL) *str = (char *) malloc ((mylength + 1) * sizeof (char)); - else *str = (char *) realloc (*str, (mylength + 1) * sizeof (char)); + else + *str = (char *) realloc (*str, (mylength + 1) * sizeof (char)); + + if (*str == NULL) { + printf("Unable to read the string: bad memory allocation"); + return; + } + strncpy (*str, mytext, mylength); } diff --git a/src/simulator/wireframe-simulator/core/vpParser.c b/src/simulator/wireframe-simulator/core/vpParser.c index 8682dad822e75ea8525006d631755bc676d72a18..6f0f28d5451b4ee91daefb6bf3a71581b3e5188f 100755 --- a/src/simulator/wireframe-simulator/core/vpParser.c +++ b/src/simulator/wireframe-simulator/core/vpParser.c @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpParser.c 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpParser.c 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpProjection.c b/src/simulator/wireframe-simulator/core/vpProjection.c index f6c7f262115bceb60d58e2ed333114134c10b987..364971d82c8bc692084e5d5f722c65b30ef1673e 100755 --- a/src/simulator/wireframe-simulator/core/vpProjection.c +++ b/src/simulator/wireframe-simulator/core/vpProjection.c @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpProjection.c 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpProjection.c 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpRfstack.c b/src/simulator/wireframe-simulator/core/vpRfstack.c index d8b4ed52b9a45cb5d3579d6fdb2b16ce4a06f106..77f4da5859776141812bc9a12a633eb530ab7a42 100755 --- a/src/simulator/wireframe-simulator/core/vpRfstack.c +++ b/src/simulator/wireframe-simulator/core/vpRfstack.c @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRfstack.c 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRfstack.c 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -69,7 +69,8 @@ static int *sp = stack; /* sommet */ void fprintf_rfstack (FILE *fp) { - int flg = 0; /* nul si element unique */ + int flg; + flg = 0; /* nul si element unique */ if (*sp == IS_INSIDE) { fprintf (fp, "(null)\n"); @@ -77,28 +78,34 @@ fprintf_rfstack (FILE *fp) } fprintf (fp, "("); if (*sp & IS_ABOVE) { - if (flg++) fprintf (fp, " "); + if (flg) fprintf (fp, " "); + flg ++; fprintf (fp, "above"); } if (*sp & IS_BELOW) { - if (flg++) fprintf (fp, " "); - fprintf (fp, "below"); + if (flg) fprintf (fp, " "); + flg ++; + fprintf (fp, "below"); } if (*sp & IS_RIGHT) { - if (flg++) fprintf (fp, " "); - fprintf (fp, "right"); + if (flg) fprintf (fp, " "); + flg ++; + fprintf (fp, "right"); } if (*sp & IS_LEFT) { - if (flg++) fprintf (fp, " "); - fprintf (fp, "left"); + if (flg) fprintf (fp, " "); + flg ++; + fprintf (fp, "left"); } if (*sp & IS_BACK) { - if (flg++) fprintf (fp, " "); - fprintf (fp, "back"); + if (flg) fprintf (fp, " "); + flg ++; + fprintf (fp, "back"); } if (*sp & IS_FRONT) { - if (flg++) fprintf (fp, " "); - fprintf (fp, "front"); + if (flg) fprintf (fp, " "); + flg ++; + fprintf (fp, "front"); } fprintf (fp, ")\n"); } diff --git a/src/simulator/wireframe-simulator/core/vpRfstack.h b/src/simulator/wireframe-simulator/core/vpRfstack.h index a8ad1b2f363ce53609246f4095d857b6353422db..80d6610b139d3e16c274db7c4f3c85d5d2d2b4d7 100755 --- a/src/simulator/wireframe-simulator/core/vpRfstack.h +++ b/src/simulator/wireframe-simulator/core/vpRfstack.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRfstack.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRfstack.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpSkipio.c b/src/simulator/wireframe-simulator/core/vpSkipio.c index c19965943467172a3b6950d80afec7ceb888fd71..81934ecc9a770e94a81325ef97135edbe11f8b4b 100755 --- a/src/simulator/wireframe-simulator/core/vpSkipio.c +++ b/src/simulator/wireframe-simulator/core/vpSkipio.c @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpSkipio.c 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpSkipio.c 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpSkipio.h b/src/simulator/wireframe-simulator/core/vpSkipio.h index eaffbc2f6d8dbfc6e8581618c06e9e021fccbf4f..42171ab327a2a1cba2606519d93eba7d253f042f 100644 --- a/src/simulator/wireframe-simulator/core/vpSkipio.h +++ b/src/simulator/wireframe-simulator/core/vpSkipio.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpSkipio.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpSkipio.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpTmstack.c b/src/simulator/wireframe-simulator/core/vpTmstack.c index 1ed738a9d74cb08a973ee836ca7cf32e36fbb77d..ffe7660d02da31ab3fe353c3f33d9de8bef9e015 100755 --- a/src/simulator/wireframe-simulator/core/vpTmstack.c +++ b/src/simulator/wireframe-simulator/core/vpTmstack.c @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpTmstack.c 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpTmstack.c 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpTmstack.h b/src/simulator/wireframe-simulator/core/vpTmstack.h index ae33445178b80161e1130edd0e57c3f7141df832..af03b7293e8877e9fb7b59db3f8219be0d2670a5 100755 --- a/src/simulator/wireframe-simulator/core/vpTmstack.h +++ b/src/simulator/wireframe-simulator/core/vpTmstack.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpTmstack.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpTmstack.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpToken.c b/src/simulator/wireframe-simulator/core/vpToken.c index ed815aec8aeb74c8dab1aa6dc8aa01dc6d368f58..b52f5805eb2f090e7e679eb8f4b20be0295b4897 100755 --- a/src/simulator/wireframe-simulator/core/vpToken.c +++ b/src/simulator/wireframe-simulator/core/vpToken.c @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpToken.c 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpToken.c 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpToken.h b/src/simulator/wireframe-simulator/core/vpToken.h index b0188bfc0da1019496bd9440da544b301d3a9b16..b185f28f6bc1c81e824311a4562829bf36060c91 100755 --- a/src/simulator/wireframe-simulator/core/vpToken.h +++ b/src/simulator/wireframe-simulator/core/vpToken.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpToken.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpToken.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpView.h b/src/simulator/wireframe-simulator/core/vpView.h index b9b0555b831bfbfe2ea2b2a665478bc4a584b398..8f95d20e4943d5d44b1b8952a07df80b5922856a 100755 --- a/src/simulator/wireframe-simulator/core/vpView.h +++ b/src/simulator/wireframe-simulator/core/vpView.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpView.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpView.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpViewio.c b/src/simulator/wireframe-simulator/core/vpViewio.c index 1f0313ce5b9af968d0ae73ce285b8beaee22c3f7..6b011645e5b18fd931189b066c5e56b712d846da 100755 --- a/src/simulator/wireframe-simulator/core/vpViewio.c +++ b/src/simulator/wireframe-simulator/core/vpViewio.c @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpViewio.c 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpViewio.c 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpVwstack.c b/src/simulator/wireframe-simulator/core/vpVwstack.c index 7a9b3db7ea6f8e5acc60ce628f80cb0c7e7efbf8..9db5e9e45d390ab3ed8a060bd4cefe7e3232e567 100644 --- a/src/simulator/wireframe-simulator/core/vpVwstack.c +++ b/src/simulator/wireframe-simulator/core/vpVwstack.c @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpVwstack.c 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpVwstack.c 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/core/vpVwstack.h b/src/simulator/wireframe-simulator/core/vpVwstack.h index ec7d76004470a27500ab8f4488aa7ab5f76f57f8..83f2f74d4c3676030384df1e59b3b8a1a35661a1 100755 --- a/src/simulator/wireframe-simulator/core/vpVwstack.h +++ b/src/simulator/wireframe-simulator/core/vpVwstack.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpVwstack.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpVwstack.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/scene/CMakeWireframeScenesList.cmake b/src/simulator/wireframe-simulator/scene/CMakeWireframeScenesList.cmake index 9e540178ded26f2415e4aafdf006db833c323b13..5b605fa34bd01ab1938b6231af8f965e11eb5c3c 100644 --- a/src/simulator/wireframe-simulator/scene/CMakeWireframeScenesList.cmake +++ b/src/simulator/wireframe-simulator/scene/CMakeWireframeScenesList.cmake @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeWireframeScenesList.cmake 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeWireframeScenesList.cmake 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/src/simulator/wireframe-simulator/vpWireFrameSimulator.cpp b/src/simulator/wireframe-simulator/vpWireFrameSimulator.cpp index ad755829b352998e9cd7ca48bbe2a9d0e355ed35..5ecb517d54b2074f558d25e9a74fef73b3d322a3 100644 --- a/src/simulator/wireframe-simulator/vpWireFrameSimulator.cpp +++ b/src/simulator/wireframe-simulator/vpWireFrameSimulator.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpWireFrameSimulator.cpp 4227 2013-04-19 07:55:22Z fspindle $ + * $Id: vpWireFrameSimulator.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -57,11 +57,6 @@ #include <visp/vpPoint.h> #include <visp/vpIoTools.h> -#if defined(WIN32) -#define bcopy(b1,b2,len) (memmove((b2), (b1), (len)), (void) 0) -#endif - - //Inventor includes #if defined(VISP_HAVE_COIN) #include <Inventor/nodes/SoSeparator.h> @@ -88,6 +83,9 @@ typedef enum UNKNOWN_MODEL } Model_3D; +Model_3D getExtension(const char* file); +void set_scene_wrl (const char* str, Bound_scene *sc, float factor); + /* Get the extension of the file and return it */ @@ -127,11 +125,9 @@ void set_scene (const char* str, Bound_scene *sc, float factor) //if ((fd = fopen (str, 0)) == -1) if ((fd = fopen (str, "r")) == NULL) { - char strerr[80]; - strcpy (strerr,"The file "); - strcat (strerr,str); - strcat (strerr," can not be opened"); - throw(vpException(vpSimulatorException::ioError,strerr)) ; + std::string error = "The file " + std::string(str) + " can not be opened"; + + throw(vpException(vpSimulatorException::ioError, error.c_str())) ; } open_keyword (keyword_tbl); open_lex (); @@ -205,7 +201,10 @@ void set_scene_wrl (const char* str, Bound_scene *sc, float factor) else { sceneGraphVRML2 = SoDB::readAllVRML(&in); - if (sceneGraphVRML2 == NULL) { /*return -1;*/ } + if (sceneGraphVRML2 == NULL) { + /*return -1;*/ + throw(vpException(vpException::notInitialized, "Cannot read VRML file")); + } sceneGraphVRML2->ref(); } @@ -463,7 +462,8 @@ vpWireFrameSimulator::display_scene(Matrix mat, Bound_scene &sc, const vpImage<u Byte b = (Byte) *get_rfstack (); Matrix m; - bcopy ((char *) mat, (char *) m, sizeof (Matrix)); + //bcopy ((char *) mat, (char *) m, sizeof (Matrix)); + memmove((char *) m, (char *) mat, sizeof (Matrix)); View_to_Matrix (get_vwstack (), *(get_tmstack ())); postmult_matrix (m, *(get_tmstack ())); bp = sc.bound.ptr; @@ -510,6 +510,15 @@ vpWireFrameSimulator::display_scene(Matrix mat, Bound_scene &sc, const vpImage<u variable that the user has to set. */ vpWireFrameSimulator::vpWireFrameSimulator() + : scene(), desiredScene(), camera(), objectImage(), fMo(), fMc(), camMf(), + refMo(), cMo(), cdMo(), object(PLATE), desiredObject(D_STANDARD), + camColor(vpColor::green), camTrajColor(vpColor::green), curColor(vpColor::blue), + desColor(vpColor::red), sceneInitialized(false), displayCameraTrajectory(true), + cameraTrajectory(), poseList(), fMoList(), nbrPtLimit(1000), old_iPr(), old_iPz(), + old_iPt(), blockedr(false), blockedz(false), blockedt(false), blocked(false), + camMf2(), f2Mf(), px_int(1), py_int(1), px_ext(1), py_ext(1), displayObject(false), + displayDesiredObject(false), displayCamera(false), displayImageSimulator(false), + cameraFactor(1.), camTrajType(CT_LINE), extCamChanged(false), rotz(), thickness_(1), scene_dir() { // set scene_dir from #define VISP_SCENE_DIR if it exists if (vpIoTools::checkDirectory(VISP_SCENES_DIR) == true) // directory exists @@ -527,51 +536,23 @@ vpWireFrameSimulator::vpWireFrameSimulator() open_display(); open_clipping(); - camColor = vpColor::green; - camTrajColor = vpColor::green; - curColor = vpColor::blue; - desColor = vpColor::red; - - sceneInitialized = false; - - displayCameraTrajectory = true; - cameraTrajectory.clear(); - poseList.clear(); - fMoList.clear(); - - fMo.setIdentity(); - old_iPr = vpImagePoint(-1,-1); old_iPz = vpImagePoint(-1,-1); old_iPt = vpImagePoint(-1,-1); - blockedr = false; - blockedz = false; - blockedt = false; - blocked = false; - - nbrPtLimit = 1000; - - px_int = 1; - py_int = 1; - px_ext = 1; - py_ext = 1; - - displayObject = false; - displayDesiredObject = false; - displayCamera = false; - - cameraFactor = 1.0; - - camTrajType = CT_LINE; - - extCamChanged = false; - + rotz.buildFrom(0,0,0,0,0,vpMath::rad(180)); - displayImageSimulator = false; - objectImage.clear(); + scene.name = NULL; + scene.bound.ptr = NULL; + scene.bound.nbr = 0; - thickness_ = 1; + desiredScene.name = NULL; + desiredScene.bound.ptr = NULL; + desiredScene.bound.nbr = 0; + + camera.name = NULL; + camera.bound.ptr = NULL; + camera.bound.nbr = 0; } @@ -606,18 +587,24 @@ vpWireFrameSimulator::~vpWireFrameSimulator() It exists several default scenes you can use. Use the vpSceneObject and the vpSceneDesiredObject attributes to use them in this method. The corresponding files are stored in the "data" folder which is in the ViSP build directory. \param obj : Type of scene used to display the object at the current position. - \param desiredObject : Type of scene used to display the object at the desired pose (in the internal view). + \param desired_object : Type of scene used to display the object at the desired pose (in the internal view). */ void -vpWireFrameSimulator::initScene(const vpSceneObject &obj, const vpSceneDesiredObject &desiredObject) +vpWireFrameSimulator::initScene(const vpSceneObject &obj, const vpSceneDesiredObject &desired_object) { char name_cam[FILENAME_MAX]; char name[FILENAME_MAX]; object = obj; - this->desiredObject = desiredObject; + this->desiredObject = desired_object; + + const char *scene_dir_ = scene_dir.c_str(); + if (strlen(scene_dir_) >= FILENAME_MAX) { + throw(vpException(vpException::memoryAllocationError, + "Not enough memory to intialize the camera name")); + } - strcpy(name_cam, scene_dir.c_str()); + strcpy(name_cam, scene_dir_); if (desiredObject != D_TOOL) { strcat(name_cam,"/camera.bnd"); @@ -629,7 +616,7 @@ vpWireFrameSimulator::initScene(const vpSceneObject &obj, const vpSceneDesiredOb set_scene(name_cam,&(this->camera),1.0); } - strcpy(name, scene_dir.c_str()); + strcpy(name, scene_dir_); switch (obj) { case THREE_PTS : {strcat(name,"/3pts.bnd"); break; } @@ -652,19 +639,25 @@ vpWireFrameSimulator::initScene(const vpSceneObject &obj, const vpSceneDesiredOb } set_scene(name,&(this->scene),1.0); + scene_dir_ = scene_dir.c_str(); + if (strlen(scene_dir_) >= FILENAME_MAX) { + throw(vpException(vpException::memoryAllocationError, + "Not enough memory to intialize the desired object name")); + } + switch (desiredObject) { case D_STANDARD : { break; } case D_CIRCLE : { - strcpy(name, scene_dir.c_str()); + strcpy(name, scene_dir_); strcat(name, "/circle_sq2.bnd"); break; } case D_TOOL : { - strcpy(name, scene_dir.c_str()); + strcpy(name, scene_dir_); strcat(name, "/tool.bnd"); break; } } - set_scene(name,&(this->desiredScene),1.0); + set_scene(name, &(this->desiredScene), 1.0); if (obj == PIPE) load_rfstack(IS_INSIDE); else add_rfstack(IS_BACK); @@ -694,13 +687,13 @@ vpWireFrameSimulator::initScene(const vpSceneObject &obj, const vpSceneDesiredOb It is also possible to add a list of vpImageSimulator instances. They will be automatically projected into the image. The position of the four corners have to be given in the object frame. \param obj : Type of scene used to display the object at the current position. - \param desiredObject : Type of scene used to display the object at the desired pose (in the internal view). + \param desired_object : Type of scene used to display the object at the desired pose (in the internal view). \param imObj : A list of vpImageSimulator instances. */ void -vpWireFrameSimulator::initScene(vpSceneObject obj, vpSceneDesiredObject desiredObject, vpList<vpImageSimulator> &imObj) +vpWireFrameSimulator::initScene(vpSceneObject obj, vpSceneDesiredObject desired_object, vpList<vpImageSimulator> &imObj) { - initScene(obj, desiredObject); + initScene(obj, desired_object); objectImage.clear(); for(imObj.front(); !imObj.outside(); imObj.next()){ objectImage.push_back(imObj.value()); @@ -718,13 +711,13 @@ vpWireFrameSimulator::initScene(vpSceneObject obj, vpSceneDesiredObject desiredO It is also possible to add a list of vpImageSimulator instances. They will be automatically projected into the image. The position of the four corners have to be given in the object frame. \param obj : Type of scene used to display the object at the current position. - \param desiredObject : Type of scene used to display the object at the desired pose (in the internal view). + \param desired_object : Type of scene used to display the object at the desired pose (in the internal view). \param imObj : A list of vpImageSimulator instances. */ void -vpWireFrameSimulator::initScene(const vpSceneObject &obj, const vpSceneDesiredObject &desiredObject, const std::list<vpImageSimulator> &imObj) +vpWireFrameSimulator::initScene(const vpSceneObject &obj, const vpSceneDesiredObject &desired_object, const std::list<vpImageSimulator> &imObj) { - initScene(obj, desiredObject); + initScene(obj, desired_object); objectImage = imObj; displayImageSimulator = true; } @@ -737,10 +730,10 @@ vpWireFrameSimulator::initScene(const vpSceneObject &obj, const vpSceneDesiredOb Here you can use the scene you want. You have to set the path to a .bnd or a .wrl file which is a 3D model file. \param obj : Path to the scene file you want to use. - \param desiredObject : Path to the scene file you want to use. + \param desired_object : Path to the scene file you want to use. */ void -vpWireFrameSimulator::initScene(const char* obj, const char* desiredObject) +vpWireFrameSimulator::initScene(const char* obj, const char* desired_object) { char name_cam[FILENAME_MAX]; char name[FILENAME_MAX]; @@ -748,10 +741,21 @@ vpWireFrameSimulator::initScene(const char* obj, const char* desiredObject) object = THREE_PTS; this->desiredObject = D_STANDARD; - strcpy(name_cam, scene_dir.c_str()); + const char *scene_dir_ = scene_dir.c_str(); + if (strlen(scene_dir_) >= FILENAME_MAX) { + throw(vpException(vpException::memoryAllocationError, + "Not enough memory to intialize the camera name")); + } + + strcpy(name_cam, scene_dir_); strcat(name_cam,"/camera.bnd"); set_scene(name_cam,&camera,cameraFactor); + if (strlen(obj) >= FILENAME_MAX) { + throw(vpException(vpException::memoryAllocationError, + "Not enough memory to intialize the name")); + } + strcpy(name,obj); Model_3D model; model = getExtension(obj); @@ -764,8 +768,13 @@ vpWireFrameSimulator::initScene(const char* obj, const char* desiredObject) vpERROR_TRACE("Unknown file extension for the 3D model"); } - strcpy(name,desiredObject); - model = getExtension(desiredObject); + if (strlen(desired_object) >= FILENAME_MAX) { + throw(vpException(vpException::memoryAllocationError, + "Not enough memory to intialize the camera name")); + } + + strcpy(name,desired_object); + model = getExtension(desired_object); if (model == BND_MODEL) set_scene(name,&(this->desiredScene),1.0); else if (model == WRL_MODEL) @@ -800,13 +809,13 @@ vpWireFrameSimulator::initScene(const char* obj, const char* desiredObject) It is also possible to add a list of vpImageSimulator instances. They will be automatically projected into the image. The position of the four corners have to be given in the object frame. \param obj : Path to the scene file you want to use. - \param desiredObject : Path to the scene file you want to use. + \param desired_object : Path to the scene file you want to use. \param imObj : A list of vpImageSimulator instances. */ void -vpWireFrameSimulator::initScene(const char* obj, const char* desiredObject, vpList<vpImageSimulator> &imObj) +vpWireFrameSimulator::initScene(const char* obj, const char* desired_object, vpList<vpImageSimulator> &imObj) { - initScene(obj, desiredObject); + initScene(obj, desired_object); objectImage.clear(); for(imObj.front(); !imObj.outside(); imObj.next()){ objectImage.push_back(imObj.value()); @@ -824,13 +833,13 @@ vpWireFrameSimulator::initScene(const char* obj, const char* desiredObject, vpLi It is also possible to add a list of vpImageSimulator instances. They will be automatically projected into the image. The position of the four corners have to be given in the object frame. \param obj : Path to the scene file you want to use. - \param desiredObject : Path to the scene file you want to use. + \param desired_object : Path to the scene file you want to use. \param imObj : A list of vpImageSimulator instances. */ void -vpWireFrameSimulator::initScene(const char* obj, const char* desiredObject, const std::list<vpImageSimulator> &imObj) +vpWireFrameSimulator::initScene(const char* obj, const char* desired_object, const std::list<vpImageSimulator> &imObj) { - initScene(obj, desiredObject); + initScene(obj, desired_object); objectImage = imObj; displayImageSimulator = true; } @@ -851,11 +860,17 @@ vpWireFrameSimulator::initScene(const vpSceneObject &obj) object = obj; - strcpy(name_cam, scene_dir.c_str()); + const char *scene_dir_ = scene_dir.c_str(); + if (strlen(scene_dir_) >= FILENAME_MAX) { + throw(vpException(vpException::memoryAllocationError, + "Not enough memory to intialize the camera name")); + } + + strcpy(name_cam, scene_dir_); strcat(name_cam,"/camera.bnd"); set_scene(name_cam,&camera,cameraFactor); - strcpy(name, scene_dir.c_str()); + strcpy(name, scene_dir_); switch (obj) { case THREE_PTS : {strcat(name,"/3pts.bnd"); break; } @@ -955,10 +970,21 @@ vpWireFrameSimulator::initScene(const char* obj) object = THREE_PTS; - strcpy(name_cam, scene_dir.c_str()); + const char *scene_dir_ = scene_dir.c_str(); + if (strlen(scene_dir_) >= FILENAME_MAX) { + throw(vpException(vpException::memoryAllocationError, + "Not enough memory to intialize the camera name")); + } + + strcpy(name_cam, scene_dir_); strcat(name_cam,"/camera.bnd"); set_scene(name_cam,&camera,cameraFactor); + if (strlen(obj) >= FILENAME_MAX) { + throw(vpException(vpException::memoryAllocationError, + "Not enough memory to intialize the name")); + } + strcpy(name,obj); Model_3D model; model = getExtension(obj); @@ -1252,16 +1278,16 @@ vpWireFrameSimulator::getExternalImage(vpImage<vpRGBa> &I) Get an external view. The point of view is set thanks to the pose between the camera camMf and the fixed world frame. \param I : The image where the external view is displayed. - \param camMf : The pose between the point of view and the fixed world frame. + \param cam_Mf : The pose between the point of view and the fixed world frame. \warning : The objects are displayed thanks to overlays. The image I is not modified. */ void -vpWireFrameSimulator::getExternalImage(vpImage<vpRGBa> &I, const vpHomogeneousMatrix &camMf) +vpWireFrameSimulator::getExternalImage(vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cam_Mf) { float w44o[4][4],w44cext[4][4],w44c[4][4],x,y,z; - vpHomogeneousMatrix camMft = rotz * camMf; + vpHomogeneousMatrix camMft = rotz * cam_Mf; double u; double v; @@ -1298,7 +1324,7 @@ vpWireFrameSimulator::getExternalImage(vpImage<vpRGBa> &I, const vpHomogeneousMa for(std::list<vpImageSimulator>::iterator it=objectImage.begin(); it!=objectImage.end(); ++it){ vpImageSimulator* imSim = &(*it); - imSim->setCameraPosition(rotz*camMf*fMo); + imSim->setCameraPosition(rotz*cam_Mf*fMo); imSim->getImage(I,getInternalCameraParameters(I)); } @@ -1535,16 +1561,16 @@ vpWireFrameSimulator::getExternalImage(vpImage<unsigned char> &I) Get an external view. The point of view is set thanks to the pose between the camera camMf and the fixed world frame. \param I : The image where the external view is displayed. - \param camMf : The pose between the point of view and the fixed world frame. + \param cam_Mf : The pose between the point of view and the fixed world frame. \warning : The objects are displayed thanks to overlays. The image I is not modified. */ void -vpWireFrameSimulator::getExternalImage(vpImage<unsigned char> &I, const vpHomogeneousMatrix &camMf) +vpWireFrameSimulator::getExternalImage(vpImage<unsigned char> &I, const vpHomogeneousMatrix &cam_Mf) { float w44o[4][4],w44cext[4][4],w44c[4][4],x,y,z; - vpHomogeneousMatrix camMft = rotz * camMf; + vpHomogeneousMatrix camMft = rotz * cam_Mf; double u; double v; @@ -1580,7 +1606,7 @@ vpWireFrameSimulator::getExternalImage(vpImage<unsigned char> &I, const vpHomoge I = 255; for(std::list<vpImageSimulator>::iterator it=objectImage.begin(); it!=objectImage.end(); ++it){ vpImageSimulator* imSim = &(*it); - imSim->setCameraPosition(rotz*camMf*fMo); + imSim->setCameraPosition(rotz*cam_Mf*fMo); imSim->getImage(I,getInternalCameraParameters(I)); } if (I.display != NULL) @@ -1954,12 +1980,13 @@ vpWireFrameSimulator::navigation(const vpImage<unsigned char> &I, bool &changed) Project the center of the internal camera into the external camera view. */ vpImagePoint -vpWireFrameSimulator::projectCameraTrajectory (const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpHomogeneousMatrix &fMo) +vpWireFrameSimulator::projectCameraTrajectory (const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo_, + const vpHomogeneousMatrix &fMo_) { vpPoint point; point.setWorldCoordinates(0,0,0); - point.track(rotz*(camMf*fMo*cMo.inverse())) ; + point.track(rotz*(camMf*fMo_*cMo_.inverse())) ; vpImagePoint iP; @@ -1972,12 +1999,14 @@ vpWireFrameSimulator::projectCameraTrajectory (const vpImage<vpRGBa> &I, const v Project the center of the internal camera into the external camera view. */ vpImagePoint -vpWireFrameSimulator::projectCameraTrajectory (const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, const vpHomogeneousMatrix &fMo) +vpWireFrameSimulator::projectCameraTrajectory (const vpImage<unsigned char> &I, + const vpHomogeneousMatrix &cMo_, + const vpHomogeneousMatrix &fMo_) { vpPoint point; point.setWorldCoordinates(0,0,0); - point.track(rotz*(camMf*fMo*cMo.inverse())) ; + point.track(rotz*(camMf*fMo_*cMo_.inverse())) ; vpImagePoint iP; @@ -1990,12 +2019,13 @@ vpWireFrameSimulator::projectCameraTrajectory (const vpImage<unsigned char> &I, Project the center of the internal camera into the external camera view. */ vpImagePoint -vpWireFrameSimulator::projectCameraTrajectory (const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpHomogeneousMatrix &fMo, const vpHomogeneousMatrix &cMf) +vpWireFrameSimulator::projectCameraTrajectory (const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo_, + const vpHomogeneousMatrix &fMo_, const vpHomogeneousMatrix &cMf) { vpPoint point; point.setWorldCoordinates(0,0,0); - point.track(rotz*(cMf*fMo*cMo.inverse())) ; + point.track(rotz*(cMf*fMo_*cMo_.inverse())) ; vpImagePoint iP; @@ -2008,12 +2038,13 @@ vpWireFrameSimulator::projectCameraTrajectory (const vpImage<vpRGBa> &I, const v Project the center of the internal camera into the external camera view. */ vpImagePoint -vpWireFrameSimulator::projectCameraTrajectory (const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, const vpHomogeneousMatrix &fMo, const vpHomogeneousMatrix &cMf) +vpWireFrameSimulator::projectCameraTrajectory (const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo_, + const vpHomogeneousMatrix &fMo_, const vpHomogeneousMatrix &cMf) { vpPoint point; point.setWorldCoordinates(0,0,0); - point.track(rotz*(cMf*fMo*cMo.inverse())) ; + point.track(rotz*(cMf*fMo_*cMo_.inverse())) ; vpImagePoint iP; diff --git a/src/simulator/wireframe-simulator/vpWireFrameSimulator.h b/src/simulator/wireframe-simulator/vpWireFrameSimulator.h index 6a8de1589db026b00a3452445a155624187c41e2..8f0b06bda2aa4330a92b424a2b2fcd88d0533e7d 100644 --- a/src/simulator/wireframe-simulator/vpWireFrameSimulator.h +++ b/src/simulator/wireframe-simulator/vpWireFrameSimulator.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpWireFrameSimulator.h 4334 2013-07-22 19:13:05Z fspindle $ + * $Id: vpWireFrameSimulator.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -447,16 +447,16 @@ public: /*! Set the position of the camera relative to the object. - \param cMo : The pose of the camera. + \param cMo_ : The pose of the camera. */ - void setCameraPositionRelObj(const vpHomogeneousMatrix &cMo) {this->cMo = rotz * cMo; fMc = fMo*this->cMo.inverse();} + void setCameraPositionRelObj(const vpHomogeneousMatrix &cMo_) {this->cMo = rotz * cMo_; fMc = fMo*this->cMo.inverse();} /*! Set the position of the the world reference frame relative to the camera. - \param fMc : The pose of the camera. + \param fMc_ : The pose of the camera. */ - void setCameraPositionRelWorld(const vpHomogeneousMatrix &fMc) {this->fMc = fMc*rotz; cMo = this->fMc.inverse()*fMo;} + void setCameraPositionRelWorld(const vpHomogeneousMatrix &fMc_) {this->fMc = fMc_*rotz; cMo = this->fMc.inverse()*fMo;} /*! Set the parameter which enables to choose the size of the main camera in the external camera views. By default this parameter is set to 1. @@ -475,9 +475,9 @@ public: /*! Set the way to display the history of the main camera trajectory in the main external view. The choice is given between displaying lines and points. - \param camTrajType : The chosen way to display the camera trajectory. + \param camTraj_type : The chosen way to display the camera trajectory. */ - inline void setCameraTrajectoryDisplayType (const vpCameraTrajectoryDisplayType &camTrajType) {this->camTrajType = camTrajType;} + inline void setCameraTrajectoryDisplayType (const vpCameraTrajectoryDisplayType &camTraj_type) {this->camTrajType = camTraj_type;} /*! Set the color used to display the object at the current position. @@ -488,9 +488,9 @@ public: /*! Set the desired position of the camera relative to the object. - \param cdMo : The desired pose of the camera. + \param cdMo_ : The desired pose of the camera. */ - void setDesiredCameraPosition(const vpHomogeneousMatrix &cdMo) {this->cdMo = rotz * cdMo;} + void setDesiredCameraPosition(const vpHomogeneousMatrix &cdMo_) {this->cdMo = rotz * cdMo_;} /*! Set the color used to display the object at the desired position. @@ -502,9 +502,9 @@ public: By default the trajectory is displayed. - \param displayCameraTrajectory : Set to true to display the camera trajectory. + \param do_display : Set to true to display the camera trajectory. */ - void setDisplayCameraTrajectory (const bool &displayCameraTrajectory) {this->displayCameraTrajectory = displayCameraTrajectory;} + void setDisplayCameraTrajectory (const bool &do_display) {this->displayCameraTrajectory = do_display;} /*! Set the internal camera parameters. @@ -518,11 +518,11 @@ public: /*! Set the external camera point of view. - \param camMf : The pose of the external camera relative to the world reference frame. + \param cam_Mf : The pose of the external camera relative to the world reference frame. */ - void setExternalCameraPosition(const vpHomogeneousMatrix &camMf) + void setExternalCameraPosition(const vpHomogeneousMatrix &cam_Mf) { - this->camMf = rotz * camMf; + this->camMf = rotz * cam_Mf; vpTranslationVector T; this->camMf.extract (T); this->camMf2.buildFrom(0,0,T[2],0,0,0); @@ -558,9 +558,9 @@ public: /*! Set the pose between the object and the fixed world frame. - \param fMo : The pose between the object and the fixed world frame. + \param fMo_ : The pose between the object and the fixed world frame. */ - void set_fMo(const vpHomogeneousMatrix &fMo) {this->fMo = fMo;/*this->cMo = fMc.inverse()*fMo;*/} + void set_fMo(const vpHomogeneousMatrix &fMo_) {this->fMo = fMo_;/*this->cMo = fMc.inverse()*fMo;*/} protected: void display_scene(Matrix mat, Bound_scene &sc, const vpImage<vpRGBa> &I, const vpColor &color); diff --git a/src/tools/geometry/vpPlane.cpp b/src/tools/geometry/vpPlane.cpp index e44ffb683a5f4b8aa8d8419781444fb0fa6ef3cb..84f6a296f1fb313aaab186ce3686c3f7f02014f2 100644 --- a/src/tools/geometry/vpPlane.cpp +++ b/src/tools/geometry/vpPlane.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpPlane.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpPlane.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -68,13 +68,7 @@ vpPlane::operator =(const vpPlane& p) /*! Basic constructor that set the plane parameters A, B, C, D to zero. */ -vpPlane::vpPlane() -{ - setA(0) ; - setB(0) ; - setC(0) ; - setD(0) ; -} +vpPlane::vpPlane() : A(0), B(0), C(0), D(0) {} /*! Plane constructor from A, B, C, D parameters. @@ -83,21 +77,17 @@ vpPlane::vpPlane() (x,y,z) are the coordinates of a point and \f$[A,B,C]^T\f$ is the normal vector of the plane. - \param A, B, C, D : Parameters of the plane. + \param a, b, c, d : Parameters of the plane. */ -vpPlane::vpPlane(const double A,const double B,const double C, const double D) -{ - setA(A) ; - setB(B) ; - setC(C) ; - setD(D) ; -} +vpPlane::vpPlane(const double a,const double b,const double c, const double d) + : A(a), B(b), C(c), D(d) {} /*! Copy constructor. */ vpPlane::vpPlane(const vpPlane& P) + : A(0), B(0), C(0), D(0) { setA(P.getA()) ; setB(P.getB()) ; @@ -120,6 +110,7 @@ vpPlane::vpPlane(const vpPlane& P) */ vpPlane::vpPlane(const vpPoint& P, const vpColVector &n) + : A(0), B(0), C(0), D(0) { //Equation of the plane is given by: A = n[0]; @@ -211,6 +202,7 @@ vpPlane::init(const vpPoint &P, const vpPoint &Q, const vpPoint &R) \sa init(const vpPoint &, const vpPoint &, const vpPoint &) */ vpPlane::vpPlane(const vpPoint &P, const vpPoint &Q, const vpPoint &R) + : A(0), B(0), C(0), D(0) { init(P,Q,R) ; } @@ -359,3 +351,14 @@ void vpPlane::changeFrame(const vpHomogeneousMatrix &cMo) D = Do - (cMo[0][3]*A + cMo[1][3]*B + cMo[2][3]*C); } +/*! + + Print the plane parameters as a stream like "(A,B,C,D) " where + A,B,C and D correspond to the parameters of the plane. + +*/ +VISP_EXPORT std::ostream& operator<< (std::ostream& os, vpPlane& p) +{ + return (os << "("<<p.getA() << ","<<p.getB() + << ","<<p.getC()<< ","<<p.getD() <<") ") ; +} ; diff --git a/src/tools/geometry/vpPlane.h b/src/tools/geometry/vpPlane.h index e41eebe9f078b1af319fc04ec70f44db8a55f4ba..3a6907fb120c94ee28c6855fdc15f6f79af4984c 100644 --- a/src/tools/geometry/vpPlane.h +++ b/src/tools/geometry/vpPlane.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpPlane.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpPlane.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -54,7 +54,7 @@ \brief This class defines the container for a plane geometrical structure. A plane is given by the equation \f$Ax + By + Cz + D = 0\f$ where - (x,y,z) are the coordinates of a point and \f$[A,B,C]^T\f$ is normal + (x,y,z) are the coordinates of a point and where \f$[A,B,C]^T\f$ is a normal vector of the plane. */ @@ -75,7 +75,6 @@ class VISP_EXPORT vpPlane #endif double A,B,C,D ; - public: vpPlane() ; vpPlane(const vpPlane& P) ; @@ -88,21 +87,21 @@ public: // SET the parameter /*! Set plane parameter A. */ - inline void setA(const double A) { this->A = A ; } + inline void setA(const double a) { this->A = a ; } /*! Set plane parameter B. */ - inline void setB(const double B) { this->B = B ; } + inline void setB(const double b) { this->B = b ; } /*! Set plane parameter C. */ - inline void setC(const double C) { this->C = C ; } + inline void setC(const double c) { this->C = c ; } /*! Set plane parameter D. */ - inline void setD(const double D) { this->D = D ; } + inline void setD(const double d) { this->D = d ; } /*! Set plane parameters A, B, C, D. */ - inline void setABCD(const double A, const double B, - const double C, const double D) + inline void setABCD(const double a, const double b, + const double c, const double d) { - this->A = A; - this->B = B; - this->C = C; - this->D = D; + this->A = a; + this->B = b; + this->C = c; + this->D = d; } vpPlane& operator =(const vpPlane& f) ; @@ -155,19 +154,7 @@ public: vpColVector getNormal() const; void getNormal(vpColVector &n) const; - - /*! - - Print the plane parameters as a stream like "(A,B,C,D) " where - A,B,C and D correspond to the parameters of the plane. - - */ - friend VISP_EXPORT std::ostream& operator<< (std::ostream& os, vpPlane& p) - { - return (os << "("<<p.getA() << ","<<p.getB() - << ","<<p.getC()<< ","<<p.getD() <<") ") ; - } ; - + friend VISP_EXPORT std::ostream& operator<< (std::ostream& os, vpPlane& p); // Operation with Plane void projectionPointOnPlan(const vpPoint& P, vpPoint& Pproj) const ; diff --git a/src/tools/geometry/vpPolygon.cpp b/src/tools/geometry/vpPolygon.cpp index 71bc4615d71a9acc8aa8583b5c09b2823ade8e48..4cef509fd821dd6d0c63c08c79066ecb52cf6257 100644 --- a/src/tools/geometry/vpPolygon.cpp +++ b/src/tools/geometry/vpPolygon.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpPolygon.cpp 4303 2013-07-04 14:14:00Z fspindle $ + * $Id: vpPolygon.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -57,8 +57,8 @@ \f$ (0,0) \f$, \f$ (1,0) \f$ and \f$ (0,1) \f$. */ vpPolygon::vpPolygon() + : _corners(), _center(), _area(0.), _goodPoly(true), _bbox() { - _goodPoly = true; std::vector<vpImagePoint> corners; corners.push_back(vpImagePoint(0,0)); corners.push_back(vpImagePoint(1,0)); @@ -74,6 +74,7 @@ vpPolygon::vpPolygon() \param corners : The Points defining the corners. */ vpPolygon::vpPolygon(const std::vector<vpImagePoint>& corners) + : _corners(), _center(), _area(0.), _goodPoly(true), _bbox() { if(corners.size() < 3){ _goodPoly = false; @@ -87,11 +88,13 @@ vpPolygon::vpPolygon(const std::vector<vpImagePoint>& corners) \param poly : The polygon used for the initialisation. */ vpPolygon::vpPolygon(const vpPolygon &poly) + : _corners(), _center(), _area(0.), _goodPoly(true), _bbox() { _corners = poly._corners; _center = poly._center; _area = poly._area; _goodPoly = poly._goodPoly; + _bbox = poly._bbox; } /*! @@ -165,8 +168,8 @@ vpPolygon::initClick(const vpImage<unsigned char>& I) std::vector<vpImagePoint> cornersClick; while(button == vpMouseButton::button1){ - vpDisplay::getClick(I, ip, button, true); - if(button == vpMouseButton::button1){ + bool ret = vpDisplay::getClick(I, ip, button, true); + if(ret && button == vpMouseButton::button1){ vpDisplay::displayCross(I, ip, 5, vpColor::red); cornersClick.push_back(ip); vpDisplay::flush(I); diff --git a/src/tools/geometry/vpPolygon.h b/src/tools/geometry/vpPolygon.h index ffa4dc49d378f5160ae53d8e042886478a9548f0..13cf64477f34aa75da457ff7d59dbb862b3cacec 100644 --- a/src/tools/geometry/vpPolygon.h +++ b/src/tools/geometry/vpPolygon.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpPolygon.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpPolygon.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/tools/geometry/vpRect.cpp b/src/tools/geometry/vpRect.cpp index 1fce4050459d1b1802a5385738d9e4de3c8e52f1..1b51f46a282dd268f2a65b48e3c4ebc8dee198bf 100755 --- a/src/tools/geometry/vpRect.cpp +++ b/src/tools/geometry/vpRect.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRect.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRect.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -56,13 +56,7 @@ */ -vpRect::vpRect() -{ - this->left = 0; - this->top = 0; - this->width = 0; - this->height = 0; -}; +vpRect::vpRect() : left(0), top(0), width(0), height(0) {}; /*! @@ -70,12 +64,9 @@ vpRect::vpRect() and \e height. */ -vpRect::vpRect(double left, double top, double width, double height) +vpRect::vpRect(double l, double t, double w, double h) + : left(l), top(t), width(w), height(h) { - this->left = left; - this->top = top; - this->width = width; - this->height = height; }; /*! @@ -84,12 +75,9 @@ vpRect::vpRect(double left, double top, double width, double height) and \e width and \e height the rectangle size. */ -vpRect::vpRect(const vpImagePoint &topLeft, double width, double height) +vpRect::vpRect(const vpImagePoint &topLeft, double w, double h) + : left(topLeft.get_u()), top(topLeft.get_v()), width(w), height(h) { - this->left = topLeft.get_u(); - this->top = topLeft.get_v(); - this->width = width; - this->height = height; }; /*! @@ -99,6 +87,7 @@ vpRect::vpRect(const vpImagePoint &topLeft, double width, double height) */ vpRect::vpRect(const vpImagePoint &topLeft, const vpImagePoint &bottomRight) + : left(topLeft.get_u()), top(topLeft.get_v()), width(0), height(0) { this->left = topLeft.get_u(); this->top = topLeft.get_v(); @@ -113,11 +102,9 @@ vpRect::vpRect(const vpImagePoint &topLeft, const vpImagePoint &bottomRight) */ vpRect::vpRect(const vpRect& r) + : left(0), top(0), width(0), height(0) { - this->left = r.left; - this->top = r.top; - this->width = r.width; - this->height = r.height; + *this = r; }; /*! @@ -132,3 +119,66 @@ vpRect &vpRect::operator=(const vpRect& r) this->height = r.height; return *this; }; + +/*! + + Create a rectangle as the bounding box of a vector of image points. + \param ip : Vector of image points. At least 1 points is mandatory, + otherwise an exception is thrown. +*/ +vpRect::vpRect(const std::vector<vpImagePoint> &ip) + : left(0), top(0), width(0), height(0) +{ + set(ip); +} + +/*! + + Set the rectangle as the bounding box of a vector of image points. + \param ip : Vector of image points. At least 1 points is mandatory, + otherwise an exception is thrown. +*/ +void vpRect::set(const std::vector<vpImagePoint> &ip) +{ + if (ip.size() < 1) + throw (vpException(vpException::dimensionError, + "At least 1 point is requested to build a rectangle")); + double minu, maxu; + double minv, maxv; + minu = maxu = ip[0].get_u(); + minv = maxv = ip[0].get_v(); + + for(size_t i=1; i<ip.size(); i++) { + double u = ip[i].get_u(); + double v = ip[i].get_v(); + if ( u < minu ) minu = u; + else if (u > maxu) maxu = u; + if ( v < minv ) minv = v; + else if (v > maxv) maxv = v; + } + + setLeft (minu); + setTop (minv); + setRight (maxu); + setBottom(maxv); +}; + +/*! + + Check if an image point belongs to a rectangle. + + \param ip : the image point. + \param rect : the rectangle. + + \return Returns true if the point belongs to the rectangle. + +*/ +VISP_EXPORT bool inRectangle( const vpImagePoint &ip, const vpRect &rect ) { + return ( ip.get_i() <= rect.getBottom() && ip.get_i() >= rect.getTop() && ip.get_j() <= rect.getRight() && ip.get_j() >= rect.getLeft()); +} + +VISP_EXPORT std::ostream& operator<< (std::ostream &os, const vpRect& r) + { + os << r.getLeft() << ", " << r.getTop() << ", " << r.getWidth() << ", " << r.getHeight(); + return os; +} diff --git a/src/tools/geometry/vpRect.h b/src/tools/geometry/vpRect.h index dc88eb1e5855c688bef3f3de6f3956e7a277e0c1..542986fb6f19b28b0e19f0cbecb08a7c12aa8731 100755 --- a/src/tools/geometry/vpRect.h +++ b/src/tools/geometry/vpRect.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpRect.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpRect.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -77,8 +77,11 @@ */ +#include <vector> +#include <visp/vpException.h> #include <visp/vpImagePoint.h> + class VISP_EXPORT vpRect { public: @@ -88,6 +91,8 @@ public: vpRect(const vpImagePoint &topLeft, double width, double height); vpRect(const vpImagePoint &topLeft, const vpImagePoint &bottomRight); vpRect(const vpRect& r); + vpRect(const std::vector<vpImagePoint> &ip); + vpRect &operator=(const vpRect& r); @@ -187,6 +192,10 @@ public: */ inline double getWidth() const { return this->width; }; + friend VISP_EXPORT bool inRectangle( const vpImagePoint &ip, const vpRect &rect ); + friend VISP_EXPORT std::ostream& operator<< (std::ostream &os, const vpRect& r); + void set(const std::vector<vpImagePoint> &ip); + /*! Sets the bottom edge position of the rectangle to pos. May change @@ -230,12 +239,15 @@ public: Sets the coordinates of the rectangle's top left corner to (left, top), and its size to (width, height). + \param l,t : (left, top) corner position. + \param w,h : (width, height) rectangle size. + */ - inline void setRect(double left, double top, double width, double height) { - this->left = left; - this->top = top; - this->width = width; - this->height = height; + inline void setRect(double l, double t, double w, double h) { + this->left = l; + this->top = t; + this->width = w; + this->height = h; }; /*! @@ -297,20 +309,4 @@ private: double height; // Rectangle height }; - -/*! - - Check if an image point belongs to a rectangle. - - \param ip : the image point. - \param rect : the rectangle. - - \return Returns true if the point belongs to the rectangle. - -*/ -VISP_EXPORT inline bool inRectangle( const vpImagePoint &ip, const vpRect &rect ) { - return ( ip.get_i() <= rect.getBottom() && ip.get_i() >= rect.getTop() && ip.get_j() <= rect.getRight() && ip.get_j() >= rect.getLeft()); -} - - #endif diff --git a/src/tools/geometry/vpTriangle.cpp b/src/tools/geometry/vpTriangle.cpp index 848eb59a42874a56cda4252eee93de8054452e77..891037145b9fccd86fedb9966390f7f4105ce0c6 100644 --- a/src/tools/geometry/vpTriangle.cpp +++ b/src/tools/geometry/vpTriangle.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpTriangle.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpTriangle.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -49,8 +49,9 @@ By default, the three 2D points coordinates which define the triangle are \f$ (0,0) \f$, \f$ (1,0) \f$ and \f$ (0,1) \f$. */ vpTriangle::vpTriangle() + : goodTriange(true), S1(), uvinv00(0), uvinv01(0), uvinv10(0), uvinv11(0), + ptempo0(0), ptempo1(0), area(0), apex1(), apex2(), apex3() { - goodTriange = true; init (vpImagePoint(0,0),vpImagePoint(1,0),vpImagePoint(0,1)); } @@ -62,9 +63,9 @@ vpTriangle::vpTriangle() \param iP3 : The first apex of the triangle. */ vpTriangle::vpTriangle(const vpImagePoint &iP1, const vpImagePoint &iP2, const vpImagePoint &iP3) + : goodTriange(true), S1(), uvinv00(0), uvinv01(0), uvinv10(0), uvinv11(0), + ptempo0(0), ptempo1(0), area(0), apex1(), apex2(), apex3() { - goodTriange = true; - init(iP1,iP2,iP3); } @@ -74,16 +75,10 @@ vpTriangle::vpTriangle(const vpImagePoint &iP1, const vpImagePoint &iP2, const v \param tri : The triangle used for the initialisation. */ vpTriangle::vpTriangle(const vpTriangle &tri) + : goodTriange(true), S1(), uvinv00(0), uvinv01(0), uvinv10(0), uvinv11(0), + ptempo0(0), ptempo1(0), area(0), apex1(), apex2(), apex3() { - goodTriange = tri.goodTriange; - S1 = tri.S1; - uvinv00 = tri.uvinv00; - uvinv01 = tri.uvinv01; - uvinv10 = tri.uvinv10; - uvinv11 = tri.uvinv11; - ptempo0 = tri.ptempo0; - ptempo1 = tri.ptempo1; - area = tri.area; + *this = tri; } /*! @@ -128,6 +123,7 @@ vpTriangle::buildFrom(const vpImagePoint &iP1, const vpImagePoint &iP2, const vp void vpTriangle::init(const vpImagePoint &iP1, const vpImagePoint &iP2, const vpImagePoint &iP3) { + ptempo0 = ptempo1 = 0.; apex1 = iP1; apex2 = iP2; apex3 = iP3; diff --git a/src/tools/geometry/vpTriangle.h b/src/tools/geometry/vpTriangle.h index e7cd0a0dba4655318f88c303dab34d0b69eccfd4..98f1aa9d16862e71298aab6945882e2276379476 100644 --- a/src/tools/geometry/vpTriangle.h +++ b/src/tools/geometry/vpTriangle.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpTriangle.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpTriangle.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/tools/histogram/vpHistogram.cpp b/src/tools/histogram/vpHistogram.cpp index 544c779e3def43a988964a16dfa0f288ae448a5a..b45b37ac28ffabb6dd1908527d17a6d1894ab357 100644 --- a/src/tools/histogram/vpHistogram.cpp +++ b/src/tools/histogram/vpHistogram.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpHistogram.cpp 4303 2013-07-04 14:14:00Z fspindle $ + * $Id: vpHistogram.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -51,6 +51,8 @@ #include <visp/vpHistogram.h> #include <stdlib.h> +bool compare_vpHistogramPeak (vpHistogramPeak first, vpHistogramPeak second); + // comparison, bool compare_vpHistogramPeak (vpHistogramPeak first, vpHistogramPeak second) { @@ -63,20 +65,16 @@ bool compare_vpHistogramPeak (vpHistogramPeak first, vpHistogramPeak second) /*! Defaut constructor for a gray level histogram. */ -vpHistogram::vpHistogram() +vpHistogram::vpHistogram() : histogram(NULL), size(256) { - histogram = NULL; - size = 256; init(); } /*! Copy constructor of a gray level histogram. */ -vpHistogram::vpHistogram(const vpHistogram &h) +vpHistogram::vpHistogram(const vpHistogram &h) : histogram(NULL), size(256) { - // vpTRACE("copy"); - histogram = NULL; init(h.size); memcpy(histogram, h.histogram, size * sizeof(unsigned)); } @@ -89,9 +87,8 @@ vpHistogram::vpHistogram(const vpHistogram &h) \sa calculate() */ vpHistogram::vpHistogram(const vpImage<unsigned char> &I) + : histogram(NULL), size(256) { - histogram = NULL; - size = 256; init(); calculate(I); @@ -138,14 +135,14 @@ vpHistogram::operator=(const vpHistogram &h) - Initialise all the values to zero. */ void -vpHistogram::init(unsigned size) +vpHistogram::init(unsigned size_) { if (histogram != NULL) { delete [] histogram; histogram = NULL; } - this->size = size; + this->size = size_; histogram = new unsigned [size]; memset(histogram, 0, size * sizeof(unsigned)); diff --git a/src/tools/histogram/vpHistogram.h b/src/tools/histogram/vpHistogram.h index 68076c3fae097804d58102769ddfd23580d55c66..db90687a64b9468b4b5795fc7a49cc368af3d89b 100644 --- a/src/tools/histogram/vpHistogram.h +++ b/src/tools/histogram/vpHistogram.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpHistogram.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpHistogram.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/tools/histogram/vpHistogramPeak.cpp b/src/tools/histogram/vpHistogramPeak.cpp index 6ff741759f3a160d7dcabafad6a44ec33ea38c31..e7d22268ed8432864fa35756681e42ce261988ee 100644 --- a/src/tools/histogram/vpHistogramPeak.cpp +++ b/src/tools/histogram/vpHistogramPeak.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpHistogramPeak.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpHistogramPeak.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -52,27 +52,21 @@ /*! Defaut constructor for a gray level histogram peak. */ -vpHistogramPeak::vpHistogramPeak() -{ - level = 0; - value = 0; -} +vpHistogramPeak::vpHistogramPeak() : level(0), value(0) {} /*! Defaut constructor for a gray level histogram peak. */ -vpHistogramPeak::vpHistogramPeak(unsigned char level, unsigned value) -{ - setLevel(level); - setValue(value); -} +vpHistogramPeak::vpHistogramPeak(unsigned char lvl, unsigned val) + : level(lvl), value(val) {} + /*! Copy constructor of a gray level histogram peak. */ vpHistogramPeak::vpHistogramPeak(const vpHistogramPeak &p) + : level(0), value(0) { - setLevel(p.level); - setValue(p.value); + *this = p; } /*! @@ -110,7 +104,7 @@ vpHistogramPeak::operator==(const vpHistogramPeak &p) const /*! \brief std::cout a peak */ -std::ostream &operator <<(std::ostream &s,const vpHistogramPeak &p) +VISP_EXPORT std::ostream &operator <<(std::ostream &s,const vpHistogramPeak &p) { s << (int)p.getLevel() << " " << p.getValue(); diff --git a/src/tools/histogram/vpHistogramPeak.h b/src/tools/histogram/vpHistogramPeak.h index 3ba1371fc46f5e67571a2ed7df39094e699ba7b4..3b1e0ea34b74d33c75b52e00431a5f889099dd07 100644 --- a/src/tools/histogram/vpHistogramPeak.h +++ b/src/tools/histogram/vpHistogramPeak.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpHistogramPeak.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpHistogramPeak.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -74,6 +74,9 @@ public : vpHistogramPeak(unsigned char level, unsigned value); vpHistogramPeak(const vpHistogramPeak & p); + /*! Destructor that does nothing. */ + virtual ~vpHistogramPeak() {} + vpHistogramPeak & operator=(const vpHistogramPeak &p); bool operator==(const vpHistogramPeak &p) const; @@ -82,43 +85,43 @@ public : Set the peak gray \e level. To set the number of pixels having this gray level use setValue(). - \param level : Location of the peak or gray \e level. + \param lvl : Location of the peak or gray \e level. \sa setValue(), set() */ - inline void setLevel(unsigned char level) + inline void setLevel(unsigned char lvl) { - this->level = level; + this->level = lvl; }; /*! Set the peak number of pixels having a same gray level. To set the gray level of this peak use setLevel(). - \param value : Number of pixels having the same location or gray level. + \param val : Number of pixels having the same location or gray level. \sa setLevel(), set() */ - inline void setValue(unsigned value) + inline void setValue(unsigned val) { - this->value = value; + this->value = val; }; /*! Set the peak gray \e level and number of pixels at this gray level. - \param level : Location of the peak or gray level. - \param value : Number of pixels having the same location or gray level. + \param lvl : Location of the peak or gray level. + \param val : Number of pixels having the same location or gray level. \sa setLevel(), setValue() */ - inline void set(unsigned char level, unsigned value) + inline void set(unsigned char lvl, unsigned val) { - this->level = level; - this->value = value; + this->level = lvl; + this->value = val; }; /*! @@ -153,8 +156,7 @@ public : //--------------------------------- // Printing //--------------------------------- - friend VISP_EXPORT std::ostream &operator << (std::ostream &s, - const vpHistogramPeak &p); + friend VISP_EXPORT std::ostream &operator << (std::ostream &s, const vpHistogramPeak &p); protected : diff --git a/src/tools/histogram/vpHistogramValey.cpp b/src/tools/histogram/vpHistogramValey.cpp index bbf55627c754e7cd721468ece1d5d2bd31b9375a..cfffac76fd7a6d8e0ff09ed0cdadd5e02174a934 100644 --- a/src/tools/histogram/vpHistogramValey.cpp +++ b/src/tools/histogram/vpHistogramValey.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpHistogramValey.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpHistogramValey.cpp 4620 2014-01-27 21:28:32Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -83,7 +83,7 @@ vpHistogramValey::operator==(const vpHistogramValey &v) const /*! \brief std::cout a valey */ -std::ostream &operator <<(std::ostream &s,const vpHistogramValey &v) +VISP_EXPORT std::ostream &operator <<(std::ostream &s,const vpHistogramValey &v) { s << (int)v.getLevel() << " " << v.getValue(); diff --git a/src/tools/histogram/vpHistogramValey.h b/src/tools/histogram/vpHistogramValey.h index 5c83b21a4580ac381354a0f415aa2070b0956a84..2c950d12a9ccef43840e0b04f46a54df7339950e 100644 --- a/src/tools/histogram/vpHistogramValey.h +++ b/src/tools/histogram/vpHistogramValey.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpHistogramValey.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpHistogramValey.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -71,12 +71,15 @@ class VISP_EXPORT vpHistogramValey : vpHistogramPeak vpHistogramValey() : vpHistogramPeak() {}; - vpHistogramValey(unsigned char level, unsigned value) : - vpHistogramPeak(level, value) {}; + vpHistogramValey(unsigned char lvl, unsigned val) : + vpHistogramPeak(lvl, val) {}; vpHistogramValey(const vpHistogramValey & v) : vpHistogramPeak(v) {}; + /*! Destructor that does nothing. */ + virtual ~vpHistogramValey() {} + vpHistogramValey & operator=(const vpHistogramValey &v); bool operator==(const vpHistogramValey &v) const; @@ -85,43 +88,43 @@ class VISP_EXPORT vpHistogramValey : vpHistogramPeak Set the valey gray \e level. To set the number of pixels having this gray level use setValue(). - \param level : Location of the valey or gray level. + \param lvl : Location of the valey or gray level. \sa setValue(), set() */ - inline void setLevel(unsigned char level) + inline void setLevel(unsigned char lvl) { - this->level = level; + this->level = lvl; }; /*! Set the valey number of pixels having a same gray level. To set the gray level of this valey use setLevel(). - \param value : Number of pixels having the same location or gray level. + \param val : Number of pixels having the same location or gray level. \sa setPosition(), set() */ - inline void setValue(unsigned value) + inline void setValue(unsigned val) { - this->value = value; + this->value = val; }; /*! Set the valey gray \e level and number of pixels at this location. - \param level : Location of the valey or gray level. - \param value : Number of pixels having the same location or gray level. + \param lvl : Location of the valey or gray level. + \param val : Number of pixels having the same location or gray level. \sa setLevel(), setValue() */ - inline void set(unsigned char level, unsigned value) + inline void set(unsigned char lvl, unsigned val) { - this->level = level; - this->value = value; + this->level = lvl; + this->value = val; }; /*! @@ -143,7 +146,7 @@ class VISP_EXPORT vpHistogramValey : vpHistogramPeak Get the valey number of pixels having a same gray level. The corresponding gray level is available through getLevel(). - \return : Number of pixels having the same location or gray level. + \return Number of pixels having the same location or gray level. \sa getLevel() @@ -156,8 +159,7 @@ class VISP_EXPORT vpHistogramValey : vpHistogramPeak //--------------------------------- // Printing //--------------------------------- - friend VISP_EXPORT std::ostream &operator << (std::ostream &s, - const vpHistogramValey &v); + friend VISP_EXPORT std::ostream &operator << (std::ostream &s, const vpHistogramValey &v); }; /* diff --git a/src/tools/io/vpIoException.h b/src/tools/io/vpIoException.h index a2aa32f000e92d8f7cbfb9a06795e793e97e5fb7..2c03ed785776ee529d843de0d000c310537dcb4c 100644 --- a/src/tools/io/vpIoException.h +++ b/src/tools/io/vpIoException.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpIoException.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpIoException.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -71,12 +71,12 @@ */ class VISP_EXPORT vpIoException : public vpException { -public: - /*! + public: + /*! \brief Lists the possible error than can be emmited while calling vpIo member. */ - enum error + enum error { invalidDirectoryName, /*! Directory name is invalid. */ cantCreateDirectory, /*! Unable to create a directory. */ @@ -84,25 +84,20 @@ public: cantGetenv /*! Cannot get environment variable value. */ } ; -public: - vpIoException (const int code, const char * msg) - : vpException(code, msg){ ; } - vpIoException (const int code, const std::string & msg) - : vpException(code, msg){ ; } - vpIoException (const int code) - : vpException(code){ ; } + public: + vpIoException (const int id, const char* format, ...) + { + this->code = id; + va_list args; + va_start(args, format); + setMessage(format, args); + va_end (args); + } + vpIoException (const int id, const std::string & msg) + : vpException(id, msg){ ; } + vpIoException (const int id) + : vpException(id){ ; } }; - - - - -#endif /* #ifndef __vpIoException_H */ - - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ +#endif diff --git a/src/tools/io/vpIoTools.cpp b/src/tools/io/vpIoTools.cpp index d3b154d41be8d70d3e3c631bc5612a6419b02fd2..8f1f4ebb88d0dbafcb96d88da00d777945d79d92 100644 --- a/src/tools/io/vpIoTools.cpp +++ b/src/tools/io/vpIoTools.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpIoTools.cpp 4303 2013-07-04 14:14:00Z fspindle $ + * $Id: vpIoTools.cpp 4604 2014-01-21 14:15:23Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -55,13 +55,13 @@ #include <fcntl.h> #include <limits> #include <cmath> -#if defined UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX # include <unistd.h> -#elif defined WIN32 +#elif defined(_WIN32) # include <windows.h> # include <direct.h> #endif -#ifndef WIN32 +#if !defined(_WIN32) # include <wordexp.h> #endif @@ -92,8 +92,8 @@ std::vector<std::string> vpIoTools::configValues = std::vector<std::string>(); void vpIoTools::getUserName(std::string &username) { - // With MinGW, UNIX and WIN32 are defined -#if defined UNIX + // With MinGW, UNIX and _WIN32 are defined +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX // Get the user name. char *_username = NULL; _username = ::getenv("LOGNAME"); @@ -103,7 +103,7 @@ vpIoTools::getUserName(std::string &username) "Cannot get the username")) ; } username = _username; -#elif defined WIN32 +#elif defined(_WIN32) unsigned int info_buffer_size = 1024; TCHAR *infoBuf = new TCHAR [info_buffer_size]; DWORD bufCharCount = (DWORD) info_buffer_size; @@ -140,7 +140,7 @@ std::string vpIoTools::getUserName() { std::string username; -#if defined UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX // Get the user name. char *_username = NULL; _username = ::getenv("LOGNAME"); @@ -150,7 +150,7 @@ vpIoTools::getUserName() "Cannot get the username")) ; } username = _username; -#elif defined WIN32 +#elif defined(_WIN32) unsigned int info_buffer_size = 1024; TCHAR *infoBuf = new TCHAR [info_buffer_size]; DWORD bufCharCount = (DWORD) info_buffer_size; @@ -206,13 +206,13 @@ int main() */ std::string vpIoTools::getenv(const char * -#if defined UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX env #endif ) { std::string value; -#if defined UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX // Get the environment variable value. char *_value = NULL; _value = ::getenv(env); @@ -224,7 +224,7 @@ vpIoTools::getenv(const char * value = _value; return value; -#elif defined WIN32 +#elif defined(_WIN32) vpERROR_TRACE( "Not implemented!" ); throw(vpIoException(vpException::notImplementedError, @@ -334,9 +334,9 @@ vpIoTools::getVersion(const std::string &version, unsigned int &major, unsigned bool vpIoTools::checkDirectory(const char *dirname ) { -#if defined UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX struct stat stbuf; -#elif defined WIN32 +#elif defined(_WIN32) struct _stat stbuf; #endif @@ -346,9 +346,9 @@ vpIoTools::checkDirectory(const char *dirname ) std::string _dirname = path(dirname); -#if defined UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX if ( stat( _dirname.c_str(), &stbuf ) != 0 ) -#elif defined WIN32 +#elif defined(_WIN32) if ( _stat( _dirname.c_str(), &stbuf ) != 0 ) #endif { @@ -357,9 +357,9 @@ vpIoTools::checkDirectory(const char *dirname ) if ( (stbuf.st_mode & S_IFDIR) == 0 ) { return false; } -#if defined UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX if ( (stbuf.st_mode & S_IWUSR) == 0 ) -#elif defined WIN32 +#elif defined(_WIN32) if ( (stbuf.st_mode & S_IWRITE) == 0 ) #endif { @@ -403,9 +403,9 @@ vpIoTools::checkDirectory(const std::string &dirname ) void vpIoTools::makeDirectory(const char *dirname ) { -#if defined UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX struct stat stbuf; -#elif defined WIN32 +#elif defined(_WIN32) struct _stat stbuf; #endif @@ -417,15 +417,15 @@ vpIoTools::makeDirectory(const char *dirname ) std::string _dirname = path(dirname); -#if defined UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX if ( stat( _dirname.c_str(), &stbuf ) != 0 ) -#elif defined WIN32 +#elif defined(_WIN32) if ( _stat( _dirname.c_str(), &stbuf ) != 0 ) #endif { -#if ( defined(UNIX) && !defined(WIN32) ) +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) if ( mkdir( _dirname.c_str(), (mode_t)0755 ) != 0 ) -#elif defined WIN32 +#elif defined(_WIN32) if ( _mkdir( _dirname.c_str()) != 0 ) #endif { @@ -484,9 +484,9 @@ vpIoTools::makeDirectory(const std::string &dirname ) bool vpIoTools::checkFilename(const char *filename) { -#if defined UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX struct stat stbuf; -#elif defined WIN32 +#elif defined(_WIN32) struct _stat stbuf; #endif @@ -495,9 +495,9 @@ vpIoTools::checkFilename(const char *filename) } std::string _filename = path(filename); -#if defined UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX if ( stat( _filename.c_str(), &stbuf ) != 0 ) -#elif defined WIN32 +#elif defined(_WIN32) if ( _stat( _filename.c_str(), &stbuf ) != 0 ) #endif { @@ -506,9 +506,9 @@ vpIoTools::checkFilename(const char *filename) if ( (stbuf.st_mode & S_IFREG) == 0 ) { return false; } -#if defined UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX if ( (stbuf.st_mode & S_IRUSR) == 0 ) -#elif defined WIN32 +#elif defined(_WIN32) if ( (stbuf.st_mode & S_IREAD) == 0 ) #endif { @@ -555,9 +555,9 @@ vpIoTools::copy(const char *src, const char *dst) // Check if we have to consider a file or a directory if ( vpIoTools::checkFilename(src) ) { //std::cout << "copy file: " << src << " in " << dst << std::endl; -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX sprintf(cmd, "cp -p %s %s", src, dst); -#elif WIN32 +#elif defined(_WIN32) std::string src_ = vpIoTools::path(src); std::string dst_ = vpIoTools::path(dst); sprintf(cmd, "copy %s %s", src_.c_str(), dst_.c_str()); @@ -568,9 +568,9 @@ vpIoTools::copy(const char *src, const char *dst) } else if ( vpIoTools::checkDirectory(src) ) { //std::cout << "copy directory: " << src << " in " << dst << std::endl; -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX sprintf(cmd, "cp -p -r %s %s", src, dst); -#elif WIN32 +#elif defined(_WIN32) std::string src_ = vpIoTools::path(src); std::string dst_ = vpIoTools::path(dst); sprintf(cmd, "copy %s %s", src_.c_str(), dst_.c_str()); @@ -627,9 +627,9 @@ vpIoTools::remove(const char *file_or_dir) else if ( vpIoTools::checkDirectory(file_or_dir) ) { //std::cout << "remove directory: " << file_or_dir << std::endl; char cmd[FILENAME_MAX]; -#ifdef UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX sprintf(cmd, "rm -rf %s", file_or_dir); -#elif WIN32 +#elif defined(_WIN32) std::string file_or_dir_ = vpIoTools::path(file_or_dir); sprintf(cmd, "rmdir /S /Q %s", file_or_dir_.c_str()); #endif @@ -716,7 +716,7 @@ vpIoTools::path(const char *pathname) { std::string path(pathname); -#ifdef WIN32 +#if defined(_WIN32) for(unsigned int i=0 ; i<path.length() ; i++) if( path[i] == '/') path[i] = '\\'; #else diff --git a/src/tools/io/vpIoTools.h b/src/tools/io/vpIoTools.h index 1a3142f396fed23d8df6ede30d0132c651fb885c..51c7e9c35797366f884bae3e620fe80341f1a973 100644 --- a/src/tools/io/vpIoTools.h +++ b/src/tools/io/vpIoTools.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpIoTools.h 4275 2013-06-25 12:35:42Z fspindle $ + * $Id: vpIoTools.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/tools/io/vpKeyboard.cpp b/src/tools/io/vpKeyboard.cpp index da4fdc0cdc34288b059683d8b988b00f8b392ce7..b18696ec2be10e26ca8e03ab9d3a9c7a07288a97 100644 --- a/src/tools/io/vpKeyboard.cpp +++ b/src/tools/io/vpKeyboard.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpKeyboard.cpp 4267 2013-06-14 18:07:13Z fspindle $ + * $Id: vpKeyboard.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -41,7 +41,7 @@ -#if ( defined(UNIX) && !defined(WIN32) ) +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) # include <stdio.h> # include <visp/vpKeyboard.h> @@ -54,7 +54,7 @@ /*! Activates the raw mode to read keys in an non blocking way. */ -vpKeyboard::vpKeyboard() +vpKeyboard::vpKeyboard() : initial_settings(), new_settings() { init(); } diff --git a/src/tools/io/vpKeyboard.h b/src/tools/io/vpKeyboard.h index 844d86f6a188cfea9614298be32fbf7205962901..c1097ca4143a7f0d4af2621b038f99ee8f55f34e 100644 --- a/src/tools/io/vpKeyboard.h +++ b/src/tools/io/vpKeyboard.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpKeyboard.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpKeyboard.h 4604 2014-01-21 14:15:23Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -50,7 +50,7 @@ #include <visp/vpConfig.h> -#if ( defined(UNIX) && !defined(WIN32) ) +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) # include <iostream> # include <termios.h> diff --git a/src/tools/io/vpParallelPort.cpp b/src/tools/io/vpParallelPort.cpp index ea1736b0f9638d4ff565cca2ec03d0589ed39053..7b8be9fde7a358aa1b85f72f69a8b8be97523b6f 100644 --- a/src/tools/io/vpParallelPort.cpp +++ b/src/tools/io/vpParallelPort.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpParallelPort.cpp 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpParallelPort.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/tools/io/vpParallelPort.h b/src/tools/io/vpParallelPort.h index 9dd876885b9be078fc3b7e0acce5577d4e75c494..d778e40dbc4ccb88d33157614a5e8c64d923bdb7 100644 --- a/src/tools/io/vpParallelPort.h +++ b/src/tools/io/vpParallelPort.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpParallelPort.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpParallelPort.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/tools/io/vpParallelPortException.h b/src/tools/io/vpParallelPortException.h index ef971f0f038a88ee3c0cfa2b3ebc01ab73783214..b1867e754ca48d87554f1e1b5e071a2a725341ea 100644 --- a/src/tools/io/vpParallelPortException.h +++ b/src/tools/io/vpParallelPortException.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpParallelPortException.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpParallelPortException.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -78,36 +78,31 @@ */ class VISP_EXPORT vpParallelPortException : public vpException { -public: - /*! + public: + /*! \brief Lists the possible errors than can be emmited while calling vpParallelPort member */ - enum error + enum error { opening, /*!< Cannot access to the parallel port device. */ closing /*!< Cannot close the parallel port device. */ } ; -public: - vpParallelPortException (const int code, const char * msg) - : vpException(code, msg){ ; } - vpParallelPortException (const int code, const std::string & msg) - : vpException(code, msg){ ; } - vpParallelPortException (const int code) - : vpException(code){ ; } + public: + vpParallelPortException (const int code, const char* format, ...) + { + this->code = code; + va_list args; + va_start(args, format); + setMessage(format, args); + va_end (args); + } + vpParallelPortException (const int code, const std::string & msg) + : vpException(code, msg){ ; } + vpParallelPortException (const int code) + : vpException(code){ ; } }; - - - - -#endif /* #ifndef __vpParallelPortException_H */ - - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ +#endif diff --git a/src/tools/io/vpParseArgv.h b/src/tools/io/vpParseArgv.h index 8b9e3e432afaaf561595a95d9e7c4e760705cffd..c466daaffe04ab19726d814deed1576a00d18b57 100644 --- a/src/tools/io/vpParseArgv.h +++ b/src/tools/io/vpParseArgv.h @@ -1,6 +1,6 @@ /**************************************************************************** * - * $Id: vpParseArgv.h 2780 2010-09-08 08:37:15Z fspindle $ + * $Id: vpParseArgv.h 4473 2013-09-27 16:50:44Z fspindle $ * * Declarations for Tk-related things that are visible * outside of the Tk module itself. @@ -35,6 +35,7 @@ #include <visp/vpConfig.h> +#include <visp/vpException.h> /*! \class vpParseArgv diff --git a/src/tools/mutex/vpMutex.h b/src/tools/mutex/vpMutex.h index 2dbb15eaca8bc9e4aeedfb366ad69f857b8e8bd3..812d2a3948360ab3a750f77b1e95b845b507fce4 100644 --- a/src/tools/mutex/vpMutex.h +++ b/src/tools/mutex/vpMutex.h @@ -1,10 +1,10 @@ /**************************************************************************** * - * $Id: vpMutex.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMutex.h 4574 2014-01-09 08:48:51Z fspindle $ * * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/tools/plot/vpPlot.cpp b/src/tools/plot/vpPlot.cpp index e458136c1774532907e6965c81ffef32c964d003..d65d4a598c9131d832240611b66c51203da06441 100644 --- a/src/tools/plot/vpPlot.cpp +++ b/src/tools/plot/vpPlot.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpPlot.cpp 4151 2013-03-11 06:52:18Z fspindle $ + * $Id: vpPlot.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -64,13 +64,9 @@ Needs then a call to init(). */ -vpPlot::vpPlot() +vpPlot::vpPlot() : I(), display(NULL), graphNbr(1), graphList(NULL), margei(30), margej(40), + factori(1.f), factorj(1.) { - graphList = NULL; - display = NULL; - - margei = 30; - margej = 40; } /*! This constructor creates a new window where the curves @@ -82,23 +78,19 @@ vpPlot::vpPlot() default font is set to "-adobe-times-medium-i-normal--10-100-75-75-p-52-iso8859-*". Note that you can chose an other one using "xfontsel". - \param graphNbr : The number of graph in the window. + \param graph_nbr : The number of graph in the window. \param height : Height of the window. \param width : Width of the window. \param x,y : The window is set at position x,y (column index, row index). \param title : Window title. */ -vpPlot::vpPlot(const unsigned int graphNbr, +vpPlot::vpPlot(const unsigned int graph_nbr, const unsigned int height, const unsigned int width, const int x, const int y, const char *title) -{ - graphList = NULL; - display = NULL; - - margei = 30; - margej = 40; - - init(graphNbr, height, width, x, y, title); + : I(), display(NULL), graphNbr(1), graphList(NULL), margei(30), margej(40), + factori(1.f), factorj(1.) +{ + init(graph_nbr, height, width, x, y, title); } /*! @@ -107,13 +99,13 @@ vpPlot::vpPlot(const unsigned int graphNbr, \warning You can modify the default window size, but this is not advised. - \param graphNbr : The number of graph in the window. + \param graph_nbr : The number of graph in the window. \param height : Height of the window. \param width : Width of the window. \param x,y : The window is set at position x,y (column index, row index). \param title : Window title. */ -void vpPlot::init(const unsigned int graphNbr, +void vpPlot::init(const unsigned int graph_nbr, const unsigned int height, const unsigned int width, const int x, const int y, const char *title) { @@ -138,7 +130,7 @@ void vpPlot::init(const unsigned int graphNbr, factori = height/700.0f; factorj = width/700.0f; - initNbGraph(graphNbr); + initNbGraph(graph_nbr); } /*! @@ -203,7 +195,6 @@ vpPlot::initNbGraph (unsigned int nbGraph) strcpy(graphList[i].unitx, ""); strcpy(graphList[i].unity, ""); strcpy(graphList[i].unitz, ""); - graphList[i].textdispayed=false; } } @@ -357,12 +348,11 @@ void vpPlot::plot(const unsigned int graphNum, const double x, const vpColVector } /*! - This method unable to move the point of view if you have a 3D graphic. + This method allows to change the point of view with the mouse if you have a 3D graphic. */ void vpPlot::navigate() { - vpImagePoint trash; vpMouseButton::vpMouseButtonType b = vpMouseButton::button1; bool blocked = false; @@ -376,15 +366,15 @@ vpPlot::navigate() vpDisplay::getPointerPosition(I,iP); for (unsigned int i = 0; i < graphNbr ; i++) { - if (iP.inRectangle((graphList+i)->graphZone)) - { - iblocked = i; - break; - } + if (iP.inRectangle((graphList+i)->graphZone)) + { + iblocked = i; + break; + } } if ((graphList+iblocked)->move(I)) { - (graphList+iblocked)->replot3D(I); + (graphList+iblocked)->replot3D(I); } blocked = (graphList+iblocked)->blocked; @@ -393,7 +383,7 @@ vpPlot::navigate() { if ((graphList+iblocked)->move(I)) { - (graphList+iblocked)->replot3D(I); + (graphList+iblocked)->replot3D(I); } blocked = (graphList+iblocked)->blocked; } diff --git a/src/tools/plot/vpPlot.h b/src/tools/plot/vpPlot.h index 32668e3e3b161f572f7aac5b7ba8130ea935da05..f16bfc119156d0fae645e3c4ddb966614c93b6f0 100644 --- a/src/tools/plot/vpPlot.h +++ b/src/tools/plot/vpPlot.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpPlot.h 4233 2013-05-02 13:46:42Z fspindle $ + * $Id: vpPlot.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/tools/plot/vpPlotCurve.cpp b/src/tools/plot/vpPlotCurve.cpp index 0106ef9aba9cc1eb5176fbea673cb939e2bd210c..245fb4078b83edb3d9534e703db3a5be589475d4 100644 --- a/src/tools/plot/vpPlotCurve.cpp +++ b/src/tools/plot/vpPlotCurve.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpPlotCurve.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpPlotCurve.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -50,14 +50,10 @@ #include <visp/vpDisplayD3D.h> #if defined(VISP_HAVE_DISPLAY) -vpPlotCurve::vpPlotCurve() +vpPlotCurve::vpPlotCurve() : + color(vpColor::red), curveStyle(point), thickness(1), nbPoint(0), lastPoint(), + pointListx(), pointListy(), pointListz(), xmin(0), xmax(0), ymin(0), ymax(0) { - color = vpColor::red; - pointListx.clear(); - pointListy.clear(); - pointListz.clear(); - nbPoint = 0; - thickness = 1 ; } vpPlotCurve::~vpPlotCurve() diff --git a/src/tools/plot/vpPlotCurve.h b/src/tools/plot/vpPlotCurve.h index 8fe6b8acbba165eda8c268c5193f3eea52a562ec..32f6eaceebd317af99bcc8da114d0dd2107e3311 100644 --- a/src/tools/plot/vpPlotCurve.h +++ b/src/tools/plot/vpPlotCurve.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpPlotCurve.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpPlotCurve.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/tools/plot/vpPlotGraph.cpp b/src/tools/plot/vpPlotGraph.cpp index 30a8bab87ccbcb66d7cbb37e97c058d6091c522b..cbe0d662958a9de7ea156bc851744617b2df90d2 100644 --- a/src/tools/plot/vpPlotGraph.cpp +++ b/src/tools/plot/vpPlotGraph.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpPlotGraph.cpp 4303 2013-07-04 14:14:00Z fspindle $ + * $Id: vpPlotGraph.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -61,41 +61,23 @@ #if defined(VISP_HAVE_DISPLAY) +int laFonctionSansNom (const double delta); +void getGrid3DPoint(const double pente, vpImagePoint &iPunit, vpImagePoint &ip1, vpImagePoint &ip2, vpImagePoint &ip3); + + vpPlotGraph::vpPlotGraph() + : xorg(0.), yorg(0.), zoomx(1.), zoomy(1.), xmax(10), ymax(10), xmin(0), ymin(-10), + xdelt(1), ydelt(1), gridx(true), gridy(true), gridColor(), curveNbr(1), curveList(NULL), + scaleInitialized(false), firstPoint(true), nbDivisionx(10), nbDivisiony(10), topLeft(), + width(0), height(0), graphZone(), dTopLeft(), dWidth(0), dHeight(0), dGraphZone(), + dTopLeft3D(), dGraphZone3D(), cam(), cMo(), cMf(), w_xval(0), w_xsize(0), w_yval(0), w_ysize(0), + w_zval(0), w_zsize(0), ptXorg(0), ptYorg(0), ptZorg(0), zoomx_3D(1.), zoomy_3D(1.), zoomz_3D(1.), + nbDivisionz(10), zorg(1.), zoomz(1.), zmax(10), zmin(-10), zdelt(1), old_iPr(), old_iPz(), + blockedr(false), blockedz(false), blocked(false), epsi(5), epsj(6), + dispUnit(false), dispTitle(false), dispLegend(false), gridThickness(1) { - curveList = NULL; - gridColor.setColor(200,200,200); - nbDivisionx = 10; - nbDivisiony = 10; - nbDivisionz = 10; - - xmax = 10; - xmin = 0; - ymax = 10; - ymin = -10; - zmax = 10; - zmin = -10; - xdelt = 1; - ydelt = 1; - zdelt = 1; - gridx = true; - gridy = true; - scaleInitialized = false; - firstPoint = true; - - dispUnit = false; - dispTitle = false; - dispLegend = false; - - blockedr = false; - blockedz = false; - blocked = false; - - epsi = 5; - epsj = 6; - old_iPr = vpImagePoint(-1,-1); old_iPz = vpImagePoint(-1,-1); @@ -130,11 +112,11 @@ vpPlotGraph::initGraph (unsigned int nbCurve) } void -vpPlotGraph::initSize (vpImagePoint topLeft, unsigned int width, unsigned int height, unsigned int margei, unsigned int margej) +vpPlotGraph::initSize (vpImagePoint top_left, unsigned int w, unsigned int h, unsigned int margei, unsigned int margej) { - this->topLeft = topLeft; - this->width = width; - this->height = height; + this->topLeft = top_left; + this->width = w; + this->height = h; graphZone.setTopLeft(topLeft); graphZone.setWidth(width); graphZone.setHeight(height); @@ -237,36 +219,61 @@ vpPlotGraph::setCurveColor(const unsigned int curveNum, const vpColor color) } void -vpPlotGraph::setTitle (const char *title) +vpPlotGraph::setTitle (const char *title_) { - strcpy(this->title, title); + if (strlen(title_) >= 256) { + throw(vpException(vpException::memoryAllocationError, + "Not enough memory to intialize the title")); + } + + strcpy(this->title, title_); dispTitle = true; } void -vpPlotGraph::setUnitX (const char *unitx) +vpPlotGraph::setUnitX (const char *unit_x) { - strcpy(this->unitx, unitx); + if (strlen(unit_x) >= 256) { + throw(vpException(vpException::memoryAllocationError, + "Not enough memory to intialize the unit along x axis")); + } + + strcpy(this->unitx, unit_x); dispUnit = true; } void -vpPlotGraph::setUnitY (const char *unity) +vpPlotGraph::setUnitY (const char *unit_y) { - strcpy(this->unity, unity); + if (strlen(unit_y) >= 256) { + throw(vpException(vpException::memoryAllocationError, + "Not enough memory to intialize the unit along y axis")); + } + + strcpy(this->unity, unit_y); dispUnit = true; } void -vpPlotGraph::setUnitZ (const char *unitz) +vpPlotGraph::setUnitZ (const char *unit_z) { - strcpy(this->unitz, unitz); + if (strlen(unit_z) >= 256) { + throw(vpException(vpException::memoryAllocationError, + "Not enough memory to intialize the unit along z axis")); + } + + strcpy(this->unitz, unit_z); dispUnit = true; } void vpPlotGraph::setLegend (const unsigned int curveNum, const char *legend) { + if (strlen(legend) >= 256) { + throw(vpException(vpException::memoryAllocationError, + "Not enough memory to intialize the legend")); + } + strcpy((curveList+curveNum)->legend,legend); dispLegend = true; } @@ -480,12 +487,13 @@ vpPlotGraph::rescaley(unsigned int side, double extremity) } void -vpPlotGraph::initScale(vpImage<unsigned char> &I, const double xmin, const double xmax, const int nbDivx, const double ymin, const double ymax, const int nbDivy, const bool gx, const bool gy) +vpPlotGraph::initScale(vpImage<unsigned char> &I, const double x_min, const double x_max, const int nbDivx, + const double y_min, const double y_max, const int nbDivy, const bool gx, const bool gy) { - this->xmin = xmin; - this->xmax = xmax; - this->ymin = ymin; - this->ymax = ymax; + this->xmin = x_min; + this->xmax = x_max; + this->ymin = y_min; + this->ymax = y_max; this->gridx = gx; this->gridy = gy; this->nbDivisionx = nbDivx; @@ -499,14 +507,16 @@ vpPlotGraph::initScale(vpImage<unsigned char> &I, const double xmin, const doubl void -vpPlotGraph::initScale(vpImage<unsigned char> &I, const double xmin, const double xmax, const int nbDivx, const double ymin, const double ymax, const int nbDivy, const double zmin, const double zmax, const int nbDivz, const bool gx, const bool gy) +vpPlotGraph::initScale(vpImage<unsigned char> &I, const double x_min, const double x_max, const int nbDivx, + const double y_min, const double y_max, const int nbDivy, + const double z_min, const double z_max, const int nbDivz, const bool gx, const bool gy) { - this->xmin = xmin; - this->xmax = xmax; - this->ymin = ymin; - this->ymax = ymax; - this->zmin = zmin; - this->zmax = zmax; + this->xmin = x_min; + this->xmax = x_max; + this->ymin = y_min; + this->ymax = y_max; + this->zmin = z_min; + this->zmax = z_max; this->gridx = gx; this->gridy = gy; this->nbDivisionx = nbDivx; @@ -881,7 +891,7 @@ vpPlotGraph::check3Dpoint(vpImagePoint &iP) if (iP.get_j() <dTopLeft3D.get_j()) iP.set_j(dTopLeft3D.get_j()); else if (iP.get_j() > dTopLeft3D.get_j()+dWidth) - iP.set_i(dTopLeft3D.get_j()+dWidth-1); + iP.set_j(dTopLeft3D.get_j()+dWidth-1); return false; } return true; @@ -1089,7 +1099,7 @@ vpPlotGraph::displayGrid3D (vpImage<unsigned char> &I) vpDisplay::displayArrow(I,iP[0],iP[1], vpColor::black, gridThickness); if (dispUnit) { - vpImagePoint iPunit(iP[1].get_i(),iP[1].get_j()-10*epsj); + iPunit.set_ij(iP[1].get_i(),iP[1].get_j()-10*epsj); check3Dpoint (iPunit); vpDisplay::displayCharString(I,iPunit,unitx, vpColor::black); } @@ -1099,7 +1109,7 @@ vpPlotGraph::displayGrid3D (vpImage<unsigned char> &I) vpDisplay::displayArrow(I,iP[3],iP[2], vpColor::black, gridThickness); if (dispUnit) { - vpImagePoint iPunit(iP[2].get_i(),iP[2].get_j()-10*epsj); + iPunit.set_ij(iP[2].get_i(),iP[2].get_j()-10*epsj); check3Dpoint (iPunit); vpDisplay::displayCharString(I,iPunit,unity, vpColor::black); } @@ -1109,7 +1119,7 @@ vpPlotGraph::displayGrid3D (vpImage<unsigned char> &I) vpDisplay::displayArrow(I,iP[4],iP[5], vpColor::black, gridThickness); if (dispUnit) { - vpImagePoint iPunit(iP[5].get_i(),iP[5].get_j()-10*epsj); + iPunit.set_ij(iP[5].get_i(),iP[5].get_j()-10*epsj); check3Dpoint (iPunit); vpDisplay::displayCharString(I,iPunit,unitz, vpColor::black); } @@ -1209,14 +1219,14 @@ vpPlotGraph::plot (vpImage<unsigned char> &I, const unsigned int curveNb, const #if( defined VISP_HAVE_X11 || defined VISP_HAVE_GDI ) double top; double left; - double width; - double height; + double width_; + double height_; - if (iP.get_i() <= (curveList+curveNb)->lastPoint.get_i()) {top = iP.get_i()-5; height = (curveList+curveNb)->lastPoint.get_i() - top+10;} - else {top = (curveList+curveNb)->lastPoint.get_i()-5; height = iP.get_i() - top+10;} - if (iP.get_j() <= (curveList+curveNb)->lastPoint.get_j()) {left = iP.get_j()-5; width = (curveList+curveNb)->lastPoint.get_j() - left+10;} - else {left = (curveList+curveNb)->lastPoint.get_j()-5; width = iP.get_j() - left+10;} - vpDisplay::flushROI(I,vpRect(left,top,width,height)); + if (iP.get_i() <= (curveList+curveNb)->lastPoint.get_i()) {top = iP.get_i()-5; height_ = (curveList+curveNb)->lastPoint.get_i() - top+10;} + else {top = (curveList+curveNb)->lastPoint.get_i()-5; height_ = iP.get_i() - top+10;} + if (iP.get_j() <= (curveList+curveNb)->lastPoint.get_j()) {left = iP.get_j()-5; width_ = (curveList+curveNb)->lastPoint.get_j() - left+10;} + else {left = (curveList+curveNb)->lastPoint.get_j()-5; width_ = iP.get_j() - left+10;} + vpDisplay::flushROI(I,vpRect(left,top,width_,height_)); #endif (curveList+curveNb)->lastPoint = iP; @@ -1368,13 +1378,13 @@ vpPlotGraph::navigation(const vpImage<unsigned char> &I, bool &changed) if (old_iPr != vpImagePoint(-1,-1) && blockedr) { - double width = vpMath::minimum(I.getWidth(),I.getHeight()); + double width_ = vpMath::minimum(I.getWidth(),I.getHeight()); double diffi = iP.get_i() - old_iPr.get_i(); double diffj = iP.get_j() - old_iPr.get_j(); - anglei = diffi*360/width; - anglej = diffj*360/width; + anglei = diffi*360/width_; + anglej = diffj*360/width_; mov.buildFrom(0,0,0,vpMath::rad(anglei),vpMath::rad(-anglej),0); changed = true; } diff --git a/src/tools/plot/vpPlotGraph.h b/src/tools/plot/vpPlotGraph.h index 88fb8084bf2de2eabb48dba65ab6985e4225065d..0e8af1e8862bf920a5e5c10bfa5f0b718e74d847 100644 --- a/src/tools/plot/vpPlotGraph.h +++ b/src/tools/plot/vpPlotGraph.h @@ -1,10 +1,10 @@ /**************************************************************************** * - * $Id: vpPlotGraph.h 4151 2013-03-11 06:52:18Z fspindle $ + * $Id: vpPlotGraph.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -79,7 +79,6 @@ class vpPlotGraph char unity[256]; unsigned int curveNbr; vpPlotCurve* curveList; - bool textdispayed; bool scaleInitialized; bool firstPoint; diff --git a/src/tools/time/vpTime.cpp b/src/tools/time/vpTime.cpp index 8c2dcb124b3a02312c1892578f565730bdae753e..e1d5adc84d83656e6a3cf3c525b54726f22ba3d7 100644 --- a/src/tools/time/vpTime.cpp +++ b/src/tools/time/vpTime.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpTime.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpTime.cpp 4622 2014-01-28 17:40:36Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -56,10 +56,10 @@ // Unix depend version -#if defined UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX # include <sys/time.h> # include <unistd.h> -#elif defined WIN32 +#elif defined(_WIN32) # include <windows.h> # include <winbase.h> #endif @@ -78,14 +78,14 @@ double vpTime::minTimeForUsleepCall = 4; /*! This time is in /*! - Return the time in milliseconds. + Return the time in milliseconds since January 1st 1970. \sa measureTimeMicros(), measureTimeSecond() */ double vpTime::measureTimeMs() { -#if defined(WIN32) +#if defined(_WIN32) LARGE_INTEGER time, frequency; QueryPerformanceFrequency(&frequency); if(frequency.QuadPart == 0){ @@ -95,7 +95,7 @@ vpTime::measureTimeMs() QueryPerformanceCounter(&time); return (double)(1000.0*time.QuadPart/frequency.QuadPart); } -#elif defined UNIX +#elif !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX struct timeval tp; gettimeofday(&tp,0); return(1000.0*tp.tv_sec + tp.tv_usec/1000.0); @@ -104,14 +104,14 @@ vpTime::measureTimeMs() /*! - Return the time in microseconds. + Return the time in microseconds since January 1st 1970. \sa measureTimeMs(), measureTimeSecond() */ double vpTime::measureTimeMicros() { -#if defined(WIN32) +#if defined(_WIN32) LARGE_INTEGER time, frequency; QueryPerformanceFrequency(&frequency); if(frequency.QuadPart == 0){ @@ -156,11 +156,11 @@ vpTime::wait(double t0, double t) if ( timeToWait <= 0. ) // no need to wait return(1); else { -#if defined UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX if (timeToWait > vpTime::minTimeForUsleepCall) { usleep((unsigned long )((timeToWait-vpTime::minTimeForUsleepCall)*1000)); } -#elif defined WIN32 +#elif defined(_WIN32) if (timeToWait > vpTime::minTimeForUsleepCall) { Sleep((DWORD)(timeToWait-vpTime::minTimeForUsleepCall)); } @@ -196,11 +196,11 @@ void vpTime::wait(double t) if ( timeToWait <= 0. ) // no need to wait return; else { -#if defined UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX if (timeToWait > vpTime::minTimeForUsleepCall) { usleep((unsigned long )((timeToWait-vpTime::minTimeForUsleepCall)*1000)); } -#elif defined WIN32 +#elif defined(_WIN32) if (timeToWait > vpTime::minTimeForUsleepCall) { Sleep((DWORD)(timeToWait-vpTime::minTimeForUsleepCall)); } @@ -218,7 +218,7 @@ void vpTime::wait(double t) /*! - Return the measured time in seconds. + Return the measured time in seconds since January 1st 1970. \sa measureTimeMs() */ @@ -235,9 +235,9 @@ double vpTime::measureTimeSecond() */ void vpTime::sleepMs(double t) { -#if defined UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX usleep((unsigned long )(t*1000)); -#elif defined WIN32 +#elif defined(_WIN32) Sleep((DWORD)(t)); #endif } diff --git a/src/tools/time/vpTime.h b/src/tools/time/vpTime.h index 8460744921bd44ec95f48f2e7e5aacb6c1e035b5..b21b2f194000672ea8a5f5d032143512a18ad354 100644 --- a/src/tools/time/vpTime.h +++ b/src/tools/time/vpTime.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpTime.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpTime.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -51,6 +51,7 @@ */ #include <visp/vpConfig.h> +#include <visp/vpException.h> /*! \class vpTime diff --git a/src/tools/trace/vpDebug.h b/src/tools/trace/vpDebug.h index 03e061be3b926b6b6b03ff14a8e4e47f5eb41bf9..4f3970ca8036f85dd47ae81c9815c0418bd8bfa7 100644 --- a/src/tools/trace/vpDebug.h +++ b/src/tools/trace/vpDebug.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDebug.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpDebug.h 4604 2014-01-21 14:15:23Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -57,7 +57,7 @@ #include <iostream> -#ifdef WIN32 +#if defined(_WIN32) # ifndef __FUNCTION__ # define __FUNCTION__ " " # endif @@ -82,21 +82,23 @@ This class is used to define the following macros: - - Macros for tracing: vpTRACE() and vpERROR_TRACE() work like printf - with carreer return at the end of the string. vpCERROR() et - vpCTRACE() work like the C++ output streams std::cout and + - Macros for tracing: vpTRACE(), vpERROR_TRACE(), vpIN_FCT() and + vpOUT_FCT() work like printf + with carreer return at the end of the string, while vpCTRACE() and + vpCERROR() work like the C++ output streams std::cout and std::cerr. - - Macros for debuging: vpDEBUG_TRACE(niv) and vpDERROR_TRACE(niv) - work like printf, but print only if the tracing level \e niv is - greater than the debug level VP_DEBUG_MODE macro. vpCDEBUG(niv) - work like the C++ output stream std::cout. vpDEBUG_ENABLE(niv) is - equal to 1 if the debug level niv is greater than the debug mode + - Macros for debuging: vpDEBUG_TRACE(level) and vpDERROR_TRACE(level) + work like printf, but print only if the tracing level \e level is + greater than the debug level VP_DEBUG_MODE macro. vpCDEBUG(level) + work like the C++ output stream std::cout. vpDEBUG_ENABLE(level) is + equal to 1 if the debug level level is greater than the debug mode VP_DEBUG_MODE, 0 else. The example below shows how to use these macros. \code +#define VP_TRACE // Activate the trace mode #define VP_DEBUG // Activate the debug mode #define VP_DEBUG_MODE 2 // Activate debug level 1 and 2 @@ -123,7 +125,7 @@ int main() vpDERROR_TRACE(2, "C-like error trace level 2"); // stderr // C++-like debug printings - vpCTRACE << "C++-like debug trace" << std::endl; // stdout + vpCTRACE << "C++-like trace" << std::endl; // stdout vpCERROR << "C++-like error trace" << std::endl; // stderr // Printing if VP_DEBUG defined and VP_DEBUG_MODE value >= 2 @@ -136,7 +138,7 @@ int main() */ class vpTraceOutput { -private: + private: const char* currentFile; //Name of the file to use in the displays const char* currentFunc; //Name of the function to use in the displays int currentLine; //Line to use in the displays @@ -146,7 +148,7 @@ private: //string to display before anything else const char* header; -public: + public: /*! Constructor. \param file Should be the name of the file where this constructor was called. @@ -157,37 +159,37 @@ public: \note Call the constructor with something like vpTraceOutput(__FILE__,__LINE__, __FUNCTION__). */ vpTraceOutput(const char* file, int line, const char* func, bool error=false, const char * s=NULL) : - currentFile(file), - currentFunc(func), - currentLine(line), - err(error), - header(s) + currentFile(file), + currentFunc(func), + currentLine(line), + err(error), + header(s) {} /*! Displays a string if the debug level is inferior to VP_DEBUG_MODE. - \param niv Level of this message. + \param level Level of this message. \param format Formating string. */ - void operator()(int niv, const char* format, ...) + void operator()(int level, const char* format, ...) { - //if the niv level is inferior to VP_DEBUG_MODE - if(VP_DEBUG_MODE >= niv) - { - //gets the variable list of arguments - va_list args; - va_start(args, format); - - if (err) - std::cerr << "(N" << niv << ") " ; - else - std::cout << "(N" << niv << ") " ; - - //calls display with it - display(format, args); - - va_end(args); - } + //if the level is inferior to VP_DEBUG_MODE + if(VP_DEBUG_MODE >= level) + { + //gets the variable list of arguments + va_list args; + va_start(args, format); + + if (err) + std::cerr << "(L" << level << ") " ; + else + std::cout << "(L" << level << ") " ; + + //calls display with it + display(format, args); + + va_end(args); + } } /*! @@ -196,18 +198,18 @@ public: */ void operator()(const char* format, ...) { - //gets the variable list of arguments - va_list args; - va_start(args, format); + //gets the variable list of arguments + va_list args; + va_start(args, format); #ifdef VP_DEBUG - std::cout<<"(N0) "; + std::cout<<"(L0) "; #endif - //calls display with it - display(format, args); + //calls display with it + display(format, args); - va_end(args); + va_end(args); } /*! @@ -221,31 +223,31 @@ public: */ void display(const char* format, va_list args) { - //if we want to write to std::cerr/stderr - if(err) - { - //first writes the header if there is one - if(header != NULL) std::cerr<<header; - //then writes the recorded namefile, function and line - std::cerr << "!!\t" << currentFile << ": " <<currentFunc << "(#" << currentLine << ") :" ; - //and finally writes the message passed to () operator. - vfprintf (stderr, format, args); - fprintf (stderr, "\n"); - //flushes the buffer - fflush (stderr); - } - else - { - //first writes the header if there is one - if(header != NULL) std::cout<<header; - //then writes the recorded namefile, function and line - std::cout <<currentFile << ": " << currentFunc << "(#" << currentLine << ") :" ; - //and finally writes the message passed to () operator. - vprintf (format, args); - printf ("\n"); - //flushes the buffer - fflush (stdout); - } + //if we want to write to std::cerr/stderr + if(err) + { + //first writes the header if there is one + if(header != NULL) std::cerr<<header; + //then writes the recorded namefile, function and line + std::cerr << "!!\t" << currentFile << ": " <<currentFunc << "(#" << currentLine << ") : " ; + //and finally writes the message passed to () operator. + vfprintf (stderr, format, args); + fprintf (stderr, "\n"); + //flushes the buffer + fflush (stderr); + } + else + { + //first writes the header if there is one + if(header != NULL) std::cout<<header; + //then writes the recorded namefile, function and line + std::cout <<currentFile << ": " << currentFunc << "(#" << currentLine << ") : " ; + //and finally writes the message passed to () operator. + vprintf (format, args); + printf ("\n"); + //flushes the buffer + fflush (stdout); + } } }; @@ -255,11 +257,14 @@ public: /* --- vpTRACE IN/OUT FONCTION --------------------------------------------- */ /* ------------------------------------------------------------------------- */ +#ifdef VP_TRACE // Activate the trace mode + /*! \ingroup Debug Works like vpTRACE() and should be used at the beginning of a function. \code +#define VP_TRACE // To activate the trace mode #include <visp/vpDebug.h> int main() @@ -280,6 +285,7 @@ int main() Works like vpTRACE() and should be used at the end of a function. \code +#define VP_TRACE // To activate the trace mode #include <visp/vpDebug.h> int main() @@ -294,27 +300,35 @@ int main() */ #define vpOUT_FCT (vpTraceOutput(__FILE__,__LINE__, __FUNCTION__, false, "end ")) +#else // #ifdef VP_TRACE + +inline void vpIN_FCT (const char * /* a */, ...){} +inline void vpOUT_FCT (const char * /* a */, ...){} +#endif // #ifdef VP_TRACE /* -------------------------------------------------------------------------- */ /* --- vpTRACE -------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +#ifdef VP_TRACE + /*! \ingroup Debug Used to display trace messages on the standard stream (C++). Use like this : vpCTRACE<<"my message"<<std::endl; \code -#define VP_DEBUG // Activate the debug mode -#define VP_DEBUG_MODE 2 // Activate debug level 1 and 2 +#define VP_TRACE // To activate trace mode +#define VP_DEBUG // To activate the debug mode +#define VP_DEBUG_MODE 2 // To activate debug level 1 and 2 #include <visp/vpDebug.h> int main() { // C++-like debug printings - vpCTRACE << "C++-like debug trace" << std::endl; // stdout + vpCTRACE << "C++-like trace" << std::endl; // stdout vpCERROR << "C++-like error trace" << std::endl; // stderr // Printing if VP_DEBUG defined and VP_DEBUG_MODE value >= 2 @@ -324,7 +338,7 @@ int main() \sa vpTRACE(), vpCERROR(), vpCDEBUG() */ -#define vpCTRACE std::cout << __FILE__ << ": " << __FUNCTION__ << "(#" << __LINE__ << ") :" +#define vpCTRACE std::cout << "(L0) " << __FILE__ << ": " << __FUNCTION__ << "(#" << __LINE__ << ") : " /*! @@ -333,15 +347,16 @@ int main() Use like this : vpCERROR<<"my message"<<std::endl; \code -#define VP_DEBUG // Activate the debug mode -#define VP_DEBUG_MODE 2 // Activate debug level 1 and 2 +#define VP_TRACE // To activate trace mode +#define VP_DEBUG // To activate the debug mode +#define VP_DEBUG_MODE 2 // To activate debug level 1 and 2 #include <visp/vpDebug.h> int main() { // C++-like debug printings - vpCTRACE << "C++-like debug trace" << std::endl; // stdout + vpCTRACE << "C++-like trace" << std::endl; // stdout vpCERROR << "C++-like error trace" << std::endl; // stderr // Printing if VP_DEBUG defined and VP_DEBUG_MODE value >= 2 @@ -351,7 +366,7 @@ int main() \sa vpCTRACE(), vpCDEBUG() */ -#define vpCERROR std::cerr << "!!\t" << __FILE__ << ": " << __FUNCTION__ << "(#" << __LINE__ << ") :" +#define vpCERROR std::cerr << "(L0) " << "!!\t" << __FILE__ << ": " << __FUNCTION__ << "(#" << __LINE__ << ") : " /*! \ingroup Debug @@ -362,6 +377,7 @@ int main() with any "printf" string. \code +#define VP_TRACE // To activate trace mode #define VP_DEBUG_MODE 2 // Activate debug level 1 and 2 #include <visp/vpDebug.h> @@ -387,6 +403,7 @@ int main() with any "printf" string. \code +#define VP_TRACE // To activate trace mode #include <visp/vpDebug.h> int main() @@ -400,6 +417,17 @@ int main() */ #define vpTRACE (vpTraceOutput( __FILE__,__LINE__, __FUNCTION__, false)) +#else // #ifdef VP_TRACE + +#define vpCTRACE if(false) std::cout // Warning C4127 +#define vpCERROR if(false) std::cerr // Warning C4127 + +inline void vpERROR_TRACE (const char * /* a */, ...){} +inline void vpERROR_TRACE (int /* level */, const char * /* a */, ...){} +inline void vpTRACE (const char * /* a */, ...){} +inline void vpTRACE (int /* level */, const char * /* a */, ...){} + +#endif // #ifdef VP_TRACE /* ------------------------------------------------------------------------- */ /* --- VP_DEBUG ------------------------------------------------------------ */ @@ -410,7 +438,7 @@ int main() /*! \ingroup Debug vpDERROR_TRACE works like printf, but prints only if the - tracing level niv is greater than the debug level VP_DEBUG_MODE. + tracing level is smaller than the debug level VP_DEBUG_MODE. \code #define VP_DEBUG // Activate the debug mode @@ -433,7 +461,7 @@ int main() /*! \ingroup Debug vpDEBUG_TRACE works like printf, but prints only if the - tracing level niv is greater than the debug level VP_DEBUG_MODE. + tracing level level is greater than the debug level VP_DEBUG_MODE. \code #define VP_DEBUG // Activate the debug mode @@ -455,7 +483,7 @@ int main() /*! \ingroup Debug - vpCDEBUG(niv) work like the C++ output stream std::cout. + vpCDEBUG(level) work like the C++ output stream std::cout. \code #define VP_DEBUG // Activate the debug mode #define VP_DEBUG_MODE 2 // Activate debug level 1 and 2 @@ -465,7 +493,7 @@ int main() int main() { // C++-like debug printings - vpCTRACE << "C++-like debug trace" << std::endl; // stdout + vpCTRACE << "C++-like trace" << std::endl; // stdout vpCERROR << "C++-like error trace" << std::endl; // stderr // Printing if VP_DEBUG defined and VP_DEBUG_MODE value >= 2 @@ -475,13 +503,13 @@ int main() \sa vpCTRACE(), vpCERROR() */ -#define vpCDEBUG(niv) if (VP_DEBUG_MODE < niv) ; else \ - std::cout << "(N" << niv << ") "<< __FILE__ << ": " << __FUNCTION__ << "(#" << __LINE__ << ") :" +#define vpCDEBUG(level) if (VP_DEBUG_MODE < level) ; else \ + std::cout << "(L" << level << ") "<< __FILE__ << ": " << __FUNCTION__ << "(#" << __LINE__ << ") : " /*! \ingroup Debug - vpDEBUG_ENABLE(niv) is equal to 1 if the debug level \e niv is greater than + vpDEBUG_ENABLE(level) is equal to 1 if the debug level \e level is greater than the debug mode VP_DEBUG_MODE, 0 else. \code @@ -499,17 +527,19 @@ int main() } \endcode */ -#define vpDEBUG_ENABLE(niv) (VP_DEBUG_MODE >= niv) +#define vpDEBUG_ENABLE(level) (VP_DEBUG_MODE >= level) -#else +#else // #ifdef VP_DEBUG -inline void vpDERROR_TRACE(int /* niv */, const char * /* a */, ...){} -inline void vpDEBUG_TRACE(int /* niv */, const char * /* a */, ...){} +inline void vpDERROR_TRACE(const char * /* a */, ...){} +inline void vpDEBUG_TRACE(const char * /* a */, ...){} +inline void vpDERROR_TRACE(int /* level */, const char * /* a */, ...){} +inline void vpDEBUG_TRACE(int /* level */, const char * /* a */, ...){} -#define vpCDEBUG(niv) if(false) std::cout // Warning C4127 -#define vpDEBUG_ENABLE(niv) (false) // Warning C4127 +#define vpCDEBUG(level) if(false) std::cout // Warning C4127 +#define vpDEBUG_ENABLE(level) (false) // Warning C4127 -#endif +#endif // #ifdef VP_DEBUG /* -------------------------------------------------------------------------- */ /* --- DEFENSIF ------------------------------------------------------------- */ @@ -522,9 +552,3 @@ inline void vpDEBUG_TRACE(int /* niv */, const char * /* a */, ...){} #endif /* #ifdef __DEBUG_HH */ - -/* - * Local variables: - * c-basic-offset: 4 - * End: - */ diff --git a/src/tools/xml/vpXmlParser.cpp b/src/tools/xml/vpXmlParser.cpp index 086d9af154499d2e36530d590da6a06b26404580..28a59ec7c959b52fe37eceba95de078668e0dad8 100755 --- a/src/tools/xml/vpXmlParser.cpp +++ b/src/tools/xml/vpXmlParser.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpXmlParser.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpXmlParser.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -58,9 +58,8 @@ Initialise the main tag with default value. */ -vpXmlParser::vpXmlParser() +vpXmlParser::vpXmlParser() : nodeMap(), main_tag("config") { - main_tag = "config"; } /*! @@ -88,6 +87,7 @@ vpXmlParser::~vpXmlParser() \param _twin : The parser to copy. */ vpXmlParser::vpXmlParser(const vpXmlParser& _twin) + : nodeMap(), main_tag("config") { main_tag = _twin.main_tag; nodeMap = _twin.nodeMap; @@ -387,7 +387,9 @@ vpXmlParser::save(const std::string& filename, const bool append) else{ if(!append){ xmlFreeDoc(doc); - remove(filename.c_str()); + if (remove(filename.c_str()) != 0) + throw vpException(vpException::ioError, "Cannot remove existing xml file"); + doc = xmlNewDoc ((xmlChar*)"1.0"); root_node = xmlNewNode(NULL, (xmlChar*)main_tag.c_str()); xmlDocSetRootElement(doc, root_node); diff --git a/src/tools/xml/vpXmlParser.h b/src/tools/xml/vpXmlParser.h index 97c0b6ecc27c4e82edd7e3432f0685bd2f0f58b4..76d6bff3904560b36051be334bb47d6b47872bf1 100755 --- a/src/tools/xml/vpXmlParser.h +++ b/src/tools/xml/vpXmlParser.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpXmlParser.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpXmlParser.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/tracking/dots/vpDot.cpp b/src/tracking/dots/vpDot.cpp index b681392054320219fdfcbe3436a89bd655f7cf18..1955089a621b916b234abc1565a718649dc5359c 100644 --- a/src/tracking/dots/vpDot.cpp +++ b/src/tracking/dots/vpDot.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDot.cpp 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpDot.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -55,6 +55,10 @@ #include <visp/vpTrackingException.h> #include <vector> +#ifdef VISP_USE_MSVC +# pragma comment(linker, "/STACK:256000000") // Increase max recursion depth +#endif + /* \class vpDot \brief Track a white dot @@ -95,9 +99,13 @@ void vpDot::init() nbMaxPoint = 0; } -vpDot::vpDot() : vpTracker() +vpDot::vpDot() + : m00(0.), m01(0.), m10(0.), m11(0.), m20(0.), m02(0.), + mu11(0.), mu20(0.), mu02(0.), ip_connexities_list(), ip_edges_list(), connexityType(CONNEXITY_4), + cog(), u_min(0), u_max(0), v_min(0), v_max(0), graphics(false), thickness(1), maxDotSizePercentage(0.25), + gray_level_out(0), mean_gray_level(0), gray_level_min(128), gray_level_max(255), grayLevelPrecision(0.85), + gamma(1.5), compute_moment(false), nbMaxPoint(0) { - init() ; } /*! @@ -105,17 +113,26 @@ vpDot::vpDot() : vpTracker() \param ip : An image point with sub-pixel coordinates. */ -vpDot::vpDot(const vpImagePoint &ip) : vpTracker() +vpDot::vpDot(const vpImagePoint &ip) + : m00(0.), m01(0.), m10(0.), m11(0.), m20(0.), m02(0.), + mu11(0.), mu20(0.), mu02(0.), ip_connexities_list(), ip_edges_list(), connexityType(CONNEXITY_4), + cog(), u_min(0), u_max(0), v_min(0), v_max(0), graphics(false), thickness(1), maxDotSizePercentage(0.25), + gray_level_out(0), mean_gray_level(0), gray_level_min(128), gray_level_max(255), grayLevelPrecision(0.85), + gamma(1.5), compute_moment(false), nbMaxPoint(0) { - init() ; - cog = ip; } /*! \brief Copy constructor. */ -vpDot::vpDot(const vpDot& d) : vpTracker() +vpDot::vpDot(const vpDot& d) + : vpTracker(d), + m00(0.), m01(0.), m10(0.), m11(0.), m20(0.), m02(0.), + mu11(0.), mu20(0.), mu02(0.), ip_connexities_list(), ip_edges_list(), connexityType(CONNEXITY_4), + cog(), u_min(0), u_max(0), v_min(0), v_max(0), graphics(false), thickness(1), maxDotSizePercentage(0.25), + gray_level_out(0), mean_gray_level(0), gray_level_min(128), gray_level_max(255), grayLevelPrecision(0.85), + gamma(1.5), compute_moment(false), nbMaxPoint(0) { *this = d ; } @@ -125,7 +142,6 @@ vpDot::vpDot(const vpDot& d) : vpTracker() */ vpDot::~vpDot() { - ip_connexities_list.clear() ; } @@ -743,10 +759,10 @@ vpDot::initTracking(const vpImage<unsigned char>& I, const vpImagePoint &ip) \param ip : Location of the starting point from which the dot will be tracked in the image. - \param gray_level_min : Minimum gray level threshold used to segment the dot; + \param level_min : Minimum gray level threshold used to segment the dot; value comprised between 0 and 255. - \param gray_level_max : Maximum gray level threshold used to segment the + \param level_max : Maximum gray level threshold used to segment the dot; value comprised between 0 and 255. \e gray_level_max should be greater than \e gray_level_min. @@ -754,13 +770,13 @@ vpDot::initTracking(const vpImage<unsigned char>& I, const vpImagePoint &ip) */ void vpDot::initTracking(const vpImage<unsigned char>& I, const vpImagePoint &ip, - unsigned int gray_level_min, unsigned int gray_level_max) + unsigned int level_min, unsigned int level_max) { cog = ip ; - this->gray_level_min = gray_level_min; - this->gray_level_max = gray_level_max; + this->gray_level_min = level_min; + this->gray_level_max = level_max; try { track( I ); @@ -832,14 +848,14 @@ vpDot::track(const vpImage<unsigned char> &I) \param I : Image to process. - \param cog [out] : Sub pixel coordinate of the tracked dot. + \param ip [out] : Sub pixel coordinate of the tracked dot center of gravity. */ void -vpDot::track(const vpImage<unsigned char> &I, vpImagePoint &cog) +vpDot::track(const vpImage<unsigned char> &I, vpImagePoint &ip) { track( I ) ; - cog = this->cog; + ip = this->cog; } /*! @@ -847,12 +863,11 @@ vpDot::track(const vpImage<unsigned char> &I, vpImagePoint &cog) \param I : Image. \param color : The color used for the display. - \param thickness : Thickness of the displayed cross located at the dot cog. + \param thick : Thickness of the displayed cross located at the dot cog. */ -void vpDot::display(const vpImage<unsigned char>& I, vpColor color, - unsigned int thickness) +void vpDot::display(const vpImage<unsigned char>& I, vpColor color, unsigned int thick) const { - vpDisplay::displayCross(I, cog, 3*thickness+8, color, thickness); + vpDisplay::displayCross(I, cog, 3*thickness+8, color, thick); std::list<vpImagePoint>::const_iterator it; for (it = ip_edges_list.begin(); it != ip_edges_list.end(); ++it) @@ -865,7 +880,7 @@ void vpDot::display(const vpImage<unsigned char>& I, vpColor color, Set the precision of the gray level of the dot. - \param grayLevelPrecision : It is a double precision float which value is + \param precision : It is a double precision float which value is in ]0,1]: - 1 means full precision, whereas values close to 0 show a very bad accuracy. - Values lower or equal to 0 are brought back to an epsion>0 @@ -878,7 +893,7 @@ void vpDot::display(const vpImage<unsigned char>& I, vpColor color, \sa setWidth(), setHeight(), setGrayLevelMin(), setGrayLevelMax() */ -void vpDot::setGrayLevelPrecision( const double & grayLevelPrecision ) +void vpDot::setGrayLevelPrecision( const double & precision ) { double epsilon = 0.05; if( grayLevelPrecision<epsilon ) @@ -891,7 +906,7 @@ void vpDot::setGrayLevelPrecision( const double & grayLevelPrecision ) } else { - this->grayLevelPrecision = grayLevelPrecision; + this->grayLevelPrecision = precision; } } @@ -949,5 +964,13 @@ void vpDot::display(const vpImage<vpRGBa>& I,const vpImagePoint &cog, } } +/*! + Writes the dot center of gravity coordinates in the frame (i,j) (For more details + about the orientation of the frame see the vpImagePoint documentation) to the stream \e os, + and returns a reference to the stream. +*/ +VISP_EXPORT std::ostream& operator<< (std::ostream& os, vpDot& d) { + return (os << "(" << d.getCog() << ")" ) ; +} ; diff --git a/src/tracking/dots/vpDot.h b/src/tracking/dots/vpDot.h index bd4debb0670fc6c38d2e49496fec1c9e5d2d19e8..96d08644104b1ee2074b0238c0a7b0d48058f49b 100644 --- a/src/tracking/dots/vpDot.h +++ b/src/tracking/dots/vpDot.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpDot.h 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpDot.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -54,10 +54,6 @@ #include <visp/vpRect.h> #include <visp/vpImagePoint.h> -#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS -# include <visp/vpList.h> -#endif - #include <math.h> #include <fstream> #include <list> @@ -200,7 +196,7 @@ public : virtual ~vpDot() ; void display(const vpImage<unsigned char>& I, vpColor color = vpColor::red, - unsigned int thickness=1); + unsigned int thickness=1) const; /*! @@ -209,7 +205,7 @@ public : \sa getWidth(), getHeight() */ - inline vpRect getBBox() { + inline vpRect getBBox() const { vpRect bbox; bbox.setRect(this->u_min, @@ -233,7 +229,7 @@ public : \warning Doesn't return the image points inside the dot anymore. To get those points see getConnexities(). */ - inline std::list<vpImagePoint> getEdges() { + inline std::list<vpImagePoint> getEdges() const { return this->ip_edges_list; }; @@ -245,11 +241,11 @@ public : This list is updated after a call to track(). */ - inline std::list<vpImagePoint> getConnexities() { + inline std::list<vpImagePoint> getConnexities() const { return this->ip_connexities_list; }; - inline double getGamma() {return this->gamma;}; + inline double getGamma() const {return this->gamma;}; /*! Return the precision of the gray level of the dot. It is a double @@ -258,13 +254,13 @@ public : */ double getGrayLevelPrecision() const {return grayLevelPrecision;} - double getMaxDotSize(){ + double getMaxDotSize() const { return this->maxDotSizePercentage; } /*! Return the mean gray level value of the dot. */ - double getMeanGrayLevel() { + double getMeanGrayLevel() const { return (this->mean_gray_level); }; @@ -298,22 +294,15 @@ public : vpDot& operator =(const vpDot& d) ; bool operator ==(const vpDot& d); bool operator !=(const vpDot& d); - /*! - Writes the dot center of gravity coordinates in the frame (i,j) (For more details - about the orientation of the frame see the vpImagePoint documentation) to the stream \e os, - and returns a reference to the stream. - */ - friend VISP_EXPORT std::ostream& operator<< (std::ostream& os, vpDot& d) { - return (os << "(" << d.getCog() << ")" ) ; - } ; + friend VISP_EXPORT std::ostream& operator<< (std::ostream& os, vpDot& d); void print(std::ostream& os) { os << *this << std::endl ; } /*! - Initialize the dot coordinates with \e cog. + Initialize the dot coordinates with \e ip. */ - inline void setCog(const vpImagePoint &cog) { - this->cog = cog; + inline void setCog(const vpImagePoint &ip) { + this->cog = ip; } /*! @@ -335,13 +324,13 @@ public : /*! Set the type of connexity: 4 or 8. */ - void setConnexity(vpConnexityType connexityType) {this->connexityType = connexityType; }; + void setConnexity(vpConnexityType type) {this->connexityType = type; }; void setMaxDotSize(double percentage) ; - void setGrayLevelMin( const unsigned int &gray_level_min ) { - this->gray_level_min = gray_level_min; + void setGrayLevelMin( const unsigned int &level_min ) { + this->gray_level_min = level_min; }; - void setGrayLevelMax( const unsigned int &gray_level_max ) { - this->gray_level_max = gray_level_max; + void setGrayLevelMax( const unsigned int &level_max ) { + this->gray_level_max = level_max; }; void setGrayLevelPrecision( const double & grayLevelPrecision ); @@ -364,7 +353,7 @@ public : \sa setGraphics() */ - void setGraphicsThickness(unsigned int thickness) {this->thickness = thickness;}; + void setGraphicsThickness(unsigned int t) {this->thickness = t;}; void track(const vpImage<unsigned char> & I) ; void track(const vpImage<unsigned char> & I, vpImagePoint &ip) ; @@ -423,45 +412,6 @@ public: static void display(const vpImage<vpRGBa>& I,const vpImagePoint &cog, const std::list<vpImagePoint> &edges_list, vpColor color = vpColor::red, unsigned int thickness=1); - -#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS - /*! - @name Deprecated functions - */ - /*! - - \deprecated This method is deprecated since the naming is not representative regarding to its functionality. \n - Previously it returned all the points inside the dot. To get the equivalent, use getConnexities(). \n \n - If you rather want to get the points on the dot border use getEdges(). - - \param edges_list : The list of all the images points on the dot - border. This list is update after a call to track(). - - */ - vp_deprecated void getEdges(std::list<vpImagePoint> &edges_list) { - edges_list = this->ip_edges_list; - }; - - /*! - - \deprecated This method is deprecated. You should use - getEdges(std::list<vpImagePoint> &) instead.\n \n - Return the list of all the image points on the dot - border. - - \param connexities_list : The list of all the images points on the dot - border. This list is update after a call to track(). - - */ - vp_deprecated void getConnexities(vpList<vpImagePoint> &connexities_list) { - // convert a vpList in a std::list - connexities_list.kill(); - std::list<vpImagePoint>::const_iterator it; - for (it = ip_connexities_list.begin(); it != ip_connexities_list.end(); ++it) { - connexities_list += *it; - } - }; -#endif } ; #endif diff --git a/src/tracking/dots/vpDot2.cpp b/src/tracking/dots/vpDot2.cpp index a2bf66a692b1fb6e011575887941062ffbc36038..ece7b13031c197ad9fb2cc7ac75e72337d1745f6 100644 --- a/src/tracking/dots/vpDot2.cpp +++ b/src/tracking/dots/vpDot2.cpp @@ -3,7 +3,7 @@ * $Id: vpDot2.cpp 2135 2009-04-29 13:51:31Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -89,7 +89,8 @@ void vpDot2::init() ellipsoidShapePrecision = 0.65; maxSizeSearchDistancePrecision = 0.65; setEllipsoidBadPointsPercentage(); - m00 = m11 = m02 = m20 = m10 = m01 = 0 ; + m00 = m11 = m02 = m20 = m10 = m01 = 0.; + mu11 = mu02 = mu20 = 0.; bbox_u_min = bbox_u_max = bbox_v_min = bbox_v_max = 0; @@ -104,9 +105,15 @@ void vpDot2::init() /*! Default constructor. Just do basic default initialization. */ -vpDot2::vpDot2() : vpTracker() +vpDot2::vpDot2() + : m00(0.), m10(0.), m01(0.), m11(0.), m20(0.), m02(0.), + mu11(0.), mu20(0.), mu02(0.), cog(), width(0), height(0), surface(0), + gray_level_min(128), gray_level_max(255), mean_gray_level(0), grayLevelPrecision(0.8), gamma(1.5), + sizePrecision(0.65), ellipsoidShapePrecision(0.65), maxSizeSearchDistancePrecision(0.65), + allowedBadPointsPercentage_(0.), area(), direction_list(), ip_edges_list(), compute_moment(false), + graphics(false), thickness(1), bbox_u_min(0), bbox_u_max(0), bbox_v_min(0), bbox_v_max(0), + firstBorder_u(0), firstBorder_v() { - init(); } /*! @@ -117,17 +124,30 @@ vpDot2::vpDot2() : vpTracker() \param ip : An image point with sub-pixel coordinates. */ -vpDot2::vpDot2(const vpImagePoint &ip) : vpTracker() +vpDot2::vpDot2(const vpImagePoint &ip) + : m00(0.), m10(0.), m01(0.), m11(0.), m20(0.), m02(0.), + mu11(0.), mu20(0.), mu02(0.), cog(), width(0), height(0), surface(0), + gray_level_min(128), gray_level_max(255), mean_gray_level(0), grayLevelPrecision(0.8), gamma(1.5), + sizePrecision(0.65), ellipsoidShapePrecision(0.65), maxSizeSearchDistancePrecision(0.65), + allowedBadPointsPercentage_(0.), area(), direction_list(), ip_edges_list(), compute_moment(false), + graphics(false), thickness(1), bbox_u_min(0), bbox_u_max(0), bbox_v_min(0), bbox_v_max(0), + firstBorder_u(0), firstBorder_v() { - init() ; - cog = ip; } /*! Copy constructor. */ -vpDot2::vpDot2(const vpDot2& twinDot ) : vpTracker() +vpDot2::vpDot2(const vpDot2& twinDot ) + : vpTracker(twinDot), + m00(0.), m10(0.), m01(0.), m11(0.), m20(0.), m02(0.), + mu11(0.), mu20(0.), mu02(0.), cog(), width(0), height(0), surface(0), + gray_level_min(128), gray_level_max(255), mean_gray_level(0), grayLevelPrecision(0.8), gamma(1.5), + sizePrecision(0.65), ellipsoidShapePrecision(0.65), maxSizeSearchDistancePrecision(0.65), + allowedBadPointsPercentage_(0.), area(), direction_list(), ip_edges_list(), compute_moment(false), + graphics(false), thickness(1), bbox_u_min(0), bbox_u_max(0), bbox_v_min(0), bbox_v_max(0), + firstBorder_u(0), firstBorder_v() { *this = twinDot; } @@ -135,7 +155,7 @@ vpDot2::vpDot2(const vpDot2& twinDot ) : vpTracker() /*! = operator. */ -void vpDot2::operator=(const vpDot2& twinDot ) +vpDot2& vpDot2::operator=(const vpDot2& twinDot ) { cog = twinDot.cog; @@ -178,6 +198,8 @@ void vpDot2::operator=(const vpDot2& twinDot ) mu11 = twinDot.mu11; mu20 = twinDot.mu20; mu02 = twinDot.mu02; + + return (*this); } /*! @@ -196,12 +218,11 @@ vpDot2::~vpDot2(){} \param I : Image. \param color : The color used for the display. - \param thickness : Thickness of the displayed cross located at the dot cog. + \param t : Thickness of the displayed cross located at the dot cog. */ -void vpDot2::display(const vpImage<unsigned char>& I, vpColor color, - unsigned int thickness) +void vpDot2::display(const vpImage<unsigned char>& I, vpColor color, unsigned int t) const { - vpDisplay::displayCross(I, cog, 3*thickness+8, color, thickness); + vpDisplay::displayCross(I, cog, 3*t+8, color, t); std::list<vpImagePoint>::const_iterator it; for (it = ip_edges_list.begin(); it != ip_edges_list.end(); ++it) @@ -353,10 +374,10 @@ void vpDot2::initTracking(const vpImage<unsigned char>& I, \param ip : Location of the starting point from which the dot will be tracked in the image. - \param gray_level_min : Minimum gray level threshold used to segment the dot; + \param gray_lvl_min : Minimum gray level threshold used to segment the dot; value comprised between 0 and 255. - \param gray_level_max : Maximum gray level threshold used to segment the + \param gray_lvl_max : Maximum gray level threshold used to segment the dot; value comprised between 0 and 255. \e gray_level_max should be greater than \e gray_level_min. @@ -379,14 +400,14 @@ void vpDot2::initTracking(const vpImage<unsigned char>& I, */ void vpDot2::initTracking(const vpImage<unsigned char>& I, const vpImagePoint &ip, - unsigned int gray_level_min, - unsigned int gray_level_max, + unsigned int gray_lvl_min, + unsigned int gray_lvl_max, unsigned int size) { cog = ip ; - this->gray_level_min = gray_level_min; - this->gray_level_max = gray_level_max; + this->gray_level_min = gray_lvl_min; + this->gray_level_max = gray_lvl_max; setWidth(size); setHeight(size); @@ -598,7 +619,7 @@ void vpDot2::track(const vpImage<unsigned char> &I) \param I : Image to process. - \param cog [out] : Sub pixel coordinate of the tracked dot. + \param ip [out] : Sub pixel coordinate of the tracked dot center of gravity. The behavior of this method is similar to the following code: \code @@ -610,11 +631,11 @@ void vpDot2::track(const vpImage<unsigned char> &I) \sa track() */ void -vpDot2::track(const vpImage<unsigned char> &I, vpImagePoint &cog) +vpDot2::track(const vpImage<unsigned char> &I, vpImagePoint &ip) { track(I); - cog = this->cog; + ip = this->cog; } ///// GET METHODS ///////////////////////////////////////////////////////////// @@ -639,20 +660,6 @@ double vpDot2::getHeight() const return height; } -/*! - Return the area of the dot. - - \warning This function is deprecated since it is mis named. Surface means here area. - You should rather use getArea(). - - The area of the dot is also given by \f$|m00|\f$. - - \sa getArea() -*/ -double vpDot2::getSurface() const -{ - return fabs(surface); -} /*! Return the area of the dot. @@ -724,13 +731,13 @@ double vpDot2::getDistance( const vpDot2& distantDot ) const Set the width of the dot. This is meant to be used to search a dot in an area. - \param width : Width of a dot to search in a region of interest. + \param w : Width of a dot to search in a region of interest. \sa setHeight(), setArea(), setSizePrecision() */ -void vpDot2::setWidth( const double & width ) +void vpDot2::setWidth( const double & w ) { - this->width = width; + this->width = w; } /*! @@ -738,50 +745,35 @@ void vpDot2::setWidth( const double & width ) Set the height of the dot. This is meant to be used to search a dot in an area. - \param height : Height of a dot to search in a region of interest. + \param h : Height of a dot to search in a region of interest. \sa setWidth(), setArea(), setSizePrecision() */ -void vpDot2::setHeight( const double & height ) +void vpDot2::setHeight( const double & h ) { - this->height = height; + this->height = h; } -/*! - - Set the surface of the dot. This is meant to be used to search a dot in a region of interest. - - \warning This function is deprecated since it is mis named. You should rather use setArea() - - \param surface : Here surface means area. Area of a dot to search in a region of interest. - - \sa setWidth(), setHeight(), setArea(), setSizePrecision() - -*/ -void vpDot2::setSurface( const double & surface ) -{ - this->surface = surface; -} /*! Set the area of the dot. This is meant to be used to search a dot in a region of interest. - \param area : Area of a dot to search in a region of interest. + \param a : Area of a dot to search in a region of interest. \sa setWidth(), setHeight(), setSizePrecision() */ -void vpDot2::setArea( const double & area ) +void vpDot2::setArea( const double & a ) { - this->surface = area; + this->surface = a; } /*! Set the precision of the gray level of the dot. - \param grayLevelPrecision : It is a double precision float which value is in ]0,1]: + \param precision : It is a double precision float which value is in ]0,1]: - 1 means full precision, whereas values close to 0 show a very bad accuracy. - Values lower or equal to 0 are brought back to an epsilon>0 - Values higher than 1 are brought back to 1 @@ -793,7 +785,7 @@ void vpDot2::setArea( const double & area ) \sa setGrayLevelMin(), setGrayLevelMax() */ -void vpDot2::setGrayLevelPrecision( const double & grayLevelPrecision ) +void vpDot2::setGrayLevelPrecision( const double & precision ) { double epsilon = 0.05; if( grayLevelPrecision<epsilon ) @@ -806,14 +798,14 @@ void vpDot2::setGrayLevelPrecision( const double & grayLevelPrecision ) } else { - this->grayLevelPrecision = grayLevelPrecision; + this->grayLevelPrecision = precision; } } /*! Set the precision of the size of the dot. Used to test the validity of the dot - \param sizePrecision : It is a double precision float which value is in [0,1]: + \param precision : It is a double precision float which value is in [0,1]: - this is the limit ratio between the tested parameter and the measured one. minSize = sizePrecision*originalSize ; maxSize = originalSize/sizePrecision ; - 1 means full precision, whereas values close to 0 show a very bad accuracy. @@ -823,7 +815,7 @@ void vpDot2::setGrayLevelPrecision( const double & grayLevelPrecision ) \sa setWidth(), setHeight(), setArea() */ -void vpDot2::setSizePrecision( const double & sizePrecision ) +void vpDot2::setSizePrecision( const double & precision ) { if( sizePrecision<0 ) { @@ -835,13 +827,13 @@ void vpDot2::setSizePrecision( const double & sizePrecision ) } else { - this->sizePrecision = sizePrecision; + this->sizePrecision = precision; } } /*! Indicates if the dot should have an ellipsoid shape to be valid. - \param ellipsoidShapePrecision : It is a double precision float which value is in [0,1]: + \param precision : It is a double precision float which value is in [0,1]: - 1 means full precision, whereas values close to 0 show a very bad accuracy. - Values lower or equal to 0 are brought back to 0. @@ -868,7 +860,7 @@ void vpDot2::setSizePrecision( const double & sizePrecision ) \sa getEllipsoidShapePrecision() */ -void vpDot2::setEllipsoidShapePrecision(const double & ellipsoidShapePrecision) { +void vpDot2::setEllipsoidShapePrecision(const double & precision) { if( ellipsoidShapePrecision<0 ) { @@ -880,7 +872,7 @@ void vpDot2::setEllipsoidShapePrecision(const double & ellipsoidShapePrecision) } else { - this->ellipsoidShapePrecision = ellipsoidShapePrecision; + this->ellipsoidShapePrecision = precision; } } @@ -889,7 +881,7 @@ void vpDot2::setEllipsoidShapePrecision(const double & ellipsoidShapePrecision) Set the precision of the search maximum distance to get the starting point on a dot border. A too low value mean a large search area. - \param maxSizeSearchDistancePrecision : It is a double precision float which value is in [0.05,1]: + \param precision : It is a double precision float which value is in [0.05,1]: - this is the limit ratio between the tested parameter and the measured one. distance < getWidth()/(getSizePrecision()+epsilon); - 1 means full precision, whereas values close to 0 show a very bad accuracy. @@ -897,7 +889,7 @@ void vpDot2::setEllipsoidShapePrecision(const double & ellipsoidShapePrecision) - Values higher than 1 are brought back to 1. */ -void vpDot2::setMaxSizeSearchDistancePrecision( const double & maxSizeSearchDistancePrecision ) +void vpDot2::setMaxSizeSearchDistancePrecision( const double & precision ) { double epsilon = 0.05; if( maxSizeSearchDistancePrecision<epsilon ) @@ -910,7 +902,7 @@ void vpDot2::setMaxSizeSearchDistancePrecision( const double & maxSizeSearchDist } else { - this->maxSizeSearchDistancePrecision = maxSizeSearchDistancePrecision; + this->maxSizeSearchDistancePrecision = precision; } } @@ -975,572 +967,6 @@ void ///// CLASS FUNCTIONALITY //////////////////////////////////////////////////// -#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS -/*! - - \deprecated This method is deprecated. You should use - searchDotsInArea(vpImage<unsigned char>&, std::list<vpDot2> &) instead.\n \n - Look for a list of dot matching this dot parameters within the entire - image. - - \warning Allocates memory for the list of dots returned by this method. - Desallocation has to be done by yourself. - - \param I : Image. - - Before calling this method, dot characteristics to found have to be set like: - - \code - vpDot2 d; - - // Set dot characteristics for the auto detection - d.setWidth(15.0); - d.setHeight(12.0); - d.setArea(124); - d.setGrayLevelMin(164); - d.setGrayLevelMax(255); - d.setAccuracy(0.65); - \endcode - - To search dots in the whole image: - \code - vpList<vpDot2> * list_d; - list_d = d.searchDotsInArea(I, 0, 0, I.getWidth(), I.getHeight()) ; - \endcode - - The number of dots found in the area is given by: - \code - std::cout << list_d->nbElement(); - \endcode - - To parse all the dots: - \code - list_d->front(); - while (! list_d->outside()) { - vpDot2 tmp_d; - tmp_d = list_d->value() ; // A matching dot found in the image - list_d->next() ; - } - \endcode - - To free memory associated to the list of dots: - \code - list_d->kill(); - delete list_d; - \endcode - -*/ -vpList<vpDot2>* vpDot2::searchDotsInArea(const vpImage<unsigned char>& I) -{ - vpList<vpDot2>* niceDotsVector = new vpList<vpDot2>(); - - // To avoid a warning due to the usage of the following deprecated function - // we duplicate the code - { - // niceDotsVector = searchDotsInArea( I, 0, 0, I.getWidth(), I.getHeight()); - } - { - // Fit the input area in the image; we keep only the common part between this - // area and the image. - int area_u = 0; - int area_v = 0; - unsigned int area_w = I.getWidth(); - unsigned int area_h = I.getHeight(); - setArea(I, area_u, area_v, area_w, area_h); - - // compute the size of the search grid - unsigned int gridWidth; - unsigned int gridHeight; - getGridSize( gridWidth, gridHeight ); - - if (graphics) { - // Display the area were the dot is search - vpDisplay::displayRectangle(I, area, vpColor::blue, false, thickness); - //vpDisplay::flush(I); - } - - // start the search loop; for all points of the search grid, - // test if the pixel belongs to a valid dot. - // if it is so eventually add it to the vector of valid dots. - // vpList<vpDot2>* niceDotsVector = new vpList<vpDot2>(); - vpList<vpDot2>* badDotsVector = new vpList<vpDot2>(); - - vpDot2* dotToTest = NULL; - vpDot2 tmpDot; - - unsigned int area_u_min = (unsigned int) area.getLeft(); - unsigned int area_u_max = (unsigned int) area.getRight(); - unsigned int area_v_min = (unsigned int) area.getTop(); - unsigned int area_v_max = (unsigned int) area.getBottom(); - - unsigned int u, v; - vpImagePoint cogTmpDot; - - for( v=area_v_min ; v<area_v_max ; v=v+gridHeight ) - { - for( u=area_u_min ; u<area_u_max ; u=u+gridWidth ) - { - // if the pixel we're in doesn't have the right color (outside the - // graylevel interval), no need to check futher, just get to the - // next grid intersection. - if( !hasGoodLevel(I, u, v) ) continue; - - // Test if an other germ is inside the bounding box of a dot previously - // detected - bool good_germ = true; - niceDotsVector->front(); - while( !niceDotsVector->outside() && good_germ == true) { - tmpDot = niceDotsVector->value(); - - cogTmpDot = tmpDot.getCog(); - double u0 = cogTmpDot.get_u(); - double v0 = cogTmpDot.get_v(); - double half_w = tmpDot.getWidth() / 2.; - double half_h = tmpDot.getHeight() / 2.; - - if ( u >= (u0-half_w) && u <= (u0+half_w) && - v >= (v0-half_h) && v <= (v0+half_h) ) { - // Germ is in a previously detected dot - good_germ = false; - } - niceDotsVector->next(); - } - - if (! good_germ) - continue; - - // Compute the right border position for this possible germ - unsigned int border_u; - unsigned int border_v; - if(findFirstBorder(I, u, v, border_u, border_v) == false){ - // germ is not good. - // Jump all the pixels between v,u and v, dotToTest->getFirstBorder_u() - u = border_u; - v = border_v; - continue; - } - - badDotsVector->front(); - #define vpBAD_DOT_VALUE (badDotsVector->value()) - vpImagePoint cogBadDot; - - std::list<vpImagePoint>::const_iterator it_edges; - while( !badDotsVector->outside() && good_germ == true) - { - if( (double)u >= vpBAD_DOT_VALUE.bbox_u_min - && (double)u <= vpBAD_DOT_VALUE.bbox_u_max && - (double)v >= vpBAD_DOT_VALUE.bbox_v_min - && (double)v <= vpBAD_DOT_VALUE.bbox_v_max) - { - - it_edges = ip_edges_list.begin(); - while (it_edges != ip_edges_list.end() && good_germ == true) - { - // Test if the germ belong to a previously detected dot: - // - from the germ go right to the border and compare this - // position to the list of pixels of previously detected dots - cogBadDot = *it_edges; - //if( border_u == cogBadDot.get_u() && v == cogBadDot.get_v()) { - if( (std::fabs(border_u - cogBadDot.get_u()) <= vpMath::maximum(std::fabs((double)border_u), std::fabs(cogBadDot.get_u()))*std::numeric_limits<double>::epsilon() ) - && - (std::fabs(v - cogBadDot.get_v()) <= vpMath::maximum(std::fabs((double)v), std::fabs(cogBadDot.get_v()))*std::numeric_limits<double>::epsilon() )) - { - good_germ = false; - } - ++ it_edges; - } - } - badDotsVector->next(); - } - #undef vpBAD_DOT_VALUE - - if (! good_germ) { - // Jump all the pixels between v,u and v, dotToTest->getFirstBorder_u() - u = border_u; - v = border_v; - continue; - } - - vpTRACE(4, "Try germ (%d, %d)", u, v); - - vpImagePoint germ; - germ.set_u( u ); - germ.set_v( v ); - - // otherwise estimate the width, height and surface of the dot we - // created, and test it. - if( dotToTest != NULL ) delete dotToTest; - dotToTest = getInstance(); - dotToTest->setCog( germ ); - dotToTest->setGrayLevelMin ( getGrayLevelMin() ); - dotToTest->setGrayLevelMax ( getGrayLevelMax() ); - dotToTest->setGrayLevelPrecision( getGrayLevelPrecision() ); - dotToTest->setSizePrecision( getSizePrecision() ); - dotToTest->setGraphics( graphics ); - dotToTest->setGraphicsThickness( thickness ); - dotToTest->setComputeMoments( true ); - dotToTest->setArea( area ); - dotToTest->setEllipsoidShapePrecision( ellipsoidShapePrecision ); - - // first compute the parameters of the dot. - // if for some reasons this caused an error tracking - // (dot partially out of the image...), check the next intersection - if( dotToTest->computeParameters( I ) == false ) { - // Jump all the pixels between v,u and v, dotToTest->getFirstBorder_u() - u = border_u; - v = border_v; - continue; - } - // if the dot to test is valid, - if( dotToTest->isValid( I, *this ) ) - { - vpImagePoint cogDotToTest = dotToTest->getCog(); - // Compute the distance to the center. The center used here is not the - // area center available by area.getCenter(area_center_u, - // area_center_v) but the center of the input area which may be - // partially outside the image. - - double area_center_u = area_u + area_w/2.0 - 0.5; - double area_center_v = area_v + area_h/2.0 - 0.5; - - double thisDiff_u = cogDotToTest.get_u() - area_center_u; - double thisDiff_v = cogDotToTest.get_v() - area_center_v; - double thisDist = sqrt( thisDiff_u*thisDiff_u + thisDiff_v*thisDiff_v); - - bool stopLoop = false; - niceDotsVector->front(); - - while( !niceDotsVector->outside() && stopLoop == false ) - { - vpDot2 tmpDot = niceDotsVector->value(); - - //double epsilon = 0.001; // detecte +sieurs points - double epsilon = 3.0; - // if the center of the dot is the same than the current - // don't add it, test the next point of the grid - cogTmpDot = tmpDot.getCog(); - - if( fabs( cogTmpDot.get_u() - cogDotToTest.get_u() ) < epsilon && - fabs( cogTmpDot.get_v() - cogDotToTest.get_v() ) < epsilon ) - { - stopLoop = true; - // Jump all the pixels between v,u and v, tmpDot->getFirstBorder_u() - u = border_u; - v = border_v; - continue; - } - - double otherDiff_u = cogTmpDot.get_u() - area_center_u; - double otherDiff_v = cogTmpDot.get_v() - area_center_v; - double otherDist = sqrt( otherDiff_u*otherDiff_u + - otherDiff_v*otherDiff_v ); - - - // if the distance of the curent vector element to the center - // is greater than the distance of this dot to the center, - // then add this dot before the current vector element. - if( otherDist > thisDist ) - { - niceDotsVector->addLeft( *dotToTest ); - niceDotsVector->next(); - stopLoop = true; - // Jump all the pixels between v,u and v, tmpDot->getFirstBorder_u() - u = border_u; - v = border_v; - continue; - } - niceDotsVector->next(); - } - vpTRACE(4, "End while (%d, %d)", u, v); - - // if we reached the end of the vector without finding the dot - // or inserting it, insert it now. - if( niceDotsVector->outside() && stopLoop == false ) - { - niceDotsVector->end(); - niceDotsVector->addRight( *dotToTest ); - } - } - else { - // Store bad dots - badDotsVector->front(); - badDotsVector->addRight( *dotToTest ); - } - } - } - if( dotToTest != NULL ) delete dotToTest; - - delete badDotsVector; - - //return niceDotsVector; - } - - - return niceDotsVector; - -} - -/*! - - \deprecated This method is deprecated. You should use - searchDotsInArea(vpImage<unsigned char>&, int, int, unsigned int, unsigned int, std::list<vpDot2> &) instead.\n \n - Look for a list of dot matching this dot parameters within a rectangle - search area in the image. The rectangle upper-left coordinates are given by - (\e area_u, \e area_v). The size of the rectangle is given by \e area_w and - \e area_h. - - \param I : Image to process. - \param area_u : Coordinate (column) of the upper-left area corner. - \param area_v : Coordinate (row) of the upper-left area corner. - - \param area_w : Width or the area in which a dot is searched. - \param area_h : Height or the area in which a dot is searched. - - \warning Allocates memory for the list of vpDot2 returned by this method. - Desallocation has to be done by yourself, see searchDotsInArea() - - \sa searchDotsInArea(vpImage<unsigned char>& I) -*/ -vpList<vpDot2>* -vpDot2::searchDotsInArea(const vpImage<unsigned char>& I, - int area_u, - int area_v, - unsigned int area_w, - unsigned int area_h) - -{ - // Fit the input area in the image; we keep only the common part between this - // area and the image. - setArea(I, area_u, area_v, area_w, area_h); - - // compute the size of the search grid - unsigned int gridWidth; - unsigned int gridHeight; - getGridSize( gridWidth, gridHeight ); - - if (graphics) { - // Display the area were the dot is search - vpDisplay::displayRectangle(I, area, vpColor::blue, false, thickness); - //vpDisplay::flush(I); - } - - // start the search loop; for all points of the search grid, - // test if the pixel belongs to a valid dot. - // if it is so eventually add it to the vector of valid dots. - vpList<vpDot2>* niceDotsVector = new vpList<vpDot2>(); - vpList<vpDot2>* badDotsVector = new vpList<vpDot2>(); - - vpDot2* dotToTest = NULL; - vpDot2 tmpDot; - - unsigned int area_u_min = (unsigned int) area.getLeft(); - unsigned int area_u_max = (unsigned int) area.getRight(); - unsigned int area_v_min = (unsigned int) area.getTop(); - unsigned int area_v_max = (unsigned int) area.getBottom(); - - unsigned int u, v; - vpImagePoint cogTmpDot; - - for( v=area_v_min ; v<area_v_max ; v=v+gridHeight ) - { - for( u=area_u_min ; u<area_u_max ; u=u+gridWidth ) - { - // if the pixel we're in doesn't have the right color (outside the - // graylevel interval), no need to check futher, just get to the - // next grid intersection. - if( !hasGoodLevel(I, u, v) ) continue; - - // Test if an other germ is inside the bounding box of a dot previoulsy - // detected - bool good_germ = true; - niceDotsVector->front(); - while( !niceDotsVector->outside() && good_germ == true) { - tmpDot = niceDotsVector->value(); - - cogTmpDot = tmpDot.getCog(); - double u0 = cogTmpDot.get_u(); - double v0 = cogTmpDot.get_v(); - double half_w = tmpDot.getWidth() / 2.; - double half_h = tmpDot.getHeight() / 2.; - - if ( u >= (u0-half_w) && u <= (u0+half_w) && - v >= (v0-half_h) && v <= (v0+half_h) ) { - // Germ is in a previously detected dot - good_germ = false; - } - niceDotsVector->next(); - } - - if (! good_germ) - continue; - - // Compute the right border position for this possible germ - unsigned int border_u; - unsigned int border_v; - if(findFirstBorder(I, u, v, border_u, border_v) == false){ - // germ is not good. - // Jump all the pixels between v,u and v, dotToTest->getFirstBorder_u() - u = border_u; - v = border_v; - continue; - } - - badDotsVector->front(); -#define vpBAD_DOT_VALUE (badDotsVector->value()) - vpImagePoint cogBadDot; - - std::list<vpImagePoint>::const_iterator it_edges; - while( !badDotsVector->outside() && good_germ == true) - { - if( (double)u >= vpBAD_DOT_VALUE.bbox_u_min - && (double)u <= vpBAD_DOT_VALUE.bbox_u_max && - (double)v >= vpBAD_DOT_VALUE.bbox_v_min - && (double)v <= vpBAD_DOT_VALUE.bbox_v_max) - { - - it_edges = ip_edges_list.begin(); - while (it_edges != ip_edges_list.end() && good_germ == true) - { - // Test if the germ belong to a previously detected dot: - // - from the germ go right to the border and compare this - // position to the list of pixels of previously detected dots - cogBadDot = *it_edges; - //if( border_u == cogBadDot.get_u() && v == cogBadDot.get_v()) { - if( (std::fabs(border_u - cogBadDot.get_u()) <= vpMath::maximum(std::fabs((double)border_u), std::fabs(cogBadDot.get_u()))*std::numeric_limits<double>::epsilon() ) - && - (std::fabs(v - cogBadDot.get_v()) <= vpMath::maximum(std::fabs((double)v), std::fabs(cogBadDot.get_v()))*std::numeric_limits<double>::epsilon() )) - { - good_germ = false; - } - ++ it_edges; - } - } - badDotsVector->next(); - } -#undef vpBAD_DOT_VALUE - - if (! good_germ) { - // Jump all the pixels between v,u and v, dotToTest->getFirstBorder_u() - u = border_u; - v = border_v; - continue; - } - - vpTRACE(4, "Try germ (%d, %d)", u, v); - - vpImagePoint germ; - germ.set_u( u ); - germ.set_v( v ); - - // otherwise estimate the width, height and surface of the dot we - // created, and test it. - if( dotToTest != NULL ) delete dotToTest; - dotToTest = getInstance(); - dotToTest->setCog( germ ); - dotToTest->setGrayLevelMin ( getGrayLevelMin() ); - dotToTest->setGrayLevelMax ( getGrayLevelMax() ); - dotToTest->setGrayLevelPrecision( getGrayLevelPrecision() ); - dotToTest->setSizePrecision( getSizePrecision() ); - dotToTest->setGraphics( graphics ); - dotToTest->setGraphicsThickness( thickness ); - dotToTest->setComputeMoments( true ); - dotToTest->setArea( area ); - dotToTest->setEllipsoidShapePrecision( ellipsoidShapePrecision ); - - // first compute the parameters of the dot. - // if for some reasons this caused an error tracking - // (dot partially out of the image...), check the next intersection - if( dotToTest->computeParameters( I ) == false ) { - // Jump all the pixels between v,u and v, dotToTest->getFirstBorder_u() - u = border_u; - v = border_v; - continue; - } - // if the dot to test is valid, - if( dotToTest->isValid( I, *this ) ) - { - vpImagePoint cogDotToTest = dotToTest->getCog(); - // Compute the distance to the center. The center used here is not the - // area center available by area.getCenter(area_center_u, - // area_center_v) but the center of the input area which may be - // partially outside the image. - - double area_center_u = area_u + area_w/2.0 - 0.5; - double area_center_v = area_v + area_h/2.0 - 0.5; - - double thisDiff_u = cogDotToTest.get_u() - area_center_u; - double thisDiff_v = cogDotToTest.get_v() - area_center_v; - double thisDist = sqrt( thisDiff_u*thisDiff_u + thisDiff_v*thisDiff_v); - - bool stopLoop = false; - niceDotsVector->front(); - - while( !niceDotsVector->outside() && stopLoop == false ) - { - vpDot2 tmpDot = niceDotsVector->value(); - - //double epsilon = 0.001; // detecte +sieurs points - double epsilon = 3.0; - // if the center of the dot is the same than the current - // don't add it, test the next point of the grid - cogTmpDot = tmpDot.getCog(); - - if( fabs( cogTmpDot.get_u() - cogDotToTest.get_u() ) < epsilon && - fabs( cogTmpDot.get_v() - cogDotToTest.get_v() ) < epsilon ) - { - stopLoop = true; - // Jump all the pixels between v,u and v, tmpDot->getFirstBorder_u() - u = border_u; - v = border_v; - continue; - } - - double otherDiff_u = cogTmpDot.get_u() - area_center_u; - double otherDiff_v = cogTmpDot.get_v() - area_center_v; - double otherDist = sqrt( otherDiff_u*otherDiff_u + - otherDiff_v*otherDiff_v ); - - - // if the distance of the curent vector element to the center - // is greater than the distance of this dot to the center, - // then add this dot before the current vector element. - if( otherDist > thisDist ) - { - niceDotsVector->addLeft( *dotToTest ); - niceDotsVector->next(); - stopLoop = true; - // Jump all the pixels between v,u and v, tmpDot->getFirstBorder_u() - u = border_u; - v = border_v; - continue; - } - niceDotsVector->next(); - } - vpTRACE(4, "End while (%d, %d)", u, v); - - // if we reached the end of the vector without finding the dot - // or inserting it, insert it now. - if( niceDotsVector->outside() && stopLoop == false ) - { - niceDotsVector->end(); - niceDotsVector->addRight( *dotToTest ); - } - } - else { - // Store bad dots - badDotsVector->front(); - badDotsVector->addRight( *dotToTest ); - } - } - } - if( dotToTest != NULL ) delete dotToTest; - - delete badDotsVector; - - return niceDotsVector; -} -#endif // VISP_BUILD_DEPRECATED_FUNCTIONS - /*! Look for a list of dot matching this dot parameters within the entire @@ -1795,7 +1221,7 @@ void vpDot2::searchDotsInArea(const vpImage<unsigned char>& I, while( itnice != niceDots.end() && stopLoop == false ) { - vpDot2 tmpDot = *itnice; + tmpDot = *itnice; //double epsilon = 0.001; // detecte +sieurs points double epsilon = 3.0; @@ -1874,8 +1300,8 @@ void vpDot2::searchDotsInArea(const vpImage<unsigned char>& I, */ bool vpDot2::isValid(const vpImage<unsigned char>& I, const vpDot2& wantedDot ) { - double sizePrecision = wantedDot.getSizePrecision(); - double ellipsoidShapePrecision = wantedDot.getEllipsoidShapePrecision(); + double size_precision = wantedDot.getSizePrecision(); + double ellipsoidShape_precision = wantedDot.getEllipsoidShapePrecision(); double epsilon = 0.001; // @@ -1890,20 +1316,20 @@ bool vpDot2::isValid(const vpImage<unsigned char>& I, const vpDot2& wantedDot ) (std::fabs(wantedDot.getHeight()) > std::numeric_limits<double>::epsilon()) && (std::fabs(wantedDot.getArea()) > std::numeric_limits<double>::epsilon()) ) - // if (sizePrecision!=0){ - if (std::fabs(sizePrecision) > std::numeric_limits<double>::epsilon()){ + // if (size_precision!=0){ + if (std::fabs(size_precision) > std::numeric_limits<double>::epsilon()){ #ifdef DEBUG std::cout << "test size precision......................\n"; std::cout << "wanted dot: " << "w=" << wantedDot.getWidth() << " h=" << wantedDot.getHeight() << " s=" << wantedDot.getArea() - << " precision=" << sizePrecision + << " precision=" << size_precision << " epsilon=" << epsilon << std::endl; std::cout << "dot found: " << "w=" << getWidth() << " h=" << getHeight() << " s=" << getArea() << std::endl; #endif - if( ( wantedDot.getWidth()*sizePrecision-epsilon < getWidth() ) == false ) + if( ( wantedDot.getWidth()*size_precision-epsilon < getWidth() ) == false ) { vpDEBUG_TRACE(3, "Bad width > for dot (%g, %g)", cog.get_u(), cog.get_v()); @@ -1913,62 +1339,62 @@ bool vpDot2::isValid(const vpImage<unsigned char>& I, const vpDot2& wantedDot ) return false; } - if( ( getWidth() < wantedDot.getWidth()/(sizePrecision+epsilon ) )== false ) + if( ( getWidth() < wantedDot.getWidth()/(size_precision+epsilon ) )== false ) { vpDEBUG_TRACE(3, "Bad width > for dot (%g, %g)", cog.get_u(), cog.get_v()); #ifdef DEBUG printf("Bad width %g > %g for dot (%g, %g)\n", - getWidth(), wantedDot.getWidth()/(sizePrecision+epsilon), + getWidth(), wantedDot.getWidth()/(size_precision+epsilon), cog.get_u(), cog.get_v()); #endif return false; } - if( ( wantedDot.getHeight()*sizePrecision-epsilon < getHeight() ) == false ) + if( ( wantedDot.getHeight()*size_precision-epsilon < getHeight() ) == false ) { vpDEBUG_TRACE(3, "Bad height > for dot (%g, %g)", cog.get_u(), cog.get_v()); #ifdef DEBUG printf("Bad height %g > %g for dot (%g, %g)\n", - wantedDot.getHeight()*sizePrecision-epsilon, getHeight(), + wantedDot.getHeight()*size_precision-epsilon, getHeight(), cog.get_u(), cog.get_v()); #endif return false; } - if( ( getHeight() < wantedDot.getHeight()/(sizePrecision+epsilon )) == false ) + if( ( getHeight() < wantedDot.getHeight()/(size_precision+epsilon )) == false ) { vpDEBUG_TRACE(3, "Bad height > for dot (%g, %g)", cog.get_u(), cog.get_v()); #ifdef DEBUG printf("Bad height %g > %g for dot (%g, %g)\n", - getHeight(), wantedDot.getHeight()/(sizePrecision+epsilon), + getHeight(), wantedDot.getHeight()/(size_precision+epsilon), cog.get_u(), cog.get_v()); #endif return false; } - if( ( wantedDot.getArea()*(sizePrecision*sizePrecision)-epsilon < getArea() ) == false ) + if( ( wantedDot.getArea()*(size_precision*size_precision)-epsilon < getArea() ) == false ) { vpDEBUG_TRACE(3, "Bad surface > for dot (%g, %g)", cog.get_u(), cog.get_v()); #ifdef DEBUG printf("Bad surface %g > %g for dot (%g, %g)\n", - wantedDot.getArea()*(sizePrecision*sizePrecision)-epsilon, + wantedDot.getArea()*(size_precision*size_precision)-epsilon, getArea(), cog.get_u(), cog.get_v()); #endif return false; } - if( ( getArea() < wantedDot.getArea()/(sizePrecision*sizePrecision+epsilon )) == false ) + if( ( getArea() < wantedDot.getArea()/(size_precision*size_precision+epsilon )) == false ) { vpDEBUG_TRACE(3, "Bad surface > for dot (%g, %g)", cog.get_u(), cog.get_v()); #ifdef DEBUG printf("Bad surface %g < %g for dot (%g, %g)\n", - getArea(), wantedDot.getArea()/(sizePrecision*sizePrecision+epsilon), + getArea(), wantedDot.getArea()/(size_precision*size_precision+epsilon), cog.get_u(), cog.get_v()); #endif return false; @@ -1984,11 +1410,11 @@ bool vpDot2::isValid(const vpImage<unsigned char>& I, const vpDot2& wantedDot ) int nb_max_bad_points = (int)(nb_point_to_test*allowedBadPointsPercentage_); double step_angle = 2*M_PI / nb_point_to_test; - // if (ellipsoidShapePrecision != 0 && compute_moment) { - if (std::fabs(ellipsoidShapePrecision) > std::numeric_limits<double>::epsilon() && compute_moment) { + // if (ellipsoidShape_precision != 0 && compute_moment) { + if (std::fabs(ellipsoidShape_precision) > std::numeric_limits<double>::epsilon() && compute_moment) { // std::cout << "test shape precision......................\n"; // See F. Chaumette. Image moments: a general and useful set of features - // for visual servoing. IEEE Trans. on Robotics, 20(4):713-723, Ao�t 2004. + // for visual servoing. IEEE Trans. on Robotics, 20(4):713-723, August 2004. // mu11 = m11 - m00 * xg * yg = m11 - m00 * m10/m00 * m01/m00 // = m11 - m10 * m01 / m00 @@ -2015,7 +1441,7 @@ bool vpDot2::isValid(const vpImage<unsigned char>& I, const vpDot2& wantedDot ) a1 -= 1.0; a2 -= 1.0; - double innerCoef = ellipsoidShapePrecision ; + double innerCoef = ellipsoidShape_precision ; unsigned int u, v; double cog_u = this->cog.get_u(); double cog_v = this->cog.get_v(); @@ -2060,7 +1486,7 @@ bool vpDot2::isValid(const vpImage<unsigned char>& I, const vpDot2& wantedDot ) a1 += 2.0; a2 += 2.0; - double outCoef = 2-ellipsoidShapePrecision; //1.6; + double outCoef = 2-ellipsoidShape_precision; //1.6; nb_bad_points = 0; for( double theta=0. ; theta<2*M_PI ; theta+= step_angle ) { u = (unsigned int) (cog_u + outCoef*(a1*cos(alpha)*cos(theta)-a2*sin(alpha)*sin(theta))); @@ -2188,12 +1614,8 @@ vpDot2* vpDot2::getInstance() return new vpDot2(); } - -#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS /*! - \deprecated This method is deprecated. You should use - getFreemanChain(std::list<unsigned int> &) instead.\n \n Returns the list of Freeman chain code used to turn around the dot counterclockwise. @@ -2207,32 +1629,7 @@ vpDot2* vpDot2::getInstance() - 6 : down - 7 : down right */ -void vpDot2::getFreemanChain(vpList<unsigned int> &freeman_chain) -{ - std::list<unsigned int>::const_iterator it; - freeman_chain.kill(); - for (it = direction_list.begin(); it != direction_list.end(); ++it) { - freeman_chain += *it; - } -} -#endif - -/*! - - Returns the list of Freeman chain code used to turn around the dot - counterclockwise. - - \return List of Freeman chain list [0, ..., 7] - - 0 : right - - 1 : top right - - 2 : top - - 3 : top left - - 4 : left - - 5 : down left - - 6 : down - - 7 : down right -*/ -void vpDot2::getFreemanChain(std::list<unsigned int> &freeman_chain) +void vpDot2::getFreemanChain(std::list<unsigned int> &freeman_chain) const { freeman_chain = direction_list; } @@ -2583,59 +1980,59 @@ bool element = (element + 2) % 8; // turn right } else { - unsigned int _u = u; - unsigned int _v = v; - updateFreemanPosition( _u, _v, (element + 1) %8 ); + unsigned int _u1 = u; + unsigned int _v1 = v; + updateFreemanPosition( _u1, _v1, (element + 1) %8 ); - if ( hasGoodLevel( I, _u, _v )) { + if ( hasGoodLevel( I, _u1, _v1 )) { element = (element + 1) % 8; // turn diag right } else { - unsigned int _u = u; - unsigned int _v = v; - updateFreemanPosition( _u, _v, element ); // same direction + unsigned int _u2 = u; + unsigned int _v2 = v; + updateFreemanPosition( _u2, _v2, element ); // same direction - if ( hasGoodLevel( I, _u, _v )) { + if ( hasGoodLevel( I, _u2, _v2 )) { //element = element; // keep same dir } else { - unsigned int _u = u; - unsigned int _v = v; - updateFreemanPosition( _u, _v, (element + 7) %8 ); // diag left + unsigned int _u3 = u; + unsigned int _v3 = v; + updateFreemanPosition( _u3, _v3, (element + 7) %8 ); // diag left - if ( hasGoodLevel( I, _u, _v )) { + if ( hasGoodLevel( I, _u3, _v3 )) { element = (element + 7) %8; // turn diag left } else { - unsigned int _u = u; - unsigned int _v = v; - updateFreemanPosition( _u, _v, (element + 6) %8 ); // left + unsigned int _u4 = u; + unsigned int _v4 = v; + updateFreemanPosition( _u4, _v4, (element + 6) %8 ); // left - if ( hasGoodLevel( I, _u, _v )) { + if ( hasGoodLevel( I, _u4, _v4 )) { element = (element + 6) %8 ; // turn left } else { - unsigned int _u = u; - unsigned int _v = v; - updateFreemanPosition( _u, _v, (element + 5) %8 ); // left + unsigned int _u5 = u; + unsigned int _v5 = v; + updateFreemanPosition( _u5, _v5, (element + 5) %8 ); // left - if ( hasGoodLevel( I, _u, _v )) { + if ( hasGoodLevel( I, _u5, _v5 )) { element = (element + 5) %8 ; // turn diag down } else { - unsigned int _u = u; - unsigned int _v = v; - updateFreemanPosition( _u, _v, (element + 4) %8 ); // left + unsigned int _u6 = u; + unsigned int _v6 = v; + updateFreemanPosition( _u6, _v6, (element + 4) %8 ); // left - if ( hasGoodLevel( I, _u, _v )) { + if ( hasGoodLevel( I, _u6, _v6 )) { element = (element + 4) %8 ; // turn down } else { - unsigned int _u = u; - unsigned int _v = v; - updateFreemanPosition( _u, _v, (element + 3) %8 ); // diag + unsigned int _u7 = u; + unsigned int _v7 = v; + updateFreemanPosition( _u7, _v7, (element + 3) %8 ); // diag - if ( hasGoodLevel( I, _u, _v )) { + if ( hasGoodLevel( I, _u7, _v7 )) { element = (element + 3) %8 ; // turn diag right down } else { @@ -2879,16 +2276,15 @@ bool vpDot2::isInImage(const vpImage<unsigned char> &I) const \return true if the image point \e ip is in the image and false otherwise. */ -bool vpDot2::isInImage(const vpImage<unsigned char> &I, - const vpImagePoint &ip) const +bool vpDot2::isInImage(const vpImage<unsigned char> &I, const vpImagePoint &ip) const { - unsigned int height = I.getHeight(); - unsigned int width = I.getWidth(); + unsigned int h = I.getHeight(); + unsigned int w = I.getWidth(); double u = ip.get_u(); double v = ip.get_v(); - if( u < 0 || u >= width ) return false; - if( v < 0 || v >= height ) return false; + if( u < 0 || u >= w ) return false; + if( v < 0 || v >= h ) return false; return true; } @@ -3224,3 +2620,45 @@ void vpDot2::display(const vpImage<vpRGBa>& I,const vpImagePoint &cog, vpDisplay::displayPoint(I, *it, color); } } + +/*! + Writes the dot center of gravity coordinates in the frame (i,j) (For more details + about the orientation of the frame see the vpImagePoint documentation) to the stream \e os, + and returns a reference to the stream. +*/ +VISP_EXPORT std::ostream& operator<< (std::ostream& os, vpDot2& d) { + return (os << "(" << d.getCog() << ")" ) ; +} ; + +#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS +/*! + \deprecated Return the area of the dot. + + This function is deprecated since it is mis named. Surface means here area. + You should rather use getArea(). + + The area of the dot is also given by \f$|m00|\f$. + + \sa getArea() +*/ +double vpDot2::getSurface() const +{ + return fabs(surface); +} + +/*! + + \deprecated Set the surface of the dot. This is meant to be used to search a dot in a region of interest. + + This function is deprecated since it is mis named. You should rather use setArea() + + \param s : Here surface means area. Area of a dot to search in a region of interest. + + \sa setWidth(), setHeight(), setArea(), setSizePrecision() + +*/ +void vpDot2::setSurface( const double & s ) +{ + this->surface = s; +} +#endif diff --git a/src/tracking/dots/vpDot2.h b/src/tracking/dots/vpDot2.h index 6e68be89f45ea9c341c5c6d0977ef0dc5fcc42e8..4989a78ad76112987d36efc698b74108f83ca240 100644 --- a/src/tracking/dots/vpDot2.h +++ b/src/tracking/dots/vpDot2.h @@ -3,7 +3,7 @@ * $Id: vpDot2.h 2135 2009-04-29 13:51:31Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -53,10 +53,6 @@ #include <visp/vpColor.h> #include <visp/vpImagePoint.h> -#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS -# include <visp/vpList.h> -#endif - #include <vector> #include <list> @@ -139,7 +135,7 @@ public: static vpMatrix defineDots(vpDot2 dot[], const unsigned int &n, const std::string &dotFile, vpImage<unsigned char> &I, vpColor col = vpColor::blue, bool trackDot = true); void display(const vpImage<unsigned char>& I, vpColor color = vpColor::red, - unsigned int thickness=1); + unsigned int thickness=1) const; double getArea() const; /*! @@ -149,7 +145,7 @@ public: \sa getWidth(), getHeight() */ - inline vpRect getBBox() { + inline vpRect getBBox() const { vpRect bbox; bbox.setRect(this->bbox_u_min, @@ -178,24 +174,36 @@ public: border. This list is update after a call to track(). */ - void getEdges(std::list<vpImagePoint> &edges_list) { + void getEdges(std::list<vpImagePoint> &edges_list) const { edges_list = this->ip_edges_list; }; + /*! + + Return the list of all the image points on the dot + border. + + \return The list of all the images points on the dot + border. This list is update after a call to track(). + + */ + std::list<vpImagePoint> getEdges() const { + return(this->ip_edges_list); + }; /*! Get the percentage of sampled points that are considered non conform in terms of the gray level on the inner and the ouside ellipses. \sa setEllipsoidBadPointsPercentage() */ - double getEllipsoidBadPointsPercentage() + double getEllipsoidBadPointsPercentage() const { return allowedBadPointsPercentage_; } double getEllipsoidShapePrecision() const; - void getFreemanChain(std::list<unsigned int> &freeman_chain) ; + void getFreemanChain(std::list<unsigned int> &freeman_chain) const; - inline double getGamma() {return this->gamma;}; + inline double getGamma() const {return this->gamma;}; /*! Return the color level of pixels inside the dot. @@ -219,29 +227,21 @@ public: /*! \return The mean gray level value of the dot. */ - double getMeanGrayLevel() { + double getMeanGrayLevel() const { return (this->mean_gray_level); }; double getSizePrecision() const; - double getSurface() const; double getWidth() const; void initTracking(const vpImage<unsigned char>& I, unsigned int size = 0); void initTracking(const vpImage<unsigned char>& I, const vpImagePoint &ip, - unsigned int size = 0); + unsigned int size = 0); void initTracking(const vpImage<unsigned char>& I, const vpImagePoint &ip, - unsigned int gray_level_min, unsigned int gray_level_max, - unsigned int size = 0 ); + unsigned int gray_lvl_min, unsigned int gray_lvl_max, + unsigned int size = 0 ); - void operator=(const vpDot2& twinDot ); - /*! - Writes the dot center of gravity coordinates in the frame (i,j) (For more details - about the orientation of the frame see the vpImagePoint documentation) to the stream \e os, - and returns a reference to the stream. - */ - friend VISP_EXPORT std::ostream& operator<< (std::ostream& os, vpDot2& d) { - return (os << "(" << d.getCog() << ")" ) ; - } ; + vpDot2& operator=(const vpDot2& twinDot ); + friend VISP_EXPORT std::ostream& operator<< (std::ostream& os, vpDot2& d); void print(std::ostream& os) { os << *this << std::endl ; } void searchDotsInArea(const vpImage<unsigned char>& I, @@ -252,10 +252,10 @@ public: void setArea( const double & area ); /*! - Initialize the dot coordinates with \e cog. + Initialize the dot coordinates with \e ip. */ - inline void setCog(const vpImagePoint &cog) { - this->cog = cog; + inline void setCog(const vpImagePoint &ip) { + this->cog = ip; } /*! @@ -315,7 +315,7 @@ public: \sa setGraphics() */ - void setGraphicsThickness(unsigned int thickness) {this->thickness = thickness;}; + void setGraphicsThickness(unsigned int t) {this->thickness = t;}; /*! Set the color level of the dot to search a dot in a region of interest. This level will be @@ -354,7 +354,6 @@ public: void setHeight( const double & height ); void setMaxSizeSearchDistancePrecision(const double & maxSizeSearchDistancePrecision); void setSizePrecision( const double & sizePrecision ); - void setSurface( const double & surface ); void setWidth( const double & width ); void track(const vpImage<unsigned char> &I); @@ -363,6 +362,14 @@ public: static void trackAndDisplay(vpDot2 dot[], const unsigned int &n, vpImage<unsigned char> &I, std::vector<vpImagePoint> &cogs, vpImagePoint* cogStar = NULL); +#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS + /*! + @name Deprecated functions + */ + vp_deprecated double getSurface() const; + vp_deprecated void setSurface( const double & surface ); +#endif + public: double m00; /*!< Considering the general distribution moments for \f$ N \f$ points defined by the relation \f$ m_{ij} = \sum_{h=0}^{N} @@ -429,37 +436,6 @@ public: \sa setComputeMoments() */ -#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS - /*! - @name Deprecated functions - */ - /*! - - \deprecated This method is deprecated. You should use - getEdges(std::list<vpImagePoint> &) instead.\n \n - Return the list of all the image points on the dot - border. - - \param edges_list : The list of all the images points on the dot - border. This list is update after a call to track(). - - */ - vp_deprecated void getEdges(vpList<vpImagePoint> &edges_list) { - // convert a vpList in a std::list - edges_list.kill(); - std::list<vpImagePoint>::const_iterator it; - for (it = ip_edges_list.begin(); it != ip_edges_list.end(); ++it) { - edges_list += *it; - } - }; - vp_deprecated void getFreemanChain(vpList<unsigned int> &freeman_chain) ; - vp_deprecated vpList<vpDot2>* searchDotsInArea(const vpImage<unsigned char>& I, - int area_u, int area_v, - unsigned int area_w, unsigned int area_h ); - - /* vp_deprecated */ vpList<vpDot2>* searchDotsInArea(const vpImage<unsigned char>& I ); -#endif - private: virtual bool isValid(const vpImage<unsigned char>& I, const vpDot2& wantedDot); diff --git a/src/tracking/feature-builder/vpFeatureBuilder.h b/src/tracking/feature-builder/vpFeatureBuilder.h index 036448391bc31474bfa399e3d94744b45e4fcf27..004bc7b0327bf66e4680582873f3dc8d4efddd1e 100644 --- a/src/tracking/feature-builder/vpFeatureBuilder.h +++ b/src/tracking/feature-builder/vpFeatureBuilder.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureBuilder.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeatureBuilder.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/tracking/feature-builder/vpFeatureBuilderEllipse.cpp b/src/tracking/feature-builder/vpFeatureBuilderEllipse.cpp index 5618cfd82cda0d60a64719f70056c3110bd0fb04..e85ad42d378e55f28afecc31b543fc6bdbc6a6be 100644 --- a/src/tracking/feature-builder/vpFeatureBuilderEllipse.cpp +++ b/src/tracking/feature-builder/vpFeatureBuilderEllipse.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureBuilderEllipse.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeatureBuilderEllipse.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/tracking/feature-builder/vpFeatureBuilderLine.cpp b/src/tracking/feature-builder/vpFeatureBuilderLine.cpp index dd33f748c56f308461c37ed4699abb4b1fa81eb5..5093da249dc402bc81fafdc03f4daca2b3691655 100644 --- a/src/tracking/feature-builder/vpFeatureBuilderLine.cpp +++ b/src/tracking/feature-builder/vpFeatureBuilderLine.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureBuilderLine.cpp 4062 2013-01-09 10:30:06Z fspindle $ + * $Id: vpFeatureBuilderLine.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -184,13 +184,13 @@ void vpFeatureBuilder::create(vpFeatureLine &s, The code below shows how to initialize a vpFeatureLine visual feature. First, we initialize the \f$(\rho,\theta)\f$, and lastly we - set the parameters of on equation plan which is generally the result + set the parameters of the plane which is generally the result of a pose estimation. \code vpImage<unsigned char> I; // Image container vpCameraParameters cam; // Default intrinsic camera parameters - vpMeLine line; // Dot tracker + vpMeLine line; // Moving-edges line tracker vpFeatureLine s; // Point feature ... @@ -247,8 +247,8 @@ vpFeatureBuilder::create(vpFeatureLine &s, // vpTRACE("pixel %f %f",rhop, thetap) ; vpPixelMeterConversion::convertLine(cam,rhop,thetap, rho,theta) ; - while (theta > M_PI) { thetap -= 2*M_PI ; } - while (theta < -M_PI) { thetap += 2*M_PI ; } + while (theta > M_PI) { theta -= 2*M_PI ; } + while (theta < -M_PI) { theta += 2*M_PI ; } // vpTRACE("meter %f %f",rho, theta) ; /* diff --git a/src/tracking/feature-builder/vpFeatureBuilderPoint.cpp b/src/tracking/feature-builder/vpFeatureBuilderPoint.cpp index 4cb2be3e86b8e9ac6eca29fe65fb3bcdb8f2a7a6..815376dc5e9730ee148772c9fdd12a8a8adf3623 100644 --- a/src/tracking/feature-builder/vpFeatureBuilderPoint.cpp +++ b/src/tracking/feature-builder/vpFeatureBuilderPoint.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureBuilderPoint.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeatureBuilderPoint.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/tracking/feature-builder/vpFeatureBuilderPoint3D.cpp b/src/tracking/feature-builder/vpFeatureBuilderPoint3D.cpp index 4344455556b80388125faff304bf826ef7cfd4ae..2367d4337220f9ce6c6cfdd5a459a38ba7ee1421 100644 --- a/src/tracking/feature-builder/vpFeatureBuilderPoint3D.cpp +++ b/src/tracking/feature-builder/vpFeatureBuilderPoint3D.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureBuilderPoint3D.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeatureBuilderPoint3D.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/tracking/feature-builder/vpFeatureBuilderPointPolar.cpp b/src/tracking/feature-builder/vpFeatureBuilderPointPolar.cpp index 03bc5828b1e2d1800bbf8733870c6840b6ef6352..fddd38933158912a8e8af8fc1212621c2e5aadf1 100644 --- a/src/tracking/feature-builder/vpFeatureBuilderPointPolar.cpp +++ b/src/tracking/feature-builder/vpFeatureBuilderPointPolar.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureBuilderPointPolar.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeatureBuilderPointPolar.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/tracking/feature-builder/vpFeatureBuilderSegment.cpp b/src/tracking/feature-builder/vpFeatureBuilderSegment.cpp index 22eeb277ecad67bf09cfbe878cc39375ddecc4af..7901bf71ecdbee979732f840bd46ad98c349a547 100644 --- a/src/tracking/feature-builder/vpFeatureBuilderSegment.cpp +++ b/src/tracking/feature-builder/vpFeatureBuilderSegment.cpp @@ -3,7 +3,7 @@ * $Id: vpFeatureBuilderLine.cpp 3530 2012-01-03 10:52:12Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/tracking/feature-builder/vpFeatureBuilderVanishingPoint.cpp b/src/tracking/feature-builder/vpFeatureBuilderVanishingPoint.cpp index 135cbbf871f232e9c49e14b086225900a30d569d..d3d8dbb09fc480708f3954ed70bb483a5683a1d6 100644 --- a/src/tracking/feature-builder/vpFeatureBuilderVanishingPoint.cpp +++ b/src/tracking/feature-builder/vpFeatureBuilderVanishingPoint.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureBuilderVanishingPoint.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeatureBuilderVanishingPoint.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -116,8 +116,9 @@ vpFeatureBuilder::create(vpFeatureVanishingPoint &s, const vpFeatureLine &L1, co if(fabs(theta_r-theta_l)<min || fabs(fabs(theta_r-theta_l)-M_PI)<min \ || fabs(fabs(theta_r-theta_l)-2*M_PI)<min) { - vpCERROR<<"there is no vanishing point : the lines are parallel in the image plane"<<std::endl; - throw(" "); + vpCERROR<<"There is no vanishing point : the lines are parallel in the image plane"<<std::endl; + throw(vpFeatureException(vpFeatureException::badInitializationError, + "There is no vanishing point : the lines are parallel in the image plane")) ; } y = (rho_r *c_l - rho_l * c_r) / (-s_l * c_r + s_r * c_l ); diff --git a/src/tracking/forward-projection/vpCircle.cpp b/src/tracking/forward-projection/vpCircle.cpp index b6bebc600710ce162c738a0c9899bb38af13e960..f0b5fe80ff542ba35eb34bf9fdbc3178dd9404ca 100644 --- a/src/tracking/forward-projection/vpCircle.cpp +++ b/src/tracking/forward-projection/vpCircle.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpCircle.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpCircle.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -58,14 +58,14 @@ vpCircle::init() Set the world coordinates of the circle from the intersection of a plane and a sphere. We mean here the coordinates of the circle in the object frame - \param oP : oP[0], oP[1], oP[2] correspond to A, B, C from the plane equation Ax + By + Cz = 0. + \param oP_ : oP[0], oP[1], oP[2] correspond to A, B, C from the plane equation Ax + By + Cz = 0. oP[3], oP[4], oP[5] correspond to X, Y, Z the coordinates of the center of the sphere. oP[6] corresponds to the radius of the sphere. */ void -vpCircle::setWorldCoordinates(const vpColVector& oP) +vpCircle::setWorldCoordinates(const vpColVector& oP_) { - this->oP = oP ; + this->oP = oP_ ; } /*! @@ -106,16 +106,16 @@ vpCircle::vpCircle() /*! Construct the circle from the intersection of a plane and a sphere. - \param oP : oP[0], oP[1], oP[2] correspond to A, B, C from the plane equation Ax + By + Cz = 0. + \param oP_ : oP[0], oP[1], oP[2] correspond to A, B, C from the plane equation Ax + By + Cz = 0. oP[3], oP[4], oP[5] correspond to X, Y, Z the coordinates of the center of the sphere. oP[6] corresponds to the radius of the sphere. \sa setWorldCoordinates() */ -vpCircle::vpCircle(const vpColVector& oP) +vpCircle::vpCircle(const vpColVector& oP_) { init() ; - setWorldCoordinates(oP) ; + setWorldCoordinates(oP_) ; } /*! @@ -157,23 +157,21 @@ vpCircle::projection() projection(cP,p) ; } -//! perspective projection of the circle +//! Perspective projection of the circle. void -vpCircle::projection(const vpColVector &cP, vpColVector &p) +vpCircle::projection(const vpColVector &cP_, vpColVector &p_) { - vpColVector K(6) ; - { - double A = cP[0] ; - double B = cP[1] ; - double C = cP[2] ; + double A = cP_[0] ; + double B = cP_[1] ; + double C = cP_[2] ; - double X0 = cP[3] ; - double Y0 = cP[4] ; - double Z0 = cP[5] ; + double X0 = cP_[3] ; + double Y0 = cP_[4] ; + double Z0 = cP_[5] ; - double r = cP[6]; + double r = cP_[6]; // projection double s = X0*X0 + Y0*Y0 + Z0*Z0 - r*r ; @@ -196,10 +194,8 @@ vpCircle::projection(const vpColVector &cP, vpColVector &p) vpERROR_TRACE("division par 0") ; throw(vpException(vpException::divideByZeroError, "division par 0")) ; - } - double xc = (K[1]*K[3]-K[2]*K[4])/det; double yc = (K[0]*K[4]-K[2]*K[3])/det; @@ -243,16 +239,16 @@ vpCircle::projection(const vpColVector &cP, vpColVector &p) double m11 = (vpMath::sqr(A) - vpMath::sqr(B)) *E / det ; double m02 = (vpMath::sqr(B) + vpMath::sqr(A*E)) / det ; - p[0] = xc ; - p[1] = yc ; - p[2] = m20 ; - p[3] = m11 ; - p[4] = m02 ; + p_[0] = xc ; + p_[1] = yc ; + p_[2] = m20 ; + p_[3] = m11 ; + p_[4] = m02 ; } //! perspective projection of the circle void -vpCircle::changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP) +vpCircle::changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP_) { double A,B,C ; @@ -266,15 +262,15 @@ vpCircle::changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP) Z0 = cMo[2][3] + cMo[2][0]*oP[3] + cMo[2][1]*oP[4] + cMo[2][2]*oP[5]; double R = oP[6] ; - cP[0] = A ; - cP[1] = B ; - cP[2] = C ; + cP_[0] = A ; + cP_[1] = B ; + cP_[2] = C ; - cP[3] = X0 ; - cP[4] = Y0 ; - cP[5] = Z0 ; + cP_[3] = X0 ; + cP_[4] = Y0 ; + cP_[5] = Z0 ; - cP[6] = R ; + cP_[6] = R ; // vpTRACE("_cP :") ; std::cout << _cP.t() ; diff --git a/src/tracking/forward-projection/vpCircle.h b/src/tracking/forward-projection/vpCircle.h index 523bd664ed53ee7a2123351790fcca7ebae8af4b..3dbba40aa7849f325bdd5b4e48ed166d64178df5 100644 --- a/src/tracking/forward-projection/vpCircle.h +++ b/src/tracking/forward-projection/vpCircle.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpCircle.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpCircle.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/tracking/forward-projection/vpCylinder.cpp b/src/tracking/forward-projection/vpCylinder.cpp index 057b9ddf56f561a097df287e41d434145d4dc099..6fe38e52315a31eb50f08f24aeb6cba49d0dfd90 100644 --- a/src/tracking/forward-projection/vpCylinder.cpp +++ b/src/tracking/forward-projection/vpCylinder.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpCylinder.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpCylinder.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -58,7 +58,7 @@ vpCylinder::init() Set the cylinder parameters \f$^{o}{\bf P} = ({^o}A,{^o}B,{^o}C,{^o}X_0,{^o}Y_0,{^o}Z_0,R)\f$ expressed in the world frame. - \param oP : Vector of parameters \f$^{o}{\bf P}\f$. + \param o_P : Vector of parameters \f$^{o}{\bf P}\f$. \code vpCylinder cylinder; @@ -74,9 +74,9 @@ vpCylinder::init() \endcode */ void -vpCylinder::setWorldCoordinates(const vpColVector& oP) +vpCylinder::setWorldCoordinates(const vpColVector& o_P) { - this->oP = oP ; + this->oP = o_P ; } /*! @@ -115,7 +115,7 @@ vpCylinder::vpCylinder() Create and initialize a cylinder with parameters \f$^{o}{\bf P} = ({^o}A,{^o}B,{^o}C,{^o}X_0,{^o}Y_0,{^o}Z_0,R)\f$ expressed in the world frame. - \param oP : Vector of parameters \f$^{o}{\bf P}\f$. + \param o_P : Vector of parameters \f$^{o}{\bf P}\f$. \code vpCylinder cylinder; @@ -131,10 +131,10 @@ vpCylinder::vpCylinder() \endcode \sa setWorldCoordinates(const vpColVector&) */ -vpCylinder::vpCylinder(const vpColVector& oP) +vpCylinder::vpCylinder(const vpColVector& o_P) { init() ; - setWorldCoordinates(oP) ; + setWorldCoordinates(o_P) ; } /*! @@ -198,8 +198,8 @@ vpCylinder::projection() From the parameters of the cylinder in the camera frame \f$c{\bf P}\f$, compute the perspective projection of the cylinder in the image plane. - \param cP [in] : Cylinder parameters in the camera frame. - \param p [out] : Parameters of the cylinder in the image plane obtained by perspective projection. + \param cP_ [in] : Cylinder parameters in the camera frame. + \param p_ [out] : Parameters of the cylinder in the image plane obtained by perspective projection. \exception vpException::fatalError : The camera is inside the cylinder. @@ -220,7 +220,7 @@ vpCylinder::projection() \sa projection() */ void -vpCylinder::projection(const vpColVector &cP, vpColVector &p) +vpCylinder::projection(const vpColVector &cP_, vpColVector &p_) { //calcul de la scene 2-D @@ -228,13 +228,13 @@ vpCylinder::projection(const vpColVector &cP, vpColVector &p) double A,B,C, X0, Y0, Z0, R ; double s, a, b, c, zero; - A = cP[0] ; - B = cP[1] ; - C = cP[2] ; - X0 = cP[3] ; - Y0 = cP[4] ; - Z0 = cP[5] ; - R= cP[6] ; + A = cP_[0] ; + B = cP_[1] ; + C = cP_[2] ; + X0 = cP_[3] ; + Y0 = cP_[4] ; + Z0 = cP_[5] ; + R= cP_[6] ; zero = A*X0 + B*Y0 + C*Z0; // should be zero for a good reprensetation of the cylinder s = X0*X0 + Y0*Y0 + Z0*Z0 - R*R - zero*zero; @@ -255,8 +255,8 @@ vpCylinder::projection(const vpColVector &cP, vpColVector &p) co = R*a*s-x0; si = R*b*s-y0; e = sqrt(co*co + si*si); - p[0] = -(R*c*s-z0)/e ; // rho1 - p[1] = atan2(si,co) ; // theta 1 + p_[0] = -(R*c*s-z0)/e ; // rho1 + p_[1] = atan2(si,co) ; // theta 1 // while (p[1] > M_PI/2) { p[1] -= M_PI ; p[0] *= -1 ; } // while (p[1] < -M_PI/2) { p[1] += M_PI ; p[0] *= -1 ; } @@ -265,8 +265,8 @@ vpCylinder::projection(const vpColVector &cP, vpColVector &p) co = R*a*s+x0; si = R*b*s+y0; e = sqrt(co*co + si*si); - p[2] = -( R*c*s+z0 )/e ; //rho2 - p[3] = atan2( si,co ) ; //theta2 + p_[2] = -( R*c*s+z0 )/e ; //rho2 + p_[3] = atan2( si,co ) ; //theta2 // while (p[3] > M_PI/2) { p[3] -= M_PI ; p[2] *= -1 ; } @@ -294,12 +294,12 @@ vpCylinder::changeFrame(const vpHomogeneousMatrix &cMo) the cylinder parameters \f$^{c}{\bf P}\f$ expressed in the camera frame. \param cMo : Camera to world frame transformation. - \param cP [out] : Parameters \f$^{c}{\bf P}\f$ expressed in the camera frame. + \param cP_ [out] : Parameters \f$^{c}{\bf P}\f$ expressed in the camera frame. \sa changeFrame(const vpHomogeneousMatrix &) */ void -vpCylinder::changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP) +vpCylinder::changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP_) { double X1, Y1, Z1; double X2, Y2, Z2; @@ -322,9 +322,9 @@ vpCylinder::changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP) c = Z1 / s; // set axis coordinates in camera frame - cP[0] = a ; - cP[1] = b ; - cP[2] = c ; + cP_[0] = a ; + cP_[1] = b ; + cP_[2] = c ; X2 = cMo[0][3] + cMo[0][0]*oX0 + cMo[0][1]*oY0 + cMo[0][2]*oZ0; Y2 = cMo[1][3] + cMo[1][0]*oX0 + cMo[1][1]*oY0 + cMo[1][2]*oZ0; @@ -332,9 +332,9 @@ vpCylinder::changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP) // adding the constraint X0 is the nearest point to the origin (A^T . X0 = 0) // using the projection operator (I - AA^T) orthogonal to A - cP[3] = (1-a*a)*X2 - a*b*Y2 - a*c*Z2; - cP[4] = -a*b*X2 + (1-b*b)*Y2 - b*c*Z2; - cP[5] = -a*c*X2 - b*c*Y2 + (1-c*c)*Z2; + cP_[3] = (1-a*a)*X2 - a*b*Y2 - a*c*Z2; + cP_[4] = -a*b*X2 + (1-b*b)*Y2 - b*c*Z2; + cP_[5] = -a*c*X2 - b*c*Y2 + (1-c*c)*Z2; /* old version for the same onstraint if ( fabs(a) > 0.25 ) @@ -385,7 +385,7 @@ vpCylinder::changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP) } */ //radius - cP[6] = oP[6] ; + cP_[6] = oP[6] ; } diff --git a/src/tracking/forward-projection/vpCylinder.h b/src/tracking/forward-projection/vpCylinder.h index 384f33c3d27657531c2e6f1aad33c01ade084a81..e8f0ebbf20d8ac7cb7f8524863acf03ee14b6479 100644 --- a/src/tracking/forward-projection/vpCylinder.h +++ b/src/tracking/forward-projection/vpCylinder.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpCylinder.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpCylinder.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/tracking/forward-projection/vpForwardProjection.cpp b/src/tracking/forward-projection/vpForwardProjection.cpp index b2767042ee588301e7054457ca6f20aac381967a..d1c30f352ae02e71f045e068361303bc28d13719 100644 --- a/src/tracking/forward-projection/vpForwardProjection.cpp +++ b/src/tracking/forward-projection/vpForwardProjection.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpForwardProjection.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpForwardProjection.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/tracking/forward-projection/vpForwardProjection.h b/src/tracking/forward-projection/vpForwardProjection.h index e030c059480119550d27ed27a4ce8d93ba0222e5..6b4a8ea36f6b1c244e22ca914db861807491ad9b 100644 --- a/src/tracking/forward-projection/vpForwardProjection.h +++ b/src/tracking/forward-projection/vpForwardProjection.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpForwardProjection.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpForwardProjection.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -225,6 +225,8 @@ public: private: vpForwardProjectionDeallocatorType deallocate ; public: + vpForwardProjection() : oP(), deallocate(user) {} + void setDeallocate(vpForwardProjectionDeallocatorType d) { deallocate = d ; } vpForwardProjectionDeallocatorType getDeallocate() { return deallocate ; } } ; diff --git a/src/tracking/forward-projection/vpLine.cpp b/src/tracking/forward-projection/vpLine.cpp index f4e082585052e3164b9424ac73eeacf833628f85..1b103840dbd068d1fd4613dbd1ecef0f912468e8 100644 --- a/src/tracking/forward-projection/vpLine.cpp +++ b/src/tracking/forward-projection/vpLine.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpLine.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpLine.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -124,19 +124,19 @@ vpLine::setWorldCoordinates(const double &A1, const double &B1, \f[ A2 X + B2 Y + C2 Z +D2 = 0 \f] Here \f$ (X, Y, Z) \f$ are the 3D coordinates in the object frame. - \param oP : The column vector which contains the eight parameters + \param oP_ : The column vector which contains the eight parameters needed to define the equations of the two planes in the object frame. \f[ oP = \left[\begin{array}{c}A1 \\ B1 \\ C1 \\ D1 \\ A2 \\ B2 \\ C2 \\ D2 \end{array}\right] \f] */ void -vpLine::setWorldCoordinates(const vpColVector &oP) +vpLine::setWorldCoordinates(const vpColVector &oP_) { - if (oP.getRows() != 8) + if (oP_.getRows() != 8) throw vpException(vpException::dimensionError, "Size of oP is not equal to 8 as it should be"); - this->oP = oP ; + this->oP = oP_ ; } @@ -226,18 +226,18 @@ vpLine::projection() image plane parameters \f$p=(\rho , \theta)\f$ are updated in output. - \param cP : The vector containing the line features relative to the + \param cP_ : The vector containing the line features relative to the camera frame. \f[ cP = \left[\begin{array}{c}A1 \\ B1 \\ C1 \\ D1 \\ A2 \\ B2 \\ C2 \\ D2 \end{array}\right] \f] - \param p : The vector which contains the 2D line features expressed + \param p_ : The vector which contains the 2D line features expressed in the image plane. \f[ p = \left[\begin{array}{c} \rho \\ \theta \end{array}\right] \f] \exception vpException::fatalError : Degenerate case, the image of the straight line is a point. */ void -vpLine::projection(const vpColVector &cP, vpColVector &p) +vpLine::projection(const vpColVector &cP_, vpColVector &p_) { //projection @@ -246,15 +246,15 @@ vpLine::projection(const vpColVector &cP, vpColVector &p) double A1, A2, B1, B2, C1, C2, D1, D2; - A1=cP[0] ; - B1=cP[1] ; - C1=cP[2] ; - D1=cP[3] ; + A1=cP_[0] ; + B1=cP_[1] ; + C1=cP_[2] ; + D1=cP_[3] ; - A2=cP[4] ; - B2=cP[5] ; - C2=cP[6] ; - D2=cP[7] ; + A2=cP_[4] ; + B2=cP_[5] ; + C2=cP_[6] ; + D2=cP_[7] ; double a, b, c, s; a = A2*D1 - A1*D2; @@ -274,8 +274,8 @@ vpLine::projection(const vpColVector &cP, vpColVector &p) if (p.getRows() != 2) p.resize(2); - p[0] = rho ; - p[1] = theta ; + p_[0] = rho ; + p_[1] = theta ; } @@ -336,7 +336,7 @@ vpLine::changeFrame(const vpHomogeneousMatrix &cMo) \param cMo : The homogeneous matrix relative to the pose between the desired frame and the object frame. - \param cP : The vector which will contain the parameters of the two + \param cP_ : The vector which will contain the parameters of the two planes in the camera frame. \f[ cP = \left[\begin{array}{c}A1 \\ B1 \\ C1 \\ D1 \\ A2 \\ B2 \\ C2 \\ D2 \end{array}\right] \f] @@ -363,7 +363,7 @@ vpLine::changeFrame(const vpHomogeneousMatrix &cMo) */ void -vpLine::changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP) +vpLine::changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP_) { double a1, a2, b1, b2, c1, c2, d1, d2; @@ -424,10 +424,10 @@ vpLine::changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP) // Constraint A1^2 + B1^2 + C1^2 = 1 d1 = 1.0/sqrt(a1*a1 + b1*b1 + c1*c1); - cP[0] = A1 = a1*d1 ; - cP[1] = B1 = b1*d1 ; - cP[2] = C1 = c1*d1 ; - cP[3] = D1 = 0 ; + cP_[0] = A1 = a1*d1 ; + cP_[1] = B1 = b1*d1 ; + cP_[2] = C1 = c1*d1 ; + cP_[3] = D1 = 0 ; // Constraint A1 A2 + B1 B2 + C1 C2 = 0 (P2 orthogonal to P1) // N2_new = (N1 x N2) x N1_new @@ -458,10 +458,10 @@ vpLine::changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP) // vpERROR_TRACE("A1 B1 C1 D1 %f %f %f %f ", A1, B1, C1, D1) ; // vpERROR_TRACE("A2 B2 C2 D2 %f %f %f %f ", A2, B2, C2, D2) ; - cP[4] = A2; - cP[5] = B2; - cP[6] = C2; - cP[7] = D2; + cP_[4] = A2; + cP_[5] = B2; + cP_[6] = C2; + cP_[7] = D2; // in case of verification /* diff --git a/src/tracking/forward-projection/vpLine.h b/src/tracking/forward-projection/vpLine.h index 3c81a28b98b1ef40c8689718cc1ce6f448e1aacf..780a1a024ea7cc45c73702d180622f5c1090a09d 100644 --- a/src/tracking/forward-projection/vpLine.h +++ b/src/tracking/forward-projection/vpLine.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpLine.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpLine.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/tracking/forward-projection/vpPoint.cpp b/src/tracking/forward-projection/vpPoint.cpp index 800a9364e04addb5cdf6ab53d900cdaa2bf438f0..5c7e2dc4a99059046df677845bad454fa2a0e302 100644 --- a/src/tracking/forward-projection/vpPoint.cpp +++ b/src/tracking/forward-projection/vpPoint.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpPoint.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpPoint.cpp 4620 2014-01-27 21:28:32Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -286,7 +286,7 @@ vpPoint::display(const vpImage<vpRGBa> &I, vpFeatureDisplay::displayPoint(_p[0],_p[1], cam, I, color, thickness) ; } -std::ostream& operator<<(std::ostream& os, vpPoint& /* vpp */) +VISP_EXPORT std::ostream& operator<<(std::ostream& os, vpPoint& /* vpp */) { return( os<<"vpPoint" ); } diff --git a/src/tracking/forward-projection/vpPoint.h b/src/tracking/forward-projection/vpPoint.h index 064d3fc67267db493baa90efb3bd29a6dcfe3258..ebe0a836093d9c988bd84df0d7538bc8ca279222 100644 --- a/src/tracking/forward-projection/vpPoint.h +++ b/src/tracking/forward-projection/vpPoint.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpPoint.h 4089 2013-02-04 08:17:31Z fspindle $ + * $Id: vpPoint.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/tracking/forward-projection/vpSphere.cpp b/src/tracking/forward-projection/vpSphere.cpp index 4d08a871a5334715f00dab7a0f59dfe871142392..4e380e443994c11ca6c678e72297b1759c342c8e 100644 --- a/src/tracking/forward-projection/vpSphere.cpp +++ b/src/tracking/forward-projection/vpSphere.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpSphere.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpSphere.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -55,9 +55,9 @@ vpSphere::init() } void -vpSphere::setWorldCoordinates(const vpColVector& oP) +vpSphere::setWorldCoordinates(const vpColVector& oP_) { - this->oP = oP ; + this->oP = oP_ ; } void @@ -78,10 +78,10 @@ vpSphere::vpSphere() } -vpSphere::vpSphere(const vpColVector& oP) +vpSphere::vpSphere(const vpColVector& oP_) { init() ; - setWorldCoordinates(oP) ; + setWorldCoordinates(oP_) ; } vpSphere::vpSphere(const double X0, const double Y0, @@ -103,9 +103,9 @@ vpSphere::projection() projection(cP,p) ; } -//! perspective projection of the circle +//! Perspective projection of the circle. void -vpSphere::projection(const vpColVector &cP, vpColVector &p) +vpSphere::projection(const vpColVector &cP_, vpColVector &p_) { double x0, y0, z0; //variables intermediaires // double k0, k1, k2, k3, k4; //variables intermediaires @@ -113,12 +113,11 @@ vpSphere::projection(const vpColVector &cP, vpColVector &p) //calcul des parametres M20, M11, M02 de l'ellipse double s, a, b, r, e; //variables intermediaires - r = cP[3]; - - x0 = cP[0] ; - y0 = cP[1] ; - z0 = cP[2] ; + r = cP_[3]; + x0 = cP_[0] ; + y0 = cP_[1] ; + z0 = cP_[2] ; s = r*r - y0*y0 -z0*z0; @@ -133,8 +132,8 @@ vpSphere::projection(const vpColVector &cP, vpColVector &p) vpERROR_TRACE("sphere derriere le plan image\n"); } - p[0] = x0*z0/s ; //x - p[1] = y0*z0/s ; //y + p_[0] = x0*z0/s ; //x + p_[1] = y0*z0/s ; //y if (fabs(x0) > 1e-6) { @@ -167,14 +166,13 @@ vpSphere::projection(const vpColVector &cP, vpColVector &p) B = r*sqrt(y0*y0+z0*z0-r*r)/s; } - p[2] = ( A*A + B*B * E*E) / (1.0 + E*E); // mu20 - p[3] = ( A*A - B*B) * E / (1.0 + E*E); // mu11 - p[4] = ( B*B + A*A * E*E) / (1.0 + E*E); // mu02 + p_[2] = ( A*A + B*B * E*E) / (1.0 + E*E); // mu20 + p_[3] = ( A*A - B*B) * E / (1.0 + E*E); // mu11 + p_[4] = ( B*B + A*A * E*E) / (1.0 + E*E); // mu02 // vpERROR_TRACE(" %f",r) ; // std::cout << p.t() ; - } //! perspective projection of the circle void @@ -183,25 +181,21 @@ vpSphere::changeFrame(const vpHomogeneousMatrix &cMo) changeFrame(cMo,cP) ; } -//! perspective projection of the circle +//! Perspective projection of the circle. void -vpSphere::changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP) +vpSphere::changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP_) { - double x0, y0, z0; //variables intermediaires - x0 = cMo[0][0]*oP[0] + cMo[0][1]*oP[1] + cMo[0][2]*oP[2] + cMo[0][3]; y0 = cMo[1][0]*oP[0] + cMo[1][1]*oP[1] + cMo[1][2]*oP[2] + cMo[1][3]; z0 = cMo[2][0]*oP[0] + cMo[2][1]*oP[1] + cMo[2][2]*oP[2] + cMo[2][3]; - cP[3] = oP[3]; - - cP[0] = x0 ; - cP[1] = y0 ; - cP[2] = z0 ; - + cP_[3] = oP[3]; + cP_[0] = x0 ; + cP_[1] = y0 ; + cP_[2] = z0 ; } //! for memory issue (used by the vpServo class only) diff --git a/src/tracking/forward-projection/vpSphere.h b/src/tracking/forward-projection/vpSphere.h index 7eb51a8aa3516df9c3697309abf7e1f573fa0aa7..dfef7c9539b0f41038121a8fa2b8e5e6f3a8b648 100644 --- a/src/tracking/forward-projection/vpSphere.h +++ b/src/tracking/forward-projection/vpSphere.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpSphere.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpSphere.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/tracking/general-tracking-issues/vpTracker.cpp b/src/tracking/general-tracking-issues/vpTracker.cpp index 3e90e10326d993cbc104b94227329a1e44a74c4c..4e3757115921cbfd90e20df5f7e0157afbc91034 100644 --- a/src/tracking/general-tracking-issues/vpTracker.cpp +++ b/src/tracking/general-tracking-issues/vpTracker.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpTracker.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpTracker.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -58,12 +58,9 @@ vpTracker::init() -vpTracker::vpTracker() -{ - init() ; -} +vpTracker::vpTracker() : p(), cP(), cPAvailable(false) {} -vpTracker::vpTracker(const vpTracker &tracker) +vpTracker::vpTracker(const vpTracker &tracker) : p(), cP(), cPAvailable(false) { *this = tracker; } diff --git a/src/tracking/general-tracking-issues/vpTracker.h b/src/tracking/general-tracking-issues/vpTracker.h index 147136ee65802d14c5e86ba5a260151cf7351393..3acc3b76c7f3a8947e61c30600f7cc1fedcd843f 100644 --- a/src/tracking/general-tracking-issues/vpTracker.h +++ b/src/tracking/general-tracking-issues/vpTracker.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpTracker.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpTracker.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/tracking/general-tracking-issues/vpTrackingException.h b/src/tracking/general-tracking-issues/vpTrackingException.h index fab9ca3a5c6e1a62da2d1a4d493bd247b7c9ef4e..4528593aa776fd194a5de7f36d9c051c82fc0bf0 100644 --- a/src/tracking/general-tracking-issues/vpTrackingException.h +++ b/src/tracking/general-tracking-issues/vpTrackingException.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpTrackingException.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpTrackingException.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -68,12 +68,12 @@ */ class VISP_EXPORT vpTrackingException : public vpException { -public: - /*! + public: + /*! \brief Lists the possible error than can be emmited while calling vpTracking member */ - enum errorTrackingCodeEnum + enum errorTrackingCodeEnum { featureLostError, @@ -83,25 +83,20 @@ public: fatalError } ; -public: - vpTrackingException (const int code, const char * msg) - : vpException(code, msg){ ; } - vpTrackingException (const int code, const std::string & msg) - : vpException(code, msg){ ; } - vpTrackingException (const int code) - : vpException(code){ ; } + public: + vpTrackingException (const int id, const char* format, ...) + { + this->code = id; + va_list args; + va_start(args, format); + setMessage(format, args); + va_end (args); + } + vpTrackingException (const int id, const std::string & msg) + : vpException(id, msg){ ; } + vpTrackingException (const int id) + : vpException(id){ ; } }; - - - - -#endif /* #ifndef __vpTrackingException_H */ - - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ +#endif diff --git a/src/tracking/klt/vpKltOpencv.cpp b/src/tracking/klt/vpKltOpencv.cpp index c1e8e339a5ae59d7177c89bfac56e313b49c7045..db5ac8e61f3660ccde4e714eb423b767b4911968 100644 --- a/src/tracking/klt/vpKltOpencv.cpp +++ b/src/tracking/klt/vpKltOpencv.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpKltOpencv.cpp 4198 2013-04-05 12:13:23Z fspindle $ + * $Id: vpKltOpencv.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -63,12 +63,12 @@ void vpKltOpencv::clean() if (pyramid) cvReleaseImage(&pyramid); if (prev_pyramid) cvReleaseImage(&prev_pyramid); - image = 0; - prev_image = 0; - pyramid = 0; - prev_pyramid = 0; + image = NULL; + prev_image = NULL; + pyramid = NULL; + prev_pyramid = NULL; - swap_temp = 0; + swap_temp = NULL; countFeatures = 0; countPrevFeatures = 0; flags = 0; @@ -85,12 +85,12 @@ void vpKltOpencv::cleanAll() if (lostDuringTrack) cvFree(&lostDuringTrack); if (featuresid) cvFree(&featuresid); if (prev_featuresid) cvFree(&prev_featuresid); - features = 0; - prev_features = 0; - status = 0; + features = NULL; + prev_features = NULL; + status = NULL; lostDuringTrack = 0; - featuresid = 0; - prev_featuresid = 0; + featuresid = NULL; + prev_featuresid = NULL; } void vpKltOpencv::reset() @@ -99,54 +99,45 @@ void vpKltOpencv::reset() } +/*! + Default constructor. + */ vpKltOpencv::vpKltOpencv() + : initialized(0), maxFeatures(50), globalcountFeatures(0), win_size(10), quality(0.01), + min_distance(10), harris_free_parameter(0.04), block_size(3), use_harris(1), + pyramid_level(3), _tid(-1), image(NULL), prev_image(NULL), pyramid(NULL), + prev_pyramid(NULL), swap_temp(NULL), countFeatures(0), countPrevFeatures(0), + features(NULL), prev_features(NULL), featuresid(NULL), prev_featuresid(NULL), + flags(0), initial_guess(false), lostDuringTrack(0), status(0), OnInitialize(0), + OnFeatureLost(0), OnNewFeature(0), OnMeasureFeature(0), IsFeatureValid(0) { - //Valeurs par d�faut pour le KLT - initialized = 0; - maxFeatures = 50; - countFeatures = 0; - countPrevFeatures = 0; - globalcountFeatures = 0; - win_size = 10; - quality = 0.01; - min_distance = 10; - block_size = 3; - use_harris = 1; - pyramid_level = 3; - harris_free_parameter = 0.04; - - //Zeroing pointers - image = 0; - prev_image = 0; - pyramid = 0; - prev_pyramid = 0; - swap_temp = 0; - features = 0; - prev_features = 0; - flags = 0; - status = 0; - lostDuringTrack = 0; - featuresid = 0; - prev_featuresid = 0; - OnInitialize = 0; - OnFeatureLost = 0; - OnNewFeature = 0; - OnMeasureFeature = 0; - IsFeatureValid = 0; - initial_guess = false; - features = (CvPoint2D32f*)cvAlloc((unsigned int)maxFeatures*sizeof(features[0])); prev_features = (CvPoint2D32f*)cvAlloc((unsigned int)maxFeatures*sizeof(prev_features[0])); status = (char*)cvAlloc((size_t)maxFeatures); lostDuringTrack = (bool*)cvAlloc((size_t)maxFeatures); featuresid = (long*)cvAlloc((unsigned int)maxFeatures*sizeof(long)); prev_featuresid = (long*)cvAlloc((unsigned int)maxFeatures*sizeof(long)); - - - _tid = -1; } +/*! + Copy constructor. + */ vpKltOpencv::vpKltOpencv(const vpKltOpencv& copy) + : initialized(0), maxFeatures(50), globalcountFeatures(0), win_size(10), quality(0.01), + min_distance(10), harris_free_parameter(0.04), block_size(3), use_harris(1), + pyramid_level(3), _tid(-1), image(NULL), prev_image(NULL), pyramid(NULL), + prev_pyramid(NULL), swap_temp(NULL), countFeatures(0), countPrevFeatures(0), + features(NULL), prev_features(NULL), featuresid(NULL), prev_featuresid(NULL), + flags(0), initial_guess(false), lostDuringTrack(0), status(0), OnInitialize(0), + OnFeatureLost(0), OnNewFeature(0), OnMeasureFeature(0), IsFeatureValid(0) +{ + *this = copy; +} + +/*! + Copy operator. + */ +vpKltOpencv & vpKltOpencv::operator=(const vpKltOpencv& copy) { //Shallow copy of primitives initialized = copy.initialized; @@ -170,18 +161,12 @@ vpKltOpencv::vpKltOpencv(const vpKltOpencv& copy) OnMeasureFeature = copy.OnMeasureFeature; IsFeatureValid = copy.IsFeatureValid; + initial_guess = copy.initial_guess; + lostDuringTrack = copy.lostDuringTrack; + if (!initialized) { - image = 0; - prev_image = 0; - pyramid = 0; - prev_pyramid = 0; - features = 0; - prev_features = 0; status = 0; lostDuringTrack = 0; - featuresid = 0; - prev_featuresid = 0; - swap_temp = 0; countFeatures = 0; countPrevFeatures = 0; flags = 0; @@ -189,72 +174,74 @@ vpKltOpencv::vpKltOpencv(const vpKltOpencv& copy) globalcountFeatures = 0; } - if (copy.image) - { - image = cvCreateImage(cvGetSize(copy.image), 8, 1); - // /*IplImage **/cvCopyImage(copy.image,image); - cvCopy(copy.image, image, 0); - } - - if (copy.prev_image) - { - prev_image = cvCreateImage(cvGetSize(copy.prev_image), IPL_DEPTH_8U, 1); - // /*IplImage **/ cvCopyImage(copy.prev_image,prev_image); - cvCopy(copy.prev_image, prev_image, 0); - } - - if (copy.pyramid) - { - pyramid = cvCreateImage(cvGetSize(copy.pyramid), IPL_DEPTH_8U, 1); - // /*IplImage **/cvCopyImage(copy.pyramid,pyramid); - cvCopy(copy.pyramid, pyramid, 0); - } - - if (copy.prev_pyramid) - { - prev_pyramid = cvCreateImage(cvGetSize(copy.prev_pyramid), IPL_DEPTH_8U, 1); - // /*IplImage **/cvCopyImage(copy.prev_pyramid,prev_pyramid); - cvCopy(copy.prev_pyramid, prev_pyramid, 0); - } + if (copy.image) + { + image = cvCreateImage(cvGetSize(copy.image), 8, 1); + // /*IplImage **/cvCopyImage(copy.image,image); + cvCopy(copy.image, image, 0); + } + + if (copy.prev_image) + { + prev_image = cvCreateImage(cvGetSize(copy.prev_image), IPL_DEPTH_8U, 1); + // /*IplImage **/ cvCopyImage(copy.prev_image,prev_image); + cvCopy(copy.prev_image, prev_image, 0); + } + + if (copy.pyramid) + { + pyramid = cvCreateImage(cvGetSize(copy.pyramid), IPL_DEPTH_8U, 1); + // /*IplImage **/cvCopyImage(copy.pyramid,pyramid); + cvCopy(copy.pyramid, pyramid, 0); + } + + if (copy.prev_pyramid) + { + prev_pyramid = cvCreateImage(cvGetSize(copy.prev_pyramid), IPL_DEPTH_8U, 1); + // /*IplImage **/cvCopyImage(copy.prev_pyramid,prev_pyramid); + cvCopy(copy.prev_pyramid, prev_pyramid, 0); + } //Deep copy of arrays if (copy.features) { - /*CvPoint2D32f **/features = - (CvPoint2D32f*)cvAlloc((unsigned int)copy.maxFeatures*sizeof(CvPoint2D32f)); - for (int i = 0; i < copy.maxFeatures; i++) - features[i] = copy.features[i]; - } + /*CvPoint2D32f **/features = + (CvPoint2D32f*)cvAlloc((unsigned int)copy.maxFeatures*sizeof(CvPoint2D32f)); + for (int i = 0; i < copy.maxFeatures; i++) + features[i] = copy.features[i]; + } if (copy.prev_features) { - /*CvPoint2D32f **/prev_features = - (CvPoint2D32f*)cvAlloc((unsigned int)copy.maxFeatures*sizeof(CvPoint2D32f)); - for (int i = 0; i < copy.maxFeatures; i++) - prev_features[i] = copy.prev_features[i]; - } + /*CvPoint2D32f **/prev_features = + (CvPoint2D32f*)cvAlloc((unsigned int)copy.maxFeatures*sizeof(CvPoint2D32f)); + for (int i = 0; i < copy.maxFeatures; i++) + prev_features[i] = copy.prev_features[i]; + } if (copy.featuresid) { - /*long **/featuresid = (long*)cvAlloc((unsigned int)copy.maxFeatures*sizeof(long)); - for (int i = 0; i < copy.maxFeatures; i++) - featuresid[i] = copy.featuresid[i]; - } + /*long **/featuresid = (long*)cvAlloc((unsigned int)copy.maxFeatures*sizeof(long)); + for (int i = 0; i < copy.maxFeatures; i++) + featuresid[i] = copy.featuresid[i]; + } if (copy.prev_featuresid) { - /*long **/prev_featuresid = (long*)cvAlloc((unsigned int)copy.maxFeatures*sizeof(long)); - for (int i = 0; i < copy.maxFeatures; i++) - prev_featuresid[i] = copy.prev_featuresid[i]; - } + /*long **/prev_featuresid = (long*)cvAlloc((unsigned int)copy.maxFeatures*sizeof(long)); + for (int i = 0; i < copy.maxFeatures; i++) + prev_featuresid[i] = copy.prev_featuresid[i]; + } if (copy.status) { - /*char **/status = (char*)cvAlloc((unsigned int)copy.maxFeatures*sizeof(char)); - for (int i = 0; i < copy.maxFeatures; i++) - status[i] = copy.status[i]; - } + /*char **/status = (char*)cvAlloc((unsigned int)copy.maxFeatures*sizeof(char)); + for (int i = 0; i < copy.maxFeatures; i++) + status[i] = copy.status[i]; + } if (copy.lostDuringTrack) { /*bool **/lostDuringTrack = (bool*)cvAlloc((unsigned int)copy.maxFeatures*sizeof(bool)); for (int i = 0; i < copy.maxFeatures; i++) lostDuringTrack[i] = copy.lostDuringTrack[i]; } + + return *this; } vpKltOpencv::~vpKltOpencv() diff --git a/src/tracking/klt/vpKltOpencv.h b/src/tracking/klt/vpKltOpencv.h index b6e0cd809c8f3727426d228158b07bc53ee5b5b7..ba7eb3634c6b52848c5099b957bad8a62ed3e593 100644 --- a/src/tracking/klt/vpKltOpencv.h +++ b/src/tracking/klt/vpKltOpencv.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpKltOpencv.h 4231 2013-04-29 16:26:28Z fspindle $ + * $Id: vpKltOpencv.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -202,6 +202,7 @@ class VISP_EXPORT vpKltOpencv //Detect corners in the image. Initialize the tracker void initTracking(const IplImage *I, const IplImage *mask = NULL); + vpKltOpencv & operator=(const vpKltOpencv& copy); //Track ! void track(const IplImage *I); diff --git a/src/tracking/mbt/edge/vpMbEdgeTracker.cpp b/src/tracking/mbt/edge/vpMbEdgeTracker.cpp index 8e474fb66e63f8fb8af68baae7fc98bb4226f805..ab7c736a8c2ba22ac0e32aa3ba4046700dee9161 100644 --- a/src/tracking/mbt/edge/vpMbEdgeTracker.cpp +++ b/src/tracking/mbt/edge/vpMbEdgeTracker.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMbEdgeTracker.cpp 4337 2013-07-23 13:57:53Z ayol $ + * $Id: vpMbEdgeTracker.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -46,8 +46,6 @@ \brief Make the complete tracking of an object by using its CAD model. */ - - #include <visp/vpDebug.h> #include <visp/vpPose.h> #include <visp/vpExponentialMap.h> @@ -71,36 +69,23 @@ #include <sstream> #include <float.h> +bool samePoint(const vpPoint &P1, const vpPoint &P2, double threshold); + /*! Basic constructor */ vpMbEdgeTracker::vpMbEdgeTracker() + : compute_interaction(1), lambda(1), me(), lines(1), cylinders(1), nline(0), ncylinder(0), + index_polygon(0), faces(), nbvisiblepolygone(0), percentageGdPt(0.4), scales(1), + Ipyramid(0), scaleLevel(0), useOgre(false), + angleAppears( vpMath::rad(89) ), angleDisappears( vpMath::rad(89) ), + distNearClip(0.001), distFarClip(100), clippingFlag(vpMbtPolygon::NO_CLIPPING) { - index_polygon =0; - compute_interaction=1; - nline = 0; - ncylinder = 0; - lambda = 1; - nbvisiblepolygone = 0; - percentageGdPt = 0.4; - computeCovariance = false; - - lines.resize(1); - cylinders.resize(1); - scales.resize(1); scales[0] = true; - lines[0].clear(); - cylinders[0].clear(); - Ipyramid.resize(0); #ifdef VISP_HAVE_OGRE faces.getOgreContext()->setWindowName("MBT Edge"); #endif - useOgre = false; - - angleAppears = vpMath::rad(95); - angleDisappears = vpMath::rad(95); - clippingFlag = vpMbtPolygon::NO_CLIPPING; } /*! @@ -139,12 +124,12 @@ vpMbEdgeTracker::~vpMbEdgeTracker() /*! Set the moving edge parameters. - \param me : an instance of vpMe containing all the desired parameters + \param p_me : an instance of vpMe containing all the desired parameters */ void -vpMbEdgeTracker::setMovingEdge(const vpMe &me) +vpMbEdgeTracker::setMovingEdge(const vpMe &p_me) { - this->me = me; + this->me = p_me; for (unsigned int i = 0; i < scales.size(); i += 1){ if(scales[i]){ @@ -268,8 +253,8 @@ vpMbEdgeTracker::computeVVS(const vpImage<unsigned char>& _I) double fac = 1; if (iter == 0) { - for(std::list<int>::const_iterator it = l->Lindex_polygon.begin(); it!=l->Lindex_polygon.end(); ++it){ - int index = *it; + for(std::list<int>::const_iterator itindex = l->Lindex_polygon.begin(); itindex!=l->Lindex_polygon.end(); ++itindex){ + int index = *itindex; if (l->hiddenface->isAppearing((unsigned int)index)) { fac = 0.2; @@ -740,8 +725,8 @@ vpMbEdgeTracker::testTracking() if (l->isVisible() && l->meline != NULL) { nbExpectedPoint += (int)l->meline->expecteddensity; - for(std::list<vpMeSite>::const_iterator it=l->meline->getMeList().begin(); it!=l->meline->getMeList().end(); ++it){ - vpMeSite pix = *it; + for(std::list<vpMeSite>::const_iterator itme=l->meline->getMeList().begin(); itme!=l->meline->getMeList().end(); ++itme){ + vpMeSite pix = *itme; if (pix.getState() == vpMeSite::NO_SUPPRESSION) nbGoodPoint++; else nbBadPoint++; } @@ -755,14 +740,14 @@ vpMbEdgeTracker::testTracking() if (cy->meline1 !=NULL && cy->meline2 != NULL) { nbExpectedPoint += (int)cy->meline1->expecteddensity; - for(std::list<vpMeSite>::const_iterator it=cy->meline1->getMeList().begin(); it!=cy->meline1->getMeList().end(); ++it){ - vpMeSite pix = *it; + for(std::list<vpMeSite>::const_iterator itme1=cy->meline1->getMeList().begin(); itme1!=cy->meline1->getMeList().end(); ++itme1){ + vpMeSite pix = *itme1; if (pix.getState() == vpMeSite::NO_SUPPRESSION) nbGoodPoint++; else nbBadPoint++; } nbExpectedPoint += (int)cy->meline2->expecteddensity; - for(std::list<vpMeSite>::const_iterator it=cy->meline2->getMeList().begin(); it!=cy->meline2->getMeList().end(); ++it){ - vpMeSite pix = *it; + for(std::list<vpMeSite>::const_iterator itme2=cy->meline2->getMeList().begin(); itme2!=cy->meline2->getMeList().end(); ++itme2){ + vpMeSite pix = *itme2; if (pix.getState() == vpMeSite::NO_SUPPRESSION) nbGoodPoint++; else nbBadPoint++; } @@ -1018,8 +1003,6 @@ vpMbEdgeTracker::loadConfigFile(const std::string& configFile) <fov_clipping>1</fov_clipping> </face> <camera> - <width>640</width> - <height>480</height> <u0>320</u0> <v0>240</v0> <px>686.24</px> @@ -1037,10 +1020,10 @@ vpMbEdgeTracker::loadConfigFile(const char* configFile) vpMbtXmlParser xmlp; xmlp.setCameraParameters(cam); - xmlp.setMovingEdge(me); xmlp.setAngleAppear(vpMath::deg(angleAppears)); xmlp.setAngleDisappear(vpMath::deg(angleDisappears)); - + xmlp.setMovingEdge(me); + try{ std::cout << " *********** Parsing XML for Mb Edge Tracker ************ " << std::endl; xmlp.parse(configFile); @@ -1067,7 +1050,8 @@ vpMbEdgeTracker::loadConfigFile(const char* configFile) setFarClippingDistance(xmlp.getFarClippingDistance()); if(xmlp.getFovClipping()) - clippingFlag = clippingFlag | vpMbtPolygon::FOV_CLIPPING; + setClipping(clippingFlag | vpMbtPolygon::FOV_CLIPPING); + #else vpTRACE("You need the libXML2 to read the config file %s", configFile); #endif @@ -1078,16 +1062,16 @@ vpMbEdgeTracker::loadConfigFile(const char* configFile) Display the 3D model from a given position of the camera. \param I : The image. - \param cMo : Pose used to project the 3D model into the image. - \param cam : The camera parameters. + \param cMo_ : Pose used to project the 3D model into the image. + \param camera : The camera parameters. \param col : The desired color. \param thickness : The thickness of the lines. \param displayFullModel : If true, the full model is displayed (even the non visible surfaces). */ void -vpMbEdgeTracker::display(const vpImage<unsigned char>& I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, - const vpColor& col, - const unsigned int thickness, const bool displayFullModel) +vpMbEdgeTracker::display(const vpImage<unsigned char>& I, const vpHomogeneousMatrix &cMo_, + const vpCameraParameters &camera, const vpColor& col, + const unsigned int thickness, const bool displayFullModel) { vpMbtDistanceLine *l ; @@ -1095,11 +1079,11 @@ vpMbEdgeTracker::display(const vpImage<unsigned char>& I, const vpHomogeneousMat if(scales[i]){ for(std::list<vpMbtDistanceLine*>::const_iterator it=lines[scaleLevel].begin(); it!=lines[scaleLevel].end(); ++it){ l = *it; - l->display(I,cMo, cam, col, thickness, displayFullModel); + l->display(I,cMo_, camera, col, thickness, displayFullModel); } for(std::list<vpMbtDistanceCylinder*>::const_iterator it=cylinders[scaleLevel].begin(); it!=cylinders[scaleLevel].end(); ++it){ - (*it)->display(I, cMo, cam, col, thickness); + (*it)->display(I, cMo_, camera, col, thickness); } break ; //displaying model on one scale only @@ -1108,7 +1092,7 @@ vpMbEdgeTracker::display(const vpImage<unsigned char>& I, const vpHomogeneousMat #ifdef VISP_HAVE_OGRE if(useOgre) - faces.displayOgre(cMo); + faces.displayOgre(cMo_); #endif } @@ -1116,16 +1100,16 @@ vpMbEdgeTracker::display(const vpImage<unsigned char>& I, const vpHomogeneousMat Display the 3D model from a given position of the camera. \param I : The image. - \param cMo : Pose used to project the 3D model into the image. - \param cam : The camera parameters. + \param cMo_ : Pose used to project the 3D model into the image. + \param camera : The camera parameters. \param col : The desired color. \param thickness : The thickness of the lines. \param displayFullModel : If true, the full model is displayed (even the non visible surfaces). */ void -vpMbEdgeTracker::display(const vpImage<vpRGBa>& I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, - const vpColor& col, - const unsigned int thickness, const bool displayFullModel) +vpMbEdgeTracker::display(const vpImage<vpRGBa>& I, const vpHomogeneousMatrix &cMo_, + const vpCameraParameters &camera, const vpColor& col, + const unsigned int thickness, const bool displayFullModel) { vpMbtDistanceLine *l ; @@ -1133,11 +1117,11 @@ vpMbEdgeTracker::display(const vpImage<vpRGBa>& I, const vpHomogeneousMatrix &cM if(scales[i]){ for(std::list<vpMbtDistanceLine*>::const_iterator it=lines[scaleLevel].begin(); it!=lines[scaleLevel].end(); ++it){ l = *it; - l->display(I, cMo, cam, col, thickness, displayFullModel) ; + l->display(I, cMo_, camera, col, thickness, displayFullModel) ; } for(std::list<vpMbtDistanceCylinder*>::const_iterator it=cylinders[scaleLevel].begin(); it!=cylinders[scaleLevel].end(); ++it){ - (*it)->display(I, cMo, cam, col, thickness) ; + (*it)->display(I, cMo_, camera, col, thickness) ; } break ; //displaying model on one scale only @@ -1146,7 +1130,7 @@ vpMbEdgeTracker::display(const vpImage<vpRGBa>& I, const vpHomogeneousMatrix &cM #ifdef VISP_HAVE_OGRE if(useOgre) - faces.displayOgre(cMo); + faces.displayOgre(cMo_); #endif } @@ -1168,8 +1152,8 @@ vpMbEdgeTracker::initMovingEdge(const vpImage<unsigned char> &I, const vpHomogen l = *it; bool isvisible = false ; - for(std::list<int>::const_iterator it=l->Lindex_polygon.begin(); it!=l->Lindex_polygon.end(); ++it){ - int index = *it; + for(std::list<int>::const_iterator itindex=l->Lindex_polygon.begin(); itindex!=l->Lindex_polygon.end(); ++itindex){ + int index = *itindex; if (index ==-1) isvisible =true ; else { @@ -1545,13 +1529,15 @@ vpMbEdgeTracker::visibleFace(const vpImage<unsigned char> & _I, unsigned int n ; bool changed = false; - if(!useOgre) - n = faces.setVisible(_I, cam, _cMo, vpMath::rad(89), vpMath::rad(89), changed) ; + if(!useOgre) { + //n = faces.setVisible(_I, cam, _cMo, vpMath::rad(89), vpMath::rad(89), changed) ; + n = faces.setVisible(_I, cam, _cMo, angleAppears, angleDisappears, changed) ; + } else{ #ifdef VISP_HAVE_OGRE n = faces.setVisibleOgre(_I, cam, _cMo, angleAppears, angleDisappears, changed); #else - n = faces.setVisible(_I, cam, _cMo, vpMath::rad(89), vpMath::rad(89), changed) ; + n = faces.setVisible(_I, cam, _cMo, angleAppears, angleDisappears, changed) ; #endif } @@ -1625,18 +1611,18 @@ vpMbEdgeTracker::initFaceFromCorners(const std::vector<vpPoint>& _corners, const Add a cylinder to track from tow points on the axis (defining the length of the cylinder) and its radius. - \param _p1 : First point on the axis. - \param _p2 : Second point on the axis. - \param _radius : Radius of the cylinder. - \param _indexCylinder : Index of the cylinder. + \param p1 : First point on the axis. + \param p2 : Second point on the axis. + \param radius : Radius of the cylinder. + \param indexCylinder : Index of the cylinder. */ void -vpMbEdgeTracker::initCylinder(const vpPoint& _p1, const vpPoint _p2, const double _radius, const unsigned int _indexCylinder) +vpMbEdgeTracker::initCylinder(const vpPoint& p1, const vpPoint &p2, const double radius, const unsigned int indexCylinder) { - if(_indexCylinder != 0){ - ncylinder = _indexCylinder; + if(indexCylinder != 0){ + ncylinder = indexCylinder; } - addCylinder(_p1, _p2, _radius); + addCylinder(p1, p2, radius); } /*! @@ -1679,10 +1665,10 @@ vpMbEdgeTracker::resetTracker() nbvisiblepolygone = 0; percentageGdPt = 0.4; - angleAppears = vpMath::rad(95); - angleDisappears = vpMath::rad(95); + angleAppears = vpMath::rad(89); + angleDisappears = vpMath::rad(89); clippingFlag = vpMbtPolygon::NO_CLIPPING; - + // reinitialization of the scales. this->setScales(scales); } @@ -1694,14 +1680,45 @@ vpMbEdgeTracker::resetTracker() \param I : The image containing the object to initialize. \param cad_name : Path to the file containing the 3D model description. - \param cMo : The new vpHomogeneousMatrix between the camera and the new model + \param cMo_ : The new vpHomogeneousMatrix between the camera and the new model */ void -vpMbEdgeTracker::reInitModel(const vpImage<unsigned char>& I, const char* cad_name, const vpHomogeneousMatrix& cMo) +vpMbEdgeTracker::reInitModel(const vpImage<unsigned char>& I, const char* cad_name, + const vpHomogeneousMatrix& cMo_) { - resetTracker(); + this->cMo.setIdentity(); + vpMbtDistanceLine *l; + vpMbtDistanceCylinder *cy; + + for (unsigned int i = 0; i < scales.size(); i += 1){ + if(scales[i]){ + for(std::list<vpMbtDistanceLine*>::const_iterator it=lines[i].begin(); it!=lines[i].end(); ++it){ + l = *it; + if (l!=NULL) delete l ; + l = NULL ; + } + + for(std::list<vpMbtDistanceCylinder*>::const_iterator it=cylinders[i].begin(); it!=cylinders[i].end(); ++it){ + cy = *it; + if (cy!=NULL) delete cy; + cy = NULL; + } + lines[i].clear(); + cylinders[i].clear(); + } + } + + faces.reset(); + + index_polygon =0; + //compute_interaction=1; + nline = 0; + ncylinder = 0; + //lambda = 1; + nbvisiblepolygone = 0; + loadModel(cad_name); - initFromPose(I, cMo); + initFromPose(I, cMo_); } /*! @@ -1727,8 +1744,8 @@ vpMbEdgeTracker::getNbPoints(const unsigned int level) const l = *it; if (l->isVisible() && l->meline != NULL) { - for(std::list<vpMeSite>::const_iterator it=l->meline->getMeList().begin(); it!=l->meline->getMeList().end(); ++it){ - if (it->getState() == vpMeSite::NO_SUPPRESSION) nbGoodPoints++; + for(std::list<vpMeSite>::const_iterator itme=l->meline->getMeList().begin(); itme!=l->meline->getMeList().end(); ++itme){ + if (itme->getState() == vpMeSite::NO_SUPPRESSION) nbGoodPoints++; } } } @@ -1738,11 +1755,11 @@ vpMbEdgeTracker::getNbPoints(const unsigned int level) const cy = *it; if (cy->meline1 != NULL || cy->meline2 != NULL) { - for(std::list<vpMeSite>::const_iterator it=cy->meline1->getMeList().begin(); it!=cy->meline1->getMeList().end(); ++it){ - if (it->getState() == vpMeSite::NO_SUPPRESSION) nbGoodPoints++; + for(std::list<vpMeSite>::const_iterator itme1=cy->meline1->getMeList().begin(); itme1!=cy->meline1->getMeList().end(); ++itme1){ + if (itme1->getState() == vpMeSite::NO_SUPPRESSION) nbGoodPoints++; } - for(std::list<vpMeSite>::const_iterator it=cy->meline2->getMeList().begin(); it!=cy->meline2->getMeList().end(); ++it){ - if (it->getState() == vpMeSite::NO_SUPPRESSION) nbGoodPoints++; + for(std::list<vpMeSite>::const_iterator itme2=cy->meline2->getMeList().begin(); itme2!=cy->meline2->getMeList().end(); ++itme2){ + if (itme2->getState() == vpMeSite::NO_SUPPRESSION) nbGoodPoints++; } } } @@ -1799,18 +1816,18 @@ vpMbEdgeTracker::getNbPolygon() const \warning At least one level must be activated. - \param scales : The vector describing the levels to use. + \param scale : The vector describing the levels to use. */ void -vpMbEdgeTracker::setScales(const std::vector<bool>& scales) +vpMbEdgeTracker::setScales(const std::vector<bool>& scale) { unsigned int nbActivatedLevels = 0; - for (unsigned int i = 0; i < scales.size(); i += 1){ - if(scales[i]){ + for (unsigned int i = 0; i < scale.size(); i += 1){ + if(scale[i]){ nbActivatedLevels++; } } - if((scales.size() < 1) || (nbActivatedLevels == 0)){ + if((scale.size() < 1) || (nbActivatedLevels == 0)){ vpERROR_TRACE(" !! WARNING : must use at least one level for the tracking. Use the global one"); this->scales.resize(0); this->scales.push_back(true); @@ -1820,9 +1837,9 @@ vpMbEdgeTracker::setScales(const std::vector<bool>& scales) cylinders[0].clear(); } else{ - this->scales = scales; - lines.resize(scales.size()); - cylinders.resize(scales.size()); + this->scales = scale; + lines.resize(scale.size()); + cylinders.resize(scale.size()); for (unsigned int i = 0; i < lines.size(); i += 1){ lines[i].clear(); cylinders[i].clear(); diff --git a/src/tracking/mbt/edge/vpMbEdgeTracker.h b/src/tracking/mbt/edge/vpMbEdgeTracker.h index ca5c29da2b8cb1ed4c3ddd79c272b31f14661ed1..6935b6df5e8399d2f3448dd2f924c14b8cc273f1 100644 --- a/src/tracking/mbt/edge/vpMbEdgeTracker.h +++ b/src/tracking/mbt/edge/vpMbEdgeTracker.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMbEdgeTracker.h 4338 2013-07-23 14:29:30Z fspindle $ + * $Id: vpMbEdgeTracker.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -380,7 +380,7 @@ public: \return an instance of the moving edge parameters used by the tracker. */ - inline void getMovingEdge(vpMe &me ) const { me = this->me;} + inline void getMovingEdge(vpMe &p_me ) const { p_me = this->me;} /*! Get the near distance for clipping. @@ -439,10 +439,10 @@ public: /*! Set the camera parameters. - \param cam : the new camera parameters + \param camera : the new camera parameters */ - virtual void setCameraParameters(const vpCameraParameters& cam) { - this->cam = cam; + virtual void setCameraParameters(const vpCameraParameters& camera) { + this->cam = camera; for (unsigned int i = 0; i < scales.size(); i += 1){ if(scales[i]){ @@ -487,9 +487,9 @@ public: /*! Set the value of the gain used to compute the control law. - \param lambda : the desired value for the gain. + \param gain : the desired value for the gain. */ - virtual inline void setLambda(const double lambda) {this->lambda = lambda;} + virtual inline void setLambda(const double gain) {this->lambda = gain;} void setMovingEdge(const vpMe &me); @@ -511,7 +511,7 @@ protected: void computeVVS(const vpImage<unsigned char>& _I); void downScale(const unsigned int _scale); void init(const vpImage<unsigned char>& I); - virtual void initCylinder(const vpPoint& _p1, const vpPoint _p2, const double _radius, const unsigned int _indexCylinder=0); + virtual void initCylinder(const vpPoint& p1, const vpPoint &p2, const double radius, const unsigned int indexCylinder=0); virtual void initFaceFromCorners(const std::vector<vpPoint>& _corners, const unsigned int _indexFace = -1); void initMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &_cMo) ; void initPyramid(const vpImage<unsigned char>& _I, std::vector<const vpImage<unsigned char>* >& _pyramid); diff --git a/src/tracking/mbt/edge/vpMbtDistanceCylinder.cpp b/src/tracking/mbt/edge/vpMbtDistanceCylinder.cpp index d7d08dcb025d30c7486bf13b78d41a61484f00f8..ec401b7ee98b91fe2ee7b0938e1970bbe6bd9626 100755 --- a/src/tracking/mbt/edge/vpMbtDistanceCylinder.cpp +++ b/src/tracking/mbt/edge/vpMbtDistanceCylinder.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMbtDistanceCylinder.cpp 4303 2013-07-04 14:14:00Z fspindle $ + * $Id: vpMbtDistanceCylinder.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -64,22 +64,12 @@ Basic constructor */ vpMbtDistanceCylinder::vpMbtDistanceCylinder() + : name(), index(0), cam(), me(NULL), alpha(0), wmean1(1), wmean2(1), + featureline1(), featureline2(), meline1(NULL), meline2(NULL), + cercle1(NULL), cercle2(NULL), radius(0), p1(NULL), p2(NULL), L(), + error(), nbFeature(0), nbFeaturel1(0), nbFeaturel2(0), Reinit(false), + c(NULL) { - name = ""; - p1 = NULL ; - p2 = NULL ; - c = NULL ; - meline1 = NULL ; - meline2 = NULL ; - wmean1 = 1 ; - wmean2 = 1 ; - nbFeaturel1 =0 ; - nbFeaturel2 =0 ; - nbFeature =0 ; - Reinit = false; - - cercle1 = NULL; - cercle2 = NULL; } /*! @@ -497,12 +487,13 @@ vpMbtDistanceCylinder::reinitMovingEdge(const vpImage<unsigned char> &I, const v \param I : The image. \param cMo : Pose used to project the 3D model into the image. - \param cam : The camera parameters. + \param camera : The camera parameters. \param col : The desired color. \param thickness : The thickness of the lines. */ void -vpMbtDistanceCylinder::display(const vpImage<unsigned char>&I, const vpHomogeneousMatrix &cMo, const vpCameraParameters&cam, const vpColor col, const unsigned int thickness) +vpMbtDistanceCylinder::display(const vpImage<unsigned char>&I, const vpHomogeneousMatrix &cMo, + const vpCameraParameters&camera, const vpColor col, const unsigned int thickness) { // Perspective projection p1->changeFrame(cMo); @@ -527,8 +518,8 @@ vpMbtDistanceCylinder::display(const vpImage<unsigned char>&I, const vpHomogeneo double rho2,theta2; // Meters to pixels conversion - vpMeterPixelConversion::convertLine(cam,c->getRho1(),c->getTheta1(),rho1,theta1); - vpMeterPixelConversion::convertLine(cam,c->getRho2(),c->getTheta2(),rho2,theta2); + vpMeterPixelConversion::convertLine(camera,c->getRho1(),c->getTheta1(),rho1,theta1); + vpMeterPixelConversion::convertLine(camera,c->getRho2(),c->getTheta2(),rho2,theta2); // Determine intersections between circles and limbos double i11,i12,i21,i22,j11,j12,j21,j22; @@ -556,12 +547,13 @@ vpMbtDistanceCylinder::display(const vpImage<unsigned char>&I, const vpHomogeneo \param I : The image. \param cMo : Pose used to project the 3D model into the image. - \param cam : The camera parameters. + \param camera : The camera parameters. \param col : The desired color. \param thickness : The thickness of the lines. */ void -vpMbtDistanceCylinder::display(const vpImage<vpRGBa>&I, const vpHomogeneousMatrix &cMo, const vpCameraParameters&cam, const vpColor col, const unsigned int thickness) +vpMbtDistanceCylinder::display(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, + const vpCameraParameters &camera, const vpColor col, const unsigned int thickness) { // Perspective projection p1->changeFrame(cMo); @@ -586,8 +578,8 @@ vpMbtDistanceCylinder::display(const vpImage<vpRGBa>&I, const vpHomogeneousMatri double rho2,theta2; // Meters to pixels conversion - vpMeterPixelConversion::convertLine(cam,c->getRho1(),c->getTheta1(),rho1,theta1); - vpMeterPixelConversion::convertLine(cam,c->getRho2(),c->getTheta2(),rho2,theta2); + vpMeterPixelConversion::convertLine(camera,c->getRho1(),c->getTheta1(),rho1,theta1); + vpMeterPixelConversion::convertLine(camera,c->getRho2(),c->getTheta2(),rho2,theta2); // Determine intersections between circles and limbos double i11,i12,i21,i22,j11,j12,j21,j22; diff --git a/src/tracking/mbt/edge/vpMbtDistanceCylinder.h b/src/tracking/mbt/edge/vpMbtDistanceCylinder.h index fe9423199b725927c9090ad2521fb1507d549117..ec448b7e1843b8c9a59af167459f5038575eba9f 100755 --- a/src/tracking/mbt/edge/vpMbtDistanceCylinder.h +++ b/src/tracking/mbt/edge/vpMbtDistanceCylinder.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMbtDistanceCylinder.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMbtDistanceCylinder.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -126,9 +126,9 @@ class VISP_EXPORT vpMbtDistanceCylinder /*! Get the camera paramters. - \param cam : The vpCameraParameters used to store the camera parameters. + \param camera : The vpCameraParameters used to store the camera parameters. */ - inline void getCameraParameters(vpCameraParameters& cam) {cam = this->cam;} + inline void getCameraParameters(vpCameraParameters& camera) {camera = this->cam;} /*! Get the index of the cylinder. @@ -168,9 +168,9 @@ class VISP_EXPORT vpMbtDistanceCylinder /*! Set the camera paramters. - \param cam : The camera parameters. + \param camera : The camera parameters. */ - inline void setCameraParameters(const vpCameraParameters& cam) {this->cam = cam;} + inline void setCameraParameters(const vpCameraParameters& camera) {this->cam = camera;} /*! Set the index of the cylinder. @@ -198,18 +198,17 @@ class VISP_EXPORT vpMbtDistanceCylinder /*! Set the name of the cylinder. - \param name : The name of the cylinder. + \param cyl_name : The name of the cylinder. */ - inline void setName(const std::string& name) {this->name = name;} + inline void setName(const std::string& cyl_name) {this->name = cyl_name;} /*! Set the name of the cylinder. - \param name : The name of the cylinder + \param cyl_name : The name of the cylinder */ - inline void setName(const char* name) {this->name = name;} + inline void setName(const char* cyl_name) {this->name = std::string(cyl_name);} - void trackMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo); void updateMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo); diff --git a/src/tracking/mbt/edge/vpMbtDistanceLine.cpp b/src/tracking/mbt/edge/vpMbtDistanceLine.cpp index afa9fc6bad11721e1cca5012cfee1ba9ad3ada83..876b32bc336f1a4e77a7a7beb5269e1feaa544ca 100644 --- a/src/tracking/mbt/edge/vpMbtDistanceLine.cpp +++ b/src/tracking/mbt/edge/vpMbtDistanceLine.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMbtDistanceLine.cpp 4311 2013-07-16 15:02:57Z ayol $ + * $Id: vpMbtDistanceLine.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -53,21 +53,18 @@ #include <visp/vpFeatureBuilder.h> #include <stdlib.h> +void buildPlane(vpPoint &P, vpPoint &Q, vpPoint &R, vpPlane &plane); +void buildLine(vpPoint &P1, vpPoint &P2, vpPoint &P3, vpPoint &P4, vpLine &L); + /*! Basic constructor */ vpMbtDistanceLine::vpMbtDistanceLine() + : name(), index(0), cam(), me(NULL), alpha(0), wmean(1), + featureline(), poly(), meline(NULL), line(NULL), p1(NULL), p2(NULL), L(), + error(), nbFeature(0), Reinit(false), hiddenface(NULL), Lindex_polygon(), + isvisible(false) { - name = ""; - p1 = NULL ; - p2 = NULL ; - line = NULL ; - meline = NULL ; - hiddenface = NULL ; - wmean = 1 ; - nbFeature =0 ; - Reinit = false; - isvisible = false; } /*! @@ -430,20 +427,21 @@ vpMbtDistanceLine::reinitMovingEdge(const vpImage<unsigned char> &I, const vpHom \param I : The image. \param cMo : Pose used to project the 3D model into the image. - \param cam : The camera parameters. + \param camera : The camera parameters. \param col : The desired color. \param thickness : The thickness of the line. \param displayFullModel : If true, the line is displayed even if it is not visible. */ void -vpMbtDistanceLine::display(const vpImage<unsigned char>&I, const vpHomogeneousMatrix &cMo, const vpCameraParameters&cam, const vpColor col, const unsigned int thickness, const bool displayFullModel) +vpMbtDistanceLine::display(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, + const vpCameraParameters &camera, const vpColor col, const unsigned int thickness, const bool displayFullModel) { p1->changeFrame(cMo); p2->changeFrame(cMo); if(isvisible || displayFullModel){ vpImagePoint ip1, ip2; - vpCameraParameters c = cam; + vpCameraParameters c = camera; if(poly.getClipping() > 3) // Contains at least one FOV constraint c.computeFov(I.getWidth(), I.getHeight()); @@ -470,20 +468,22 @@ vpMbtDistanceLine::display(const vpImage<unsigned char>&I, const vpHomogeneousMa \param I : The image. \param cMo : Pose used to project the 3D model into the image. - \param cam : The camera parameters. + \param camera : The camera parameters. \param col : The desired color. \param thickness : The thickness of the line. \param displayFullModel : If true, the line is displayed even if it is not visible. */ void -vpMbtDistanceLine::display(const vpImage<vpRGBa>&I, const vpHomogeneousMatrix &cMo, const vpCameraParameters&cam, const vpColor col, const unsigned int thickness, const bool displayFullModel) +vpMbtDistanceLine::display(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, + const vpCameraParameters &camera, const vpColor col, + const unsigned int thickness, const bool displayFullModel) { p1->changeFrame(cMo); p2->changeFrame(cMo); if(isvisible || displayFullModel){ vpImagePoint ip1, ip2; - vpCameraParameters c = cam; + vpCameraParameters c = camera; if(poly.getClipping() > 3) // Contains at least one FOV constraint c.computeFov(I.getWidth(), I.getHeight()); @@ -566,7 +566,7 @@ vpMbtDistanceLine::computeInteractionMatrixError(const vpHomogeneousMatrix &cMo) double xc = cam.get_u0() ; double yc = cam.get_v0() ; - double alpha ; + double alpha_ ; vpMatrix H ; H = featureline.interaction() ; @@ -580,14 +580,14 @@ vpMbtDistanceLine::computeInteractionMatrixError(const vpHomogeneousMatrix &cMo) x = (x-xc)*mx ; y = (y-yc)*my ; - alpha = x*si - y*co; + alpha_ = x*si - y*co; double *Lrho = H[0] ; double *Ltheta = H[1] ; // Calculate interaction matrix for a distance for (unsigned int k=0 ; k < 6 ; k++) { - L[j][k] = (Lrho[k] + alpha*Ltheta[k]); + L[j][k] = (Lrho[k] + alpha_*Ltheta[k]); } error[j] = rho - ( x*co + y*si) ; j++; diff --git a/src/tracking/mbt/edge/vpMbtDistanceLine.h b/src/tracking/mbt/edge/vpMbtDistanceLine.h index 925504b12ab14124ab82a4c2a8900e4fd1a2b82f..ad0d2af148057c6dac2ec5cf59673f7cfd8034cd 100644 --- a/src/tracking/mbt/edge/vpMbtDistanceLine.h +++ b/src/tracking/mbt/edge/vpMbtDistanceLine.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMbtDistanceLine.h 4337 2013-07-23 13:57:53Z ayol $ + * $Id: vpMbtDistanceLine.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -119,9 +119,9 @@ class VISP_EXPORT vpMbtDistanceLine /*! Get the camera paramters. - \param cam : The vpCameraParameters used to store the camera parameters. + \param camera : The vpCameraParameters used to store the camera parameters. */ - inline void getCameraParameters(vpCameraParameters& cam) const {cam = this->cam;} + inline void getCameraParameters(vpCameraParameters& camera) const {camera = this->cam;} /*! Get the index of the line. @@ -167,9 +167,9 @@ class VISP_EXPORT vpMbtDistanceLine /*! Set the camera paramters. - \param cam : The camera parameters. + \param camera : The camera parameters. */ - inline void setCameraParameters(const vpCameraParameters& cam) {this->cam = cam;} + inline void setCameraParameters(const vpCameraParameters& camera) {this->cam = camera;} /*! Set the index of the line. @@ -181,25 +181,25 @@ class VISP_EXPORT vpMbtDistanceLine /*! Set the mean weight of the line. - \param wmean : The mean weight of the line. + \param w_mean : The mean weight of the line. */ - inline void setMeanWeight(const double wmean) {this->wmean = wmean;} + inline void setMeanWeight(const double w_mean) {this->wmean = w_mean;} void setMovingEdge(vpMe *Me); /*! Set the name of the line. - \param name : The name of the line. + \param line_name : The name of the line. */ - inline void setName(const std::string name) {this->name = name;} + inline void setName(const std::string line_name) {this->name = line_name;} /*! Set the name of the line. - \param name : The name of the line. + \param line_name : The name of the line. */ - inline void setName(const char* name) {this->name = name;} + inline void setName(const char* line_name) {this->name = std::string(line_name);} /*! Set a boolean parameter to indicates if the line is visible in the image or not. @@ -213,7 +213,7 @@ class VISP_EXPORT vpMbtDistanceLine void updateMovingEdge(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo); private: - void belongToPolygon(int index) { Lindex_polygon.push_back(index); } + void belongToPolygon(int index_) { Lindex_polygon.push_back(index_); } void project(const vpHomogeneousMatrix &cMo); void setFace( vpMbHiddenFaces<vpMbtPolygon> *_hiddenface) { hiddenface = _hiddenface ; } diff --git a/src/tracking/mbt/edge/vpMbtMeLine.cpp b/src/tracking/mbt/edge/vpMbtMeLine.cpp index 9754263a8eec73e1259f5fd2f520c228b9cda850..7c2cea16902219661e2e1e724d42f1ba955a71e6 100644 --- a/src/tracking/mbt/edge/vpMbtMeLine.cpp +++ b/src/tracking/mbt/edge/vpMbtMeLine.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMbtMeLine.cpp 4303 2013-07-04 14:14:00Z fspindle $ + * $Id: vpMbtMeLine.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -66,10 +66,11 @@ normalizeAngle(double &delta) /*! Basic constructor that calls the constructor of the class vpMeTracker. */ -vpMbtMeLine::vpMbtMeLine():vpMeTracker() +vpMbtMeLine::vpMbtMeLine() + : rho(0.), theta(0.), theta_1(M_PI/2), delta(0.), delta_1(0), sign(1), + a(0.), b(0.), c(0.), imin(0), imax(0), jmin(0), jmax(0), + expecteddensity(0.) { - sign = 1; - theta_1 = M_PI/2; } /*! @@ -89,11 +90,12 @@ vpMbtMeLine::~vpMbtMeLine() \param I : Image in which the line appears. \param ip1 : Coordinates of the first point. \param ip2 : Coordinates of the second point. - \param rho : The \f$\rho\f$ parameter - \param theta : The \f$\theta\f$ parameter + \param rho_ : The \f$\rho\f$ parameter + \param theta_ : The \f$\theta\f$ parameter */ void -vpMbtMeLine::initTracking(const vpImage<unsigned char> &I, const vpImagePoint &ip1, const vpImagePoint &ip2, double rho, double theta) +vpMbtMeLine::initTracking(const vpImage<unsigned char> &I, const vpImagePoint &ip1, const vpImagePoint &ip2, + double rho_, double theta_) { vpCDEBUG(1) <<" begin vpMeLine::initTracking()"<<std::endl ; @@ -106,8 +108,8 @@ vpMbtMeLine::initTracking(const vpImage<unsigned char> &I, const vpImagePoint &i PExt[1].ifloat = (float)ip2.get_i() ; PExt[1].jfloat = (float)ip2.get_j() ; - this->rho = rho; - this->theta = theta; + this->rho = rho_; + this->theta = theta_; a = cos(theta); b = sin(theta); @@ -287,7 +289,7 @@ vpMbtMeLine::seekExtremities(const vpImage<unsigned char> &I) // number of samples along line_p n_sample = length_p/(double)me->getSampleStep(); - double sample = (double)me->getSampleStep(); + double sample_step = (double)me->getSampleStep(); vpMeSite P ; P.init((int) PExt[0].ifloat, (int)PExt[0].jfloat, delta_1, 0, sign) ; @@ -298,8 +300,8 @@ vpMbtMeLine::seekExtremities(const vpImage<unsigned char> &I) for (int i=0 ; i < 3 ; i++) { - P.ifloat = P.ifloat + di*sample ; P.i = (int)P.ifloat ; - P.jfloat = P.jfloat + dj*sample ; P.j = (int)P.jfloat ; + P.ifloat = P.ifloat + di*sample_step ; P.i = (int)P.ifloat ; + P.jfloat = P.jfloat + dj*sample_step ; P.j = (int)P.jfloat ; if ((P.i < imin) ||(P.i > imax) || (P.j < jmin) || (P.j > jmax) ) @@ -325,8 +327,8 @@ vpMbtMeLine::seekExtremities(const vpImage<unsigned char> &I) P.setDisplay(selectDisplay) ; for (int i=0 ; i < 3 ; i++) { - P.ifloat = P.ifloat - di*sample ; P.i = (int)P.ifloat ; - P.jfloat = P.jfloat - dj*sample ; P.j = (int)P.jfloat ; + P.ifloat = P.ifloat - di*sample_step ; P.i = (int)P.ifloat ; + P.jfloat = P.jfloat - dj*sample_step ; P.j = (int)P.jfloat ; if ((P.i < imin) ||(P.i > imax) || (P.j < jmin) || (P.j > jmax) ) @@ -371,9 +373,9 @@ vpMbtMeLine::reSample(const vpImage<unsigned char> &I) double d = sqrt(vpMath::sqr(PExt[0].ifloat-PExt[1].ifloat)+vpMath::sqr(PExt[0].jfloat-PExt[1].jfloat)) ; unsigned int n = numberOfSignal() ; - double expecteddensity = d / (double)me->getSampleStep(); + double expected_density = d / (double)me->getSampleStep(); - if ((double)n<0.5*expecteddensity && n > 0) + if ((double)n<0.5*expected_density && n > 0) { double delta_new = delta; delta = delta_1; @@ -427,7 +429,7 @@ vpMbtMeLine::reSample(const vpImage<unsigned char> &I, vpImagePoint ip1, vpImage void vpMbtMeLine::updateDelta() { - vpMeSite p ; + vpMeSite p_me ; double diff = 0; @@ -447,10 +449,10 @@ vpMbtMeLine::updateDelta() normalizeAngle(delta); for(std::list<vpMeSite>::iterator it=list.begin(); it!=list.end(); ++it){ - p = *it; - p.alpha = delta ; - p.mask_sign = sign; - *it = p; + p_me = *it; + p_me.alpha = delta ; + p_me.mask_sign = sign; + *it = p_me; } delta_1 = delta; } @@ -483,14 +485,14 @@ vpMbtMeLine::track(const vpImage<unsigned char> &I) Update the moving edges parameters after the virtual visual servoing. \param I : The image. - \param rho : The \f$\rho\f$ parameter used in the line's polar equation. - \param theta : The \f$\theta\f$ parameter used in the line's polar equation. + \param rho_ : The \f$\rho\f$ parameter used in the line's polar equation. + \param theta_ : The \f$\theta\f$ parameter used in the line's polar equation. */ void -vpMbtMeLine::updateParameters(const vpImage<unsigned char> &I, double rho, double theta) +vpMbtMeLine::updateParameters(const vpImage<unsigned char> &I, double rho_, double theta_) { - this->rho = rho; - this->theta = theta; + this->rho = rho_; + this->theta = theta_; a = cos(theta); b = sin(theta); c = -rho; @@ -514,14 +516,15 @@ vpMbtMeLine::updateParameters(const vpImage<unsigned char> &I, double rho, doubl \param I : The image. \param ip1 : The first extremity of the line. \param ip2 : The second extremity of the line. - \param rho : The \f$\rho\f$ parameter used in the line's polar equation. - \param theta : The \f$\theta\f$ parameter used in the line's polar equation. + \param rho_ : The \f$\rho\f$ parameter used in the line's polar equation. + \param theta_ : The \f$\theta\f$ parameter used in the line's polar equation. */ void -vpMbtMeLine::updateParameters(const vpImage<unsigned char> &I, vpImagePoint ip1, vpImagePoint ip2, double rho, double theta) +vpMbtMeLine::updateParameters(const vpImage<unsigned char> &I, vpImagePoint ip1, vpImagePoint ip2, + double rho_, double theta_) { - this->rho = rho; - this->theta = theta; + this->rho = rho_; + this->theta = theta_; a = cos(theta); b = sin(theta); c = -rho; @@ -545,58 +548,58 @@ vpMbtMeLine::updateParameters(const vpImage<unsigned char> &I, vpImagePoint ip1, void vpMbtMeLine::setExtremities() { - double imin = +1e6 ; - double jmin = +1e6; - double imax = -1 ; - double jmax = -1 ; + double i_min = +1e6 ; + double j_min = +1e6; + double i_max = -1 ; + double j_max = -1 ; // Loop through list of sites to track for(std::list<vpMeSite>::const_iterator it=list.begin(); it!=list.end(); ++it){ vpMeSite s = *it;//current reference pixel - if (s.ifloat < imin) + if (s.ifloat < i_min) { - imin = s.ifloat ; - jmin = s.jfloat ; + i_min = s.ifloat ; + j_min = s.jfloat ; } - if (s.ifloat > imax) + if (s.ifloat > i_max) { - imax = s.ifloat ; - jmax = s.jfloat ; + i_max = s.ifloat ; + j_max = s.jfloat ; } } if ( ! list.empty() ) { - PExt[0].ifloat = imin ; - PExt[0].jfloat = jmin ; - PExt[1].ifloat = imax ; - PExt[1].jfloat = jmax ; + PExt[0].ifloat = i_min ; + PExt[0].jfloat = j_min ; + PExt[1].ifloat = i_max ; + PExt[1].jfloat = j_max ; } - if (fabs(imin-imax) < 25) + if (fabs(i_min-i_max) < 25) { for(std::list<vpMeSite>::const_iterator it=list.begin(); it!=list.end(); ++it){ vpMeSite s = *it;//current reference pixel - if (s.jfloat < jmin) + if (s.jfloat < j_min) { - imin = s.ifloat ; - jmin = s.jfloat ; + i_min = s.ifloat ; + j_min = s.jfloat ; } - if (s.jfloat > jmax) + if (s.jfloat > j_max) { - imax = s.ifloat ; - jmax = s.jfloat ; + i_max = s.ifloat ; + j_max = s.jfloat ; } } if (! list.empty()) { - PExt[0].ifloat = imin ; - PExt[0].jfloat = jmin ; - PExt[1].ifloat = imax ; - PExt[1].jfloat = jmax ; + PExt[0].ifloat = i_min ; + PExt[0].jfloat = j_min ; + PExt[1].ifloat = i_max ; + PExt[1].jfloat = j_max ; } bubbleSortJ(); } @@ -661,7 +664,7 @@ vpMbtMeLine::bubbleSortJ() void -vpMbtMeLine::findSignal(const vpImage<unsigned char>& I, const vpMe *me, double *conv) +vpMbtMeLine::findSignal(const vpImage<unsigned char>& I, const vpMe *p_me, double *conv) { vpImagePoint itest(PExt[0].ifloat+(PExt[1].ifloat-PExt[0].ifloat)/2, PExt[0].jfloat+(PExt[1].jfloat-PExt[0].jfloat)/2); @@ -670,7 +673,7 @@ vpMbtMeLine::findSignal(const vpImage<unsigned char>& I, const vpMe *me, double vpMeSite *list_query_pixels; // double convolution = 0; - unsigned int range = me->getRange(); + unsigned int range = p_me->getRange(); list_query_pixels = pix.getQueryList(I, (int)range); @@ -680,7 +683,7 @@ vpMbtMeLine::findSignal(const vpImage<unsigned char>& I, const vpMe *me, double for(unsigned int n = 0 ; n < 2 * range + 1 ; n++) { - conv[n] = list_query_pixels[n].convolution(I, me); + conv[n] = list_query_pixels[n].convolution(I, p_me); } delete [] list_query_pixels; } diff --git a/src/tracking/mbt/edge/vpMbtMeLine.h b/src/tracking/mbt/edge/vpMbtMeLine.h index a3ebfcb09bf128e81594dcbb9bdb40fdc533e886..8cdaaa009e293bbc1509cb5298bb2eecc3197764 100644 --- a/src/tracking/mbt/edge/vpMbtMeLine.h +++ b/src/tracking/mbt/edge/vpMbtMeLine.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMbtMeLine.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMbtMeLine.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/tracking/mbt/edge/vpMbtPolygon.cpp b/src/tracking/mbt/edge/vpMbtPolygon.cpp index d605fa8ce907b27e3fb3c430a5fdd13dcec975d6..c5c87c8300661e4ea96678413d1102c9b4c381ab 100644 --- a/src/tracking/mbt/edge/vpMbtPolygon.cpp +++ b/src/tracking/mbt/edge/vpMbtPolygon.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMbtPolygon.cpp 4319 2013-07-17 10:04:09Z ayol $ + * $Id: vpMbtPolygon.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -56,17 +56,37 @@ Basic constructor. */ vpMbtPolygon::vpMbtPolygon() + : index(-1), nbpt(0), nbCornersInsidePrev(0), isvisible(false), isappearing(false), + p(NULL), roiPointsClip(), clippingFlag(vpMbtPolygon::NO_CLIPPING), + distNearClip(0.001), distFarClip(100.) { - nbpt = 0 ; - p = NULL ; - isappearing = false; - isvisible = false; - nbCornersInsidePrev = 0; - - distNearClip = 0.001; - distFarClip = 100.0; - - clippingFlag = vpMbtPolygon::NO_CLIPPING; +} + +vpMbtPolygon::vpMbtPolygon(const vpMbtPolygon& mbtp) + : index(-1), nbpt(0), nbCornersInsidePrev(0), isvisible(false), isappearing(false), + p(NULL), roiPointsClip(), clippingFlag(vpMbtPolygon::NO_CLIPPING), + distNearClip(0.001), distFarClip(100.) +{ + *this = mbtp; +} + +vpMbtPolygon& vpMbtPolygon::operator=(const vpMbtPolygon& mbtp) +{ + index = mbtp.index; + nbpt = mbtp.nbpt; + nbCornersInsidePrev = mbtp.nbCornersInsidePrev; + isvisible = mbtp.isvisible; + isappearing = mbtp.isappearing; + roiPointsClip = mbtp.roiPointsClip; + clippingFlag = mbtp.clippingFlag; + distNearClip = mbtp.distFarClip; + + if (p) delete [] p; + p = new vpPoint [nbpt]; + for(unsigned int i = 0; i < nbpt; i++) + p[i] = mbtp.p[i]; + + return (*this); } /*! diff --git a/src/tracking/mbt/edge/vpMbtPolygon.h b/src/tracking/mbt/edge/vpMbtPolygon.h index 1109ac6ef189716fb5a4027ce26b6b6e1baa5efc..75283e9ce65f9313a248e2e716d0bce2a83bd5f4 100644 --- a/src/tracking/mbt/edge/vpMbtPolygon.h +++ b/src/tracking/mbt/edge/vpMbtPolygon.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMbtPolygon.h 4331 2013-07-22 12:37:11Z ayol $ + * $Id: vpMbtPolygon.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -81,7 +81,7 @@ public: } vpMbtPolygonClippingType; public: - //! Index of the polygon. Cannot be unsigned int because deafult value is -1. + //! Index of the polygon. Cannot be unsigned int because default value is -1. int index; //! Number of points used to define the polygon. unsigned int nbpt; @@ -115,7 +115,8 @@ private: const vpCameraParameters &cam, const std::vector<vpColVector> &fovNormals); public: - vpMbtPolygon() ; + vpMbtPolygon() ; + vpMbtPolygon(const vpMbtPolygon& mbtp) ; virtual ~vpMbtPolygon() ; void addPoint(const unsigned int n, const vpPoint &P) ; @@ -187,7 +188,9 @@ public: inline bool isAppearing() const {return isappearing;} virtual bool isVisible(const vpHomogeneousMatrix &cMo, const double alpha, const bool &modulo = false) ; bool isVisible() const {return isvisible;} - + + vpMbtPolygon& operator=(const vpMbtPolygon& mbtp) ; + /*! Specify which clipping to use. diff --git a/src/tracking/mbt/edge/vpMbtXmlParser.cpp b/src/tracking/mbt/edge/vpMbtXmlParser.cpp index ace2eff552e817ce4989c3b951295150c8ff3412..8dd9cf2438ce53eb99825f1096485107b36d46fd 100644 --- a/src/tracking/mbt/edge/vpMbtXmlParser.cpp +++ b/src/tracking/mbt/edge/vpMbtXmlParser.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMbtXmlParser.cpp 4320 2013-07-17 15:37:27Z ayol $ + * $Id: vpMbtXmlParser.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -32,12 +32,13 @@ * * * Description: - * Make the complete tracking of an object by using its CAD model + * Load XML parameters of the Model based tracker (using edges). * * Authors: * Nicolas Melchior * Romain Tallonneau * Eric Marchand + * Aurelien Yol * *****************************************************************************/ #include <visp/vpConfig.h> @@ -57,11 +58,8 @@ Default constructor. */ -vpMbtXmlParser::vpMbtXmlParser() +vpMbtXmlParser::vpMbtXmlParser() : m_ecm() { - hasNearClipping = false; - hasFarClipping = false; - fovClipping = false; init(); } @@ -78,9 +76,8 @@ vpMbtXmlParser::~vpMbtXmlParser() void vpMbtXmlParser::init() { - setMainTag("conf"); + vpMbXmlParser::init(); - nodeMap["conf"] = conf; nodeMap["ecm"] = ecm; nodeMap["mask"] = mask; nodeMap["size"] = size; @@ -94,20 +91,6 @@ vpMbtXmlParser::init() nodeMap["sample"] = sample; nodeMap["step"] = step; nodeMap["nb_sample"] = nb_sample; - nodeMap["face"] = face; - nodeMap["angle_appear"] = angle_appear; - nodeMap["angle_disappear"] = angle_disappear; - nodeMap["near_clipping"] = near_clipping; - nodeMap["far_clipping"] = far_clipping; - nodeMap["fov_clipping"] = fov_clipping; - nodeMap["camera"] = camera; - nodeMap["height"] = height; - nodeMap["width"] = width; - nodeMap["u0"] = u0; - nodeMap["v0"] = v0; - nodeMap["px"] = px; - nodeMap["py"] = py; - } /*! @@ -144,24 +127,16 @@ vpMbtXmlParser::writeMainClass(xmlNodePtr /*node*/) void vpMbtXmlParser::readMainClass(xmlDocPtr doc, xmlNodePtr node) { - bool ecm_node = false; - bool sample_node = false; bool camera_node = false; bool face_node = false; + bool ecm_node = false; + bool sample_node = false; for(xmlNodePtr dataNode = node->xmlChildrenNode; dataNode != NULL; dataNode = dataNode->next) { if(dataNode->type == XML_ELEMENT_NODE){ std::map<std::string, int>::iterator iter_data= this->nodeMap.find((char*)dataNode->name); if(iter_data != nodeMap.end()){ switch (iter_data->second){ - case ecm:{ - this->read_ecm (doc, dataNode); - ecm_node = true; - }break; - case sample:{ - this->read_sample (doc, dataNode); - sample_node = true; - }break; case camera:{ this->read_camera (doc, dataNode); camera_node = true; @@ -170,6 +145,14 @@ vpMbtXmlParser::readMainClass(xmlDocPtr doc, xmlNodePtr node) this->read_face(doc, dataNode); face_node = true; }break; + case ecm:{ + this->read_ecm (doc, dataNode); + ecm_node = true; + }break; + case sample:{ + this->read_sample (doc, dataNode); + sample_node = true; + }break; default:{ // vpTRACE("unknown tag in read_sample : %d, %s", iter_data->second, (iter_data->first).c_str()); }break; @@ -178,17 +161,31 @@ vpMbtXmlParser::readMainClass(xmlDocPtr doc, xmlNodePtr node) } } - if(!ecm_node) - std::cout << "WARNING: ECM Node not specified, default values used" << std::endl; - - if(!sample_node) - std::cout << "WARNING: SAMPLE Node not specified, default values used" << std::endl; - - if(!camera_node) - std::cout << "WARNING: CAMERA Node not specified, default values used" << std::endl; + if(!camera_node) { + std::cout << "camera : u0 : "<< this->cam.get_u0() << " (default)" <<std::endl; + std::cout << "camera : v0 : "<< this->cam.get_v0() << " (default)" <<std::endl; + std::cout << "camera : px : "<< this->cam.get_px() << " (default)" <<std::endl; + std::cout << "camera : py : "<< this->cam.get_py() << " (default)" <<std::endl; + } + + if(!face_node) { + std::cout << "face : Angle Appear : "<< angleAppear <<" (default)" <<std::endl; + std::cout << "face : Angle Disappear : "<< angleDisappear <<" (default)" <<std::endl; + } + + if(!ecm_node) { + std::cout << "ecm : mask : size : "<< this->m_ecm.getMaskSize() << " (default)" <<std::endl; + std::cout << "ecm : mask : nb_mask : "<< this->m_ecm.getMaskNumber() << " (default)" <<std::endl; + std::cout <<"ecm : range : tracking : "<< this->m_ecm.getRange()<< " (default)" <<std::endl; + std::cout <<"ecm : contrast : threshold : " << this->m_ecm.getThreshold()<<" (default)" <<std::endl; + std::cout <<"ecm : contrast : mu1 : " << this->m_ecm.getMu1()<<" (default)" <<std::endl; + std::cout <<"ecm : contrast : mu2 : " << this->m_ecm.getMu2()<<" (default)" <<std::endl; + } - if(!face_node) - std::cout << "WARNING: FACE Node not specified, default values used" << std::endl; + if(!sample_node) { + std::cout <<"sample : sample_step : "<< this->m_ecm.getSampleStep()<< " (default)" << std::endl; + std::cout <<"sample : n_total_sample : "<< this->m_ecm.getNbTotalSample()<< " (default)"<<std::endl; + } } @@ -232,14 +229,20 @@ vpMbtXmlParser::read_ecm (xmlDocPtr doc, xmlNodePtr node) } } - if(!mask_node) - std::cout << "WARNING: In ECM Node, MASK Node not specified, default values used" << std::endl; + if(!mask_node) { + std::cout << "ecm : mask : size : "<< this->m_ecm.getMaskSize() << " (default)" <<std::endl; + std::cout << "ecm : mask : nb_mask : "<< this->m_ecm.getMaskNumber() << " (default)" <<std::endl; + } - if(!range_node) - std::cout << "WARNING: In ECM Node, RANGE Node not specified, default values used" << std::endl; + if(!range_node) { + std::cout <<"ecm : range : tracking : "<< this->m_ecm.getRange()<< " (default)" <<std::endl; + } - if(!contrast_node) - std::cout << "WARNING: In ECM Node, CONTRAST Node not specified, default values used" << std::endl; + if(!contrast_node) { + std::cout <<"ecm : contrast : threshold " << this->m_ecm.getThreshold()<<" (default)" <<std::endl; + std::cout <<"ecm : contrast : mu1 " << this->m_ecm.getMu1()<<" (default)" <<std::endl; + std::cout <<"ecm : contrast : mu2 " << this->m_ecm.getMu2()<<" (default)" <<std::endl; + } } /*! @@ -285,188 +288,14 @@ vpMbtXmlParser::read_sample (xmlDocPtr doc, xmlNodePtr node) this->m_ecm.setNbTotalSample(d_nb_sample); if(!step_node) - std::cout << "WARNING: In SAMPLE Node, STEP Node not specified, default value used : " << this->m_ecm.getSampleStep() << std::endl; + std::cout <<"sample : sample_step : "<< this->m_ecm.getSampleStep()<< " (default)" << std::endl; else - std::cout <<"sample : sample_step "<< this->m_ecm.getSampleStep()<<std::endl; + std::cout <<"sample : sample_step : "<< this->m_ecm.getSampleStep()<<std::endl; if(!nb_sample_node) - std::cout << "WARNING: In SAMPLE Node, NB_SAMPLE Node not specified, default value used : " << this->m_ecm.getNbTotalSample() << std::endl; - else - std::cout <<"sample : n_total_sample "<< this->m_ecm.getNbTotalSample()<<std::endl; -} - -/*! - Read camera information. - - \throw vpException::fatalError if there was an unexpected number of data. - - \param doc : Pointer to the document. - \param node : Pointer to the node of the camera information. -*/ -void -vpMbtXmlParser::read_camera (xmlDocPtr doc, xmlNodePtr node) -{ - bool height_node = false; - bool width_node = false; - bool u0_node = false; - bool v0_node = false; - bool px_node = false; - bool py_node = false; - - // current data values. -// int d_height=0 ; -// int d_width= 0 ; - double d_u0 = this->cam.get_u0(); - double d_v0 = this->cam.get_v0(); - double d_px = this->cam.get_px(); - double d_py = this->cam.get_py(); - - for(xmlNodePtr dataNode = node->xmlChildrenNode; dataNode != NULL; dataNode = dataNode->next) { - if(dataNode->type == XML_ELEMENT_NODE){ - std::map<std::string, int>::iterator iter_data= this->nodeMap.find((char*)dataNode->name); - if(iter_data != nodeMap.end()){ - switch (iter_data->second){ - case height:{ - /* d_height = */ xmlReadIntChild(doc, dataNode); - height_node = true; - }break; - case width:{ - /* d_width = */ xmlReadIntChild(doc, dataNode); - width_node = true; - }break; - case u0:{ - d_u0 = xmlReadDoubleChild(doc, dataNode); - u0_node = true; - }break; - case v0:{ - d_v0 = xmlReadDoubleChild(doc, dataNode); - v0_node = true; - }break; - case px:{ - d_px = xmlReadDoubleChild(doc, dataNode); - px_node = true; - }break; - case py:{ - d_py = xmlReadDoubleChild(doc, dataNode); - py_node = true; - }break; - default:{ -// vpTRACE("unknown tag in read_camera : %d, %s", iter_data->second, (iter_data->first).c_str()); - }break; - } - } - } - } - - this->cam.initPersProjWithoutDistortion(d_px, d_py, d_u0, d_v0) ; - - if(!height_node) - std::cout << "WARNING: In CAMERA Node, HEIGHT Node not specified, default value used" << std::endl; - - if(!width_node) - std::cout << "WARNING: In CAMERA Node, WIDTH Node not specified, default value used" << std::endl; - - if(!u0_node) - std::cout << "WARNING: In CAMERA Node, u0 Node not specified, default value used : " << this->cam.get_u0() << std::endl; - else - std::cout << "camera : u0 "<< this->cam.get_u0() <<std::endl; - - if(!v0_node) - std::cout << "WARNING: In CAMERA Node, v0 Node not specified, default value used : " << this->cam.get_v0() << std::endl; - else - std::cout << "camera : v0 "<< this->cam.get_v0() <<std::endl; - - if(!px_node) - std::cout << "WARNING: In CAMERA Node, px Node not specified, default value used : " << this->cam.get_px() << std::endl; - else - std::cout << "camera : px "<< this->cam.get_px() <<std::endl; - - if(!py_node) - std::cout << "WARNING: In CAMERA Node, py Node not specified, default value used : " << this->cam.get_py() << std::endl; - else - std::cout << "camera : py "<< this->cam.get_py() <<std::endl; -} - -/*! - Read face information. - - \throw vpException::fatalError if there was an unexpected number of data. - - \param doc : Pointer to the document. - \param node : Pointer to the node of the camera information. -*/ -void -vpMbtXmlParser::read_face(xmlDocPtr doc, xmlNodePtr node) -{ - bool angle_appear_node = false; - bool angle_disappear_node = false; - bool near_clipping_node = false; - bool far_clipping_node = false; - bool fov_clipping_node = false; - - for(xmlNodePtr dataNode = node->xmlChildrenNode; dataNode != NULL; dataNode = dataNode->next) { - if(dataNode->type == XML_ELEMENT_NODE){ - std::map<std::string, int>::iterator iter_data= this->nodeMap.find((char*)dataNode->name); - if(iter_data != nodeMap.end()){ - switch (iter_data->second){ - case angle_appear:{ - angleAppear = xmlReadDoubleChild(doc, dataNode); - angle_appear_node = true; - }break; - case angle_disappear:{ - angleDisappear = xmlReadDoubleChild(doc, dataNode); - angle_disappear_node = true; - }break; - case near_clipping:{ - nearClipping = xmlReadDoubleChild(doc, dataNode); - near_clipping_node = true; - hasNearClipping = true; - }break; - case far_clipping:{ - farClipping = xmlReadDoubleChild(doc, dataNode); - far_clipping_node = true; - hasFarClipping = true; - }break; - case fov_clipping:{ - fovClipping = (bool)xmlReadIntChild(doc, dataNode); - fov_clipping_node = true; - }break; - default:{ -// vpTRACE("unknown tag in read_camera : %d, %s", iter_data->second, (iter_data->first).c_str()); - }break; - } - } - } - } - - if(!angle_appear_node) - std::cout << "WARNING: In FACE Node, ANGLE_APPEAR Node not specified, default value used : " << angleAppear << std::endl; - else - std::cout << "face : Angle Appear "<< angleAppear <<std::endl; - - if(!angle_disappear_node) - std::cout << "WARNING: In FACE Node, ANGLE_DESAPPEAR Node not specified, default value used : " << angleDisappear << std::endl; + std::cout <<"sample : n_total_sample : "<< this->m_ecm.getNbTotalSample()<< " (default)"<<std::endl; else - std::cout << "face : Angle Disappear : "<< angleDisappear <<std::endl; - - if(!near_clipping_node) - std::cout << "WARNING: In FACE Node, NEAR_CLIPPING Node not specified, no near clipping used" << std::endl; - else - std::cout << "face : Near Clipping : "<< nearClipping <<std::endl; - - if(!far_clipping_node) - std::cout << "WARNING: In FACE Node, FAR_CLIPPING Node not specified, no far clipping used" << std::endl; - else - std::cout << "face : Far Clipping : "<< farClipping <<std::endl; - - if(!fov_clipping_node) - std::cout << "WARNING: In FACE Node, FOV_CLIPPING Node not specified, no fov clipping used" << std::endl; - else{ - if(fovClipping) - std::cout << "face : Fov Clipping : True" <<std::endl; - else - std::cout << "face : Fov Clipping : False" <<std::endl; - } + std::cout <<"sample : n_total_sample : "<< this->m_ecm.getNbTotalSample()<<std::endl; } /*! @@ -512,14 +341,14 @@ vpMbtXmlParser::read_mask (xmlDocPtr doc, xmlNodePtr node) this->m_ecm.setMaskNumber(d_nb_mask); if(!size_node) - std::cout << "WARNING: In MASK Node, SIZE Node not specified, default value used : " << this->m_ecm.getMaskSize() << std::endl; - else - std::cout << "ecm : mask : size "<< this->m_ecm.getMaskSize() <<std::endl; + std::cout << "ecm : mask : size : "<< this->m_ecm.getMaskSize() << " (default)" <<std::endl; + else + std::cout << "ecm : mask : size : "<< this->m_ecm.getMaskSize() <<std::endl; if(!nb_mask_node) - std::cout << "WARNING: In MASK Node, NB_MASK Node not specified, default value used : " << this->m_ecm.getMaskNumber() << std::endl; + std::cout << "ecm : mask : nb_mask : "<< this->m_ecm.getMaskNumber() << " (default)" <<std::endl; else - std::cout << "ecm : mask : nb_mask "<< this->m_ecm.getMaskNumber() <<std::endl; + std::cout << "ecm : mask : nb_mask : "<< this->m_ecm.getMaskNumber() <<std::endl; } /*! @@ -558,9 +387,9 @@ vpMbtXmlParser::read_range (xmlDocPtr doc, xmlNodePtr node) this->m_ecm.setRange(m_range_tracking); if(!tracking_node) - std::cout << "WARNING: In RANGE Node, TRACKING Node not specified, default value used : " << this->m_ecm.getRange() << std::endl; + std::cout <<"ecm : range : tracking : "<< this->m_ecm.getRange()<< " (default)" <<std::endl; else - std::cout <<"ecm : range : tracking "<< this->m_ecm.getRange()<<std::endl; + std::cout <<"ecm : range : tracking : "<< this->m_ecm.getRange()<<std::endl; } @@ -614,17 +443,17 @@ vpMbtXmlParser::read_contrast (xmlDocPtr doc, xmlNodePtr node) this->m_ecm.setThreshold(d_edge_threshold); if(!edge_threshold_node) - std::cout << "WARNING: In CONTRAST Node, EDGE_THRESHOLD Node not specified, default value used : " << this->m_ecm.getThreshold() << std::endl; + std::cout <<"ecm : contrast : threshold " << this->m_ecm.getThreshold()<<" (default)" <<std::endl; else std::cout <<"ecm : contrast : threshold " << this->m_ecm.getThreshold()<<std::endl; if(!mu1_node) - std::cout << "WARNING: In CONTRAST Node, mu1 Node not specified, default value used : " << this->m_ecm.getMu1() << std::endl; + std::cout <<"ecm : contrast : mu1 " << this->m_ecm.getMu1()<<" (default)" <<std::endl; else std::cout <<"ecm : contrast : mu1 " << this->m_ecm.getMu1()<<std::endl; if(!mu2_node) - std::cout << "WARNING: In CONTRAST Node, mu2 Node not specified, default value used : " << this->m_ecm.getMu2() << std::endl; + std::cout <<"ecm : contrast : mu2 " << this->m_ecm.getMu2()<<" (default)" <<std::endl; else std::cout <<"ecm : contrast : mu2 " << this->m_ecm.getMu2()<<std::endl; } diff --git a/src/tracking/mbt/edge/vpMbtXmlParser.h b/src/tracking/mbt/edge/vpMbtXmlParser.h index 9431ad0142fa27cbf545e314b8f2104f29774753..ed870fecae4bb5026bb4be54000a48ca0d28f062 100644 --- a/src/tracking/mbt/edge/vpMbtXmlParser.h +++ b/src/tracking/mbt/edge/vpMbtXmlParser.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMbtXmlParser.h 4320 2013-07-17 15:37:27Z ayol $ + * $Id: vpMbtXmlParser.h 4582 2014-01-14 14:02:46Z ayol $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -32,12 +32,13 @@ * * * Description: - * Make the complete tracking of an object by using its CAD model + * Load XML parameters of the Model based tracker (using edges). * * Authors: * Nicolas Melchior * Romain Tallonneau * Eric Marchand + * Aurelien Yol * *****************************************************************************/ @@ -55,11 +56,8 @@ #include <libxml/xmlmemory.h> /* Fonctions de la lib XML. */ -#include <visp/vpXmlParser.h> +#include <visp/vpMbXmlParser.h> #include <visp/vpMe.h> -#include <visp/vpCameraParameters.h> - - /*! \class vpMbtXmlParser @@ -69,31 +67,14 @@ Data parser for the model based tracker. */ -class VISP_EXPORT vpMbtXmlParser: public vpXmlParser +class VISP_EXPORT vpMbtXmlParser: virtual public vpMbXmlParser { protected: //! Moving edges parameters. vpMe m_ecm; - //! Camera parameters. - vpCameraParameters cam; - //! Angle to determine if a face appeared - double angleAppear; - //! Angle to determine if a face disappeared - double angleDisappear; - //! Is near clipping distance specified? - bool hasNearClipping; - //! Near clipping distance - double nearClipping; - //! Is far clipping distance specified? - bool hasFarClipping; - //! Near clipping distance - double farClipping; - //! Fov Clipping - bool fovClipping; - + typedef enum{ - conf, - ecm, + ecm = vpMbXmlParser::last, mask, size, nb_mask, @@ -106,20 +87,8 @@ protected: sample, step, nb_sample, - face, - angle_appear, - angle_disappear, - near_clipping, - far_clipping, - fov_clipping, - camera, - height, - width, - u0, - v0, - px, - py - } dataToParse; + last + } dataToParseMb; public: @@ -127,101 +96,19 @@ public: vpMbtXmlParser(); virtual ~vpMbtXmlParser(); - /*! - Get the angle to determine if a face appeared. - - \return angleAppear - */ - inline double getAngleAppear() const {return angleAppear;} - - /*! - Get the angle to determine if a face disappeared. - - \return angleDisappear - */ - inline double getAngleDisappear() const {return angleDisappear;} - - void getCameraParameters(vpCameraParameters& _cam) const { _cam = this->cam;} - - /*! - Get the far clipping distance. - - \return farClipping - */ - inline double getFarClippingDistance() const {return farClipping;} - - /*! - Use FOV clipping - - \return True if yes, False otherwise. - */ - inline bool getFovClipping() const {return fovClipping;} - void getMe(vpMe& _ecm) const { _ecm = this->m_ecm;} - /*! - Get the near clipping distance. - \return nearClipping - */ - inline double getNearClippingDistance() const {return nearClipping;} - - /*! - Has Far clipping been specified? + void parse(const char * filename); - \return True if yes, False otherwise. - */ - inline bool hasFarClippingDistance() const {return hasFarClipping;} - - /*! - Has Near clipping been specified? - - \return True if yes, False otherwise. - */ - inline bool hasNearClippingDistance() const {return hasNearClipping;} - - void parse(const char * filename); - - void readMainClass(xmlDocPtr doc, xmlNodePtr node); - void read_ecm (xmlDocPtr doc, xmlNodePtr node); - void read_sample (xmlDocPtr doc, xmlNodePtr node); - void read_camera (xmlDocPtr doc, xmlNodePtr node); - void read_mask (xmlDocPtr doc, xmlNodePtr node); - void read_range (xmlDocPtr doc, xmlNodePtr node); - void read_contrast (xmlDocPtr doc, xmlNodePtr node); - void read_face(xmlDocPtr doc, xmlNodePtr node); - - /*! - Set the angle to determine if a face appeared. - - \param aappear : New angleAppear - */ - inline void setAngleAppear(const double &aappear) {angleAppear = aappear;} - - /*! - Set the angle to determine if a face disappeared. - - \param adisappear : New angleDisappear - */ - inline void setAngleDisappear(const double &adisappear) {angleDisappear = adisappear;} - - void setCameraParameters(const vpCameraParameters &_cam){ cam = _cam; } - - /*! - Set the far clipping distance. - - \param fclip : New farClipping - */ - inline void setFarClippingDistance(const double &fclip) {farClipping = fclip;} + virtual void readMainClass(xmlDocPtr doc, xmlNodePtr node); + void read_ecm (xmlDocPtr doc, xmlNodePtr node); + void read_sample (xmlDocPtr doc, xmlNodePtr node); + void read_mask (xmlDocPtr doc, xmlNodePtr node); + void read_range (xmlDocPtr doc, xmlNodePtr node); + void read_contrast (xmlDocPtr doc, xmlNodePtr node); void setMovingEdge(const vpMe &_ecm){ m_ecm = _ecm; } - - /*! - Set the near clipping distance. - - \param nclip : New nearClipping - */ - inline void setNearClippingDistance(const double &nclip) {nearClipping = nclip;} void writeMainClass(xmlNodePtr node); diff --git a/src/tracking/mbt/hybrid/vpMbEdgeKltTracker.cpp b/src/tracking/mbt/hybrid/vpMbEdgeKltTracker.cpp index 11bb67f739f88754d622c77f184af9fa3e216ac3..6c9c2842f65299b2052953dcb531f05a5a946b55 100644 --- a/src/tracking/mbt/hybrid/vpMbEdgeKltTracker.cpp +++ b/src/tracking/mbt/hybrid/vpMbEdgeKltTracker.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMbEdgeKltTracker.cpp 4327 2013-07-19 14:08:01Z fspindle $ + * $Id: vpMbEdgeKltTracker.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -44,14 +44,10 @@ #ifdef VISP_HAVE_OPENCV vpMbEdgeKltTracker::vpMbEdgeKltTracker() + : compute_interaction(true), lambda(0.8), thresholdKLT(2.), thresholdMBT(2.), maxIter(200) { - compute_interaction = true; computeCovariance = false; - lambda = 0.8; - thresholdKLT = 2.0; - thresholdMBT = 2.0; - maxIter = 200; vpMbKltTracker::setMaxIter(30); #ifdef VISP_HAVE_OGRE @@ -278,8 +274,64 @@ void vpMbEdgeKltTracker::loadConfigFile(const char* configFile) { #ifdef VISP_HAVE_XML2 - vpMbEdgeTracker::loadConfigFile(configFile); - vpMbKltTracker::loadConfigFile(configFile); + vpMbtEdgeKltXmlParser xmlp; + + xmlp.setCameraParameters(cam); + xmlp.setAngleAppear(vpMath::deg(vpMbKltTracker::angleAppears)); + xmlp.setAngleDisappear(vpMath::deg(vpMbKltTracker::angleDisappears)); + + xmlp.setMovingEdge(me); + + xmlp.setMaxFeatures(10000); + xmlp.setWindowSize(5); + xmlp.setQuality(0.01); + xmlp.setMinDistance(5); + xmlp.setHarrisParam(0.01); + xmlp.setBlockSize(3); + xmlp.setPyramidLevels(3); + xmlp.setMaskBorder(maskBorder); + + try{ + std::cout << " *********** Parsing XML for Mb Edge Tracker ************ " << std::endl; + xmlp.parse(configFile); + } + catch(...){ + vpERROR_TRACE("Can't open XML file \"%s\"\n ", configFile); + throw vpException(vpException::ioError, "problem to parse configuration file."); + } + + vpCameraParameters camera; + xmlp.getCameraParameters(camera); + setCameraParameters(camera); + + vpMbEdgeTracker::angleAppears = vpMath::rad(xmlp.getAngleAppear()); + vpMbEdgeTracker::angleDisappears = vpMath::rad(xmlp.getAngleDisappear()); + vpMbKltTracker::angleAppears = vpMath::rad(xmlp.getAngleAppear()); + vpMbKltTracker::angleDisappears = vpMath::rad(xmlp.getAngleDisappear()); + + if(xmlp.hasNearClippingDistance()) + setNearClippingDistance(xmlp.getNearClippingDistance()); + + if(xmlp.hasFarClippingDistance()) + setFarClippingDistance(xmlp.getFarClippingDistance()); + + if(xmlp.getFovClipping()){ + vpMbEdgeTracker::setClipping(vpMbEdgeTracker::clippingFlag | vpMbtPolygon::FOV_CLIPPING); + vpMbKltTracker::setClipping(vpMbKltTracker::clippingFlag | vpMbtPolygon::FOV_CLIPPING); + } + + vpMe meParser; + xmlp.getMe(meParser); + vpMbEdgeTracker::setMovingEdge(meParser); + + tracker.setMaxFeatures((int)xmlp.getMaxFeatures()); + tracker.setWindowSize((int)xmlp.getWindowSize()); + tracker.setQuality(xmlp.getQuality()); + tracker.setMinDistance(xmlp.getMinDistance()); + tracker.setHarrisFreeParameter(xmlp.getHarrisParam()); + tracker.setBlockSize((int)xmlp.getBlockSize()); + tracker.setPyramidLevels((int)xmlp.getPyramidLevels()); + maskBorder = xmlp.getMaskBorder(); #else vpTRACE("You need the libXML2 to read the config file %s", configFile); #endif @@ -731,8 +783,8 @@ vpMbEdgeKltTracker::trackFirstLoop(const vpImage<unsigned char>& I, vpColVector l->computeInteractionMatrixError(cMo); double fac = 1; - for(std::list<int>::const_iterator it = l->Lindex_polygon.begin(); it!=l->Lindex_polygon.end(); ++it){ - int index = *it; + for(std::list<int>::const_iterator itindex = l->Lindex_polygon.begin(); itindex!=l->Lindex_polygon.end(); ++itindex){ + int index = *itindex; if (l->hiddenface->isAppearing((unsigned int)index)) { fac = 0.2; break; @@ -790,7 +842,7 @@ vpMbEdgeKltTracker::trackFirstLoop(const vpImage<unsigned char>& I, vpColVector void vpMbEdgeKltTracker::trackSecondLoop(const vpImage<unsigned char>& I, vpMatrix &L, vpColVector &error, - vpHomogeneousMatrix& cMo, const unsigned int lvl) + vpHomogeneousMatrix& cMo_, const unsigned int lvl) { vpMbtDistanceLine* l; vpMbtDistanceCylinder *cy ; @@ -798,7 +850,7 @@ vpMbEdgeKltTracker::trackSecondLoop(const vpImage<unsigned char>& I, vpMatrix & unsigned int n = 0 ; for(std::list<vpMbtDistanceLine*>::const_iterator it=lines[lvl].begin(); it!=lines[lvl].end(); ++it){ l = *it; - l->computeInteractionMatrixError(cMo) ; + l->computeInteractionMatrixError(cMo_) ; for (unsigned int i=0 ; i < l->nbFeature ; i++){ for (unsigned int j=0; j < 6 ; j++){ L[n+i][j] = l->L[i][j]; @@ -810,7 +862,7 @@ vpMbEdgeKltTracker::trackSecondLoop(const vpImage<unsigned char>& I, vpMatrix & for(std::list<vpMbtDistanceCylinder*>::const_iterator it=cylinders[lvl].begin(); it!=cylinders[lvl].end(); ++it){ cy = *it; - cy->computeInteractionMatrixError(cMo, I) ; + cy->computeInteractionMatrixError(cMo_, I) ; for(unsigned int i=0 ; i < cy->nbFeature ; i++){ for(unsigned int j=0; j < 6 ; j++){ L[n+i][j] = cy->L[i][j]; @@ -825,12 +877,12 @@ vpMbEdgeKltTracker::trackSecondLoop(const vpImage<unsigned char>& I, vpMatrix & /*! Set the camera parameters - \param cam : the new camera parameters + \param camera : the new camera parameters */ void -vpMbEdgeKltTracker::setCameraParameters(const vpCameraParameters& cam) +vpMbEdgeKltTracker::setCameraParameters(const vpCameraParameters& camera) { - this->cam = cam; + this->cam = camera; vpMbEdgeTracker::setCameraParameters(cam); vpMbKltTracker::setCameraParameters(cam); @@ -853,30 +905,30 @@ vpMbEdgeKltTracker::initFaceFromCorners(const std::vector<vpPoint>& corners, con Add a cylinder to track from tow points on the axis (defining the length of the cylinder) and its radius. - \param _p1 : First point on the axis. - \param _p2 : Second point on the axis. - \param _radius : Radius of the cylinder. - \param _indexCylinder : Index of the cylinder. + \param p1 : First point on the axis. + \param p2 : Second point on the axis. + \param radius : Radius of the cylinder. + \param indexCylinder : Index of the cylinder. */ void -vpMbEdgeKltTracker::initCylinder(const vpPoint& _p1, const vpPoint _p2, const double _radius, const unsigned int _indexCylinder) +vpMbEdgeKltTracker::initCylinder(const vpPoint& p1, const vpPoint &p2, const double radius, const unsigned int indexCylinder) { - vpMbEdgeTracker::initCylinder(_p1, _p2, _radius, _indexCylinder); + vpMbEdgeTracker::initCylinder(p1, p2, radius, indexCylinder); } /*! Display the 3D model at a given position using the given camera parameters \param I : The image. - \param cMo : Pose used to project the 3D model into the image. - \param cam : The camera parameters. + \param cMo_ : Pose used to project the 3D model into the image. + \param camera : The camera parameters. \param col : The desired color. \param thickness : The thickness of the lines. \param displayFullModel : boolean to say if all the model has to be displayed. */ void -vpMbEdgeKltTracker::display(const vpImage<unsigned char>& I, const vpHomogeneousMatrix &cMo, const vpCameraParameters & cam, - const vpColor& col , const unsigned int thickness, const bool displayFullModel) +vpMbEdgeKltTracker::display(const vpImage<unsigned char>& I, const vpHomogeneousMatrix &cMo_, const vpCameraParameters &camera, + const vpColor& col, const unsigned int thickness, const bool displayFullModel) { vpMbtDistanceLine *l ; @@ -884,11 +936,11 @@ vpMbEdgeKltTracker::display(const vpImage<unsigned char>& I, const vpHomogeneous if(scales[i]){ for(std::list<vpMbtDistanceLine*>::const_iterator it=lines[scaleLevel].begin(); it!=lines[scaleLevel].end(); ++it){ l = *it; - l->display(I,cMo, cam, col, thickness, displayFullModel); + l->display(I,cMo_, camera, col, thickness, displayFullModel); } for(std::list<vpMbtDistanceCylinder*>::const_iterator it=cylinders[scaleLevel].begin(); it!=cylinders[scaleLevel].end(); ++it){ - (*it)->display(I, cMo, cam, col, thickness); + (*it)->display(I, cMo_, camera, col, thickness); } break ; //displaying model on one scale only @@ -903,7 +955,7 @@ vpMbEdgeKltTracker::display(const vpImage<unsigned char>& I, const vpHomogeneous #ifdef VISP_HAVE_OGRE if(vpMbKltTracker::useOgre) - vpMbKltTracker::faces.displayOgre(cMo); + vpMbKltTracker::faces.displayOgre(cMo_); #endif } @@ -911,14 +963,14 @@ vpMbEdgeKltTracker::display(const vpImage<unsigned char>& I, const vpHomogeneous Display the 3D model at a given position using the given camera parameters \param I : The color image. - \param cMo : Pose used to project the 3D model into the image. - \param cam : The camera parameters. + \param cMo_ : Pose used to project the 3D model into the image. + \param camera : The camera parameters. \param col : The desired color. \param thickness : The thickness of the lines. \param displayFullModel : boolean to say if all the model has to be displayed. */ void -vpMbEdgeKltTracker::display(const vpImage<vpRGBa>& I, const vpHomogeneousMatrix &cMo, const vpCameraParameters & cam, +vpMbEdgeKltTracker::display(const vpImage<vpRGBa>& I, const vpHomogeneousMatrix &cMo_, const vpCameraParameters &camera, const vpColor& col , const unsigned int thickness, const bool displayFullModel) { vpMbtDistanceLine *l ; @@ -927,11 +979,11 @@ vpMbEdgeKltTracker::display(const vpImage<vpRGBa>& I, const vpHomogeneousMatrix if(scales[i]){ for(std::list<vpMbtDistanceLine*>::const_iterator it=lines[scaleLevel].begin(); it!=lines[scaleLevel].end(); ++it){ l = *it; - l->display(I,cMo, cam, col, thickness, displayFullModel); + l->display(I,cMo_, camera, col, thickness, displayFullModel); } for(std::list<vpMbtDistanceCylinder*>::const_iterator it=cylinders[scaleLevel].begin(); it!=cylinders[scaleLevel].end(); ++it){ - (*it)->display(I, cMo, cam, col, thickness); + (*it)->display(I, cMo_, camera, col, thickness); } break ; //displaying model on one scale only @@ -946,7 +998,7 @@ vpMbEdgeKltTracker::display(const vpImage<vpRGBa>& I, const vpHomogeneousMatrix #ifdef VISP_HAVE_OGRE if(vpMbKltTracker::useOgre) - vpMbKltTracker::faces.displayOgre(cMo); + vpMbKltTracker::faces.displayOgre(cMo_); #endif } diff --git a/src/tracking/mbt/hybrid/vpMbEdgeKltTracker.h b/src/tracking/mbt/hybrid/vpMbEdgeKltTracker.h index fe6830fcfa029e71373ca9fb8907c35d80f63edb..8f1c27044360fad2d55174472d8880307e1bc96c 100644 --- a/src/tracking/mbt/hybrid/vpMbEdgeKltTracker.h +++ b/src/tracking/mbt/hybrid/vpMbEdgeKltTracker.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMbEdgeKltTracker.h 4338 2013-07-23 14:29:30Z fspindle $ + * $Id: vpMbEdgeKltTracker.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -55,11 +55,11 @@ #include <visp/vpSubMatrix.h> #include <visp/vpSubColVector.h> #include <visp/vpExponentialMap.h> -#include <visp/vpMbtXmlParser.h> #include <visp/vpMbTracker.h> #include <visp/vpKltOpencv.h> #include <visp/vpMbEdgeTracker.h> #include <visp/vpPoseVector.h> +#include <visp/vpMbtEdgeKltXmlParser.h> #include <visp/vpMbKltTracker.h> /*! @@ -308,7 +308,7 @@ public: \param a : new angle in radian. */ - virtual inline void setAngleAppear(const double &a) { vpMbKltTracker::setAngleAppear(a); } + virtual inline void setAngleAppear(const double &a) { vpMbKltTracker::setAngleAppear(a); vpMbEdgeTracker::setAngleAppear(a);} /*! Set the angle used to test polygons disappearance. @@ -319,7 +319,7 @@ public: \param a : new angle in radian. */ - virtual inline void setAngleDisappear(const double &a) { vpMbKltTracker::setAngleDisappear(a); } + virtual inline void setAngleDisappear(const double &a) { vpMbKltTracker::setAngleDisappear(a); vpMbEdgeTracker::setAngleDisappear(a);} virtual void setCameraParameters(const vpCameraParameters& cam); @@ -342,9 +342,9 @@ public: /*! Set the value of the gain used to compute the control law. - \param lambda : the desired value for the gain. + \param gain : the desired value for the gain. */ - virtual inline void setLambda(const double lambda) {this->lambda = lambda; vpMbEdgeTracker::setLambda(lambda); vpMbKltTracker::setLambda(lambda);} + virtual inline void setLambda(const double gain) {this->lambda = gain; vpMbEdgeTracker::setLambda(lambda); vpMbKltTracker::setLambda(lambda);} /*! Set the maximum iteration of the virtual visual servoing stage. @@ -379,7 +379,7 @@ protected: vpColVector &w_klt, const unsigned int lvl=0); virtual void init(const vpImage<unsigned char>& I); - virtual void initCylinder(const vpPoint& , const vpPoint , const double , const unsigned int ); + virtual void initCylinder(const vpPoint& , const vpPoint &, const double , const unsigned int ); virtual void initFaceFromCorners(const std::vector<vpPoint>& corners, const unsigned int indexFace = -1); unsigned int initMbtTracking(const unsigned int level=0); diff --git a/src/tracking/mbt/hybrid/vpMbtEdgeKltXmlParser.cpp b/src/tracking/mbt/hybrid/vpMbtEdgeKltXmlParser.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a61e627c233427cf522eb705f54f840955f45496 --- /dev/null +++ b/src/tracking/mbt/hybrid/vpMbtEdgeKltXmlParser.cpp @@ -0,0 +1,198 @@ +/**************************************************************************** + * + * $Id: vpMbtEdgeKltXmlParser.cpp 4577 2014-01-10 16:19:41Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Load XML parameters of the Model based tracker (using edges and point features). + * + * Authors: + * Aurelien Yol + * + *****************************************************************************/ +#include <visp/vpConfig.h> + + +#ifdef VISP_HAVE_XML2 + +#include <iostream> +#include <map> + +#include <libxml/xmlmemory.h> /* Fonctions de la lib XML. */ + +#include <visp/vpMbtEdgeKltXmlParser.h> + + +/*! + Default constructor. + +*/ +vpMbtEdgeKltXmlParser::vpMbtEdgeKltXmlParser() +{ + init(); +} + +/*! + Default destructor. +*/ +vpMbtEdgeKltXmlParser::~vpMbtEdgeKltXmlParser() +{ +} + +/*! + Initialise internal variables (including the map). +*/ +void +vpMbtEdgeKltXmlParser::init() +{ + vpMbtXmlParser::init(); + vpMbtKltXmlParser::init(); + + nodeMap["camera"] = vpMbtEdgeKltXmlParser::camera; + nodeMap["face"] = vpMbtEdgeKltXmlParser::face; + nodeMap["klt"] = vpMbtEdgeKltXmlParser::klt; + nodeMap["ecm"] = vpMbtEdgeKltXmlParser::ecm; + nodeMap["sample"] = vpMbtEdgeKltXmlParser::sample; +} + +/*! + Parse the file in parameters. + This method is deprecated, use parse() instead. + + \param filename : File to parse. +*/ +void +vpMbtEdgeKltXmlParser::parse(const char * filename) +{ + std::string file = filename; + vpXmlParser::parse(file); +} + +/*! + Write info to file. + + \warning Useless, so not yet implemented => Throw exception. +*/ +void +vpMbtEdgeKltXmlParser::writeMainClass(xmlNodePtr /*node*/) +{ + throw vpException(vpException::notImplementedError, "Not yet implemented." ); +} + +/*! + Read the parameters of the class from the file given by its document pointer + and by its root node. + + \param doc : Document to parse. + \param node : Root node. +*/ +void +vpMbtEdgeKltXmlParser::readMainClass(xmlDocPtr doc, xmlNodePtr node) +{ + bool camera_node = false; + bool face_node = false; + bool ecm_node = false; + bool sample_node = false; + bool klt_node = false; + + for(xmlNodePtr dataNode = node->xmlChildrenNode; dataNode != NULL; dataNode = dataNode->next) { + if(dataNode->type == XML_ELEMENT_NODE){ + std::map<std::string, int>::iterator iter_data= this->nodeMap.find((char*)dataNode->name); + if(iter_data != nodeMap.end()){ + switch (iter_data->second){ + case vpMbtEdgeKltXmlParser::camera:{ + this->read_camera (doc, dataNode); + camera_node = true; + }break; + case vpMbtEdgeKltXmlParser::face:{ + this->read_face(doc, dataNode); + face_node = true; + }break; + case vpMbtEdgeKltXmlParser::klt:{ + this->read_klt(doc, dataNode); + klt_node = true; + }break; + case vpMbtEdgeKltXmlParser::ecm:{ + this->read_ecm (doc, dataNode); + ecm_node = true; + }break; + case vpMbtEdgeKltXmlParser::sample:{ + this->read_sample (doc, dataNode); + sample_node = true; + }break; + default:{ +// vpTRACE("unknown tag in read_sample : %d, %s", iter_data->second, (iter_data->first).c_str()); + }break; + } + } + } + } + + if(!camera_node) { + std::cout << "camera : u0 : "<< this->cam.get_u0() << " (default)" <<std::endl; + std::cout << "camera : v0 : "<< this->cam.get_v0() << " (default)" <<std::endl; + std::cout << "camera : px : "<< this->cam.get_px() << " (default)" <<std::endl; + std::cout << "camera : py : "<< this->cam.get_py() << " (default)" <<std::endl; + } + + if(!face_node) { + std::cout << "face : Angle Appear : "<< angleAppear <<" (default)" <<std::endl; + std::cout << "face : Angle Disappear : "<< angleDisappear <<" (default)" <<std::endl; + } + + if(!klt_node) { + std::cout << "klt : Mask Border : "<< maskBorder <<" (default)" <<std::endl; + std::cout << "klt : Max Features : "<< maxFeatures <<" (default)" <<std::endl; + std::cout << "klt : Windows Size : "<< winSize <<" (default)" <<std::endl; + std::cout << "klt : Quality : "<< qualityValue <<" (default)" <<std::endl; + std::cout << "klt : Min Distance : "<< minDist <<" (default)" <<std::endl; + std::cout << "klt : Harris Parameter : "<< harrisParam <<" (default)" <<std::endl; + std::cout << "klt : Block Size : "<< blockSize <<" (default)" <<std::endl; + std::cout << "klt : Pyramid Levels : "<< pyramidLevels <<" (default)" <<std::endl; + } + + if(!ecm_node) { + std::cout << "ecm : mask : size : "<< this->m_ecm.getMaskSize() << " (default)" <<std::endl; + std::cout << "ecm : mask : nb_mask : "<< this->m_ecm.getMaskNumber() << " (default)" <<std::endl; + std::cout <<"ecm : range : tracking : "<< this->m_ecm.getRange()<< " (default)" <<std::endl; + std::cout <<"ecm : contrast : threshold : " << this->m_ecm.getThreshold()<<" (default)" <<std::endl; + std::cout <<"ecm : contrast : mu1 : " << this->m_ecm.getMu1()<<" (default)" <<std::endl; + std::cout <<"ecm : contrast : mu2 : " << this->m_ecm.getMu2()<<" (default)" <<std::endl; + } + + if(!sample_node) { + std::cout <<"sample : sample_step : "<< this->m_ecm.getSampleStep()<< " (default)" << std::endl; + std::cout <<"sample : n_total_sample : "<< this->m_ecm.getNbTotalSample()<< " (default)"<<std::endl; + } +} + +#endif + diff --git a/src/tracking/mbt/hybrid/vpMbtEdgeKltXmlParser.h b/src/tracking/mbt/hybrid/vpMbtEdgeKltXmlParser.h new file mode 100644 index 0000000000000000000000000000000000000000..06208bebd1ac4347522f080044dd45e36aa9d0cc --- /dev/null +++ b/src/tracking/mbt/hybrid/vpMbtEdgeKltXmlParser.h @@ -0,0 +1,98 @@ +/**************************************************************************** + * + * $Id: vpMbtEdgeKltXmlParser.h 4574 2014-01-09 08:48:51Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Load XML parameters of the Model based tracker (using edges and point features). + * + * Authors: + * Aurelien Yol + * + *****************************************************************************/ + +/*! + * \file vpMbtEdgeKltXmlParser.h + * \brief Parse an Xml file to extract configuration parameters of a mbtConfig object. +*/ + +#ifndef vpMbtEdgeKltXmlParser_HH +#define vpMbtEdgeKltXmlParser_HH + +#include <visp/vpConfig.h> + +#ifdef VISP_HAVE_XML2 + +#include <libxml/xmlmemory.h> /* Fonctions de la lib XML. */ + +#include <visp/vpMbtXmlParser.h> +#include <visp/vpMbtKltXmlParser.h> + +/*! + \class vpMbtEdgeKltXmlParser + \brief Parse an Xml file to extract configuration parameters of a mbtConfig object. + \ingroup ModelBasedTracking + + Data parser for the model based tracker. + + */ +class VISP_EXPORT vpMbtEdgeKltXmlParser: public vpMbtXmlParser, public vpMbtKltXmlParser +{ +protected: + typedef enum{ + camera, + face, + klt, + ecm, + sample + } dataToParseMbtEdgeKlt; +public: + + vpMbtEdgeKltXmlParser(); + virtual ~vpMbtEdgeKltXmlParser(); + + void parse(const char * filename); + + virtual void readMainClass(xmlDocPtr doc, xmlNodePtr node); + + void writeMainClass(xmlNodePtr node); + +protected: + void init(); + +}; + +#endif + +#endif /* NMBTEDGEKLTXMLPARSER_H_ */ + + + diff --git a/src/tracking/mbt/klt/vpMbKltTracker.cpp b/src/tracking/mbt/klt/vpMbKltTracker.cpp index 0dd96ef59f8caaeb3426420e33a7a949fbb26a93..542405c1f7031a1051638d079025fbd226e1c0a7 100644 --- a/src/tracking/mbt/klt/vpMbKltTracker.cpp +++ b/src/tracking/mbt/klt/vpMbKltTracker.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMbKltTracker.cpp 4337 2013-07-23 13:57:53Z ayol $ + * $Id: vpMbKltTracker.cpp 4661 2014-02-10 19:34:58Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -44,14 +44,11 @@ #ifdef VISP_HAVE_OPENCV vpMbKltTracker::vpMbKltTracker() -{ - - cur = NULL; - compute_interaction = true; - firstInitialisation = true; - computeCovariance = false; - firstTrack = false; - + : cur(NULL), c0Mo(), angleAppears(0), angleDisappears(0), compute_interaction(true), + firstInitialisation(true), maskBorder(5), lambda(0.8), maxIter(200), threshold_outlier(0.5), + percentGood(0.6), useOgre(false), ctTc0(), tracker(), faces(), firstTrack(false), + distNearClip(0.01), distFarClip(100), clippingFlag(vpMbtPolygon::NO_CLIPPING) +{ tracker.setTrackerId(1); tracker.setUseHarris(1); @@ -65,21 +62,10 @@ vpMbKltTracker::vpMbKltTracker() angleAppears = vpMath::rad(65); angleDisappears = vpMath::rad(75); - - clippingFlag = vpMbtPolygon::NO_CLIPPING; - - maskBorder = 5; - threshold_outlier = 0.5; - percentGood = 0.6; - - lambda = 0.8; - maxIter = 200; - + #ifdef VISP_HAVE_OGRE faces.getOgreContext()->setWindowName("MBT KLT"); #endif - - useOgre = false; } /*! @@ -134,9 +120,10 @@ vpMbKltTracker::reinit(const vpImage<unsigned char>& I) IplImage* mask = cvCreateImage(cvSize((int)I.getWidth(), (int)I.getHeight()), IPL_DEPTH_8U, 1); cvZero(mask); + unsigned char val = 255/* - i*15*/; for (unsigned int i = 0; i < faces.size(); i += 1){ if(faces[i]->isVisible()) - faces[i]->updateMask(mask, 255/* - i*15*/, maskBorder); + faces[i]->updateMask(mask, val, maskBorder); } tracker.initTracking(cur, mask); @@ -260,15 +247,15 @@ vpMbKltTracker::setKltOpencv(const vpKltOpencv& t){ /*! Set the camera parameters. - \param cam : the new camera parameters. + \param camera : the new camera parameters. */ void -vpMbKltTracker::setCameraParameters(const vpCameraParameters& cam) +vpMbKltTracker::setCameraParameters(const vpCameraParameters& camera) { for (unsigned int i = 0; i < faces.size(); i += 1){ - faces[i]->setCameraParameters(cam); + faces[i]->setCameraParameters(camera); } - this->cam = cam; + this->cam = camera; } /*! @@ -344,7 +331,7 @@ vpMbKltTracker::setPose(const vpImage<unsigned char> &I, const vpHomogeneousMatr double invDc = 1.0 / plan.getD(); //Create the homography - vpHomography cdHc; + vpMatrix cdHc; vpGEMM(cdtc, Nc, -invDc, cdRc, 1.0, cdHc, VP_GEMM_B_T); cdHc /= cdHc[2][2]; @@ -764,7 +751,6 @@ vpMbKltTracker::loadConfigFile(const char* configFile) try{ std::cout << " *********** Parsing XML for MBT KLT Tracker ************ " << std::endl; - xmlp.parse(configFile); } catch(...){ @@ -794,7 +780,8 @@ vpMbKltTracker::loadConfigFile(const char* configFile) setFarClippingDistance(xmlp.getFarClippingDistance()); if(xmlp.getFovClipping()) - clippingFlag = clippingFlag | vpMbtPolygon::FOV_CLIPPING; + setClipping(clippingFlag = clippingFlag | vpMbtPolygon::FOV_CLIPPING); + #else vpTRACE("You need the libXML2 to read the config file %s", configFile); #endif @@ -804,17 +791,17 @@ vpMbKltTracker::loadConfigFile(const char* configFile) Display the 3D model at a given position using the given camera parameters \param I : The image. - \param cMo : Pose used to project the 3D model into the image. - \param cam : The camera parameters. + \param cMo_ : Pose used to project the 3D model into the image. + \param camera : The camera parameters. \param col : The desired color. \param thickness : The thickness of the lines. \param displayFullModel : Boolean to say if all the model has to be displayed. */ void -vpMbKltTracker::display(const vpImage<unsigned char>& I, const vpHomogeneousMatrix &cMo, const vpCameraParameters & cam, - const vpColor& col , const unsigned int thickness, const bool displayFullModel) +vpMbKltTracker::display(const vpImage<unsigned char>& I, const vpHomogeneousMatrix &cMo_, const vpCameraParameters & camera, + const vpColor& col, const unsigned int thickness, const bool displayFullModel) { - vpCameraParameters c = cam; + vpCameraParameters c = camera; if(clippingFlag > 3) // Contains at least one FOV constraint c.computeFov(I.getWidth(), I.getHeight()); @@ -822,7 +809,7 @@ vpMbKltTracker::display(const vpImage<unsigned char>& I, const vpHomogeneousMatr for (unsigned int i = 0; i < faces.size(); i += 1){ if(displayFullModel || faces[i]->isVisible()) { - faces[i]->changeFrame(cMo); + faces[i]->changeFrame(cMo_); faces[i]->computeRoiClipped(c); std::vector<std::pair<vpImagePoint,unsigned int> > roi; faces[i]->getRoiClipped(c, roi); @@ -850,7 +837,7 @@ vpMbKltTracker::display(const vpImage<unsigned char>& I, const vpHomogeneousMatr #ifdef VISP_HAVE_OGRE if(useOgre) - faces.displayOgre(cMo); + faces.displayOgre(cMo_); #endif } @@ -858,17 +845,17 @@ vpMbKltTracker::display(const vpImage<unsigned char>& I, const vpHomogeneousMatr Display the 3D model at a given position using the given camera parameters \param I : The color image. - \param cMo : Pose used to project the 3D model into the image. - \param cam : The camera parameters. + \param cMo_ : Pose used to project the 3D model into the image. + \param camera : The camera parameters. \param col : The desired color. \param thickness : The thickness of the lines. \param displayFullModel : Boolean to say if all the model has to be displayed. */ void -vpMbKltTracker::display(const vpImage<vpRGBa>& I, const vpHomogeneousMatrix &cMo, const vpCameraParameters & cam, +vpMbKltTracker::display(const vpImage<vpRGBa>& I, const vpHomogeneousMatrix &cMo_, const vpCameraParameters & camera, const vpColor& col , const unsigned int thickness, const bool displayFullModel) { - vpCameraParameters c = cam; + vpCameraParameters c = camera; if(clippingFlag > 3) // Contains at least one FOV constraint c.computeFov(I.getWidth(), I.getHeight()); @@ -876,7 +863,7 @@ vpMbKltTracker::display(const vpImage<vpRGBa>& I, const vpHomogeneousMatrix &cMo for (unsigned int i = 0; i < faces.size(); i += 1){ if(displayFullModel || faces[i]->isVisible()) { - faces[i]->changeFrame(cMo); + faces[i]->changeFrame(cMo_); faces[i]->computeRoiClipped(c); std::vector<std::pair<vpImagePoint,unsigned int> > roi; faces[i]->getRoiClipped(c, roi); @@ -904,7 +891,7 @@ vpMbKltTracker::display(const vpImage<vpRGBa>& I, const vpHomogeneousMatrix &cMo #ifdef VISP_HAVE_OGRE if(useOgre) - faces.displayOgre(cMo); + faces.displayOgre(cMo_); #endif } diff --git a/src/tracking/mbt/klt/vpMbKltTracker.h b/src/tracking/mbt/klt/vpMbKltTracker.h index 80060b8b93a54d14623ce25bee8ad221989bd7f0..b51a97ffa01e2f31049752a4ba7275d460501be3 100644 --- a/src/tracking/mbt/klt/vpMbKltTracker.h +++ b/src/tracking/mbt/klt/vpMbKltTracker.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMbKltTracker.h 4338 2013-07-23 14:29:30Z fspindle $ + * $Id: vpMbKltTracker.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -405,9 +405,9 @@ public: /*! Set the value of the gain used to compute the control law. - \param lambda : the desired value for the gain. + \param gain : the desired value for the gain. */ - virtual inline void setLambda(const double lambda) {this->lambda = lambda;} + virtual inline void setLambda(const double gain) {this->lambda = gain;} /*! Set the erosion of the mask used on the Model faces. @@ -443,7 +443,7 @@ protected: void computeVVS(const unsigned int &nbInfos, vpColVector &w); virtual void initFaceFromCorners(const std::vector<vpPoint>& corners, const unsigned int indexFace = -1); - virtual void initCylinder(const vpPoint& , const vpPoint , const double , const unsigned int ){}; + virtual void initCylinder(const vpPoint&, const vpPoint &, const double, const unsigned int ){}; void preTracking(const vpImage<unsigned char>& I, unsigned int &nbInfos, unsigned int &nbFaceUsed); bool postTracking(const vpImage<unsigned char>& I, vpColVector &w); diff --git a/src/tracking/mbt/klt/vpMbtKltPolygon.cpp b/src/tracking/mbt/klt/vpMbtKltPolygon.cpp index 9d02cabe2905b04f1c41add8af1361d1470d35f5..6e88f1610967b54f8726bca4bd4cd234a03e1c60 100644 --- a/src/tracking/mbt/klt/vpMbtKltPolygon.cpp +++ b/src/tracking/mbt/klt/vpMbtKltPolygon.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMbtKltPolygon.cpp 4318 2013-07-17 09:47:51Z fspindle $ + * $Id: vpMbtKltPolygon.cpp 4661 2014-02-10 19:34:58Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -49,12 +49,9 @@ */ vpMbtKltPolygon::vpMbtKltPolygon() + : H(), N(), N_cur(), invd0(1.), cRc0_0n(), initPoints(), curPoints(), curPointsInd(), + nbPointsCur(0), nbPointsInit(0), minNbPoint(4), enoughPoints(false), dt(1.), d0(1.), cam() { - minNbPoint = 4; - enoughPoints = false; - - nbPointsInit = 0; - nbPointsCur = 0; initPoints = std::map<int, vpImagePoint>(); curPoints = std::map<int, vpImagePoint>(); curPointsInd = std::map<int, int>(); @@ -157,7 +154,7 @@ vpMbtKltPolygon::computeNbDetectedCurrent(const vpKltOpencv& _tracker) void vpMbtKltPolygon::computeInteractionMatrixAndResidu(vpColVector& _R, vpMatrix& _J) { - unsigned int index = 0; + unsigned int index_ = 0; std::map<int, vpImagePoint>::const_iterator iter = curPoints.begin(); for( ; iter != curPoints.end(); iter++){ @@ -176,23 +173,23 @@ vpMbtKltPolygon::computeInteractionMatrixAndResidu(vpColVector& _R, vpMatrix& _J double invZ = compute_1_over_Z(x_cur, y_cur); - _J[2*index][0] = - invZ; - _J[2*index][1] = 0; - _J[2*index][2] = x_cur * invZ; - _J[2*index][3] = x_cur * y_cur; - _J[2*index][4] = -(1+x_cur*x_cur); - _J[2*index][5] = y_cur; + _J[2*index_][0] = - invZ; + _J[2*index_][1] = 0; + _J[2*index_][2] = x_cur * invZ; + _J[2*index_][3] = x_cur * y_cur; + _J[2*index_][4] = -(1+x_cur*x_cur); + _J[2*index_][5] = y_cur; - _J[2*index+1][0] = 0; - _J[2*index+1][1] = - invZ; - _J[2*index+1][2] = y_cur * invZ; - _J[2*index+1][3] = (1+y_cur*y_cur); - _J[2*index+1][4] = - y_cur * x_cur; - _J[2*index+1][5] = - x_cur; - - _R[2*index] = (x0_transform - x_cur); - _R[2*index+1] = (y0_transform - y_cur); - index++; + _J[2*index_+1][0] = 0; + _J[2*index_+1][1] = - invZ; + _J[2*index_+1][2] = y_cur * invZ; + _J[2*index_+1][3] = (1+y_cur*y_cur); + _J[2*index_+1][4] = - y_cur * x_cur; + _J[2*index_+1][5] = - x_cur; + + _R[2*index_] = (x0_transform - x_cur); + _R[2*index_+1] = (y0_transform - y_cur); + index_++; } } @@ -251,12 +248,13 @@ vpMbtKltPolygon::computeHomography(const vpHomogeneousMatrix& _cTc0, vpHomograph _cTc0.extract(cRc0); _cTc0.extract(ctransc0); - + vpMatrix cHc0(_cHc0); + // vpGEMM(cRc0, 1.0, invd0, cRc0, -1.0, _cHc0, VP_GEMM_A_T); - vpGEMM(ctransc0, N, -invd0, cRc0, 1.0, _cHc0, VP_GEMM_B_T); - _cHc0 /= _cHc0[2][2]; + vpGEMM(ctransc0, N, -invd0, cRc0, 1.0, cHc0, VP_GEMM_B_T); + cHc0 /= cHc0[2][2]; - H = _cHc0; + H = cHc0; // vpQuaternionVector NQuat(N[0], N[1], N[2], 0.0); // vpQuaternionVector RotQuat(cRc0); @@ -315,7 +313,7 @@ vpMbtKltPolygon::isTrackedFeature(const int _id) \param _shiftBorder : Optionnal shift for the border in pixel (sort of built-in erosion) to avoid to consider pixels near the limits of the face. */ void -vpMbtKltPolygon::updateMask(IplImage* _mask, unsigned int _nb, unsigned int _shiftBorder) +vpMbtKltPolygon::updateMask(IplImage* _mask, unsigned char _nb, unsigned int _shiftBorder) { int width = _mask->width; int i_min, i_max, j_min, j_max; @@ -340,7 +338,7 @@ vpMbtKltPolygon::updateMask(IplImage* _mask, unsigned int _nb, unsigned int _shi } double shiftBorder_d = (double) _shiftBorder; - char* ptrData = _mask->imageData + i_min*width+j_min; + unsigned char* ptrData = (unsigned char*)_mask->imageData + i_min*width+j_min; for(int i=i_min; i< i_max; i++){ double i_d = (double) i; for(int j=j_min; j< j_max; j++){ @@ -477,7 +475,8 @@ bool vpMbtKltPolygon::intersect(const vpImagePoint& p1, const vpImagePoint& p2, double den = dx * ey - dy * ex; double t = 0, u = 0; - if(den != 0){ + //if(den != 0){ + if(std::fabs(den) > std::fabs(den)*std::numeric_limits<double>::epsilon()){ t = -( ey * ( p1.get_j() - j_test ) + ex * ( -p1.get_i() + i_test ) ) / den; u = -( dx * ( -p1.get_i() + i_test ) + dy * ( p1.get_j() - j_test ) ) / den; } diff --git a/src/tracking/mbt/klt/vpMbtKltPolygon.h b/src/tracking/mbt/klt/vpMbtKltPolygon.h index 7c1c868a1f3479bd53b2d558e4bf299b7ea4c5bf..ba8fe2a698960de7e1e39c5df276aa0302d6ec68 100644 --- a/src/tracking/mbt/klt/vpMbtKltPolygon.h +++ b/src/tracking/mbt/klt/vpMbtKltPolygon.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMbtKltPolygon.h 4339 2013-07-23 15:24:42Z ayol $ + * $Id: vpMbtKltPolygon.h 4661 2014-02-10 19:34:58Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -157,7 +157,7 @@ public: */ virtual inline void setCameraParameters(const vpCameraParameters& _cam){ cam = _cam; } - void updateMask(IplImage* _mask, unsigned int _nb = 255, unsigned int _shiftBorder = 0); + void updateMask(IplImage* _mask, unsigned char _nb = 255, unsigned int _shiftBorder = 0); //################### // Static Functions diff --git a/src/tracking/mbt/klt/vpMbtKltXmlParser.cpp b/src/tracking/mbt/klt/vpMbtKltXmlParser.cpp index 554ddd641bb41780df5d00d4e2df8a605ba27365..5b81b53cf299cd67bab47a54c5a3d5e0f48c0761 100644 --- a/src/tracking/mbt/klt/vpMbtKltXmlParser.cpp +++ b/src/tracking/mbt/klt/vpMbtKltXmlParser.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMbtKltXmlParser.cpp 4320 2013-07-17 15:37:27Z ayol $ + * $Id: vpMbtKltXmlParser.cpp 4582 2014-01-14 14:02:46Z ayol $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -32,7 +32,7 @@ * * * Description: - * Read MBT KLT Tracker information in an XML file + * Load XML parameters of the Model based tracker (using point features). * * Authors: * Aurelien Yol @@ -56,9 +56,8 @@ */ vpMbtKltXmlParser::vpMbtKltXmlParser() { - hasNearClipping = false; - hasFarClipping = false; - fovClipping = false; + maskBorder = maxFeatures = winSize = blockSize = pyramidLevels = 0; + qualityValue = minDist = harrisParam = 0.; init(); } @@ -75,9 +74,8 @@ vpMbtKltXmlParser::~vpMbtKltXmlParser() void vpMbtKltXmlParser::init() { - setMainTag("conf"); + vpMbXmlParser::init(); - nodeMap["conf"] = conf; nodeMap["klt"] = klt; nodeMap["mask_border"] = mask_border; nodeMap["max_features"] = max_features; @@ -87,19 +85,6 @@ vpMbtKltXmlParser::init() nodeMap["harris"] = harris; nodeMap["size_block"] = size_block; nodeMap["pyramid_lvl"] = pyramid_lvl; - nodeMap["face"] = face; - nodeMap["angle_appear"] = angle_appear; - nodeMap["angle_disappear"] = angle_disappear; - nodeMap["near_clipping"] = near_clipping; - nodeMap["far_clipping"] = far_clipping; - nodeMap["fov_clipping"] = fov_clipping; - nodeMap["camera"] = camera; - nodeMap["height"] = height; - nodeMap["width"] = width; - nodeMap["u0"] = u0; - nodeMap["v0"] = v0; - nodeMap["px"] = px; - nodeMap["py"] = py; } /*! @@ -136,27 +121,27 @@ vpMbtKltXmlParser::writeMainClass(xmlNodePtr /*node*/) void vpMbtKltXmlParser::readMainClass(xmlDocPtr doc, xmlNodePtr node) { - bool klt_node = false; bool camera_node = false; bool face_node = false; + bool klt_node = false; for(xmlNodePtr dataNode = node->xmlChildrenNode; dataNode != NULL; dataNode = dataNode->next) { if(dataNode->type == XML_ELEMENT_NODE){ std::map<std::string, int>::iterator iter_data= this->nodeMap.find((char*)dataNode->name); if(iter_data != nodeMap.end()){ switch (iter_data->second){ - case klt:{ - this->read_klt(doc, dataNode); - klt_node = true; - }break; case camera:{ - this->read_camera(doc, dataNode); + this->read_camera (doc, dataNode); camera_node = true; }break; case face:{ this->read_face(doc, dataNode); face_node = true; }break; + case klt:{ + this->read_klt(doc, dataNode); + klt_node = true; + }break; default:{ // vpTRACE("unknown tag in read_sample : %d, %s", iter_data->second, (iter_data->first).c_str()); }break; @@ -165,95 +150,27 @@ vpMbtKltXmlParser::readMainClass(xmlDocPtr doc, xmlNodePtr node) } } - if(!klt_node) - std::cout << "WARNING: KLT Node not specified, default values used" << std::endl; - - if(!camera_node) - std::cout << "WARNING: CAMERA Node not specified, default values used" << std::endl; - - if(!face_node) - std::cout << "WARNING: FACE Node not specified, default values used" << std::endl; -} + if(!camera_node) { + std::cout << "camera : u0 : "<< this->cam.get_u0() << " (default)" <<std::endl; + std::cout << "camera : v0 : "<< this->cam.get_v0() << " (default)" <<std::endl; + std::cout << "camera : px : "<< this->cam.get_px() << " (default)" <<std::endl; + std::cout << "camera : py : "<< this->cam.get_py() << " (default)" <<std::endl; + } -/*! - Read face information. - - \throw vpException::fatalError if there was an unexpected number of data. - - \param doc : Pointer to the document. - \param node : Pointer to the node of the camera information. -*/ -void -vpMbtKltXmlParser::read_face(xmlDocPtr doc, xmlNodePtr node) -{ - bool angle_appear_node = false; - bool angle_disappear_node = false; - bool near_clipping_node = false; - bool far_clipping_node = false; - bool fov_clipping_node = false; - - for(xmlNodePtr dataNode = node->xmlChildrenNode; dataNode != NULL; dataNode = dataNode->next) { - if(dataNode->type == XML_ELEMENT_NODE){ - std::map<std::string, int>::iterator iter_data= this->nodeMap.find((char*)dataNode->name); - if(iter_data != nodeMap.end()){ - switch (iter_data->second){ - case angle_appear:{ - angleAppear = xmlReadDoubleChild(doc, dataNode); - angle_appear_node = true; - }break; - case angle_disappear:{ - angleDisappear = xmlReadDoubleChild(doc, dataNode); - angle_disappear_node = true; - }break; - case near_clipping:{ - nearClipping = xmlReadDoubleChild(doc, dataNode); - near_clipping_node = true; - hasNearClipping = true; - }break; - case far_clipping:{ - farClipping = xmlReadDoubleChild(doc, dataNode); - far_clipping_node = true; - hasFarClipping = true; - }break; - case fov_clipping:{ - fovClipping = (bool)xmlReadIntChild(doc, dataNode); - fov_clipping_node = true; - }break; - default:{ -// vpTRACE("unknown tag in read_camera : %d, %s", iter_data->second, (iter_data->first).c_str()); - }break; - } - } - } + if(!face_node) { + std::cout << "face : Angle Appear : "<< angleAppear <<" (default)" <<std::endl; + std::cout << "face : Angle Disappear : "<< angleDisappear <<" (default)" <<std::endl; } - - if(!angle_appear_node) - std::cout << "WARNING: In FACE Node, ANGLE_APPEAR Node not specified, default value used : " << angleAppear << std::endl; - else - std::cout << "face : Angle Appear "<< angleAppear <<std::endl; - - if(!angle_disappear_node) - std::cout << "WARNING: In FACE Node, ANGLE_DESAPPEAR Node not specified, default value used : " << angleDisappear << std::endl; - else - std::cout << "face : Angle Disappear : "<< angleDisappear <<std::endl; - - if(!near_clipping_node) - std::cout << "WARNING: In FACE Node, NEAR_CLIPPING Node not specified, no near clipping used" << std::endl; - else - std::cout << "face : Near Clipping : "<< nearClipping <<std::endl; - - if(!far_clipping_node) - std::cout << "WARNING: In FACE Node, FAR_CLIPPING Node not specified, no far clipping used" << std::endl; - else - std::cout << "face : Far Clipping : "<< farClipping <<std::endl; - - if(!fov_clipping_node) - std::cout << "WARNING: In FACE Node, FOV_CLIPPING Node not specified, no fov clipping used" << std::endl; - else{ - if(fovClipping) - std::cout << "face : Fov Clipping : True" <<std::endl; - else - std::cout << "face : Fov Clipping : False" <<std::endl; + + if(!klt_node) { + std::cout << "klt : Mask Border : "<< maskBorder <<" (default)" <<std::endl; + std::cout << "klt : Max Features : "<< maxFeatures <<" (default)" <<std::endl; + std::cout << "klt : Windows Size : "<< winSize <<" (default)" <<std::endl; + std::cout << "klt : Quality : "<< qualityValue <<" (default)" <<std::endl; + std::cout << "klt : Min Distance : "<< minDist <<" (default)" <<std::endl; + std::cout << "klt : Harris Parameter : "<< harrisParam <<" (default)" <<std::endl; + std::cout << "klt : Block Size : "<< blockSize <<" (default)" <<std::endl; + std::cout << "klt : Pyramid Levels : "<< pyramidLevels <<" (default)" <<std::endl; } } @@ -268,7 +185,7 @@ vpMbtKltXmlParser::read_face(xmlDocPtr doc, xmlNodePtr node) void vpMbtKltXmlParser::read_klt(xmlDocPtr doc, xmlNodePtr node) { - bool mask_border_node = false; + bool mask_border_node = false; bool max_features_node = false; bool window_size_node = false; bool quality_node = false; @@ -323,138 +240,45 @@ vpMbtKltXmlParser::read_klt(xmlDocPtr doc, xmlNodePtr node) } if(!mask_border_node) - std::cout << "WARNING: In KLT Node, MASK_BORDER Node not specified, default value used : " << maskBorder << std::endl; + std::cout << "klt : Mask Border : "<< maskBorder <<" (default)" <<std::endl; else std::cout << "klt : Mask Border : "<< maskBorder <<std::endl; if(!max_features_node) - std::cout << "WARNING: In KLT Node, MAX_FEATURES Node not specified, default value used : " << maxFeatures << std::endl; + std::cout << "klt : Max Features : "<< maxFeatures <<" (default)" <<std::endl; else std::cout << "klt : Max Features : "<< maxFeatures <<std::endl; if(!window_size_node) - std::cout << "WARNING: In KLT Node, WINDOW_SIZE Node not specified, default value used : " << winSize << std::endl; + std::cout << "klt : Windows Size : "<< winSize <<" (default)" <<std::endl; else std::cout << "klt : Windows Size : "<< winSize <<std::endl; if(!quality_node) - std::cout << "WARNING: In KLT Node, QUALITY Node not specified, default value used : " << qualityValue << std::endl; + std::cout << "klt : Quality : "<< qualityValue <<" (default)" <<std::endl; else std::cout << "klt : Quality : "<< qualityValue <<std::endl; if(!min_distance_node) - std::cout << "WARNING: In KLT Node, MIN_DISTANCE Node not specified, default value used : " << minDist << std::endl; + std::cout << "klt : Min Distance : "<< minDist <<" (default)" <<std::endl; else std::cout << "klt : Min Distance : "<< minDist <<std::endl; if(!harris_node) - std::cout << "WARNING: In KLT Node, HARRIS Node not specified, default value used : " << harrisParam << std::endl; + std::cout << "klt : Harris Parameter : "<< harrisParam <<" (default)" <<std::endl; else std::cout << "klt : Harris Parameter : "<< harrisParam <<std::endl; if(!size_block_node) - std::cout << "WARNING: In KLT Node, SIZE_BLOCK Node not specified, default value used : " << blockSize << std::endl; + std::cout << "klt : Block Size : "<< blockSize <<" (default)" <<std::endl; else std::cout << "klt : Block Size : "<< blockSize <<std::endl; if(!pyramid_lvl_node) - std::cout << "WARNING: In KLT Node, PYRAMID_LVL Node not specified, default value used : " << pyramidLevels << std::endl; + std::cout << "klt : Pyramid Levels : "<< pyramidLevels <<" (default)" <<std::endl; else std::cout << "klt : Pyramid Levels : "<< pyramidLevels <<std::endl; } -/*! - Read camera information. - - \throw vpException::fatalError if there was an unexpected number of data. - - \param doc : Pointer to the document. - \param node : Pointer to the node of the camera information. -*/ -void -vpMbtKltXmlParser::read_camera (xmlDocPtr doc, xmlNodePtr node) -{ - bool height_node = false; - bool width_node = false; - bool u0_node = false; - bool v0_node = false; - bool px_node = false; - bool py_node = false; - - // current data values. -// int d_height=0 ; -// int d_width= 0 ; - double d_u0 = this->cam.get_u0(); - double d_v0 = this->cam.get_v0(); - double d_px = this->cam.get_px(); - double d_py = this->cam.get_py(); - - for(xmlNodePtr dataNode = node->xmlChildrenNode; dataNode != NULL; dataNode = dataNode->next) { - if(dataNode->type == XML_ELEMENT_NODE){ - std::map<std::string, int>::iterator iter_data= this->nodeMap.find((char*)dataNode->name); - if(iter_data != nodeMap.end()){ - switch (iter_data->second){ - case height:{ - /* d_height = */ xmlReadIntChild(doc, dataNode); - height_node = true; - }break; - case width:{ - /* d_width = */ xmlReadIntChild(doc, dataNode); - width_node = true; - }break; - case u0:{ - d_u0 = xmlReadDoubleChild(doc, dataNode); - u0_node = true; - }break; - case v0:{ - d_v0 = xmlReadDoubleChild(doc, dataNode); - v0_node = true; - }break; - case px:{ - d_px = xmlReadDoubleChild(doc, dataNode); - px_node = true; - }break; - case py:{ - d_py = xmlReadDoubleChild(doc, dataNode); - py_node = true; - }break; - default:{ -// vpTRACE("unknown tag in read_camera : %d, %s", iter_data->second, (iter_data->first).c_str()); - }break; - } - } - } - } - - this->cam.initPersProjWithoutDistortion(d_px, d_py, d_u0, d_v0) ; - - if(!height_node) - std::cout << "WARNING: In CAMERA Node, HEIGHT Node not specified, default value used" << std::endl; - - if(!width_node) - std::cout << "WARNING: In CAMERA Node, WIDTH Node not specified, default value used" << std::endl; - - if(!u0_node) - std::cout << "WARNING: In CAMERA Node, u0 Node not specified, default value used : " << this->cam.get_u0() << std::endl; - else - std::cout << "camera : u0 "<< this->cam.get_u0() <<std::endl; - - if(!v0_node) - std::cout << "WARNING: In CAMERA Node, v0 Node not specified, default value used : " << this->cam.get_v0() << std::endl; - else - std::cout << "camera : v0 "<< this->cam.get_v0() <<std::endl; - - if(!px_node) - std::cout << "WARNING: In CAMERA Node, px Node not specified, default value used : " << this->cam.get_px() << std::endl; - else - std::cout << "camera : px "<< this->cam.get_px() <<std::endl; - - if(!py_node) - std::cout << "WARNING: In CAMERA Node, py Node not specified, default value used : " << this->cam.get_py() << std::endl; - else - std::cout << "camera : py "<< this->cam.get_py() <<std::endl; -} - - #endif diff --git a/src/tracking/mbt/klt/vpMbtKltXmlParser.h b/src/tracking/mbt/klt/vpMbtKltXmlParser.h index ee260f2f6cb802b72dfd3ebe9a41a0259d6256bc..0de55c7eb220e1f34365c6ba394c1a5bf387f61e 100644 --- a/src/tracking/mbt/klt/vpMbtKltXmlParser.h +++ b/src/tracking/mbt/klt/vpMbtKltXmlParser.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMbtKltXmlParser.h 4320 2013-07-17 15:37:27Z ayol $ + * $Id: vpMbtKltXmlParser.h 4582 2014-01-14 14:02:46Z ayol $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -32,7 +32,7 @@ * * * Description: - * Read MBT KLT Tracker information in an XML file + * Load XML parameters of the Model based tracker (using point features). * * Authors: * Aurelien Yol @@ -52,8 +52,7 @@ #include <libxml/xmlmemory.h> /* Fonctions de la lib XML. */ -#include <visp/vpXmlParser.h> -#include <visp/vpCameraParameters.h> +#include <visp/vpMbXmlParser.h> /*! \class vpMbtKltXmlParser @@ -63,7 +62,7 @@ Data parser for the KLT model based tracker. */ -class VISP_EXPORT vpMbtKltXmlParser: public vpXmlParser +class VISP_EXPORT vpMbtKltXmlParser: virtual public vpMbXmlParser { protected: //! Border of the mask used on Klt points @@ -82,26 +81,9 @@ protected: unsigned int blockSize; //! Number of pyramid levels unsigned int pyramidLevels; - //! Angle to determine if a face appeared - double angleAppear; - //! Angle to determine if a face disappeared - double angleDisappear; - //! Is near clipping distance specified? - bool hasNearClipping; - //! Near clipping distance - double nearClipping; - //! Is far clipping distance specified? - bool hasFarClipping; - //! Near clipping distance - double farClipping; - //! Fov Clipping - bool fovClipping; - //! Camera parameters. - vpCameraParameters cam; typedef enum{ - conf, - klt, + klt = vpMbXmlParser::last, mask_border, max_features, window_size, @@ -110,20 +92,8 @@ protected: harris, size_block, pyramid_lvl, - face, - angle_appear, - angle_disappear, - near_clipping, - far_clipping, - fov_clipping, - camera, - height, - width, - u0, - v0, - px, - py - } dataToParse; + last + } dataToParseMbKlt; public: @@ -131,20 +101,6 @@ public: vpMbtKltXmlParser(); virtual ~vpMbtKltXmlParser(); - /*! - Get the angle to determine if a face appeared. - - \return angleAppear - */ - inline double getAngleAppear() const {return angleAppear;} - - /*! - Get the angle to determine if a face disappeared. - - \return angleDisappear - */ - inline double getAngleDisappear() const {return angleDisappear;} - /*! Get the size of a block. @@ -152,27 +108,6 @@ public: */ inline unsigned int getBlockSize() const {return blockSize;} - /*! - Get the camera parameters. - - \return cam - */ - void getCameraParameters(vpCameraParameters& _cam) const { _cam = cam;} - - /*! - Get the far clipping distance. - - \return farClipping - */ - inline double getFarClippingDistance() const {return farClipping;} - - /*! - Use FOV clipping - - \return True if yes, False otherwise. - */ - inline bool getFovClipping() const {return fovClipping;} - /*! Get the Harris free parameter. @@ -201,13 +136,6 @@ public: */ inline double getMinDistance() const {return minDist;} - /*! - Get the near clipping distance. - - \return nearClipping - */ - inline double getNearClippingDistance() const {return nearClipping;} - /*! Get the number of pyramid levels @@ -229,40 +157,10 @@ public: */ inline unsigned int getWindowSize() const {return winSize;} - /*! - Has Far clipping been specified? - - \return True if yes, False otherwise. - */ - inline bool hasFarClippingDistance() const {return hasFarClipping;} - - /*! - Has Near clipping been specified? - - \return True if yes, False otherwise. - */ - inline bool hasNearClippingDistance() const {return hasNearClipping;} - void parse(const char * filename); - void readMainClass(xmlDocPtr doc, xmlNodePtr node); - void read_camera (xmlDocPtr doc, xmlNodePtr node); + virtual void readMainClass(xmlDocPtr doc, xmlNodePtr node); void read_klt(xmlDocPtr doc, xmlNodePtr node); - void read_face(xmlDocPtr doc, xmlNodePtr node); - - /*! - Set the angle to determine if a face appeared. - - \param aappear : New angleAppear - */ - inline void setAngleAppear(const double &aappear) {angleAppear = aappear;} - - /*! - Set the angle to determine if a face disappeared. - - \param adisappear : New angleDisappear - */ - inline void setAngleDisappear(const double &adisappear) {angleDisappear = adisappear;} /*! Set the size of a block. @@ -271,20 +169,6 @@ public: */ inline void setBlockSize(const unsigned int &bs) {blockSize = bs;} - /*! - Set the camera parameters. - - \param _cam : New cam - */ - void setCameraParameters(const vpCameraParameters& _cam) {cam = _cam;} - - /*! - Set the far clipping distance. - - \param fclip : New farClipping - */ - inline void setFarClippingDistance(const double &fclip) {farClipping = fclip;} - /*! Set the Harris free parameter. @@ -312,14 +196,7 @@ public: \param mD : New minDist */ inline void setMinDistance(const double &mD) {minDist = mD;} - - /*! - Set the near clipping distance. - \param nclip : New nearClipping - */ - inline void setNearClippingDistance(const double &nclip) {nearClipping = nclip;} - /*! Set the number of pyramid levels diff --git a/src/tracking/mbt/vpMbHiddenFaces.h b/src/tracking/mbt/vpMbHiddenFaces.h index 60b4e9138756b868051ab1607c04bc965bae3165..0fecbd1241c4a52572741a84df0059a4fe2dc862 100644 --- a/src/tracking/mbt/vpMbHiddenFaces.h +++ b/src/tracking/mbt/vpMbHiddenFaces.h @@ -3,7 +3,7 @@ * $Id: vpMbTracker.h 4004 2012-11-23 17:34:44Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -54,6 +54,7 @@ #endif #include <vector> +#include <limits> /*! \class vpMbHiddenFaces @@ -79,11 +80,11 @@ class vpMbHiddenFaces std::vector< Ogre::ManualObject* > lOgrePolygons; #endif - unsigned int setVisiblePrivate(const vpHomogeneousMatrix &_cMo, const double &angleAppears, const double &angleDisappears, + unsigned int setVisiblePrivate(const vpHomogeneousMatrix &cMo, const double &angleAppears, const double &angleDisappears, bool &changed, bool useOgre = false, bool testRoi = false, - const vpImage<unsigned char> &_I = vpImage<unsigned char>(), - const vpCameraParameters &_cam = vpCameraParameters() + const vpImage<unsigned char> &I = vpImage<unsigned char>(), + const vpCameraParameters &cam = vpCameraParameters() ) ; @@ -94,7 +95,7 @@ class vpMbHiddenFaces void addPolygon(PolygonType *p) ; #ifdef VISP_HAVE_OGRE - void displayOgre(const vpHomogeneousMatrix &_cMo); + void displayOgre(const vpHomogeneousMatrix &cMo); #endif /*! @@ -105,7 +106,7 @@ class vpMbHiddenFaces std::vector<PolygonType*>& getPolygon() {return Lpol;} #ifdef VISP_HAVE_OGRE - void initOgre(vpCameraParameters _cam = vpCameraParameters()); + void initOgre(const vpCameraParameters &cam = vpCameraParameters()); #endif /*! @@ -169,13 +170,13 @@ class vpMbHiddenFaces void setBackgroundSizeOgre(const unsigned int &h, const unsigned int &w) { ogreBackground.resize(h,w); } #endif - unsigned int setVisible(const vpImage<unsigned char>& _I, const vpCameraParameters &_cam, const vpHomogeneousMatrix &_cMo, const double &angle, bool &changed) ; - unsigned int setVisible(const vpImage<unsigned char>& _I, const vpCameraParameters &_cam, const vpHomogeneousMatrix &_cMo, const double &angleAppears, const double &angleDisappears, bool &changed) ; - unsigned int setVisible(const vpHomogeneousMatrix &_cMo, const double &angleAppears, const double &angleDisappears, bool &changed) ; + unsigned int setVisible(const vpImage<unsigned char>& I, const vpCameraParameters &cam, const vpHomogeneousMatrix &cMo, const double &angle, bool &changed) ; + unsigned int setVisible(const vpImage<unsigned char>& I, const vpCameraParameters &cam, const vpHomogeneousMatrix &cMo, const double &angleAppears, const double &angleDisappears, bool &changed) ; + unsigned int setVisible(const vpHomogeneousMatrix &cMo, const double &angleAppears, const double &angleDisappears, bool &changed) ; #ifdef VISP_HAVE_OGRE - unsigned int setVisibleOgre(const vpImage<unsigned char>& _I, const vpCameraParameters &_cam, const vpHomogeneousMatrix &_cMo, const double &angleAppears, const double &angleDisappears, bool &changed) ; - unsigned int setVisibleOgre(const vpHomogeneousMatrix &_cMo, const double &angleAppears, const double &angleDisappears, bool &changed) ; + unsigned int setVisibleOgre(const vpImage<unsigned char>& I, const vpCameraParameters &cam, const vpHomogeneousMatrix &cMo, const double &angleAppears, const double &angleDisappears, bool &changed) ; + unsigned int setVisibleOgre(const vpHomogeneousMatrix &cMo, const double &angleAppears, const double &angleDisappears, bool &changed) ; #endif /*! Get the number of polygons. @@ -207,7 +208,7 @@ class vpMbHiddenFaces \param d : New value. */ vp_deprecated void setDepthTest(const bool &d){depthTest = d;} - unsigned int setVisible(const vpHomogeneousMatrix &_cMo) ; + unsigned int setVisible(const vpHomogeneousMatrix &cMo) ; #endif } ; @@ -215,7 +216,12 @@ class vpMbHiddenFaces Basic constructor. */ template<class PolygonType> -vpMbHiddenFaces<PolygonType>::vpMbHiddenFaces(): nbVisiblePolygon(0) +vpMbHiddenFaces<PolygonType>::vpMbHiddenFaces() + : Lpol(), nbVisiblePolygon(0) +#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS + , depthTest(false) +#endif + { #ifdef VISP_HAVE_OGRE ogreInitialised = false; @@ -223,9 +229,6 @@ vpMbHiddenFaces<PolygonType>::vpMbHiddenFaces(): nbVisiblePolygon(0) ogre->setShowConfigDialog(false); ogreBackground = vpImage<unsigned char>(480, 640); #endif -#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS - depthTest = false; -#endif } @@ -286,23 +289,23 @@ vpMbHiddenFaces<PolygonType>::reset() /*! Compute the number of visible polygons. - \param _cMo : The pose of the camera + \param cMo : The pose of the camera \param angleAppears : Angle used to test the appearance of a face \param angleDisappears : Angle used to test the disappearance of a face \param changed : True if a face appeared, disappeared or too many points have been lost. False otherwise \param useOgre : True if a Ogre is used to test the visibility, False otherwise \param testRoi : True if a face have to be entirely in the image False otherwise - \param _I : Image used to test if a face is entirely projected in the image. - \param _cam : Camera parameters. + \param I : Image used to test if a face is entirely projected in the image. + \param cam : Camera parameters. \return Return the number of visible polygons */ template<class PolygonType> unsigned int -vpMbHiddenFaces<PolygonType>::setVisiblePrivate(const vpHomogeneousMatrix &_cMo, const double &angleAppears, const double &angleDisappears, +vpMbHiddenFaces<PolygonType>::setVisiblePrivate(const vpHomogeneousMatrix &cMo, const double &angleAppears, const double &angleDisappears, bool &changed, bool useOgre, bool testRoi, - const vpImage<unsigned char> &_I, - const vpCameraParameters &_cam + const vpImage<unsigned char> &I, + const vpCameraParameters &cam ) { nbVisiblePolygon = 0; @@ -312,15 +315,15 @@ vpMbHiddenFaces<PolygonType>::setVisiblePrivate(const vpHomogeneousMatrix &_cMo, if(useOgre){ #ifdef VISP_HAVE_OGRE - _cMo.inverse().extract(cameraPos); - ogre->renderOneFrame(ogreBackground, _cMo); + cMo.inverse().extract(cameraPos); + ogre->renderOneFrame(ogreBackground, cMo); #else vpTRACE("ViSP doesn't have Ogre3D, simple visibility test used"); #endif } for (unsigned int i = 0; i < Lpol.size(); i += 1){ - Lpol[i]->changeFrame(_cMo); + Lpol[i]->changeFrame(cMo); Lpol[i]->isappearing = false; if(Lpol[i]->isVisible()) @@ -330,19 +333,19 @@ vpMbHiddenFaces<PolygonType>::setVisiblePrivate(const vpHomogeneousMatrix &_cMo, if(testRoi){ nbCornerInsidePrev = Lpol[i]->getNbCornerInsidePrevImage(); - if(Lpol[i]->getNbCornerInsideImage(_I, _cam) == 0) + if(Lpol[i]->getNbCornerInsideImage(I, cam) == 0) testDisappear = true; } if(!testDisappear){ if(useOgre) #ifdef VISP_HAVE_OGRE - testDisappear = ((!Lpol[i]->isVisible(_cMo, angleDisappears, true)) || !isVisibleOgre(cameraPos,i)); + testDisappear = ((!Lpol[i]->isVisible(cMo, angleDisappears, true)) || !isVisibleOgre(cameraPos,i)); #else - testDisappear = (!Lpol[i]->isVisible(_cMo, angleDisappears)); + testDisappear = (!Lpol[i]->isVisible(cMo, angleDisappears)); #endif else - testDisappear = (!Lpol[i]->isVisible(_cMo, angleDisappears)); + testDisappear = (!Lpol[i]->isVisible(cMo, angleDisappears)); } // test if the face is still visible @@ -363,18 +366,18 @@ vpMbHiddenFaces<PolygonType>::setVisiblePrivate(const vpHomogeneousMatrix &_cMo, { bool testAppear = true; - if(testRoi && Lpol[i]->getNbCornerInsideImage(_I, _cam) == 0) + if(testRoi && Lpol[i]->getNbCornerInsideImage(I, cam) == 0) testAppear = false; if(testAppear){ if(useOgre) #ifdef VISP_HAVE_OGRE - testAppear = ((Lpol[i]->isVisible(_cMo, angleAppears, true)) && isVisibleOgre(cameraPos,i)); + testAppear = ((Lpol[i]->isVisible(cMo, angleAppears, true)) && isVisibleOgre(cameraPos,i)); #else - testAppear = (Lpol[i]->isVisible(_cMo, angleAppears)); + testAppear = (Lpol[i]->isVisible(cMo, angleAppears)); #endif else - testAppear = (Lpol[i]->isVisible(_cMo, angleAppears)); + testAppear = (Lpol[i]->isVisible(cMo, angleAppears)); } if(testAppear){ @@ -395,9 +398,9 @@ vpMbHiddenFaces<PolygonType>::setVisiblePrivate(const vpHomogeneousMatrix &_cMo, /*! Compute the number of visible polygons. - \param _I : Image used to check if the region of interest is inside the image. - \param _cam : Camera parameters. - \param _cMo : The pose of the camera. + \param I : Image used to check if the region of interest is inside the image. + \param cam : Camera parameters. + \param cMo : The pose of the camera. \param angle : Angle used to test the appearance and disappearance of a face. \param changed : True if a face appeared, disappeared or too many points have been lost. False otherwise @@ -405,17 +408,17 @@ vpMbHiddenFaces<PolygonType>::setVisiblePrivate(const vpHomogeneousMatrix &_cMo, */ template<class PolygonType> unsigned int -vpMbHiddenFaces<PolygonType>::setVisible(const vpImage<unsigned char>& _I, const vpCameraParameters &_cam, const vpHomogeneousMatrix &_cMo, const double &angle, bool &changed) +vpMbHiddenFaces<PolygonType>::setVisible(const vpImage<unsigned char>& I, const vpCameraParameters &cam, const vpHomogeneousMatrix &cMo, const double &angle, bool &changed) { - return setVisible(_I, _cam, _cMo, angle, angle, changed); + return setVisible(I, cam, cMo, angle, angle, changed); } /*! Compute the number of visible polygons. - \param _I : Image used to check if the region of interest is inside the image. - \param _cam : Camera parameters. - \param _cMo : The pose of the camera + \param I : Image used to check if the region of interest is inside the image. + \param cam : Camera parameters. + \param cMo : The pose of the camera \param changed : True if a face appeared, disappeared or too many points have been lost. False otherwise \param angleAppears : Angle used to test the appearance of a face \param angleDisappears : Angle used to test the disappearance of a face @@ -424,15 +427,15 @@ vpMbHiddenFaces<PolygonType>::setVisible(const vpImage<unsigned char>& _I, const */ template<class PolygonType> unsigned int -vpMbHiddenFaces<PolygonType>::setVisible(const vpImage<unsigned char>& _I, const vpCameraParameters &_cam, const vpHomogeneousMatrix &_cMo, const double &angleAppears, const double &angleDisappears, bool &changed) +vpMbHiddenFaces<PolygonType>::setVisible(const vpImage<unsigned char>& I, const vpCameraParameters &cam, const vpHomogeneousMatrix &cMo, const double &angleAppears, const double &angleDisappears, bool &changed) { - return setVisiblePrivate(_cMo,angleAppears,angleDisappears,changed,false,true,_I,_cam); + return setVisiblePrivate(cMo,angleAppears,angleDisappears,changed,false,true,I,cam); } /*! Compute the number of visible polygons. - \param _cMo : The pose of the camera + \param cMo : The pose of the camera \param angleAppears : Angle used to test the appearance of a face \param angleDisappears : Angle used to test the disappearance of a face \param changed : True if a face appeared, disappeared or too many points have been lost. False otherwise @@ -441,23 +444,23 @@ vpMbHiddenFaces<PolygonType>::setVisible(const vpImage<unsigned char>& _I, const */ template<class PolygonType> unsigned int -vpMbHiddenFaces<PolygonType>::setVisible(const vpHomogeneousMatrix &_cMo, const double &angleAppears, const double &angleDisappears, bool &changed) +vpMbHiddenFaces<PolygonType>::setVisible(const vpHomogeneousMatrix &cMo, const double &angleAppears, const double &angleDisappears, bool &changed) { - return setVisiblePrivate(_cMo,angleAppears,angleDisappears,changed,false); + return setVisiblePrivate(cMo,angleAppears,angleDisappears,changed,false); } #ifdef VISP_HAVE_OGRE /*! Initialise the ogre context for face visibility tests. - \param _cam : Camera parameters. + \param cam : Camera parameters. */ template<class PolygonType> void -vpMbHiddenFaces<PolygonType>::initOgre(vpCameraParameters _cam) +vpMbHiddenFaces<PolygonType>::initOgre(const vpCameraParameters &cam) { ogreInitialised = true; - ogre->setCameraParameters(_cam); + ogre->setCameraParameters(cam); ogre->init(ogreBackground, false, true); for(unsigned int n = 0 ; n < Lpol.size(); n++){ @@ -482,11 +485,11 @@ vpMbHiddenFaces<PolygonType>::initOgre(vpCameraParameters _cam) /*! Update the display in Ogre Window. - \param _cMo : Pose used to display. + \param cMo : Pose used to display. */ template<class PolygonType> void -vpMbHiddenFaces<PolygonType>::displayOgre(const vpHomogeneousMatrix &_cMo) +vpMbHiddenFaces<PolygonType>::displayOgre(const vpHomogeneousMatrix &cMo) { if(ogreInitialised && !ogre->isWindowHidden()){ for(unsigned int i = 0 ; i < Lpol.size() ; i++){ @@ -496,16 +499,16 @@ vpMbHiddenFaces<PolygonType>::displayOgre(const vpHomogeneousMatrix &_cMo) else lOgrePolygons[i]->setVisible(false); } - ogre->display(ogreBackground, _cMo); + ogre->display(ogreBackground, cMo); } } /*! Compute the number of visible polygons through Ogre3D. - \param _I : Image used to check if the region of interest is inside the image. - \param _cam : Camera parameters. - \param _cMo : The pose of the camera + \param I : Image used to check if the region of interest is inside the image. + \param cam : Camera parameters. + \param cMo : The pose of the camera \param changed : True if a face appeared, disappeared or too many points have been lost. False otherwise \param angleAppears : Angle used to test the appearance of a face \param angleDisappears : Angle used to test the disappearance of a face @@ -514,15 +517,15 @@ vpMbHiddenFaces<PolygonType>::displayOgre(const vpHomogeneousMatrix &_cMo) */ template<class PolygonType> unsigned int -vpMbHiddenFaces<PolygonType>::setVisibleOgre(const vpImage<unsigned char>& _I, const vpCameraParameters &_cam, const vpHomogeneousMatrix &_cMo, const double &angleAppears, const double &angleDisappears, bool &changed) +vpMbHiddenFaces<PolygonType>::setVisibleOgre(const vpImage<unsigned char>& I, const vpCameraParameters &cam, const vpHomogeneousMatrix &cMo, const double &angleAppears, const double &angleDisappears, bool &changed) { - return setVisiblePrivate(_cMo,angleAppears,angleDisappears,changed,true,true,_I,_cam); + return setVisiblePrivate(cMo,angleAppears,angleDisappears,changed,true,true,I,cam); } /*! Compute the number of visible polygons through Ogre3D. - \param _cMo : The pose of the camera + \param cMo : The pose of the camera \param angleAppears : Angle used to test the appearance of a face \param angleDisappears : Angle used to test the disappearance of a face \param changed : True if a face appeared, disappeared or too many points have been lost. False otherwise @@ -531,9 +534,9 @@ vpMbHiddenFaces<PolygonType>::setVisibleOgre(const vpImage<unsigned char>& _I, c */ template<class PolygonType> unsigned int -vpMbHiddenFaces<PolygonType>::setVisibleOgre(const vpHomogeneousMatrix &_cMo, const double &angleAppears, const double &angleDisappears, bool &changed) +vpMbHiddenFaces<PolygonType>::setVisibleOgre(const vpHomogeneousMatrix &cMo, const double &angleAppears, const double &angleDisappears, bool &changed) { - return setVisiblePrivate(_cMo,angleAppears,angleDisappears,changed,true); + return setVisiblePrivate(cMo,angleAppears,angleDisappears,changed,true); } /*! @@ -594,7 +597,8 @@ vpMbHiddenFaces<PolygonType>::isVisibleOgre(const vpTranslationVector &cameraPos it++; while(!visible && it != result.end()){ distance = it->distance; - if(distance == distancePrev){ + //if(distance == distancePrev){ + if(std::fabs(distance - distancePrev) < distance * std::numeric_limits<double>::epsilon()){ if(it->movable->getName() == Ogre::StringConverter::toString(index)){ visible = true; break; @@ -630,18 +634,18 @@ vpMbHiddenFaces<PolygonType>::isVisibleOgre(const vpTranslationVector &cameraPos Compute the number of visible polygons. - \param _cMo : The pose of the camera + \param cMo : The pose of the camera \return Return the number of visible polygons */ template<class PolygonType> unsigned int -vpMbHiddenFaces<PolygonType>::setVisible(const vpHomogeneousMatrix &_cMo) +vpMbHiddenFaces<PolygonType>::setVisible(const vpHomogeneousMatrix &cMo) { nbVisiblePolygon = 0 ; for(unsigned int i = 0 ; i < Lpol.size() ; i++){ - if (Lpol[i]->isVisible(_cMo, depthTest)){ + if (Lpol[i]->isVisible(cMo, depthTest)){ nbVisiblePolygon++; } } diff --git a/src/tracking/mbt/vpMbTracker.cpp b/src/tracking/mbt/vpMbTracker.cpp index 44ce1855ad0f8eb4b4a6e9f802243f74ef506464..1752beaea7a982307968a67d39599ef9d2927af3 100755 --- a/src/tracking/mbt/vpMbTracker.cpp +++ b/src/tracking/mbt/vpMbTracker.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMbTracker.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: vpMbTracker.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -93,10 +93,9 @@ */ vpMbTracker::vpMbTracker() + : cam(), cMo(), modelFileName(), modelInitialised(false), + poseSavingFilename(), computeCovariance(false), covarianceMatrix(), displayFeatures(false) { - modelInitialised = false; - computeCovariance = false; - displayFeatures = false; } /*! @@ -251,6 +250,11 @@ vpMbTracker::initClick(const vpImage<unsigned char>& I, const std::string& initF unsigned int n ; finit >> n ; std::cout << "number of points " << n << std::endl ; + if (n > 100000) { + throw vpException(vpException::badValue, + "Exceed the max number of points."); + } + vpPoint *P = new vpPoint [n] ; for (unsigned int i=0 ; i < n ; i++){ finit >> X ; @@ -305,7 +309,7 @@ vpMbTracker::initClick(const vpImage<unsigned char>& I, const std::string& initF vpDisplay::flush(I) ; - vpMouseButton::vpMouseButtonType button = vpMouseButton::button1; + button = vpMouseButton::button1; while (!vpDisplay::getClick(I, ip, button)) ; @@ -486,6 +490,12 @@ void vpMbTracker::initFromPoints( const vpImage<unsigned char>& I, const std::st double X, Y, Z; finit >> size ; std::cout << "number of points " << size << std::endl ; + + if (size > 100000) { + throw vpException(vpException::badValue, + "Exceed the max number of points."); + } + vpPoint *P = new vpPoint [size]; vpPose pose ; @@ -629,11 +639,11 @@ void vpMbTracker::initFromPose(const vpImage<unsigned char>& I, const std::strin Initialise the tracking thanks to the pose. \param I : Input image - \param cMo : Pose matrix. + \param cMo_ : Pose matrix. */ -void vpMbTracker::initFromPose(const vpImage<unsigned char>& I, const vpHomogeneousMatrix &cMo) +void vpMbTracker::initFromPose(const vpImage<unsigned char>& I, const vpHomogeneousMatrix &cMo_) { - this->cMo = cMo; + this->cMo = cMo_; init(I); } @@ -839,7 +849,13 @@ vpMbTracker::loadCAOModel(const std::string& modelFile) char c; // Extraction of the version (remove empty line and commented ones (comment // line begin with the #)). - while( (fileId.get(c)!=NULL)&&(c == '#')) fileId.ignore(256,'\n'); + //while ((fileId.get(c) != NULL) && (c == '#')) fileId.ignore(256, '\n'); + fileId.get(c); + while (!fileId.fail() && (c == '#')) + { + fileId.ignore(256, '\n'); + fileId.get(c); + } fileId.unget(); int caoVersion; @@ -848,22 +864,42 @@ vpMbTracker::loadCAOModel(const std::string& modelFile) fileId >> caoVersion; } else{ - std::cout <<"in vpMbEdgeTracker::loadCAOModel -> Bad parameter header file : use V0, V1, ..."; + std::cout <<"in vpMbTracker::loadCAOModel() -> Bad parameter header file : use V0, V1, ..."; throw vpException(vpException::badValue, - "in vpMbEdgeTracker::loadCAOModel -> Bad parameter header file : use V0, V1, ..."); + "in vpMbTracker::loadCAOModel() -> Bad parameter header file : use V0, V1, ..."); } - while( (fileId.get(c)!=NULL)&&(c!='\n')) ; - while( (fileId.get(c)!=NULL)&&(c == '#')) fileId.ignore(256,'\n') ; + //while( (fileId.get(c)!=NULL)&&(c!='\n')) ; + fileId.get(c); + while (!fileId.fail() && (c != '\n')) + { + fileId.get(c); + } + + //while ((fileId.get(c) != NULL) && (c == '#')) fileId.ignore(256, '\n'); + fileId.get(c); + while (!fileId.fail() && (c == '#')) + { + fileId.ignore(256, '\n'); + fileId.get(c); + } fileId.unget(); //Read the points unsigned int caoNbrPoint; fileId >> caoNbrPoint; std::cout << "> " << caoNbrPoint << " points" << std::endl; - vpPoint *caoPoints = NULL; - if (caoNbrPoint > 0) - caoPoints = new vpPoint[caoNbrPoint]; + if (caoNbrPoint > 100000) { + throw vpException(vpException::badValue, + "Exceed the max number of points in the CAO model."); + } + + if (caoNbrPoint == 0) { + throw vpException(vpException::badValue, + "in vpMbTracker::loadCAOModel() -> no points are defined"); + + } + vpPoint *caoPoints = new vpPoint[caoNbrPoint]; double x ; // 3D coordinates double y ; @@ -872,7 +908,6 @@ vpMbTracker::loadCAOModel(const std::string& modelFile) int i ; // image coordinate (used for matching) int j ; - for(unsigned int k=0; k < caoNbrPoint; k++){ fileId >> x ; fileId >> y ; @@ -888,8 +923,20 @@ vpMbTracker::loadCAOModel(const std::string& modelFile) caoPoints[k].setWorldCoordinates(x, y, z) ; } - while( (fileId.get(c)!=NULL)&&(c!='\n')) ; - while( (fileId.get(c)!=NULL)&&(c == '#')) fileId.ignore(256,'\n'); + //while( (fileId.get(c)!=NULL)&&(c!='\n')) ; + fileId.get(c); + while (!fileId.fail() && (c != '\n')) + { + fileId.get(c); + } + + //while ((fileId.get(c) != NULL) && (c == '#')) fileId.ignore(256, '\n'); + fileId.get(c); + while (!fileId.fail() && (c == '#')) + { + fileId.ignore(256, '\n'); + fileId.get(c); + } fileId.unget(); //Read the lines @@ -897,6 +944,13 @@ vpMbTracker::loadCAOModel(const std::string& modelFile) fileId >> caoNbrLine; unsigned int *caoLinePoints = NULL; std::cout << "> " << caoNbrLine << " lines" << std::endl; + + if (caoNbrLine > 100000) { + delete [] caoPoints; + throw vpException(vpException::badValue, + "Exceed the max number of lines in the CAO model."); + } + if (caoNbrLine > 0) caoLinePoints = new unsigned int[2*caoNbrLine]; @@ -924,23 +978,48 @@ vpMbTracker::loadCAOModel(const std::string& modelFile) } } - while( (fileId.get(c)!=NULL)&&(c!='\n')) ; - while( (fileId.get(c)!=NULL)&&(c == '#')) fileId.ignore(256,'\n'); - fileId.unget(); + //while( (fileId.get(c)!=NULL)&&(c!='\n')) ; + fileId.get(c); + while (!fileId.fail() && (c != '\n')) + { + fileId.get(c); + } + //while ((fileId.get(c) != NULL) && (c == '#')) fileId.ignore(256, '\n'); + fileId.get(c); + while (!fileId.fail() && (c == '#')) + { + fileId.ignore(256, '\n'); + fileId.get(c); + } + fileId.unget(); - /* Load polygon from the lines extracted earlier + /* Load polygon from the lines extracted earlier (the first point of the line is used)*/ unsigned int caoNbrPolygonLine; fileId >> caoNbrPolygonLine; std::cout << "> " << caoNbrPolygonLine << " polygon line" << std::endl; + if (caoNbrPolygonLine > 100000) { + delete [] caoPoints; + delete [] caoLinePoints; + throw vpException(vpException::badValue, "Exceed the max number of polygon lines."); + } + unsigned int index; for(unsigned int k = 0;k < caoNbrPolygonLine; k++){ unsigned int nbLinePol; fileId >> nbLinePol; std::vector<vpPoint> corners; - for(unsigned int i = 0; i < nbLinePol; i++){ + if (nbLinePol > 100000) { + throw vpException(vpException::badValue, "Exceed the max number of lines."); + } + + for(unsigned int n = 0; n < nbLinePol; n++){ fileId >> index; + if (2*index > 2*caoNbrLine-1) { + throw vpException(vpException::badValue, "Exceed the max number of lines."); + } + corners.push_back(caoPoints[caoLinePoints[2*index]]); } if(k != caoNbrPolygonLine-1){// the rest of the line is removed (not the last one due to the need to remove possible comments). @@ -949,20 +1028,44 @@ vpMbTracker::loadCAOModel(const std::string& modelFile) initFaceFromCorners(corners, k); } - while( (fileId.get(c)!=NULL)&&(c!='\n')) ; - while( (fileId.get(c)!=NULL)&&(c == '#')) fileId.ignore(256,'\n'); + //while( (fileId.get(c)!=NULL)&&(c!='\n')) ; + fileId.get(c); + while (!fileId.fail() && (c != '\n')) + { + fileId.get(c); + } + + //while ((fileId.get(c) != NULL) && (c == '#')) fileId.ignore(256, '\n'); + fileId.get(c); + while (!fileId.fail() && (c == '#')) + { + fileId.ignore(256, '\n'); + fileId.get(c); + } fileId.unget(); - /* Extract the polygon using the point coordinates (top of the file) */ + /* Extract the polygon using the point coordinates (top of the file) */ unsigned int caoNbrPolygonPoint; fileId >> caoNbrPolygonPoint; std::cout << "> " << caoNbrPolygonPoint << " polygon point" << std::endl; + + if (caoNbrPolygonPoint > 100000) { + throw vpException(vpException::badValue, "Exceed the max number of polygon point."); + } + for(unsigned int k = 0;k < caoNbrPolygonPoint; k++){ - int nbPointPol; + unsigned int nbPointPol; fileId >> nbPointPol; + if (nbPointPol > 100000) { + throw vpException(vpException::badValue, "Exceed the max number of points."); + } + std::vector<vpPoint> corners; - for(int i = 0; i < nbPointPol; i++){ + for(unsigned int n = 0; n < nbPointPol; n++){ fileId >> index; + if (index > caoNbrPoint-1) { + throw vpException(vpException::badValue, "Exceed the max number of points."); + } corners.push_back(caoPoints[index]); } if(k != caoNbrPolygonPoint-1){// the rest of the line is removed (not the last one due to the need to remove possible comments). @@ -973,9 +1076,20 @@ vpMbTracker::loadCAOModel(const std::string& modelFile) unsigned int caoNbCylinder; try{ - while( (fileId.get(c)!=NULL)&&(c!='\n')) ; - while( (fileId.get(c)!=NULL)&&(c == '#')) fileId.ignore(256,'\n'); - fileId.unget(); + //while( (fileId.get(c)!=NULL)&&(c!='\n')) ; + fileId.get(c); + while (!fileId.fail() && (c != '\n')) + { + fileId.get(c); + } + + //while ((fileId.get(c) != NULL) && (c == '#')) fileId.ignore(256, '\n'); + fileId.get(c); + while (!fileId.fail() && (c == '#')) + { + fileId.ignore(256, '\n'); + fileId.get(c); + } fileId.unget(); if(fileId.eof()){// check if not at the end of the file (for old style files) delete[] caoPoints; @@ -988,6 +1102,10 @@ vpMbTracker::loadCAOModel(const std::string& modelFile) fileId >> caoNbCylinder; std::cout << "> " << caoNbCylinder << " cylinder" << std::endl; + if (caoNbCylinder > 100000) { + throw vpException(vpException::badValue, "Exceed the max number of cylinders."); + } + for(unsigned int k=0; k<caoNbCylinder; ++k){ double radius; unsigned int indexP1, indexP2; @@ -1011,9 +1129,6 @@ vpMbTracker::loadCAOModel(const std::string& modelFile) } - - - #ifdef VISP_HAVE_COIN /*! Extract a VRML object Group. diff --git a/src/tracking/mbt/vpMbTracker.h b/src/tracking/mbt/vpMbTracker.h index e25d4b90dc81b3544085a9e7e7897f8dd03d383b..4e8e49a65b71f7dfb04d8c314ca16dba07d777b9 100755 --- a/src/tracking/mbt/vpMbTracker.h +++ b/src/tracking/mbt/vpMbTracker.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMbTracker.h 4317 2013-07-17 09:40:17Z fspindle $ + * $Id: vpMbTracker.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -60,7 +60,7 @@ #ifdef VISP_HAVE_COIN //Work around to avoid type redefinition int8_t with Coin -// #if defined(WIN32) && defined(VISP_HAVE_OGRE) && (_MSC_VER >= 1600) // Visual Studio 2010 +// #if defined(_WIN32) && defined(VISP_HAVE_OGRE) && (_MSC_VER >= 1600) // Visual Studio 2010 // #define HAVE_INT8_T 1 // #endif @@ -153,9 +153,9 @@ public: /*! Get the camera parameters. - \param cam : copy of the camera parameters used by the tracker. + \param camera : copy of the camera parameters used by the tracker. */ - virtual void getCameraParameters(vpCameraParameters& cam) const { cam = this->cam;} + virtual void getCameraParameters(vpCameraParameters& camera) const { camera = this->cam;} /*! Get the covariance matrix. @@ -172,9 +172,9 @@ public: cMo is the matrix which can be used to express coordinates from the object frame to camera frame. - \param cMo : the pose + \param cMo_ : the pose */ - inline void getPose(vpHomogeneousMatrix& cMo) const {cMo = this->cMo;} + inline void getPose(vpHomogeneousMatrix& cMo_) const {cMo_ = this->cMo;} /*! Get the current pose between the object and the camera. @@ -228,9 +228,9 @@ public: /*! Set the camera parameters. - \param cam : the new camera parameters + \param camera : the new camera parameters */ - virtual void setCameraParameters(const vpCameraParameters& cam) {this->cam = cam;} + virtual void setCameraParameters(const vpCameraParameters& camera) {this->cam = camera;} /*! Set if the covaraince matrix has to be computed. @@ -305,7 +305,7 @@ protected: \param radius : Radius of the cylinder. \param indexCylinder : Index of the cylinder. */ - virtual void initCylinder(const vpPoint& p1, const vpPoint p2, const double radius, const unsigned int indexCylinder=0)=0; + virtual void initCylinder(const vpPoint& p1, const vpPoint &p2, const double radius, const unsigned int indexCylinder=0)=0; /*! Add a face to track from its corners (in the object frame). This method is diff --git a/src/tracking/mbt/vpMbXmlParser.cpp b/src/tracking/mbt/vpMbXmlParser.cpp new file mode 100644 index 0000000000000000000000000000000000000000..84b450b9341d36caf5f9b0a14fb642a389c60b22 --- /dev/null +++ b/src/tracking/mbt/vpMbXmlParser.cpp @@ -0,0 +1,323 @@ +/**************************************************************************** + * + * $Id: vpMbXmlParser.cpp 4577 2014-01-10 16:19:41Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Load XML Parameter for Model Based Tracker. + * + * Authors: + * Aurelien Yol + * + *****************************************************************************/ +#include <visp/vpConfig.h> + + +#ifdef VISP_HAVE_XML2 + +#include <iostream> +#include <map> + +#include <libxml/xmlmemory.h> /* Fonctions de la lib XML. */ + +#include <visp/vpMbXmlParser.h> + + +/*! + Default constructor. + +*/ +vpMbXmlParser::vpMbXmlParser() + : cam(), angleAppear(70), angleDisappear(80), + hasNearClipping(false), nearClipping(false), + hasFarClipping(false), farClipping(false), fovClipping(false) + +{ + init(); +} + +/*! + Default destructor. +*/ +vpMbXmlParser::~vpMbXmlParser() +{ +} + +/*! + Initialise internal variables (including the map). +*/ +void +vpMbXmlParser::init() +{ + setMainTag("conf"); + + nodeMap["conf"] = conf; + nodeMap["face"] = face; + nodeMap["angle_appear"] = angle_appear; + nodeMap["angle_disappear"] = angle_disappear; + nodeMap["near_clipping"] = near_clipping; + nodeMap["far_clipping"] = far_clipping; + nodeMap["fov_clipping"] = fov_clipping; + nodeMap["camera"] = camera; + nodeMap["height"] = height; + nodeMap["width"] = width; + nodeMap["u0"] = u0; + nodeMap["v0"] = v0; + nodeMap["px"] = px; + nodeMap["py"] = py; +} + +/*! + Parse the file in parameters. + This method is deprecated, use parse() instead. + + \param filename : File to parse. +*/ +void +vpMbXmlParser::parse(const char * filename) +{ + std::string file = filename; + vpXmlParser::parse(file); +} + +/*! + Write info to file. + + \warning Useless, so not yet implemented => Throw exception. +*/ +void +vpMbXmlParser::writeMainClass(xmlNodePtr /*node*/) +{ + throw vpException(vpException::notImplementedError, "Not yet implemented." ); +} + +/*! + Read the parameters of the class from the file given by its document pointer + and by its root node. + + \param doc : Document to parse. + \param node : Root node. +*/ +void +vpMbXmlParser::readMainClass(xmlDocPtr doc, xmlNodePtr node) +{ + bool camera_node = false; + bool face_node = false; + + for(xmlNodePtr dataNode = node->xmlChildrenNode; dataNode != NULL; dataNode = dataNode->next) { + if(dataNode->type == XML_ELEMENT_NODE){ + std::map<std::string, int>::iterator iter_data= this->nodeMap.find((char*)dataNode->name); + if(iter_data != nodeMap.end()){ + switch (iter_data->second){ + case camera:{ + this->read_camera (doc, dataNode); + camera_node = true; + }break; + case face:{ + this->read_face(doc, dataNode); + face_node = true; + }break; + default:{ +// vpTRACE("unknown tag in read_sample : %d, %s", iter_data->second, (iter_data->first).c_str()); + }break; + } + } + } + } + + if(!camera_node) { + std::cout << "camera : u0 : "<< this->cam.get_u0() << " (default)" <<std::endl; + std::cout << "camera : v0 : "<< this->cam.get_v0() << " (default)" <<std::endl; + std::cout << "camera : px : "<< this->cam.get_px() << " (default)" <<std::endl; + std::cout << "camera : py : "<< this->cam.get_py() << " (default)" <<std::endl; + } + + if(!face_node) { + std::cout << "face : Angle Appear : "<< angleAppear <<" (default)" <<std::endl; + std::cout << "face : Angle Disappear : "<< angleDisappear <<" (default)" <<std::endl; + } +} + +/*! + Read camera information. + + \throw vpException::fatalError if there was an unexpected number of data. + + \param doc : Pointer to the document. + \param node : Pointer to the node of the camera information. +*/ +void +vpMbXmlParser::read_camera (xmlDocPtr doc, xmlNodePtr node) +{ + bool u0_node = false; + bool v0_node = false; + bool px_node = false; + bool py_node = false; + + // current data values. + double d_u0 = this->cam.get_u0(); + double d_v0 = this->cam.get_v0(); + double d_px = this->cam.get_px(); + double d_py = this->cam.get_py(); + + for(xmlNodePtr dataNode = node->xmlChildrenNode; dataNode != NULL; dataNode = dataNode->next) { + if(dataNode->type == XML_ELEMENT_NODE){ + std::map<std::string, int>::iterator iter_data= this->nodeMap.find((char*)dataNode->name); + if(iter_data != nodeMap.end()){ + switch (iter_data->second){ + case u0:{ + d_u0 = xmlReadDoubleChild(doc, dataNode); + u0_node = true; + }break; + case v0:{ + d_v0 = xmlReadDoubleChild(doc, dataNode); + v0_node = true; + }break; + case px:{ + d_px = xmlReadDoubleChild(doc, dataNode); + px_node = true; + }break; + case py:{ + d_py = xmlReadDoubleChild(doc, dataNode); + py_node = true; + }break; + default:{ +// vpTRACE("unknown tag in read_camera : %d, %s", iter_data->second, (iter_data->first).c_str()); + }break; + } + } + } + } + + this->cam.initPersProjWithoutDistortion(d_px, d_py, d_u0, d_v0) ; + + if(!u0_node) + std::cout << "camera : u0 : "<< this->cam.get_u0() << " (default)" <<std::endl; + else + std::cout << "camera : u0 : "<< this->cam.get_u0() <<std::endl; + + if(!v0_node) + std::cout << "camera : v0 : "<< this->cam.get_v0() << " (default)" <<std::endl; + else + std::cout << "camera : v0 : "<< this->cam.get_v0() <<std::endl; + + if(!px_node) + std::cout << "camera : px : "<< this->cam.get_px() << " (default)" <<std::endl; + else + std::cout << "camera : px : "<< this->cam.get_px() <<std::endl; + + if(!py_node) + std::cout << "camera : py : "<< this->cam.get_py() << " (default)" <<std::endl; + else + std::cout << "camera : py : "<< this->cam.get_py() <<std::endl; +} + +/*! + Read face information. + + \throw vpException::fatalError if there was an unexpected number of data. + + \param doc : Pointer to the document. + \param node : Pointer to the node of the camera information. +*/ +void +vpMbXmlParser::read_face(xmlDocPtr doc, xmlNodePtr node) +{ + bool angle_appear_node = false; + bool angle_disappear_node = false; + bool near_clipping_node = false; + bool far_clipping_node = false; + bool fov_clipping_node = false; + + for(xmlNodePtr dataNode = node->xmlChildrenNode; dataNode != NULL; dataNode = dataNode->next) { + if(dataNode->type == XML_ELEMENT_NODE){ + std::map<std::string, int>::iterator iter_data= this->nodeMap.find((char*)dataNode->name); + if(iter_data != nodeMap.end()){ + switch (iter_data->second){ + case angle_appear:{ + angleAppear = xmlReadDoubleChild(doc, dataNode); + angle_appear_node = true; + }break; + case angle_disappear:{ + angleDisappear = xmlReadDoubleChild(doc, dataNode); + angle_disappear_node = true; + }break; + case near_clipping:{ + nearClipping = xmlReadDoubleChild(doc, dataNode); + near_clipping_node = true; + hasNearClipping = true; + }break; + case far_clipping:{ + farClipping = xmlReadDoubleChild(doc, dataNode); + far_clipping_node = true; + hasFarClipping = true; + }break; + case fov_clipping:{ + if (xmlReadIntChild(doc, dataNode)) + fovClipping = true; + else + fovClipping = false; + fov_clipping_node = true; + }break; + default:{ +// vpTRACE("unknown tag in read_camera : %d, %s", iter_data->second, (iter_data->first).c_str()); + }break; + } + } + } + } + + if(!angle_appear_node) + std::cout << "face : Angle Appear : "<< angleAppear << " (default)" <<std::endl; + else + std::cout << "face : Angle Appear : "<< angleAppear <<std::endl; + + if(!angle_disappear_node) + std::cout << "face : Angle Disappear : "<< angleDisappear << " (default)" <<std::endl; + else + std::cout << "face : Angle Disappear : "<< angleDisappear <<std::endl; + + if(near_clipping_node) + std::cout << "face : Near Clipping : "<< nearClipping <<std::endl; + + if(far_clipping_node) + std::cout << "face : Far Clipping : "<< farClipping <<std::endl; + + if(fov_clipping_node) { + if(fovClipping) + std::cout << "face : Fov Clipping : True" <<std::endl; + else + std::cout << "face : Fov Clipping : False" <<std::endl; + } +} + +#endif + diff --git a/src/tracking/mbt/vpMbXmlParser.h b/src/tracking/mbt/vpMbXmlParser.h new file mode 100644 index 0000000000000000000000000000000000000000..198d70b2d13c1735b9ff609ebd81c0fc3dde279c --- /dev/null +++ b/src/tracking/mbt/vpMbXmlParser.h @@ -0,0 +1,210 @@ +/**************************************************************************** + * + * $Id: vpMbXmlParser.h 4574 2014-01-09 08:48:51Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Load XML Parameter for Model Based Tracker. + * + * Authors: + * Aurelien Yol + * + *****************************************************************************/ + +/*! + * \file vpMbXmlParser.h + * \brief Parse an Xml file to extract configuration parameters of a mbtConfig object. +*/ + +#ifndef vpMbXmlParser_HH +#define vpMbXmlParser_HH + +#include <visp/vpConfig.h> + +#ifdef VISP_HAVE_XML2 + +#include <libxml/xmlmemory.h> /* Fonctions de la lib XML. */ + +#include <visp/vpXmlParser.h> +#include <visp/vpCameraParameters.h> + +/*! + \class vpMbXmlParser + \brief Parse an Xml file to extract configuration parameters of a mbtConfig object. + \ingroup ModelBasedTracking + + Data parser for the model based tracker. + + */ +class VISP_EXPORT vpMbXmlParser: public vpXmlParser +{ +protected: + //! Camera parameters. + vpCameraParameters cam; + //! Angle to determine if a face appeared + double angleAppear; + //! Angle to determine if a face disappeared + double angleDisappear; + //! Is near clipping distance specified? + bool hasNearClipping; + //! Near clipping distance + double nearClipping; + //! Is far clipping distance specified? + bool hasFarClipping; + //! Near clipping distance + double farClipping; + //! Fov Clipping + bool fovClipping; + + typedef enum{ + conf, + face, + angle_appear, + angle_disappear, + near_clipping, + far_clipping, + fov_clipping, + camera, + height, + width, + u0, + v0, + px, + py, + last + } dataToParseMb; + + +public: + + vpMbXmlParser(); + virtual ~vpMbXmlParser(); + + /*! + Get the angle to determine if a face appeared. + + \return angleAppear + */ + inline double getAngleAppear() const {return angleAppear;} + + /*! + Get the angle to determine if a face disappeared. + + \return angleDisappear + */ + inline double getAngleDisappear() const {return angleDisappear;} + + void getCameraParameters(vpCameraParameters& _cam) const { _cam = this->cam;} + + /*! + Get the far clipping distance. + + \return farClipping + */ + inline double getFarClippingDistance() const {return farClipping;} + + /*! + Use FOV clipping + + \return True if yes, False otherwise. + */ + inline bool getFovClipping() const {return fovClipping;} + + /*! + Get the near clipping distance. + + \return nearClipping + */ + inline double getNearClippingDistance() const {return nearClipping;} + + /*! + Has Far clipping been specified? + + \return True if yes, False otherwise. + */ + inline bool hasFarClippingDistance() const {return hasFarClipping;} + + /*! + Has Near clipping been specified? + + \return True if yes, False otherwise. + */ + inline bool hasNearClippingDistance() const {return hasNearClipping;} + + void parse(const char * filename); + + virtual void readMainClass(xmlDocPtr doc, xmlNodePtr node); + void read_camera (xmlDocPtr doc, xmlNodePtr node); + void read_face(xmlDocPtr doc, xmlNodePtr node); + + /*! + Set the angle to determine if a face appeared. + + \param aappear : New angleAppear + */ + inline void setAngleAppear(const double &aappear) {angleAppear = aappear;} + + /*! + Set the angle to determine if a face disappeared. + + \param adisappear : New angleDisappear + */ + inline void setAngleDisappear(const double &adisappear) {angleDisappear = adisappear;} + + void setCameraParameters(const vpCameraParameters &_cam){ cam = _cam; } + + /*! + Set the far clipping distance. + + \param fclip : New farClipping + */ + inline void setFarClippingDistance(const double &fclip) {farClipping = fclip;} + + /*! + Set the near clipping distance. + + \param nclip : New nearClipping + */ + inline void setNearClippingDistance(const double &nclip) {nearClipping = nclip;} + + void writeMainClass(xmlNodePtr node); + +protected: + void init(); + +}; + +#endif + +#endif /* NMBXMLPARSER_H_ */ + + + diff --git a/src/tracking/moments/vpMoment.cpp b/src/tracking/moments/vpMoment.cpp index e1c7a0ade932b401fb3aad4111c47ae6f8832202..e681b382baf905f1fdeef482bba57b72f6c549f6 100644 --- a/src/tracking/moments/vpMoment.cpp +++ b/src/tracking/moments/vpMoment.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMoment.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMoment.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -52,8 +52,7 @@ /*! Default constructor */ -vpMoment::vpMoment(): object(NULL),moments(NULL) { -} +vpMoment::vpMoment(): object(NULL), moments(NULL), values() {} /*! @@ -99,23 +98,27 @@ int main() \endcode - \param moments : database of moment primitives. + \param data_base : database of moment primitives. */ -void vpMoment::linkTo(vpMomentDatabase& moments){ - std::strcpy(_name,name()); - this->moments=&moments; +void vpMoment::linkTo(vpMomentDatabase& data_base){ + if (strlen( name() ) >= 255) { + throw(vpException(vpException::memoryAllocationError, + "Not enough memory to intialize the moment name")); + } + std::strcpy(_name,name()); + this->moments=&data_base; - moments.add(*this,_name); + data_base.add(*this,_name); } /*! Updates the moment with the current object. This does not compute any values. - \param object : object descriptor of the current camera vision. + \param moment_object : object descriptor of the current camera vision. */ -void vpMoment::update(vpMomentObject& object){ - this->object=&object; +void vpMoment::update(vpMomentObject& moment_object){ + this->object=&moment_object; } /*! @@ -123,7 +126,7 @@ void vpMoment::update(vpMomentObject& object){ \param os : a std::stream. \param m : a moment instance. */ -std::ostream & operator<<(std::ostream & os, const vpMoment& m){ +VISP_EXPORT std::ostream & operator<<(std::ostream & os, const vpMoment& m){ for(std::vector<double>::const_iterator i = m.values.begin();i!=m.values.end();i++) os << *i << ","; diff --git a/src/tracking/moments/vpMoment.h b/src/tracking/moments/vpMoment.h index 02ec5b9a8f8d620eb549f7cf6558fbb151a46721..470c9cc573ea0ac4c79f1158b9aee295bc004415 100644 --- a/src/tracking/moments/vpMoment.h +++ b/src/tracking/moments/vpMoment.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMoment.h 4219 2013-04-17 10:00:56Z mbakthav $ + * $Id: vpMoment.h 4583 2014-01-14 17:06:37Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -87,19 +87,23 @@ class vpMomentObject; Some moments can be computed only if they are linked to a a database containing their dependencies. Linking to a database is done using the vpMoment::linkTo(...) method. - There are no constraints about format of the array returned by vpMoment::get: any implementation is fine. + There are no constraints about format of the array returned by vpMoment::get(); any implementation is fine. Each moment must have a string name by implementing the char* vpMoment::name() method which allows to identify the moment in the database. Each moment must also implement a compute method describing how to obtain its values from the object. - \attention Order of moment computation DOES matter: when you compute (vpMoment::compute call) a moment, all moment dependencies must be computed. - Moments pre-implementes dans ViSP: + \attention Order of moment computation DOES matter: when you compute a moment using vpMoment::compute(), + all moment dependencies must be computed. + We recall that implemented moments are: - vpMomentAlpha + - vpMomentArea + - vpMomentAreaNormalized - vpMomentBasic - vpMomentCentered - vpMomentCInvariant - - vpMomentSInvariant - - vpMomentAreaNormalized + - vpMomentGravityCenter + - vpMomentGravityCenterNormalized + */ class VISP_EXPORT vpMoment{ private: @@ -116,17 +120,17 @@ class VISP_EXPORT vpMoment{ public: - inline vpMomentObject& getObject() const { return *object;} + inline const vpMomentObject& getObject() const { return *object;} vpMoment(); /*! Returns all values computed by the moment. \return vector of values */ - std::vector<double>& get(){ return values;} + const std::vector<double>& get() const { return values;} void linkTo(vpMomentDatabase& moments); void update(vpMomentObject& object); virtual void compute()=0; - virtual const char* name() = 0; + virtual const char* name() const = 0; friend VISP_EXPORT std::ostream & operator<<(std::ostream & os, const vpMoment& m); /*! diff --git a/src/tracking/moments/vpMomentAlpha.cpp b/src/tracking/moments/vpMomentAlpha.cpp index 0a1b9ca283816685c8e0425183a8c43f516de446..e6370ffe2ce7f4d48c74df874d6a03c9e2de67f1 100644 --- a/src/tracking/moments/vpMomentAlpha.cpp +++ b/src/tracking/moments/vpMomentAlpha.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMomentAlpha.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMomentAlpha.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -48,8 +48,8 @@ Empty constructor. Initializes alpha moment as a reference alpha. A default-constructed alpha moment may be used as a reference for other alphas. A reference alpha is class harbouring an alpha value computed for a \f$[-\pi/2..\pi/2]\f$ portion of the circle. Not setting a reference alpha will prevent you from doing more than 180deg rotation with moments. -*/ -vpMomentAlpha::vpMomentAlpha() : vpMoment(),isRef(true), symmetric(false){ + */ +vpMomentAlpha::vpMomentAlpha() : isRef(true), symmetric(false), ref(), alphaRef(0.) { values.resize(1); } @@ -57,102 +57,99 @@ vpMomentAlpha::vpMomentAlpha() : vpMoment(),isRef(true), symmetric(false){ Common constructor. Initializes alpha moment as a non-reference alpha. A default-constructed alpha moment must be used as a reference for other this alpha. A reference alpha is class harbouring an alpha value computed for a \f$[0..\pi]\f$ portion of the circle. Not having a reference alpha will prevent you from doing more than 180deg rotation with moments. - - \param ref : vector of 3rd order centered moments corresponding to the reference alpha in the following order: \f$\mu_{03},\mu_{12},\mu_{21},\mu_{30}\f$. - \param alphaRef : value of the reference alpha. + \param ref_ : vector of 3rd order centered moments corresponding to the reference alpha in the following order: \f$\mu_{03},\mu_{12},\mu_{21},\mu_{30}\f$. + \param alpha_ref : value of the reference alpha. */ -vpMomentAlpha::vpMomentAlpha(std::vector<double>& ref,double alphaRef) : vpMoment(),isRef(false),symmetric(false),ref(ref),alphaRef(alphaRef){ - for (std::vector<double>::iterator it = ref.begin(); it!=ref.end(); it++) - if (*it<=1e-4) - symmetric = true; - - values.resize(1); +vpMomentAlpha::vpMomentAlpha(std::vector<double>& ref_, double alpha_ref) + : vpMoment(),isRef(false),symmetric(false),ref(ref_),alphaRef(alpha_ref) +{ + for (std::vector<double>::iterator it = ref_.begin(); it!=ref_.end(); it++) + if (*it<=1e-4) + symmetric = true; + + values.resize(1); } /*! Compute the value of the alpha-moment. Depends on vpMomentCentered. -*/ + */ void vpMomentAlpha::compute(){ //symmetric = symmetric | this->getObject().isSymmetric(); - bool found_moment_centered; - - vpMomentCentered& momentCentered = (static_cast<vpMomentCentered&> (getMoments().get("vpMomentCentered", - found_moment_centered))); - - if (!found_moment_centered) - throw vpException(vpException::notInitialized, "vpMomentCentered not found"); - - double alpha = 0.5 * atan2(2.0 * momentCentered.get(1, 1), (momentCentered.get(2, 0) - momentCentered.get(0, 2))); - - unsigned int order = 4; - std::vector<double> rotMu(4); - std::vector<double> realMu(4); - - if (isRef) - { - alphaRef = alpha; - } - else - { - if (!symmetric) - { - double r11 = cos(alpha - alphaRef); - double r12 = sin(alpha - alphaRef); - double r21 = -sin(alpha - alphaRef); - double r22 = cos(alpha - alphaRef); - unsigned int idx = 0; - for (register unsigned int c = 0; c < (order) * (order); c++) - { - unsigned int i = c % order; - unsigned int j = c / order; - - if (i + j == 3) - { - double r11_k = 1.; - for (register unsigned int k = 0; k <= i; k++) - { - double r12_i_k = pow(r12, (int)(i - k)); - double comb_i_k = static_cast<double> (vpMath::comb(i, k)); - for (register unsigned int l = 0; l <= j; l++) - { - rotMu[idx] += static_cast<double> (comb_i_k * vpMath::comb(j, l) * r11_k * pow(r21, (int)l) * r12_i_k - * pow(r22, (int)(j - l)) * momentCentered.get(k + l, (unsigned int)(int)(i + j - k - l))); - } - r11_k *= r11; - } - realMu[idx] = momentCentered.get(i, j); - idx++; - } - } - - double sum = 0.; - bool signChange = true; - for (register unsigned int i = 0; i < 4; i++) - { - if (std::abs(rotMu[i]) > 1e10 * std::numeric_limits<double>::epsilon() && std::abs(ref[i]) > 1e10 - * std::numeric_limits<double>::epsilon() && rotMu[i] * ref[i] > 0) - signChange = false; - sum += std::abs(rotMu[i] * ref[i]); - } - - if (sum < 1e4 * std::numeric_limits<double>::epsilon()) - signChange = false; - if (signChange) - alpha = alpha + M_PI; - } - } - values[0] = alpha; + bool found_moment_centered; + + const vpMomentCentered& momentCentered = (static_cast<const vpMomentCentered&> (getMoments().get("vpMomentCentered", + found_moment_centered))); + + if (!found_moment_centered) + throw vpException(vpException::notInitialized, "vpMomentCentered not found"); + + double alpha = 0.5 * atan2(2.0 * momentCentered.get(1, 1), (momentCentered.get(2, 0) - momentCentered.get(0, 2))); + + unsigned int order = 4; + std::vector<double> rotMu(4); + std::vector<double> realMu(4); + + if (isRef) + { + alphaRef = alpha; + } + else + { + if (!symmetric) + { + double r11 = cos(alpha - alphaRef); + double r12 = sin(alpha - alphaRef); + double r21 = -sin(alpha - alphaRef); + double r22 = cos(alpha - alphaRef); + unsigned int idx = 0; + for (register unsigned int c = 0; c < (order) * (order); c++) + { + unsigned int i = c % order; + unsigned int j = c / order; + + if (i + j == 3) + { + double r11_k = 1.; + for (register unsigned int k = 0; k <= i; k++) + { + double r12_i_k = pow(r12, (int)(i - k)); + double comb_i_k = static_cast<double> (vpMath::comb(i, k)); + for (register unsigned int l = 0; l <= j; l++) + { + rotMu[idx] += static_cast<double> (comb_i_k * vpMath::comb(j, l) * r11_k * pow(r21, (int)l) * r12_i_k + * pow(r22, (int)(j - l)) * momentCentered.get(k + l, (unsigned int)(int)(i + j - k - l))); + } + r11_k *= r11; + } + realMu[idx] = momentCentered.get(i, j); + idx++; + } + } + + double sum = 0.; + bool signChange = true; + for (register unsigned int i = 0; i < 4; i++) + { + if (std::abs(rotMu[i]) > 1e10 * std::numeric_limits<double>::epsilon() && std::abs(ref[i]) > 1e10 + * std::numeric_limits<double>::epsilon() && rotMu[i] * ref[i] > 0) + signChange = false; + sum += std::abs(rotMu[i] * ref[i]); + } + + if (sum < 1e4 * std::numeric_limits<double>::epsilon()) + signChange = false; + if (signChange) + alpha = alpha + M_PI; + } + } + values[0] = alpha; } /*! Prints the value of the orientation. -*/ -std::ostream & operator<<(std::ostream & os, const vpMomentAlpha& c){ - os << c.values[0] ; - return os; + */ +VISP_EXPORT std::ostream & operator<<(std::ostream & os, const vpMomentAlpha& c){ + os << c.values[0] ; + return os; } - - - - diff --git a/src/tracking/moments/vpMomentAlpha.h b/src/tracking/moments/vpMomentAlpha.h index eed0d6aa759dae7ea72e3df1bd80c31de014f3ca..821c8e6c8ffd3e927b4fd51b9b5553d4a9c99ab0 100644 --- a/src/tracking/moments/vpMomentAlpha.h +++ b/src/tracking/moments/vpMomentAlpha.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMomentAlpha.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMomentAlpha.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -210,11 +210,27 @@ class VISP_EXPORT vpMomentAlpha : public vpMoment { /*! Retrieve the orientation of the object as a single double value. */ - double get(){ return values[0]; } + double get() const { return values[0]; } /*! Moment name. */ - const char* name(){return "vpMomentAlpha";} + const char* name() const {return "vpMomentAlpha";} + + inline bool is_ref() const + { + if (isRef) + return true; + else + return false; + } + + inline bool is_symmetric() const + { + if (symmetric) + return true; + else + return false; + } friend VISP_EXPORT std::ostream & operator<<(std::ostream & os, const vpMomentAlpha& v); diff --git a/src/tracking/moments/vpMomentArea.cpp b/src/tracking/moments/vpMomentArea.cpp index 5e23f6043cee55f59ddbdc879e70b4661a16e556..679aca15d3b1ad5f750a13d17516452d7856c21d 100644 --- a/src/tracking/moments/vpMomentArea.cpp +++ b/src/tracking/moments/vpMomentArea.cpp @@ -3,7 +3,7 @@ * $Id: vpMomentArea.cpp 3530 2012-01-03 10:52:12Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -55,7 +55,7 @@ void vpMomentArea::compute(){ /* getMoments() returns a reference to a vpMomentDatabase. It is a protected member of and is inherited from vpMoment * .get() is a member function of vpMomentDatabase that returns a specific moment which is linked to it */ - vpMomentCentered& momentCentered = static_cast<vpMomentCentered&>(getMoments().get("vpMomentCentered",found_moment_centered)); + const vpMomentCentered& momentCentered = static_cast<const vpMomentCentered&>(getMoments().get("vpMomentCentered",found_moment_centered)); if(!found_moment_centered) throw vpException(vpException::notInitialized,"vpMomentCentered not found"); values[0] = momentCentered.get(2,0) + momentCentered.get(0,2); } @@ -74,7 +74,7 @@ vpMomentArea::vpMomentArea() : vpMoment(){ /*! Outputs the moment's values to a stream. */ -std::ostream & operator<<(std::ostream & os, const vpMomentArea& m){ +VISP_EXPORT std::ostream & operator<<(std::ostream & os, const vpMomentArea& m){ os << "Area a:" << m.values[0]; return os; } diff --git a/src/tracking/moments/vpMomentArea.h b/src/tracking/moments/vpMomentArea.h index f70783fea12c249501a86f5f6905846065622cac..b14ebd3e87f39d6ac6fab7332d6797105bf83b39 100644 --- a/src/tracking/moments/vpMomentArea.h +++ b/src/tracking/moments/vpMomentArea.h @@ -3,7 +3,7 @@ * $Id: vpMomentArea.h 3530 2012-01-03 10:52:12Z mbakthav $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -61,7 +61,7 @@ class VISP_EXPORT vpMomentArea : public vpMoment { /*! Moment name. */ - const char* name(){return "vpMomentArea";} + const char* name() const {return "vpMomentArea";} friend VISP_EXPORT std::ostream & operator<<(std::ostream & os, const vpMomentArea& m); }; diff --git a/src/tracking/moments/vpMomentAreaNormalized.cpp b/src/tracking/moments/vpMomentAreaNormalized.cpp index 12b8113320e1775aea50859f27132fe78cd16b34..2c141de05040344b01b2b708fd39c86daabb9eff 100644 --- a/src/tracking/moments/vpMomentAreaNormalized.cpp +++ b/src/tracking/moments/vpMomentAreaNormalized.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMomentAreaNormalized.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMomentAreaNormalized.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -54,7 +54,7 @@ void vpMomentAreaNormalized::compute(){ /* getMoments() returns a reference to a vpMomentDatabase. (a protected member inherited from vpMoment) .get() is a member function of vpMomentDatabase that returns a specific moment which is linked to it*/ - vpMomentCentered& momentCentered = static_cast<vpMomentCentered&>(getMoments().get("vpMomentCentered",found_moment_centered)); + const vpMomentCentered& momentCentered = static_cast<const vpMomentCentered&>(getMoments().get("vpMomentCentered",found_moment_centered)); if(!found_moment_centered) throw vpException(vpException::notInitialized,"vpMomentCentered not found"); @@ -71,17 +71,19 @@ void vpMomentAreaNormalized::compute(){ /*! Default constructor. - \param desiredSurface : desired area \e a* when the visual servoing converges. - \param desiredDepth : desired depth \e Z* when the visual servoing converges. + \param desired_surface : desired area \e a* when the visual servoing converges. + \param desired_depth : desired depth \e Z* when the visual servoing converges. */ -vpMomentAreaNormalized::vpMomentAreaNormalized(double desiredSurface, double desiredDepth) : vpMoment(),desiredSurface(desiredSurface),desiredDepth(desiredDepth){ +vpMomentAreaNormalized::vpMomentAreaNormalized(double desired_surface, double desired_depth) + : vpMoment(),desiredSurface(desired_surface),desiredDepth(desired_depth) +{ values.resize(1); } /*! Outputs the moment's values to a stream. */ -std::ostream & operator<<(std::ostream & os, const vpMomentAreaNormalized& m){ +VISP_EXPORT std::ostream & operator<<(std::ostream & os, const vpMomentAreaNormalized& m){ os << "An:" << m.values[0] ; return os; diff --git a/src/tracking/moments/vpMomentAreaNormalized.h b/src/tracking/moments/vpMomentAreaNormalized.h index f6ac39f9640ff206753de00c750679dcace603ff..b61a51048261252c19c9674cbad2d42df2ff653e 100644 --- a/src/tracking/moments/vpMomentAreaNormalized.h +++ b/src/tracking/moments/vpMomentAreaNormalized.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMomentAreaNormalized.h 4276 2013-06-25 12:36:48Z fspindle $ + * $Id: vpMomentAreaNormalized.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -139,16 +139,16 @@ class VISP_EXPORT vpMomentAreaNormalized : public vpMoment { /*! Retrieves the desired depth \e Z* as specified in the constructor. */ - double getDesiredDepth(){ return desiredDepth; } + double getDesiredDepth() const { return desiredDepth; } /*! Retrieves the desired surface \e a* as specified in the constructor. */ - double getDesiredSurface(){ return desiredSurface; } + double getDesiredSurface() const { return desiredSurface; } /*! Moment name. */ - const char* name(){return "vpMomentAreaNormalized";} + const char* name() const {return "vpMomentAreaNormalized";} friend VISP_EXPORT std::ostream & operator<<(std::ostream & os, const vpMomentAreaNormalized& v); }; diff --git a/src/tracking/moments/vpMomentBasic.cpp b/src/tracking/moments/vpMomentBasic.cpp index 37db4a4641141a1a9891dd5e17116e8682f0372f..50b1d371d0a9d7fafaa0e757a6d0a0712925f343 100644 --- a/src/tracking/moments/vpMomentBasic.cpp +++ b/src/tracking/moments/vpMomentBasic.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMomentBasic.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMomentBasic.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -54,7 +54,7 @@ vpMomentBasic::vpMomentBasic() : vpMoment(){ Same behaviour as vpMomentObject. */ -std::vector<double>& vpMomentBasic::get(){ +const std::vector<double>& vpMomentBasic::get() const{ return getObject().get(); } @@ -66,7 +66,7 @@ std::vector<double>& vpMomentBasic::get(){ Same behaviour as vpMomentObject. */ -double vpMomentBasic::get(unsigned int i,unsigned int j){ +double vpMomentBasic::get(unsigned int i,unsigned int j) const{ return getObject().get(i,j); } diff --git a/src/tracking/moments/vpMomentBasic.h b/src/tracking/moments/vpMomentBasic.h index 26fd96c91966fa57c60fe527ab0283633dedb306..d16290d89531a10870381ed07912966f8dbf2b1b 100644 --- a/src/tracking/moments/vpMomentBasic.h +++ b/src/tracking/moments/vpMomentBasic.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMomentBasic.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMomentBasic.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -76,12 +76,12 @@ class VISP_EXPORT vpMomentBasic : public vpMoment { vpMomentBasic(); void compute(); - std::vector<double>& get(); - double get(unsigned int i,unsigned int j); + const std::vector<double>& get() const; + double get (unsigned int i,unsigned int j) const; /*! Moment name. */ - const char* name(){ return "vpMomentBasic";} + const char* name() const { return "vpMomentBasic";} }; std::ostream & operator<<(std::ostream & os, vpMomentBasic& v); diff --git a/src/tracking/moments/vpMomentCInvariant.cpp b/src/tracking/moments/vpMomentCInvariant.cpp index 4bda5b749a805d8b692482b4ee3c1ab2218b0a04..3513467c0fd49d52b9819dd8ea139dfe0912bbe2 100644 --- a/src/tracking/moments/vpMomentCInvariant.cpp +++ b/src/tracking/moments/vpMomentCInvariant.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMomentCInvariant.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMomentCInvariant.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -45,9 +45,12 @@ /*! Default constructor. + (option to use a different calculation mode for sx and sy) */ -vpMomentCInvariant::vpMomentCInvariant() : vpMoment(),I(16),II(4),c(4),s(4){ - values.resize(14); +vpMomentCInvariant::vpMomentCInvariant(bool flg_sxsynormalization) + : I(16),II(4),c(4),s(4), K(0.0), cn(4),sn(4), In1(0.0), flg_sxsynormalization_(flg_sxsynormalization) +{ + values.resize(14); } /*! @@ -55,9 +58,11 @@ vpMomentCInvariant::vpMomentCInvariant() : vpMoment(),I(16),II(4),c(4),s(4){ \param momentCentered : centered moments \param I : invariant output values */ -void vpMomentCInvariant::computeI(vpMomentCentered& momentCentered, std::vector<double>& I){ +void vpMomentCInvariant::computeI(const vpMomentCentered& momentCentered, std::vector<double>& I_val){ + double mu30 = momentCentered.get(3,0); double mu30_2 = mu30*mu30; + double mu30_3 = mu30_2*mu30; double mu03 = momentCentered.get(0,3); double mu03_2 = mu03*mu03; @@ -80,7 +85,6 @@ void vpMomentCInvariant::computeI(vpMomentCentered& momentCentered, std::vector< double mu12 = momentCentered.get(1,2); double mu11 = momentCentered.get(1,1); - double mu11_2 = mu11*mu11; double mu12_2 = mu12*mu12; double mu21_2 = mu21*mu21; @@ -94,8 +98,7 @@ void vpMomentCInvariant::computeI(vpMomentCentered& momentCentered, std::vector< double mu12_4 = mu12_3*mu12; double mu21_4 = mu21_2*mu21_2; - - double kappa = mu30_2+mu03_2-3*mu21_2+6*mu21*mu03; + //double kappa = mu30_2+mu03_2-3*mu21_2+6*mu21*mu03; //Used in I8 calculation but simplified with MAPLE and found it to be wrong double zeta = mu20-mu02; double zeta_2 = zeta * zeta; double omicron = (mu03_2+3*mu03*mu21+mu30*(mu30+3*mu12)); @@ -113,23 +116,23 @@ void vpMomentCInvariant::computeI(vpMomentCentered& momentCentered, std::vector< double delta_2 = delta*delta; double phi_2 = phi*phi; - I[1]=-mu20*mu02+mu11_2; - I[2]=zeta_2+4*mu11_2; - I[3]=(mu30-3*mu12)*(mu30-3*mu12)+(mu03-3*mu21)*(mu03-3*mu21); - I[4]=(mu30+mu12)*(mu30+mu12)+(mu21+mu03)*(mu21+mu03); - I[5]=-mu30_2*mu03_2+(-4*mu12_3+6*mu21*mu12*mu03)*mu30-4*mu21_3*mu03+3*mu21_2*mu12_2; - I[6]=3*mu12_4+2*mu30*mu12_3+(3*mu30_2-6*mu03*mu21)*mu12_2-6*mu30*mu21*(mu21+mu03)*mu12+2*mu30_2*mu03_2+2*mu21_3*mu03+3*mu21_2*mu03_2+3*mu21_4; - - I[7]=(3*mu21+2*mu03)*mu12_3+3*mu30*(mu03+2*mu21)*mu12_2-3*mu21*(mu30+mu03+mu21)*(-mu30+mu03+mu21)*mu12+mu30*(-mu30_2*mu03-2*mu21_3-3*mu03*mu21_2+mu03_3); - I[8]=3*mu21_4-3*mu21_3*mu03+(3*mu03_2+kappa-6*mu12_2)*mu21_2-mu03*(-15*mu12_2+kappa)*mu21-(-3*mu12_2*mu30+(2*kappa-3*mu03_2)*mu12+kappa*mu30)*mu12; - I[9]=omicron*omicron; - - I[10]=mu40*mu04-4*mu31*mu13+3*mu22_2; - I[11]=3*mu13_2+2*mu31*mu13+(-3*mu40-3*mu04)*mu22-2*mu40*mu04+3*mu31_2; - I[12]=3*mu04_2+(2*mu40+12*mu22)*mu04+3*mu40_2+12*mu40*mu22+16*mu31*mu13; - I[13]=omega_2+nu_2; - I[14]=ro_2+gamma_2; - I[15]=delta_2+phi_2; + I_val[1]=-mu20*mu02+mu11_2; + I_val[2]=zeta_2+4*mu11_2; + I_val[3]=(mu30-3*mu12)*(mu30-3*mu12)+(mu03-3*mu21)*(mu03-3*mu21); + I_val[4]=(mu30+mu12)*(mu30+mu12)+(mu21+mu03)*(mu21+mu03); + I_val[5]=-mu30_2*mu03_2+(-4*mu12_3+6*mu21*mu12*mu03)*mu30-4*mu21_3*mu03+3*mu21_2*mu12_2; + I_val[6]=3*mu12_4+2*mu30*mu12_3+(3*mu30_2-6*mu03*mu21)*mu12_2-6*mu30*mu21*(mu21+mu03)*mu12+2*mu30_2*mu03_2+2*mu21_3*mu03+3*mu21_2*mu03_2+3*mu21_4; + I_val[7]=(3*mu21+2*mu03)*mu12_3+3*mu30*(mu03+2*mu21)*mu12_2-3*mu21*(mu30+mu03+mu21)*(-mu30+mu03+mu21)*mu12+mu30*(-mu30_2*mu03-2*mu21_3-3*mu03*mu21_2+mu03_3); + //I_val[8]=3*mu21_4-3*mu21_3*mu03+(3*mu03_2+kappa-6*mu12_2)*mu21_2-mu03*(-15*mu12_2+kappa)*mu21-(-3*mu12_2*mu30+(2*kappa-3*mu03_2)*mu12+kappa*mu30)*mu12; + I_val[8] = 3*mu03*mu21_3-2*mu03_2*mu21_2+mu21_2*mu30_2+3*mu12_2*mu03*mu21-mu03*mu21*mu30_2-mu03_3*mu21+3*mu12_3*mu30-2*mu12_2*mu30_2+mu12_2*mu03_2-mu12*mu30_3-mu12*mu30*mu03_2+3*mu12*mu30*mu21_2-6*mu12*mu30*mu03*mu21; + I_val[9]=omicron*omicron; + + I_val[10]=mu40*mu04-4*mu31*mu13+3*mu22_2; + I_val[11]=3*mu13_2+2*mu31*mu13+(-3*mu40-3*mu04)*mu22-2*mu40*mu04+3*mu31_2; + I_val[12]=3*mu04_2+(2*mu40+12*mu22)*mu04+3*mu40_2+12*mu40*mu22+16*mu31*mu13; + I_val[13]=omega_2+nu_2; + I_val[14]=ro_2+gamma_2; + I_val[15]=delta_2+phi_2; double a; if(getObject().getType()==vpMomentObject::DISCRETE) @@ -148,10 +151,31 @@ void vpMomentCInvariant::computeI(vpMomentCentered& momentCentered, std::vector< II[2]=c[2]*c[2]+s[2]*s[2]; II[3]=momentCentered.get(2,0)+momentCentered.get(0,2); - K=(II[1]*(II[3]*sqrt(II[3])))/sqrt(a); + K=(II[1]*(II[3]*sqrt(std::abs(II[3]))))/sqrt(std::abs(a)); + /* + * Intermediate quantities required for calculation of normalized version of Sx and Sy + * The pij doubles below are the respective centered moment values mu_ij scaled by mu20 + mu02 + */ + double p20 = momentCentered.get(2,0)/II[3]; // II[3] is the normalization factor for the 2nd order moments + double p11 = momentCentered.get(1,1)/II[3]; + double p02 = momentCentered.get(0,2)/II[3]; + double d = sqrt(std::abs(a))/(II[3]*sqrt(std::abs(II[3]))); // d is the normalization factor for 3rd order moments + double p30 = momentCentered.get(3,0)*d; + double p21 = momentCentered.get(2,1)*d; + double p12 = momentCentered.get(1,2)*d; + double p03 = momentCentered.get(0,3)*d; + cn[1] = p20 - p02; + sn[1] = 2.0*p11; + sn[2] = p30 - 3.0*p12; + cn[2] = p03 - 3.0*p21; + + cn[3] = cn[1]*cn[1]-sn[1]*sn[1]; + sn[3] = 2.0*sn[1]*cn[1]; + + In1 = cn[1]*cn[1]+sn[1]*sn[1]; } /*! @@ -162,7 +186,7 @@ void vpMomentCInvariant::computeI(vpMomentCentered& momentCentered, std::vector< void vpMomentCInvariant::compute(){ if(getObject().getOrder()<5) throw vpException(vpException::notInitialized,"Order is not high enough for vpMomentCInvariant. Specify at least order 5."); bool found_moment_centered; - vpMomentCentered& momentCentered = (static_cast<vpMomentCentered&>(getMoments().get("vpMomentCentered",found_moment_centered))); + const vpMomentCentered& momentCentered = (static_cast<const vpMomentCentered&>(getMoments().get("vpMomentCentered",found_moment_centered))); if(!found_moment_centered) throw vpException(vpException::notInitialized,"vpMomentCentered not found"); @@ -195,11 +219,30 @@ void vpMomentCInvariant::compute(){ values[9] = I[14]/I[15]; - values[10] = (c[2]*c[3]+s[2]*s[3])/K; - values[11] = (s[2]*c[3]-c[2]*s[3])/K; + if (flg_sxsynormalization_) + calcSxSyNormalized(values[10], values[11]); + else + calcSxSy(values[10], values[11]); + + values[12] = II[1]/(II3_2); // Px + values[13] = a*II[2]/(II3_3); // Py +} - values[12] = II[1]/(II3_2); - values[13] = a*II[2]/(II3_3); +/*! + Sx and Sy as it was inside compute() + */ +void vpMomentCInvariant::calcSxSy(double& sx, double& sy) const{ + sx = (c[2]*c[3]+s[2]*s[3])/K; + sy = (s[2]*c[3]-c[2]*s[3])/K; +} + +/*! + * Sx and Sy from normalized 2nd and 3rd order moments + * Numerically better (than in the usual Sx,Sy when K appears in the denominator) + */ +void vpMomentCInvariant::calcSxSyNormalized(double& sx, double& sy) const{ + sx = (cn[2]*cn[3] + sn[2]*sn[3]) / In1; + sy = (sn[2]*cn[3] - cn[2]*sn[3]) / In1; } /*! @@ -213,14 +256,10 @@ void vpMomentCInvariant::printI(unsigned int index){ /*! Outputs the moment's values to a stream. */ -std::ostream & operator<<(std::ostream & os, const vpMomentCInvariant& c){ +VISP_EXPORT std::ostream & operator<<(std::ostream & os, const vpMomentCInvariant& c){ for(unsigned int i = 0;i<c.values.size();i++){ os << c.values[i] << "," << std::endl; } return os; } - - - - diff --git a/src/tracking/moments/vpMomentCInvariant.h b/src/tracking/moments/vpMomentCInvariant.h index 41898c5b79d48b300dcfdc78b31950a58e5fa171..7aef7624ed8cfb57a830eeb1be2a359db58a59d0 100644 --- a/src/tracking/moments/vpMomentCInvariant.h +++ b/src/tracking/moments/vpMomentCInvariant.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMomentCInvariant.h 4276 2013-06-25 12:36:48Z fspindle $ + * $Id: vpMomentCInvariant.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -56,10 +56,10 @@ class vpMomentBasic; \ingroup TrackingMoments - \brief This class defines several 2D (translation+rotation+scale) invariants for both symmetric and non-symmetric objects. + This class defines several 2D (translation+rotation+scale) invariants for both symmetric and non-symmetric objects. These moment-based invariants are described in the following papers \cite Chaumette04a, \cite Tahri05z. - The descriptions for the invariants \f$C_1\f$ to \f$C_{10}\f$ can be found in [1] and for invariants \f$P_x\f$,\f$P_y\f$,\f$S_x\f$,\f$S_y\f$ in [2]. + The descriptions for the invariants \f$C_1\f$ to \f$C_{10}\f$ can be found in \cite Chaumette04a and for invariants \f$P_x\f$,\f$P_y\f$,\f$S_x\f$,\f$S_y\f$ in \cite Tahri05z. These invariants are classicaly used in visual servoing to control the out-of-plane rotations. The C-type or P-type invariants are used for non-symmetric objects whereas the S-type invariants are used for symmetric objects. @@ -103,7 +103,7 @@ int main() db.updateAll(obj); // Update AND compute all moments //get C-invariant - vpMomentCInvariant& C = static_cast<vpMomentCInvariant&>(db.get("vpMomentCInvariant",success)); + const vpMomentCInvariant& C = static_cast<const vpMomentCInvariant&>(db.get("vpMomentCInvariant",success)); if(success) std::cout << C.get(1) << std:: endl; // print C2 invariant else @@ -121,89 +121,97 @@ class VISP_EXPORT vpMomentCInvariant : public vpMoment { std::vector<double> II; std::vector<double> c; std::vector<double> s; - double K; + double K; + void computeI(const vpMomentCentered& momentCentered, std::vector<double>& I); + + /* To calculate Sx and Sy from normalized moments */ + void calcSxSy(double& sx, double& sy) const; + void calcSxSyNormalized(double& sx, double& sy) const; + std::vector<double> cn; // same as s above but calculated from normalized moments + std::vector<double> sn; // same as c above but calculated from normalized moments + double In1; // same as I1 in Sx,Sy formulae but calculated from normalized moments + bool flg_sxsynormalization_; - void computeI(vpMomentCentered& momentCentered, std::vector<double>& I); public: - vpMomentCInvariant(); + vpMomentCInvariant(bool flg_sxsynormalization = false); /*! Shorcut for getting the value of \f$C_1\f$. */ - double C1(){ return values[0]; } + double C1() const { return values[0]; } /*! Shorcut for getting the value of \f$C_2\f$. */ - double C2(){ return values[1]; } + double C2() const { return values[1]; } /*! Shorcut for getting the value of \f$C_3\f$. */ - double C3(){ return values[2]; } + double C3() const { return values[2]; } /*! Shorcut for getting the value of \f$C_4\f$. */ - double C4(){ return values[3]; } + double C4() const { return values[3]; } /*! Shorcut for getting the value of \f$C_5\f$. */ - double C5(){ return values[4]; } + double C5() const { return values[4]; } /*! Shorcut for getting the value of \f$C_6\f$. */ - double C6(){ return values[5]; } + double C6() const { return values[5]; } /*! Shorcut for getting the value of \f$C_7\f$. */ - double C7(){ return values[6]; } + double C7() const { return values[6]; } /*! Shorcut for getting the value of \f$C_8\f$. */ - double C8(){ return values[7]; } + double C8() const { return values[7]; } /*! Shorcut for getting the value of \f$C_9\f$. */ - double C9(){ return values[8]; } + double C9() const { return values[8]; } /*! Shorcut for getting the value of \f$C_{10}\f$. */ - double C10(){ return values[9]; } + double C10() const { return values[9]; } - void compute(); + void compute(); /*! Gets the desired invariant. \param i given index. For invariants from C1 to C10 the corresponding index is from 0 to 9. For \f$S_x\f$,\f$S_y\f$ the indexes are 10,11 and for \f$P_x\f$,\f$P_y\f$ they are 12,13. */ - double get(unsigned int i){ return values[i]; } + double get(unsigned int i) const { return values[i]; } /*! Access to partial invariant c (see [2]). */ - double getC(unsigned int i){return c[i];} + double getC(unsigned int i) const {return c[i];} /*! Access to partial invariants. The index convention is the same as in [1]. */ - double getI(unsigned int index){return I[index];} + double getI(unsigned int index) const {return I[index];} /*! Access to partial invariant I (see [2]). */ - double getII(unsigned int i){return II[i];} + double getII(unsigned int i) const {return II[i];} /*! Access to partial invariant K (see [2]). */ - double getK(){return K;} + double getK() const {return K;} /*! Access to partial invariant S (see [2]). */ - double getS(unsigned int i){return s[i];} + double getS(unsigned int i) const {return s[i];} /*! Moment name. */ - const char* name(){return "vpMomentCInvariant";} + const char* name() const {return "vpMomentCInvariant";} /*! Print partial invariant. @@ -222,13 +230,40 @@ class VISP_EXPORT vpMomentCInvariant : public vpMoment { /*! Shorcut for getting the value of \f$S_x\f$. */ - double Sx(){ return values[10]; } + double Sx() const { return values[10]; } /*! Shorcut for getting the value of \f$S_y\f$. */ - double Sy(){ return values[11]; } + double Sy() const { return values[11]; } + + /*! + * Getters for I + * (calculated from normalized 2nd and 3ord order moments) + */ + double getIn1() const {return In1;} + + /*! + * Getter for c + * (calculated from normalized 2nd and 3ord order moments) + */ + double getCN(unsigned int i) const {return cn[i];} + + /*! + * Getter for s + * (calculated from normalized 2nd and 3ord order moments) + */ + double getSN(unsigned int i) const {return sn[i];} + + /*! + * To know if Sx and Sy were calculated from normalized moments or not + */ + bool isSxSyfromNormalizedMoments() const {return flg_sxsynormalization_;}; + + /*! + * To get all the invariant values as a whole. + */ + inline const std::vector<double>& getMomentVector() const { return values; } friend VISP_EXPORT std::ostream & operator<<(std::ostream & os, const vpMomentCInvariant& v); }; - #endif diff --git a/src/tracking/moments/vpMomentCentered.cpp b/src/tracking/moments/vpMomentCentered.cpp index 6ba7b52dad2312a6f699732359722413bb157a8f..94c8fd09e379c54ea234bf743dfa4963a8c38cd9 100644 --- a/src/tracking/moments/vpMomentCentered.cpp +++ b/src/tracking/moments/vpMomentCentered.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMomentCentered.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMomentCentered.cpp 4620 2014-01-27 21:28:32Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -45,6 +45,19 @@ #include <exception> #include <cassert> +/*! + To set the values of centred moments. Required when normalizing the moment values. + @param i : first index of the 2D moment. + @param j : second index of the 2D moment. + @param value : value of the moment. +*/ +void vpMomentCentered::set(unsigned int i, unsigned int j, double value){ + vpMomentObject mobj = getObject(); + assert(i+j<=mobj.getOrder()); + if(i+j>mobj.getOrder()) throw vpException(vpException::badValue,"You cannot set that value."); + values[j*(mobj.getOrder()+1)+i] = value; +} + /*! Computes centered moments of all available orders. Depends on vpMomentGravityCenter. @@ -53,8 +66,9 @@ void vpMomentCentered::compute(){ bool found_moment_gravity; values.resize((getObject().getOrder()+1)*(getObject().getOrder()+1)); - vpMomentGravityCenter& momentGravity = static_cast<vpMomentGravityCenter&>(getMoments().get("vpMomentGravityCenter",found_moment_gravity)); + const vpMomentGravityCenter& momentGravity = static_cast<const vpMomentGravityCenter&>(getMoments().get("vpMomentGravityCenter",found_moment_gravity)); if(!found_moment_gravity) throw vpException(vpException::notInitialized,"vpMomentGravityCenter not found"); + unsigned int order = getObject().getOrder()+1; for(register unsigned int j=0;j<(order);j++){ for(register unsigned int i=0;i<order-j;i++){ @@ -87,11 +101,12 @@ vpMomentCentered::vpMomentCentered() : vpMoment(){ \param j : second index of the centered moment. \return \f$\mu_{ij}\f$ moment. */ -double vpMomentCentered::get(unsigned int i,unsigned int j){ - assert(i+j<=getObject().getOrder()); - if(i+j>getObject().getOrder()) throw vpException(vpException::badValue,"The requested value has not been computed, you should specify a higher order."); +double vpMomentCentered::get(unsigned int i,unsigned int j) const { + unsigned int order = getObject().getOrder(); + assert(i+j<=order); + if(i+j>order) throw vpException(vpException::badValue,"The requested value has not been computed, you should specify a higher order."); - return values[j*(getObject().getOrder()+1)+i]; + return values[j*(order+1)+i]; } /*! @@ -109,7 +124,7 @@ u30 x x x \endcode */ -std::ostream & operator<<(std::ostream & os, vpMomentCentered& m){ +VISP_EXPORT std::ostream & operator<<(std::ostream & os, vpMomentCentered& m){ for(unsigned int i = 0;i<m.values.size();i++){ if(i%(m.getObject().getOrder()+1)==0) os << std::endl; diff --git a/src/tracking/moments/vpMomentCentered.h b/src/tracking/moments/vpMomentCentered.h index bed1e1af2b294aad26b66213f0b48f06ce7d4e67..c0815848951709ebca1961ff8294afd6202cb29f 100644 --- a/src/tracking/moments/vpMomentCentered.h +++ b/src/tracking/moments/vpMomentCentered.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMomentCentered.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMomentCentered.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -81,16 +81,21 @@ public: vpMomentCentered(); - void compute(); - double get(unsigned int i,unsigned int j); + void compute(); + double get(unsigned int i,unsigned int j) const; - inline std::vector<double>& get(); + inline const std::vector<double>& get() const; /*! Moment name. */ - inline const char* name(){return "vpMomentCentered";} + inline const char* name() const {return "vpMomentCentered";} friend VISP_EXPORT std::ostream & operator<<(std::ostream & os, vpMomentCentered& v); + +protected: + + void set(unsigned int i, unsigned int j, double value); + }; /*! @@ -120,7 +125,7 @@ mu12 = mc.get()[2*(obj.getOrder()+1)+1]; // i=1 and j=2 mu12 = mc.get(1,2); // the same \endcode */ -inline std::vector<double>& vpMomentCentered::get() +inline const std::vector<double>& vpMomentCentered::get() const { return vpMoment::get(); } diff --git a/src/tracking/moments/vpMomentCommon.cpp b/src/tracking/moments/vpMomentCommon.cpp index 11f507a56766fa7fca1b1b264e40d03337fa84c6..9c67fcdf96f86d0cb211530bc221917d27d472f1 100644 --- a/src/tracking/moments/vpMomentCommon.cpp +++ b/src/tracking/moments/vpMomentCommon.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMomentCommon.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMomentCommon.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -44,13 +44,14 @@ /*! Default constructor. Initializes the common database with the following moments: - basic, gravity,centered,centered+normalized,normalized gravity,normalized surface, scale-plane-rotation-translation invariant,alpha, symmetric invariant. - \param dstSurface : destination surface. You may use vpMomentCommon::getSurface. - \param ref : reference 3rd order moments (see vpMomentAlpha). You may use vpMomentCommon::getMu3. - \param refAlpha : reference alpha (see vpMomentAlpha). You may use vpMomentCommon::getAlpha. + basic, gravity,centered,centered+normalized,normalized gravity,normalized surface, scale-plane-rotation-translation invariant, alpha, symmetric invariant. + \param dstSurface : destination surface. You may use vpMomentCommon::getSurface(). + \param ref : reference 3rd order moments (see vpMomentAlpha). You may use vpMomentCommon::getMu3(). + \param refAlpha : reference alpha (see vpMomentAlpha). You may use vpMomentCommon::getAlpha(). \param dstZ : destination depth. + \param flg_sxsyfromnormalized : flag to enable calculation of sx,sy from normalized moments. */ -vpMomentCommon::vpMomentCommon(double dstSurface,std::vector<double> ref,double refAlpha,double dstZ): +vpMomentCommon::vpMomentCommon(double dstSurface,std::vector<double> ref,double refAlpha,double dstZ, bool flg_sxsyfromnormalized): momentBasic(), momentGravity(), momentCentered(), @@ -60,12 +61,14 @@ vpMomentCommon::vpMomentCommon(double dstSurface,std::vector<double> ref,double momentAlpha(ref,refAlpha), momentArea() { + momentCInvariant = new vpMomentCInvariant(flg_sxsyfromnormalized); + momentBasic.linkTo(*this); momentGravity.linkTo(*this); momentCentered.linkTo(*this); momentGravityNormalized.linkTo(*this); momentSurfaceNormalized.linkTo(*this); - momentCInvariant.linkTo(*this); + momentCInvariant->linkTo(*this); momentAlpha.linkTo(*this); momentArea.linkTo(*this); } @@ -130,7 +133,7 @@ void vpMomentCommon::updateAll(vpMomentObject& object){ momentGravity.compute(); momentCentered.compute(); momentAlpha.compute(); - momentCInvariant.compute(); + momentCInvariant->compute(); momentSurfaceNormalized.compute(); momentGravityNormalized.compute(); @@ -140,14 +143,13 @@ void vpMomentCommon::updateAll(vpMomentObject& object){ std::cout << "exception:" << ex <<std::endl; } - } /*! Gets the surface of an object \param object : moment object */ -double vpMomentCommon::getSurface(vpMomentObject& object){ +double vpMomentCommon::getSurface(vpMomentObject& object) { vpMomentDatabase moments; vpMomentGravityCenter momentGravity;momentGravity.linkTo(moments); @@ -165,14 +167,13 @@ double vpMomentCommon::getSurface(vpMomentObject& object){ a = object.get(0,0); return a; - } /*! Gets a reference alpha of an object. \param object : Moment object. */ -double vpMomentCommon::getAlpha(vpMomentObject& object){ +double vpMomentCommon::getAlpha(vpMomentObject& object) { vpMomentDatabase moments; vpMomentGravityCenter momentGravity;momentGravity.linkTo(moments); @@ -191,7 +192,7 @@ double vpMomentCommon::getAlpha(vpMomentObject& object){ Gets the reference 3rd order moments of an object. \param object : Moment object. */ -std::vector<double> vpMomentCommon::getMu3(vpMomentObject& object){ +std::vector<double> vpMomentCommon::getMu3(vpMomentObject& object) { vpMomentDatabase moments; vpMomentGravityCenter momentGravity;momentGravity.linkTo(moments); @@ -204,13 +205,18 @@ std::vector<double> vpMomentCommon::getMu3(vpMomentObject& object){ std::vector<double> mu(4); unsigned int idx=0; - for (unsigned int i=0; i<4; i++) { - for (unsigned int j=0; j<4; j++) { + for (unsigned int j=0; j<4; j++) { + for (unsigned int i=0; i<4; i++) { if (i+j==3){ - mu[idx] = momentCentered.get(j,i); + mu[idx] = momentCentered.get(i,j); idx++; } } } return mu; } + +vpMomentCommon::~vpMomentCommon(){ + if (momentCInvariant) + delete momentCInvariant; +} diff --git a/src/tracking/moments/vpMomentCommon.h b/src/tracking/moments/vpMomentCommon.h index 5cce98c0056035edb2bdab014847bcb431b3e4d8..beb17c3bd6aa76b5d74d9163ccf561b746bfb615 100644 --- a/src/tracking/moments/vpMomentCommon.h +++ b/src/tracking/moments/vpMomentCommon.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMomentCommon.h 4276 2013-06-25 12:36:48Z fspindle $ + * $Id: vpMomentCommon.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -70,14 +70,15 @@ class vpMomentObject; - vpMomentBasic - vpMomentGravityCenter - vpMomentCentered - - vpMomentCenteredNormalized + - vpMomentGravityCenterNormalized - vpMomentAreaNormalized - vpMomentCInvariant - vpMomentAlpha + - vpMomentArea There is no need to do the linkTo operations manually nor is it necessary to care about the order of moment computation. - This class carries an vpMomentCommon::updateAll method capable of updating AND computing moments from an object (see 4-step process in vpMoment). + This class carries an vpMomentCommon::updateAll() method capable of updating AND computing moments from an object (see 4-step process in vpMoment). The moments computed by this class are classical moments used in moment-based visual servoing. For more information see \cite Tahri05z. @@ -88,7 +89,8 @@ class vpMomentObject; - the surface of the destination object in the end of the visual servoing process. - the reference alpha: angular position of the object used to obtain the Mu3 set. - Shortcuts for each of these prerequisites are provided by this class except depth (methods vpMomentCommon::getMu3, vpMomentCommon::getSurface,vpMomentCommon::getAlpha). + Shortcuts for each of these prerequisites are provided by this class except depth (methods + vpMomentCommon::getMu3(), vpMomentCommon::getSurface(), vpMomentCommon::getAlpha()). \attention Make sure your object is at least of order 5 when using this pre-filled database. @@ -100,18 +102,17 @@ private: vpMomentCentered momentCentered; vpMomentGravityCenterNormalized momentGravityNormalized; vpMomentAreaNormalized momentSurfaceNormalized; - vpMomentCInvariant momentCInvariant; + vpMomentCInvariant* momentCInvariant; vpMomentAlpha momentAlpha; vpMomentArea momentArea; public: - vpMomentCommon(double dstSurface,std::vector<double> ref,double refAlpha,double dstZ=1.0); + vpMomentCommon(double dstSurface,std::vector<double> ref,double refAlpha,double dstZ=1.0, bool flg_sxsyfromnormalized=false); - static double getAlpha(vpMomentObject& objec); + static double getAlpha(vpMomentObject& object); static std::vector<double> getMu3(vpMomentObject& object); static double getSurface(vpMomentObject& object); void updateAll(vpMomentObject& object); + ~vpMomentCommon(); }; - - #endif // VPCOMMONMOMENTS_H diff --git a/src/tracking/moments/vpMomentDatabase.cpp b/src/tracking/moments/vpMomentDatabase.cpp index ee96c18ed3043835e9b69331ea0a92c659229cc6..f0c6f15713e1135a544b0eeaaab65f72cec488d9 100644 --- a/src/tracking/moments/vpMomentDatabase.cpp +++ b/src/tracking/moments/vpMomentDatabase.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMomentDatabase.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMomentDatabase.cpp 4620 2014-01-27 21:28:32Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -62,7 +62,7 @@ void vpMomentDatabase::add(vpMoment& moment,const char* name){ \param found : true if the moment's type exists in the database, false otherwise. \return Moment corresponding to \e type. */ -vpMoment& vpMomentDatabase::get(const char* type, bool& found){ +const vpMoment& vpMomentDatabase::get(const char* type, bool& found) const { std::map<const char*,vpMoment*,vpMomentDatabase::cmp_str>::const_iterator it = moments.find(type); found = (it!=moments.end()); @@ -86,7 +86,7 @@ void vpMomentDatabase::updateAll(vpMomentObject& object){ /*! Outputs all the moments values in the database to a stream. */ -std::ostream & operator<<(std::ostream & os, const vpMomentDatabase& m){ +VISP_EXPORT std::ostream & operator<<(std::ostream & os, const vpMomentDatabase& m){ std::map<const char*,vpMoment*,vpMomentDatabase::cmp_str>::const_iterator itr; os << "{"; diff --git a/src/tracking/moments/vpMomentDatabase.h b/src/tracking/moments/vpMomentDatabase.h index efbd2938efdfa6a19363385d6ecb767b9ab1b67e..733574c777fcdbc343f07969b07b61622af66747 100644 --- a/src/tracking/moments/vpMomentDatabase.h +++ b/src/tracking/moments/vpMomentDatabase.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMomentDatabase.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMomentDatabase.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -136,9 +136,10 @@ class VISP_EXPORT vpMomentDatabase{ std::map<const char*,vpMoment*,cmp_str> moments; void add(vpMoment& moment, const char* name); public: + vpMomentDatabase() : moments() {} virtual ~vpMomentDatabase() {} - vpMoment& get(const char* type, bool& found); + const vpMoment& get(const char* type, bool& found) const; /*! Get the first element in the database. May be useful in case an unnamed object is present but is the only element in the database. diff --git a/src/tracking/moments/vpMomentGravityCenter.cpp b/src/tracking/moments/vpMomentGravityCenter.cpp index d782bbaeade2d1d65134f6fb6f389feae492d958..5e0d00f3b0992c2e7fed2bcaa1a536ec12576f35 100644 --- a/src/tracking/moments/vpMomentGravityCenter.cpp +++ b/src/tracking/moments/vpMomentGravityCenter.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMomentGravityCenter.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMomentGravityCenter.cpp 4620 2014-01-27 21:28:32Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -60,14 +60,14 @@ vpMomentGravityCenter::vpMomentGravityCenter() : vpMoment(){ Returns a vector of the two gravity center coordinates. \return Coordinates in the following moment: \f$(x_g,y_g)\f$. */ -std::vector<double>& vpMomentGravityCenter::get(){ +const std::vector<double>& vpMomentGravityCenter::get() const{ return values; } /*! Outputs the moment's values to a stream. */ -std::ostream & operator<<(std::ostream & os, const vpMomentGravityCenter& m){ +VISP_EXPORT std::ostream & operator<<(std::ostream & os, const vpMomentGravityCenter& m){ os << "Xg=" << m.values[0] << ", Yg=" << m.values[1]; return os; diff --git a/src/tracking/moments/vpMomentGravityCenter.h b/src/tracking/moments/vpMomentGravityCenter.h index cf65cb72904672a9495b1e78cdf6db0e91caffb5..3e391f7e4f11686b87d725f3232eecb8f9a2b79c 100644 --- a/src/tracking/moments/vpMomentGravityCenter.h +++ b/src/tracking/moments/vpMomentGravityCenter.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMomentGravityCenter.h 4220 2013-04-17 10:03:36Z mbakthav $ + * $Id: vpMomentGravityCenter.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -115,7 +115,7 @@ class VISP_EXPORT vpMomentGravityCenter : public vpMoment { vpMomentGravityCenter(); void compute(); - std::vector<double>& get(); + const std::vector<double>& get() const; /*! Shortcut function to retrieve \f$x_g\f$. \return The first gravity center coordinate. @@ -129,7 +129,7 @@ class VISP_EXPORT vpMomentGravityCenter : public vpMoment { /*! The class's string name. */ - const char* name(){return "vpMomentGravityCenter";} + const char* name() const {return "vpMomentGravityCenter";} friend VISP_EXPORT std::ostream & operator<<(std::ostream & os, const vpMomentGravityCenter& v); }; diff --git a/src/tracking/moments/vpMomentGravityCenterNormalized.cpp b/src/tracking/moments/vpMomentGravityCenterNormalized.cpp index d668b126db77b0f827e367d2a4165bcdfa1d0c7b..c18ff89eeb93ecf5c46ad9abc177dc25ead91af2 100644 --- a/src/tracking/moments/vpMomentGravityCenterNormalized.cpp +++ b/src/tracking/moments/vpMomentGravityCenterNormalized.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMomentGravityCenterNormalized.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMomentGravityCenterNormalized.cpp 4620 2014-01-27 21:28:32Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -52,8 +52,8 @@ void vpMomentGravityCenterNormalized::compute(){ bool found_moment_gravity; bool found_moment_surface_normalized; - vpMomentAreaNormalized& momentSurfaceNormalized = static_cast<vpMomentAreaNormalized&>(getMoments().get("vpMomentAreaNormalized",found_moment_surface_normalized)); - vpMomentGravityCenter& momentGravity = static_cast<vpMomentGravityCenter&>(getMoments().get("vpMomentGravityCenter",found_moment_gravity)); + const vpMomentAreaNormalized& momentSurfaceNormalized = static_cast<const vpMomentAreaNormalized&>(getMoments().get("vpMomentAreaNormalized",found_moment_surface_normalized)); + const vpMomentGravityCenter& momentGravity = static_cast<const vpMomentGravityCenter&>(getMoments().get("vpMomentGravityCenter",found_moment_gravity)); if(!found_moment_surface_normalized) throw vpException(vpException::notInitialized,"vpMomentAreaNormalized not found"); if(!found_moment_gravity) throw vpException(vpException::notInitialized,"vpMomentGravityCenter not found"); @@ -74,7 +74,7 @@ vpMomentGravityCenterNormalized::vpMomentGravityCenterNormalized() : vpMomentGra /*! Outputs the moment's values to a stream. */ -std::ostream & operator<<(std::ostream & os, const vpMomentGravityCenterNormalized& m){ +VISP_EXPORT std::ostream & operator<<(std::ostream & os, const vpMomentGravityCenterNormalized& m){ os << "Xn:" << m.values[0] << ",Yn=" << m.values[1]; return os; diff --git a/src/tracking/moments/vpMomentGravityCenterNormalized.h b/src/tracking/moments/vpMomentGravityCenterNormalized.h index 96488c21aabca5cf49239a4deb6ec211c5df43a9..64b892399b2bc6743f7bf3b1320888e59661eec2 100644 --- a/src/tracking/moments/vpMomentGravityCenterNormalized.h +++ b/src/tracking/moments/vpMomentGravityCenterNormalized.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMomentGravityCenterNormalized.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMomentGravityCenterNormalized.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -68,7 +68,7 @@ class VISP_EXPORT vpMomentGravityCenterNormalized : public vpMomentGravityCenter /*! Moment name. */ - const char* name(){return "vpMomentGravityCenterNormalized";} + const char* name() const {return "vpMomentGravityCenterNormalized";} friend VISP_EXPORT std::ostream & operator<<(std::ostream & os, const vpMomentGravityCenterNormalized& v); }; diff --git a/src/tracking/moments/vpMomentObject.cpp b/src/tracking/moments/vpMomentObject.cpp index 7b3d20f42a72de40161cb87819c3bd366dbdaabd..c92a6ebd1b09043b63ad0ebd78a2f79848438245 100644 --- a/src/tracking/moments/vpMomentObject.cpp +++ b/src/tracking/moments/vpMomentObject.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMomentObject.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMomentObject.cpp 4653 2014-02-07 15:38:09Z mbakthav $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -44,8 +44,11 @@ #include <visp/vpCameraParameters.h> #include <visp/vpPixelMeterConversion.h> #include <visp/vpConfig.h> +#include <stdexcept> + #include <cmath> #include <limits> + #ifdef VISP_HAVE_OPENMP #include <omp.h> #endif @@ -134,6 +137,32 @@ void vpMomentObject::cacheValues(std::vector<double>& cache,double x, double y){ } } +/*! + * Manikandan.B + * Need to cache intensity along with the coordinates for photometric moments + */ +void vpMomentObject::cacheValues(std::vector<double>& cache,double x, double y, double IntensityNormalized) { + + cache[0]=IntensityNormalized; + + double invIntensityNormalized = 0.; + if (std::fabs(IntensityNormalized)>=std::numeric_limits<double>::epsilon()) + invIntensityNormalized = 1.0/IntensityNormalized; + + for(register unsigned int i=1;i<order;i++) + cache[i]=cache[i-1]*x; + + for(register unsigned int j=order;j<order*order;j+=order) + cache[j]=cache[j-order]*y; + + for(register unsigned int j=1;j<order;j++){ + for(register unsigned int i=1;i<order-j;i++){ + cache[j*order+i] = cache[j*order]*cache[i]*invIntensityNormalized; + } + } +} + + /*! Computes basic moments from a vector of points. There are two cases: @@ -262,10 +291,10 @@ int main() */ void vpMomentObject::fromImage(const vpImage<unsigned char>& image, unsigned char threshold, const vpCameraParameters& cam){ -#ifdef VISP_HAVE_OPENMP +#ifdef VISP_HAVE_OPENMP #pragma omp parallel shared(threshold) - { - std::vector<double> curvals(order*order); + { + std::vector<double> curvals(order*order); curvals.assign(order*order,0.); unsigned int i_, j_; @@ -281,36 +310,35 @@ void vpMomentObject::fromImage(const vpImage<unsigned char>& image, unsigned cha double xval=1.; double yval=1.; - for(register unsigned int k=0;k<order;k++){ + for(register unsigned int k=0;k<order;k++){ xval=1.; for(register unsigned int l=0;l<order-k;l++){ curvals[(k*order+l)]+=(xval*yval); xval*=x; } yval*=y; - } + } } } - } - + } + #pragma omp master //only set this variable in master thread - { - values.assign(order*order, 0.); + { + values.assign(order*order, 0.); } #pragma omp barrier - - for(register unsigned int k=0;k<order;k++){ + + for(register unsigned int k=0;k<order;k++){ for(register unsigned int l=0;l<order-k;l++){ #pragma omp atomic values[k*order+l]+= curvals[k*order+l]; } } - - } - + + } #else - std::vector<double> cache(order*order,0.); + std::vector<double> cache(order*order,0.); values.assign(order*order,0); for(register unsigned int i=0;i<image.getCols();i++){ for(register unsigned int j=0;j<image.getRows();j++){ @@ -328,9 +356,128 @@ void vpMomentObject::fromImage(const vpImage<unsigned char>& image, unsigned cha } } #endif + + //Normalisation equivalent to sampling interval/pixel size delX x delY + double norm_factor = 1./(cam.get_px()*cam.get_py()); + for (std::vector<double>::iterator it = values.begin(); it!=values.end(); it++) { + *it = (*it) * norm_factor; + } +} + +/*! + * Manikandan. B + * Photometric moments v2 + * Intended to be used by 'vpMomentObject's of type DENSE_FULL_OBJECT + * @param image : Grayscale image + * @param cam : Camera parameters (to change to ) + * @param bg_type : White/Black background surrounding the image + * @param normalize_with_pix_size : This flag if SET, the moments, after calculation are normalized w.r.t pixel size + * available from camera parameters + */ +void vpMomentObject::fromImage(const vpImage<unsigned char>& image, const vpCameraParameters& cam, + vpCameraImgBckGrndType bg_type, bool normalize_with_pix_size) +{ + std::vector<double> cache(order*order,0.); + values.assign(order*order,0); + + // (x,y) - Pixel co-ordinates in metres + double x=0; + double y=0; + //for indexing into cache[] and values[] + unsigned int idx = 0; + unsigned int kidx = 0; + + double intensity = 0; + double intensity_white = 0; + + //double Imax = static_cast<double>(image.getMaxValue()); + double Imax = 255.; // To check the effect of gray level change. ISR Coimbra + + double iscale = 1.0; + if (flg_normalize_intensity) // This makes the image a probability density function + iscale = 1.0/Imax; + + if (bg_type == vpMomentObject::WHITE) { + /////////// WHITE BACKGROUND /////////// + for(register unsigned int j=0;j<image.getRows();j++){ + for(register unsigned int i=0;i<image.getCols();i++){ + x = 0; + y = 0; + intensity = (double)(image[j][i])*iscale; + intensity_white = 1. - intensity; + + vpPixelMeterConversion::convertPoint(cam,i,j,x,y); + cacheValues(cache,x,y, intensity_white); // Modify 'cache' which has x^p*y^q to x^p*y^q*(1 - I(x,y)) + + // Copy to "values" + for(register unsigned int k=0;k<order;k++){ + kidx = k*order; + for(register unsigned int l=0;l<order-k;l++){ + idx = kidx+l; + values[idx]+= cache[idx]; + } + } + } + } + } + else { + /////////// BLACK BACKGROUND /////////// + for(register unsigned int j=0;j<image.getRows();j++){ + for(register unsigned int i=0;i<image.getCols();i++){ + x = 0; + y = 0; + intensity = (double)(image[j][i])*iscale; + vpPixelMeterConversion::convertPoint(cam,i,j,x,y); + + // Cache values for fast moment calculation + cacheValues(cache,x,y, intensity); // Modify 'cache' which has x^p*y^q to x^p*y^q*I(x,y) + + // Copy to moments array 'values' + for(register unsigned int k=0;k<order;k++){ + kidx = k*order; + for(register unsigned int l=0;l<order-k;l++){ + idx = kidx+l; + values[idx]+= cache[idx]; + } + } + + } + } + } + + if (normalize_with_pix_size){ + // Normalisation equivalent to sampling interval/pixel size delX x delY + double norm_factor = 1./(cam.get_px()*cam.get_py()); + for (std::vector<double>::iterator it = values.begin(); it!=values.end(); it++) { + *it = (*it) * norm_factor; + } + } } +/*! + Does exactly the work of the default constructor as it existed in the very + first version of vpMomentObject + */ +void +vpMomentObject::init(unsigned int orderinp) { + order = orderinp + 1; + type = vpMomentObject::DENSE_FULL_OBJECT; + flg_normalize_intensity = true; // By default, the intensity values are normalized + values.resize((order+1)*(order+1)); + values.assign((order+1)*(order+1),0); +} +/*! + Helper to copy constructor + */ +void +vpMomentObject::init(const vpMomentObject& objin){ + order = objin.getOrder()+1; + type = objin.getType(); + flg_normalize_intensity = objin.flg_normalize_intensity; + values.resize(objin.values.size()); + values = objin.values; +} /*! Default constructor. @@ -338,14 +485,28 @@ void vpMomentObject::fromImage(const vpImage<unsigned char>& image, unsigned cha The parameter specified is the highest desired included order. All orders up to this values will be computed. In other words, a vpMomentObject will compute all \f$ m_{ij} \f$ moments with \f$ i+j \in [0..order] \f$. - \param order : Maximum reached order (i+j) to be used. All + \param max_order : Maximum reached order (i+j) to be used. All considered i+j will be of order smaller or equal than this parameter. For example if this parameter is 5, all moment values of order 0 to 5 included will be computed. + + Mani : outsourced the constructor work to void init (unsigned int orderinp); */ -vpMomentObject::vpMomentObject(unsigned int order) : order(order+1),type(DENSE_FULL_OBJECT){ - values.resize((order+1)*(order+1)*12); - values.assign((order+1)*(order+1)*12,0); +vpMomentObject::vpMomentObject(unsigned int max_order) + : flg_normalize_intensity(true), order(max_order+1), type(vpMomentObject::DENSE_FULL_OBJECT), + values() +{ + init(max_order); +} + +/*! + Copy constructor + */ +vpMomentObject::vpMomentObject(const vpMomentObject& srcobj) + : flg_normalize_intensity(true), order(order+1), type(vpMomentObject::DENSE_FULL_OBJECT), + values() +{ + init(srcobj); } /*! @@ -367,7 +528,7 @@ double m12; m12 = mij[2*(obj.getOrder()+1)+1]; // i=1 and j=2 \endcode */ -std::vector<double>& vpMomentObject::get() { +const std::vector<double>& vpMomentObject::get() const { return values; } @@ -385,6 +546,18 @@ double vpMomentObject::get(unsigned int i, unsigned int j) const { return values[j*order+i]; } +/*! + Sets the basic moment value \f$m_{ij}\f$ corresponding to i,j indexes + \param i : First moment index, with \f$i+j \leq order\f$. + \param j : Second moment index, with \f$i+j \leq order\f$. + \param value_ij : Moment value. +*/ +void vpMomentObject::set(unsigned int i, unsigned int j, const double& value_ij){ + assert(i+j<=getOrder()); + if(i+j>=order) throw vpException(vpException::badValue,"The requested value cannot be set, you should specify a higher order for the moment object."); + values[j*order+i] = value_ij; +} + /*! Outputs the basic moment's values \f$m_{ij}\f$ to a stream presented as a matrix. The first line corresponds to \f$m_{0[0:order]}\f$, the second one to \f$m_{1[0:order]}\f$ @@ -400,7 +573,7 @@ double vpMomentObject::get(unsigned int i, unsigned int j) const { \endcode */ -std::ostream & operator<<(std::ostream & os, const vpMomentObject& m){ +VISP_EXPORT std::ostream & operator<<(std::ostream & os, const vpMomentObject& m){ for(unsigned int i = 0;i<m.values.size();i++){ if(i%(m.order)==0) diff --git a/src/tracking/moments/vpMomentObject.h b/src/tracking/moments/vpMomentObject.h index cd6d348e6cdc83374adb42ec9e6cd16a38a6ab39..14eedb5d3995dc910a30adfb7e93b5cc11facf56 100644 --- a/src/tracking/moments/vpMomentObject.h +++ b/src/tracking/moments/vpMomentObject.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMomentObject.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMomentObject.h 4650 2014-02-07 15:30:36Z mbakthav $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -48,7 +48,8 @@ #include <visp/vpImage.h> #include <visp/vpMoment.h> #include <visp/vpPoint.h> - +#include <visp/vpMath.h> +#include <cstdlib> #include <utility> class vpCameraParameters; @@ -212,6 +213,7 @@ Centered moments (mu03, mu12, mu21, mu30): 0.003375 0.0045625 -0.00228125 -0.000 */ class VISP_EXPORT vpMomentObject{ public: + /*! Type of object that will be considered. */ @@ -220,32 +222,57 @@ public: DENSE_POLYGON = 1, /*!< A set of points (stored in clockwise order) describing a polygon. It will be treated as dense. */ DISCRETE = 2, /*!< A cloud of points. Treated as discrete. */ } vpObjectType; + + /*! + Type of camera image background. + */ + typedef enum{ + BLACK = 0, /*! Black background */ + WHITE = 1, /*! No functionality as of now */ + } vpCameraImgBckGrndType; + + bool flg_normalize_intensity; // To scale the intensity of each individual pixel in the image by the maximum intensity value present in it + + // Constructor helpers + void init(unsigned int orderinp); + void init(const vpMomentObject& objin); + // Constructors vpMomentObject(unsigned int order); - void fromImage(const vpImage<unsigned char>& image,unsigned char threshold, const vpCameraParameters& cam); + vpMomentObject(const vpMomentObject& srcobj); + + void fromImage(const vpImage<unsigned char>& image,unsigned char threshold, const vpCameraParameters& cam); // Binary version + void fromImage(const vpImage<unsigned char>& image, const vpCameraParameters& cam, vpCameraImgBckGrndType bg_type, bool normalize_with_pix_size = true); // Photometric version + void fromVector(std::vector<vpPoint>& points); - std::vector<double>& get(); + const std::vector<double>& get() const; double get(unsigned int i,unsigned int j) const; + /*! \return The type of object that is considered. */ vpObjectType getType() const {return type;} + /*! \return The maximal order. The basic moments \f$m_{ij}\f$ that will be computed are for \f$i+j \in [0:\mbox{order}]\f$. */ unsigned int getOrder() const {return order-1;} + /*! Specifies the type of the input data. - \param type : An input type. + \param input_type : An input type. */ - void setType(vpObjectType type){this->type=type;} + void setType(vpObjectType input_type){this->type=input_type;} friend VISP_EXPORT std::ostream & operator<<(std::ostream & os, const vpMomentObject& v); -private: +protected: unsigned int order; vpObjectType type; std::vector<double> values; + void set(unsigned int i, unsigned int j, const double& value_ij); void cacheValues(std::vector<double>& cache,double x, double y); +private: + void cacheValues(std::vector<double>& cache,double x, double y, double IntensityNormalized); double calc_mom_polygon(unsigned int p, unsigned int q, const std::vector<vpPoint>& points); }; diff --git a/src/tracking/moving-edges/vpMe.cpp b/src/tracking/moving-edges/vpMe.cpp index 4b187885bb9514e8ffcc316f8143b8bbaeb94ae2..5c86afde3dc35ada50ff30f1e2acdb26e079a964 100644 --- a/src/tracking/moving-edges/vpMe.cpp +++ b/src/tracking/moving-edges/vpMe.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMe.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMe.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -411,34 +411,28 @@ vpMe::print( ) } vpMe::vpMe() + : threshold(1500), mu1(0.5), mu2(0.5), min_samplestep(4), anglestep(1), mask_sign(0), + range(4), sample_step(10), ntotal_sample(0), points_to_track(500), mask_size(5), + n_mask(180), strip(2), mask(NULL) +#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS + , aberration(2), init_aberration(5.) +#endif { - mask = NULL ; - threshold = 1500 ; - mu1 = 0.5 ; - mu2 = 0.5 ; - sample_step = 10 ; - range = 4 ; - mask_size = 5 ; - n_mask = 180 ; - mask_sign = 0 ; - ntotal_sample = 0; // not sure that it is used - points_to_track = 500; // not sure that it is used + //ntotal_sample = 0; // not sure that it is used + //points_to_track = 500; // not sure that it is used anglestep = (180 / n_mask) ; - strip = 2 ; - min_samplestep = 4 ; - - #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS - aberration = 2.0 ; - init_aberration = 5.0 ; - #endif - + initMask() ; } vpMe::vpMe(const vpMe &me) + : threshold(1500), mu1(0.5), mu2(0.5), min_samplestep(4), anglestep(1), mask_sign(0), + range(4), sample_step(10), ntotal_sample(0), points_to_track(500), mask_size(5), + n_mask(180), strip(2), mask(NULL) +#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS + , aberration(2), init_aberration(5.) +#endif { - mask = NULL ; - *this = me; } diff --git a/src/tracking/moving-edges/vpMe.h b/src/tracking/moving-edges/vpMe.h index c94d3170655b598a3cd1c1ab13c620e87a75aaff..d51f7f4116589721fd91a808fbe1cc83e1cdb748 100644 --- a/src/tracking/moving-edges/vpMe.h +++ b/src/tracking/moving-edges/vpMe.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMe.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMe.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -166,9 +166,9 @@ public: /*! Set the minimum image contrast allowed to detect a contour. - \param mu1 : new mu1. + \param mu_1 : new mu1. */ - void setMu1(const double &mu1) { this->mu1 = mu1 ; } + void setMu1(const double &mu_1) { this->mu1 = mu_1 ; } /*! Get the minimum image contrast allowed to detect a contour. @@ -180,9 +180,9 @@ public: /*! Set the maximum image contrast allowed to detect a contour. - \param mu2 : new mu2. + \param mu_2 : new mu2. */ - void setMu2(const double &mu2) { this->mu2 = mu2 ; } + void setMu2(const double &mu_2) { this->mu2 = mu_2 ; } /*! Get the maximum image contrast allowed to detect a contour. diff --git a/src/tracking/moving-edges/vpMeEllipse.cpp b/src/tracking/moving-edges/vpMeEllipse.cpp index 38ea8432038ea4ca2867877c08fd66fe6b571330..0496655a31ba6f8eb6713dff3599e997f92cfbb3 100644 --- a/src/tracking/moving-edges/vpMeEllipse.cpp +++ b/src/tracking/moving-edges/vpMeEllipse.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMeEllipse.cpp 4303 2013-07-04 14:14:00Z fspindle $ + * $Id: vpMeEllipse.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -51,6 +51,8 @@ #include <cmath> // std::fabs #include <limits> // numeric_limits + +void computeTheta(double &theta, vpColVector &K, vpImagePoint iP); /*! Computes the \f$ \theta \f$ angle which represents the angle between the tangente to the curve and the i axis. @@ -78,36 +80,34 @@ computeTheta(double &theta, vpColVector &K, vpImagePoint iP) /*! Basic constructor that calls the constructor of the class vpMeTracker. */ -vpMeEllipse::vpMeEllipse():vpMeTracker() +vpMeEllipse::vpMeEllipse() + : K(), iPc(), a(0.), b(0.), e(0.), iP1(), iP2(), alpha1(0), alpha2(2*M_PI), + ce(0.), se(0.), angle(), m00(0.), mu11(0.), mu20(0.), mu02(0.), + m10(0.), m01(0.), m11(0.), m02(0.), m20(0.), thresholdWeight(0.2), circle(false) { vpCDEBUG(1) << "begin vpMeEllipse::vpMeEllipse() " << std::endl ; // redimensionnement du vecteur de parametre // i^2 + K0 j^2 + 2 K1 i j + 2 K2 i + 2 K3 j + K4 - circle = false ; K.resize(5) ; - alpha1 = 0 ; - alpha2 = 2*M_PI ; - //j1 = j2 = i1 = i2 = 0 ; iP1.set_i(0); iP1.set_j(0); iP2.set_i(0); iP2.set_j(0); - m00 = m01 = m10 = m11 = m20 = m02 = mu11 = mu20 = mu02 = 0; - - thresholdWeight = 0.2; - vpCDEBUG(1) << "end vpMeEllipse::vpMeEllipse() " << std::endl ; } /*! Copy constructor. */ -vpMeEllipse::vpMeEllipse(const vpMeEllipse &meellipse):vpMeTracker(meellipse) +vpMeEllipse::vpMeEllipse(const vpMeEllipse &meellipse) + : vpMeTracker(meellipse), K(), iPc(), a(0.), b(0.), e(0.), iP1(), iP2(), alpha1(0), alpha2(2*M_PI), + ce(0.), se(0.), angle(), m00(0.), mu11(0.), mu20(0.), mu02(0.), + m10(0.), m01(0.), m11(0.), m02(0.), m20(0.), thresholdWeight(0.2), circle(false) { K = meellipse.K; iPc = meellipse.iPc; @@ -134,6 +134,8 @@ vpMeEllipse::vpMeEllipse(const vpMeEllipse &meellipse):vpMeTracker(meellipse) m02 = meellipse.m02; m20 = meellipse.m20; thresholdWeight = meellipse.thresholdWeight; + + circle = meellipse.circle; } /*! @@ -416,16 +418,16 @@ vpMeEllipse::computeAngle(vpImagePoint pt1, vpImagePoint pt2) void vpMeEllipse::updateTheta() { - vpMeSite p; + vpMeSite p_me; double theta; for(std::list<vpMeSite>::iterator it=list.begin(); it!=list.end(); ++it){ - p = *it; + p_me = *it; vpImagePoint iP; - iP.set_i(p.ifloat); - iP.set_j(p.jfloat); + iP.set_i(p_me.ifloat); + iP.set_j(p_me.jfloat); computeTheta(theta, K, iP) ; - p.alpha = theta ; - *it = p; + p_me.alpha = theta ; + *it = p_me; } } @@ -629,10 +631,10 @@ vpMeEllipse::leastSquare() // A = (j^2 2ij 2i 2j 1) x = (K0 K1 K2 K3 K4)^T b = (-i^2 ) unsigned int i ; - vpMeSite p ; + vpMeSite p_me ; unsigned int iter =0 ; - vpColVector b(numberOfSignal()) ; + vpColVector b_(numberOfSignal()) ; vpRobust r(numberOfSignal()) ; r.setThreshold(2); r.setIteration(0) ; @@ -658,17 +660,16 @@ vpMeEllipse::leastSquare() unsigned int k =0 ; for(std::list<vpMeSite>::const_iterator it=list.begin(); it!=list.end(); ++it){ - p = *it; - if (p.getState() == vpMeSite::NO_SUPPRESSION) + p_me = *it; + if (p_me.getState() == vpMeSite::NO_SUPPRESSION) { - - A[k][0] = vpMath::sqr(p.jfloat) ; - A[k][1] = 2 * p.ifloat * p.jfloat ; - A[k][2] = 2 * p.ifloat ; - A[k][3] = 2 * p.jfloat ; + A[k][0] = vpMath::sqr(p_me.jfloat) ; + A[k][1] = 2 * p_me.ifloat * p_me.jfloat ; + A[k][2] = 2 * p_me.ifloat ; + A[k][3] = 2 * p_me.jfloat ; A[k][4] = 1 ; - b[k] = - vpMath::sqr(p.ifloat) ; + b_[k] = - vpMath::sqr(p_me.ifloat) ; k++ ; } } @@ -678,10 +679,10 @@ vpMeEllipse::leastSquare() DA = D*A ; vpMatrix DAp ; - x = DA.pseudoInverse(1e-26) *D*b ; + x = DA.pseudoInverse(1e-26) *D*b_ ; vpColVector residu(nos_1); - residu = b - A*x; + residu = b_ - A*x; r.setIteration(iter) ; r.MEstimator(vpRobust::TUKEY,residu,w) ; @@ -696,14 +697,14 @@ vpMeEllipse::leastSquare() k =0 ; for(std::list<vpMeSite>::iterator it=list.begin(); it!=list.end(); ++it){ - p = *it; - if (p.getState() == vpMeSite::NO_SUPPRESSION) + p_me = *it; + if (p_me.getState() == vpMeSite::NO_SUPPRESSION) { if (w[k] < thresholdWeight) { - p.setState(vpMeSite::M_ESTIMATOR); + p_me.setState(vpMeSite::M_ESTIMATOR); - *it = p; + *it = p_me; } k++ ; } @@ -719,15 +720,14 @@ vpMeEllipse::leastSquare() unsigned int k =0 ; for(std::list<vpMeSite>::const_iterator it=list.begin(); it!=list.end(); ++it){ - p = *it; - if (p.getState() == vpMeSite::NO_SUPPRESSION) + p_me = *it; + if (p_me.getState() == vpMeSite::NO_SUPPRESSION) { - - A[k][0] = 2* p.ifloat ; - A[k][1] = 2 * p.jfloat ; + A[k][0] = 2* p_me.ifloat ; + A[k][1] = 2 * p_me.jfloat ; A[k][2] = 1 ; - b[k] = - vpMath::sqr(p.ifloat) - vpMath::sqr(p.jfloat) ; + b_[k] = - vpMath::sqr(p_me.ifloat) - vpMath::sqr(p_me.jfloat) ; k++ ; } } @@ -737,10 +737,10 @@ vpMeEllipse::leastSquare() DA = D*A ; vpMatrix DAp ; - x = DA.pseudoInverse(1e-26) *D*b ; + x = DA.pseudoInverse(1e-26) *D*b_ ; vpColVector residu(nos_1); - residu = b - A*x; + residu = b_ - A*x; r.setIteration(iter) ; r.MEstimator(vpRobust::TUKEY,residu,w) ; @@ -755,14 +755,14 @@ vpMeEllipse::leastSquare() k =0 ; for(std::list<vpMeSite>::iterator it=list.begin(); it!=list.end(); ++it){ - p = *it; - if (p.getState() == vpMeSite::NO_SUPPRESSION) + p_me = *it; + if (p_me.getState() == vpMeSite::NO_SUPPRESSION) { if (w[k] < thresholdWeight) { - p.setState(vpMeSite::M_ESTIMATOR); + p_me.setState(vpMeSite::M_ESTIMATOR); - *it = p; + *it = p_me; } k++ ; } @@ -840,7 +840,7 @@ vpMeEllipse::initTracking(const vpImage<unsigned char> &I, const unsigned int n, if (circle==false) { vpMatrix A(n,5) ; - vpColVector b(n) ; + vpColVector b_(n) ; vpColVector x(5) ; // Construction du systeme Ax=b @@ -855,16 +855,16 @@ vpMeEllipse::initTracking(const vpImage<unsigned char> &I, const unsigned int n, A[k][3] = 2* iP[k].get_j() ; A[k][4] = 1 ; - b[k] = - vpMath::sqr(iP[k].get_i()) ; + b_[k] = - vpMath::sqr(iP[k].get_i()) ; } - K = A.pseudoInverse(1e-26)*b ; + K = A.pseudoInverse(1e-26)*b_ ; std::cout << K << std::endl; } else { vpMatrix A(n,3) ; - vpColVector b(n) ; + vpColVector b_(n) ; vpColVector x(3) ; vpColVector Kc(3) ; @@ -874,10 +874,10 @@ vpMeEllipse::initTracking(const vpImage<unsigned char> &I, const unsigned int n, A[k][1] = 2* iP[k].get_j() ; A[k][2] = 1 ; - b[k] = - vpMath::sqr(iP[k].get_i()) - vpMath::sqr(iP[k].get_j()) ; + b_[k] = - vpMath::sqr(iP[k].get_i()) - vpMath::sqr(iP[k].get_j()) ; } - Kc = A.pseudoInverse(1e-26)*b ; + Kc = A.pseudoInverse(1e-26)*b_ ; K[0] = 1 ; K[1] = 0 ; K[2] = Kc[0] ; @@ -901,7 +901,6 @@ vpMeEllipse::initTracking(const vpImage<unsigned char> &I, const unsigned int n, vpMeTracker::initTracking(I) ; } - try{ track(I) ; } @@ -1130,7 +1129,7 @@ vpMeEllipse::initTracking(const vpImage<unsigned char> &I, const unsigned int n, if (circle==false) { vpMatrix A(n,5) ; - vpColVector b(n) ; + vpColVector b_(n) ; vpColVector x(5) ; // Construction du systeme Ax=b @@ -1145,16 +1144,16 @@ vpMeEllipse::initTracking(const vpImage<unsigned char> &I, const unsigned int n, A[k][3] = 2* j[k] ; A[k][4] = 1 ; - b[k] = - vpMath::sqr(i[k]) ; + b_[k] = - vpMath::sqr(i[k]) ; } - K = A.pseudoInverse(1e-26)*b ; + K = A.pseudoInverse(1e-26)*b_ ; std::cout << K << std::endl; } else { vpMatrix A(n,3) ; - vpColVector b(n) ; + vpColVector b_(n) ; vpColVector x(3) ; vpColVector Kc(3) ; @@ -1164,10 +1163,10 @@ vpMeEllipse::initTracking(const vpImage<unsigned char> &I, const unsigned int n, A[k][1] = 2* j[k] ; A[k][2] = 1 ; - b[k] = - vpMath::sqr(i[k]) - vpMath::sqr(j[k]) ; + b_[k] = - vpMath::sqr(i[k]) - vpMath::sqr(j[k]) ; } - Kc = A.pseudoInverse(1e-26)*b ; + Kc = A.pseudoInverse(1e-26)*b_ ; K[0] = 1 ; K[1] = 0 ; K[2] = Kc[0] ; @@ -1192,7 +1191,6 @@ vpMeEllipse::initTracking(const vpImage<unsigned char> &I, const unsigned int n, vpMeTracker::initTracking(I) ; } - try{ track(I) ; } diff --git a/src/tracking/moving-edges/vpMeEllipse.h b/src/tracking/moving-edges/vpMeEllipse.h index 8aa71961960743781d22a22201df898a572d90bc..741d60ea294b91a06f3e73799663c9437e54eacf 100644 --- a/src/tracking/moving-edges/vpMeEllipse.h +++ b/src/tracking/moving-edges/vpMeEllipse.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMeEllipse.h 4231 2013-04-29 16:26:28Z fspindle $ + * $Id: vpMeEllipse.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -175,9 +175,9 @@ public: Compared to the classical equation of an ellipse, \f$ K_0 \f$ is equal to 1 and \f$ K_1 \f$ is equal to 0. - \param circle : Set to true if you want to track a circle. + \param is_circle : Set to true if you want to track a circle. */ - void setCircle(bool circle) { this->circle = circle ; } + void setCircle(bool is_circle) { this->circle = is_circle ; } /*! Gets the 0 order moment \f$ m_{00} \f$ which represents the area of the ellipse. diff --git a/src/tracking/moving-edges/vpMeLine.cpp b/src/tracking/moving-edges/vpMeLine.cpp index fa562e93ef8f003df0500e82b70b853b0858a3d6..338fea347bb2e6cd15167165258a92496c705123 100644 --- a/src/tracking/moving-edges/vpMeLine.cpp +++ b/src/tracking/moving-edges/vpMeLine.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMeLine.cpp 4140 2013-02-21 10:50:22Z fspindle $ + * $Id: vpMeLine.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -58,8 +58,12 @@ #include <stdlib.h> #include <cmath> // std::fabs #include <limits> // numeric_limits +#include <algorithm> // std::min + #define INCR_MIN 1 +void computeDelta(double &delta, int i1, int j1, int i2, int j2); + static void normalizeAngle(double &delta) { @@ -101,18 +105,21 @@ project(double a, double b, double c, Basic constructor that calls the constructor of the class vpMeTracker. */ -vpMeLine::vpMeLine():vpMeTracker() +vpMeLine::vpMeLine() + : rho(0.), theta(0.), delta(0.), delta_1(0.), angle(0.), angle_1(90), sign(1), + _useIntensityForRho(true), a(0.), b(0.), c(0.) { - sign = 1; - angle_1 = 90; - _useIntensityForRho = true; } /*! Copy constructor. */ -vpMeLine::vpMeLine(const vpMeLine &meline):vpMeTracker(meline) +vpMeLine::vpMeLine(const vpMeLine &meline) + : vpMeTracker(meline), + rho(0.), theta(0.), delta(0.), delta_1(0.), angle(0.), angle_1(90), sign(1), + _useIntensityForRho(true), a(0.), b(0.), c(0.) + { rho = meline.rho; theta = meline.theta; @@ -300,7 +307,7 @@ vpMeLine::leastSquare() vpColVector w(numberOfSignal()) ; vpColVector B(numberOfSignal()) ; w =1 ; - vpMeSite p ; + vpMeSite p_me ; unsigned int iter =0 ; unsigned int nos_1 = 0 ; double distance = 100; @@ -320,12 +327,12 @@ vpMeLine::leastSquare() nos_1 = numberOfSignal() ; unsigned int k =0 ; for(std::list<vpMeSite>::const_iterator it=list.begin(); it!=list.end(); ++it){ - p = *it; - if (p.getState() == vpMeSite::NO_SUPPRESSION) + p_me = *it; + if (p_me.getState() == vpMeSite::NO_SUPPRESSION) { - A[k][0] = p.ifloat ; + A[k][0] = p_me.ifloat ; A[k][1] = 1 ; - B[k] = -p.jfloat ; + B[k] = -p_me.jfloat ; k++ ; } } @@ -353,14 +360,14 @@ vpMeLine::leastSquare() k =0 ; for(std::list<vpMeSite>::iterator it=list.begin(); it!=list.end(); ++it){ - p = *it; - if (p.getState() == vpMeSite::NO_SUPPRESSION) + p_me = *it; + if (p_me.getState() == vpMeSite::NO_SUPPRESSION) { if (w[k] < 0.2) { - p.setState(vpMeSite::M_ESTIMATOR); + p_me.setState(vpMeSite::M_ESTIMATOR); - *it = p; + *it = p_me; } k++ ; } @@ -385,12 +392,12 @@ vpMeLine::leastSquare() nos_1 = numberOfSignal() ; unsigned int k =0 ; for(std::list<vpMeSite>::const_iterator it=list.begin(); it!=list.end(); ++it){ - p = *it; - if (p.getState() == vpMeSite::NO_SUPPRESSION) + p_me = *it; + if (p_me.getState() == vpMeSite::NO_SUPPRESSION) { - A[k][0] = p.jfloat ; + A[k][0] = p_me.jfloat ; A[k][1] = 1 ; - B[k] = -p.ifloat ; + B[k] = -p_me.ifloat ; k++ ; } } @@ -416,17 +423,16 @@ vpMeLine::leastSquare() x_1 = x; } - k =0 ; for(std::list<vpMeSite>::iterator it=list.begin(); it!=list.end(); ++it){ - p = *it; - if (p.getState() == vpMeSite::NO_SUPPRESSION) + p_me = *it; + if (p_me.getState() == vpMeSite::NO_SUPPRESSION) { if (w[k] < 0.2) { - p.setState(vpMeSite::M_ESTIMATOR); + p_me.setState(vpMeSite::M_ESTIMATOR); - *it = p; + *it = p_me; } k++ ; } @@ -482,9 +488,9 @@ vpMeLine::initTracking(const vpImage<unsigned char> &I, PExt[1].ifloat = (float)ip2.get_i() ; PExt[1].jfloat = (float)ip2.get_j() ; - double angle = atan2((double)(i1s-i2s),(double)(j1s-j2s)) ; - a = cos(angle) ; - b = sin(angle) ; + double angle_ = atan2((double)(i1s-i2s),(double)(j1s-j2s)) ; + a = cos(angle_) ; + b = sin(angle_) ; // Real values of a, b can have an other sign. So to get the good values // of a and b in order to initialise then c, we call track(I) just below @@ -634,7 +640,7 @@ vpMeLine::seekExtremities(const vpImage<unsigned char> &I) // number of samples along line_p n_sample = length_p/(double)me->getSampleStep(); - double sample = (double)me->getSampleStep(); + double sample_step = (double)me->getSampleStep(); vpMeSite P ; P.init((int) PExt[0].ifloat, (int)PExt[0].jfloat, delta_1, 0, sign) ; @@ -647,8 +653,8 @@ vpMeLine::seekExtremities(const vpImage<unsigned char> &I) for (int i=0 ; i < 3 ; i++) { - P.ifloat = P.ifloat + di*sample ; P.i = (int)P.ifloat ; - P.jfloat = P.jfloat + dj*sample ; P.j = (int)P.jfloat ; + P.ifloat = P.ifloat + di*sample_step ; P.i = (int)P.ifloat ; + P.jfloat = P.jfloat + dj*sample_step ; P.j = (int)P.jfloat ; if(!outOfImage(P.i, P.j, 5, rows, cols)) { @@ -678,8 +684,8 @@ vpMeLine::seekExtremities(const vpImage<unsigned char> &I) P.setDisplay(selectDisplay) ; for (int i=0 ; i < 3 ; i++) { - P.ifloat = P.ifloat - di*sample ; P.i = (int)P.ifloat ; - P.jfloat = P.jfloat - dj*sample ; P.j = (int)P.jfloat ; + P.ifloat = P.ifloat - di*sample_step ; P.i = (int)P.ifloat ; + P.jfloat = P.jfloat - dj*sample_step ; P.j = (int)P.jfloat ; if(!outOfImage(P.i, P.j, 5, rows, cols)) { @@ -767,34 +773,34 @@ vpMeLine::reSample(const vpImage<unsigned char> &I) void vpMeLine::updateDelta() { - vpMeSite p ; + vpMeSite p_me ; - double angle = delta + M_PI/2; + double angle_ = delta + M_PI/2; double diff = 0; - while (angle<0) angle += M_PI; - while (angle>M_PI) angle -= M_PI; + while (angle_<0) angle_ += M_PI; + while (angle_>M_PI) angle_ -= M_PI; - angle = vpMath::round(angle * 180 / M_PI) ; + angle_ = vpMath::round(angle_ * 180 / M_PI) ; - //if(fabs(angle) == 180 ) - if(std::fabs(std::fabs(angle) - 180) <= std::numeric_limits<double>::epsilon()) + //if(fabs(angle_) == 180 ) + if(std::fabs(std::fabs(angle_) - 180) <= std::numeric_limits<double>::epsilon()) { - angle= 0 ; + angle_= 0 ; } //std::cout << "angle theta : " << theta << std::endl ; - diff = fabs(angle - angle_1); + diff = fabs(angle_ - angle_1); if (diff > 90) sign *= -1; - angle_1 = angle; + angle_1 = angle_; for(std::list<vpMeSite>::iterator it=list.begin(); it!=list.end(); ++it){ - p = *it; - p.alpha = delta ; - p.mask_sign = sign; - *it = p; + p_me = *it; + p_me.alpha = delta ; + p_me.mask_sign = sign; + *it = p_me; } delta_1 = delta; } diff --git a/src/tracking/moving-edges/vpMeLine.h b/src/tracking/moving-edges/vpMeLine.h index 6f7897db63a470dda8dd3339d7761260c1954d73..3d51adda929a91c67e360cc3c650a3087c751042 100644 --- a/src/tracking/moving-edges/vpMeLine.h +++ b/src/tracking/moving-edges/vpMeLine.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMeLine.h 4231 2013-04-29 16:26:28Z fspindle $ + * $Id: vpMeLine.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/tracking/moving-edges/vpMeNurbs.cpp b/src/tracking/moving-edges/vpMeNurbs.cpp index 389b91721d77f96f9d4685a056af9266930f0680..1ea32929d147ee0e57c9cc38c8e27906047ffbcc 100644 --- a/src/tracking/moving-edges/vpMeNurbs.cpp +++ b/src/tracking/moving-edges/vpMeNurbs.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMeNurbs.cpp 4135 2013-02-13 16:48:19Z fspindle $ + * $Id: vpMeNurbs.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -68,6 +68,15 @@ # endif #endif +double computeDelta(double deltai, double deltaj); +void findAngle(const vpImage<unsigned char> &I, const vpImagePoint &iP, + vpMe* me, double &angle, double &convlt); +vpImagePoint findFirstBorder(const vpImage<unsigned char>& Isub, const vpImagePoint &iP); +bool findCenterPoint(std::list<vpImagePoint> *ip_edges_list); +#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS +vp_deprecated bool findCenterPoint(vpList<vpImagePoint> *ip_edges_list); +#endif + //Compute the angle delta = arctan(deltai/deltaj) //and normalize it between 0 and pi double @@ -220,20 +229,19 @@ bool findCenterPoint(std::list<vpImagePoint> *ip_edges_list) /*! Basic constructor that calls the constructor of the class vpMeTracker. */ -vpMeNurbs::vpMeNurbs():vpMeTracker() +vpMeNurbs::vpMeNurbs() + : nurbs(), dist(0.), nbControlPoints(20), beginPtFound(0), endPtFound(0), enableCannyDetection(false), + cannyTh1(100.), cannyTh2(200.) { - nbControlPoints = 20; - beginPtFound = 0; - endPtFound =0; - enableCannyDetection = false; - cannyTh1 = 100.0; - cannyTh2 = 200.0; } /*! Copy constructor. */ -vpMeNurbs::vpMeNurbs(const vpMeNurbs &menurbs):vpMeTracker(menurbs) +vpMeNurbs::vpMeNurbs(const vpMeNurbs &menurbs) + : vpMeTracker(menurbs), + nurbs(), dist(0.), nbControlPoints(20), beginPtFound(0), endPtFound(0), enableCannyDetection(false), + cannyTh1(100.), cannyTh2(200.) { nurbs = menurbs.nurbs; dist = menurbs.dist; @@ -459,7 +467,7 @@ vpMeNurbs::seekExtremities(const vpImage<unsigned char> &I) //Check if the two extremities are not to close to eachother. double d = vpImagePoint::distance(begin[0],end[0]); double threshold = 3*me->getSampleStep(); - double sample = me->getSampleStep(); + double sample_step = me->getSampleStep(); vpImagePoint pt; if ( d > threshold /*|| (list.firstValue()).mask_sign != (list.lastValue()).mask_sign*/) { @@ -483,8 +491,8 @@ vpMeNurbs::seekExtremities(const vpImage<unsigned char> &I) si = si * vpMath::sign(begin[1].get_i()); for (int i=0 ; i < 3 ; i++) { - P.ifloat = P.ifloat - si*sample ; P.i = (int)P.ifloat ; - P.jfloat = P.jfloat - co*sample ; P.j = (int)P.jfloat ; + P.ifloat = P.ifloat - si*sample_step ; P.i = (int)P.ifloat ; + P.jfloat = P.jfloat - co*sample_step ; P.j = (int)P.jfloat ; pt.set_ij(P.ifloat,P.jfloat); if (vpImagePoint::distance(end[0],pt) < threshold) break; if(!outOfImage(P.i, P.j, 5, rows, cols)) @@ -501,9 +509,9 @@ vpMeNurbs::seekExtremities(const vpImage<unsigned char> &I) } } else { - if (vpDEBUG_ENABLE(3)) { - vpDisplay::displayCross(I, pt, 10, vpColor::blue) ; - } + if (vpDEBUG_ENABLE(3)) { + vpDisplay::displayCross(I, pt, 10, vpColor::blue) ; + } } } } @@ -521,8 +529,8 @@ vpMeNurbs::seekExtremities(const vpImage<unsigned char> &I) si = si * vpMath::sign(end[1].get_i()); for (int i=0 ; i < 3 ; i++) { - P.ifloat = P.ifloat + si*sample ; P.i = (int)P.ifloat ; - P.jfloat = P.jfloat + co*sample ; P.j = (int)P.jfloat ; + P.ifloat = P.ifloat + si*sample_step ; P.i = (int)P.ifloat ; + P.jfloat = P.jfloat + co*sample_step ; P.j = (int)P.jfloat ; pt.set_ij(P.ifloat,P.jfloat); if (vpImagePoint::distance(begin[0],pt) < threshold) break; if(!outOfImage(P.i, P.j, 5, rows, cols)) @@ -538,9 +546,9 @@ vpMeNurbs::seekExtremities(const vpImage<unsigned char> &I) } } else { - if (vpDEBUG_ENABLE(3)) { - vpDisplay::displayCross(I, pt, 10, vpColor::blue) ; - } + if (vpDEBUG_ENABLE(3)) { + vpDisplay::displayCross(I, pt, 10, vpColor::blue) ; + } } } } @@ -551,8 +559,8 @@ vpMeNurbs::seekExtremities(const vpImage<unsigned char> &I) { list.pop_front(); } - if(begin != NULL) delete[] begin; - if(end != NULL) delete[] end; + /*if(begin != NULL)*/ delete[] begin; + /*if(end != NULL) */ delete[] end; } @@ -709,7 +717,7 @@ vpMeNurbs::seekExtremitiesCanny(const vpImage<unsigned char> & /* I */) me->setRange(memory_range); } - if (begin != NULL) delete[] begin; + /* if (begin != NULL) */ delete[] begin; beginPtFound = 0; } @@ -806,6 +814,7 @@ vpMeNurbs::seekExtremitiesCanny(const vpImage<unsigned char> & /* I */) } std::list<vpMeSite>::iterator itList = list.end(); + --itList; // Move on the last element double convlt; double delta; int nbr = 0; @@ -839,17 +848,18 @@ vpMeNurbs::seekExtremitiesCanny(const vpImage<unsigned char> & /* I */) unsigned int memory_range = me->getRange(); me->setRange(3); std::list<vpMeSite>::iterator itList2 = list.end(); + --itList2; // Move to the last element for (int j = 0; j < nbr; j++) { - vpMeSite s = *itList2; - s.track(I,me,false); - *itList2 = s; + vpMeSite me_s = *itList2; + me_s.track(I,me,false); + *itList2 = me_s; --itList2; } me->setRange(memory_range); } - if (end != NULL) delete[] end; + /* if (end != NULL) */ delete[] end; endPtFound = 0; } #else @@ -944,14 +954,14 @@ vpMeNurbs::localReSample(const vpImage<unsigned char> &I) //if(( u != 1.0 || uend != 1.0) if( (std::fabs(u-1.0) > std::fabs(vpMath::maximum(u, 1.0))*std::numeric_limits<double>::epsilon()) - || (std::fabs(uend-1.0) > std::fabs(vpMath::maximum(u, 1.0))*std::numeric_limits<double>::epsilon())) + || (std::fabs(uend-1.0) > std::fabs(vpMath::maximum(uend, 1.0))*std::numeric_limits<double>::epsilon())) { iP = nurbs.computeCurveDersPoint(u, 1); while (vpImagePoint::sqrDistance(iP[0],iPend) > vpMath::sqr(me->getSampleStep()) && u < uend) { u+=0.01; - if (iP!=NULL) { + /*if (iP!=NULL)*/ { delete[] iP; iP = NULL; } @@ -970,7 +980,7 @@ vpMeNurbs::localReSample(const vpImage<unsigned char> &I) } } } - if (iP!=NULL) { + /*if (iP!=NULL)*/ { delete[] iP; iP = NULL; } diff --git a/src/tracking/moving-edges/vpMeNurbs.h b/src/tracking/moving-edges/vpMeNurbs.h index 737281298bd1fdac3333a6d08848e20b3bfee710..242a99e2ef5febc319e024722d2a8380ad361945 100644 --- a/src/tracking/moving-edges/vpMeNurbs.h +++ b/src/tracking/moving-edges/vpMeNurbs.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMeNurbs.h 4062 2013-01-09 10:30:06Z fspindle $ + * $Id: vpMeNurbs.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -160,16 +160,16 @@ class VISP_EXPORT vpMeNurbs : public vpMeTracker /*! Sets the number of control points used to compute the Nurbs. - \param nbControlPoints : The number of control points used to compute the Nurbs. + \param nb_point : The number of control points used to compute the Nurbs. */ - void setNbControlPoints(const unsigned int nbControlPoints) {this->nbControlPoints = nbControlPoints;} + void setNbControlPoints(const unsigned int nb_point) {this->nbControlPoints = nb_point;} /*! Enables or disables the canny detection used during the extremities search. - \param enableCannyDetection : if true it enables the canny detection. + \param enable_canny : if true it enables the canny detection. */ - void setEnableCannyDetection(const bool enableCannyDetection) {this->enableCannyDetection =enableCannyDetection;} + void setEnableCannyDetection(const bool enable_canny) {this->enableCannyDetection =enable_canny;} /*! Enables to set the two thresholds use by the canny detection. diff --git a/src/tracking/moving-edges/vpMeSite.cpp b/src/tracking/moving-edges/vpMeSite.cpp index 31a8af8823cbabe1e324f05b335850877185dca5..5b87a50f5894464924c69e1d0bdfdaf71c11c4da 100644 --- a/src/tracking/moving-edges/vpMeSite.cpp +++ b/src/tracking/moving-edges/vpMeSite.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMeSite.cpp 4062 2013-01-09 10:30:06Z fspindle $ + * $Id: vpMeSite.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -100,15 +100,21 @@ vpMeSite::init() } vpMeSite::vpMeSite() + : i(0), j(0), i_1(0), j_1(0), ifloat(0), jfloat(0), v(0), mask_sign(1), alpha(0.), + convlt(0.), normGradient(0), weight(1), selectDisplay(NONE), state(NO_SUPPRESSION) +#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS + , suppress(0) +#endif { - init() ; } vpMeSite::vpMeSite(double ip, double jp) + : i(0), j(0), i_1(0), j_1(0), ifloat(0), jfloat(0), v(0), mask_sign(1), alpha(0.), + convlt(0.), normGradient(0), weight(1), selectDisplay(NONE), state(NO_SUPPRESSION) +#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS + , suppress(0) +#endif { - init() ; - - selectDisplay = NONE ; i = vpMath::round(ip) ; j = vpMath::round(jp) ; ifloat = ip ; @@ -119,6 +125,11 @@ vpMeSite::vpMeSite(double ip, double jp) Copy constructor. */ vpMeSite::vpMeSite (const vpMeSite &mesite) + : i(0), j(0), i_1(0), j_1(0), ifloat(0), jfloat(0), v(0), mask_sign(1), alpha(0.), + convlt(0.), normGradient(0), weight(1), selectDisplay(NONE), state(NO_SUPPRESSION) +#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS + , suppress(0) +#endif { *this = mesite; } @@ -497,7 +508,7 @@ vpMeSite::track(const vpImage<unsigned char>& I, int max_rank =-1 ; // int max_rank1=-1 ; // int max_rank2 = -1; - double convolution = 0 ; + double convolution_ = 0 ; double max_convolution = 0 ; double max = 0 ; double contraste = 0; @@ -530,21 +541,21 @@ vpMeSite::track(const vpImage<unsigned char>& I, for(unsigned int n = 0 ; n < 2 * range + 1 ; n++) { // convolution results - convolution = list_query_pixels[n].convolution(I, me) ; + convolution_ = list_query_pixels[n].convolution(I, me) ; // luminance ratio of reference pixel to potential correspondent pixel // the luminance must be similar, hence the ratio value should // lay between, for instance, 0.5 and 1.5 (parameter tolerance) if( test_contraste ) { - likelihood[n] = fabs(convolution + convlt ); + likelihood[n] = fabs(convolution_ + convlt ); if (likelihood[n]> threshold) { - contraste = convolution / convlt; + contraste = convolution_ / convlt; if((contraste > contraste_min) && (contraste < contraste_max) && fabs(1-contraste) < diff) { diff = fabs(1-contraste); - max_convolution= convolution; + max_convolution= convolution_; max = likelihood[n] ; max_rank = (int)n ; // max_rank2 = max_rank1; @@ -555,10 +566,10 @@ vpMeSite::track(const vpImage<unsigned char>& I, else { - likelihood[n] = fabs(2*convolution) ; + likelihood[n] = fabs(2*convolution_) ; if (likelihood[n] > max && likelihood[n] > threshold) { - max_convolution= convolution; + max_convolution= convolution_; max = likelihood[n] ; max_rank = (int)n ; // max_rank2 = max_rank1; @@ -617,18 +628,18 @@ int vpMeSite::operator!=(const vpMeSite &m) } -std::ostream& operator<<(std::ostream& os, vpMeSite& vpMeS) +VISP_EXPORT std::ostream& operator<<(std::ostream& os, vpMeSite& vpMeS) { #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS return (os << "Alpha: " << vpMeS.alpha << " Convolution: " << vpMeS.convlt << " Flag: " << vpMeS.suppress << " Weight: " << vpMeS.weight ); -#endif - +#else return (os << "Alpha: " << vpMeS.alpha << " Convolution: " << vpMeS.convlt << " Weight: " << vpMeS.weight ); +#endif } void vpMeSite::display(const vpImage<unsigned char>& I) @@ -675,6 +686,7 @@ void vpMeSite::display(const vpImage<unsigned char>& I, const double &i, const d case TOO_NEAR: vpDisplay::displayCross(I,vpImagePoint(i,j),3,vpColor::cyan,1); + break; default: vpDisplay::displayCross(I,vpImagePoint(i,j),3,vpColor::yellow,1); @@ -718,6 +730,7 @@ void vpMeSite::display(const vpImage<vpRGBa>& I, const double &i, const double & case TOO_NEAR: vpDisplay::displayCross(I,vpImagePoint(i,j),3,vpColor::cyan,1); + break; default: vpDisplay::displayCross(I,vpImagePoint(i,j),3,vpColor::yellow,1); diff --git a/src/tracking/moving-edges/vpMeSite.h b/src/tracking/moving-edges/vpMeSite.h index d1c70b0ff78b6949fb87293b8a53fb76a8b93542..bac0bbad5232e374900d32a2efcba1d63e98795d 100644 --- a/src/tracking/moving-edges/vpMeSite.h +++ b/src/tracking/moving-edges/vpMeSite.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMeSite.h 4062 2013-01-09 10:30:06Z fspindle $ + * $Id: vpMeSite.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/tracking/moving-edges/vpMeTracker.cpp b/src/tracking/moving-edges/vpMeTracker.cpp index 1d7c911abe918db69ed01225b5e9df19c60b3846..f043857f5e516279ad76d0fb710b45e24b26bb6a 100644 --- a/src/tracking/moving-edges/vpMeTracker.cpp +++ b/src/tracking/moving-edges/vpMeTracker.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * -* $Id: vpMeTracker.cpp 4303 2013-07-04 14:14:00Z fspindle $ +* $Id: vpMeTracker.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. -* Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +* Copyright (C) 2005 - 2014 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 @@ -66,19 +66,20 @@ vpMeTracker::init() } vpMeTracker::vpMeTracker() + : list(), me(NULL), init_range(1), nGoodElement(0), selectDisplay(vpMeSite::NONE) +#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS + , query_range (0), display_point(false) +#endif { init(); - me = NULL ; - nGoodElement = 0; - init_range = 1; - - #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS - query_range = 0; - display_point = false ; - #endif } -vpMeTracker::vpMeTracker(const vpMeTracker& meTracker):vpTracker(meTracker) +vpMeTracker::vpMeTracker(const vpMeTracker& meTracker) + : vpTracker(meTracker), + list(), me(NULL), init_range(1), nGoodElement(0), selectDisplay(vpMeSite::NONE) +#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS + , query_range (0), display_point(false) +#endif { init(); @@ -100,11 +101,11 @@ vpMeTracker::~vpMeTracker() } vpMeTracker& -vpMeTracker::operator = (vpMeTracker& p) +vpMeTracker::operator = (vpMeTracker& p_me) { - list = p.list; - me = p.me; - selectDisplay = p.selectDisplay ; + list = p_me.list; + me = p_me.me; + selectDisplay = p_me.selectDisplay ; return *this; } @@ -331,8 +332,8 @@ vpMeTracker::display(const vpImage<unsigned char>& I) } #endif for(std::list<vpMeSite>::const_iterator it=list.begin(); it!=list.end(); ++it){ - vpMeSite p = *it; - p.display(I); + vpMeSite p_me = *it; + p_me.display(I); } } diff --git a/src/tracking/moving-edges/vpMeTracker.h b/src/tracking/moving-edges/vpMeTracker.h index de23ef774c9fbabc4fe6d0f683508a9d625e8a6b..ecc60da7df06f17a8b2a1cbff637cd553aaf6c4c 100644 --- a/src/tracking/moving-edges/vpMeTracker.h +++ b/src/tracking/moving-edges/vpMeTracker.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpMeTracker.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpMeTracker.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -135,9 +135,9 @@ public: /*! Set the moving edges initialisation parameters - \param me : Moving Edges. + \param p_me : Moving Edges. */ - void setMe(vpMe *me) { this->me = me ; } + void setMe(vpMe *p_me) { this->me = p_me ; } /*! Return the moving edges initialisation parameters diff --git a/src/tracking/template-tracker/ssd/vpTemplateTrackerSSD.cpp b/src/tracking/template-tracker/ssd/vpTemplateTrackerSSD.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b7dcbb91584fc35dae102ca28c9e1ddc7bc727a2 --- /dev/null +++ b/src/tracking/template-tracker/ssd/vpTemplateTrackerSSD.cpp @@ -0,0 +1,132 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerSSD.cpp 4666 2014-02-16 16:21:33Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ + +#include <visp/vpTemplateTrackerSSD.h> + +vpTemplateTrackerSSD::vpTemplateTrackerSSD(vpTemplateTrackerWarp *warp) + : vpTemplateTracker(warp), DI(), temp() +{ + dW.resize(2,nbParam); + G.resize(nbParam); + H.resize(nbParam,nbParam); + HLM.resize(nbParam,nbParam); + + temp.resize(nbParam); + + X1.resize(2); + X2.resize(2); + DI.resize(2); +} + +double vpTemplateTrackerSSD::getCost(const vpImage<unsigned char> &I,vpColVector &tp) +{ + double erreur=0; + double IW,Tij; + int i,j; + double i2,j2; + int Nbpoint=0; + + Warp->computeCoeff(tp); + for(unsigned int point=0;point<templateSize;point++) + { + i=ptTemplate[point].y; + j=ptTemplate[point].x; + X1[0]=j;X1[1]=i; + Warp->computeDenom(X1,tp); + Warp->warpX(X1,X2,tp); + + j2=X2[0];i2=X2[1]; + if((i2>=0)&&(j2>=0)&&(i2<I.getHeight()-1)&&(j2<I.getWidth()-1)) + { + Tij=ptTemplate[point].val; + if(!blur) + IW=I.getValue(i2,j2); + else + IW=BI.getValue(i2,j2); + //IW=getSubPixBspline4(I,i2,j2); + erreur+=((double)Tij-IW)*((double)Tij-IW); + Nbpoint++; + } + } + ratioPixelIn=(double)Nbpoint/(double)templateSize; + + if(Nbpoint==0)return 10e10; + return erreur/Nbpoint; +} + + +double vpTemplateTrackerSSD::getSSD(vpImage<unsigned char> &I,vpColVector &tp) +{ + double erreur=0; + double IW,Tij; + int i,j; + double i2,j2; + int Nbpoint=0; + + if(pyrInitialised) + { + templateSize=templateSizePyr[0]; + ptTemplate=ptTemplatePyr[0]; + } + + Warp->computeCoeff(tp); + for(unsigned int point=0;point<templateSize;point++) + { + i=ptTemplate[point].y; + j=ptTemplate[point].x; + X1[0]=j;X1[1]=i; + Warp->computeDenom(X1,tp); + Warp->warpX(X1,X2,tp); + + j2=X2[0];i2=X2[1]; + if((j2<I.getWidth()-1)&&(i2<I.getHeight()-1)&&(i2>0)&&(j2>0)) + { + Tij=ptTemplate[point].val; + IW=I.getValue(i2,j2); + //IW=getSubPixBspline4(I,i2,j2); + erreur+=((double)Tij-IW)*((double)Tij-IW); + Nbpoint++; + } + } + if(Nbpoint==0)return 10e10; + return erreur/Nbpoint; +} diff --git a/src/tracking/template-tracker/ssd/vpTemplateTrackerSSD.h b/src/tracking/template-tracker/ssd/vpTemplateTrackerSSD.h new file mode 100644 index 0000000000000000000000000000000000000000..00c6a92f92546f313a1eacec522df41a50ffb7cd --- /dev/null +++ b/src/tracking/template-tracker/ssd/vpTemplateTrackerSSD.h @@ -0,0 +1,84 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerSSD.h 4666 2014-02-16 16:21:33Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +/*! + \file vpTemplateTrackerSSD.h + \brief +*/ + +#ifndef vpTemplateTrackerSSD_hh +#define vpTemplateTrackerSSD_hh + +#include <math.h> + +#include <visp/vpTemplateTracker.h> +#include <visp/vpImage.h> +#include <visp/vpDisplay.h> +#include <visp/vpImageTools.h> +#include <visp/vpImageIo.h> +#include <visp/vpIoTools.h> +#include <visp/vpImageTools.h> +#include <visp/vpImageFilter.h> +#include <visp/vpMath.h> +#include <visp/vpList.h> +#include <visp/vpHomography.h> + +class VISP_EXPORT vpTemplateTrackerSSD: public vpTemplateTracker +{ + protected: + vpRowVector DI; + vpRowVector temp; + + protected: + double getCost(const vpImage<unsigned char> &I, vpColVector &tp); + double getCost(const vpImage<unsigned char> &I){ return getCost(I,p); } + virtual void initHessienDesired(const vpImage<unsigned char> &I) = 0; + virtual void trackNoPyr(const vpImage<unsigned char> &I) = 0; + + public: + vpTemplateTrackerSSD(vpTemplateTrackerWarp *warp); + + double getSSD(vpImage<unsigned char> &I,vpColVector &tp); + void setGain(double g){ gain=g; } +}; + +#endif + diff --git a/src/tracking/template-tracker/ssd/vpTemplateTrackerSSDESM.cpp b/src/tracking/template-tracker/ssd/vpTemplateTrackerSSDESM.cpp new file mode 100644 index 0000000000000000000000000000000000000000..343680b0b95b45a2eda23a7767ea18687a1ddf49 --- /dev/null +++ b/src/tracking/template-tracker/ssd/vpTemplateTrackerSSDESM.cpp @@ -0,0 +1,332 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerSSDESM.cpp 4632 2014-02-03 17:06:40Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +#include <visp/vpTemplateTrackerSSDESM.h> +#include <visp/vpImageFilter.h> + +vpTemplateTrackerSSDESM::vpTemplateTrackerSSDESM(vpTemplateTrackerWarp *warp) + : vpTemplateTrackerSSD(warp), compoInitialised(false), HDir(), HInv(), + HLMDir(), HLMInv(), GDir(), GInv() +{ + useCompositionnal=false; + useInverse=false; + + if(!Warp->isESMcompatible()) + std::cerr<<"The selected warp function is not appropriate for the ESM algorithm..."<<std::endl; + + HInv.resize(nbParam,nbParam); + HDir.resize(nbParam,nbParam); + HLMInv.resize(nbParam,nbParam); + HLMDir.resize(nbParam,nbParam); + GInv.resize(nbParam); + GDir.resize(nbParam); +} + +void vpTemplateTrackerSSDESM::initHessienDesired(const vpImage<unsigned char> &I) +{ + initCompInverse(I); +} + +void vpTemplateTrackerSSDESM::initCompInverse(const vpImage<unsigned char> &/*I*/) +{ + //std::cout<<"Initialise precomputed value of ESM with templateSize: "<< templateSize<<std::endl; + ptTemplateCompo=new vpTemplateTrackerPointCompo[templateSize]; + int i,j; + //direct + for(unsigned int point=0;point<templateSize;point++) + { + i=ptTemplate[point].y; + j=ptTemplate[point].x; + ptTemplateCompo[point].dW=new double[2*nbParam]; + X1[0]=j;X1[1]=i; + Warp->computeDenom(X1,p); + Warp->getdWdp0(i,j,ptTemplateCompo[point].dW); + + } + + //inverse + HInv=0; + for(unsigned int point=0;point<templateSize;point++) + { + i=ptTemplate[point].y; + j=ptTemplate[point].x; + + X1[0]=j;X1[1]=i; + Warp->computeDenom(X1,p); + ptTemplate[point].dW=new double[nbParam]; + Warp->getdW0(i,j,ptTemplate[point].dy,ptTemplate[point].dx,ptTemplate[point].dW); + + for(unsigned int it=0;it<nbParam;it++) + for(unsigned int jt=0;jt<nbParam;jt++) + HInv[it][jt]+=ptTemplate[point].dW[it]*ptTemplate[point].dW[jt]; + } + vpMatrix::computeHLM(HInv,lambdaDep,HLMInv); + +compoInitialised=true; +} + +void vpTemplateTrackerSSDESM::trackNoPyr(const vpImage<unsigned char> &I) +{ + double erreur=0; + int Nbpoint=0; + + if(blur) + vpImageFilter::filter(I, BI,fgG,taillef); + vpImageFilter::getGradXGauss2D(I, dIx, fgG,fgdG,taillef); + vpImageFilter::getGradYGauss2D(I, dIy, fgG,fgdG,taillef); + + double IW,dIWx,dIWy; + double Tij; + unsigned int iteration=0; + int i,j; + double i2,j2; + double alpha=2.; + do + { + Nbpoint=0; + erreur=0; + dp=0; + HDir=0; + GDir=0; + GInv=0; + Warp->computeCoeff(p); + for(unsigned int point=0;point<templateSize;point++) + { + i=ptTemplate[point].y; + j=ptTemplate[point].x; + X1[0]=j;X1[1]=i; + + Warp->computeDenom(X1,p); + Warp->warpX(X1,X2,p); + + j2=X2[0];i2=X2[1]; + if((i2>=0)&&(j2>=0)&&(i2<I.getHeight()-1)&&(j2<I.getWidth()-1)) + { + //INVERSE + Tij=ptTemplate[point].val; + if(!blur) + IW=I.getValue(i2,j2); + else + IW=BI.getValue(i2,j2); + Nbpoint++; + double er=(Tij-IW); + for(unsigned int it=0;it<nbParam;it++) + GInv[it]+=er*ptTemplate[point].dW[it]; + + erreur+=er*er; + + //DIRECT + //dIWx=dIx.getValue(i2,j2); + //dIWy=dIy.getValue(i2,j2); + + dIWx=dIx.getValue(i2,j2)+ptTemplate[point].dx; + dIWy=dIy.getValue(i2,j2)+ptTemplate[point].dy; + + //Calcul du Hessien + //Warp->dWarp(X1,X2,p,dW); + Warp->dWarpCompo(X1,X2,p,ptTemplateCompo[point].dW,dW); + + double *tempt=new double[nbParam]; + for(unsigned int it=0;it<nbParam;it++) + tempt[it]=dW[0][it]*dIWx+dW[1][it]*dIWy; + + for(unsigned int it=0;it<nbParam;it++) + for(unsigned int jt=0;jt<nbParam;jt++) + HDir[it][jt]+=tempt[it]*tempt[jt]; + + for(unsigned int it=0;it<nbParam;it++) + GDir[it]+=er*tempt[it]; + delete[] tempt; + } + + + } + vpMatrix::computeHLM(HDir,lambdaDep,HLMDir); + //if(Nbpoint==0)std::cout<<"plus de point dans template suivi"<<std::endl; + try + { + //dp=(HLMInv+HLMDir).inverseByLU()*(GInv+GDir); + //dp=HLMInv.inverseByLU()*GInv+HLMDir.inverseByLU()*GDir; + //dp=HLMInv.inverseByLU()*GInv; + dp=(HLMDir).inverseByLU()*(GDir); + } + catch(...) + { + std::cout<<"probleme inversion"<<std::endl; + break; + } + + dp=gain*dp; + if(useBrent) + { + if(! Nbpoint) { + throw(vpException(vpException::divideByZeroError, + "Cannot compute optimal Brent gain: size = 0")) ; + } + + alpha=2.; + computeOptimalBrentGain(I,p,erreur/Nbpoint,dp,alpha); + dp=alpha*dp; + } + + //Warp->pRondp(p,dp,p); + p+=dp; + iteration++; + + } + while( (iteration < iterationMax)); + + nbIteration=iteration; +} + + +/*void vpTemplateTrackerSSDESM::InitCompInverse(vpImage<unsigned char> &I) +{ + ptTempateCompo=new vpTemplateTrackerPointCompo[taille_template]; + int i,j; + for(int point=0;point<taille_template;point++) + { + i=ptTemplate[point].y; + j=ptTemplate[point].x; + ptTempateCompo[point].dW=new double[2*nbParam]; + Warp->getdWdp0(i,j,ptTempateCompo[point].dW); + } + +} + +void vpTemplateTrackerSSDESM::track(vpImage<unsigned char> &I) +{ + double erreur=0,erreur_prec=1e38; + int Nbpoint=0; + + int taillefiltre=taille_filtre_dgaussien; + double *fg=new double[taillefiltre+1] ; + getGaussianDerivativeKernel(fg, taillefiltre) ; + getGradX(I, dIx,fg,taillefiltre); + getGradY(I, dIy,fg,taillefiltre); + delete[] fg; + + vpColVector dpinv(nbParam); + double lambda=lambdaDep; + double IW,dIWx,dIWy; + double Tij; + int iteration=0; + int i,j; + double i2,j2; + vpTemplateTrackerPoint *pt; + do + { + Nbpoint=0; + erreur_prec=erreur; + erreur=0; + dp=0; + HDir=0; + GDir=0; + GInv=0; + Warp->ComputeCoeff(p); + for(int point=0;point<taille_template;point++) + { + pt=&ptTemplate[point]; + i=pt->y; + j=pt->x; + X1[0]=j;X1[1]=i; + + Warp->ComputeDenom(X1,p); + Warp->warpX(X1,X2,p); + + j2=X2[0];i2=X2[1]; + if((j2<I.getWidth())&&(i2<I.getHeight())&&(i2>0)&&(j2>0)) + { + //INVERSE + Tij=pt->val; + IW=I.getPixelBI(j2,i2); + Nbpoint++; + double er=(Tij-IW); + for(int it=0;it<nbParam;it++) + GInv[it]+=er*ptTemplate[point].dW[it]; + + erreur+=er*er; + + //DIRECT COMPO + Tij=ptTemplate[point].val; + IW=I.getPixelBI(j2,i2); + dIWx=dIx.getPixelBI(j2,i2); + dIWy=dIy.getPixelBI(j2,i2); + Nbpoint++; + Warp->dWarpCompo(X1,X2,p,ptTempateCompo[point].dW,dW); + double *tempt=new double[nbParam]; + for(int it=0;it<nbParam;it++) + tempt[it] =dW[0][it]*dIWx+dW[1][it]*dIWy; + + for(int it=0;it<nbParam;it++) + for(int jt=0;jt<nbParam;jt++) + HDir[it][jt]+=tempt[it]*tempt[jt]; + + for(int it=0;it<nbParam;it++) + GDir[it]+=er*tempt[it]; + + delete[] tempt; + } + + + } + if(Nbpoint==0)std::cout<<"plus de point dans template suivi"<<std::endl; + try + { + dp=(HInv+HDir).inverseByLU()*(GInv+GDir); + } + catch(...) + { + std::cout<<"probleme inversion"<<std::endl; + break; + } + + if(Compare)write_infos(p,erreur/Nbpoint); + + p+=Gain*dp; + iteration++; + + } + while( (iteration < IterationMax)); + + NbIteration=iteration; +}*/ + diff --git a/src/tracking/template-tracker/ssd/vpTemplateTrackerSSDESM.h b/src/tracking/template-tracker/ssd/vpTemplateTrackerSSDESM.h new file mode 100644 index 0000000000000000000000000000000000000000..3ab98a1dddf8cc83327b3cb2375f4acb179f217f --- /dev/null +++ b/src/tracking/template-tracker/ssd/vpTemplateTrackerSSDESM.h @@ -0,0 +1,71 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerSSDESM.h 4574 2014-01-09 08:48:51Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +/*! + \file vpTemplateTrackerSSDESM.h + \brief +*/ + +#ifndef vpTemplateTrackerSSDESM_hh +#define vpTemplateTrackerSSDESM_hh + +#include <visp/vpTemplateTrackerSSD.h> + +class VISP_EXPORT vpTemplateTrackerSSDESM: public vpTemplateTrackerSSD +{ + protected: + bool compoInitialised; + vpMatrix HDir; + vpMatrix HInv; + vpMatrix HLMDir; + vpMatrix HLMInv; + vpColVector GDir; + vpColVector GInv; + + protected: + void initHessienDesired(const vpImage<unsigned char> &I); + void initCompInverse(const vpImage<unsigned char> &I); + void trackNoPyr(const vpImage<unsigned char> &I); + + public: + vpTemplateTrackerSSDESM(vpTemplateTrackerWarp *warp); +}; +#endif diff --git a/src/tracking/template-tracker/ssd/vpTemplateTrackerSSDForwardAdditional.cpp b/src/tracking/template-tracker/ssd/vpTemplateTrackerSSDForwardAdditional.cpp new file mode 100644 index 0000000000000000000000000000000000000000..510ab358f173a10f44f8680843fb80f4e6035cec --- /dev/null +++ b/src/tracking/template-tracker/ssd/vpTemplateTrackerSSDForwardAdditional.cpp @@ -0,0 +1,211 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerSSDForwardAdditional.cpp 4661 2014-02-10 19:34:58Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ + +#include <limits> // numeric_limits + +#include <visp/vpTemplateTrackerSSDForwardAdditional.h> +#include <visp/vpImageTools.h> + +vpTemplateTrackerSSDForwardAdditional::vpTemplateTrackerSSDForwardAdditional(vpTemplateTrackerWarp *warp) + : vpTemplateTrackerSSD(warp), minimizationMethod(USE_NEWTON), p_prec(), G_prec(), KQuasiNewton() +{ + useCompositionnal=false; +} + +void vpTemplateTrackerSSDForwardAdditional::trackNoPyr(const vpImage<unsigned char> &I) +{ + double erreur=0; + int Nbpoint=0; + + if(blur) + vpImageFilter::filter(I, BI,fgG,taillef); + vpImageFilter::getGradXGauss2D(I, dIx, fgG,fgdG,taillef); + vpImageFilter::getGradYGauss2D(I, dIy, fgG,fgdG,taillef); + + dW=0; + + double lambda=lambdaDep; + double IW,dIWx,dIWy; + double Tij; + unsigned int iteration=0; + int i,j; + double i2,j2; + double alpha=2.; + do + { + Nbpoint=0; + erreur=0; + G=0; + H=0 ; + Warp->computeCoeff(p); + for(unsigned int point=0;point<templateSize;point++) + { + i=ptTemplate[point].y; + j=ptTemplate[point].x; + X1[0]=j;X1[1]=i; + + Warp->computeDenom(X1,p); + Warp->warpX(X1,X2,p); + + j2=X2[0];i2=X2[1]; + if((i2>=0)&&(j2>=0)&&(i2<I.getHeight()-1)&&(j2<I.getWidth()-1)) + { + Tij=ptTemplate[point].val; + + if(!blur) + IW=I.getValue(i2,j2); + else + IW=BI.getValue(i2,j2); + + dIWx=dIx.getValue(i2,j2); + dIWy=dIy.getValue(i2,j2); + Nbpoint++; + //Calcul du Hessien + Warp->dWarp(X1,X2,p,dW); + double *tempt=new double[nbParam]; + for(unsigned int it=0;it<nbParam;it++) + tempt[it]=dW[0][it]*dIWx+dW[1][it]*dIWy; + + for(unsigned int it=0;it<nbParam;it++) + for(unsigned int jt=0;jt<nbParam;jt++) + H[it][jt]+=tempt[it]*tempt[jt]; + + double er=(Tij-IW); + for(unsigned int it=0;it<nbParam;it++) + G[it]+=er*tempt[it]; + + erreur+=(er*er); + delete[] tempt; + } + + + } + if(Nbpoint==0)std::cout<<"plus de point dans template suivi"<<std::endl; + + vpMatrix::computeHLM(H,lambda,HLM); + try + { + dp=1.*HLM.inverseByLU()*G; + } + catch(...) + { + std::cout<<"probleme inversion"<<std::endl; + break; + } + + switch(minimizationMethod) + { + case vpTemplateTrackerSSDForwardAdditional::USE_LMA: + { + vpColVector p_test_LMA(nbParam); + p_test_LMA=p+1.*dp; + erreur=-getCost(I,p); + double erreur_LMA=-getCost(I,p_test_LMA); + if(erreur_LMA<erreur) + { + p=p_test_LMA; + lambda=(lambda/10.<1e-6)?lambda/10.:1e-6; + } + else + { + lambda=(lambda*10.<1e6)?1e6:lambda*10.; + } + } + break; + case vpTemplateTrackerSSDForwardAdditional::USE_GRADIENT: + { + dp=gain*0.000001*G; + if(useBrent) + { + alpha=2.; + computeOptimalBrentGain(I,p,erreur,dp,alpha); + dp=alpha*dp; + } + p+=1.*dp; + break; + } + + case vpTemplateTrackerSSDForwardAdditional::USE_QUASINEWTON: + { + double s_scal_y; + if(iterationGlobale!=0) + { + vpColVector s_quasi=p-p_prec; + vpColVector y_quasi=G-G_prec; + s_scal_y=s_quasi.t()*y_quasi; + //if(s_scal_y!=0)//BFGS + // KQuasiNewton=KQuasiNewton-(s_quasi*y_quasi.t()*KQuasiNewton+KQuasiNewton*y_quasi*s_quasi.t())/s_scal_y+(1.+y_quasi.t()*(KQuasiNewton*y_quasi)/s_scal_y)*s_quasi*s_quasi.t()/s_scal_y; + //if(s_scal_y!=0.0)//DFP + if(std::fabs(s_scal_y) > std::numeric_limits<double>::epsilon()) //DFP + KQuasiNewton=KQuasiNewton+0.001*(s_quasi*s_quasi.t()/s_scal_y-KQuasiNewton*y_quasi*y_quasi.t()*KQuasiNewton/(y_quasi.t()*KQuasiNewton*y_quasi)); + } + dp=-KQuasiNewton*G; + p_prec=p; + G_prec=G; + p-=1.01*dp; + } + break; + + case vpTemplateTrackerSSDForwardAdditional::USE_NEWTON: + default: + { + if(useBrent) + { + alpha=2.; + computeOptimalBrentGain(I,p,erreur,dp,alpha); + dp=alpha*dp; + } + + p+=1.*dp; + break; + } + } + + iteration++; + iterationGlobale++; + } + while( /*( erreur_prec-erreur<50) && */(iteration < iterationMax)); + + //std::cout<<"erreur "<<erreur<<std::endl; + nbIteration=iteration; +} + diff --git a/src/tracking/template-tracker/ssd/vpTemplateTrackerSSDForwardAdditional.h b/src/tracking/template-tracker/ssd/vpTemplateTrackerSSDForwardAdditional.h new file mode 100644 index 0000000000000000000000000000000000000000..4d57db07f1edb662695870af441cd981c81c3c3e --- /dev/null +++ b/src/tracking/template-tracker/ssd/vpTemplateTrackerSSDForwardAdditional.h @@ -0,0 +1,83 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerSSDForwardAdditional.h 4574 2014-01-09 08:48:51Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +/*! + \file vpTemplateTrackerSSDForwardAdditional.h + \brief +*/ + +#ifndef vpTemplateTrackerSSDForwardAdditional_hh +#define vpTemplateTrackerSSDForwardAdditional_hh + +#include <visp/vpTemplateTrackerSSD.h> + +/*! + The algorithm implemented in this class is described in \cite Baker04a. + */ +class VISP_EXPORT vpTemplateTrackerSSDForwardAdditional: public vpTemplateTrackerSSD +{ + public: + /*! Minimization method. */ + typedef enum { + USE_NEWTON, + USE_LMA, + USE_GRADIENT, + USE_QUASINEWTON + } vpMinimizationTypeSSDForwardAdditional; + + private: + vpMinimizationTypeSSDForwardAdditional minimizationMethod; + //valeur pour calculer Quasi_Newton + vpColVector p_prec; + vpColVector G_prec; + vpMatrix KQuasiNewton; + + protected: + void initHessienDesired(const vpImage<unsigned char> &/*I*/){} + void trackNoPyr(const vpImage<unsigned char> &I); + + public: + vpTemplateTrackerSSDForwardAdditional(vpTemplateTrackerWarp *warp); + + void setMinimizationMethod(vpMinimizationTypeSSDForwardAdditional method){minimizationMethod=method;} +}; +#endif + diff --git a/src/tracking/template-tracker/ssd/vpTemplateTrackerSSDForwardCompositional.cpp b/src/tracking/template-tracker/ssd/vpTemplateTrackerSSDForwardCompositional.cpp new file mode 100644 index 0000000000000000000000000000000000000000..53655fe4517f8e81998b2d6f9a4d274cd131c1b2 --- /dev/null +++ b/src/tracking/template-tracker/ssd/vpTemplateTrackerSSDForwardCompositional.cpp @@ -0,0 +1,175 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerSSDForwardCompositional.cpp 4632 2014-02-03 17:06:40Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +#include <visp/vpTemplateTrackerSSDForwardCompositional.h> +#include <visp/vpImageFilter.h> + +vpTemplateTrackerSSDForwardCompositional::vpTemplateTrackerSSDForwardCompositional(vpTemplateTrackerWarp *warp) + : vpTemplateTrackerSSD(warp), compoInitialised(false) +{ +} + +void vpTemplateTrackerSSDForwardCompositional::initCompo(const vpImage<unsigned char> &/*I*/) +{ + // std::cout<<"Initialise precomputed value of Compositionnal Direct"<<std::endl; + int i,j; + for(unsigned int point=0;point<templateSize;point++) + { + i=ptTemplate[point].y; + j=ptTemplate[point].x; + ptTemplate[point].dW=new double[2*nbParam]; + X1[0]=j;X1[1]=i; + Warp->computeDenom(X1,p); + Warp->getdWdp0(i,j,ptTemplate[point].dW); + + } + compoInitialised=true; +} + +void vpTemplateTrackerSSDForwardCompositional::initHessienDesired(const vpImage<unsigned char> &I) +{ + initCompo(I); +} + +void vpTemplateTrackerSSDForwardCompositional::trackNoPyr(const vpImage<unsigned char> &I) +{ + if(!compoInitialised) + std::cout<<"Compositionnal tracking no initialised\nUse InitCompo(vpImage<unsigned char> &I) function"<<std::endl; + double erreur=0; + int Nbpoint=0; + + if(blur) + vpImageFilter::filter(I, BI,fgG,taillef); + vpImageFilter::getGradXGauss2D(I, dIx, fgG,fgdG,taillef); + vpImageFilter::getGradYGauss2D(I, dIy, fgG,fgdG,taillef); + + dW=0; + + double lambda=lambdaDep; + double IW,dIWx,dIWy; + double Tij; + unsigned int iteration=0; + int i,j; + double i2,j2; + double alpha=2.; + do + { + Nbpoint=0; + erreur=0; + G=0; + H=0 ; + Warp->computeCoeff(p); + for(unsigned int point=0;point<templateSize;point++) + { + i=ptTemplate[point].y; + j=ptTemplate[point].x; + X1[0]=j;X1[1]=i; + + Warp->computeDenom(X1,p); + Warp->warpX(X1,X2,p); + + j2=X2[0];i2=X2[1]; + if((i2>=0)&&(j2>=0)&&(i2<I.getHeight()-1)&&(j2<I.getWidth()-1)) + { + Tij=ptTemplate[point].val; + if(!blur) + IW=I.getValue(i2,j2); + else + IW=BI.getValue(i2,j2); + dIWx=dIx.getValue(i2,j2); + dIWy=dIy.getValue(i2,j2); + Nbpoint++; + //Calcul du Hessien + /*Warp->dWarp(X1,X2,p,dW); + double *tempt=new double[nbParam]; + for(int it=0;it<nbParam;it++) + tempt[it]=dW[0][it]*dIWx+dW[1][it]*dIWy;*/ + + Warp->dWarpCompo(X1,X2,p,ptTemplate[point].dW,dW); + + double *tempt=new double[nbParam]; + for(unsigned int it=0;it<nbParam;it++) + tempt[it] =dW[0][it]*dIWx+dW[1][it]*dIWy; + + for(unsigned int it=0;it<nbParam;it++) + for(unsigned int jt=0;jt<nbParam;jt++) + H[it][jt]+=tempt[it]*tempt[jt]; + + double er=(Tij-IW); + for(unsigned int it=0;it<nbParam;it++) + G[it]+=er*tempt[it]; + + erreur+=(er*er); + delete[] tempt; + } + + + } + if(Nbpoint==0)std::cout<<"plus de point dans template suivi"<<std::endl; + + vpMatrix::computeHLM(H,lambda,HLM); + + try + { + dp=1.*HLM.inverseByLU()*G; + } + catch(...) + { + std::cout<<"probleme inversion"<<std::endl; + break; + } + + dp=gain*dp; + if(useBrent) + { + alpha=2.; + computeOptimalBrentGain(I,p,erreur/Nbpoint,dp,alpha); + dp=alpha*dp; + } + Warp->pRondp(p,dp,p); + //p+=Gain*dp; + iteration++; + } + while( /*( erreur_prec-erreur<50) &&*/ (iteration < iterationMax)); + + nbIteration=iteration; +} + diff --git a/src/tracking/template-tracker/ssd/vpTemplateTrackerSSDForwardCompositional.h b/src/tracking/template-tracker/ssd/vpTemplateTrackerSSDForwardCompositional.h new file mode 100644 index 0000000000000000000000000000000000000000..76134fe7ce8f1849abdef8d101915af7903cb66a --- /dev/null +++ b/src/tracking/template-tracker/ssd/vpTemplateTrackerSSDForwardCompositional.h @@ -0,0 +1,68 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerSSDForwardCompositional.h 4574 2014-01-09 08:48:51Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +/*! + \file vpTemplateTrackerSSDForwardCompositional.h + \brief +*/ + +#ifndef vpTemplateTrackerSSDForwardCompositional_hh +#define vpTemplateTrackerSSDForwardCompositional_hh + +#include <visp/vpTemplateTrackerSSD.h> + +/*! + The algorithm implemented in this class is described in \cite Baker04a. + */ +class VISP_EXPORT vpTemplateTrackerSSDForwardCompositional: public vpTemplateTrackerSSD +{ + protected: + bool compoInitialised; + + protected: + void initHessienDesired(const vpImage<unsigned char> &I); + void initCompo(const vpImage<unsigned char> &I); + void trackNoPyr(const vpImage<unsigned char> &I); + + public: + vpTemplateTrackerSSDForwardCompositional(vpTemplateTrackerWarp *warp); +}; +#endif diff --git a/src/tracking/template-tracker/ssd/vpTemplateTrackerSSDInverseCompositional.cpp b/src/tracking/template-tracker/ssd/vpTemplateTrackerSSDInverseCompositional.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4b1aa28a0a4d2dab778bdd9ee7bb8d58eeeaeb01 --- /dev/null +++ b/src/tracking/template-tracker/ssd/vpTemplateTrackerSSDInverseCompositional.cpp @@ -0,0 +1,235 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerSSDInverseCompositional.cpp 4672 2014-02-17 09:01:17Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +#include <visp/vpTemplateTrackerSSDInverseCompositional.h> +#include <visp/vpImageTools.h> + +vpTemplateTrackerSSDInverseCompositional::vpTemplateTrackerSSDInverseCompositional(vpTemplateTrackerWarp *warp) + : vpTemplateTrackerSSD(warp), compoInitialised(false), HInv(), HCompInverse(), useTemplateSelect(false), + evolRMS(0), x_pos(), y_pos(), threshold_RMS(1e-8) +{ + useInverse=true; + HInv.resize(nbParam,nbParam); + HCompInverse.resize(nbParam,nbParam); +} + +void vpTemplateTrackerSSDInverseCompositional::initCompInverse(const vpImage<unsigned char> &/*I*/) +{ + + H=0; + int i,j; + + for(unsigned int point=0;point<templateSize;point++) + { + if((!useTemplateSelect)||(ptTemplateSelect[point])) + { + i=ptTemplate[point].y; + j=ptTemplate[point].x; + X1[0]=j;X1[1]=i; + Warp->computeDenom(X1,p); + ptTemplate[point].dW=new double[nbParam]; + + Warp->getdW0(i,j,ptTemplate[point].dy,ptTemplate[point].dx,ptTemplate[point].dW); + + for(unsigned int it=0;it<nbParam;it++) + for(unsigned int jt=0;jt<nbParam;jt++) + H[it][jt]+=ptTemplate[point].dW[it]*ptTemplate[point].dW[jt]; + } + + } + HInv=H; + vpMatrix HLMtemp(nbParam,nbParam); + vpMatrix::computeHLM(H,lambdaDep,HLMtemp); + + HCompInverse.resize(nbParam,nbParam); + HCompInverse=HLMtemp.inverseByLU(); + //std::cout<<Hinverse<<std::endl; + vpColVector dWtemp(nbParam); + vpColVector HiGtemp(nbParam); + + for(unsigned int point=0;point<templateSize;point++) + { + if((!useTemplateSelect)||(ptTemplateSelect[point])) + { + i=ptTemplate[point].y; + j=ptTemplate[point].x; + for(unsigned int it=0;it<nbParam;it++) + dWtemp[it]=ptTemplate[point].dW[it]; + + HiGtemp = -1.*HCompInverse*dWtemp; + ptTemplate[point].HiG=new double[nbParam]; + + for(unsigned int it=0;it<nbParam;it++) + ptTemplate[point].HiG[it]=HiGtemp[it]; + } + } + compoInitialised=true; +} + +void vpTemplateTrackerSSDInverseCompositional::initHessienDesired(const vpImage<unsigned char> &I) +{ + initCompInverse(I); +} + +void vpTemplateTrackerSSDInverseCompositional::trackNoPyr(const vpImage<unsigned char> &I) +{ + double erreur=0; + int Nbpoint=0; + if(blur) + vpImageFilter::filter(I, BI,fgG,taillef); + + vpColVector dpinv(nbParam); + double IW; + double Tij; + unsigned int iteration=0; + int i,j; + double i2,j2; + double alpha=2.; + //vpTemplateTrackerPointtest *pt; + initPosEvalRMS(p); + + vpTemplateTrackerPoint *pt; + do + { + Nbpoint=0; + erreur=0; + dp=0; + Warp->computeCoeff(p); + for(unsigned int point=0;point<templateSize;point++) + { + if((!useTemplateSelect)||(ptTemplateSelect[point])) + { + //pt=&ptTemplatetest[point]; + pt=&ptTemplate[point]; + i=pt->y; + j=pt->x; + X1[0]=j;X1[1]=i; + Warp->computeDenom(X1,p); + Warp->warpX(X1,X2,p); + j2=X2[0];i2=X2[1]; + + if((i2>=0)&&(j2>=0)&&(i2<I.getHeight()-1)&&(j2<I.getWidth()-1)) + { + Tij=pt->val; + if(!blur) + IW=I.getValue(i2,j2); + else + IW=BI.getValue(i2,j2); + Nbpoint++; + double er=(Tij-IW); + for(unsigned int it=0;it<nbParam;it++) + dp[it]+=er*pt->HiG[it]; + + erreur+=er*er; + } + } + } + if(Nbpoint==0)std::cout<<"plus de point dans template suivi"<<std::endl; + dp=gain*dp; + //std::cout<<erreur/Nbpoint<<","<<GetCost(I,p)<<std::endl; + if(useBrent) + { + alpha=2.; + computeOptimalBrentGain(I,p,erreur/Nbpoint,dp,alpha); + dp=alpha*dp; + } + Warp->getParamInverse(dp,dpinv); + Warp->pRondp(p,dpinv,p); + iteration++; + + computeEvalRMS(p); + } + while(/*( erreur_prec-erreur<50) &&*/ (iteration < iterationMax)&&(evolRMS>threshold_RMS)); + + nbIteration=iteration; + deletePosEvalRMS(); +} + +void vpTemplateTrackerSSDInverseCompositional::initPosEvalRMS(vpColVector &p_) +{ + unsigned int nb_corners = zoneTracked->getNbTriangle() * 3; + x_pos.resize(nb_corners); + y_pos.resize(nb_corners); + + Warp->computeCoeff(p_); + vpTemplateTrackerTriangle triangle; + + for(unsigned int i=0;i<zoneTracked->getNbTriangle();i++) + { + zoneTracked->getTriangle(i, triangle); + for (unsigned int j=0; j<3; j++) { + triangle.getCorner(j, X1[0], X1[1]); + + Warp->computeDenom(X1,p_); + Warp->warpX(X1,X2,p_); + x_pos[i*3+j]=X2[0]; + y_pos[i*3+j]=X2[1]; + } + } +} + +void vpTemplateTrackerSSDInverseCompositional::computeEvalRMS(const vpColVector &p_) +{ + unsigned int nb_corners = zoneTracked->getNbTriangle() * 3; + + Warp->computeCoeff(p_); + evolRMS=0; + vpTemplateTrackerTriangle triangle; + + for(unsigned int i=0;i<zoneTracked->getNbTriangle();i++) + { + zoneTracked->getTriangle(i, triangle); + for (unsigned int j=0; j<3; j++) { + triangle.getCorner(j, X1[0], X1[1]); + + Warp->computeDenom(X1,p_); + Warp->warpX(X1,X2,p_); + evolRMS+=(x_pos[i*3+j]-X2[0])*(x_pos[i*3+j]-X2[0])+(y_pos[i*3+j]-X2[1])*(y_pos[i*3+j]-X2[1]); + x_pos[i*3+j]=X2[0]; + y_pos[i*3+j]=X2[1]; + } + } + evolRMS=evolRMS/nb_corners; +} + +void vpTemplateTrackerSSDInverseCompositional::deletePosEvalRMS() +{ +} diff --git a/src/tracking/template-tracker/ssd/vpTemplateTrackerSSDInverseCompositional.h b/src/tracking/template-tracker/ssd/vpTemplateTrackerSSDInverseCompositional.h new file mode 100644 index 0000000000000000000000000000000000000000..c2c39e187a3c3bc12fdf10bac657a23d08b60d4c --- /dev/null +++ b/src/tracking/template-tracker/ssd/vpTemplateTrackerSSDInverseCompositional.h @@ -0,0 +1,85 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerSSDInverseCompositional.h 4672 2014-02-17 09:01:17Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +/*! + \file vpTemplateTrackerSSDInverseCompositional.h + \brief +*/ +#ifndef vpTemplateTrackerSSDInverseCompositional_hh +#define vpTemplateTrackerSSDInverseCompositional_hh + +#include <vector> + +#include <visp/vpTemplateTrackerSSD.h> + +/*! + The algorithm implemented in this class is described in \cite Baker04a. + */ +class VISP_EXPORT vpTemplateTrackerSSDInverseCompositional: public vpTemplateTrackerSSD +{ + protected: + bool compoInitialised; + vpMatrix HInv; + vpMatrix HCompInverse; + bool useTemplateSelect;//use only the strong gradient pixels to compute the Jabocian + //pour eval evolRMS + double evolRMS; + std::vector<double> x_pos; + std::vector<double> y_pos; + double threshold_RMS; + + protected: + void initHessienDesired(const vpImage<unsigned char> &I); + void initCompInverse(const vpImage<unsigned char> &I); + void trackNoPyr(const vpImage<unsigned char> &I); + void deletePosEvalRMS(); + void computeEvalRMS(const vpColVector &p); + void initPosEvalRMS(vpColVector &p); + + public: + vpTemplateTrackerSSDInverseCompositional(vpTemplateTrackerWarp *warp); + + /*! Use only the strong gradient pixels to compute the Jabobian. By default this feature is disabled. */ + void setUseTemplateSelect(bool b) {useTemplateSelect = b;} + void setThresholdRMS(double threshold){threshold_RMS=threshold;} +}; +#endif + diff --git a/src/tracking/template-tracker/tools/vpTemplateTrackerBSpline.cpp b/src/tracking/template-tracker/tools/vpTemplateTrackerBSpline.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7e3c33643f29955b034cde4642632a2fcf5fe630 --- /dev/null +++ b/src/tracking/template-tracker/tools/vpTemplateTrackerBSpline.cpp @@ -0,0 +1,82 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerBSpline.cpp 4574 2014-01-09 08:48:51Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +#include <visp/vpTemplateTrackerBSpline.h> + +#ifndef DOXYGEN_SHOULD_SKIP_THIS + +double vpTemplateTrackerBSpline::getSubPixBspline4(const vpImage<double> &I, double r, double t) +{ + double res=0; + int cr=(int)(r); + int ct=(int)(t); + double er=(double)r-cr; + double et=(double)t-ct; + int height=(int)I.getHeight();//r + int width=(int)I.getWidth();//t + int tr,tt; + for(int ir=-1;ir<=2;ir++) + { + tr=ir+cr; + for(int it=-1;it<=2;it++) + { + tt=it+ct; + if(tr>=0 && tr <height && tt>=0 && tt <width) + res+=Bspline4((double)ir-er)*Bspline4((double)it-et)*I[tr][tt]; + } + } + return res; +} + +double vpTemplateTrackerBSpline::Bspline4(double diff) +{ + //double result; + double aDiff=vpMath::abs(diff); + if(aDiff<1.) + return (aDiff*aDiff*aDiff/2.-aDiff*aDiff+4./6.); + //return (0.5*(1.-aDiff)*(1.-aDiff)*(1.-aDiff)+0.5*(1.-aDiff)*(1.-aDiff)-0.5*(1.-aDiff)+1./6.); + else if(aDiff<2.) + return ((2.-aDiff)*(2.-aDiff)*(2.-aDiff)/6.); + else + return 0; +} + +#endif diff --git a/example/manual/image-manipulation/manGrab1394-1.cpp b/src/tracking/template-tracker/tools/vpTemplateTrackerBSpline.h similarity index 51% rename from example/manual/image-manipulation/manGrab1394-1.cpp rename to src/tracking/template-tracker/tools/vpTemplateTrackerBSpline.h index ae0f2615e02a843bdeb140ad521b79c6ff5b4474..7a372d30bab574dcc2e51718f6a35116855538fa 100644 --- a/example/manual/image-manipulation/manGrab1394-1.cpp +++ b/src/tracking/template-tracker/tools/vpTemplateTrackerBSpline.h @@ -1,10 +1,10 @@ /**************************************************************************** * - * $Id: manGrab1394-1.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpTemplateTrackerBSpline.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. - * + * Copyright (C) 2005 - 2014 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. @@ -12,11 +12,11 @@ * 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 + * 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 @@ -26,67 +26,39 @@ * * 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: - * Images grabbing example. + * Template tracker. * * Authors: - * Anthony Saunier + * Amaury Dame + * Aurelien Yol * Fabien Spindler * *****************************************************************************/ /*! - \file manGrab1394-1.cpp - - \brief Images grabbing example with the vp1394Grabber class. - - */ -/*! - \example manGrab1394-1.cpp + \file vpTemplateTrackerBSpline.h + \brief +*/ - \brief Images grabbing example with the vp1394Grabber class. - - */ +#ifndef vpTemplateTrackerBSpline_hh +#define vpTemplateTrackerBSpline_hh #include <visp/vpConfig.h> - -#include <stdlib.h> -#include <stdio.h> #include <visp/vpImage.h> -#include <visp/vp1394Grabber.h> +#include <visp/vpMath.h> + +#ifndef DOXYGEN_SHOULD_SKIP_THIS -int main() +class VISP_EXPORT vpTemplateTrackerBSpline { -#ifdef VISP_HAVE_DC1394_1 - unsigned int ncameras; // Number of cameras on the bus - vp1394Grabber g; - g.getNumCameras(ncameras); - vpImage<unsigned char> *I = new vpImage<unsigned char> [ncameras]; - - // If the first camera supports MODE_640x480_YUV422 video mode - g.setCamera(0); - g.setFormat(FORMAT_VGA_NONCOMPRESSED); - g.setMode(MODE_640x480_YUV422); - - // If all cameras support 30 fps acquisition - for (unsigned int camera=0; camera < ncameras; camera ++) { - g.setCamera(camera); - g.setFramerate(FRAMERATE_30); - } - - for ( ; ; ) { - for (unsigned int camera=0; camera < ncameras; camera ++) { - // Acquire successively images from the different cameras - g.setCamera(camera); - g.acquire(I[camera]); - } - } - delete [] I; -#endif +public: + static double Bspline4(double diff); - return 0; -} + static double getSubPixBspline4(const vpImage<double> &I, double r, double t); +}; +#endif +#endif diff --git a/src/tracking/template-tracker/tools/vpTemplateTrackerHeader.h b/src/tracking/template-tracker/tools/vpTemplateTrackerHeader.h new file mode 100644 index 0000000000000000000000000000000000000000..339ff9260548399c038d294952aa1bf49120ddf2 --- /dev/null +++ b/src/tracking/template-tracker/tools/vpTemplateTrackerHeader.h @@ -0,0 +1,91 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerHeader.h 4632 2014-02-03 17:06:40Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +/*! + \file vpTemplateTrackerHeader.h + \brief +*/ + +#ifndef vpTemplateTrackerHeader_hh +#define vpTemplateTrackerHeader_hh + +#include <stdio.h> + +struct vpTemplateTrackerZPoint { + int x,y; + + vpTemplateTrackerZPoint() : x(0), y(0) {} +}; +struct vpTemplateTrackerDPoint { + double x,y; + + vpTemplateTrackerDPoint() : x(0), y(0) {} +}; +struct vpTemplateTrackerPoint { + int x,y; + double dx,dy; + double val; + double *dW; + double *HiG; + + vpTemplateTrackerPoint() : x(0), y(0), dx(0), dy(0), val(0), dW(NULL), HiG(NULL) {} +}; +struct vpTemplateTrackerPointCompo { + double *dW; + vpTemplateTrackerPointCompo() : dW(NULL) {} +}; + +#ifndef DOXYGEN_SHOULD_SKIP_THIS +struct vpTemplateTrackerPointSuppMIInv { + double et; + int ct; + double *BtInit; + double *Bt; + double *dBt; + double *d2W; + double *d2Wx; + double *d2Wy; + vpTemplateTrackerPointSuppMIInv() : et(0), ct(0), BtInit(NULL), Bt(NULL), dBt(NULL), + d2W(NULL), d2Wx(NULL), d2Wy(NULL) {} +}; +#endif // DOXYGEN_SHOULD_SKIP_THIS + +#endif diff --git a/src/tracking/template-tracker/tools/vpTemplateTrackerTriangle.cpp b/src/tracking/template-tracker/tools/vpTemplateTrackerTriangle.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5292864b46a0205d73ded7f75eff8e3df8004a4c --- /dev/null +++ b/src/tracking/template-tracker/tools/vpTemplateTrackerTriangle.cpp @@ -0,0 +1,436 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerTriangle.cpp 4636 2014-02-04 08:17:58Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +#include <visp/vpTemplateTrackerTriangle.h> + +/*! + Default constructor. + */ +vpTemplateTrackerTriangle::vpTemplateTrackerTriangle() + : minx_temp(0), miny_temp(0), C1(), C2(), C3(), l_t(0), h_t(0), not_good(false), + uvinv00(0.), uvinv01(0.), uvinv10(0.), uvinv11(0.), marge_triangle(0.00001) +{ +} + +/*! + Copy constructor. + */ +vpTemplateTrackerTriangle::vpTemplateTrackerTriangle(const vpTemplateTrackerTriangle& T) + : minx_temp(0), miny_temp(0), C1(), C2(), C3(), l_t(0), h_t(0), not_good(false), + uvinv00(0.), uvinv01(0.), uvinv10(0.), uvinv11(0.), marge_triangle(0.00001) +{ + *this = T; +} + +/*! + Copy operator. + */ +vpTemplateTrackerTriangle & vpTemplateTrackerTriangle::operator=(const vpTemplateTrackerTriangle& T) +{ + minx_temp=T.minx_temp; + miny_temp=T.miny_temp; + + l_t=T.l_t; + h_t=T.h_t; + C1.x=T.C1.x; + C1.y=T.C1.y; + C2.x=T.C2.x; + C2.y=T.C2.y; + C3.x=T.C3.x; + C3.y=T.C3.y; + //uvinv.resize(2,2); + //uvinv=T.uvinv; + //p_ds_uv.resize(2); + //p_ds_uv=T.p_ds_uv; + //ptempo.resize(2); + //ptempo=T.ptempo; + not_good=T.not_good; + + uvinv00=T.uvinv00; + uvinv01=T.uvinv01; + uvinv10=T.uvinv10; + uvinv11=T.uvinv11; + + marge_triangle = T.marge_triangle; + + return (*this); +} + +/*! + Create a triangle from 3 corners. + \param c1 : First corner. + \param c2 : Second corner. + \param c3 : Third corner. + + The coordinates of the points are defined as a 2 dimension vector with coordinates (x,y). + */ +vpTemplateTrackerTriangle::vpTemplateTrackerTriangle(const vpColVector &c1, + const vpColVector &c2, + const vpColVector &c3) + : minx_temp(0), miny_temp(0), C1(), C2(), C3(), l_t(0), h_t(0), not_good(false), + uvinv00(0.), uvinv01(0.), uvinv10(0.), uvinv11(0.), marge_triangle(0.00001) +{ + init(c1[0],c1[1],c2[0],c2[1],c3[0],c3[1]); +} +/*! + Return a triangle with coordinates that are down scaled by a factor 2. + */ +vpTemplateTrackerTriangle vpTemplateTrackerTriangle::getPyramidDown() const +{ + vpTemplateTrackerTriangle Ttemp; + Ttemp.init(C1.x/2.,C1.y/2.,C2.x/2.,C2.y/2.,C3.x/2.,C3.y/2.); + return Ttemp; +} + +/*! + Create a triangle from 3 corners with coordinates (x1,y1), (x2,y2), (x3,y3). + - x coordinate is along the columns + - y coordinate is along the rows. + */ +vpTemplateTrackerTriangle::vpTemplateTrackerTriangle(int x1,int y1, int x2,int y2, int x3,int y3) + : minx_temp(0), miny_temp(0), C1(), C2(), C3(), l_t(0), h_t(0), not_good(false), + uvinv00(0.), uvinv01(0.), uvinv10(0.), uvinv11(0.), marge_triangle(0.00001) +{ + init(x1,y1,x2,y2,x3,y3); +} + +/*! + Create a triangle from 3 corners defined as image points. + \param c1 : First corner. + \param c2 : Second corner. + \param c3 : Third corner. + */ +vpTemplateTrackerTriangle::vpTemplateTrackerTriangle(const vpImagePoint &c1, const vpImagePoint &c2, const vpImagePoint &c3) + : minx_temp(0), miny_temp(0), C1(), C2(), C3(), l_t(0), h_t(0), not_good(false), + uvinv00(0.), uvinv01(0.), uvinv10(0.), uvinv11(0.), marge_triangle(0.00001) +{ + init(c1.get_u(), c1.get_v(), c2.get_u(), c2.get_v(), c3.get_u(), c3.get_v()); +} + +/*! + Create a triangle from 3 corners with coordinates (x1,y1), (x2,y2), (x3,y3). + - x coordinate is along the columns + - y coordinate is along the rows. + */ +vpTemplateTrackerTriangle::vpTemplateTrackerTriangle(double x1,double y1, double x2,double y2, double x3,double y3) + : minx_temp(0), miny_temp(0), C1(), C2(), C3(), l_t(0), h_t(0), not_good(false), + uvinv00(0.), uvinv01(0.), uvinv10(0.), uvinv11(0.), marge_triangle(0.00001) +{ + init(x1,y1,x2,y2,x3,y3); +} +/*! + Initializes a triangle from 3 corners. + \param c1 : First corner. + \param c2 : Second corner. + \param c3 : Third corner. + + The coordinates of the points are defined as a 2 dimension vector with coordinates (x,y). + */ +void vpTemplateTrackerTriangle::init(const vpColVector &c1,const vpColVector &c2,const vpColVector &c3) +{ + init(c1[0],c1[1],c2[0],c2[1],c3[0],c3[1]); +} +/*! + Initializes a triangle from 3 corners defined as image points. + \param c1 : First corner. + \param c2 : Second corner. + \param c3 : Third corner. + */ +void vpTemplateTrackerTriangle::init(const vpImagePoint &c1, const vpImagePoint &c2, const vpImagePoint &c3) +{ + init(c1.get_u(), c1.get_v(), c2.get_u(), c2.get_v(), c3.get_u(), c3.get_v()); +} + +/*! + Initializes a triangle from 3 corners with coordinates (x1,y1), (x2,y2), (x3,y3). + - x coordinate is along the columns + - y coordinate is along the rows. + */ +void vpTemplateTrackerTriangle::init(int x1, int y1, int x2,int y2, int x3, int y3) +{ + init((double)x1,(double)y1,(double)x2,(double)y2,(double)x3,(double)y3); +} + +/*! + Initializes a triangle from 3 corners with coordinates (x1,y1), (x2,y2), (x3,y3). + - x coordinate is along the columns + - y coordinate is along the rows. + */ +void vpTemplateTrackerTriangle::init(double x1, double y1, double x2,double y2, double x3, double y3) +{ + C1.x=x1;C1.y=y1; + C2.x=x2;C2.y=y2; + C3.x=x3;C3.y=y3; + + double minx,miny,maxx,maxy; + //calcul du rectangle minimal contenant le triangle seletionn� + minx=(x1<x2)?x1:x2; + miny=(y1<y2)?y1:y2; + minx=(minx<x3)?minx:x3; + miny=(miny<y3)?miny:y3; + maxx=(x1>x2)?x1:x2; + maxy=(y1>y2)?y1:y2; + maxx=(maxx>x3)?maxx:x3; + maxy=(maxy>y3)?maxy:y3; + + vpColVector u; + vpColVector v; + u.resize(2); + v.resize(2); + vpMatrix uv(2,2); + vpMatrix uvinv(2,2); + + u[0]=C2.x-C1.x; + u[1]=C2.y-C1.y; + + v[0]=C3.x-C1.x; + v[1]=C3.y-C1.y; + + uv[0][0]=u[0];uv[1][0]=v[0]; + uv[0][1]=u[1];uv[1][1]=v[1]; + try + { + uvinv=uv.inverseByLU(); + not_good=false; + } + catch(...) + { + not_good=true; + std::cout<<"Triangle vide"<<std::endl; + + } + uvinv00=uvinv[0][0]; + uvinv01=uvinv[0][1]; + uvinv10=uvinv[1][0]; + uvinv11=uvinv[1][1]; + + l_t=maxx-minx; + h_t=maxy-miny; + minx_temp=minx; + miny_temp=miny; + + marge_triangle = 0.00001; +} + +//marge ajoutee a zone pour que sommet soit pris en compte + +/*! + Indicates if a point with coordinates (i,j) is in the triangle. + \param i : Coordinate along the rows. + \param j : Coordinate along the columns. + */ +bool vpTemplateTrackerTriangle::inTriangle(const int &i, const int &j) const +{ + if(not_good) + return false; + + /*ptempo[0]=j-C1.x; + ptempo[1]=i-C1.y; + + p_ds_uv=ptempo*uvinv; + return (p_ds_uv[0]+p_ds_uv[1]<1. && p_ds_uv[0]>0 && p_ds_uv[1]>0);*/ + + double ptempo0=j-C1.x; + double ptempo1=i-C1.y; + double p_ds_uv0=ptempo0*uvinv00+ptempo1*uvinv10; + double p_ds_uv1=ptempo0*uvinv01+ptempo1*uvinv11; + return (p_ds_uv0+p_ds_uv1<1.+marge_triangle && p_ds_uv0>-marge_triangle && p_ds_uv1>-marge_triangle); +} + +/*! + Indicates if a point with coordinates (i,j) is in the triangle. + \param i : Coordinate along the rows. + \param j : Coordinate along the columns. + */ +bool vpTemplateTrackerTriangle::inTriangle(const double &i, const double &j) const +{ + if(not_good) + return false; + /*ptempo[0]=j-C1.x; + ptempo[1]=i-C1.y; + + p_ds_uv=ptempo*uvinv; + return (p_ds_uv[0]+p_ds_uv[1]<1. && p_ds_uv[0]>0 && p_ds_uv[1]>0);*/ + double ptempo0=j-C1.x; + double ptempo1=i-C1.y; + double p_ds_uv0=ptempo0*uvinv00+ptempo1*uvinv10; + double p_ds_uv1=ptempo0*uvinv01+ptempo1*uvinv11; + return (p_ds_uv0+p_ds_uv1<1.+marge_triangle && p_ds_uv0>-marge_triangle && p_ds_uv1>-marge_triangle); +} + +/*! + Indicates if an image point is in the triangle. + \param ip : Image point to consider. + */ +bool vpTemplateTrackerTriangle::inTriangle(const vpImagePoint &ip) const +{ + return inTriangle(ip.get_i(), ip.get_j()); +} +/*! + Returns the coordinates of the triangle corners as an image point. + \param c1 : First corner. + \param c2 : Second corner. + \param c3 : Third corner. + */ +void vpTemplateTrackerTriangle::getCorners(vpImagePoint &c1, vpImagePoint &c2, vpImagePoint &c3) const +{ + c1.set_uv(C1.x, C1.y); + c2.set_uv(C2.x, C2.y); + c3.set_uv(C3.x, C3.y); +} + +/*! + Returns the coordinates of the triangle corners as a 3 dimension vector of image points. + \param c : 3 dimension vector of image points that correspond to the triangle corners. + */ +void vpTemplateTrackerTriangle::getCorners(std::vector<vpImagePoint> &c) const +{ + c.resize(3); + c[0].set_uv(C1.x, C1.y); + c[1].set_uv(C2.x, C2.y); + c[2].set_uv(C3.x, C3.y); +} + +/*! + Returns the coordinates of the triangle corners as a 2 dimension vector (x,y). + \param c1 : First corner. + \param c2 : Second corner. + \param c3 : Third corner. + */ +void vpTemplateTrackerTriangle::getCorners(vpColVector &c1,vpColVector &c2,vpColVector &c3) const +{ + c1=getCorner1(); + c2=getCorner2(); + c3=getCorner3(); +} + +/*! + Returns the coordinates of the triangle first corner. + \return A vector with dimension 2, that contains the coordinates (x,y) of the corner. + */ +vpColVector vpTemplateTrackerTriangle::getCorner1() const +{ + vpColVector c(2); + c[0]=C1.x; + c[1]=C1.y; + + return c; +} +/*! + Returns the coordinates of the triangle second corner. + \return A vector with dimension 2, that contains the coordinates (x,y) of the corner. + */ +vpColVector vpTemplateTrackerTriangle::getCorner2() const +{ + vpColVector c(2); + c[0]=C2.x; + c[1]=C2.y; + return c; +} + +/*! + Returns the coordinates of the triangle third corner. + \return A vector with dimension 2, that contains the coordinates (x,y) of the corner. + */ +vpColVector vpTemplateTrackerTriangle::getCorner3() const +{ + vpColVector c(2); + c[0]=C3.x; + c[1]=C3.y; + return c; +} + +/*! + Get the size of the triangle bounding box. + \param w : Bounding box width. + \param h : Bounding box height. + */ +void vpTemplateTrackerTriangle::getSize(double &w,double &h) const +{ + w=l_t; + h=h_t; +} +/*! + Get the size of the triangle bounding box. + \param w : Bounding box width. + \param h : Bounding box height. + */ +void vpTemplateTrackerTriangle::getSize(int &w,int &h) const +{ + w=(int)l_t+1; + h=(int)h_t+1; +} + +/*! + \return The minimal x coordinate (along the columns of the image) of the points that are in the triangle. + \sa getMaxx() + */ +double vpTemplateTrackerTriangle::getMinx() const +{ + return minx_temp-1; +} +/*! + \return The minimal y coordinate (along the rows of the image) of the points that are in the triangle. + \sa getMaxy() + */ +double vpTemplateTrackerTriangle::getMiny() const +{ + return miny_temp-1; +} +/*! + \return The maximal x coordinate (along the columns of the image) of the points that are in the triangle. + \sa getMinx() + */ +double vpTemplateTrackerTriangle::getMaxx() const +{ + return minx_temp+l_t+1; +} +/*! + \return The maximal y coordinate (along the rows of the image) of the points that are in the triangle. + \sa getMaxx() + */ +double vpTemplateTrackerTriangle::getMaxy() const +{ + return miny_temp+h_t+1; +} + + + diff --git a/src/tracking/template-tracker/tools/vpTemplateTrackerTriangle.h b/src/tracking/template-tracker/tools/vpTemplateTrackerTriangle.h new file mode 100644 index 0000000000000000000000000000000000000000..62460b5e820b0d5f10b59a1c80d9e9500477e5b3 --- /dev/null +++ b/src/tracking/template-tracker/tools/vpTemplateTrackerTriangle.h @@ -0,0 +1,155 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerTriangle.h 4636 2014-02-04 08:17:58Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +/*! + \file vpTemplateTrackerTriangle.h + \brief +*/ + +#ifndef vpTemplateTrackerTriangle_hh +#define vpTemplateTrackerTriangle_hh + +#include <assert.h> +#include <vector> + +#include <visp/vpMatrix.h> +#include <visp/vpMath.h> +#include <visp/vpColVector.h> +#include <visp/vpImagePoint.h> +#include <visp/vpTemplateTrackerHeader.h> + +class VISP_EXPORT vpTemplateTrackerTriangle +{ + protected: + double minx_temp; + double miny_temp; + vpTemplateTrackerDPoint C1; //! Corner 1 + vpTemplateTrackerDPoint C2; //! Corner 2 + vpTemplateTrackerDPoint C3; //! Corner 3 + + double l_t; + double h_t; + + bool not_good; + double uvinv00; + double uvinv01; + double uvinv10; + double uvinv11; + double marge_triangle; + + private: + vpColVector getCorner1() const; + vpColVector getCorner2() const; + vpColVector getCorner3() const; + + public: + vpTemplateTrackerTriangle(); + vpTemplateTrackerTriangle(const vpTemplateTrackerTriangle& T); + vpTemplateTrackerTriangle(const vpColVector &c1, const vpColVector &c2, const vpColVector &c3); + vpTemplateTrackerTriangle(const vpImagePoint &c1, const vpImagePoint &c2, const vpImagePoint &c3); + vpTemplateTrackerTriangle(int x1, int y1, int x2, int y2, int x3, int y3); + vpTemplateTrackerTriangle(double x1, double y1, double x2, double y2, double x3, double y3); + + vpTemplateTrackerTriangle getPyramidDown() const; + void getCorners(vpColVector &c1,vpColVector &c2,vpColVector &c3) const; + void getCorners(vpImagePoint &c1, vpImagePoint &c2, vpImagePoint &c3) const; + void getCorners(std::vector<vpImagePoint> &c) const; + + /*! + Returns the coordinates of a triangle corner. + \param i : Allowed values are 0, 1 or 2. + \return + - if i = 0, return corner 1 coordinates, + - if i = 1, return corner 2 coordinates, + - if i = 2, return corner 3 coordinates. + + The coordinates are returned as a 2 dimension vector (x,y). + */ + vpColVector getCorner(unsigned int i) const { + assert(i<3); + if(i==0) return getCorner1(); + else if(i==1) return getCorner2(); + else /*if(i==2)*/ return getCorner3(); + }; + /*! + Returns the coordinates of a triangle corner. + \param i : Allowed values are 0, 1 or 2. + - if i = 0, return corner 1 coordinates, + - if i = 1, return corner 2 coordinates, + - if i = 2, return corner 3 coordinates. + \param x,y : The coordinates of the corner. + */ + void getCorner(unsigned int i, double &x, double &y) const { + assert(i<3); + if(i==0) { + x = C1.x; + y = C1.y; + } + else if(i==1) { + x = C2.x; + y = C2.y; + } + else /*if(i==2)*/ { + x = C3.x; + y = C3.y; + } + }; + + double getMaxx() const; + double getMaxy() const; + double getMinx() const; + double getMiny() const; + + void getSize(double &w, double &h) const; + void getSize(int &w, int &h) const; + + void init(const vpColVector &c1,const vpColVector &c2,const vpColVector &c3); + void init(const vpImagePoint &c1, const vpImagePoint &c2, const vpImagePoint &c3); + void init(int x1,int y1, int x2,int y2, int x3,int y3); + void init(double x1,double y1, double x2,double y2, double x3,double y3); + bool inTriangle(const vpImagePoint &ip) const; + bool inTriangle(const int &i, const int &j) const; + bool inTriangle(const double &i,const double &j) const; + + vpTemplateTrackerTriangle & operator=(const vpTemplateTrackerTriangle& T); +}; +#endif + diff --git a/src/tracking/template-tracker/tools/vpTemplateTrackerZone.cpp b/src/tracking/template-tracker/tools/vpTemplateTrackerZone.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5e7e2eaa2278e733d7ead4fe1ce4e60626ab8467 --- /dev/null +++ b/src/tracking/template-tracker/tools/vpTemplateTrackerZone.cpp @@ -0,0 +1,590 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerZone.cpp 4661 2014-02-10 19:34:58Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ + +#include <limits> // numeric_limits + +#include <visp/vpConfig.h> + +#if VISP_HAVE_OPENCV_VERSION >= 0x020300 +#include <opencv2/imgproc/imgproc.hpp> +#endif + +#include <visp/vpTemplateTrackerZone.h> + + +/*! + Default constructor. + */ +vpTemplateTrackerZone::vpTemplateTrackerZone() + : Zone(), min_x(-1), min_y(-1), max_x(-1), max_y(-1) +{ +} + +/*! + Copy constructor. + */ +vpTemplateTrackerZone::vpTemplateTrackerZone(const vpTemplateTrackerZone &z) + : Zone(), min_x(-1), min_y(-1), max_x(-1), max_y(-1) +{ + *this = z; +} + +/*! + Remove all the triangles that define the zone. + */ +void vpTemplateTrackerZone::clear() +{ + min_x=-1; + min_y=-1; + max_x=-1; + max_y=-1; + + Zone.clear(); +} + +/*! + Copy operator. + */ +vpTemplateTrackerZone & vpTemplateTrackerZone::operator=(const vpTemplateTrackerZone &z) +{ + clear(); + + this->copy(z); + return (*this); +} + +/*! + Initialize a zone in image \e I using mouse click. + + \param I : Image used to select the zone. + \param delaunay : Flag used to enable Delaunay triangulation. + - If true, from the image points selected by the user, a Delaunay triangulation is performed + to initialize the zone. + - A left click select a image point; + - A right click select the last image point and ends the initialisation stage. + In that case at least 3 points need to be selected by the user. + - If false, the user select directly points as successive triangle corners. + Three successive points define a triangle. It is not mandatory + that triangles have one edge in common; they can define a discontinued area. + - A left click select a triangle corner; + - A right click select the last triangle corner and ends the initialisation stage. + The number of points that are selected by the user should be a multiple of 3. + For example, to select a zone as two triangles, the user has to left click + five times and finish the selection on the sixth corner with a right click. + + */ +void vpTemplateTrackerZone::initClick(const vpImage<unsigned char> &I, bool delaunay) +{ + Zone.clear(); + + std::vector<vpImagePoint> vip; + + bool end = false; + + do { + vpImagePoint p; + vpMouseButton::vpMouseButtonType button; + if (vpDisplay::getClick(I, p, button, false) ) { + vip.push_back(p); + + vpDisplay::displayCross(I, p, 7, vpColor::red); + + if (vip.size() > 1) { + if (delaunay) { + // Draw a line between the 2 last points + vpDisplay::displayLine(I, p, vip[vip.size()-2], vpColor::blue, 3); + } + else { + if(vip.size() % 3 ==2) + // draw line between point 2-1 + vpDisplay::displayLine(I, p, vip[vip.size()-2], vpColor::blue, 3); + else if(vip.size() % 3 ==0) { + // draw line between point 3-2 + vpDisplay::displayLine(I, p, vip[vip.size()-2], vpColor::blue, 3); + // draw line between point 3-1 + vpDisplay::displayLine(I, p, vip[vip.size()-3], vpColor::blue, 3); + } + + } + } + vpDisplay::flush(I); + + if (button == vpMouseButton::button3) + end = true; + } + + vpTime::wait(20); + } while(!end); + + initFromPoints(I, vip, delaunay); +} + +/*! + + Initialize the zone using a vector of image points. + + \param I : Image to process. + \param vip : Vector of image points used as initialization. + \param delaunay : + - If true, a Delaunay triangulation is perfomed on the vector of image points. This functionality + is only available if ViSP is build with OpenCV >2.3 third-party. + - If false, the vector of image points describe triangles. Its size is then a multiple of 3. + */ +void vpTemplateTrackerZone::initFromPoints(const vpImage<unsigned char>& I, const std::vector< vpImagePoint > &vip, bool delaunay) +{ + if (delaunay) { +#if VISP_HAVE_OPENCV_VERSION >= 0x020300 + // Init Delaunay + cv::Subdiv2D subdiv(cv::Rect(0, 0, (int)I.getWidth(), (int)I.getHeight())); + for(size_t i=0; i< vip.size(); i++) { + cv::Point2f fp((float)vip[i].get_u(), (float)vip[i].get_v()); + std::cout << "Click point: " << vip[i] << std::endl; + subdiv.insert(fp); + } + + // Compute Delaunay triangulation + std::vector<cv::Vec6f> triangleList; + subdiv.getTriangleList(triangleList); + + // Keep only the Delaunay points that are inside the area + vpRect rect(vip); + + std::vector<vpImagePoint> vip_delaunay; + + for( size_t i = 0; i < triangleList.size(); i++ ) { + cv::Vec6f t = triangleList[i]; + std::vector<vpImagePoint> p(3); + + p[0].set_uv(t[0], t[1]); + p[1].set_uv(t[2], t[3]); + p[2].set_uv(t[4], t[5]); + if (p[0].inRectangle(rect) && p[1].inRectangle(rect) && p[2].inRectangle(rect)) { + vip_delaunay.push_back(p[0]); + vip_delaunay.push_back(p[1]); + vip_delaunay.push_back(p[2]); + } + } + + initFromPoints(I, vip_delaunay, false); +#else + throw vpException(vpException::functionNotImplementedError,"Delaunay triangulation is not available!"); +#endif + } + else { + Zone.clear(); + for(unsigned int i=0; i<vip.size(); i+=3) { + vpTemplateTrackerTriangle triangle(vip[i], vip[i+1], vip[i+2]); + add(triangle); + + vpDisplay::displayLine(I, vip[i], vip[i+1], vpColor::green, 1); + vpDisplay::displayLine(I, vip[i+1], vip[i+2], vpColor::green, 1); + vpDisplay::displayLine(I, vip[i+2], vip[i], vpColor::green,1); + vpDisplay::flush(I) ; + + // Update the bounding box + if((triangle.getMinx()<min_x)||(min_x==-1)) + min_x=(int)triangle.getMinx(); + if((triangle.getMaxx()>max_x)||(max_x==-1)) + max_x=(int)triangle.getMaxx(); + if((triangle.getMiny()<min_y)||(min_y==-1)) + min_y=(int)triangle.getMiny(); + if((triangle.getMaxy()>max_y)||(max_y==-1)) + max_y=(int)triangle.getMaxy(); + } + } +} + +/*! + Add a triangle to the zone and update the bounding box. + \param t : Triangle to introduce in the zone. + */ +void vpTemplateTrackerZone::add(const vpTemplateTrackerTriangle &t) +{ + Zone.push_back(t); + + // Update the bounding box + if((t.getMinx()<min_x)||(min_x==-1)) + min_x=(int)t.getMinx(); + if((t.getMaxx()>max_x)||(max_x==-1)) + max_x=(int)t.getMaxx(); + if((t.getMiny()<min_y)||(min_y==-1)) + min_y=(int)t.getMiny(); + if((t.getMaxy()>max_y)||(max_y==-1)) + max_y=(int)t.getMaxy(); +} + +/*! + Test if a pixel with coordinates (i,j) is in the zone.. + \param i, j : Coordinates of the pixel to test. + \return true if the pixel with coordinates (i,j) is in the zone defined by a set of triangles, false otherwise. + */ +bool vpTemplateTrackerZone::inZone(const int &i, const int &j) const +{ + std::vector<vpTemplateTrackerTriangle>::const_iterator Iterateurvecteur; + for(Iterateurvecteur=Zone.begin();Iterateurvecteur!=Zone.end();Iterateurvecteur++) + { + if(Iterateurvecteur->inTriangle(i,j)) + return true; + } + return false; +} + +/*! + Test if a pixel with coordinates (i,j) is in the zone.. + \param i, j : Coordinates of the pixel to test. + \return true if the pixel with coordinates (i,j) is in the zone defined by a set of triangles, false otherwise. + */ +bool vpTemplateTrackerZone::inZone(const double &i,const double &j) const +{ + std::vector<vpTemplateTrackerTriangle>::const_iterator Iterateurvecteur; + for(Iterateurvecteur=Zone.begin();Iterateurvecteur!=Zone.end();Iterateurvecteur++) + { + if(Iterateurvecteur->inTriangle(i,j)) + return true; + } + return false; +} + +/*! + Test if a pixel with coordinates (i,j) is in the zone and returns also the index of + the triangle that contains the pixel. + \param i, j : Coordinates of the pixel to test. + \param id_triangle : Index of the triangle that contains the pixel (i,j). + \return true if the pixel with coordinates (i,j) is in the zone defined by a set of triangles, false otherwise. + */ +bool vpTemplateTrackerZone::inZone(const int &i,const int &j, unsigned int &id_triangle) const +{ + unsigned int id=0; + std::vector<vpTemplateTrackerTriangle>::const_iterator Iterateurvecteur; + for(Iterateurvecteur=Zone.begin();Iterateurvecteur!=Zone.end();Iterateurvecteur++) + { + if(Iterateurvecteur->inTriangle(i,j)) + { + id_triangle=id; + return true; + } + id++; + } + return false; +} + +/*! + Test if a pixel with coordinates (i,j) is in the zone and returns also the index of + the triangle that contains the pixel. + \param i, j : Coordinates of the pixel to test. + \param id_triangle : Index of the triangle that contains the pixel (i,j). + \return true if the pixel with coordinates (i,j) is in the zone defined by a set of triangles, false otherwise. + */ +bool vpTemplateTrackerZone::inZone(const double &i,const double &j, unsigned int &id_triangle) const +{ + unsigned int id=0; + std::vector<vpTemplateTrackerTriangle>::const_iterator Iterateurvecteur; + for(Iterateurvecteur=Zone.begin();Iterateurvecteur!=Zone.end();Iterateurvecteur++) + { + if(Iterateurvecteur->inTriangle(i,j)) + { + id_triangle=id; + return true; + } + id++; + } + return false; +} + +/*! + A zone is defined by a set of triangles. This function returns the ith triangle. + \param i : Index of the triangle to return. + \param T : The triangle corresponding to index i. + \return true if the triangle with index i was found, false otherwise. + + The following sample code shows how to use this function: + \code + vpTemplateTrackerZone zone; + ... + for (unsigned int i=0; i < zone.getNbTriangle(); i++) { + vpTemplateTrackerTriangle triangle; + zone.getTriangle(i, triangle); + } + \endcode + */ +void vpTemplateTrackerZone::getTriangle(unsigned int i,vpTemplateTrackerTriangle &T) const +{ + if (i > getNbTriangle()-1) + throw(vpException(vpException::badValue, "Cannot get triangle with index %u", i)); + + T = Zone[i]; +} +/*! + A zone is defined by a set of triangles. This function returns the ith triangle. + \param i : Index of the triangle to return. + \return The triangle corresponding to index i. + + The following sample code shows how to use this function: + \code + vpTemplateTrackerZone zone; + ... + for (unsigned int i=0; i < zone.getNbTriangle(); i++) { + vpTemplateTrackerTriangle triangle = zone.getTriangle(i); + } + \endcode + */ +vpTemplateTrackerTriangle vpTemplateTrackerZone::getTriangle(unsigned int i) const +{ + if (i > getNbTriangle()-1) + throw(vpException(vpException::badValue, "Cannot get triangle with index %u", i)); + + return Zone[i]; +} +/*! + Return the position of the center of gravity of the zone. + \exception vpException::divideByZeroError: The size of the zone is null. + */ +vpImagePoint vpTemplateTrackerZone::getCenter() const +{ + double xc=0; + double yc=0; + int cpt=0; + for(int i=min_y;i<max_y;i++) + for(int j=min_x;j<max_x;j++) + if(inZone(i,j)) + { + xc+=j; + yc+=i; + cpt ++; + } + if(! cpt) { + throw(vpException(vpException::divideByZeroError, + "Cannot compute the zone center: size = 0")) ; + } + xc=xc/cpt; + yc=yc/cpt; + vpImagePoint ip; + ip.set_uv(xc, yc); + return ip; +} + +/*! + \return The maximal x coordinate (along the columns of the image) of the points that are in the zone. + \sa getMinx(), getBoundingBox() + */ +int vpTemplateTrackerZone::getMaxx() const +{ + return max_x; +} +/*! + \return The maximal y coordinate (along the rows of the image) of the points that are in the zone. + \sa getMiny(), getBoundingBox() + */ +int vpTemplateTrackerZone::getMaxy() const +{ + return max_y; +} +/*! + \return The minimal x coordinate (along the columns of the image) of the points that are in the zone. + \sa getMaxx(), getBoundingBox() + */ +int vpTemplateTrackerZone::getMinx() const +{ + return min_x; +} +/*! + \return The minimal y coordinate (along the rows of the image) of the points that are in the zone. + \sa getMaxy(), getBoundingBox() + */ +int vpTemplateTrackerZone::getMiny() const +{ + return min_y; +} + +/*! + Return a rectangle that defines the bounding box of the zone. + \sa getMinx(), getMiny(), getMaxx(), getMaxy() + */ +vpRect vpTemplateTrackerZone::getBoundingBox() const +{ + vpRect bbox; + bbox.setTopLeft(vpImagePoint(min_y, min_x)); + bbox.setBottomRight(vpImagePoint(max_y, max_x)); + return bbox; +} + +/*! + If a display device is associated to image \c I, display in overlay the triangles that define the zone. + \param I : Image. + \param col : Color used to display the triangles. + \param thickness : Thickness of the triangle lines. + */ +void vpTemplateTrackerZone::display(const vpImage<unsigned char> &I, const vpColor &col, const unsigned int thickness) +{ + std::vector<vpImagePoint> ip; + for (unsigned int i=0; i < Zone.size(); i++) { + vpTemplateTrackerTriangle triangle; + Zone[i].getCorners(ip); + vpDisplay::displayLine(I, ip[0], ip[1], col, thickness); + vpDisplay::displayLine(I, ip[1], ip[2], col, thickness); + vpDisplay::displayLine(I, ip[2], ip[0], col, thickness); + } +} + +/*! + If a display device is associated to image \c I, display in overlay the triangles that define the zone. + \param I : Image. + \param col : Color used to display the triangles. + \param thickness : Thickness of the triangle lines. + */ +void vpTemplateTrackerZone::display(const vpImage<vpRGBa> &I, const vpColor &col, const unsigned int thickness) +{ + std::vector<vpImagePoint> ip; + for (unsigned int i=0; i < Zone.size(); i++) { + vpTemplateTrackerTriangle triangle; + Zone[i].getCorners(ip); + vpDisplay::displayLine(I, ip[0], ip[1], col, thickness); + vpDisplay::displayLine(I, ip[1], ip[2], col, thickness); + vpDisplay::displayLine(I, ip[2], ip[0], col, thickness); + } +} + +/*! + Destructor. + */ +vpTemplateTrackerZone::~vpTemplateTrackerZone() +{ + clear(); +} + +/*! + Modify all the pixels inside a triangle with a given gray level. + \param I: Output image. + \param id: Triangle id. This value should be less than the number + of triangles used to define the zone and available using getNbTriangle(). + \param gray_level: Color used to fill the triangle with. + */ +void vpTemplateTrackerZone::fillTriangle(vpImage<unsigned char>& I, unsigned int id,unsigned char gray_level) +{ + assert(id < getNbTriangle()); + vpTemplateTrackerTriangle triangle; + getTriangle(id, triangle); + for (int i=0 ; i < (int) I.getHeight() ; i++) + { + for (int j=0 ; j < (int) I.getWidth() ; j++) + { + if(triangle.inTriangle(i,j)) + { + I[i][j]=gray_level; + } + } + } +} + +/*! + Return a zone with triangles that are down scaled by a factor 2. + */ +vpTemplateTrackerZone vpTemplateTrackerZone::getPyramidDown() const +{ + vpTemplateTrackerZone tempZone; + vpTemplateTrackerTriangle Ttemp; + vpTemplateTrackerTriangle TtempDown; + for(unsigned int i=0;i<getNbTriangle();i++) + { + getTriangle(i,Ttemp); + TtempDown=Ttemp.getPyramidDown(); + tempZone.add(TtempDown); + } + return tempZone; +} + +/*! + Copy all the triangles that define zone \c Z in the current zone (*this) and + update the zone bounding box. + \param z : Zone with a set of triangles provided as input. + */ +void vpTemplateTrackerZone::copy(const vpTemplateTrackerZone& z) +{ + vpTemplateTrackerTriangle triangle; + for(unsigned int i=0;i<z.getNbTriangle();i++) + { + z.getTriangle(i, triangle); + add(triangle); + // Update the bounding box + if((triangle.getMinx()<min_x)||(min_x==-1)) + min_x=(int)triangle.getMinx(); + if((triangle.getMaxx()>max_x)||(max_x==-1)) + max_x=(int)triangle.getMaxx(); + if((triangle.getMiny()<min_y)||(min_y==-1)) + min_y=(int)triangle.getMiny(); + if((triangle.getMaxy()>max_y)||(max_y==-1)) + max_y=(int)triangle.getMaxy(); + } +} + +/*! + Return the position of the center of gravity in a given area. + \param borne_x : Right coordinate of the area to consider. + \param borne_y : Bottom coordinate of the area to consider. + \exception vpException::divideByZeroError: The size of the zone is null. + */ + +vpImagePoint vpTemplateTrackerZone::getCenter(int borne_x, int borne_y) const +{ + int cpt_pt=0; + double x_center=0,y_center=0; + for(int j=0;j<borne_x;j++) + for(int i=0;i<borne_y;i++) + if(inZone(i,j)) + { + x_center+=j; + y_center+=i; + cpt_pt++; + } + + if(! cpt_pt) { + throw(vpException(vpException::divideByZeroError, + "Cannot compute the zone center: size = 0")) ; + } + + x_center=x_center/cpt_pt; + y_center=y_center/cpt_pt; + vpImagePoint center; + center.set_uv(x_center, y_center); + return center; +} + diff --git a/src/tracking/template-tracker/tools/vpTemplateTrackerZone.h b/src/tracking/template-tracker/tools/vpTemplateTrackerZone.h new file mode 100644 index 0000000000000000000000000000000000000000..a1a6b2cffc8d8970669cce783ff6a51e1f0ced86 --- /dev/null +++ b/src/tracking/template-tracker/tools/vpTemplateTrackerZone.h @@ -0,0 +1,118 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerZone.h 4661 2014-02-10 19:34:58Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +#ifndef vpTemplateTrackerZone_hh +#define vpTemplateTrackerZone_hh + +#include <vector> + +#include <visp/vpDisplay.h> +#include <visp/vpException.h> +#include <visp/vpImage.h> +#include <visp/vpTemplateTrackerTriangle.h> +#include <visp/vpTemplateTrackerHeader.h> +#include <visp/vpRect.h> + +/*! + A zone is defined by a set of triangles defined as vpTemplateTrackerTriangle. + + A zone can be initialized either by user interaction using mouse click in a display device + throw initClick(), or by a list of points throw initFromPoints(). + */ +class VISP_EXPORT vpTemplateTrackerZone +{ + protected: + std::vector<vpTemplateTrackerTriangle> Zone; //!< Vector of triangles that defines the zone. + int min_x; //!< Bounding box parameter + int min_y; //!< Bounding box parameter + int max_x; //!< Bounding box parameter + int max_y; //!< Bounding box parameter + + public: + vpTemplateTrackerZone(); + vpTemplateTrackerZone(const vpTemplateTrackerZone &z); + ~vpTemplateTrackerZone(); + + //add a triangle to the zone + void add(const vpTemplateTrackerTriangle &t); + void clear(); + void copy(const vpTemplateTrackerZone& z); + + //display the area on an image + void display(const vpImage<unsigned char> &I, const vpColor &col = vpColor::green, const unsigned int thickness=3); + void display(const vpImage<vpRGBa> &I, const vpColor &col = vpColor::green, const unsigned int thickness=3); + + //colorie le tieme triangle + void fillTriangle(vpImage<unsigned char>& I, unsigned int id, unsigned char gray_level); + + vpImagePoint getCenter() const; + vpImagePoint getCenter(int borne_x, int borne_y) const; + //get bounds of the area + int getMaxx() const; + int getMaxy() const; + int getMinx() const; + int getMiny() const; + vpRect getBoundingBox() const; + + /*! Return the number of triangles that define the zone. \sa getTriangle() */ + unsigned int getNbTriangle() const { return (unsigned int)Zone.size(); } + vpTemplateTrackerZone getPyramidDown() const; + //renvoie le ieme triangle de la zone + void getTriangle(unsigned int i, vpTemplateTrackerTriangle &T) const; + vpTemplateTrackerTriangle getTriangle(unsigned int i) const; + + //create an area by clicking on an image + void initClick(const vpImage<unsigned char>& I, bool delaunay = false); + //create an area with a pointer of integer that describes a series of triangles: + // *pt= t0.S1.x,t0.S1.y,t0.S2.x,t0.S2.y,t0.S3.x,t0.S3.y, t1.S1.x ... + void initFromPoints(const vpImage<unsigned char>& I, const std::vector< vpImagePoint > &ip, bool delaunay = false); + + //check if a point is in the area + bool inZone(const int &i,const int &j) const; + bool inZone(const double &i,const double &j) const; + //check if a point is in the area and return the corresponding triangle id_triangle where the point is. + bool inZone(const int &i,const int &j, unsigned int &id_triangle) const; + bool inZone(const double &i,const double &j, unsigned int &id_triangle) const; + + vpTemplateTrackerZone & operator=(const vpTemplateTrackerZone &z); +}; +#endif + diff --git a/src/tracking/template-tracker/vpTemplateTracker.cpp b/src/tracking/template-tracker/vpTemplateTracker.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7fe6387b2e512bdc734f89bdf703adb49c68c623 --- /dev/null +++ b/src/tracking/template-tracker/vpTemplateTracker.cpp @@ -0,0 +1,927 @@ +/**************************************************************************** + * + * $Id: vpTemplateTracker.cpp 4635 2014-02-04 08:16:59Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +#include <visp/vpTemplateTracker.h> +#include <visp/vpTemplateTrackerBSpline.h> + +vpTemplateTracker::vpTemplateTracker(vpTemplateTrackerWarp *_warp) + : nbLvlPyr(1), l0Pyr(0), pyrInitialised(false), ptTemplate(NULL), ptTemplatePyr(NULL), + ptTemplateInit(false), templateSize(0), templateSizePyr(NULL), + ptTemplateSelect(NULL), ptTemplateSelectPyr(NULL), ptTemplateSelectInit(NULL), + templateSelectSize(0), ptTemplateSupp(NULL), ptTemplateSuppPyr(NULL), + ptTemplateCompo(NULL), ptTemplateCompoPyr(NULL), zoneTracked(NULL), zoneTrackedPyr(NULL), + pyr_IDes(NULL), H(), Hdesire(), HdesirePyr(), HLM(), HLMdesire(), HLMdesirePyr(), + HLMdesireInverse(), HLMdesireInversePyr(), G(), gain(1.), thresholdGradient(40), + costFunctionVerification(false), blur(true), useBrent(false), nbIterBrent(3), + taillef(7), fgG(NULL), fgdG(NULL), ratioPixelIn(0), mod_i(1), mod_j(1), nbParam(0), + lambdaDep(0.001), iterationMax(30), iterationGlobale(0), diverge(false), nbIteration(0), + useCompositionnal(true), useInverse(false), Warp(_warp), p(0), dp(), X1(), X2(), + dW(), BI(), dIx(), dIy(), zoneRef_() +{ + nbParam = Warp->getNbParam() ; + p.resize(nbParam); + dp.resize(nbParam); + + fgG=new double[(taillef+1)/2] ; + vpImageFilter::getGaussianKernel(fgG, taillef) ; + + fgdG=new double[(taillef+1)/2] ; + vpImageFilter::getGaussianDerivativeKernel(fgdG, taillef) ; +} + +void vpTemplateTracker::setGaussianFilterSize(unsigned int new_taill) +{ + taillef=new_taill; + if (fgG) delete[] fgG; + fgG=new double[taillef] ; + vpImageFilter::getGaussianKernel(fgG, taillef) ; + + if (fgdG) delete[] fgdG; + fgdG=new double[taillef] ; + vpImageFilter::getGaussianDerivativeKernel(fgdG, taillef) ; +} + +void vpTemplateTracker::initTracking(const vpImage<unsigned char>& I, vpTemplateTrackerZone &zone) +{ + // std::cout<<"\tInitialise reference..."<<std::endl; + zoneTracked=&zone; + + int largeur_im=(int)I.getWidth(); + int hauteur_im=(int)I.getHeight(); + + unsigned int NbPointDsZone=0; + double xtotal=0,ytotal=0; + int mod_fi,mod_fj; + mod_fi=mod_i;mod_fj=mod_i; + + for(int j=0;j<largeur_im;j++) + for(int i=0;i<hauteur_im;i++) + if(i%mod_fi ==0 && j%mod_fj ==0) + if(zone.inZone(i,j)) + { + NbPointDsZone++; + xtotal+=j; + ytotal+=i; + } + //Warp->setCentre((double)xtotal/NbPointDsZone,(double)ytotal/NbPointDsZone); + + templateSize=NbPointDsZone; + ptTemplate = new vpTemplateTrackerPoint[templateSize];ptTemplateInit=true; + ptTemplateSelect = new bool[templateSize];ptTemplateSelectInit=true; + + Hdesire.resize(nbParam,nbParam); + HLMdesire.resize(nbParam,nbParam); + + //RecupÈration des donnÈes des triangles de la pyramide gaussienne + vpTemplateTrackerPoint pt; + //vpTemplateTrackerZPoint ptZ; + vpImage<double> GaussI ; + vpImageFilter::filter(I, GaussI,fgG,taillef); + vpImageFilter::getGradXGauss2D(I, dIx, fgG,fgdG,taillef); + vpImageFilter::getGradYGauss2D(I, dIy, fgG,fgdG,taillef); + + unsigned int cpt_point=0; + templateSelectSize=0; + for(int i=0;i<hauteur_im;i++) + { + //for(int j=minx_t;j<maxx_t;j++) + for(int j=0;j<largeur_im;j++) + { + if(i%mod_i ==0 && j%mod_j ==0) + if(zone.inZone(i,j)) + { + pt.x=j; + pt.y=i; + + pt.dx=dIx[i][j]; + pt.dy=dIy[i][j]; + + if(pt.dx*pt.dx+pt.dy*pt.dy>thresholdGradient) + { + ptTemplateSelect[cpt_point]=true; + templateSelectSize++; + } + else + ptTemplateSelect[cpt_point]=false; + //ptTemplate_select[cpt_point]=true; + + /*if(blur) + pt.val=GaussI[i][j]; + else + pt.val=I[i][j];*/ + pt.val=vpTemplateTrackerBSpline::getSubPixBspline4(GaussI,i,j); + //ptZone_pyr[NbLevelPyramid-cpt].push_back(pt); + + ptTemplate[cpt_point]=pt; + cpt_point++; + } + } + } + + // std::cout<<"\tNb pt template apres scale:"<<cpt_point<<std::endl; + // std::cout<<"utilisation de "<<taille_template_select<<"/"<<cpt_point<<" = "<<100.*taille_template_select/cpt_point<<"% pour calcul derivees"<<std::endl; + + templateSize=cpt_point; + GaussI.destroy(); + // std::cout<<"\tEnd of reference initialisation ..."<<std::endl; +} + +vpTemplateTracker::~vpTemplateTracker() +{ + // vpTRACE("destruction tracker"); + delete[] fgG; + delete[] fgdG; + + resetTracker(); +} + +/*! + Reset the tracker by freeing the memory allocated by the template tracker during the initialization. + */ +void vpTemplateTracker::resetTracker() +{ + // reset the tracker parameters + p = 0; + + // vpTRACE("resetTracking"); + if(pyrInitialised) + { + for(unsigned int i=0;i<nbLvlPyr;i++) + { + for(unsigned int point=0;point<templateSizePyr[i];point++) + { + delete[] ptTemplatePyr[i][point].dW; + delete[] ptTemplatePyr[i][point].HiG; + } + delete[] ptTemplatePyr[i]; + } + delete[] ptTemplatePyr; + + if (ptTemplateCompoPyr) { + for(unsigned int i=0;i<nbLvlPyr;i++) + { + if (ptTemplateCompoPyr[i]) { + for(unsigned int point=0;point<templateSizePyr[i];point++) { + delete[] ptTemplateCompoPyr[i][point].dW; + } + delete[] ptTemplateCompoPyr[i]; + } + } + delete[] ptTemplateCompoPyr; + ptTemplateCompoPyr = NULL; + } + + if (ptTemplateSuppPyr) { + for(unsigned int i=0;i<nbLvlPyr;i++) + { + if (ptTemplateSuppPyr[i]) { + for(unsigned int point=0;point<templateSizePyr[i];point++) { + delete[] ptTemplateSuppPyr[i][point].Bt; + delete[] ptTemplateSuppPyr[i][point].BtInit; + delete[] ptTemplateSuppPyr[i][point].dBt; + delete[] ptTemplateSuppPyr[i][point].d2W; + delete[] ptTemplateSuppPyr[i][point].d2Wx; + delete[] ptTemplateSuppPyr[i][point].d2Wy; + } + delete[] ptTemplateSuppPyr[i]; + } + } + delete[] ptTemplateSuppPyr; + ptTemplateSuppPyr = NULL; + } + + for(unsigned int i=0;i<nbLvlPyr;i++) + delete[] ptTemplateSelectPyr[i]; + delete[] ptTemplateSelectPyr; + + delete[] templateSizePyr; + delete[] HdesirePyr; + delete[] HLMdesirePyr; + delete[] HLMdesireInversePyr; + + delete[] zoneTrackedPyr; + delete[] pyr_IDes; + } + else + { + if(ptTemplateInit) + { + for(unsigned int point=0;point<templateSize;point++) + { + delete[] ptTemplate[point].dW; + delete[] ptTemplate[point].HiG; + } + delete[] ptTemplate; + ptTemplate = NULL; + ptTemplateInit = false; + } + if (ptTemplateCompo) { + for(unsigned int point=0;point<templateSize;point++) + { + delete[] ptTemplateCompo[point].dW; + } + delete[] ptTemplateCompo; + ptTemplateCompo = NULL; + } + if (ptTemplateSupp) { + for(unsigned int point=0;point<templateSize;point++) + { + delete[] ptTemplateSupp[point].Bt; + delete[] ptTemplateSupp[point].BtInit; + delete[] ptTemplateSupp[point].dBt; + delete[] ptTemplateSupp[point].d2W; + delete[] ptTemplateSupp[point].d2Wx; + delete[] ptTemplateSupp[point].d2Wy; + } + delete[] ptTemplateSupp; + ptTemplateSupp = NULL; + } + if(ptTemplateSelectInit) { + if (ptTemplateSelect) { + delete[] ptTemplateSelect; ptTemplateSelect = NULL; + } + } + } +} + +/*! + Display the warped reference template in an image. + + \param I: Image in which the warped zone has to be displayed. + \param col: Color used to draw the triangle edges. + \param thickness: Thickness of the lines. + + The following code shows how to use display capabilities: + \code +#include <visp/vpTemplateTrackerSSDInverseCompositional.h> +#include <visp/vpTemplateTrackerWarpHomography.h> + +int main() +{ + vpImage<unsigned char> I; + vpTemplateTrackerWarpHomography warp; + vpTemplateTrackerSSDInverseCompositional tracker(&warp); + vpTemplateTrackerZone zoneRef, zoneWarped; + + // Display the warped zone + tracker.display(I, vpColor::red); + + // Display the reference zone + zoneRef = tracker.getZoneRef(); + zoneRef.display(I, vpColor::green); + + // Display the warped zone + vpColVector p = tracker.getp(); + warp.warpZone(zoneRef, p, zoneWarped); + zoneWarped.display(I, vpColor::blue); +} + \endcode + */ +void vpTemplateTracker::display(const vpImage<unsigned char> &I, const vpColor& col, const unsigned int thickness) +{ + if (I.display) { // Only if a display is associated to the image + vpTemplateTrackerZone zoneWarped; + Warp->warpZone(*zoneTracked, p, zoneWarped); + zoneWarped.display(I, col, thickness); + } +} + +/*! + Display the warped reference template in an image. + + \param I: Image in which the warped zone has to be displayed. + \param col: Color used to draw the triangle edges. + \param thickness: Thickness of the lines. + + The following code shows how to use display capabilities: + \code +#include <visp/vpTemplateTrackerSSDInverseCompositional.h> +#include <visp/vpTemplateTrackerWarpHomography.h> + +int main() +{ + vpImage<vpRGBa> I; + vpTemplateTrackerWarpHomography warp; + vpTemplateTrackerSSDInverseCompositional tracker(&warp); + vpTemplateTrackerZone zoneRef, zoneWarped; + + // Display the warped zone + tracker.display(I, vpColor::red); + + // Display the reference zone + zoneRef = tracker.getZoneRef(); + zoneRef.display(I, vpColor::green); + + // Display the warped zone + vpColVector p = tracker.getp(); + warp.warpZone(zoneRef, p, zoneWarped); + zoneWarped.display(I, vpColor::blue); +} + \endcode + */ +void vpTemplateTracker::display(const vpImage<vpRGBa> &I, const vpColor& col, const unsigned int thickness) +{ + if (I.display) { // Only if a display is associated to the image + vpTemplateTrackerZone zoneWarped; + Warp->warpZone(*zoneTracked, p, zoneWarped); + zoneWarped.display(I, col, thickness); + } +} + +void vpTemplateTracker::computeOptimalBrentGain(const vpImage<unsigned char> &I,vpColVector &tp,double tMI,vpColVector &direction,double &alpha) +{ + vpColVector **ptp; + ptp=new vpColVector*[4]; + vpColVector p0(nbParam); + p0=tp; + + //valeur necessaire si conditionnel + vpColVector dpt(Warp->getNbParam()); + vpColVector adpt(Warp->getNbParam()); + + vpColVector p1(nbParam); + if(useCompositionnal) + { + if(useInverse) + Warp->getParamInverse(direction,dpt); + else + dpt=direction; + Warp->pRondp(tp,dpt,p1); + } + else + { + p1=tp+direction; + } + + vpColVector p2(nbParam); + if(useCompositionnal) + { + adpt=alpha*direction; + if(useInverse) + Warp->getParamInverse(adpt,dpt); + else + dpt=adpt; + Warp->pRondp(tp,dpt,p2); + } + else + { + p2=tp+alpha*direction; + } + vpColVector p3(nbParam); + ptp[0]=&p0; + ptp[1]=&p1; + ptp[2]=&p2; + ptp[3]=&p3; + + + double *Cost=new double[4]; + //Cost[0]=getCost(I,p0); + Cost[0]=tMI; + Cost[1]=getCost(I,p1); + Cost[2]=getCost(I,p2); + + + double *talpha=new double[4]; + talpha[0]=0; + talpha[1]=1.; + talpha[2]=alpha; + + //for(int i=0;i<3;i++) + // std::cout<<"alpha["<<i<<"] = "<<talpha[i]<<" Cost["<<i<<"] = "<<Cost[i]<<std::endl; + + //Utilise trois estimᅵes de paraboles succesive ... + //A changer pour rendre adaptable + for(unsigned int opt=0;opt<nbIterBrent;opt++) + { + //double a=talpha[0]; + //double b=talpha[1]; + //double c=talpha[2]; + //double Cost0=Cost[0]; + //double Cost1=Cost[1]; + //double Cost2=Cost[2]; + + vpMatrix A(3,3); + for(unsigned int i=0;i<3;i++){A[i][0]=talpha[i]*talpha[i];A[i][1]=talpha[i];A[i][2]=1.;} + //std::cout<<"A="<<A<<std::endl; + vpColVector B(3);for(unsigned int i=0;i<3;i++)B[i]=Cost[i]; + vpColVector parabol(3);parabol=(A.t()*A).inverseByLU()*A.t()*B; + //vpColVector parabol(3);parabol=A.pseudoInverse()*B; + + //si convexe + if(parabol[0]>0) + { + talpha[3]=-0.5*parabol[1]/parabol[0]; + //std::cout<<"parabol = "<<parabol<<std::endl; + //std::cout<<"convexe talpha = "<<talpha[3]<<std::endl; + } + else//si concave + { + int tindic_x_min=0; + int tindic_x_max=0; + for(int i=1;i<3;i++) + { + if(talpha[i]<talpha[tindic_x_min]) + tindic_x_min=i; + if(talpha[i]>talpha[tindic_x_max]) + tindic_x_max=i; + } + + if(Cost[tindic_x_max]<Cost[tindic_x_min]) + { + //talpha[3]=talpha[tindic_x_max]+1.; + talpha[3]=talpha[tindic_x_max]+1.; + /*if(talpha[tindic_x_min]>talpha[tindic_x_max]) + talpha[3]=talpha[tindic_x_min]+1.; + else + talpha[3]=talpha[tindic_x_min]-1.;*/ + } + else + { + //talpha[3]=talpha[tindic_x_min]-1.; + talpha[3]=talpha[tindic_x_min]-1.; + /*if(talpha[tindic_x_min]<talpha[tindic_x_max]) + talpha[3]=talpha[tindic_x_max]+1.; + else + talpha[3]=talpha[tindic_x_max]-1.;*/ + } + //std::cout<<"concave talpha="<<talpha[3]<<std::endl; + } + //std::cout<<"talpha="<<talpha[3]<<std::endl; + int indic_x_min=0; + int indic_x_max=0; + for(int i=1;i<3;i++) + { + if(talpha[i]<talpha[indic_x_min]) + indic_x_min=i; + if(talpha[i]>talpha[indic_x_max]) + indic_x_max=i; + } + //std::cout<<"talpha = "<<talpha[3]<<std::endl; + if(talpha[3]>talpha[indic_x_max]) + if((talpha[3]-talpha[indic_x_max])>alpha)talpha[3]=talpha[indic_x_max]+4.; + if(talpha[3]<talpha[indic_x_min]) + if((talpha[indic_x_min]-talpha[3])>alpha)talpha[3]=talpha[indic_x_min]-4.; + + /*if(((b-a)*(Cost1-Cost2)-(b-c)*(Cost1-Cost0))==0) + {Cost[3]=1000;break;} + + //calcul du gain correspondant au minimum de la parabole estimᅵe + talpha[3]=b-0.5*((b-a)*(b-a)*(Cost1-Cost2)-(b-c)*(b-c)*(Cost1-Cost0))/((b-a)*(Cost1-Cost2)-(b-c)*(Cost1-Cost0)); + int indic_x_min=0; + int indic_x_max=0; + for(int i=1;i<3;i++) + { + if(talpha[i]<talpha[indic_x_min]) + indic_x_min=i; + if(talpha[i]>talpha[indic_x_max]) + indic_x_max=i; + } + std::cout<<"talpha = "<<talpha[3]<<std::endl; + if(talpha[3]>talpha[indic_x_max]) + if((talpha[3]-talpha[indic_x_max])>alpha)talpha[3]=talpha[indic_x_max]+alpha; + if(talpha[3]<talpha[indic_x_min]) + if((talpha[indic_x_min]-talpha[3])>alpha)talpha[3]=talpha[indic_x_min]-alpha;*/ + + //p3=tp-talpha[3]*direction; + if(useCompositionnal) + { + adpt=talpha[3]*direction; + if(useInverse) + Warp->getParamInverse(adpt,dpt); + else + dpt=adpt; + Warp->pRondp(tp,dpt,p3); + } + else + { + p3=tp+talpha[3]*direction; + } + + Cost[3]=getCost(I,p3); + //std::cout<<"new cost="<<Cost[3]<<std::endl; + + int indice_f_max=0; + for(int i=1;i<4;i++) + if(Cost[i]>Cost[indice_f_max]) + indice_f_max=i; + if(indice_f_max!=3) + { + *ptp[indice_f_max]=*ptp[3]; + Cost[indice_f_max]=Cost[3]; + talpha[indice_f_max]=talpha[3]; + } + else + break; + } + + int indice_f_min=0; + for(int i=0;i<4;i++) + if(Cost[i]<Cost[indice_f_min]) + indice_f_min=i; + + alpha=talpha[indice_f_min]; + + if(alpha<1)alpha=1.; + + delete[] ptp; + delete[] Cost; + delete[] talpha; +} + + +/*! + \param nbLvl : Number of levels in the pyramid. + \param l0 : Pyramid level where the tracking is stopped. The level with the highest resolution is 0. + */ +void vpTemplateTracker::initPyramidal(unsigned int nbLvl, unsigned int l0) +{ + // vpTRACE("init_pyramidal"); + nbLvlPyr=nbLvl; + l0Pyr=l0; + + zoneTrackedPyr=new vpTemplateTrackerZone[nbLvlPyr]; + pyr_IDes=new vpImage<unsigned char>[nbLvlPyr]; + ptTemplatePyr=new vpTemplateTrackerPoint*[nbLvlPyr]; + ptTemplateSelectPyr=new bool*[nbLvlPyr]; + ptTemplateSuppPyr=new vpTemplateTrackerPointSuppMIInv*[nbLvlPyr]; + ptTemplateCompoPyr=new vpTemplateTrackerPointCompo*[nbLvlPyr]; + for(unsigned int i=0; i< nbLvlPyr; i++) { + ptTemplatePyr[i] = NULL; + ptTemplateSuppPyr[i] = NULL; + ptTemplateSelectPyr[i] = NULL; + ptTemplateCompoPyr[i] = NULL; + } + templateSizePyr=new unsigned int[nbLvlPyr]; + HdesirePyr=new vpMatrix[nbLvlPyr]; + HLMdesirePyr=new vpMatrix[nbLvlPyr]; + HLMdesireInversePyr=new vpMatrix[nbLvlPyr]; + + pyrInitialised=true; + // vpTRACE("fin init_pyramidal"); + +} +void vpTemplateTracker::initTrackingPyr(const vpImage<unsigned char>& I,vpTemplateTrackerZone &zone) +{ + // vpTRACE("initTrackingPyr"); + zoneTrackedPyr[0].copy(zone); + //vpTRACE("fin copy zone"); + + pyr_IDes[0]=I; + initTracking(pyr_IDes[0],zoneTrackedPyr[0]); + ptTemplatePyr[0]=ptTemplate; + ptTemplateSelectPyr[0]=ptTemplateSelect; + templateSizePyr[0]=templateSize; + + //creationpyramide de zones et images desiree + if(nbLvlPyr>1) + { + for(unsigned int i=1;i<nbLvlPyr;i++) + { + zoneTrackedPyr[i]=zoneTrackedPyr[i-1].getPyramidDown(); + vpImageFilter::getGaussPyramidal(pyr_IDes[i-1],pyr_IDes[i]); + + initTracking(pyr_IDes[i],zoneTrackedPyr[i]); + ptTemplatePyr[i]=ptTemplate; + ptTemplateSelectPyr[i]=ptTemplateSelect; + templateSizePyr[i]=templateSize; + //reste probleme avec le Hessien + } + } + /*for(int i=0;i<nbLvlPyr;i++) + { + vpColVector ptemp(8);ptemp=0; + zoneTracked=&zoneTrackedPyr[i]; + init_pos_evalRMS(ptemp); + }*/ + zoneTracked=&zoneTrackedPyr[0]; + + + // vpTRACE("fin initTrackingPyr"); + +} + +/*! + Select the reference template in image \e I using mouse click. + + \param I: Image containing the reference template. + \param delaunay: Flag used to enable Delaunay triangulation. + - If true, from the image points selected by the user, a Delaunay triangulation is performed + to initialize the reference template. + - A left click select a image point; + - A right click select the last image point and ends the initialisation stage. + - If false, the user select directly points as successive triangle corners. + The size of \e v_ip vector should be a multiple of 3. It is not mandatory + that triangles have one edge in common; they can define a discontinued area. + - A left click select a triangle corner; + - A right click select the last triangle corner and ends the initialisation stage. + For example, to select the reference template as two triangles, the user has to left click + five times and finish the selection on the sixth corner with a right click. + + */ +void vpTemplateTracker::initClick(const vpImage<unsigned char> &I, bool delaunay) +{ + zoneRef_.initClick(I, delaunay); + + if (nbLvlPyr > 1) { + initPyramidal(nbLvlPyr, l0Pyr); + initTrackingPyr(I, zoneRef_); + initHessienDesiredPyr(I); + } + else { + initTracking(I, zoneRef_); + initHessienDesired(I); +// trackNoPyr(I); + } +} + +/*! + Initialize the reference template from a vector of points. + + \param I: Image containing the reference template. + \param v_ip: Vector of image points defining the reference template. + \param delaunay: + - If true, from the image points defining the reference template enable Delaunay triangulation. + - If false, the vector of image points define the reference template as a list of triangles. + The size of \e v_ip vector should be a multiple of 3. + */ +void vpTemplateTracker::initFromPoints(const vpImage<unsigned char> &I, const std::vector< vpImagePoint > &v_ip, bool delaunay) +{ + zoneRef_.initFromPoints(I, v_ip, delaunay); + + if (nbLvlPyr > 1) { + initPyramidal(nbLvlPyr, l0Pyr); + initTrackingPyr(I, zoneRef_); + initHessienDesiredPyr(I); + } + else { + initTracking(I, zoneRef_); + initHessienDesired(I); + //trackNoPyr(I); + } +} + +/*! + Initialize the reference template from a vector of points. + + \param I: Image containing the reference template. + \param zone: The zone that describes the reference template. + */ +void vpTemplateTracker::initFromZone(const vpImage<unsigned char> &I, const vpTemplateTrackerZone& zone) +{ + zoneRef_ = zone; + + if (nbLvlPyr > 1) { + initPyramidal(nbLvlPyr, l0Pyr); + initTrackingPyr(I, zoneRef_); + initHessienDesiredPyr(I); + } + else { + initTracking(I, zoneRef_); + initHessienDesired(I); +// trackNoPyr(I); + } +} + +void vpTemplateTracker::initCompInversePyr(const vpImage<unsigned char> &I) +{ + vpTRACE("initCompInversePyr"); + templateSize=templateSizePyr[0]; + //ptTemplateSupp=ptTemplateSuppPyr[0]; + //ptTemplateCompo=ptTemplateCompoPyr[0]; + ptTemplate=ptTemplatePyr[0]; + ptTemplateSelect=ptTemplateSelectPyr[0]; + initCompInversePyr(I); + ptTemplateSuppPyr[0]=ptTemplateSupp; + ptTemplateCompoPyr[0]=ptTemplateCompo; + + + if(nbLvlPyr>1) + { + vpImage<unsigned char> Itemp=I; + for(unsigned int i=1;i<nbLvlPyr;i++) + { + vpImageFilter::getGaussPyramidal(Itemp,Itemp); + + templateSize=templateSizePyr[i]; + ptTemplate=ptTemplatePyr[i]; + ptTemplateSelect=ptTemplateSelectPyr[i]; + initCompInversePyr(Itemp); + ptTemplateSuppPyr[i]=ptTemplateSupp; + ptTemplateCompoPyr[i]=ptTemplateCompo; + } + } + // vpTRACE("fin initCompInversePyr"); + +} +void vpTemplateTracker::initHessienDesiredPyr(const vpImage<unsigned char> &I) +{ + // vpTRACE("initHessienDesiredPyr"); + templateSize=templateSizePyr[0]; + //ptTemplateSupp=ptTemplateSuppPyr[0]; + //ptTemplateCompo=ptTemplateCompoPyr[0]; + ptTemplate=ptTemplatePyr[0]; + ptTemplateSelect=ptTemplateSelectPyr[0]; + initHessienDesired(I); + ptTemplateSuppPyr[0]=ptTemplateSupp; + + ptTemplateCompoPyr[0]=ptTemplateCompo; + //HdesirePyr[0].resize(NbParam,NbParam); + //HLMdesirePyr[0].resize(NbParam,NbParam); + HdesirePyr[0]=Hdesire; + HLMdesirePyr[0]=HLMdesire; + HLMdesireInversePyr[0]=HLMdesireInverse; + + if(nbLvlPyr>1) + { + vpImage<unsigned char> Itemp;Itemp=I; + for(unsigned int i=1;i<nbLvlPyr;i++) + { + vpImageFilter::getGaussPyramidal(Itemp,Itemp); + + templateSize=templateSizePyr[i]; + ptTemplate=ptTemplatePyr[i]; + ptTemplateSelect=ptTemplateSelectPyr[i]; + //ptTemplateSupp=ptTemplateSuppPyr[i]; + //ptTemplateCompo=ptTemplateCompoPyr[i]; + initHessienDesired(Itemp); + ptTemplateSuppPyr[i]=ptTemplateSupp; + ptTemplateCompoPyr[i]=ptTemplateCompo; + + /*HdesirePyr[i].resize(NbParam,NbParam);HdesirePyr[i]=H; + HLMdesirePyr[i].resize(NbParam,NbParam);HLMdesirePyr[i]=HLM;*/ + HdesirePyr[i]=Hdesire; + HLMdesirePyr[i]=HLMdesire; + HLMdesireInversePyr[i]=HLMdesireInverse; + } + } + // vpTRACE("fin initHessienDesiredPyr"); +} + +/*! + Track the template on image \e I. + \param I: Image to process. + */ +void vpTemplateTracker::track(const vpImage<unsigned char> &I) +{ + if (nbLvlPyr > 1) + trackPyr(I); + else + trackNoPyr(I); +} + +void vpTemplateTracker::trackPyr(const vpImage<unsigned char> &I) +{ + //vpTRACE("trackPyr"); + vpImage<unsigned char> *pyr_I; +// pyr_I=new vpImage<unsigned char>[nbLvlPyr+1]; // Why +1 ? + pyr_I=new vpImage<unsigned char>[nbLvlPyr]; // Why +1 ? + pyr_I[0]=I; + + vpColVector ptemp(nbParam); + if(nbLvlPyr>1) + { +// vpColVector *p_sauv=new vpColVector[nbLvlPyr]; +// for(unsigned int i=0;i<nbLvlPyr;i++)p_sauv[i].resize(nbParam); + +// p_sauv[0]=p; + for(unsigned int i=1;i<nbLvlPyr;i++) + { + vpImageFilter::getGaussPyramidal(pyr_I[i-1],pyr_I[i]); + //test getParamPyramidDown + /*vpColVector vX_test(2);vX_test[0]=15.;vX_test[1]=30.; + vpColVector vX_test2(2); + Warp->computeCoeff(p); + Warp->computeDenom(vX_test,p); + Warp->warpX(vX_test,vX_test2,p); + std::cout<<"p = "<<p.t()<<std::endl;*/ + //std::cout<<"get p down"<<std::endl; + Warp->getParamPyramidDown(p,ptemp); + p=ptemp; + zoneTracked=&zoneTrackedPyr[i]; + +// p_sauv[i]=p; + /*std::cout<<"p_down = "<<p.t()<<std::endl; + + vpColVector vX_testd(2);vX_testd[0]=15./2.;vX_testd[1]=30./2.; + vpColVector vX_testd2(2); + Warp->computeCoeff(p); + Warp->computeDenom(vX_testd,p); + Warp->warpX(vX_testd,vX_testd2,p); + std::cout<<2.*vX_testd2[0]<<","<<2.*vX_testd2[1]<<" <=> "<<vX_test2[0]<<","<<vX_test2[1]<<std::endl;*/ + + } + + for(int i=(int)nbLvlPyr-1;i>=0;i--) + { + if(i>=(int)l0Pyr) + { + templateSize=templateSizePyr[i]; + ptTemplate=ptTemplatePyr[i]; + ptTemplateSelect=ptTemplateSelectPyr[i]; + ptTemplateSupp=ptTemplateSuppPyr[i]; + ptTemplateCompo=ptTemplateCompoPyr[i]; + H=HdesirePyr[i]; + HLM=HLMdesirePyr[i]; + HLMdesireInverse=HLMdesireInversePyr[i]; +// zoneTracked=&zoneTrackedPyr[i]; + trackRobust(pyr_I[i]); + } + //std::cout<<"get p up"<<std::endl; +// ptemp=p_sauv[i-1]; + if (i > 0) { + Warp->getParamPyramidUp(p,ptemp); + p=ptemp; + zoneTracked=&zoneTrackedPyr[i-1]; + } + } +#if 0 + if(l0Pyr==0) + { + templateSize=templateSizePyr[0]; + ptTemplate=ptTemplatePyr[0]; + ptTemplateSelect=ptTemplateSelectPyr[0]; + ptTemplateSupp=ptTemplateSuppPyr[0]; + ptTemplateCompo=ptTemplateCompoPyr[0]; + H=HdesirePyr[0]; + HLM=HLMdesirePyr[0]; + HLMdesireInverse=HLMdesireInversePyr[0]; + zoneTracked=&zoneTrackedPyr[0]; + trackRobust(pyr_I[0]); + } + + if (l0Pyr > 0) { +// for (int l=(int)l0Pyr; l >=0; l--) { +// Warp->getParamPyramidUp(p,ptemp); +// p=ptemp; +// } + zoneTracked=&zoneTrackedPyr[0]; + } +#endif + // delete [] p_sauv; + } + else + { + //std::cout<<"reviens a tracker de base"<<std::endl; + trackRobust(I); + } + delete[] pyr_I; +} + +void vpTemplateTracker::trackRobust(const vpImage<unsigned char> &I) +{ + if(costFunctionVerification) + { + vpColVector p_pre_estimation;p_pre_estimation=p; + getGaussianBluredImage(I); + double pre_fcost=getCost(I,p); + + trackNoPyr(I); + + //std::cout<<"fct avant : "<<pre_fcost<<std::endl; + double post_fcost=getCost(I,p); + //std::cout<<"fct apres : "<<post_fcost<<std::endl<<std::endl; + if(pre_fcost<post_fcost) + p=p_pre_estimation; + } + else + trackNoPyr(I); + +} diff --git a/src/tracking/template-tracker/vpTemplateTracker.h b/src/tracking/template-tracker/vpTemplateTracker.h new file mode 100644 index 0000000000000000000000000000000000000000..1fbdeaacb8992fcf46b63fdc6084563dbe653021 --- /dev/null +++ b/src/tracking/template-tracker/vpTemplateTracker.h @@ -0,0 +1,219 @@ +/**************************************************************************** + * + * $Id: vpTemplateTracker.h 4648 2014-02-07 13:30:07Z ayol $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +/*! + \file vpTemplateTracker.h + \brief +*/ + +#ifndef vpTemplateTracker_hh +#define vpTemplateTracker_hh + +#include <math.h> + +#include <visp/vpTemplateTrackerHeader.h> +#include <visp/vpTemplateTrackerZone.h> +#include <visp/vpTemplateTrackerWarp.h> +#include <visp/vpImageFilter.h> + +class VISP_EXPORT vpTemplateTracker +{ + protected: + //traitement pyramidal + unsigned int nbLvlPyr; // If = 1, disable pyramidal usage + unsigned int l0Pyr; + bool pyrInitialised; + + vpTemplateTrackerPoint *ptTemplate; + vpTemplateTrackerPoint **ptTemplatePyr; + bool ptTemplateInit; + unsigned int templateSize; + unsigned int *templateSizePyr; + bool *ptTemplateSelect; + bool **ptTemplateSelectPyr; + bool ptTemplateSelectInit; + unsigned int templateSelectSize; + + #ifndef DOXYGEN_SHOULD_SKIP_THIS + vpTemplateTrackerPointSuppMIInv *ptTemplateSupp; //pour inverse et compo + vpTemplateTrackerPointSuppMIInv **ptTemplateSuppPyr; //pour inverse et compo + #endif + + vpTemplateTrackerPointCompo *ptTemplateCompo; //pour ESM + vpTemplateTrackerPointCompo **ptTemplateCompoPyr; //pour ESM + vpTemplateTrackerZone *zoneTracked; + vpTemplateTrackerZone *zoneTrackedPyr; + + vpImage<unsigned char> *pyr_IDes; + + vpMatrix H; + vpMatrix Hdesire; + vpMatrix *HdesirePyr; + vpMatrix HLM; + vpMatrix HLMdesire; + vpMatrix *HLMdesirePyr; + vpMatrix HLMdesireInverse; + vpMatrix *HLMdesireInversePyr; + vpColVector G; + + double gain; + double thresholdGradient; + bool costFunctionVerification; + bool blur; + bool useBrent; + unsigned int nbIterBrent; + unsigned int taillef; + double *fgG; + double *fgdG; + double ratioPixelIn; + int mod_i; + int mod_j;//variable de sampling de zone de reference + unsigned int nbParam ; + double lambdaDep ; + unsigned int iterationMax ; + //pour BFGS + unsigned int iterationGlobale; + //diverge is set to true if there is no more point in the tracked area + bool diverge; + unsigned int nbIteration; + bool useCompositionnal; + bool useInverse; + + vpTemplateTrackerWarp *Warp; + //Parametre de deplacement + vpColVector p; + vpColVector dp; + + //temporary values for warping + vpColVector X1; + vpColVector X2; + //temporary derivative matrix + vpMatrix dW; + + vpImage<double> BI; + vpImage<double> dIx ; + vpImage<double> dIy ; + vpTemplateTrackerZone zoneRef_; // Reference zone + + public: + vpTemplateTracker(vpTemplateTrackerWarp *_warp); + virtual ~vpTemplateTracker(); + + void display(const vpImage<unsigned char> &I, const vpColor& col = vpColor::green, const unsigned int thickness=3); + void display(const vpImage<vpRGBa> &I, const vpColor& col = vpColor::green, const unsigned int thickness=3); + + bool getDiverge() const {return diverge;} + vpColVector getdp(){ return dp; } + vpColVector getG() const { return G; } + vpMatrix getH() const { return H; } + unsigned int getNbParam() const { return nbParam ; } + unsigned int getNbIteration() const { return nbIteration; } + vpColVector getp() const { return p;} + double getRatioPixelIn() const {return ratioPixelIn;} + + /*! + + \return The pointer to the warper. + */ + vpTemplateTrackerWarp *getWarp() const {return Warp;} + + /*! + Return the reference template zone. + */ + vpTemplateTrackerZone getZoneRef() const { return zoneRef_; } + + void initClick(const vpImage<unsigned char> &I, bool delaunay=false); + void initFromPoints(const vpImage<unsigned char> &I, const std::vector< vpImagePoint > &v_ip, bool delaunay=false); + void initFromZone(const vpImage<unsigned char> &I, const vpTemplateTrackerZone& zone); + + void resetTracker(); + + void setBlur(bool b){blur = b;} + void setCostFunctionVerification(bool b){costFunctionVerification = b;} + void setGain(double g){gain=g;} + void setGaussianFilterSize(unsigned int new_taill); + void setHDes(vpMatrix &tH){ Hdesire=tH; vpMatrix::computeHLM(Hdesire,lambdaDep,HLMdesire); HLMdesireInverse = HLMdesire.inverseByLU();} + void setIterationMax(const unsigned int &n) { iterationMax = n ; } + void setLambda(double l) { lambdaDep = l ; } + void setNbIterBrent(const unsigned int &b){nbIterBrent=b;} + void setp(const vpColVector &tp){ p=tp; diverge=false; iterationGlobale=0; } + /*! + Set the number of pyramid levels used in the multi-resolution scheme. + If \e nlevels > 1, the tracker uses a pyramidal approach. + + \param nlevels: Number of pyramid levels. Algorithm starts at level nlevels-1. + \param level_to_stop: Last level of the pyramid that will be considered. (Lowest level is Zero) + */ + void setPyramidal(unsigned int nlevels=2, unsigned int level_to_stop=1) { + nbLvlPyr = nlevels; + l0Pyr = level_to_stop; + if(l0Pyr >= nlevels){ + std::cout << "Warning: level_to_stop: " << level_to_stop << " higher than level_to_start: " << nlevels-1 << " (nlevels-1)" <<std::endl; + std::cout << "Level to stop put to: " << nlevels-1 << std::endl; + l0Pyr = nlevels-1; + } + } + + void setSampling(int _mod_i,int _mod_j){mod_i=_mod_i;mod_j=_mod_j;} + void setThresholdGradient(double threshold){thresholdGradient=threshold;} + /*! By default Brent usage is disabled. */ + void setUseBrent(bool b){useBrent = b;} + + void track(const vpImage<unsigned char> &I); + void trackRobust(const vpImage<unsigned char> &I); + + protected: + + void computeOptimalBrentGain(const vpImage<unsigned char> &I,vpColVector &tp,double tMI,vpColVector &direction,double &alpha); + virtual double getCost(const vpImage<unsigned char> &I, vpColVector &tp) = 0; + void getGaussianBluredImage(const vpImage<unsigned char> &I){ vpImageFilter::filter(I, BI,fgG,taillef); } + void initCompInverse(const vpImage<unsigned char> &I); + virtual void initCompInversePyr(const vpImage<unsigned char> &I); + virtual void initHessienDesired(const vpImage<unsigned char> &I)=0; + virtual void initHessienDesiredPyr(const vpImage<unsigned char> &I); + virtual void initPyramidal(unsigned int nbLvl,unsigned int l0); + void initTracking(const vpImage<unsigned char>& I,vpTemplateTrackerZone &zone); + virtual void initTrackingPyr(const vpImage<unsigned char>& I,vpTemplateTrackerZone &zone); + virtual void trackNoPyr(const vpImage<unsigned char> &I) = 0; + virtual void trackPyr(const vpImage<unsigned char> &I); +}; +#endif + diff --git a/src/tracking/template-tracker/warp/vpTemplateTrackerWarp.cpp b/src/tracking/template-tracker/warp/vpTemplateTrackerWarp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7754a79b42c75d5940562b992519b079eeb5208d --- /dev/null +++ b/src/tracking/template-tracker/warp/vpTemplateTrackerWarp.cpp @@ -0,0 +1,163 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerWarp.cpp 4649 2014-02-07 14:57:11Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +#include <visp/vpTemplateTrackerWarp.h> + +void vpTemplateTrackerWarp::warpTriangle(const vpTemplateTrackerTriangle &in,const vpColVector &p, vpTemplateTrackerTriangle &out) +{ + vpColVector S1(2),S2(2),S3(2); + vpColVector rS1(2),rS2(2),rS3(2); + in.getCorners(S1,S2,S3); + computeDenom(S1,p); + warpX(S1,rS1,p); + computeDenom(S2,p); + warpX(S2,rS2,p); + computeDenom(S3,p); + warpX(S3,rS3,p); + out.init(rS1,rS2,rS3); +} +void vpTemplateTrackerWarp::warpZone(const vpTemplateTrackerZone &in,const vpColVector &p, vpTemplateTrackerZone &out) +{ + vpTemplateTrackerTriangle TR,TT; + out.clear(); + for(unsigned int i=0;i<in.getNbTriangle();i++) + { + in.getTriangle(i,TR); + warpTriangle(TR,p,TT); + out.add(TT); + } +} + +double vpTemplateTrackerWarp::getDistanceBetweenZoneAndWarpedZone(const vpTemplateTrackerZone &Z, const vpColVector &p) +{ + unsigned int nb_corners = Z.getNbTriangle() * 3; + computeCoeff(p); + vpColVector X1(2),X2(2); + + double res=0; + vpTemplateTrackerTriangle triangle; + for(unsigned int i=0;i<Z.getNbTriangle();i++) + { + Z.getTriangle(i, triangle); + for (unsigned int j=0; j<3; j++) { + triangle.getCorner(j, X1[0], X1[1]); + + computeDenom(X1,p); + warpX(X1,X2,p); + res+=sqrt((X2[0]-X1[0])*(X2[0]-X1[0])+(X2[1]-X1[1])*(X2[1]-X1[1])); + } + } + + return res/nb_corners; +} + +void vpTemplateTrackerWarp::warp(const double *ut0,const double *vt0,int nb_pt,const vpColVector& p,double *u,double *v) +{ + computeCoeff(p); + vpColVector X1(2),X2(2); + for(int i=0;i<nb_pt;i++) + { + X1[0]=ut0[i]; + X1[1]=vt0[i]; + computeDenom(X1,p); + warpX(X1,X2,p); + u[i]=X2[0]; + v[i]=X2[1]; + //std::cout<<"warp "<<X2[0]<<","<<X2[1]<<std::endl; + } +} + +#ifndef DOXYGEN_SHOULD_SKIP_THIS +void vpTemplateTrackerWarp::findWarp(const double *ut0,const double *vt0,const double *u,const double *v,int nb_pt,vpColVector& p) +{ + vpMatrix dW_(2,nbParam); + vpMatrix dX(2,1); + vpMatrix H(nbParam,nbParam), HLM(nbParam,nbParam); + vpMatrix G(nbParam,1); + + int cpt=0; + vpColVector X1(2); + vpColVector fX1(2); + vpColVector X2(2); + double erreur=0; + double erreur_prec; + double lambda=0.01; + do + { + erreur_prec=erreur; + H=0; + G=0; + erreur=0; + computeCoeff(p); + for(int i=0;i<nb_pt;i++) + { + X1[0]=ut0[i]; + X1[1]=vt0[i]; + computeDenom(X1,p); + warpX(X1,fX1,p); + dWarp(X1,fX1,p,dW_); + H+=dW_.AtA(); + + X2[0]=u[i]; + X2[1]=v[i]; + + dX=X2-fX1; + G+=dW_.t()*dX; + + erreur+=((u[i]-fX1[0])*(u[i]-fX1[0])+(v[i]-fX1[1])*(v[i]-fX1[1])); + + } + + vpMatrix::computeHLM(H, lambda, HLM); + try{ + p+=HLM.inverseByLU()*G; + } + catch(...) { + std::cout<<"Cannot inverse the matrix by LU " << std::endl; + break; + } + cpt++; + } + while((cpt<150)&&(sqrt((erreur_prec-erreur)*(erreur_prec-erreur))>1e-20)); + //std::cout<<"erreur apres transformation="<<erreur<<std::endl; +} +#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS + diff --git a/src/tracking/template-tracker/warp/vpTemplateTrackerWarp.h b/src/tracking/template-tracker/warp/vpTemplateTrackerWarp.h new file mode 100644 index 0000000000000000000000000000000000000000..74f527333effc53086fbd6602c4f2c287f0a4a7d --- /dev/null +++ b/src/tracking/template-tracker/warp/vpTemplateTrackerWarp.h @@ -0,0 +1,245 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerWarp.h 4632 2014-02-03 17:06:40Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +/*! + \file vpTemplateTrackerWarp.h + \brief +*/ + + +#ifndef vpTemplateTrackerWarp_hh +#define vpTemplateTrackerWarp_hh + +#include <visp/vpDisplay.h> +#include <visp/vpTemplateTrackerHeader.h> +#include <visp/vpTemplateTrackerTriangle.h> +#include <visp/vpTemplateTrackerZone.h> +#include <visp/vpTrackingException.h> + +class VISP_EXPORT vpTemplateTrackerWarp +{ + protected: + double denom; + vpMatrix dW; + unsigned int nbParam ; + + public: + //constructor; + vpTemplateTrackerWarp() : denom(1.), dW(), nbParam(0) {} + virtual ~vpTemplateTrackerWarp(){} + + #ifndef DOXYGEN_SHOULD_SKIP_THIS + virtual void computeCoeff(const vpColVector &p)=0; + virtual void computeDenom(vpColVector &vX, const vpColVector &ParamM)=0; + #endif + + /*! + Compute the derivative of the warping function according to its parameters. + + \param X1 : Point to consider in the derivative computation. + \param X2 : Point to consider in the derivative computation. + \param ParamM : Parameters of the warping function. + \param dW : Resulting derivative matrix. + */ + virtual void dWarp(const vpColVector &X1,const vpColVector &X2,const vpColVector &ParamM,vpMatrix &dW) = 0; + + /*! + Compute the compositionnal derivative of the warping function according to its parameters. + + \param X1 : Point to consider in the derivative computation. + \param X2 : Point to consider in the derivative computation. + \param ParamM : Parameters of the warping function. + \param dwdp0 : Derivative matrix of the warping function according to the initial warping function parameters (p=0). + \param dW : Resulting compositionnal derivative matrix. + */ + virtual void dWarpCompo(const vpColVector &X1,const vpColVector &X2,const vpColVector &ParamM,const double *dwdp0,vpMatrix &dW) = 0; + + #ifndef DOXYGEN_SHOULD_SKIP_THIS + void findWarp(const double *ut0,const double *vt0,const double *u,const double *v,int nb_pt,vpColVector& p); + #endif + + /*! + Compute the derivative of the image with relation to the warping function parameters. + + \param i : i coordinate (along the rows) of the point to consider in the image. + \param j : j coordinate (along the columns) of the point to consider in the image. + \param dy : Derivative on the y-axis (along the rows) of the point (i,j). + \param dx : Derivative on the x-axis (along the columns) of the point (i,j). + \param dIdW : Resulting derivative matrix (Image according to the warping function). + */ + virtual void getdW0(const int &i,const int &j,const double &dy,const double &dx,double *dIdW) = 0; + + /*! + Compute the derivative of the warping function according to the initial parameters. + + \param i : i coordinate (along the rows) of the point to consider in the image. + \param j : j coordinate (along the columns) of the point to consider in the image. + \param dIdW : Resulting derivative matrix (Image according to the warping function). + */ + virtual void getdWdp0(const int &i,const int &j,double *dIdW) = 0; + + /*! + Compute the distance between a zone and its associated warped zone. + + \param Z : Zone to consider. + \param p : Parameters of the warping function. + */ + double getDistanceBetweenZoneAndWarpedZone(const vpTemplateTrackerZone &Z,const vpColVector &p); + + /*! + Get the number of parameters of the warping function. + + \return Number of parameters. + */ + unsigned int getNbParam() const {return nbParam;} + + /*! + Get the inverse of the warping function parameters. + + \param ParamM : Parameters of the warping function. + \param ParamMinv : Inverse parameters. + */ + virtual void getParamInverse(const vpColVector &ParamM,vpColVector &ParamMinv) const = 0; + + /*! + Get the parameters of the warping function one level down. + + \param p : Current parameters of the warping function. + \param pdown : Resulting parameters on level down. + */ + virtual void getParamPyramidDown(const vpColVector &p,vpColVector &pdown) =0; + + /*! + Get the parameters of the warping function one level up. + + \param p : Current parameters of the warping function. + \param pup : Resulting parameters one level up. + */ + virtual void getParamPyramidUp(const vpColVector &p,vpColVector &pup) =0; + + /*! + Tells if the warping function is ESM compatible. + + \return True if it is ESM compatible, False otherwise. + */ + virtual bool isESMcompatible() const =0; + + /*! + Get the displacement resulting from the composition of two other displacements. + + \param p1 : First displacement. + \param p2 : Second displacement. + \param pres : Displacement resulting from the composition of p1 and p2. + */ + virtual void pRondp(const vpColVector &p1, const vpColVector &p2,vpColVector &pres) const = 0; + + /*! + Set the number of parameters of the warping function. + + \param nb : New number of parameters. + */ + void setNbParam(unsigned int nb){nbParam=nb;dW.resize(2,nbParam);} + + /*! + Warp a list of points. + + \param ut0 : List of u coordinates of the points. + \param vt0 : List of v coordinates of the points. + \param nb_pt : Number of points to consider. + \param p : Parameters of the warp. + \param u : Resulting u coordinates. + \param v : resulting v coordinates. + */ + void warp(const double *ut0,const double *vt0,int nb_pt,const vpColVector& p,double *u,double *v); + + /*! + Warp a point. + + \param i : i coordinate (along the rows) of the point to warp. + \param j : j coordinate (along the columns) of the point to warp. + \param i2 : i coordinate (along the rows) of the warped point. + \param j2 : j coordinate (along the columns) of the warped point. + \param ParamM : Parameters of the warp. + */ + virtual void warpX(const int &i, const int &j,double &i2,double &j2, const vpColVector &ParamM) = 0; + + /*! + Warp a point. + + \param vX : Coordinates of the point to warp. + \param vXres : Coordinates of the warped point. + \param ParamM : Parameters of the warping function. + */ + virtual void warpX(const vpColVector &vX,vpColVector &vXres,const vpColVector &ParamM) = 0; + + /*! + Inverse Warp a point. + + \param vX : Coordinates of the point to warp. + \param vXres : Coordinates of the warped point. + \param ParamM : Parameters of the warping function. + */ + virtual void warpXInv(const vpColVector &vX,vpColVector &vXres,const vpColVector &ParamM) = 0; + + /*! + Warp a triangle and store the result in a new zone. + + \param in : Triangle to warp. + \param p : Parameters of the warping function. These parameters are estimated by the template + tracker and returned using vpTemplateTracker::getp(). + \param out : Resulting triangle. + */ + void warpTriangle(const vpTemplateTrackerTriangle &in,const vpColVector &p, vpTemplateTrackerTriangle &out); + + /*! + Warp a zone and store the result in a new zone. + + \param in : Zone to warp. + \param p : Parameters of the warping function. These parameters are estimated by the template + tracker and returned using vpTemplateTracker::getp(). + \param out : Resulting zone. + */ + void warpZone(const vpTemplateTrackerZone &in,const vpColVector &p, vpTemplateTrackerZone &out); + +}; + +#endif + diff --git a/src/tracking/template-tracker/warp/vpTemplateTrackerWarpAffine.cpp b/src/tracking/template-tracker/warp/vpTemplateTrackerWarpAffine.cpp new file mode 100644 index 0000000000000000000000000000000000000000..078f13cf5450ad857909bd922e7b28feb0affaca --- /dev/null +++ b/src/tracking/template-tracker/warp/vpTemplateTrackerWarpAffine.cpp @@ -0,0 +1,172 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerWarpAffine.cpp 4649 2014-02-07 14:57:11Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +#include <visp/vpTemplateTrackerWarpAffine.h> + + +vpTemplateTrackerWarpAffine::vpTemplateTrackerWarpAffine() +{ + nbParam = 6 ; + dW.resize(2,nbParam); +} + +//get the parameter corresponding to the lower level of a gaussian pyramid +void vpTemplateTrackerWarpAffine::getParamPyramidDown(const vpColVector &p,vpColVector &pdown) +{ + pdown=p; + pdown[4]=p[4]/2.; + pdown[5]=p[5]/2.; +} + +void vpTemplateTrackerWarpAffine::getParamPyramidUp(const vpColVector &p,vpColVector &pup) +{ + pup=p; + pup[4]=p[4]*2.; + pup[5]=p[5]*2.; +} +/*calcul de di*dw(x,p0)/dp +*/ +void vpTemplateTrackerWarpAffine::getdW0(const int &i,const int &j,const double &dy,const double &dx,double *dIdW) +{ + dIdW[0]=j*dx; + dIdW[1]=j*dy; + dIdW[2]=i*dx; + dIdW[3]=i*dy; + dIdW[4]=dx; + dIdW[5]=dy; +} +/*calcul de dw(x,p0)/dp +*/ +void vpTemplateTrackerWarpAffine::getdWdp0(const int &i,const int &j,double *dIdW) +{ + dIdW[0]=j; + dIdW[1]=0; + dIdW[2]=i; + dIdW[3]=0; + dIdW[4]=1.; + dIdW[5]=0; + + dIdW[6]=0; + dIdW[7]=j; + dIdW[8]=0; + dIdW[9]=i; + dIdW[10]=0; + dIdW[11]=1.; +} + +void vpTemplateTrackerWarpAffine::warpX(const int &i, const int &j,double &i2,double &j2, const vpColVector &ParamM) +{ + j2=(1+ParamM[0])*j+ParamM[2]*i+ParamM[4]; + i2=ParamM[1]*j+(1+ParamM[3])*i+ParamM[5]; +} + + +void vpTemplateTrackerWarpAffine::warpX(const vpColVector &vX,vpColVector &vXres,const vpColVector &ParamM) +{ + vXres[0]=(1.0+ParamM[0])*vX[0]+ParamM[2]*vX[1]+ParamM[4]; + vXres[1]=ParamM[1]*vX[0]+(1.0+ParamM[3])*vX[1]+ParamM[5]; +} + +void vpTemplateTrackerWarpAffine::dWarp(const vpColVector &X1,const vpColVector &/*X2*/,const vpColVector &/*ParamM*/,vpMatrix &dW_) +{ + double j=X1[0]; + double i=X1[1]; + dW_=0; + dW_[0][0]=j;dW_[0][2]=i;dW_[0][4]=1; + dW_[1][1]=j;dW_[1][3]=i;dW_[1][5]=1; +} + +/*compute dw=dw/dx*dw/dp +*/ +void vpTemplateTrackerWarpAffine::dWarpCompo(const vpColVector &/*X1*/,const vpColVector &/*X2*/,const vpColVector &ParamM, + const double *dwdp0, vpMatrix &dW_) +{ + for(unsigned int i=0;i<nbParam;i++) + { + dW_[0][i]=(1.+ParamM[0])*dwdp0[i]+ParamM[2]*dwdp0[i+nbParam]; + dW_[1][i]=ParamM[1]*dwdp0[i]+(1.+ParamM[3])*dwdp0[i+nbParam]; + } +} + +void vpTemplateTrackerWarpAffine::warpXInv(const vpColVector &vX,vpColVector &vXres,const vpColVector &ParamM) +{ + vXres[0]=(1+ParamM[0])*vX[0]+ParamM[2]*vX[1]+ParamM[4]; + vXres[1]=ParamM[1]*vX[0]+(1+ParamM[3])*vX[1]+ParamM[5]; +} +void vpTemplateTrackerWarpAffine::getParamInverse(const vpColVector &ParamM,vpColVector &ParamMinv) const +{ + vpColVector Trans(2); + vpMatrix MWrap(2,2); + Trans[0]=ParamM[4];Trans[1]=ParamM[5]; + MWrap[0][0]=1+ParamM[0];MWrap[0][1]=ParamM[2]; + MWrap[1][0]=ParamM[1];MWrap[1][1]=1+ParamM[3]; + + vpMatrix MWrapInv(2,2);MWrapInv=MWrap.inverseByLU(); + vpColVector TransInv(2);TransInv=-1*MWrapInv*Trans; + + ParamMinv[0]=MWrapInv[0][0]-1;ParamMinv[2]=MWrapInv[0][1]; + ParamMinv[1]=MWrapInv[1][0];ParamMinv[3]=MWrapInv[1][1]-1; + ParamMinv[4]=TransInv[0];ParamMinv[5]=TransInv[1]; +} + +void vpTemplateTrackerWarpAffine::pRondp(const vpColVector &p1, const vpColVector &p2,vpColVector &pres) const +{ + vpColVector Trans1(2); + vpMatrix MWrap1(2,2); + Trans1[0]=p1[4];Trans1[1]=p1[5]; + MWrap1[0][0]=1+p1[0];MWrap1[0][1]=p1[2]; + MWrap1[1][0]=p1[1];MWrap1[1][1]=1+p1[3]; + + vpColVector Trans2(2); + vpMatrix MWrap2(2,2); + Trans2[0]=p2[4];Trans2[1]=p2[5]; + MWrap2[0][0]=1+p2[0];MWrap2[0][1]=p2[2]; + MWrap2[1][0]=p2[1];MWrap2[1][1]=1+p2[3]; + + vpColVector TransRes(2); + vpMatrix MWrapRes(2,2); + TransRes=MWrap1*Trans2+Trans1; + MWrapRes=MWrap1*MWrap2; + + pres[0]=MWrapRes[0][0]-1;pres[2]=MWrapRes[0][1]; + pres[1]=MWrapRes[1][0];pres[3]=MWrapRes[1][1]-1; + pres[4]=TransRes[0];pres[5]=TransRes[1]; +} diff --git a/src/tracking/template-tracker/warp/vpTemplateTrackerWarpAffine.h b/src/tracking/template-tracker/warp/vpTemplateTrackerWarpAffine.h new file mode 100644 index 0000000000000000000000000000000000000000..0c60a29fe2c3940df995be5ae6a2d8e79b82a2d6 --- /dev/null +++ b/src/tracking/template-tracker/warp/vpTemplateTrackerWarpAffine.h @@ -0,0 +1,175 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerWarpAffine.h 4607 2014-01-21 16:02:11Z ayol $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +/*! + \file vpTemplateTrackerWarpAffine.h + \brief Affine warping function: w(X)=AX+b with: A=[[1+p0, p2], [p1, 1+p3]] and b= [p4, p5]] +*/ + + +#ifndef vpTemplateTrackerWarpAffine_hh +#define vpTemplateTrackerWarpAffine_hh + +#include <visp/vpTemplateTrackerWarp.h> + + +class VISP_EXPORT vpTemplateTrackerWarpAffine: public vpTemplateTrackerWarp +{ + public: + //constructor; + vpTemplateTrackerWarpAffine(); + + #ifndef DOXYGEN_SHOULD_SKIP_THIS + void computeCoeff(const vpColVector &/*p*/){} + void computeDenom(vpColVector &/*vX*/, const vpColVector &/*ParamM*/){} + #endif + + /*! + Compute the derivative of the warping function according to its parameters. + + \param X1 : Point to consider in the derivative computation. + \param X2 : Point to consider in the derivative computation. + \param ParamM : Parameters of the warping function. + \param dW : Resulting derivative matrix. + */ + void dWarp(const vpColVector &X1,const vpColVector &X2,const vpColVector &ParamM,vpMatrix &dW); + + /*! + Compute the compositionnal derivative of the warping function according to its parameters. + + \param X1 : Point to consider in the derivative computation. + \param X2 : Point to consider in the derivative computation. + \param ParamM : Parameters of the warping function. + \param dwdp0 : Derivative matrix of the warping function according to the initial warping function parameters (p=0). + \param dW : Resulting compositionnal derivative matrix. + */ + void dWarpCompo(const vpColVector &X1,const vpColVector &X2,const vpColVector &ParamM,const double *dwdp0,vpMatrix &dW); + + /*! + Compute the derivative of the image with relation to the warping function parameters. + + \param i : i coordinate (along the rows) of the point to consider in the image. + \param j : j coordinate (along the columns) of the point to consider in the image. + \param dy : Derivative on the y-axis (along the rows) of the point (i,j). + \param dx : Derivative on the x-axis of the point (i,j). + \param dIdW : Resulting derivative matrix (Image according to the warping function). + */ + void getdW0(const int &i,const int &j,const double &dy,const double &dx,double *dIdW); + + /*! + Compute the derivative of the warping function according to the initial parameters. + + \param i : i coordinate (along the rows) of the point to consider in the image. + \param j : j coordinate (along the columns) of the point to consider in the image. + \param dIdW : Resulting derivative matrix (Image according to the warping function). + */ + void getdWdp0(const int &i,const int &j,double *dIdW); + + /*! + Get the inverse of the warping function parameters. + + \param ParamM : Parameters of the warping function. + \param ParamMinv : Inverse parameters. + */ + void getParamInverse(const vpColVector &ParamM,vpColVector &ParamMinv) const; + + /*! + Get the parameters of the warping function one level down. + + \param p : Current parameters of the warping function. + \param pdown : Resulting parameters on level down. + */ + void getParamPyramidDown(const vpColVector &p,vpColVector &pdown); + + /*! + Get the parameters of the warping function one level up. + + \param p : Current parameters of the warping function. + \param pup : Resulting parameters one level up. + */ + void getParamPyramidUp(const vpColVector &p,vpColVector &pup); + + /*! + Tells if the warping function is ESM compatible. + + \return True if it is ESM compatible, False otherwise. + */ + bool isESMcompatible() const {return false;} + + /*! + Get the displacement resulting from the composition of two other displacements. + + \param p1 : First displacement. + \param p2 : Second displacement. + \param pres : Displacement resulting from the composition of p1 and p2. + */ + void pRondp(const vpColVector &p1, const vpColVector &p2,vpColVector &pres) const; + + /*! + Warp a point. + + \param vX : Coordinates of the point to warp. + \param vXres : Coordinates of the warped point. + \param ParamM : Parameters of the warping function. + */ + void warpX(const vpColVector &vX,vpColVector &vXres,const vpColVector &ParamM); + + /*! + Warp a point. + + \param i : i coordinate (along the rows) of the point to warp. + \param j : j coordinate (along the columns) of the point to warp. + \param i2 : i coordinate (along the columns) of the warped point. + \param j2 : j coordinate (along the columns) of the warped point. + \param ParamM : Parameters of the warping function. + */ + void warpX(const int &i,const int &j,double &i2,double &j2,const vpColVector &ParamM); + + /*! + Inverse Warp a point. + + \param vX : Coordinates of the point to warp. + \param vXres : Coordinates of the warped point. + \param ParamM : Parameters of the warping function. + */ + void warpXInv(const vpColVector &vX,vpColVector &vXres,const vpColVector &ParamM); +}; +#endif diff --git a/src/tracking/template-tracker/warp/vpTemplateTrackerWarpHomography.cpp b/src/tracking/template-tracker/warp/vpTemplateTrackerWarpHomography.cpp new file mode 100644 index 0000000000000000000000000000000000000000..46ad0f129a1e08276bbb2be49e924dca0be4a460 --- /dev/null +++ b/src/tracking/template-tracker/warp/vpTemplateTrackerWarpHomography.cpp @@ -0,0 +1,221 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerWarpHomography.cpp 4649 2014-02-07 14:57:11Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +#include <visp/vpTemplateTrackerWarpHomography.h> +#include <visp/vpTrackingException.h> + +vpTemplateTrackerWarpHomography::vpTemplateTrackerWarpHomography() +{ + nbParam = 8 ; + dW.resize(2,nbParam); +} + +//get the parameter corresponding to the lower level of a gaussian pyramid +void vpTemplateTrackerWarpHomography::getParamPyramidDown(const vpColVector &p,vpColVector &pdown) +{ + pdown=p; + pdown[2]=p[2]*2.; + pdown[5]=p[5]*2.; + pdown[6]=p[6]/2.; + pdown[7]=p[7]/2.; +} + +void vpTemplateTrackerWarpHomography::getParamPyramidUp(const vpColVector &p,vpColVector &pup) +{ + pup=p; + pup[2]=p[2]/2.; + pup[5]=p[5]/2.; + pup[6]=p[6]*2.; + pup[7]=p[7]*2.; +} + +/*calcul de di*dw(x,p0)/dp */ +void vpTemplateTrackerWarpHomography::getdW0(const int &i,const int &j,const double &dy,const double &dx,double *dIdW) +{ + dIdW[0]=j*dx; + dIdW[1]=j*dy; + dIdW[2]=-j*j*dx-i*j*dy; + dIdW[3]=i*dx; + dIdW[4]=i*dy; + dIdW[5]=-i*j*dx-i*i*dy; + dIdW[6]=dx; + dIdW[7]=dy; +} +/*calcul de dw(x,p0)/dp */ +void vpTemplateTrackerWarpHomography::getdWdp0(const int &i,const int &j,double *dIdW) +{ + dIdW[0]=j; + dIdW[1]=0; + dIdW[2]=-j*j; + dIdW[3]=i; + dIdW[4]=0; + dIdW[5]=-i*j; + dIdW[6]=1.; + dIdW[7]=0; + + dIdW[8]=0; + dIdW[9]=j; + dIdW[10]=-i*j; + dIdW[11]=0; + dIdW[12]=i; + dIdW[13]=-i*i; + dIdW[14]=0; + dIdW[15]=1.; +} +void vpTemplateTrackerWarpHomography::computeDenom(vpColVector &vX, const vpColVector &ParamM) +{ + denom=(1./(ParamM[2]*vX[0]+ParamM[5]*vX[1]+1.)); +} + +void vpTemplateTrackerWarpHomography::warpX(const int &i,const int &j,double &i2,double &j2,const vpColVector &ParamM) +{ + j2=((1.+ParamM[0])*j+ParamM[3]*i+ParamM[6])*denom; + i2=(ParamM[1]*j+(1.+ParamM[4])*i+ParamM[7])*denom; +} + + +void vpTemplateTrackerWarpHomography::warpX(const vpColVector &vX,vpColVector &vXres,const vpColVector &ParamM) +{ + //if((ParamM[2]*vX[0]+ParamM[5]*vX[1]+1)>0)//si dans le plan image reel + if((denom)>0)// FS optimisation + { + vXres[0]=((1+ParamM[0])*vX[0]+ParamM[3]*vX[1]+ParamM[6])*denom; + vXres[1]=(ParamM[1]*vX[0]+(1+ParamM[4])*vX[1]+ParamM[7])*denom; + } + else + throw(vpTrackingException(vpTrackingException::fatalError,"Division by zero in vpTemplateTrackerWarpHomography::warpX()")); +} + +void vpTemplateTrackerWarpHomography::dWarp(const vpColVector &X1,const vpColVector &X2,const vpColVector &/*ParamM*/,vpMatrix &dW_) +{ + double j=X1[0]; + double i=X1[1]; + dW_=0; + dW_[0][0]=j*denom; + dW_[0][2]=-j*X2[0]*denom; + dW_[0][3]=i*denom; + dW_[0][5]=-i*X2[0]*denom; + dW_[0][6]=denom; + + dW_[1][1]=j*denom; + dW_[1][2]=-j*X2[1]*denom; + dW_[1][4]=i*denom; + dW_[1][5]=-i*X2[1]*denom; + dW_[1][7]=denom; +} + +/*compute dw=dw/dx*dw/dp */ +void vpTemplateTrackerWarpHomography::dWarpCompo(const vpColVector &/*X1*/,const vpColVector &X2,const vpColVector &ParamM, + const double *dwdp0,vpMatrix &dW_) +{ + double dwdx0,dwdx1; + double dwdy0,dwdy1; + + dwdx0=((1.+ParamM[0])-X2[0]*ParamM[2])*denom; + dwdx1=(ParamM[1]-X2[1]*ParamM[2])*denom; + dwdy0=(ParamM[3]-X2[0]*ParamM[5])*denom; + dwdy1=((1.+ParamM[4])-X2[1]*ParamM[5])*denom; + for(unsigned int i=0;i<nbParam;i++) + { + dW_[0][i]=dwdx0*dwdp0[i]+dwdy0*dwdp0[i+nbParam]; + dW_[1][i]=dwdx1*dwdp0[i]+dwdy1*dwdp0[i+nbParam]; + } +} + +void vpTemplateTrackerWarpHomography::warpXInv(const vpColVector &vX,vpColVector &vXres,const vpColVector &ParamM) +{ + + if((ParamM[2]*vX[0]+ParamM[5]*vX[1]+1)<0)//si dans le plan image reel + { + vXres[0]=((1+ParamM[0])*vX[0]+ParamM[3]*vX[1]+ParamM[6])/(ParamM[2]*vX[0]+ParamM[5]*vX[1]+1); + vXres[1]=(ParamM[1]*vX[0]+(1+ParamM[4])*vX[1]+ParamM[7])/(ParamM[2]*vX[0]+ParamM[5]*vX[1]+1); + } + else + throw(vpTrackingException(vpTrackingException::fatalError,"Division by zero in vpTemplateTrackerWarpHomography::warpXSpecialInv()")) ; +} +void vpTemplateTrackerWarpHomography::getParamInverse(const vpColVector &ParamM,vpColVector &ParamMinv) const +{ + vpHomography H = getHomography(ParamM); + vpHomography Hinv = H.inverse(); + getParam(Hinv, ParamMinv); +} + + +vpHomography vpTemplateTrackerWarpHomography::getHomography(const vpColVector &ParamM) const +{ + vpHomography H; + for(unsigned int i=0;i<3;i++) + for(unsigned int j=0;j<3;j++) + { + if(i+3*j!=8) + { + H[i][j]=ParamM[i+3*j]; + if(i==j)H[i][j]++; + } + else + H[i][j]=1.; + } + + return H; +} +void vpTemplateTrackerWarpHomography::getParam(const vpHomography &H,vpColVector &par) const +{ + par=0; + for(unsigned int i=0;i<3;i++) + for(unsigned int j=0;j<3;j++) + { + if(i+3*j!=8) + { + par[i+3*j]=H[i][j]/H[2][2]; + if(i==j)par[i+3*j]--; + } + } +} + + + +void vpTemplateTrackerWarpHomography::pRondp(const vpColVector &p1, const vpColVector &p2,vpColVector &pres) const +{ + vpHomography H1 = getHomography(p1); + vpHomography H2 = getHomography(p2); + vpHomography H = H1*H2; + getParam(H,pres); +} diff --git a/src/tracking/template-tracker/warp/vpTemplateTrackerWarpHomography.h b/src/tracking/template-tracker/warp/vpTemplateTrackerWarpHomography.h new file mode 100644 index 0000000000000000000000000000000000000000..58201ab16a0c311a947ce93cabd121003e4f7fbf --- /dev/null +++ b/src/tracking/template-tracker/warp/vpTemplateTrackerWarpHomography.h @@ -0,0 +1,200 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerWarpHomography.h 4607 2014-01-21 16:02:11Z ayol $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +/*! + \file vpTemplateTrackerWarpHomography.h + \brief warping function of an homography: the homography is directly defined by the diplacement parameter: H=[[1+p0, p3, p6], [p1, 1+p4, p7], [p2, p5, 1]] +*/ + + +#ifndef vpTemplateTrackerWarpHomography_hh +#define vpTemplateTrackerWarpHomography_hh + +#include <visp/vpTemplateTrackerWarp.h> +#include <visp/vpHomography.h> + + +class VISP_EXPORT vpTemplateTrackerWarpHomography: public vpTemplateTrackerWarp +{ + public: + //constructor; + vpTemplateTrackerWarpHomography(); + + #ifndef DOXYGEN_SHOULD_SKIP_THIS + void computeCoeff(const vpColVector &/*p*/){} + #endif + + /*! + Compute the projection denominator (Z) used in x = X/Z and y = Y/Z. + + \param vX : Point to consider + \param ParamM : parameters of the warping function. + */ + void computeDenom(vpColVector &vX, const vpColVector &ParamM); + + /*! + Compute the derivative of the warping function according to its parameters. + + \param X1 : Point to consider in the derivative computation. + \param X2 : Point to consider in the derivative computation. + \param ParamM : Parameters of the warping function. + \param dW : Resulting derivative matrix. + */ + void dWarp(const vpColVector &X1,const vpColVector &X2,const vpColVector &ParamM,vpMatrix &dW); + + /*! + Compute the compositionnal derivative of the warping function according to its parameters. + + \param X1 : Point to consider in the derivative computation. + \param X2 : Point to consider in the derivative computation. + \param ParamM : Parameters of the warping function. + \param dwdp0 : Derivative matrix of the warping function according to the initial warping function parameters (p=0). + \param dW : Resulting compositionnal derivative matrix. + */ + void dWarpCompo(const vpColVector &X1,const vpColVector &X2,const vpColVector &ParamM,const double *dwdp0,vpMatrix &dW); + + /*! + Compute the derivative of the image with relation to the warping function parameters. + + \param i : i coordinate (along the rows) of the point to consider in the image. + \param j : j coordinate (along the columns) of the point to consider in the image. + \param dy : Derivative on the y-axis (along the rows) of the point (i,j). + \param dx : Derivative on the x-axis (along the columns) of the point (i,j). + \param dIdW : Resulting derivative matrix (Image according to the warping function). + */ + void getdW0(const int &i,const int &j,const double &dy,const double &dx,double *dIdW); + + /*! + Compute the derivative of the warping function according to the initial parameters. + + \param i : i coordinate (along the rows) of the point to consider in the image. + \param j : j coordinate (along the columns) of the point to consider in the image. + \param dIdW : Resulting derivative matrix (Image according to the warping function). + */ + void getdWdp0(const int &i,const int &j,double *dIdW); + + /*! + Return the homography defined by the given parameters + + \param ParamM : Parameters of the homography. + + \return An Homography via vpHomography. + */ + vpHomography getHomography(const vpColVector &ParamM) const; + + /*! + Compute the parameters of the homography warping function according to the given vpHomography + + \param H : Homography used to compute the parameters. + \param par : Resulting warping function parameters. + */ + void getParam(const vpHomography &H,vpColVector &par) const; + + /*! + Get the inverse of the warping function parameters. + + \param ParamM : Parameters of the warping function. + \param ParamMinv : Inverse parameters. + */ + void getParamInverse(const vpColVector &ParamM,vpColVector &ParamMinv) const; + + /*! + Get the parameters of the warping function one level down. + + \param p : Current parameters of the warping function. + \param pdown : Resulting parameters on level down. + */ + void getParamPyramidDown(const vpColVector &p,vpColVector &pdown); + + /*! + Get the parameters of the warping function one level up. + + \param p : Current parameters of the warping function. + \param pup : Resulting parameters one level up. + */ + void getParamPyramidUp(const vpColVector &p,vpColVector &pup); + + /*! + Tells if the warping function is ESM compatible. + + \return True if it is ESM compatible, False otherwise. + */ + bool isESMcompatible() const {return false;} + + /*! + Get the displacement resulting from the composition of two other displacements. + + \param p1 : First displacement. + \param p2 : Second displacement. + \param pres : Displacement resulting from the composition of p1 and p2. + */ + void pRondp(const vpColVector &p1, const vpColVector &p2,vpColVector &pres) const ; + + /*! + Warp a point. + + \param vX : Coordinates of the point to warp. + \param vXres : Coordinates of the warped point. + \param ParamM : Parameters of the warping function. + */ + void warpX(const vpColVector &vX,vpColVector &vXres,const vpColVector &ParamM); + + /*! + Warp a point. + + \param i : i coordinate (along the rows) of the point to warp. + \param j : j coordinate (along the columns) of the point to warp. + \param i2 : i coordinate (along the rows) of the warped point. + \param j2 : j coordinate (along the columns) of the warped point. + \param ParamM : Parameters of the warping function. + */ + void warpX(const int &i,const int &j,double &i2,double &j2,const vpColVector &ParamM); + + /*! + Inverse Warp a point. + + \param vX : Coordinates of the point to warp. + \param vXres : Coordinates of the warped point. + \param ParamM : Parameters of the warping function. + */ + void warpXInv(const vpColVector &vX,vpColVector &vXres,const vpColVector &ParamM); +}; +#endif diff --git a/src/tracking/template-tracker/warp/vpTemplateTrackerWarpHomographySL3.cpp b/src/tracking/template-tracker/warp/vpTemplateTrackerWarpHomographySL3.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3e667651f9ca76e0071dca9af3775c06fa5420a1 --- /dev/null +++ b/src/tracking/template-tracker/warp/vpTemplateTrackerWarpHomographySL3.cpp @@ -0,0 +1,402 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerWarpHomographySL3.cpp 4669 2014-02-16 16:25:57Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +#include <visp/vpTemplateTrackerWarpHomographySL3.h> + +//findWarp special a SL3 car methode additionnelle ne marche pas (la derivee n est calculable qu en p=0) +// => resout le probleme de maniere compositionnelle +void vpTemplateTrackerWarpHomographySL3::findWarp(const double *ut0,const double *vt0, + const double *u, const double *v,int nb_pt,vpColVector& p) +{ + //std::cout<<"findWarp OVERLOADE"<<std::endl; + vpColVector dp(nbParam); + vpMatrix dW_(2,nbParam); + vpMatrix dX(2,1); + vpMatrix H(nbParam,nbParam), HLM(nbParam,nbParam); + vpMatrix G_(nbParam,1); + + //vpMatrix *dW_ddp0=new vpMatrix[nb_pt]; + double **dW_ddp0=new double*[(unsigned int)nb_pt]; + for(int i=0;i<nb_pt;i++) + { + //dW_ddp0[i].resize(2,nbParam); + dW_ddp0[i]=new double[2*nbParam]; + //getdWdp0(vt0[i],ut0[i],dW_ddp0[i]); + //std::cout<<"findWarp"<<v[i]<<","<<u[i]<<std::endl; + getdWdp0(v[i],u[i],dW_ddp0[i]); + } + + int cpt=0; + vpColVector X1(2); + vpColVector fX1(2); + vpColVector X2(2); + double erreur=0; + double erreur_prec; + double lambda=0.00001; + do + { + erreur_prec=erreur; + H=0; + G_=0; + erreur=0; + computeCoeff(p); + for(int i=0;i<nb_pt;i++) + { + X1[0]=ut0[i]; + X1[1]=vt0[i]; + computeDenom(X1,p); + warpX(X1,fX1,p); + //dWarpCompo(X1,fX1,p,dW_ddp0[i],dW); + //dWarp(X1,fX1,p,dW); + for(unsigned int ip=0;ip<nbParam;ip++) + { + dW_[0][ip]=dW_ddp0[i][ip]; + dW_[1][ip]=dW_ddp0[i][ip+nbParam]; + } + + H+=dW_.AtA(); + + X2[0]=u[i]; + X2[1]=v[i]; + + dX=X2-fX1; + G_+=dW_.t()*dX; + + erreur+=((u[i]-fX1[0])*(u[i]-fX1[0])+(v[i]-fX1[1])*(v[i]-fX1[1])); + } + + vpMatrix::computeHLM(H, lambda, HLM); + try{ + dp=HLM.inverseByLU()*G_; + } + catch(...){ + std::cout<<"Cannot inverse the matrix by LU "<<std::endl; + break; + } + pRondp(p,dp,p); + + cpt++; + // std::cout<<"erreur ="<<erreur<<std::endl; + } + //while((cpt<1500)); + while((cpt<150)&&(sqrt((erreur_prec-erreur)*(erreur_prec-erreur))>1e-20)); + + //std::cout<<"erreur apres transformation="<<erreur<<std::endl; + for(int i=0;i<nb_pt;i++) + delete[] dW_ddp0[i]; + delete[] dW_ddp0; + +} + +vpTemplateTrackerWarpHomographySL3::vpTemplateTrackerWarpHomographySL3() + : G(), dGx(), A() +{ + nbParam = 8 ; + G.resize(3,3); + dGx.resize(3,nbParam); + + A.resize(8); + for(unsigned int i=0;i<8;i++) + { + A[i].resize(3,3); + A[i]=0; + } + A[0][0][2]=1; + A[1][1][2]=1; + A[2][0][1]=1; + A[3][1][0]=1; + A[4][0][0]=1; + A[4][1][1]=-1; + A[5][1][1]=-1; + A[5][2][2]=1; + A[6][2][0]=1; + A[7][2][1]=1; +} + +vpTemplateTrackerWarpHomographySL3::~vpTemplateTrackerWarpHomographySL3() +{ +} + +//get the parameter corresponding to the lower level of a gaussian pyramid +//a refaire de facon analytique +void vpTemplateTrackerWarpHomographySL3::getParamPyramidDown(const vpColVector &p,vpColVector &pdown) +{ + double *u,*v;u=new double[4];v=new double[4]; + //u[0]=0;v[0]=0;u[1]=640;v[1]=0;u[2]=640;v[2]=480;u[3]=0;v[3]=480; + u[0]=0;v[0]=0;u[1]=160;v[1]=0;u[2]=160;v[2]=120;u[3]=0;v[3]=120; + double *u2,*v2;u2=new double[4];v2=new double[4]; + warp(u,v,4,p,u2,v2); + //p=0;findWarp(u,v,u2,v2,4,p); + for(int i=0;i<4;i++) + { + u[i]=u[i]/2.; + v[i]=v[i]/2.; + u2[i]=u2[i]/2.; + v2[i]=v2[i]/2.; + //std::cout<<"recherche "<<u2[i]<<","<<v2[i]<<std::endl; + } + pdown=p; + findWarp(u,v,u2,v2,4,pdown); + delete[] u; + delete[] v; + delete[] u2; + delete[] v2; +} + +void vpTemplateTrackerWarpHomographySL3::getParamPyramidUp(const vpColVector &p,vpColVector &pup) +{ + double *u,*v;u=new double[4];v=new double[4]; + //u[0]=0;v[0]=0;u[1]=640;v[1]=0;u[2]=640;v[2]=480;u[3]=0;v[3]=480; + u[0]=0;v[0]=0;u[1]=160;v[1]=0;u[2]=160;v[2]=120;u[3]=0;v[3]=120; + //u[0]=40;v[0]=30;u[1]=160;v[1]=30;u[2]=160;v[2]=120;u[3]=40;v[3]=120; + double *u2,*v2;u2=new double[4];v2=new double[4]; + + //pup=p; + + /*vpColVector ptest=pup; + warp(u,v,4,ptest,u2,v2); + for(int i=0;i<4;i++) + std::cout<<"test "<<u2[i]<<","<<v2[i]<<std::endl;*/ + + warp(u,v,4,p,u2,v2); + //p=0;findWarp(u,v,u2,v2,4,p); + + + for(int i=0;i<4;i++) + { + u[i]=u[i]*2.; + v[i]=v[i]*2.; + u2[i]=u2[i]*2.; + v2[i]=v2[i]*2.; + /*std::cout<<"#########################################################################################"<<std::endl; + std::cout<<"#########################################################################################"<<std::endl; + std::cout<<"#########################################################################################"<<std::endl; + std::cout<<"recherche "<<u2[i]<<","<<v2[i]<<std::endl;*/ + } + findWarp(u,v,u2,v2,4,pup); + + delete[] u; + delete[] v; + delete[] u2; + delete[] v2; +} + +void vpTemplateTrackerWarpHomographySL3::computeDenom(vpColVector &vX, const vpColVector &/*ParamM*/) +{ + denom=vX[0]*G[2][0]+vX[1]*G[2][1]+G[2][2]; +} + +void vpTemplateTrackerWarpHomographySL3::computeCoeff(const vpColVector &p) +{ + vpMatrix pA(3,3); + pA[0][0]=p[4]; + pA[0][1]=p[2]; + pA[0][2]=p[0]; + + pA[1][0]=p[3]; + pA[1][1]=-p[4]-p[5]; + pA[1][2]=p[1]; + + pA[2][0]=p[6]; + pA[2][1]=p[7]; + pA[2][2]=p[5]; + + G=pA.expm(); +} + + +void vpTemplateTrackerWarpHomographySL3::warpX(const vpColVector &vX,vpColVector &vXres,const vpColVector &/*ParamM*/) +{ + double i=vX[1],j=vX[0]; + vXres[0]=(j*G[0][0]+i*G[0][1]+G[0][2])/denom; + vXres[1]=(j*G[1][0]+i*G[1][1]+G[1][2])/denom; +} +void vpTemplateTrackerWarpHomographySL3::warpX(const int &i,const int &j,double &i2,double &j2,const vpColVector &/*ParamM*/) +{ + j2=(j*G[0][0]+i*G[0][1]+G[0][2])/denom; + i2=(j*G[1][0]+i*G[1][1]+G[1][2])/denom; +} + +vpHomography vpTemplateTrackerWarpHomographySL3::getHomography() const +{ + vpHomography H; + for (unsigned int i=0; i<3; i++) + for (unsigned int j=0; j<3; j++) + H[i][j] = G[i][j]; + return H; +} + +void vpTemplateTrackerWarpHomographySL3::dWarp(const vpColVector &X1,const vpColVector &X2,const vpColVector &/*ParamM*/,vpMatrix &dW_) +{ + vpMatrix dhdx(2,3); + dhdx=0; + dhdx[0][0]=1./denom;dhdx[1][1]=1./denom;dhdx[0][2]=-X2[0]/(denom);dhdx[1][2]=-X2[1]/(denom); + dGx=0; + for(unsigned int i=0;i<3;i++) + { + dGx[i][0]=G[i][0]; + dGx[i][1]=G[i][1]; + dGx[i][2]=G[i][0]*X1[1]; + dGx[i][3]=G[i][1]*X1[0]; + dGx[i][4]=G[i][0]*X1[0]-G[i][1]*X1[1]; + dGx[i][5]=G[i][2]-G[i][1]*X1[1]; + dGx[i][6]=G[i][2]*X1[0]; + dGx[i][7]=G[i][2]*X1[1]; + } + dW_=dhdx*dGx; + +} + +/*calcul de di*dw(x,p0)/dp +*/ +void vpTemplateTrackerWarpHomographySL3::getdW0(const int &i,const int &j,const double &dy,const double &dx,double *dIdW) +{ + vpMatrix dhdx(1,3); + dhdx=0; + dhdx[0][0]=dx;dhdx[0][1]=dy;dhdx[0][2]=-j*dx-i*dy; + G.setIdentity(); + + dGx=0; + for(unsigned int par=0;par<3;par++) + { + dGx[par][0]=G[par][0]; + dGx[par][1]=G[par][1]; + dGx[par][2]=G[par][0]*i; + dGx[par][3]=G[par][1]*j; + dGx[par][4]=G[par][0]*j-G[par][1]*i; + dGx[par][5]=G[par][2]-G[par][1]*i; + dGx[par][6]=G[par][2]*j; + dGx[par][7]=G[par][2]*i; + } + + for(unsigned int par=0;par<nbParam;par++) + { + double res=0; + for(unsigned int par2=0;par2<3;par2++) + res+=dhdx[0][par2]*dGx[par2][par]; + dIdW[par]=res; + } + +} +/*calcul de dw(x,p0)/dp +*/ + +void vpTemplateTrackerWarpHomographySL3::getdWdp0(const int &i,const int &j,double *dIdW) +{ + vpMatrix dhdx(2,3); + dhdx=0; + dhdx[0][0]=1.;dhdx[1][1]=1.;dhdx[0][2]=-j;dhdx[1][2]=-i; + G.setIdentity(); + + dGx=0; + for(unsigned int par=0;par<3;par++) + { + dGx[par][0]=G[par][0]; + dGx[par][1]=G[par][1]; + dGx[par][2]=G[par][0]*i; + dGx[par][3]=G[par][1]*j; + dGx[par][4]=G[par][0]*j-G[par][1]*i; + dGx[par][5]=G[par][2]-G[par][1]*i; + dGx[par][6]=G[par][2]*j; + dGx[par][7]=G[par][2]*i; + } + vpMatrix dIdW_temp(2,nbParam); + dIdW_temp=dhdx*dGx; + + for(unsigned int par=0;par<nbParam;par++) + { + dIdW[par]=dIdW_temp[0][par]; + dIdW[par+nbParam]=dIdW_temp[1][par]; + } + +} +void vpTemplateTrackerWarpHomographySL3::getdWdp0(const double &i,const double &j,double *dIdW) +{ + vpMatrix dhdx(2,3); + dhdx=0; + dhdx[0][0]=1.;dhdx[1][1]=1.;dhdx[0][2]=-j;dhdx[1][2]=-i; + G.setIdentity(); + + dGx=0; + for(unsigned int par=0;par<3;par++) + { + dGx[par][0]=G[par][0]; + dGx[par][1]=G[par][1]; + dGx[par][2]=G[par][0]*i; + dGx[par][3]=G[par][1]*j; + dGx[par][4]=G[par][0]*j-G[par][1]*i; + dGx[par][5]=G[par][2]-G[par][1]*i; + dGx[par][6]=G[par][2]*j; + dGx[par][7]=G[par][2]*i; + } + vpMatrix dIdW_temp(2,nbParam); + dIdW_temp=dhdx*dGx; + + for(unsigned int par=0;par<nbParam;par++) + { + dIdW[par]=dIdW_temp[0][par]; + dIdW[par+nbParam]=dIdW_temp[1][par]; + } + +} +/*compute dw=dw/dx*dw/dp +*/ + +void vpTemplateTrackerWarpHomographySL3::dWarpCompo(const vpColVector &/*X1*/,const vpColVector &X2,const vpColVector &/*ParamM*/, + const double *dwdp0,vpMatrix &dW_) +{ + for(unsigned int i=0;i<nbParam;i++) + { + dW_[0][i]=denom*((G[0][0]-X2[0]*G[2][0])*dwdp0[i]+(G[0][1]-X2[0]*G[2][1])*dwdp0[i+nbParam]); + dW_[1][i]=denom*((G[1][0]-X2[1]*G[2][0])*dwdp0[i]+(G[1][1]-X2[1]*G[2][1])*dwdp0[i+nbParam]); + } +} + +void vpTemplateTrackerWarpHomographySL3::getParamInverse(const vpColVector &ParamM,vpColVector &ParamMinv) const +{ + ParamMinv=-ParamM; +} +void vpTemplateTrackerWarpHomographySL3::pRondp(const vpColVector &p1, const vpColVector &p2,vpColVector &pres) const +{ + //vrai que si commutatif ... + pres=p1+p2; +} + diff --git a/src/tracking/template-tracker/warp/vpTemplateTrackerWarpHomographySL3.h b/src/tracking/template-tracker/warp/vpTemplateTrackerWarpHomographySL3.h new file mode 100644 index 0000000000000000000000000000000000000000..43adff0e036df23a51d9b2f56ec02eab7e6e9453 --- /dev/null +++ b/src/tracking/template-tracker/warp/vpTemplateTrackerWarpHomographySL3.h @@ -0,0 +1,216 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerWarpHomographySL3.h 4669 2014-02-16 16:25:57Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +/*! + \file vpTemplateTrackerWarpHomographySL3.h + \brief warping function of an homography: the homography is defined on the sl3 lie algebra H=exp(Sum(p[i]* A_i)) A_i is the basis of the SL3 Algebra +*/ + + +#ifndef vpTemplateTrackerWarpHomographySL3_hh +#define vpTemplateTrackerWarpHomographySL3_hh + +#include <vector> + +#include <visp/vpTemplateTrackerWarp.h> +#include <visp/vpHomography.h> + +class VISP_EXPORT vpTemplateTrackerWarpHomographySL3: public vpTemplateTrackerWarp +{ + protected: + vpMatrix G; + vpMatrix dGx; + std::vector<vpMatrix> A; + + public: + //constructor; + vpTemplateTrackerWarpHomographySL3(); + ~vpTemplateTrackerWarpHomographySL3(); + + /*! + Compute the exponential of the homography matrix defined by the given parameters + + \param p : Parameters of the SL3 homography warping function. + */ + void computeCoeff(const vpColVector &p); + + /*! + Compute the projection denominator (Z) used in x = X/Z and y = Y/Z. + + \param vX : Point to consider + \param ParamM : parameters of the warping function. + */ + void computeDenom(vpColVector &vX, const vpColVector &ParamM); + + /*! + Compute the derivative of the warping function according to its parameters. + + \param X1 : Point to consider in the derivative computation. + \param X2 : Point to consider in the derivative computation. + \param ParamM : Parameters of the warping function. + \param dW : Resulting derivative matrix. + */ + void dWarp(const vpColVector &X1,const vpColVector &X2,const vpColVector &ParamM,vpMatrix &dW); + + /*! + Compute the compositionnal derivative of the warping function according to its parameters. + + \param X1 : Point to consider in the derivative computation. + \param X2 : Point to consider in the derivative computation. + \param ParamM : Parameters of the warping function. + \param dwdp0 : Derivative matrix of the warping function according to the initial warping function parameters (p=0). + \param dW : Resulting compositionnal derivative matrix. + */ + void dWarpCompo(const vpColVector &X1,const vpColVector &X2,const vpColVector &ParamM,const double *dwdp0,vpMatrix &dW); + + /*! + Find the displacement/warping function parameters from a list of points. + + \param ut0 : Original u coordinates. + \param vt0 : Original v coordinates. + \param u : Warped u coordinates. + \param v : Warped v coordinates. + \param nb_pt : Number of points. + \param p : Resulting warping function parameters. + */ + void findWarp(const double *ut0,const double *vt0,const double *u,const double *v,int nb_pt,vpColVector& p); + + /*! + Compute the derivative of the image with relation to the warping function parameters. + + \param i : i coordinate (along the rows) of the point to consider in the image. + \param j : j coordinate (along the columns) of the point to consider in the image. + \param dy : Derivative on the y-axis (along the rows) of the point (i,j). + \param dx : Derivative on the x-axis (along the columns) of the point (i,j). + \param dIdW : Resulting derivative matrix (Image according to the warping function). + */ + void getdW0(const int &i,const int &j,const double &dy,const double &dx,double *dIdW); + + /*! + Compute the derivative of the warping function according to the initial parameters. + + \param i : i coordinate (along the rows) of the point to consider in the image. + \param j : j coordinate (along the columns) of the point to consider in the image. + \param dIdW : Resulting derivative matrix (Image according to the warping function). + */ + void getdWdp0(const int &i,const int &j,double *dIdW); + + /*! + Compute the derivative of the warping function according to the initial parameters. + + \param i : i coordinate (along the rows) of the point to consider in the image. + \param j : j coordinate (along the columns) of the point to consider in the image. + \param dIdW : Resulting derivative matrix (Image according to the warping function). + */ + void getdWdp0(const double &i, const double &j,double *dIdW); + + /*! + Return the homography defined by the warping function + + \return An Homography via vpHomography. + */ + vpHomography getHomography() const; + + /*! + Get the inverse of the warping function parameters. + + \param ParamM : Parameters of the warping function. + \param ParamMinv : Inverse parameters. + */ + void getParamInverse(const vpColVector &ParamM,vpColVector &ParamMinv) const; + + /*! + Get the parameters of the warping function one level down. + + \param p : Current parameters of the warping function. + \param pdown : Resulting parameters on level down. + */ + void getParamPyramidDown(const vpColVector &p,vpColVector &pdown); + + /*! + Get the parameters of the warping function one level up. + + \param p : Current parameters of the warping function. + \param pup : Resulting parameters one level up. + */ + void getParamPyramidUp(const vpColVector &p,vpColVector &pup); + + /*! + Tells if the warping function is ESM compatible. + + \return True if it is ESM compatible, False otherwise. + */ + bool isESMcompatible() const {return true;} + + /*! + Get the displacement resulting from the composition of two other displacements. + + \param p1 : First displacement. + \param p2 : Second displacement. + \param pres : Displacement resulting from the composition of p1 and p2. + */ + void pRondp(const vpColVector &p1, const vpColVector &p2,vpColVector &pres) const; + + /*! + Warp a point. + + \param vX : Coordinates of the point to warp. + \param vXres : Coordinates of the warped point. + \param ParamM : Parameters of the warping function. + */ + void warpX(const vpColVector &vX,vpColVector &vXres,const vpColVector &ParamM); + + /*! + Warp a point. + + \param i : i coordinate (along the rows) of the point to warp. + \param j : j coordinate (along the columns) of the point to warp. + \param i2 : i coordinate (along the rows) of the warped point. + \param j2 : j coordinate (along the columns) of the warped point. + \param ParamM : Parameters of the warping function. + */ + void warpX(const int &i,const int &j,double &i2,double &j2,const vpColVector &ParamM); + + #ifndef DOXYGEN_SHOULD_SKIP_THIS + void warpXInv(const vpColVector &/*vX*/,vpColVector &/*vXres*/,const vpColVector &/*ParamM*/) {} + #endif +}; +#endif diff --git a/src/tracking/template-tracker/warp/vpTemplateTrackerWarpSRT.cpp b/src/tracking/template-tracker/warp/vpTemplateTrackerWarpSRT.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6913eff1e994820747d9922b72c84afd8eb59104 --- /dev/null +++ b/src/tracking/template-tracker/warp/vpTemplateTrackerWarpSRT.cpp @@ -0,0 +1,188 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerWarpSRT.cpp 4649 2014-02-07 14:57:11Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +#include <visp/vpTemplateTrackerWarpSRT.h> + + +vpTemplateTrackerWarpSRT::vpTemplateTrackerWarpSRT() +{ + nbParam = 4 ; + dW.resize(2,nbParam); +} + +//get the parameter corresponding to the lower level of a gaussian pyramid +void vpTemplateTrackerWarpSRT::getParamPyramidDown(const vpColVector &p,vpColVector &pdown) +{ + pdown=p; + pdown[2]=p[2]/2.; + pdown[3]=p[3]/2.; +} + +void vpTemplateTrackerWarpSRT::getParamPyramidUp(const vpColVector &p,vpColVector &pup) +{ + pup=p; + pup[2]=p[2]*2.; + pup[3]=p[3]*2.; +} +/*calcul de di*dw(x,p0)/dp +*/ +void vpTemplateTrackerWarpSRT::getdW0(const int &i,const int &j,const double &dy,const double &dx,double *dIdW) +{ + // std::cout << "getdW0" << std::endl; + dIdW[0]=j*dx + i*dy; + dIdW[1]=-i*dx + j*dy; + dIdW[2]=dx; + dIdW[3]=dy; +} +/*calcul de dw(x,p0)/dp +*/ +void vpTemplateTrackerWarpSRT::getdWdp0(const int &i,const int &j,double *dIdW) +{ + dIdW[0]=j; + dIdW[1]=-i; + dIdW[2]=1.; + dIdW[3]=0; + + dIdW[4]=i; + dIdW[5]=j; + dIdW[6]=0; + dIdW[7]=1.; +} + +void vpTemplateTrackerWarpSRT::warpX(const int &i,const int &j,double &i2,double &j2,const vpColVector &ParamM) +{ + j2=((1.0+ParamM[0])*cos(ParamM[1])*j) - ((1.0+ParamM[0])*sin(ParamM[1])*i) + ParamM[2]; + i2=((1.0+ParamM[0])*sin(ParamM[1])*j) + ((1.0+ParamM[0])*cos(ParamM[1])*i) + ParamM[3]; +} + + +void vpTemplateTrackerWarpSRT::warpX(const vpColVector &vX,vpColVector &vXres,const vpColVector &ParamM) +{ + vXres[0]=((1.0+ParamM[0])*cos(ParamM[1])*vX[0]) - ((1.0+ParamM[0])*sin(ParamM[1])*vX[1]) + ParamM[2]; + vXres[1]=((1.0+ParamM[0])*sin(ParamM[1])*vX[0]) + ((1.0+ParamM[0])*cos(ParamM[1])*vX[1]) + ParamM[3]; +} + +void vpTemplateTrackerWarpSRT::dWarp(const vpColVector &X1,const vpColVector &/*X2*/,const vpColVector &ParamM,vpMatrix &dW_) +{ + double j=X1[0]; + double i=X1[1]; + dW_=0; + dW_[0][0]=cos(ParamM[1])*j - sin(ParamM[1])*i; + dW_[0][1]=(-(1.0+ParamM[0])*sin(ParamM[1])*j) - ((1.0+ParamM[0])*cos(ParamM[1])*i); + dW_[0][2]=1; + + dW_[1][0]=sin(ParamM[1])*j + cos(ParamM[1])*i; + dW_[1][1]=(1.0+ParamM[0])*cos(ParamM[1])*j - (1.0+ParamM[0])*sin(ParamM[1])*i; + dW_[1][3]=1; +} + +/*compute dw=dw/dx*dw/dp +*/ +void vpTemplateTrackerWarpSRT::dWarpCompo(const vpColVector &/*X1*/,const vpColVector &/*X2*/,const vpColVector &ParamM, + const double *dwdp0,vpMatrix &dW_) +{ + for(unsigned int i=0;i<nbParam;i++) + { + dW_[0][i]=((1.+ParamM[0])*cos(ParamM[1])*dwdp0[i]) - ((1.0+ParamM[0])*sin(ParamM[1])*dwdp0[i+nbParam]); + dW_[1][i]=((1.+ParamM[0])*sin(ParamM[1])*dwdp0[i]) + ((1.0+ParamM[0])*cos(ParamM[1])*dwdp0[i+nbParam]); + } +} + +void vpTemplateTrackerWarpSRT::warpXInv(const vpColVector &vX,vpColVector &vXres,const vpColVector &ParamM) +{ + // std::cout << "warpXspe" << std::endl; + vXres[0]=((1.0+ParamM[0])*cos(ParamM[1])*vX[0]) - ((1.0+ParamM[0])*sin(ParamM[1])*vX[1]) + ParamM[2]; + vXres[1]=((1.0+ParamM[0])*sin(ParamM[1])*vX[0]) + ((1.0+ParamM[0])*cos(ParamM[1])*vX[1]) + ParamM[3]; +} + +void vpTemplateTrackerWarpSRT::getParamInverse(const vpColVector &ParamM,vpColVector &ParamMinv) const +{ + vpColVector Trans(2); + vpMatrix MWrap(2,2); + Trans[0]=ParamM[2]; + Trans[1]=ParamM[3]; + MWrap[0][0]=cos(ParamM[1]); + MWrap[0][1]=-sin(ParamM[1]); + MWrap[1][0]=sin(ParamM[1]); + MWrap[1][1]=cos(ParamM[1]); + + vpMatrix MWrapInv(2,2); + MWrapInv=MWrap.transpose(); + vpColVector TransInv(2); + TransInv=(-1.0/(1.0+ParamM[0]))*MWrapInv*Trans; + + ParamMinv[0]=1.0/(1.0+ParamM[0]) - 1.0; + ParamMinv[1]= atan2(MWrapInv[1][0],MWrapInv[1][1]); + ParamMinv[2]=TransInv[0]; + ParamMinv[3]=TransInv[1]; +} + +void vpTemplateTrackerWarpSRT::pRondp(const vpColVector &p1, const vpColVector &p2,vpColVector &pres) const +{ + vpColVector Trans1(2); + vpMatrix MWrap1(2,2); + Trans1[0]=p1[2];Trans1[1]=p1[3]; + + MWrap1[0][0]=cos(p1[1]); + MWrap1[0][1]=-sin(p1[1]); + MWrap1[1][0]=sin(p1[1]); + MWrap1[1][1]=cos(p1[1]); + + vpColVector Trans2(2); + vpMatrix MWrap2(2,2); + Trans2[0]=p2[2];Trans2[1]=p2[3]; + + MWrap2[0][0]=cos(p2[1]); + MWrap2[0][1]=-sin(p2[1]); + MWrap2[1][0]=sin(p2[1]); + MWrap2[1][1]=cos(p2[1]); + + vpColVector TransRes(2); + vpMatrix MWrapRes(2,2); + TransRes=(1.0+p1[0])*MWrap1*Trans2+Trans1; + MWrapRes=MWrap1*MWrap2; + + pres[0]=(1.0+p1[0])*(1.0+p2[0]) - 1.0; + pres[1]=atan2(MWrapRes[1][0],MWrapRes[1][1]); + + pres[2]=TransRes[0]; + pres[3]=TransRes[1]; +} diff --git a/src/tracking/template-tracker/warp/vpTemplateTrackerWarpSRT.h b/src/tracking/template-tracker/warp/vpTemplateTrackerWarpSRT.h new file mode 100644 index 0000000000000000000000000000000000000000..08f7d50e9008891583b92bdc30362133fac49b94 --- /dev/null +++ b/src/tracking/template-tracker/warp/vpTemplateTrackerWarpSRT.h @@ -0,0 +1,174 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerWarpSRT.h 4607 2014-01-21 16:02:11Z ayol $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +/*! + \file vpTemplateTrackerWarpSRT.h + \brief sRt warping function +*/ + + +#ifndef vpTemplateTrackerWarpSRT_hh +#define vpTemplateTrackerWarpSRT_hh + +#include <visp/vpTemplateTrackerWarp.h> + +class VISP_EXPORT vpTemplateTrackerWarpSRT: public vpTemplateTrackerWarp +{ + public: + //constructor; + vpTemplateTrackerWarpSRT(); + + #ifndef DOXYGEN_SHOULD_SKIP_THIS + void computeCoeff(const vpColVector &/*p*/){} + void computeDenom(vpColVector &/*vX*/, const vpColVector &/*ParamM*/){} + #endif + + /*! + Compute the derivative of the warping function according to its parameters. + + \param X1 : Point to consider in the derivative computation. + \param X2 : Point to consider in the derivative computation. + \param ParamM : Parameters of the warping function. + \param dW : Resulting derivative matrix. + */ + void dWarp(const vpColVector &X1,const vpColVector &X2,const vpColVector &ParamM,vpMatrix &dW); + + /*! + Compute the compositionnal derivative of the warping function according to its parameters. + + \param X1 : Point to consider in the derivative computation. + \param X2 : Point to consider in the derivative computation. + \param ParamM : Parameters of the warping function. + \param dwdp0 : Derivative matrix of the warping function according to the initial warping function parameters (p=0). + \param dW : Resulting compositionnal derivative matrix. + */ + void dWarpCompo(const vpColVector &X1,const vpColVector &X2,const vpColVector &ParamM,const double *dwdp0,vpMatrix &dW); + + /*! + Compute the derivative of the image with relation to the warping function parameters. + + \param i : i coordinate (along the rows) of the point to consider in the image. + \param j : j coordinate (along the columns) of the point to consider in the image. + \param dy : Derivative on the y-axis (along the rows) of the point (i,j). + \param dx : Derivative on the x-axis (along the columns) of the point (i,j). + \param dIdW : Resulting derivative matrix (Image according to the warping function). + */ + void getdW0(const int &i,const int &j,const double &dy,const double &dx,double *dIdW); + + /*! + Compute the derivative of the warping function according to the initial parameters. + + \param i : i coordinate (along the rows) of the point to consider in the image. + \param j : j coordinate (along the columns) of the point to consider in the image. + \param dIdW : Resulting derivative matrix (Image according to the warping function). + */ + void getdWdp0(const int &i,const int &j,double *dIdW); + + /*! + Get the inverse of the warping function parameters. + + \param ParamM : Parameters of the warping function. + \param ParamMinv : Inverse parameters. + */ + void getParamInverse(const vpColVector &ParamM,vpColVector &ParamMinv) const; + + /*! + Get the parameters of the warping function one level down. + + \param p : Current parameters of the warping function. + \param pdown : Resulting parameters on level down. + */ + void getParamPyramidDown(const vpColVector &p,vpColVector &pdown); + + /*! + Get the parameters of the warping function one level up. + + \param p : Current parameters of the warping function. + \param pup : Resulting parameters one level up. + */ + void getParamPyramidUp(const vpColVector &p,vpColVector &pup); + + /*! + Tells if the warping function is ESM compatible. + + \return True if it is ESM compatible, False otherwise. + */ + bool isESMcompatible() const {return false;} + + /*! + Get the displacement resulting from the composition of two other displacements. + + \param p1 : First displacement. + \param p2 : Second displacement. + \param pres : Displacement resulting from the composition of p1 and p2. + */ + void pRondp(const vpColVector &p1, const vpColVector &p2,vpColVector &pres) const; + + /*! + Warp a point. + + \param vX : Coordinates of the point to warp. + \param vXres : Coordinates of the warped point. + \param ParamM : Parameters of the warping function. + */ + void warpX(const vpColVector &vX,vpColVector &vXres,const vpColVector &ParamM); + + /*! + Warp a point. + + \param i : i coordinate (along the rows) of the point to warp. + \param j : j coordinate (along the columns) of the point to warp. + \param i2 : i coordinate (along the rows) of the warped point. + \param j2 : j coordinate (along the columns) of the warped point. + \param ParamM : Parameters of the warping function. + */ + void warpX(const int &i,const int &j,double &i2,double &j2,const vpColVector &ParamM); + + /*! + Inverse Warp a point. + + \param vX : Coordinates of the point to warp. + \param vXres : Coordinates of the warped point. + \param ParamM : Parameters of the warping function. + */ + void warpXInv(const vpColVector &vX,vpColVector &vXres,const vpColVector &ParamM); +}; +#endif diff --git a/src/tracking/template-tracker/warp/vpTemplateTrackerWarpTranslation.cpp b/src/tracking/template-tracker/warp/vpTemplateTrackerWarpTranslation.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d61f8fc065cf516b8066b984d548d75603adf836 --- /dev/null +++ b/src/tracking/template-tracker/warp/vpTemplateTrackerWarpTranslation.cpp @@ -0,0 +1,129 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerWarpTranslation.cpp 4649 2014-02-07 14:57:11Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +#include <visp/vpTemplateTrackerWarpTranslation.h> + +vpTemplateTrackerWarpTranslation::vpTemplateTrackerWarpTranslation() +{ + nbParam = 2 ; + dW.resize(2,nbParam); +} + + +//get the parameter corresponding to the lower level of a gaussian pyramid +void vpTemplateTrackerWarpTranslation::getParamPyramidDown(const vpColVector &p,vpColVector &pdown) +{ + pdown[0]=p[0]/2.; + pdown[1]=p[1]/2.; +} + +void vpTemplateTrackerWarpTranslation::getParamPyramidUp(const vpColVector &p,vpColVector &pup) +{ + pup[0]=p[0]*2.; + pup[1]=p[1]*2.; +} + +/*calcul de di*dw(x,p0)/dp +*/ +void vpTemplateTrackerWarpTranslation::getdW0(const int &/*i*/,const int &/*j*/,const double &dy,const double &dx,double *dIdW) +{ + dIdW[0]=dx; + dIdW[1]=dy; +} +/*calcul de dw(x,p0)/dp +*/ +void vpTemplateTrackerWarpTranslation::getdWdp0(const int &/*i*/,const int &/*j*/,double *dIdW) +{ + dIdW[0]=1.; + dIdW[1]=0; + + dIdW[2]=0; + dIdW[3]=1.; +} + +void vpTemplateTrackerWarpTranslation::warpX(const int &i,const int &j,double &i2,double &j2,const vpColVector &ParamM) +{ + j2=j+ParamM[0]; + i2=i+ParamM[1]; +} + + +void vpTemplateTrackerWarpTranslation::warpX(const vpColVector &vX,vpColVector &vXres,const vpColVector &ParamM) +{ + vXres[0]=vX[0]+ParamM[0]; + vXres[1]=vX[1]+ParamM[1]; +} + +void vpTemplateTrackerWarpTranslation::dWarp(const vpColVector &/*X1*/,const vpColVector &/*X2*/,const vpColVector &/*ParamM*/, + vpMatrix &dW_) +{ + dW_[0][0]=1;dW_[0][1]=0; + dW_[1][0]=0;dW_[1][1]=1; +} + +/*compute dw=dw/dx*dw/dp +*/ +void vpTemplateTrackerWarpTranslation::dWarpCompo(const vpColVector &/*X1*/,const vpColVector &/*X2*/,const vpColVector &/*ParamM*/, + const double *dwdp0,vpMatrix &dW_) +{ + for(unsigned int i=0;i<nbParam;i++) + { + dW_[0][i]=dwdp0[i]; + dW_[1][i]=dwdp0[i+nbParam]; + } +} + +void vpTemplateTrackerWarpTranslation::warpXInv(const vpColVector &vX,vpColVector &vXres,const vpColVector &ParamM) +{ + vXres[0]=vX[0]+ParamM[0]; + vXres[1]=vX[1]+ParamM[1]; +} +void vpTemplateTrackerWarpTranslation::getParamInverse(const vpColVector &ParamM,vpColVector &ParamMinv) const +{ + ParamMinv[0]=-ParamM[0]; + ParamMinv[1]=-ParamM[1]; +} + +void vpTemplateTrackerWarpTranslation::pRondp(const vpColVector &p1, const vpColVector &p2,vpColVector &pres) const +{ + pres[0]=p1[0]+p2[0]; + pres[1]=p1[1]+p2[1]; +} diff --git a/src/tracking/template-tracker/warp/vpTemplateTrackerWarpTranslation.h b/src/tracking/template-tracker/warp/vpTemplateTrackerWarpTranslation.h new file mode 100644 index 0000000000000000000000000000000000000000..61a705fd92d1618f4ba614aea2f5dcdc9abea9c7 --- /dev/null +++ b/src/tracking/template-tracker/warp/vpTemplateTrackerWarpTranslation.h @@ -0,0 +1,175 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerWarpTranslation.h 4607 2014-01-21 16:02:11Z ayol $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +/*! + \file vpTemplateTrackerWarpTranslation.h + \brief Translation warping function: w(X)=X+b with: b= [p0, p1]] +*/ + + +#ifndef vpTemplateTrackerWarpTranslation_hh +#define vpTemplateTrackerWarpTranslation_hh + +#include <visp/vpTemplateTrackerWarp.h> + + +class VISP_EXPORT vpTemplateTrackerWarpTranslation: public vpTemplateTrackerWarp +{ + public: + //constructor; + vpTemplateTrackerWarpTranslation(); + + #ifndef DOXYGEN_SHOULD_SKIP_THIS + void computeCoeff(const vpColVector &/*p*/){} + void computeDenom(vpColVector &/*vX*/, const vpColVector &/*ParamM*/){} + #endif + + /*! + Compute the derivative of the warping function according to its parameters. + + \param X1 : Point to consider in the derivative computation. + \param X2 : Point to consider in the derivative computation. + \param ParamM : Parameters of the warping function. + \param dW : Resulting derivative matrix. + */ + void dWarp(const vpColVector &X1,const vpColVector &X2,const vpColVector &ParamM,vpMatrix &dW); + + /*! + Compute the compositionnal derivative of the warping function according to its parameters. + + \param X1 : Point to consider in the derivative computation. + \param X2 : Point to consider in the derivative computation. + \param ParamM : Parameters of the warp. + \param dwdp0 : Derivative matrix of the warping function according to the initial warping function parameters (p=0). + \param dW : Resulting compositionnal derivative matrix. + */ + void dWarpCompo(const vpColVector &X1,const vpColVector &X2,const vpColVector &ParamM,const double *dwdp0,vpMatrix &dW); + + /*! + Compute the derivative of the image with relation to the warping function parameters. + + \param i : i coordinate (along the rows) of the point to consider in the image. + \param j : j coordinate (along the columns) of the point to consider in the image. + \param dy : Derivative on the y-axis (along the rows) of the point (i,j). + \param dx : Derivative on the x-axis (along the columns) of the point (i,j). + \param dIdW : Resulting derivative matrix (Image according to the warping function). + */ + void getdW0(const int &i,const int &j,const double &dy,const double &dx,double *dIdW); + + /*! + Compute the derivative of the warping function according to the initial parameters. + + \param i : i coordinate (along the rows) of the point to consider in the image. + \param j : j coordinate (along the columns) of the point to consider in the image. + \param dIdW : Resulting derivative matrix (Image according to the warping function). + */ + void getdWdp0(const int &i,const int &j,double *dIdW); + + /*! + Get the inverse of the warping function parameters. + + \param ParamM : Parameters of the warping function. + \param ParamMinv : Inverse parameters. + */ + void getParamInverse(const vpColVector &ParamM,vpColVector &ParamMinv) const ; + + /*! + Get the parameters of the warping function one level down. + + \param p : Current parameters of the warping function. + \param pdown : Resulting parameters on level down. + */ + void getParamPyramidDown(const vpColVector &p,vpColVector &pdown); + + /*! + Get the parameters of the warping function one level up. + + \param p : Current parameters of the warping function. + \param pup : Resulting parameters one level up. + */ + void getParamPyramidUp(const vpColVector &p,vpColVector &pup); + + /*! + Tells if the warping function is ESM compatible. + + \return True if it is ESM compatible, False otherwise. + */ + bool isESMcompatible() const {return true;} + + /*! + Get the displacement resulting from the composition of two other displacements. + + \param p1 : First displacement. + \param p2 : Second displacement. + \param pres : Displacement resulting from the composition of p1 and p2. + */ + void pRondp(const vpColVector &p1, const vpColVector &p2,vpColVector &pres) const ; + + /*! + Warp a point. + + \param vX : Coordinates of the point to warp. + \param vXres : Coordinates of the warped point. + \param ParamM : Parameters of the warping function. + */ + void warpX(const vpColVector &vX,vpColVector &vXres,const vpColVector &ParamM); + + /*! + Warp a point. + + \param i : i coordinate (along the rows) of the point to warp. + \param j : j coordinate (along the columns) of the point to warp. + \param i2 : i coordinate (along the rows) of the warped point. + \param j2 : j coordinate (along the columns) of the warped point. + \param ParamM : Parameters of the warping function. + */ + void warpX(const int &i,const int &j,double &i2,double &j2,const vpColVector &ParamM); + + /*! + Inverse Warp a point. + + \param vX : Coordinates of the point to warp. + \param vXres : Coordinates of the warped point. + \param ParamM : Parameters of the warping function. + */ + void warpXInv(const vpColVector &vX,vpColVector &vXres,const vpColVector &ParamM); +}; +#endif diff --git a/src/tracking/template-tracker/zncc/vpTemplateTrackerZNCC.cpp b/src/tracking/template-tracker/zncc/vpTemplateTrackerZNCC.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d8e866f1647c2fe329245e977954ee191d8a0ce6 --- /dev/null +++ b/src/tracking/template-tracker/zncc/vpTemplateTrackerZNCC.cpp @@ -0,0 +1,134 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerZNCC.cpp 4666 2014-02-16 16:21:33Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +#include <visp/vpTemplateTrackerZNCC.h> + +vpTemplateTrackerZNCC::vpTemplateTrackerZNCC(vpTemplateTrackerWarp *warp) + : vpTemplateTracker(warp), DI(), temp() +{ + dW.resize(2,nbParam); + G.resize(nbParam); + H.resize(nbParam,nbParam); + HLM.resize(nbParam,nbParam); + + temp.resize(nbParam); + + X1.resize(2); + X2.resize(2); + DI.resize(2); +} + + +double vpTemplateTrackerZNCC::getCost(const vpImage<unsigned char> &I, vpColVector &tp) +{ + double IW,Tij; + int i,j; + double i2,j2; + int Nbpoint=0; + + Warp->computeCoeff(tp); + + double moyTij=0; + double moyIW=0; + for(unsigned int point=0;point<templateSize;point++) + { + i=ptTemplate[point].y; + j=ptTemplate[point].x; + X1[0]=j;X1[1]=i; + Warp->computeDenom(X1,tp); + Warp->warpX(X1,X2,tp); + + j2=X2[0];i2=X2[1]; + if((j2<I.getWidth()-1)&&(i2<I.getHeight()-1)&&(i2>0)&&(j2>0)) + { + Tij=ptTemplate[point].val; + if(!blur) + IW=I.getValue(i2,j2); + else + IW=BI.getValue(i2,j2); + //IW=getSubPixBspline4(I,i2,j2); + moyTij+=Tij; + moyIW+=IW; + Nbpoint++; + } + } + ratioPixelIn=(double)Nbpoint/(double)templateSize; + if(! Nbpoint) { + throw(vpException(vpException::divideByZeroError, + "Cannot get cost: size = 0")) ; + } + + moyTij=moyTij/Nbpoint; + moyIW=moyIW/Nbpoint; + + double nom=0,denom=0; + double var1=0,var2=0; + for(unsigned int point=0;point<templateSize;point++) + { + i=ptTemplate[point].y; + j=ptTemplate[point].x; + X1[0]=j;X1[1]=i; + Warp->computeDenom(X1,tp); + Warp->warpX(X1,X2,tp); + + j2=X2[0];i2=X2[1]; + if((j2<I.getWidth()-1)&&(i2<I.getHeight()-1)&&(i2>0)&&(j2>0)) + { + Tij=ptTemplate[point].val; + if(!blur) + IW=I.getValue(i2,j2); + else + IW=BI.getValue(i2,j2); + //IW=getSubPixBspline4(I,i2,j2); + nom+=(Tij-moyTij)*(IW-moyIW); + denom+=(Tij-moyTij)*(Tij-moyTij)*(IW-moyIW)*(IW-moyIW); + var1+=(IW-moyIW)*(IW-moyIW); + var2+=(Tij-moyTij)*(Tij-moyTij); + + Nbpoint++; + } + } + if(Nbpoint==0)return 10e10; + //return -nom/sqrt(denom); + return -nom/sqrt(var1*var2); +} + + diff --git a/src/tracking/template-tracker/zncc/vpTemplateTrackerZNCC.h b/src/tracking/template-tracker/zncc/vpTemplateTrackerZNCC.h new file mode 100644 index 0000000000000000000000000000000000000000..f0e5141365170030529d3e592db7391a7209c93d --- /dev/null +++ b/src/tracking/template-tracker/zncc/vpTemplateTrackerZNCC.h @@ -0,0 +1,83 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerZNCC.h 4666 2014-02-16 16:21:33Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +/*! + \file vpTemplateTrackerZNCC.h + \brief +*/ + +#ifndef vpTemplateTrackerZNCC_hh +#define vpTemplateTrackerZNCC_hh + +#include <math.h> + +#include <visp/vpTemplateTracker.h> +#include <visp/vpImage.h> +#include <visp/vpDisplay.h> +#include <visp/vpImageTools.h> +#include <visp/vpIoTools.h> +#include <visp/vpImageTools.h> +#include <visp/vpImageFilter.h> +#include <visp/vpMath.h> +#include <visp/vpList.h> +#include <visp/vpHomography.h> + +#define APPROX_NCC + +class VISP_EXPORT vpTemplateTrackerZNCC: public vpTemplateTracker +{ + protected: + vpRowVector DI; + vpRowVector temp; + + protected: + double getCost(const vpImage<unsigned char> &I, vpColVector &tp) ; + double getCost(const vpImage<unsigned char> &I) {vpColVector tp; return getCost(I,tp);} + virtual void initHessienDesired(const vpImage<unsigned char> &I)=0; + virtual void trackNoPyr(const vpImage<unsigned char> &I)=0; + + public: + vpTemplateTrackerZNCC(vpTemplateTrackerWarp *warp); + + void setGain(double _gain){gain=_gain;} +}; +#endif + diff --git a/src/tracking/template-tracker/zncc/vpTemplateTrackerZNCCForwardAdditional.cpp b/src/tracking/template-tracker/zncc/vpTemplateTrackerZNCCForwardAdditional.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1954f235a3a2fd38b501baa594e4208cf3fa3f63 --- /dev/null +++ b/src/tracking/template-tracker/zncc/vpTemplateTrackerZNCCForwardAdditional.cpp @@ -0,0 +1,323 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerZNCCForwardAdditional.cpp 4574 2014-01-09 08:48:51Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +#include <visp/vpTemplateTrackerZNCCForwardAdditional.h> +#include <visp/vpImageFilter.h> + +vpTemplateTrackerZNCCForwardAdditional::vpTemplateTrackerZNCCForwardAdditional(vpTemplateTrackerWarp *warp):vpTemplateTrackerZNCC(warp) +{ + useCompositionnal=false; +} + +void vpTemplateTrackerZNCCForwardAdditional::initHessienDesired(const vpImage<unsigned char> &I) +{ + if(blur) + vpImageFilter::filter(I, BI,fgG,taillef); + vpImageFilter::getGradXGauss2D(I, dIx, fgG,fgdG,taillef); + vpImageFilter::getGradYGauss2D(I, dIy, fgG,fgdG,taillef); + + vpImage<double> dIxx,dIxy,dIyx,dIyy; + vpImageFilter::getGradX(dIx, dIxx, fgdG,taillef); + vpImageFilter::getGradY(dIx, dIxy, fgdG,taillef); + + vpImageFilter::getGradX(dIy, dIyx, fgdG,taillef); + vpImageFilter::getGradY(dIy, dIyy, fgdG,taillef); + + Warp->computeCoeff(p); + double IW,dIWx,dIWy; + double Tij; + int i,j; + double i2,j2; + int Nbpoint=0; + + double moyTij=0; + double moyIW=0; + double denom=0; + for(unsigned int point=0;point<templateSize;point++) + { + i=ptTemplate[point].y; + j=ptTemplate[point].x; + X1[0]=j;X1[1]=i; + X2[0]=j;X2[1]=i; + + Warp->computeDenom(X1,p); + + j2=X2[0];i2=X2[1]; + + if((i2>=0)&&(j2>=0)&&(i2<I.getHeight()-1)&&(j2<I.getWidth()-1)) + { + Tij=ptTemplate[point].val; + + if(!blur) + IW=I.getValue(i2,j2); + else + IW=BI.getValue(i2,j2); + + Nbpoint++; + moyTij+=Tij; + moyIW+=IW; + } + } + moyTij=moyTij/Nbpoint; + moyIW=moyIW/Nbpoint; + Hdesire=0; + for(unsigned int point=0;point<templateSize;point++) + { + i=ptTemplate[point].y; + j=ptTemplate[point].x; + X1[0]=j;X1[1]=i; + X2[0]=j;X2[1]=i; + + Warp->computeDenom(X1,p); + + j2=X2[0];i2=X2[1]; + + if((i2>=0)&&(j2>=0)&&(i2<I.getHeight()-1)&&(j2<I.getWidth()-1)) + { + Tij=ptTemplate[point].val; + + if(!blur) + IW=I.getValue(i2,j2); + else + IW=BI.getValue(i2,j2); + + dIWx=dIx.getValue(i2,j2); + dIWy=dIy.getValue(i2,j2); + //Calcul du Hessien + Warp->dWarp(X1,X2,p,dW); + double *tempt=new double[nbParam]; + for(unsigned int it=0;it<nbParam;it++) + tempt[it]=dW[0][it]*dIWx+dW[1][it]*dIWy; + + + double prod=(Tij-moyTij); + + double d_Ixx=dIxx.getValue(i2,j2); + double d_Iyy=dIyy.getValue(i2,j2); + double d_Ixy=dIxy.getValue(i2,j2); + + for(unsigned int it=0;it<nbParam;it++) + for(unsigned int jt=0;jt<nbParam;jt++) + Hdesire[it][jt] +=prod*(dW[0][it]*(dW[0][jt]*d_Ixx+dW[1][jt]*d_Ixy) + +dW[1][it]*(dW[0][jt]*d_Ixy+dW[1][jt]*d_Iyy)); + /*Hdesire[0][0]+=prod*d_Ixx; + Hdesire[1][0]+=prod*d_Ixy; + Hdesire[0][1]+=prod*d_Ixy; + Hdesire[1][1]+=prod*d_Iyy;*/ + + denom+=(Tij-moyTij)*(Tij-moyTij)*(IW-moyIW)*(IW-moyIW); + delete[] tempt; + } + + + } + + Hdesire=Hdesire/sqrt(denom); + vpMatrix::computeHLM(Hdesire,lambdaDep,HLMdesire); + HLMdesireInverse=HLMdesire.inverseByLU(); + //std::cout<<"Hdesire = "<<Hdesire<<std::endl; + +} + +void vpTemplateTrackerZNCCForwardAdditional::trackNoPyr(const vpImage<unsigned char> &I) +{ + double erreur=0; + int Nbpoint=0; + + if(blur) + vpImageFilter::filter(I, BI,fgG,taillef); + vpImageFilter::getGradXGauss2D(I, dIx, fgG,fgdG,taillef); + vpImageFilter::getGradYGauss2D(I, dIy, fgG,fgdG,taillef); + + /*vpImage<double> dIxx,dIxy,dIyx,dIyy; + getGradX(dIx, dIxx, fgdG,taillef); + getGradY(dIx, dIxy, fgdG,taillef); + + getGradX(dIy, dIyx, fgdG,taillef); + getGradY(dIy, dIyy, fgdG,taillef);*/ + + dW=0; + + //double lambda=lambdaDep; + double IW,dIWx,dIWy; + double Tij; + unsigned int iteration=0; + int i,j; + double i2,j2; + double alpha=2.; + do + { + Nbpoint=0; + erreur=0; + G=0; + H=0 ; + Warp->computeCoeff(p); + double moyTij=0; + double moyIW=0; + double denom=0; + for(unsigned int point=0;point<templateSize;point++) + { + i=ptTemplate[point].y; + j=ptTemplate[point].x; + X1[0]=j;X1[1]=i; + + Warp->computeDenom(X1,p); + Warp->warpX(X1,X2,p); + + j2=X2[0];i2=X2[1]; + if((i2>=0)&&(j2>=0)&&(i2<I.getHeight()-1)&&(j2<I.getWidth()-1)) + { + Tij=ptTemplate[point].val; + + if(!blur) + IW=I.getValue(i2,j2); + else + IW=BI.getValue(i2,j2); + + Nbpoint++; + moyTij+=Tij; + moyIW+=IW; + } + } + + if(! Nbpoint) { + throw(vpException(vpException::divideByZeroError, + "Cannot track the template: no point")) ; + } + + moyTij=moyTij/Nbpoint; + moyIW=moyIW/Nbpoint; + //vpMatrix d2Wx(nbParam,nbParam); + //vpMatrix d2Wy(nbParam,nbParam); + for(unsigned int point=0;point<templateSize;point++) + { + i=ptTemplate[point].y; + j=ptTemplate[point].x; + X1[0]=j;X1[1]=i; + + Warp->computeDenom(X1,p); + Warp->warpX(X1,X2,p); + + j2=X2[0];i2=X2[1]; + if((i2>=0)&&(j2>=0)&&(i2<I.getHeight()-1)&&(j2<I.getWidth()-1)) + { + Tij=ptTemplate[point].val; + + if(!blur) + IW=I.getValue(i2,j2); + else + IW=BI.getValue(i2,j2); + + dIWx=dIx.getValue(i2,j2); + dIWy=dIy.getValue(i2,j2); + //Calcul du Hessien + Warp->dWarp(X1,X2,p,dW); + double *tempt=new double[nbParam]; + for(unsigned int it=0;it<nbParam;it++) + tempt[it]=dW[0][it]*dIWx+dW[1][it]*dIWy; + + + double prod=(Tij-moyTij); + for(unsigned int it=0;it<nbParam;it++) + G[it]+=prod*tempt[it]; + + /* Warp->d2Warp(X1,X2,p,d2Wx,d2Wy); + for(int it=0;it<nbParam;it++) + for(int jt=0;jt<nbParam;jt++) + H[it][jt]+=prod*(d2Wx[it][jt]*dIWx+d2Wx[it][jt]*dIWy);*/ + /*double d_Ixx=dIxx.getValue(i2,j2); + double d_Iyy=dIyy.getValue(i2,j2); + double d_Ixy=dIxy.getValue(i2,j2); + + for(int it=0;it<nbParam;it++) + for(int jt=0;jt<nbParam;jt++) + H[it][jt] +=prod*(dW[0][it]*(dW[0][jt]*d_Ixx+dW[1][jt]*d_Ixy) + +dW[1][it]*(dW[0][jt]*d_Ixy+dW[1][jt]*d_Iyy));*/ + /*H[0][0]+=prod*d_Ixx; + H[1][0]+=prod*d_Ixy; + H[0][1]+=prod*d_Ixy; + H[1][1]+=prod*d_Iyy;*/ + + double er=(Tij-IW); + erreur+=(er*er); + denom+=(Tij-moyTij)*(Tij-moyTij)*(IW-moyIW)*(IW-moyIW); + delete[] tempt; + } + + + } + /*std::cout<<"G="<<G<<std::endl; + std::cout<<"H="<<H<<std::endl; + std::cout<<" denom="<<denom<<std::endl;*/ + G=G/sqrt(denom); + //std::cout<<G<<std::endl; + H=H/sqrt(denom); + + if(Nbpoint==0)std::cout<<"plus de point dans template suivi"<<std::endl; + + try + { + //vpMatrix::computeHLM(H,lambda,HLM); + //dp=1.*HLM.inverseByLU()*G; + dp=1.*HLMdesireInverse*G; + } + catch(...) + { + std::cout<<"probleme inversion"<<std::endl; + break; + } + + dp=gain*dp; + if(useBrent) + { + alpha=2.; + computeOptimalBrentGain(I,p,erreur/Nbpoint,dp,alpha); + dp=alpha*dp; + } + p-=dp; + iteration++; + } + while( /*( erreur_prec-erreur<50) && */(iteration < iterationMax)); + + //std::cout<<"erreur "<<erreur<<std::endl; + nbIteration=iteration; +} + diff --git a/src/tracking/template-tracker/zncc/vpTemplateTrackerZNCCForwardAdditional.h b/src/tracking/template-tracker/zncc/vpTemplateTrackerZNCCForwardAdditional.h new file mode 100644 index 0000000000000000000000000000000000000000..5da1c7ec2fffc4cb6cf09625b4fcc3ec82764f25 --- /dev/null +++ b/src/tracking/template-tracker/zncc/vpTemplateTrackerZNCCForwardAdditional.h @@ -0,0 +1,66 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerZNCCForwardAdditional.h 4574 2014-01-09 08:48:51Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +/*! + \file vpTemplateTrackerZNCCForwardAdditional.h + \brief +*/ + +#ifndef vpTemplateTrackerZNCCForwardAdditional_hh +#define vpTemplateTrackerZNCCForwardAdditional_hh + + +#include <visp/vpTemplateTrackerZNCC.h> + +/*! + The algorithm implemented in this class is described in \cite Irani98a. + */ +class VISP_EXPORT vpTemplateTrackerZNCCForwardAdditional: public vpTemplateTrackerZNCC +{ + protected: + void initHessienDesired(const vpImage<unsigned char> &I); + void trackNoPyr(const vpImage<unsigned char> &I); + + public: + vpTemplateTrackerZNCCForwardAdditional(vpTemplateTrackerWarp *warp); +}; +#endif + diff --git a/src/tracking/template-tracker/zncc/vpTemplateTrackerZNCCInverseCompositional.cpp b/src/tracking/template-tracker/zncc/vpTemplateTrackerZNCCInverseCompositional.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4724275913422984a6d44723bce4ff4a1ea6f9d1 --- /dev/null +++ b/src/tracking/template-tracker/zncc/vpTemplateTrackerZNCCInverseCompositional.cpp @@ -0,0 +1,439 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerZNCCInverseCompositional.cpp 4671 2014-02-17 08:59:28Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +#include <limits> // numeric_limits + +#include <visp/vpTemplateTrackerZNCCInverseCompositional.h> +#include <visp/vpImageFilter.h> + +vpTemplateTrackerZNCCInverseCompositional::vpTemplateTrackerZNCCInverseCompositional(vpTemplateTrackerWarp *warp) + : vpTemplateTrackerZNCC(warp), compoInitialised(false), + evolRMS(0), x_pos(), y_pos(), threshold_RMS(1e-8), moydIrefdp() +{ + useInverse=true; +} + +void vpTemplateTrackerZNCCInverseCompositional::initCompInverse(const vpImage<unsigned char> &I) +{ + //std::cout<<"Initialise precomputed value of Compositionnal Inverse"<<std::endl; + int i,j; + + vpImageFilter::getGradXGauss2D(I, dIx, fgG,fgdG,taillef); + vpImageFilter::getGradYGauss2D(I, dIy, fgG,fgdG,taillef); + + + for(unsigned int point=0;point<templateSize;point++) + { + i=ptTemplate[point].y; + j=ptTemplate[point].x; + + X1[0]=j;X1[1]=i; + Warp->computeDenom(X1,p); + ptTemplate[point].dW=new double[nbParam]; + + double dx=ptTemplate[point].dx; + double dy=ptTemplate[point].dy; + //std::cout<<ptTemplate[point].dx<<","<<ptTemplate[point].dy<<std::endl; + + Warp->getdW0(i,j,dy,dx,ptTemplate[point].dW); + + } + //vpTRACE("fin Comp Inverse"); + compoInitialised=true; +} + +void vpTemplateTrackerZNCCInverseCompositional::initHessienDesired(const vpImage<unsigned char> &I) +{ + initCompInverse(I); + + if(blur) + vpImageFilter::filter(I, BI,fgG,taillef); + vpImageFilter::getGradXGauss2D(I, dIx, fgG,fgdG,taillef); + vpImageFilter::getGradYGauss2D(I, dIy, fgG,fgdG,taillef); + + vpImage<double> dIxx,dIxy,dIyx,dIyy; + vpImageFilter::getGradX(dIx, dIxx, fgdG,taillef); + vpImageFilter::getGradY(dIx, dIxy, fgdG,taillef); + + vpImageFilter::getGradX(dIy, dIyx, fgdG,taillef); + vpImageFilter::getGradY(dIy, dIyy, fgdG,taillef); + + Warp->computeCoeff(p); + double Ic,dIcx=0.,dIcy=0.; + double Iref; + int i,j; + double i2,j2; + int Nbpoint=0; + + double moyIref=0; + double moyIc=0; + double denom=0; + moydIrefdp.resize(nbParam); moydIrefdp=0; + vpMatrix moyd2Iref(nbParam,nbParam);moyd2Iref=0; + + for(unsigned int point=0;point<templateSize;point++) + { + i=ptTemplate[point].y; + j=ptTemplate[point].x; + X1[0]=j;X1[1]=i; + X2[0]=j;X2[1]=i; + + Warp->computeDenom(X1,p); + + j2=X2[0];i2=X2[1]; + + if((i2>=0)&&(j2>=0)&&(i2<I.getHeight()-1)&&(j2<I.getWidth()-1)) + { + Iref=ptTemplate[point].val; + + if(!blur) + Ic=I.getValue(i2,j2); + else + Ic=BI.getValue(i2,j2); + + Nbpoint++; + moyIref+=Iref; + moyIc+=Ic; + + for(unsigned int it=0;it<nbParam;it++) + moydIrefdp[it]+=ptTemplate[point].dW[it]; + + + Warp->dWarp(X1,X2,p,dW); + double *tempt=new double[nbParam]; + for(unsigned int it=0;it<nbParam;it++) + tempt[it]=dW[0][it]*dIcx+dW[1][it]*dIcy; + double d_Ixx=dIxx.getValue(i2,j2); + double d_Iyy=dIyy.getValue(i2,j2); + double d_Ixy=dIxy.getValue(i2,j2); + + for(unsigned int it=0;it<nbParam;it++) + for(unsigned int jt=0;jt<nbParam;jt++) + { + moyd2Iref[it][jt] +=(dW[0][it]*(dW[0][jt]*d_Ixx+dW[1][jt]*d_Ixy) + +dW[1][it]*(dW[0][jt]*d_Ixy+dW[1][jt]*d_Iyy)); + } + + delete[] tempt; + + + } + } + + moyIref=moyIref/Nbpoint; + moydIrefdp=moydIrefdp/Nbpoint; + moyd2Iref=moyd2Iref/Nbpoint; + moyIc=moyIc/Nbpoint; + Hdesire=0; + double covarIref=0,covarIc=0; + double sIcIref=0; + vpColVector sIcdIref(nbParam);sIcdIref=0; + vpMatrix sIcd2Iref(nbParam,nbParam);sIcd2Iref=0; + vpMatrix sdIrefdIref(nbParam,nbParam);sdIrefdIref=0; + for(unsigned int point=0;point<templateSize;point++) + { + i=ptTemplate[point].y; + j=ptTemplate[point].x; + X1[0]=j;X1[1]=i; + X2[0]=j;X2[1]=i; + + Warp->computeDenom(X1,p); + + j2=X2[0];i2=X2[1]; + + if((i2>=0)&&(j2>=0)&&(i2<I.getHeight()-1)&&(j2<I.getWidth()-1)) + { + Iref=ptTemplate[point].val; + + if(!blur) + Ic=I.getValue(i2,j2); + else + Ic=BI.getValue(i2,j2); + + dIcx=dIx.getValue(i2,j2); + dIcy=dIy.getValue(i2,j2); + + Warp->dWarp(X1,X2,p,dW); + + double *tempt=new double[nbParam]; + for(unsigned int it=0;it<nbParam;it++) + tempt[it]=dW[0][it]*dIcx+dW[1][it]*dIcy; + + double prodIc=(Ic-moyIc); + + double d_Ixx=dIxx.getValue(i2,j2); + double d_Iyy=dIyy.getValue(i2,j2); + double d_Ixy=dIxy.getValue(i2,j2); + + for(unsigned int it=0;it<nbParam;it++) + for(unsigned int jt=0;jt<nbParam;jt++) + { + sIcd2Iref[it][jt] +=prodIc*(dW[0][it]*(dW[0][jt]*d_Ixx+dW[1][jt]*d_Ixy) + +dW[1][it]*(dW[0][jt]*d_Ixy+dW[1][jt]*d_Iyy)-moyd2Iref[it][jt]); + sdIrefdIref[it][jt] +=(ptTemplate[point].dW[it]-moydIrefdp[it])*(ptTemplate[point].dW[jt]-moydIrefdp[jt]); + } + + + delete[] tempt; + + for(unsigned int it=0;it<nbParam;it++) + sIcdIref[it]+=prodIc*(ptTemplate[point].dW[it]-moydIrefdp[it]); + + covarIref+=(Iref-moyIref)*(Iref-moyIref); + covarIc+=(Ic-moyIc)*(Ic-moyIc); + sIcIref+=(Iref-moyIref)*(Ic-moyIc); + } + + + } + covarIref=sqrt(covarIref); + covarIc=sqrt(covarIc); + + denom=covarIref*covarIc; + + double NCC=sIcIref/denom; + //std::cout<<"NCC = "<<NCC<<std::endl; + vpColVector dcovarIref(nbParam);dcovarIref=-sIcdIref/covarIref; + + vpColVector dNCC(nbParam);dNCC=(sIcdIref/denom-NCC*dcovarIref/covarIref); + vpMatrix d2covarIref(nbParam,nbParam); + d2covarIref=-(sIcd2Iref-sdIrefdIref+dcovarIref*dcovarIref.t())/covarIref; +#ifdef APPROX_NCC + Hdesire=sIcd2Iref/denom; +#else + Hdesire=(sIcd2Iref-sdIrefdIref+dcovarIref*dcovarIref.t())/denom; +#endif + vpMatrix::computeHLM(Hdesire,lambdaDep,HLMdesire); + HLMdesireInverse=HLMdesire.inverseByLU(); + //std::cout<<"Hdesire = "<<Hdesire<<std::endl; +} + +void vpTemplateTrackerZNCCInverseCompositional::trackNoPyr(const vpImage<unsigned char> &I) +{ + if(blur) + vpImageFilter::filter(I, BI,fgG,taillef); + + double erreur=0; + int Nbpoint=0; + vpColVector dpinv(nbParam); + double Ic; + double Iref; + unsigned int iteration=0; + int i,j; + double i2,j2; + initPosEvalRMS(p); + do + { + Nbpoint=0; + erreur=0; + G=0; + Warp->computeCoeff(p); + double moyIref=0; + double moyIc=0; + double denom=0; + for(unsigned int point=0;point<templateSize;point++) + { + i=ptTemplate[point].y; + j=ptTemplate[point].x; + X1[0]=j;X1[1]=i; + + Warp->computeDenom(X1,p); + Warp->warpX(X1,X2,p); + + j2=X2[0];i2=X2[1]; + if((i2>=0)&&(j2>=0)&&(i2<I.getHeight()-1)&&(j2<I.getWidth()-1)) + { + Iref=ptTemplate[point].val; + + if(!blur) + Ic=I.getValue(i2,j2); + else + Ic=BI.getValue(i2,j2); + + Nbpoint++; + moyIref+=Iref; + moyIc+=Ic; + } + + + } + if(Nbpoint!=0) + { + moyIref=moyIref/Nbpoint; + moyIc=moyIc/Nbpoint; + double sIcIref=0; + double covarIref=0,covarIc=0; + vpColVector sIcdIref(nbParam);sIcdIref=0; + vpColVector sIrefdIref(nbParam);sIrefdIref=0; + + + for(unsigned int point=0;point<templateSize;point++) + { + i=ptTemplate[point].y; + j=ptTemplate[point].x; + X1[0]=j;X1[1]=i; + + Warp->computeDenom(X1,p); + Warp->warpX(X1,X2,p); + + j2=X2[0];i2=X2[1]; + if((i2>=0)&&(j2>=0)&&(i2<I.getHeight()-1)&&(j2<I.getWidth()-1)) + { + Iref=ptTemplate[point].val; + + if(!blur) + Ic=I.getValue(i2,j2); + else + Ic=BI.getValue(i2,j2); + + + double prod=(Ic-moyIc); + for(unsigned int it=0;it<nbParam;it++) + sIcdIref[it]+=prod*(ptTemplate[point].dW[it]-moydIrefdp[it]); + for(unsigned int it=0;it<nbParam;it++) + sIrefdIref[it]+=(Iref-moyIref)*(ptTemplate[point].dW[it]-moydIrefdp[it]); + + double er=(Iref-Ic); + erreur+=(er*er); + //denom+=(Iref-moyIref)*(Iref-moyIref)*(Ic-moyIc)*(Ic-moyIc); + covarIref+=(Iref-moyIref)*(Iref-moyIref); + covarIc+=(Ic-moyIc)*(Ic-moyIc); + sIcIref+=(Iref-moyIref)*(Ic-moyIc); + } + + + } + covarIref=sqrt(covarIref); + covarIc=sqrt(covarIc); + denom=covarIref*covarIc; + + //if(denom==0.0) + if (std::fabs(denom) <= std::numeric_limits<double>::epsilon()) + { + diverge=true; + } + else + { + double NCC=sIcIref/denom; + vpColVector dcovarIref(nbParam);dcovarIref=sIrefdIref/covarIref; + G=1.*(sIcdIref/denom-NCC*dcovarIref/covarIref); + + + try + { + dp=-1.*HLMdesireInverse*G; + } + catch(...) + { + std::cout<<"probleme inversion"<<std::endl; + break; + } + + Warp->getParamInverse(dp,dpinv); + Warp->pRondp(p,dpinv,p); + + computeEvalRMS(p); + } + } + else + diverge=true; + + iteration++; + } + while( (!diverge &&(evolRMS>threshold_RMS) && (iteration < iterationMax))); + + //std::cout<<"erreur "<<erreur<<std::endl; + nbIteration=iteration; + + deletePosEvalRMS(); +} + +void vpTemplateTrackerZNCCInverseCompositional::initPosEvalRMS(vpColVector &p_) +{ + unsigned int nb_corners = zoneTracked->getNbTriangle() * 3; + x_pos.resize(nb_corners); + y_pos.resize(nb_corners); + + Warp->computeCoeff(p); + vpTemplateTrackerTriangle triangle; + + for(unsigned int i=0;i<zoneTracked->getNbTriangle();i++) + { + zoneTracked->getTriangle(i, triangle); + for (unsigned int j=0; j<3; j++) { + triangle.getCorner(j, X1[0], X1[1]); + + Warp->computeDenom(X1,p_); + Warp->warpX(X1,X2,p_); + x_pos[i*3+j]=X2[0]; + y_pos[i*3+j]=X2[1]; + } + } +} + +void vpTemplateTrackerZNCCInverseCompositional::computeEvalRMS(const vpColVector &p_) +{ + unsigned int nb_corners = zoneTracked->getNbTriangle() * 3; + + Warp->computeCoeff(p_); + evolRMS=0; + vpTemplateTrackerTriangle triangle; + + for(unsigned int i=0;i<zoneTracked->getNbTriangle();i++) + { + zoneTracked->getTriangle(i, triangle); + for (unsigned int j=0; j<3; j++) { + triangle.getCorner(j, X1[0], X1[1]); + + Warp->computeDenom(X1,p_); + Warp->warpX(X1,X2,p_); + evolRMS+=(x_pos[i*3+j]-X2[0])*(x_pos[i*3+j]-X2[0])+(y_pos[i*3+j]-X2[1])*(y_pos[i*3+j]-X2[1]); + x_pos[i*3+j]=X2[0]; + y_pos[i*3+j]=X2[1]; + } + } + evolRMS=evolRMS/nb_corners; + +} + +void vpTemplateTrackerZNCCInverseCompositional::deletePosEvalRMS() +{ +} diff --git a/src/tracking/template-tracker/zncc/vpTemplateTrackerZNCCInverseCompositional.h b/src/tracking/template-tracker/zncc/vpTemplateTrackerZNCCInverseCompositional.h new file mode 100644 index 0000000000000000000000000000000000000000..814b2379475b15c49c161f2e80a2c3396fdd983d --- /dev/null +++ b/src/tracking/template-tracker/zncc/vpTemplateTrackerZNCCInverseCompositional.h @@ -0,0 +1,82 @@ +/**************************************************************************** + * + * $Id: vpTemplateTrackerZNCCInverseCompositional.h 4669 2014-02-16 16:25:57Z fspindle $ + * + * This file is part of the ViSP software. + * Copyright (C) 2005 - 2014 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: + * Template tracker. + * + * Authors: + * Amaury Dame + * Aurelien Yol + * Fabien Spindler + * + *****************************************************************************/ +/*! + \file vpTemplateTrackerZNCCInverseCompositional.h + \brief +*/ + +#ifndef vpTemplateTrackerZNCCInverseCompositional_hh +#define vpTemplateTrackerZNCCInverseCompositional_hh + +#include <vector> + +#include <visp/vpTemplateTrackerZNCC.h> + +/*! + The algorithm implemented in this class is described in \cite Irani98a. + */ +class VISP_EXPORT vpTemplateTrackerZNCCInverseCompositional: public vpTemplateTrackerZNCC +{ + protected: + bool compoInitialised; + //pour eval evolRMS + double evolRMS; + std::vector<double> x_pos; + std::vector<double> y_pos; + double threshold_RMS; + vpColVector moydIrefdp; + + protected: + void initCompInverse(const vpImage<unsigned char> &I); + void initHessienDesired(const vpImage<unsigned char> &I); + void trackNoPyr(const vpImage<unsigned char> &I); + void deletePosEvalRMS(); + void computeEvalRMS(const vpColVector &p); + void initPosEvalRMS(vpColVector &p); + + public: + vpTemplateTrackerZNCCInverseCompositional(vpTemplateTrackerWarp *warp); + + void setThresholdRMS(double threshold){threshold_RMS=threshold;} +}; +#endif + diff --git a/src/video/vpFFMPEG.cpp b/src/video/vpFFMPEG.cpp index 85dc4cffe0a0146533c17e3d1fde3bd8753003e8..744d873c01d2f1961f82200a4a78e804c5a04382 100644 --- a/src/video/vpFFMPEG.cpp +++ b/src/video/vpFFMPEG.cpp @@ -3,7 +3,7 @@ * $Id: vpImagePoint.h 2359 2009-11-24 15:09:25Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -65,23 +65,15 @@ extern "C" Basic constructor. */ vpFFMPEG::vpFFMPEG() + : width(-1), height(-1), frameNumber(0), pFormatCtx(NULL), pCodecCtx(NULL), + pCodec(NULL), pFrame(NULL), pFrameRGB(NULL), pFrameGRAY(NULL), packet(NULL), + img_convert_ctx(NULL), videoStream(0), numBytes(0), buffer(NULL), index(), + streamWasOpen(false), streamWasInitialized(false), color_type(COLORED), + f(NULL), outbuf(NULL), picture_buf(NULL), outbuf_size(0), out_size(0), + bit_rate(500000), encoderWasOpened(false), + framerate_stream(-1), framerate_encoder(25) { - frameNumber = 0; - width = -1; - height = -1; - framerate_stream = -1; - framerate_encoder = 25; - buffer = NULL; - streamWasOpen = false; - streamWasInitialized = false; - bit_rate = 500000; - outbuf = NULL; - picture_buf = NULL; - f = NULL; - encoderWasOpened = false; packet = new AVPacket; - - pFormatCtx = NULL; } /*! @@ -99,14 +91,14 @@ vpFFMPEG::~vpFFMPEG() and the dimension of the images using getWidth() and getHeight(). \param filename : Path to the video which has to be read. - \param color_type : Desired color map used to open the video. + \param colortype : Desired color map used to open the video. The parameter can take two values : COLORED and GRAY_SCALED. \return It returns true if the paramters could be initialized. Else it returns false. */ -bool vpFFMPEG::openStream(const char *filename, vpFFMPEGColorType color_type) +bool vpFFMPEG::openStream(const char *filename, vpFFMPEGColorType colortype) { - this->color_type = color_type; + this->color_type = colortype; av_register_all(); #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53,0,0) // libavformat 52.84.0 @@ -141,7 +133,7 @@ bool vpFFMPEG::openStream(const char *filename, vpFFMPEGColorType color_type) #endif { videoStream = i; - std::cout << "rate: " << pFormatCtx->streams[i]->r_frame_rate.num << " " << pFormatCtx->streams[i]->r_frame_rate.den << std::endl; + //std::cout << "rate: " << pFormatCtx->streams[i]->r_frame_rate.num << " " << pFormatCtx->streams[i]->r_frame_rate.den << std::endl; framerate_stream = pFormatCtx->streams[i]->r_frame_rate.num; framerate_stream /= pFormatCtx->streams[i]->r_frame_rate.den; found_codec= true; @@ -643,8 +635,7 @@ void vpFFMPEG::closeStream() Allocates and initializes the parameters depending on the video to write. \param filename : Path to the video which has to be writen. - \param width : Width of the image which will be saved. - \param height : Height of the image which will be saved. + \param w,h : Width and height of the image which will be saved. \param codec : Type of codec used to encode the video. By default codec is set to AV_CODEC_ID_MPEG1VIDEO. But if installed, you can use one of the @@ -656,9 +647,9 @@ void vpFFMPEG::closeStream() \return It returns true if the paramters could be initialized. Else it returns false. */ #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54,51,110) // libavcodec 54.51.100 -bool vpFFMPEG::openEncoder(const char *filename, unsigned int width, unsigned int height, CodecID codec) +bool vpFFMPEG::openEncoder(const char *filename, unsigned int w, unsigned int h, CodecID codec) #else -bool vpFFMPEG::openEncoder(const char *filename, unsigned int width, unsigned int height, AVCodecID codec) +bool vpFFMPEG::openEncoder(const char *filename, unsigned int w, unsigned int h, AVCodecID codec) #endif { av_register_all(); @@ -681,10 +672,10 @@ bool vpFFMPEG::openEncoder(const char *filename, unsigned int width, unsigned in /* put sample parameters */ pCodecCtx->bit_rate = (int)bit_rate; /* resolution must be a multiple of two */ - pCodecCtx->width = (int)width; - pCodecCtx->height = (int)height; - this->width = (int)width; - this->height = (int)height; + pCodecCtx->width = (int)w; + pCodecCtx->height = (int)h; + this->width = (int)w; + this->height = (int)h; /* frames per second */ pCodecCtx->time_base= (AVRational){1,framerate_encoder}; pCodecCtx->gop_size = 10; /* emit one intra frame every ten frames */ diff --git a/src/video/vpFFMPEG.h b/src/video/vpFFMPEG.h index 5c6b586fb381d6f645f0ce50a5c97981748700bf..85b0986bbfc8b73aa42fd8b41fe6360791f9b6ce 100644 --- a/src/video/vpFFMPEG.h +++ b/src/video/vpFFMPEG.h @@ -3,7 +3,7 @@ * $Id: vpImagePoint.h 2359 2009-11-24 15:09:25Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -252,9 +252,9 @@ class VISP_EXPORT vpFFMPEG /*! Sets the bit rate of the video when encoding. - \param bit_rate : the expected bit rate. + \param rate : the expected bit rate. */ - inline void setBitRate(const unsigned int bit_rate) {this->bit_rate = bit_rate;} + inline void setBitRate(const unsigned int rate) {this->bit_rate = rate;} /*! Sets the framerate of the video when encoding. diff --git a/src/video/vpVideoReader.cpp b/src/video/vpVideoReader.cpp index f79518b26d934aae6c2a2aad8d147dfa634131b3..187fce0c10f2086c4f1436532783a9a68e925b55 100644 --- a/src/video/vpVideoReader.cpp +++ b/src/video/vpVideoReader.cpp @@ -3,7 +3,7 @@ * $Id: vpImagePoint.h 2359 2009-11-24 15:09:25Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -55,21 +55,15 @@ Basic constructor. */ vpVideoReader::vpVideoReader() + : imSequence(NULL), +#ifdef VISP_HAVE_FFMPEG + ffmpeg(NULL), +#endif + formatType(FORMAT_UNKNOWN), initFileName(false), isOpen(false), frameCount(0), + firstFrame(0), lastFrame(0), firstFrameIndexIsSet(false), lastFrameIndexIsSet(false) { - imSequence = NULL; - #ifdef VISP_HAVE_FFMPEG - ffmpeg = NULL; - #endif - initFileName = false; - isOpen = false; - firstFrame = 0; - frameCount = 0; - lastFrame = 0; - firstFrameIndexIsSet = false; - lastFrameIndexIsSet = false; } - /*! Basic destructor. */ @@ -105,6 +99,11 @@ void vpVideoReader::setFileName(const char *filename) throw (vpImageException(vpImageException::noFileNameError,"filename empty ")) ; } + if (strlen( filename ) >= FILENAME_MAX) { + throw(vpException(vpException::memoryAllocationError, + "Not enough memory to intialize the file name")); + } + strcpy(this->fileName,filename); formatType = getFormat(fileName); @@ -487,25 +486,30 @@ vpVideoReader::findLastFrameIndex() if (imSequence != NULL) { - char name[FILENAME_MAX]; - int image_number = firstFrame; - std::fstream file; - bool failed; - do - { - sprintf(name,fileName,image_number) ; - file.open(name, std::fstream::in); - failed = file.fail(); - if (!failed) file.close(); - image_number++; - }while(!failed); - - lastFrame = image_number - 2; + if (! lastFrameIndexIsSet) { + char name[FILENAME_MAX]; + int image_number = firstFrame; + bool failed; + do + { + std::fstream file; + sprintf(name,fileName,image_number) ; + file.open(name, std::ios::in); + failed = file.fail(); + if (!failed) file.close(); + image_number++; + }while(!failed); + + lastFrame = image_number - 2; + } } - #ifdef VISP_HAVE_FFMPEG - else if (ffmpeg != NULL) - lastFrame = (long)(ffmpeg->getFrameNumber() - 1); +#ifdef VISP_HAVE_FFMPEG + else if (ffmpeg != NULL) { + if (! lastFrameIndexIsSet) { + lastFrame = (long)(ffmpeg->getFrameNumber() - 1); + } + } #endif } /*! @@ -519,11 +523,11 @@ vpVideoReader::findFirstFrameIndex() if (! firstFrameIndexIsSet) { char name[FILENAME_MAX]; int image_number = 0; - std::fstream file; bool failed; do { + std::fstream file; sprintf(name, fileName, image_number) ; - file.open(name, std::fstream::in); + file.open(name, std::ios::in); failed = file.fail(); if (!failed) file.close(); image_number++; diff --git a/src/video/vpVideoReader.h b/src/video/vpVideoReader.h index 89790d9e66acd189c58265a7d1a1775b9b55de17..e0da5a4cd10a9f77553bf57adcfe0ba7a6d8668c 100644 --- a/src/video/vpVideoReader.h +++ b/src/video/vpVideoReader.h @@ -3,7 +3,7 @@ * $Id: vpImagePoint.h 2359 2009-11-24 15:09:25Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -101,7 +101,10 @@ int main() The other following example explains how to use the class to read a sequence of images. The images are stored in the folder "./image" and are named "image0000.jpeg", "image0001.jpeg", "image0002.jpeg", ... As explained - in setFirstFrameIndex() it is also possible to set the first and last image numbers. + in setFirstFrameIndex() and setLastFrameIndex() it is also possible to set the + first and last image numbers to read a portion of the sequence. If these two + functions are not used, first and last image numbers are set automatically to + match the first and image images of the sequence. \code #include <visp/vpImage.h> @@ -116,6 +119,8 @@ int main() // Initialize the reader. reader.setFileName("./image/image%04d.jpeg"); + reader.setFirstFrameIndex(10); + reader.setLastFrameIndex(20); reader.open(I); while (! reader.end() ) @@ -250,24 +255,24 @@ class VISP_EXPORT vpVideoReader : public vpFrameGrabber Enables to set the first frame index if you want to use the class like a grabber (ie with the acquire method). - \param firstFrame : The first frame index. + \param first_frame : The first frame index. \sa setLastFrameIndex() */ - inline void setFirstFrameIndex(const long firstFrame) { + inline void setFirstFrameIndex(const long first_frame) { this->firstFrameIndexIsSet = true; - this->firstFrame = firstFrame; + this->firstFrame = first_frame; } /*! Enables to set the last frame index. - \param lastFrame : The last frame index. + \param last_frame : The last frame index. \sa setFirstFrameIndex() */ - inline void setLastFrameIndex(const long lastFrame) { + inline void setLastFrameIndex(const long last_frame) { this->lastFrameIndexIsSet = true; - this->lastFrame = lastFrame; + this->lastFrame = last_frame; } private: diff --git a/src/video/vpVideoWriter.cpp b/src/video/vpVideoWriter.cpp index 0e9755588560638e1630b10753bf1c4e45c9f5d7..9451e74fbef5b8ba983c6bc3af2b10ae58c554c6 100755 --- a/src/video/vpVideoWriter.cpp +++ b/src/video/vpVideoWriter.cpp @@ -3,7 +3,7 @@ * $Id: vpImagePoint.h 2359 2009-11-24 15:09:25Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -52,21 +52,35 @@ Basic constructor. */ vpVideoWriter::vpVideoWriter() + : +#ifdef VISP_HAVE_FFMPEG + ffmpeg(NULL), +# if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54,51,110) // libavcodec 54.51.100 + codec(CODEC_ID_MPEG1VIDEO), +# else + codec(AV_CODEC_ID_MPEG1VIDEO), +# endif + bit_rate(500000), + framerate(25), +#endif + formatType(FORMAT_UNKNOWN), initFileName(false), isOpen(false), frameCount(0), + firstFrame(0), width(0), height(0) { initFileName = false; firstFrame = 0; frameCount = 0; - - #ifdef VISP_HAVE_FFMPEG + isOpen = false; + width = height = 0; +#ifdef VISP_HAVE_FFMPEG ffmpeg = NULL; -#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54,51,110) // libavcodec 54.51.100 +# if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54,51,110) // libavcodec 54.51.100 codec = CODEC_ID_MPEG1VIDEO; -#else +# else codec = AV_CODEC_ID_MPEG1VIDEO; -#endif +# endif bit_rate = 500000; framerate = 25; - #endif +#endif } @@ -96,7 +110,12 @@ void vpVideoWriter::setFileName(const char *filename) vpERROR_TRACE("filename empty ") ; throw (vpImageException(vpImageException::noFileNameError,"filename empty ")) ; } - + + if (strlen( filename ) >= FILENAME_MAX) { + throw(vpException(vpException::memoryAllocationError, + "Not enough memory to intialize the file name")); + } + strcpy(this->fileName,filename); formatType = getFormat(fileName); diff --git a/src/video/vpVideoWriter.h b/src/video/vpVideoWriter.h index 6a198c63f402c80bb80766a8bd7c636075dafed7..d8b50e0bd1eef075ca78fed9f865124ed66f5c47 100755 --- a/src/video/vpVideoWriter.h +++ b/src/video/vpVideoWriter.h @@ -3,7 +3,7 @@ * $Id: vpImagePoint.h 2359 2009-11-24 15:09:25Z nmelchio $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -212,16 +212,16 @@ class VISP_EXPORT vpVideoWriter /*! Sets the bit rate of the video when encoding. - \param bit_rate : the expected bit rate. + \param bitrate : the expected bit rate. By default the bit rate is set to 500 000. */ - inline void setBitRate(const unsigned int bit_rate) {this->bit_rate = bit_rate;} + inline void setBitRate(const unsigned int bitrate) {this->bit_rate = bitrate;} /*! Sets the codec used to encode the video. - \param codec : the expected codec. + \param codec_id : the expected codec. By default codec is set to AV_CODEC_ID_MPEG1VIDEO. But if installed, you can use one of the AVCodecID proposed by ffmpeg such as : AV_CODEC_ID_MPEG2VIDEO, AV_CODEC_ID_MPEG2VIDEO_XVMC, @@ -230,9 +230,9 @@ class VISP_EXPORT vpVideoWriter Of course to use the codec it must be installed on your computer. */ #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54,51,110) // libavcodec 54.51.100 - inline void setCodec(const CodecID codec) {this->codec = codec;} + inline void setCodec(const CodecID codec_id) {this->codec = codec_id;} #else - inline void setCodec(const AVCodecID codec) {this->codec = codec;} + inline void setCodec(const AVCodecID codec_id) {this->codec = codec_id;} #endif #endif @@ -241,19 +241,19 @@ class VISP_EXPORT vpVideoWriter /*! Enables to set the first frame index. - \param firstFrame : The first frame index. + \param first_frame : The first frame index. */ - inline void setFirstFrameIndex(const unsigned int firstFrame) {this->firstFrame = firstFrame;} + inline void setFirstFrameIndex(const unsigned int first_frame) {this->firstFrame = first_frame;} #ifdef VISP_HAVE_FFMPEG /*! Sets the framerate in Hz of the video when encoding. - \param framerate : the expected framerate. + \param frame_rate : the expected framerate. By default the framerate is set to 25Hz. */ - inline void setFramerate(const int framerate) { - this->framerate = framerate; + inline void setFramerate(const int frame_rate) { + this->framerate = frame_rate; } #endif diff --git a/src/visual-feature/vpBasicFeature.cpp b/src/visual-feature/vpBasicFeature.cpp index 2b228bbe1b1842efc0cda97a01bfd702897d9230..3c8ccdce2d1321ae37cf1b66ba58d38217210910 100644 --- a/src/visual-feature/vpBasicFeature.cpp +++ b/src/visual-feature/vpBasicFeature.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpBasicFeature.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpBasicFeature.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -68,21 +68,39 @@ const unsigned int vpBasicFeature::FEATURE_ALL = 0xffff; /*! \file vpBasicFeature.cpp \brief Class that defines what is a visual feature. -*/ + Default constructor. +*/ vpBasicFeature::vpBasicFeature() + : s(), dim_s(0), flags(NULL), nbParameters(0), deallocate(vpBasicFeature::user) +{ +} + +/*! + Copy constructor. +*/ +vpBasicFeature::vpBasicFeature(const vpBasicFeature &f) + : s(), dim_s(0), flags(NULL), nbParameters(0), deallocate(vpBasicFeature::user) { -// featureLine[0] = 0x1 ; -// featureLine[1] = 0x2 ; -// featureLine[2] = 0x4 ; -// featureLine[3] = 0x8 ; -// featureLine[4] = 0x10 ; -// featureLine[5] = 0x20 ; -// featureLine[6] = 0x40 ; -// featureLine[7] = 0x80 ; - //vpTRACE("0x%x", this); - deallocate = vpBasicFeature::user ; - flags = NULL; + *this = f; +} + +/*! + Copy operator. +*/ +vpBasicFeature &vpBasicFeature::operator=(const vpBasicFeature &f) +{ + s = f.s; + dim_s = f.dim_s; + nbParameters = f.nbParameters; + deallocate = f.deallocate; + if (flags) + delete [] flags; + flags = new bool [nbParameters]; + for (unsigned int i = 0; i < nbParameters; i++) + flags[i] = f.flags[i]; + + return (*this); } //! Get the feature vector dimension. diff --git a/src/visual-feature/vpBasicFeature.h b/src/visual-feature/vpBasicFeature.h index 23258fd407c4036715d361b04f313043970b64d1..79215c69a71150b94ecb24ef4af1e42388fcb64d 100644 --- a/src/visual-feature/vpBasicFeature.h +++ b/src/visual-feature/vpBasicFeature.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpBasicFeature.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpBasicFeature.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -106,6 +106,8 @@ public: virtual void init() = 0 ; vpBasicFeature() ; + vpBasicFeature(const vpBasicFeature &f) ; + vpBasicFeature &operator=(const vpBasicFeature &f) ; virtual ~vpBasicFeature() { /*vpTRACE("0x%x", this)*/; } //! Return element \e i in the state vector (usage : x = s[i] ) virtual inline double operator[](const unsigned int i) const { return s[i]; } diff --git a/src/visual-feature/vpFeatureDepth.cpp b/src/visual-feature/vpFeatureDepth.cpp index 385f543dd6b74b4f7ba9476701566e5e12302034..e8bc72c90370d29b91f050a2e469b8175f51d0ca 100644 --- a/src/visual-feature/vpFeatureDepth.cpp +++ b/src/visual-feature/vpFeatureDepth.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureDepth.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeatureDepth.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -92,13 +92,15 @@ vpFeatureDepth::init() if (flags == NULL) flags = new bool[nbParameters]; for (unsigned int i = 0; i < nbParameters; i++) flags[i] = false; + x = y = 0.; + Z = 1.; } /*! Default constructor that build a visual feature. */ -vpFeatureDepth::vpFeatureDepth() : vpBasicFeature() +vpFeatureDepth::vpFeatureDepth() : x(0), y(0), Z(1.) { init() ; } @@ -131,12 +133,12 @@ vpFeatureDepth::get_LogZoverZstar() const /*! Set the value of \f$ x \f$ which represents the x coordinate of the point in the camera frame. - \param x : \f$ x \f$ value to set. + \param x_ : \f$ x \f$ value to set. */ void -vpFeatureDepth::set_x(const double x) +vpFeatureDepth::set_x(const double x_) { - this->x = x ; + this->x = x_ ; flags[0] = true; } @@ -156,12 +158,12 @@ vpFeatureDepth::get_x() const /*! Set the value of \f$ y \f$ which represents the y coordinate of the point in the camera frame. - \param y : \f$ y \f$ value to set. + \param y_ : \f$ y \f$ value to set. */ void -vpFeatureDepth::set_y(const double y) +vpFeatureDepth::set_y(const double y_) { - this->y = y ; + this->y = y_ ; flags[1] = true; } @@ -180,12 +182,12 @@ vpFeatureDepth::get_y() const /*! Set the value of \f$ Z \f$ which represents the depth in the 3D camera frame. - \param Z : \f$ Z \f$ value to set. + \param Z_ : \f$ Z \f$ value to set. */ void -vpFeatureDepth::set_Z(const double Z) +vpFeatureDepth::set_Z(const double Z_) { - this->Z = Z ; + this->Z = Z_ ; flags[2] = true; } @@ -205,20 +207,20 @@ vpFeatureDepth::get_Z() const /*! Set the value of \f$ x \f$, \f$ y \f$, \f$ Z \f$ and \f$ log(\frac{Z}{Z^*}) \f$. \f$ x \f$ and \f$ y \f$ represent the coordinates of the point in the camera frame. \f$ Z \f$ is the 3D coordinate representing the depth. \f$ log(\frac{Z}{Z^*}) \f$ represents the logarithm of the current depth relative to the desired depth. - \param x : \f$ x \f$ value to set. - \param y : \f$ y \f$ value to set. - \param Z : \f$ Z \f$ value to set. + \param x_ : \f$ x \f$ value to set. + \param y_ : \f$ y \f$ value to set. + \param Z_ : \f$ Z \f$ value to set. \param LogZoverZstar : \f$ log(\frac{Z}{Z^*}) \f$ value to set. */ void -vpFeatureDepth::set_xyZLogZoverZstar(const double x, - const double y, - const double Z, +vpFeatureDepth::set_xyZLogZoverZstar(const double x_, + const double y_, + const double Z_, const double LogZoverZstar) { - set_x(x) ; - set_y(y) ; - set_Z(Z) ; + set_x(x_) ; + set_y(y_) ; + set_Z(Z_) ; set_LogZoverZstar(LogZoverZstar) ; for( unsigned int i = 0; i < nbParameters; i++) flags[i] = true; } @@ -276,23 +278,23 @@ vpFeatureDepth::interaction(const unsigned int select) L.resize(1,6) ; - double x = get_x(); - double y = get_y(); - double Z = get_Z(); + double x_ = get_x(); + double y_ = get_y(); + double Z_ = get_Z(); - if (Z < 0) + if (Z_ < 0) { vpERROR_TRACE("Point is behind the camera ") ; - std::cout <<"Z = " << Z << std::endl ; + std::cout <<"Z = " << Z_ << std::endl ; throw(vpFeatureException(vpFeatureException::badInitializationError, "Point is behind the camera ")) ; } - if (fabs(Z) < 1e-6) + if (fabs(Z_) < 1e-6) { vpERROR_TRACE("Point Z coordinates is null ") ; - std::cout <<"Z = " << Z << std::endl ; + std::cout <<"Z = " << Z_ << std::endl ; throw(vpFeatureException(vpFeatureException::badInitializationError, "Point Z coordinates is null")) ; @@ -303,9 +305,9 @@ vpFeatureDepth::interaction(const unsigned int select) L = 0; L[0][0] = 0; L[0][1] = 0; - L[0][2] = -1/Z; - L[0][3] = -y; - L[0][4] = x; + L[0][2] = -1/Z_; + L[0][3] = -y_; + L[0][4] = x_; L[0][5] = 0; } @@ -403,20 +405,20 @@ vpFeatureDepth::print(const unsigned int select ) const /*! Build a 3D depth visual feature from the point coordinates \f$ x \f$ and \f$ y \f$ given in the camera frame, \f$ Z \f$ which describes the depth and \f$ log(\frac{Z}{Z^*}) \f$ which represents the logarithm of the current depth relative to the desired depth. - \param x : The \f$ x \f$ parameter. - \param y : The \f$ y \f$ parameter. - \param Z : The \f$ Z \f$ parameter. + \param x_ : The \f$ x \f$ parameter. + \param y_ : The \f$ y \f$ parameter. + \param Z_ : The \f$ Z \f$ parameter. \param LogZoverZstar : The \f$ log(\frac{Z}{Z^*}) \f$ parameter. */ void -vpFeatureDepth::buildFrom(const double x, const double y, const double Z, const double LogZoverZstar) +vpFeatureDepth::buildFrom(const double x_, const double y_, const double Z_, const double LogZoverZstar) { s[0] = LogZoverZstar; - this->x = x ; - this->y = y ; - this->Z = Z ; + this->x = x_ ; + this->y = y_ ; + this->Z = Z_ ; if (Z < 0) { diff --git a/src/visual-feature/vpFeatureDepth.h b/src/visual-feature/vpFeatureDepth.h index d6cadd223d3753c36ba53490bc7575f3afee7e66..17779f120dcafe613c9274838967f39e5d051c05 100644 --- a/src/visual-feature/vpFeatureDepth.h +++ b/src/visual-feature/vpFeatureDepth.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureDepth.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeatureDepth.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/visual-feature/vpFeatureDisplay.cpp b/src/visual-feature/vpFeatureDisplay.cpp index e97aa9abf2a78d5c1d4ccd2816198b5e6c3f22ef..f29dae725cd167c2a7d5f9389cc7868c170afaa0 100644 --- a/src/visual-feature/vpFeatureDisplay.cpp +++ b/src/visual-feature/vpFeatureDisplay.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureDisplay.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeatureDisplay.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/visual-feature/vpFeatureDisplay.h b/src/visual-feature/vpFeatureDisplay.h index bb39b212839be1df446390e68e90c3f0bc9f72f1..9547c4df945b568a24746a5e1644cd6485c8a371 100644 --- a/src/visual-feature/vpFeatureDisplay.h +++ b/src/visual-feature/vpFeatureDisplay.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureDisplay.h 4062 2013-01-09 10:30:06Z fspindle $ + * $Id: vpFeatureDisplay.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/visual-feature/vpFeatureEllipse.cpp b/src/visual-feature/vpFeatureEllipse.cpp index ff30ae64f8e031016ef51f6704c144b4a635501d..8c864e16ef8721e8b5a261115bc47ad6542c8670 100644 --- a/src/visual-feature/vpFeatureEllipse.cpp +++ b/src/visual-feature/vpFeatureEllipse.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureEllipse.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeatureEllipse.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -97,7 +97,7 @@ vpFeatureEllipse::init() } -vpFeatureEllipse::vpFeatureEllipse() : vpBasicFeature() +vpFeatureEllipse::vpFeatureEllipse() : A(0), B(0), C(0) { init() ; } @@ -343,7 +343,7 @@ void vpFeatureEllipse::buildFrom(const double x, const double y, const double mu20, const double mu11, const double mu02, - const double A, const double B, const double C) + const double a, const double b, const double c) { s[0] = x ; @@ -352,9 +352,9 @@ vpFeatureEllipse::buildFrom(const double x, const double y, s[3] = mu11 ; s[4] = mu02 ; - this->A = A ; - this->B = B ; - this->C = C ; + this->A = a ; + this->B = b ; + this->C = c ; for( unsigned int i = 0; i < nbParameters; i++) flags[i] = true; } @@ -382,11 +382,11 @@ vpFeatureEllipse::set_xy(const double x,const double y) } void -vpFeatureEllipse::setABC(const double A, const double B, const double C) +vpFeatureEllipse::setABC(const double a, const double b, const double c) { - this->A = A ; - this->B = B ; - this->C = C ; + this->A = a ; + this->B = b ; + this->C = c ; for( unsigned int i = 5; i < nbParameters; i++) flags[i] = true; } diff --git a/src/visual-feature/vpFeatureEllipse.h b/src/visual-feature/vpFeatureEllipse.h index dd99810a95bb8962e419a117252dfc2b283143ec..7e19a333686d0956266e3225e356f3134efc3827 100644 --- a/src/visual-feature/vpFeatureEllipse.h +++ b/src/visual-feature/vpFeatureEllipse.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureEllipse.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeatureEllipse.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/visual-feature/vpFeatureException.h b/src/visual-feature/vpFeatureException.h index 61cfcc6e981c7f8d73625ce688da5b8bdab407e3..f89311d14eaf446ac301243e2af301f1063b0ff0 100644 --- a/src/visual-feature/vpFeatureException.h +++ b/src/visual-feature/vpFeatureException.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureException.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeatureException.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -70,12 +70,12 @@ */ class VISP_EXPORT vpFeatureException : public vpException { -public: - /*! + public: + /*! \brief Lists the possible error than can be emmited while calling vpFeature member */ - enum errorFeatureCodeEnum + enum errorFeatureCodeEnum { //! feature list or desired feature list is empty badErrorVectorError, @@ -84,25 +84,20 @@ public: badInitializationError } ; -public: - vpFeatureException (const int code, const char * msg) - : vpException(code, msg){ ; } - vpFeatureException (const int code, const std::string & msg) - : vpException(code, msg){ ; } - vpFeatureException (const int code) - : vpException(code){ ; } + public: + vpFeatureException (const int id, const char* format, ...) + { + this->code = id; + va_list args; + va_start(args, format); + setMessage(format, args); + va_end (args); + } + vpFeatureException (const int id, const std::string & msg) + : vpException(id, msg){ ; } + vpFeatureException (const int id) + : vpException(id){ ; } }; - - - - -#endif /* #ifndef __vpFeatureException_H */ - - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ +#endif diff --git a/src/visual-feature/vpFeatureLine.cpp b/src/visual-feature/vpFeatureLine.cpp index b04c8525411b5a119192d70b89094a7dc43b1273..77d348d7276784f1ec4b3e6f9a882743948edcb8 100644 --- a/src/visual-feature/vpFeatureLine.cpp +++ b/src/visual-feature/vpFeatureLine.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureLine.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeatureLine.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -113,7 +113,7 @@ vpFeatureLine::init() /*! Default constructor that build a visual feature. */ -vpFeatureLine::vpFeatureLine() : vpBasicFeature() +vpFeatureLine::vpFeatureLine() : A(0), B(0), C(0), D(0) { init() ; } @@ -139,19 +139,19 @@ vpFeatureLine::setRhoTheta(const double rho, const double theta) \f[ AX + BY + CZ + D = 0 \f] Those parameters are needed to compute the interaction matrix associated to a visual feature. Normally, two plans are needed to describe a line (the intersection of those two plans). But to compute the interaction matrix only one plan equation is required. The only one restrictions is that the value of D must not be equal to zero ! - \param A : A value to set. - \param B : B value to set. - \param C : C value to set. - \param D : D value to set. + \param A_ : A value to set. + \param B_ : B value to set. + \param C_ : C value to set. + \param D_ : D value to set. */ void -vpFeatureLine::setABCD(const double A, const double B, - const double C, const double D) +vpFeatureLine::setABCD(const double A_, const double B_, + const double C_, const double D_) { - this->A = A ; - this->B = B ; - this->C = C ; - this->D = D ; + this->A = A_ ; + this->B = B_ ; + this->C = C_ ; + this->D = D_ ; for(unsigned int i = 2; i < nbParameters; i++) flags[i] = true; } @@ -457,22 +457,22 @@ vpFeatureLine::buildFrom(const double rho, const double theta) \param rho : The \f$ \rho \f$ parameter. \param theta : The \f$ \theta \f$ parameter. - \param A : A parameter of the plan equation. - \param B : B parameter of the plan equation. - \param C : C parameter of the plan equation. - \param D : D parameter of the plan equation. + \param A_ : A parameter of the plan equation. + \param B_ : B parameter of the plan equation. + \param C_ : C parameter of the plan equation. + \param D_ : D parameter of the plan equation. */ void vpFeatureLine::buildFrom(const double rho, const double theta, - const double A, const double B, - const double C, const double D) + const double A_, const double B_, + const double C_, const double D_) { s[0] = rho ; s[1] = theta ; - this->A = A ; - this->B = B ; - this->C = C ; - this->D = D ; + this->A = A_ ; + this->B = B_ ; + this->C = C_ ; + this->D = D_ ; for(unsigned int i = 0; i < nbParameters; i++) flags[i] = true; } diff --git a/src/visual-feature/vpFeatureLine.h b/src/visual-feature/vpFeatureLine.h index 0d946351fcc3abed4a0f22a0e2f0effff6d4dbc2..f7ad5023cacabeed7d900e00238ff652bf9b4846 100644 --- a/src/visual-feature/vpFeatureLine.h +++ b/src/visual-feature/vpFeatureLine.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureLine.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeatureLine.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/visual-feature/vpFeatureLuminance.cpp b/src/visual-feature/vpFeatureLuminance.cpp index 63a7d86a39ede789fd6b3b7d48a5c0d5e1c4e13f..700eda41cd3c48dd5e79bf6cb141d968772d996e 100755 --- a/src/visual-feature/vpFeatureLuminance.cpp +++ b/src/visual-feature/vpFeatureLuminance.cpp @@ -15,11 +15,7 @@ \file vpFeatureLuminance.cpp \brief Class that defines the image luminance visual feature - for more details see - C. Collewet, E. Marchand, F. Chaumette. Visual - servoing set free from image processing. In IEEE Int. Conf. on - Robotics and Automation, ICRA'08, Pages 81-86, Pasadena, Californie, - Mai 2008. + For more details see \cite collewet:inria-00261398.. */ @@ -39,6 +35,7 @@ vpFeatureLuminance::init() firstTimeIn =0 ; + nbr = nbc = 0; } @@ -70,17 +67,44 @@ vpFeatureLuminance::init(unsigned int _nbr, unsigned int _nbc, double _Z) /*! Default constructor that build a visual feature. */ -vpFeatureLuminance::vpFeatureLuminance() : vpBasicFeature() +vpFeatureLuminance::vpFeatureLuminance() + : Z(1), nbr(0), nbc(0), bord(10), pixInfo(NULL), firstTimeIn(0), cam() { nbParameters = 1; dim_s = 0 ; - bord = 10 ; flags = NULL; - pixInfo = NULL; init() ; } +/*! + Copy constructor. + */ +vpFeatureLuminance::vpFeatureLuminance(const vpFeatureLuminance& f) + : vpBasicFeature(f), Z(1), nbr(0), nbc(0), bord(10), pixInfo(NULL), firstTimeIn(0), cam() +{ + *this = f; +} + +/*! + Copy operator. + */ +vpFeatureLuminance &vpFeatureLuminance::operator=(const vpFeatureLuminance& f) +{ + Z = f.Z; + nbr = f.nbr; + nbc = f.nbc; + bord = f.bord; + firstTimeIn = f.firstTimeIn; + cam = f.cam; + if (pixInfo) + delete [] pixInfo; + pixInfo = new vpLuminance[dim_s] ; + for(unsigned int i=0; i< dim_s; i++) + pixInfo[i] = f.pixInfo[i]; + return (*this); +} + /*! Default destructor. */ @@ -95,12 +119,12 @@ vpFeatureLuminance::~vpFeatureLuminance() /*! Set the value of \f$ Z \f$ which represents the depth in the 3D camera frame. - \param Z : \f$ Z \f$ value to set. + \param Z_ : \f$ Z \f$ value to set. */ void -vpFeatureLuminance::set_Z(const double Z) +vpFeatureLuminance::set_Z(const double Z_) { - this->Z = Z ; + this->Z = Z_ ; flags[0] = true; } diff --git a/src/visual-feature/vpFeatureLuminance.h b/src/visual-feature/vpFeatureLuminance.h index fe68cc76ecce434d7ba1355a93f5a223aa6395c0..3e4d9fa6a1587f63a10cc592da2a683de8efa601 100755 --- a/src/visual-feature/vpFeatureLuminance.h +++ b/src/visual-feature/vpFeatureLuminance.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureLuminance.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeatureLuminance.h 4664 2014-02-16 16:17:54Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -51,11 +51,7 @@ \file vpFeatureLuminance.h \brief Class that defines the image luminance visual feature - for more details see - C. Collewet, E. Marchand, F. Chaumette. Visual - servoing set free from image processing. In IEEE Int. Conf. on - Robotics and Automation, ICRA'08, Pages 81-86, Pasadena, Californie, - Mai 2008. + For more details see \cite collewet:inria-00261398. */ @@ -82,11 +78,7 @@ class VISP_EXPORT vpLuminance \class vpFeatureLuminance \brief Class that defines the image luminance visual feature - For more details see - C. Collewet, E. Marchand, F. Chaumette. Visual - servoing set free from image processing. In IEEE Int. Conf. on - Robotics and Automation, ICRA'08, Pages 81-86, Pasadena, Californie, - Mai 2008. + For more details see \cite collewet:inria-00261398. */ class VISP_EXPORT vpFeatureLuminance : public vpBasicFeature @@ -116,7 +108,9 @@ public: void init(unsigned int _nbr, unsigned int _nbc, double _Z) ; vpFeatureLuminance() ; - + vpFeatureLuminance(const vpFeatureLuminance& f) ; + vpFeatureLuminance &operator=(const vpFeatureLuminance& f) ; + //! Destructor. virtual ~vpFeatureLuminance() ; diff --git a/src/visual-feature/vpFeatureMoment.cpp b/src/visual-feature/vpFeatureMoment.cpp index ae3cd40b102377a7dfa7cf5d687db490a5010cb9..a2a26757635bd7be57669f5fe06a7ae030a3cc3e 100644 --- a/src/visual-feature/vpFeatureMoment.cpp +++ b/src/visual-feature/vpFeatureMoment.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureMoment.cpp 4303 2013-07-04 14:14:00Z fspindle $ + * $Id: vpFeatureMoment.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -142,20 +142,19 @@ void vpFeatureMoment::display (const vpCameraParameters &cam, const vpImage< vpR \attention The behaviour of this method is not the same as vpMoment::update which only acknowledges the new object. This method also computes the interaction matrices. - \param A : A coefficient of the plane. - \param B : B coefficient of the plane. - \param C : C coefficient of the plane. + \param A_ : A coefficient of the plane. + \param B_ : B coefficient of the plane. + \param C_ : C coefficient of the plane. */ -void vpFeatureMoment::update (double A, double B, double C){ - this->A = A; - this->B = B; - this->C = C; +void vpFeatureMoment::update (double A_, double B_, double C_){ + this->A = A_; + this->B = B_; + this->C = C_; if(moment==NULL){ bool found; this->moment = &(moments.get(momentName(),found)); - if(!found) throw ("Moment not found for feature"); - + if(!found) throw vpException(vpException::notInitialized,"Moment not found for feature"); } nbParameters = 1; if(this->moment!=NULL){ @@ -235,10 +234,15 @@ vpBasicFeature* vpFeatureMoment::duplicate () const */ void vpFeatureMoment::linkTo(vpFeatureMomentDatabase& featureMoments){ - std::strcpy(_name,name()); - this->featureMomentsDataBase=&featureMoments; + if (strlen( name() ) >= 255) { + throw(vpException(vpException::memoryAllocationError, + "Not enough memory to intialize the moment name")); + } + + std::strcpy(_name,name()); + this->featureMomentsDataBase=&featureMoments; - featureMoments.add(*this,_name); + featureMoments.add(*this,_name); } diff --git a/src/visual-feature/vpFeatureMoment.h b/src/visual-feature/vpFeatureMoment.h index 85ec24427772af1e7ac1ce622f1500554f24da96..76b8b4bce1c549f896411110e8224822eff03e0b 100644 --- a/src/visual-feature/vpFeatureMoment.h +++ b/src/visual-feature/vpFeatureMoment.h @@ -1,9 +1,9 @@ /**************************************************************************** * -* $Id: vpFeatureMoment.h 4276 2013-06-25 12:36:48Z fspindle $ +* $Id: vpFeatureMoment.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. -* Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +* Copyright (C) 2005 - 2014 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 @@ -145,8 +145,8 @@ return 0; */ class VISP_EXPORT vpFeatureMoment : public vpBasicFeature{ protected: - vpMoment* moment; - vpMoment& getMoment(){return *moment;} + const vpMoment* moment; + const vpMoment& getMoment() const {return *moment;} vpMomentDatabase& moments; vpFeatureMomentDatabase* featureMomentsDataBase; std::vector<vpMatrix> interaction_matrices; @@ -155,22 +155,24 @@ protected: double B; double C; char _name[255]; + public: /*! Initializes the feature with information about the database of moment primitives, the object plane, feature database and matrix size. - \param moments : Moment database. The database of moment primitives (first parameter) is mandatory. It is used to access different moment values later used to compute the final matrix. - \param A : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. - \param B : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. - \param C : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. + \param data_base : Moment database. The database of moment primitives (first parameter) is mandatory. It is used to access different moment values later used to compute the final matrix. + \param A_ : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. + \param B_ : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. + \param C_ : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. \param featureMoments : Feature database \param nbmatrices : If you want to create a new vpFeatureMoment implementation, your feature will often have a matrix size of n lines. You can specify the number of lines by this parameter. */ - vpFeatureMoment(vpMomentDatabase& moments,double A=0.0, double B=0.0, double C=0.0,vpFeatureMomentDatabase* featureMoments=NULL,unsigned int nbmatrices=1) : - moment(NULL), - moments(moments), - featureMomentsDataBase(featureMoments), - interaction_matrices(nbmatrices), - A(A),B(B),C(C) {} + vpFeatureMoment(vpMomentDatabase& data_base,double A_=0.0, double B_=0.0, double C_=0.0, + vpFeatureMomentDatabase* featureMoments=NULL,unsigned int nbmatrices=1) + : moment(NULL), + moments(data_base), + featureMomentsDataBase(featureMoments), + interaction_matrices(nbmatrices), + A(A_),B(B_),C(C_) {} virtual ~vpFeatureMoment(); virtual void compute_interaction (void); @@ -182,24 +184,24 @@ public: int getDimension (unsigned int select=FEATURE_ALL) const; void init (void); - vpMatrix interaction (const unsigned int select=FEATURE_ALL); + vpMatrix interaction (const unsigned int select=FEATURE_ALL) ; void linkTo(vpFeatureMomentDatabase& featureMoments); /*! Name of the moment corresponding to the feature. This allows to locate the moment associated with the feature in the provided database. */ - virtual const char* momentName() = 0; + virtual const char* momentName() const = 0; /*! Name of the feature used to locate it in the database of features. */ - virtual const char* name() = 0; + virtual const char* name() const = 0; void print (const unsigned int select=FEATURE_ALL) const ; void update (double A, double B, double C); #ifndef DOXYGEN_SHOULD_SKIP_THIS - void operator=(const vpFeatureMoment &){ + vpFeatureMoment& operator=(const vpFeatureMoment &){ throw vpException(vpException::functionNotImplementedError,"Not implemented!"); } #endif @@ -222,15 +224,17 @@ Duplication is mostly used internally in ViSP. */ class VISP_EXPORT vpMomentGenericFeature : public vpFeatureMoment{ public: - vpMomentGenericFeature(vpMomentDatabase& moments,double A, double B, double C,vpFeatureMomentDatabase* featureMoments, vpMoment* moment) : vpFeatureMoment(moments,A,B,C,featureMoments){this->moment = moment;} + vpMomentGenericFeature(vpMomentDatabase& data_base,double A_, double B_, double C_, + vpFeatureMomentDatabase* featureMoments, const vpMoment* p_moment) + : vpFeatureMoment(data_base,A_,B_,C_,featureMoments){this->moment = p_moment;} /*! No specific moment name. */ - const char* momentName() { return NULL;} + const char* momentName() const { return NULL;} /*! No specific feature name. */ - virtual const char* name() { return NULL;} + virtual const char* name() const { return NULL;} }; #endif diff --git a/src/visual-feature/vpFeatureMomentAlpha.cpp b/src/visual-feature/vpFeatureMomentAlpha.cpp index 26ae79e18cd3cdccf9105354ae5a8a9c076f0be2..9645e49e1fcc24321e618fbdf327f5c7b0611975 100644 --- a/src/visual-feature/vpFeatureMomentAlpha.cpp +++ b/src/visual-feature/vpFeatureMomentAlpha.cpp @@ -3,7 +3,7 @@ * $Id: vpFeatureMomentImpl.cpp 3317 2011-09-06 14:14:47Z fnovotny $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -62,8 +62,8 @@ void vpFeatureMomentAlpha::compute_interaction(){ bool found_moment_centered; bool found_FeatureMoment_centered; - vpMomentCentered& momentCentered = (static_cast<vpMomentCentered&>(moments.get("vpMomentCentered",found_moment_centered))); - vpFeatureMomentCentered& featureMomentCentered = (static_cast<vpFeatureMomentCentered&>(featureMoments->get("vpFeatureMomentCentered",found_FeatureMoment_centered))); + const vpMomentCentered& momentCentered = (static_cast<const vpMomentCentered&>(moments.get("vpMomentCentered",found_moment_centered))); + vpFeatureMomentCentered& featureMomentCentered = (static_cast<vpFeatureMomentCentered&>(featureMomentsDataBase->get("vpFeatureMomentCentered",found_FeatureMoment_centered))); if(!found_moment_centered) throw vpException(vpException::notInitialized,"vpMomentCentered not found"); if(!found_FeatureMoment_centered) throw vpException(vpException::notInitialized,"vpFeatureMomentCentered not found"); @@ -87,9 +87,9 @@ void vpFeatureMomentAlpha::compute_interaction(){ bool found_moment_centered; bool found_moment_gravity; - vpMomentCentered& momentCentered = static_cast<vpMomentCentered&>(moments.get("vpMomentCentered",found_moment_centered)); - vpMomentGravityCenter& momentGravity = static_cast<vpMomentGravityCenter&>(moments.get("vpMomentGravityCenter",found_moment_gravity)); - vpMomentObject& momentObject = moment->getObject(); + const vpMomentCentered& momentCentered = static_cast<const vpMomentCentered&>(moments.get("vpMomentCentered",found_moment_centered)); + const vpMomentGravityCenter& momentGravity = static_cast<const vpMomentGravityCenter&>(moments.get("vpMomentGravityCenter",found_moment_gravity)); + const vpMomentObject& momentObject = moment->getObject(); if(!found_moment_centered) throw vpException(vpException::notInitialized,"vpMomentCentered not found"); diff --git a/src/visual-feature/vpFeatureMomentAlpha.h b/src/visual-feature/vpFeatureMomentAlpha.h index 1f03148004267f75569adb4fef3d5ef73fd1c53d..40faae3afd619c9552dbaae005d146eec8774a26 100644 --- a/src/visual-feature/vpFeatureMomentAlpha.h +++ b/src/visual-feature/vpFeatureMomentAlpha.h @@ -3,7 +3,7 @@ * $Id: vpFeatureMomentImpl.h 3317 2011-09-06 14:14:47Z fnovotny $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -91,11 +91,11 @@ class VISP_EXPORT vpFeatureMomentAlpha : public vpFeatureMoment{ /*! associated moment name */ - const char* momentName(){ return "vpMomentAlpha";} + const char* momentName() const { return "vpMomentAlpha";} /*! feature name */ - const char* name(){ return "vpFeatureMomentAlpha";} + const char* name() const { return "vpFeatureMomentAlpha";} }; #else class vpMomentDatabase; @@ -149,26 +149,26 @@ class VISP_EXPORT vpFeatureMomentAlpha : public vpFeatureMoment{ public: /*! Initializes the feature with information about the database of moment primitives, the object plane and feature database. - \param moments : Moment database. The database of moment primitives (first parameter) is mandatory. It is used to access different moment values later used to compute the final matrix. - \param A : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. - \param B : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. - \param C : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. + \param data_base : Moment database. The database of moment primitives (first parameter) is mandatory. It is used to access different moment values later used to compute the final matrix. + \param A_ : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. + \param B_ : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. + \param C_ : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. \param featureMoments : Feature database. */ - vpFeatureMomentAlpha(vpMomentDatabase& moments,double A, double B, double C,vpFeatureMomentDatabase* featureMoments=NULL) : - vpFeatureMoment(moments,A,B,C,featureMoments,1) + vpFeatureMomentAlpha(vpMomentDatabase& data_base,double A_, double B_, double C_,vpFeatureMomentDatabase* featureMoments=NULL) : + vpFeatureMoment(data_base,A_,B_,C_,featureMoments,1) {} void compute_interaction(); /*! Associated moment name. */ - const char* momentName(){ return "vpMomentAlpha";} + const char* momentName() const { return "vpMomentAlpha";} /*! Feature name. */ - const char* name(){ return "vpFeatureMomentAlpha";} + const char* name() const { return "vpFeatureMomentAlpha";} vpColVector error (const vpBasicFeature &s_star, const unsigned int select=FEATURE_ALL); }; diff --git a/src/visual-feature/vpFeatureMomentArea.cpp b/src/visual-feature/vpFeatureMomentArea.cpp index a26646497b80a062333c2fa9205caa887a22f19c..bd409128f162e1dac429f330c113df7e20f19376 100644 --- a/src/visual-feature/vpFeatureMomentArea.cpp +++ b/src/visual-feature/vpFeatureMomentArea.cpp @@ -3,7 +3,7 @@ * $Id: vpFeatureMomentArea.cpp 3317 2011-09-06 14:14:47Z fnovotny $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -80,19 +80,19 @@ void vpFeatureMomentArea::compute_interaction(){ else { // Get Xg and Yg bool found_xgyg; - vpMomentGravityCenter& momentGravity = static_cast<vpMomentGravityCenter&>(moments.get("vpMomentGravityCenter",found_xgyg)); + const vpMomentGravityCenter& momentGravity = static_cast<const vpMomentGravityCenter&>(moments.get("vpMomentGravityCenter",found_xgyg)); if (!found_xgyg) throw vpException(vpException::notInitialized,"vpMomentGravityCenter not found"); bool found_m00; - vpMomentArea& areamoment = static_cast<vpMomentArea&>(moments.get("vpMomentArea", found_m00)); + const vpMomentArea& areamoment = static_cast<const vpMomentArea&>(moments.get("vpMomentArea", found_m00)); if (!found_m00) throw vpException(vpException::notInitialized,"vpMomentArea not found"); double Xg = momentGravity.getXg(); double Yg = momentGravity.getYg(); double a = areamoment.get()[0]; // Area scalar - //assert(a==mobj.get(0,0)); - assert(std::fabs(a-mobj.get(0,0)) < a*std::numeric_limits<double>::epsilon()); + //assert(a==mobj.get(0,0)); + assert(std::fabs(a-mobj.get(0,0)) < a*std::numeric_limits<double>::epsilon()); interaction_matrices[0][0][0] = -a*A; interaction_matrices[0][0][1] = -a*B; diff --git a/src/visual-feature/vpFeatureMomentArea.h b/src/visual-feature/vpFeatureMomentArea.h index 42045ef6a0e848126c2d9461a441f98ebe5ddf6a..1d95aac849c680f27100f3b04289e671f06ae4b0 100644 --- a/src/visual-feature/vpFeatureMomentArea.h +++ b/src/visual-feature/vpFeatureMomentArea.h @@ -3,7 +3,7 @@ * $Id: vpFeatureMomentArea.h 3317 2011-09-06 14:14:47Z mbakthav $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -61,25 +61,25 @@ class VISP_EXPORT vpFeatureMomentArea : public vpFeatureMoment{ public: /*! Initializes the feature with information about the database of moment primitives, the object plane and feature database. - \param moments : Moment database. The database of moment primitives (first parameter) is mandatory. It is used to access different moment values later used to compute the final matrix. - \param A : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. - \param B : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. - \param C : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. + \param data_base : Moment database. The database of moment primitives (first parameter) is mandatory. It is used to access different moment values later used to compute the final matrix. + \param A_ : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. + \param B_ : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. + \param C_ : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. \param featureMoments : Feature database. */ - vpFeatureMomentArea(vpMomentDatabase& moments,double A, double B, double C,vpFeatureMomentDatabase* featureMoments=NULL) : - vpFeatureMoment(moments,A,B,C,featureMoments,1){} + vpFeatureMomentArea(vpMomentDatabase& data_base,double A_, double B_, double C_,vpFeatureMomentDatabase* featureMoments=NULL) : + vpFeatureMoment(data_base,A_,B_,C_,featureMoments,1){} void compute_interaction(); /*! associated moment name */ - const char* momentName(){ return "vpMomentArea";} + const char* momentName() const { return "vpMomentArea";} /*! feature name */ - const char* name(){ return "vpFeatureMomentArea";} + const char* name() const { return "vpFeatureMomentArea";} }; #endif diff --git a/src/visual-feature/vpFeatureMomentAreaNormalized.cpp b/src/visual-feature/vpFeatureMomentAreaNormalized.cpp index 30142620c570104602062d4fa0c63e19f23f0177..5150af6d8d99243ba9977c26404ad55799d89e64 100644 --- a/src/visual-feature/vpFeatureMomentAreaNormalized.cpp +++ b/src/visual-feature/vpFeatureMomentAreaNormalized.cpp @@ -3,7 +3,7 @@ * $Id: vpFeatureMomentImpl.cpp 3317 2011-09-06 14:14:47Z fnovotny $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -68,14 +68,12 @@ void vpFeatureMomentAreaNormalized::compute_interaction(){ bool found_FeatureMoment_centered; bool found_featuremoment_basic; - vpFeatureMomentBasic& featureMomentBasic= (static_cast<vpFeatureMomentBasic&>(featureMoments->get("vpFeatureMomentBasic",found_featuremoment_basic))); + vpFeatureMomentBasic& featureMomentBasic= (static_cast<vpFeatureMomentBasic&>(featureMomentsDataBase->get("vpFeatureMomentBasic",found_featuremoment_basic))); - - - vpMomentCentered& momentCentered = static_cast<vpMomentCentered&>(moments.get("vpMomentCentered",found_moment_centered)); - vpMomentObject& momentObject = moment->getObject(); - vpMomentAreaNormalized& momentSurfaceNormalized = static_cast<vpMomentAreaNormalized&>(moments.get("vpMomentAreaNormalized",found_moment_surface_normalized)); - vpFeatureMomentCentered& featureMomentCentered = (static_cast<vpFeatureMomentCentered&>(featureMoments->get("vpFeatureMomentCentered",found_FeatureMoment_centered))); + const vpMomentCentered& momentCentered = static_cast<const vpMomentCentered&>(moments.get("vpMomentCentered",found_moment_centered)); + const vpMomentObject& momentObject = moment->getObject(); + const vpMomentAreaNormalized& momentSurfaceNormalized = static_cast<const vpMomentAreaNormalized&>(moments.get("vpMomentAreaNormalized",found_moment_surface_normalized)); + vpFeatureMomentCentered& featureMomentCentered = (static_cast<vpFeatureMomentCentered&>(featureMomentsDataBase->get("vpFeatureMomentCentered",found_FeatureMoment_centered))); if(!found_FeatureMoment_centered) throw vpException(vpException::notInitialized, "vpFeatureMomentCentered not found"); if(!found_moment_surface_normalized) throw vpException(vpException::notInitialized,"vpMomentAreaNormalized not found"); @@ -125,10 +123,10 @@ void vpFeatureMomentAreaNormalized::compute_interaction(){ bool found_moment_surface_normalized; bool found_moment_gravity; - vpMomentCentered& momentCentered = static_cast<vpMomentCentered&>(moments.get("vpMomentCentered",found_moment_centered)); - vpMomentGravityCenter& momentGravity = static_cast<vpMomentGravityCenter&>(moments.get("vpMomentGravityCenter",found_moment_gravity)); - vpMomentObject& momentObject = moment->getObject(); - vpMomentAreaNormalized& momentSurfaceNormalized = static_cast<vpMomentAreaNormalized&>(moments.get("vpMomentAreaNormalized",found_moment_surface_normalized)); + const vpMomentCentered& momentCentered = static_cast<const vpMomentCentered&>(moments.get("vpMomentCentered",found_moment_centered)); + const vpMomentGravityCenter& momentGravity = static_cast<const vpMomentGravityCenter&>(moments.get("vpMomentGravityCenter",found_moment_gravity)); + const vpMomentObject& momentObject = moment->getObject(); + const vpMomentAreaNormalized& momentSurfaceNormalized = static_cast<const vpMomentAreaNormalized&>(moments.get("vpMomentAreaNormalized",found_moment_surface_normalized)); if (!found_moment_surface_normalized) throw vpException(vpException::notInitialized,"vpMomentAreaNormalized not found"); if (!found_moment_centered) throw vpException(vpException::notInitialized,"vpMomentCentered not found"); diff --git a/src/visual-feature/vpFeatureMomentAreaNormalized.h b/src/visual-feature/vpFeatureMomentAreaNormalized.h index b43e2ea26a793bb0237e775da6e563aaceda5ab9..7004fe33a6ea1e4b1f9c4c2b19642fab8cdc0cb3 100644 --- a/src/visual-feature/vpFeatureMomentAreaNormalized.h +++ b/src/visual-feature/vpFeatureMomentAreaNormalized.h @@ -3,7 +3,7 @@ * $Id: vpFeatureMomentImpl.h 3317 2011-09-06 14:14:47Z fnovotny $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -77,24 +77,24 @@ class VISP_EXPORT vpFeatureMomentAreaNormalized : public vpFeatureMoment{ public: /*! Initializes the feature with information about the database of moment primitives, the object plane and feature database. - \param moments : Moment database. The database of moment primitives (first parameter) is mandatory. It is used to access different moment values later used to compute the final matrix. + \param database : Moment database. The database of moment primitives (first parameter) is mandatory. It is used to access different moment values later used to compute the final matrix. \param A : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. \param B : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. \param C : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. \param featureMoments : Feature database. */ - vpFeatureMomentAreaNormalized(vpMomentDatabase& moments,double A, double B, double C,vpFeatureMomentDatabase* featureMoments=NULL) : - vpFeatureMoment(moments,A,B,C,featureMoments,1){} + vpFeatureMomentAreaNormalized(vpMomentDatabase& database,double A_, double B_, double C_,vpFeatureMomentDatabase* featureMoments=NULL) + : vpFeatureMoment(database,A_,B_,C_,featureMoments,1){} void compute_interaction(); /*! associated moment name */ - const char* momentName(){ return "vpMomentAreaNormalized";} + const char* momentName() const { return "vpMomentAreaNormalized";} /*! feature name */ - const char* name(){ return "vpFeatureMomentAreaNormalized";} + const char* name() const { return "vpFeatureMomentAreaNormalized";} }; @@ -160,24 +160,24 @@ class VISP_EXPORT vpFeatureMomentAreaNormalized : public vpFeatureMoment{ public: /*! Initializes the feature with information about the database of moment primitives, the object plane and feature database. - \param moments : Moment database. The database of moment primitives (first parameter) is mandatory. It is used to access different moment values later used to compute the final matrix. - \param A : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. - \param B : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. - \param C : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. + \param data_base : Moment database. The database of moment primitives (first parameter) is mandatory. It is used to access different moment values later used to compute the final matrix. + \param A_ : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. + \param B_ : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. + \param C_ : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. \param featureMoments : Feature database. */ - vpFeatureMomentAreaNormalized(vpMomentDatabase& moments,double A, double B, double C,vpFeatureMomentDatabase* featureMoments=NULL) : - vpFeatureMoment(moments,A,B,C,featureMoments,1){} + vpFeatureMomentAreaNormalized(vpMomentDatabase& data_base,double A_, double B_, double C_,vpFeatureMomentDatabase* featureMoments=NULL) : + vpFeatureMoment(data_base,A_,B_,C_,featureMoments,1){} void compute_interaction(); /*! associated moment name */ - const char* momentName(){ return "vpMomentAreaNormalized";} + const char* momentName() const { return "vpMomentAreaNormalized";} /*! feature name */ - const char* name(){ return "vpFeatureMomentAreaNormalized";} + const char* name() const { return "vpFeatureMomentAreaNormalized";} }; #endif diff --git a/src/visual-feature/vpFeatureMomentBasic.cpp b/src/visual-feature/vpFeatureMomentBasic.cpp index 102ce4a76d37d0cd765bd4f9785f0cfc45b85c83..08ef40ebf6732ac23cc9b15c4703f0aba228dc8a 100644 --- a/src/visual-feature/vpFeatureMomentBasic.cpp +++ b/src/visual-feature/vpFeatureMomentBasic.cpp @@ -3,7 +3,7 @@ * $Id: vpFeatureMomentImpl.cpp 3317 2011-09-06 14:14:47Z fnovotny $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -48,14 +48,14 @@ #include <limits> /*! Default constructor. - \param moments : Database of moment primitives. - \param A : First plane coefficient for a plane equation of the following type Ax+By+C=1/Z. - \param B : Second plane coefficient for a plane equation of the following type Ax+By+C=1/Z. - \param C : Third plane coefficient for a plane equation of the following type Ax+By+C=1/Z. + \param data_base : Database of moment primitives. + \param A_ : First plane coefficient for a plane equation of the following type Ax+By+C=1/Z. + \param B_ : Second plane coefficient for a plane equation of the following type Ax+By+C=1/Z. + \param C_ : Third plane coefficient for a plane equation of the following type Ax+By+C=1/Z. \param featureMoments : Database of features. */ -vpFeatureMomentBasic::vpFeatureMomentBasic(vpMomentDatabase& moments,double A, double B, double C,vpFeatureMomentDatabase* featureMoments) : - vpFeatureMoment(moments,A,B,C,featureMoments) +vpFeatureMomentBasic::vpFeatureMomentBasic(vpMomentDatabase& data_base,double A_, double B_, double C_,vpFeatureMomentDatabase* featureMoments) : + vpFeatureMoment(data_base,A_,B_,C_,featureMoments), order(0) { } @@ -65,12 +65,12 @@ vpFeatureMomentBasic::vpFeatureMomentBasic(vpMomentDatabase& moments,double A, d */ void vpFeatureMomentBasic::compute_interaction(){ int delta; - vpMomentObject& momentObject = moment->getObject(); - order = momentObject.getOrder()+1; + const vpMomentObject& m = moment->getObject(); + order = m.getOrder()+1; interaction_matrices.resize(order*order); for(std::vector< vpMatrix >::iterator i=interaction_matrices.begin();i!=interaction_matrices.end();i++) i->resize(1,6); - if (momentObject.getType()==vpMomentObject::DISCRETE){ + if (m.getType()==vpMomentObject::DISCRETE){ delta=0; } else { delta=1; @@ -84,12 +84,12 @@ void vpFeatureMomentBasic::compute_interaction(){ int WZ = 5; //i=0;j=0 - interaction_matrices[0][0][VX] = -delta*A*momentObject.get(0, 0); - interaction_matrices[0][0][VY] = -delta*B*momentObject.get(0, 0); - interaction_matrices[0][0][VZ] = 3*delta*(A*momentObject.get(1, 0)+B*momentObject.get(0, 1)+C*momentObject.get(0, 0))-delta*C*momentObject.get(0, 0); + interaction_matrices[0][0][VX] = -delta*A*m.get(0, 0); + interaction_matrices[0][0][VY] = -delta*B*m.get(0, 0); + interaction_matrices[0][0][VZ] = 3*delta*(A*m.get(1, 0)+B*m.get(0, 1)+C*m.get(0, 0))-delta*C*m.get(0, 0); - interaction_matrices[0][0][WX] = 3*delta*momentObject.get(0, 1); - interaction_matrices[0][0][WY] = -3*delta*momentObject.get(1, 0); + interaction_matrices[0][0][WX] = 3*delta*m.get(0, 1); + interaction_matrices[0][0][WY] = -3*delta*m.get(1, 0); interaction_matrices[0][0][WZ] = 0; // int i=0; @@ -98,13 +98,13 @@ void vpFeatureMomentBasic::compute_interaction(){ unsigned int jm1_ = j_ - 1; unsigned int jp1_ = j_ + 1; - interaction_matrices[j_*order][0][VX] = -delta*A*momentObject.get(0, j_); - interaction_matrices[j_*order][0][VY] = -j*(A*momentObject.get(1,jm1_)+B*momentObject.get(0,j_)+C*momentObject.get(0,jm1_))-delta*B*momentObject.get(0,j_); - interaction_matrices[j_*order][0][VZ] = (j+3*delta)*(A*momentObject.get(1,j_)+B*momentObject.get(0,jp1_)+C*momentObject.get(0,j_))-delta*C*momentObject.get(0,j_); + interaction_matrices[j_*order][0][VX] = -delta*A*m.get(0, j_); + interaction_matrices[j_*order][0][VY] = -j*(A*m.get(1,jm1_)+B*m.get(0,j_)+C*m.get(0,jm1_))-delta*B*m.get(0,j_); + interaction_matrices[j_*order][0][VZ] = (j+3*delta)*(A*m.get(1,j_)+B*m.get(0,jp1_)+C*m.get(0,j_))-delta*C*m.get(0,j_); - interaction_matrices[j_*order][0][WX] = (j+3*delta)*momentObject.get(0,jp1_)+j*momentObject.get(0,jm1_); - interaction_matrices[j_*order][0][WY] = -(j+3*delta)*momentObject.get(1,j_); - interaction_matrices[j_*order][0][WZ] = -j*momentObject.get(1,jm1_); + interaction_matrices[j_*order][0][WX] = (j+3*delta)*m.get(0,jp1_)+j*m.get(0,jm1_); + interaction_matrices[j_*order][0][WY] = -(j+3*delta)*m.get(1,j_); + interaction_matrices[j_*order][0][WZ] = -j*m.get(1,jm1_); } //int j=0; @@ -113,13 +113,13 @@ void vpFeatureMomentBasic::compute_interaction(){ unsigned int im1_ = i_ - 1; unsigned int ip1_ = i_ + 1; - interaction_matrices[i_][0][VX] = -i*(A*momentObject.get(i_, 0)+B*momentObject.get(im1_, 1)+C*momentObject.get(im1_, 0))-delta*A*momentObject.get(i_, 0); - interaction_matrices[i_][0][VY] = -delta*B*momentObject.get(i_, 0); - interaction_matrices[i_][0][VZ] = (i+3*delta)*(A*momentObject.get(ip1_, 0)+B*momentObject.get(i_, 1)+C*momentObject.get(i_, 0))-delta*C*momentObject.get(i_, 0); + interaction_matrices[i_][0][VX] = -i*(A*m.get(i_, 0)+B*m.get(im1_, 1)+C*m.get(im1_, 0))-delta*A*m.get(i_, 0); + interaction_matrices[i_][0][VY] = -delta*B*m.get(i_, 0); + interaction_matrices[i_][0][VZ] = (i+3*delta)*(A*m.get(ip1_, 0)+B*m.get(i_, 1)+C*m.get(i_, 0))-delta*C*m.get(i_, 0); - interaction_matrices[i_][0][WX] = (i+3*delta)*momentObject.get(i_, 1); - interaction_matrices[i_][0][WY] = -(i+3*delta)*momentObject.get(ip1_, 0)-i*momentObject.get(im1_, 0); - interaction_matrices[i_][0][WZ] = i*momentObject.get(im1_, 1); + interaction_matrices[i_][0][WX] = (i+3*delta)*m.get(i_, 1); + interaction_matrices[i_][0][WY] = -(i+3*delta)*m.get(ip1_, 0)-i*m.get(im1_, 0); + interaction_matrices[i_][0][WZ] = i*m.get(im1_, 1); } for(int j=1; j<(int)order-1; j++){ @@ -132,13 +132,13 @@ void vpFeatureMomentBasic::compute_interaction(){ unsigned int im1_ = i_ - 1; unsigned int ip1_ = i_ + 1; - interaction_matrices[j_*order+i_][0][VX] = -i*(A*momentObject.get(i_, j_)+B*momentObject.get(im1_, jp1_)+C*momentObject.get(im1_,j_))-delta*A*momentObject.get(i_, j_); - interaction_matrices[j_*order+i_][0][VY] = -j*(A*momentObject.get(ip1_, jm1_)+B*momentObject.get(i_, j_)+C*momentObject.get(i_,jm1_))-delta*B*momentObject.get(i_, j_); - interaction_matrices[j_*order+i_][0][VZ] = (i+j+3*delta)*(A*momentObject.get(ip1_, j_)+B*momentObject.get(i_,jp1_)+C*momentObject.get(i_, j_))-delta*C*momentObject.get(i_,j_); + interaction_matrices[j_*order+i_][0][VX] = -i*(A*m.get(i_, j_)+B*m.get(im1_, jp1_)+C*m.get(im1_,j_))-delta*A*m.get(i_, j_); + interaction_matrices[j_*order+i_][0][VY] = -j*(A*m.get(ip1_, jm1_)+B*m.get(i_, j_)+C*m.get(i_,jm1_))-delta*B*m.get(i_, j_); + interaction_matrices[j_*order+i_][0][VZ] = (i+j+3*delta)*(A*m.get(ip1_, j_)+B*m.get(i_,jp1_)+C*m.get(i_, j_))-delta*C*m.get(i_,j_); - interaction_matrices[j_*order+i_][0][WX] = (i+j+3*delta)*momentObject.get(i_, jp1_)+j*momentObject.get(i_, jm1_); - interaction_matrices[j_*order+i_][0][WY] = -(i+j+3*delta)*momentObject.get(ip1_, j_)-i*momentObject.get(im1_, j_); - interaction_matrices[j_*order+i_][0][WZ] = i*momentObject.get(im1_,jp1_)-j*momentObject.get(ip1_, jm1_); + interaction_matrices[j_*order+i_][0][WX] = (i+j+3*delta)*m.get(i_, jp1_)+j*m.get(i_, jm1_); + interaction_matrices[j_*order+i_][0][WY] = -(i+j+3*delta)*m.get(ip1_, j_)-i*m.get(im1_, j_); + interaction_matrices[j_*order+i_][0][WZ] = i*m.get(im1_,jp1_)-j*m.get(ip1_, jm1_); } } } @@ -149,7 +149,7 @@ Interaction matrix corresponding to \f$ m_{ij} \f$ moment. \param select_two : second index (j). \return Interaction matrix \f$ L_{m_{ij}} \f$ corresponding to the moment. */ -vpMatrix vpFeatureMomentBasic::interaction (unsigned int select_one,unsigned int select_two){ +vpMatrix vpFeatureMomentBasic::interaction (unsigned int select_one,unsigned int select_two) const { if(select_one+select_two>moment->getObject().getOrder()) throw vpException(vpException::badValue,"The requested value has not been computed, you should specify a higher order."); return interaction_matrices[select_two*order+select_one]; diff --git a/src/visual-feature/vpFeatureMomentBasic.h b/src/visual-feature/vpFeatureMomentBasic.h index 90d889a338852d91b560d221d419e15dcee76792..64df62c7161fa3254321a6ce9e7f8955c54b394d 100644 --- a/src/visual-feature/vpFeatureMomentBasic.h +++ b/src/visual-feature/vpFeatureMomentBasic.h @@ -3,7 +3,7 @@ * $Id: vpFeatureMomentImpl.h 3317 2011-09-06 14:14:47Z fnovotny $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -71,7 +71,7 @@ class vpMomentDatabase; */ class VISP_EXPORT vpFeatureMomentBasic : public vpFeatureMoment{ -private: +protected: unsigned int order; public: vpFeatureMomentBasic(vpMomentDatabase& moments,double A, double B, double C,vpFeatureMomentDatabase* featureMoments=NULL); @@ -84,15 +84,15 @@ private: } #endif - vpMatrix interaction (unsigned int select_one,unsigned int select_two); + vpMatrix interaction (unsigned int select_one,unsigned int select_two) const; /*! Associated moment name. */ - const char* momentName(){ return "vpMomentBasic";} + const char* momentName() const { return "vpMomentBasic";} /*! Feature name. */ - const char* name(){ return "vpFeatureMomentBasic";} + const char* name() const { return "vpFeatureMomentBasic";} }; #endif diff --git a/src/visual-feature/vpFeatureMomentCInvariant.cpp b/src/visual-feature/vpFeatureMomentCInvariant.cpp index d00d1bd40f330ce86364131e728d140975c9ac2c..c6dbe9577c27b296b6a4dfb2c8b04a0dcfbfa7fb 100644 --- a/src/visual-feature/vpFeatureMomentCInvariant.cpp +++ b/src/visual-feature/vpFeatureMomentCInvariant.cpp @@ -3,7 +3,7 @@ * $Id: vpFeatureMomentImpl.cpp 3317 2011-09-06 14:14:47Z fnovotny $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -68,12 +68,12 @@ void vpFeatureMomentCInvariant::compute_interaction(){ bool found_FeatureMoment_centered; bool found_featuremoment_basic; - vpMomentObject& momentObject = moment->getObject(); - vpMomentCentered& momentCentered = (static_cast<vpMomentCentered&>(moments.get("vpMomentCentered",found_moment_centered))); - vpMomentCInvariant& momentCInvariant = (static_cast<vpMomentCInvariant&>(moments.get("vpMomentCInvariant",found_moment_cinvariant))); - vpFeatureMomentCentered& featureMomentCentered = (static_cast<vpFeatureMomentCentered&>(featureMoments->get("vpFeatureMomentCentered",found_FeatureMoment_centered))); + const vpMomentObject& momentObject = moment->getObject(); + const vpMomentCentered& momentCentered = (static_cast<const vpMomentCentered&>(moments.get("vpMomentCentered",found_moment_centered))); + const vpMomentCInvariant& momentCInvariant = (static_cast<const vpMomentCInvariant&>(moments.get("vpMomentCInvariant",found_moment_cinvariant))); + vpFeatureMomentCentered& featureMomentCentered = (static_cast<vpFeatureMomentCentered&>(featureMomentsDataBase->get("vpFeatureMomentCentered",found_FeatureMoment_centered))); - vpFeatureMomentBasic& featureMomentBasic= (static_cast<vpFeatureMomentBasic&>(featureMoments->get("vpFeatureMomentBasic",found_featuremoment_basic))); + vpFeatureMomentBasic& featureMomentBasic= (static_cast<vpFeatureMomentBasic&>(featureMomentsDataBase->get("vpFeatureMomentBasic",found_featuremoment_basic))); if(!found_featuremoment_basic) throw vpException(vpException::notInitialized,"vpFeatureMomentBasic not found"); @@ -194,7 +194,7 @@ void vpFeatureMomentCInvariant::compute_interaction(){ #include <vector> #include <iostream> #include <limits> - +#include <cmath> /*! Computes interaction matrix for space-scale-rotation invariants. Called internally. @@ -214,16 +214,15 @@ void vpFeatureMomentCInvariant::compute_interaction(){ bool found_FeatureMoment_centered; bool found_featuremoment_basic; - vpMomentObject& momentObject = moment->getObject(); - vpMomentCentered& momentCentered = (static_cast<vpMomentCentered&>(moments.get("vpMomentCentered",found_moment_centered))); - vpMomentCInvariant& momentCInvariant = (static_cast<vpMomentCInvariant&>(moments.get("vpMomentCInvariant",found_moment_cinvariant))); + const vpMomentObject& momentObject = moment->getObject(); + const vpMomentCentered& momentCentered = (static_cast<const vpMomentCentered&>(moments.get("vpMomentCentered",found_moment_centered))); + const vpMomentCInvariant& momentCInvariant = (static_cast<const vpMomentCInvariant&>(moments.get("vpMomentCInvariant",found_moment_cinvariant))); + vpFeatureMomentCentered& featureMomentCentered = (static_cast<vpFeatureMomentCentered&>(featureMomentsDataBase->get("vpFeatureMomentCentered",found_FeatureMoment_centered))); vpFeatureMomentBasic& featureMomentBasic= (static_cast<vpFeatureMomentBasic&>(featureMomentsDataBase->get("vpFeatureMomentBasic",found_featuremoment_basic))); if(!found_featuremoment_basic) throw vpException(vpException::notInitialized,"vpFeatureMomentBasic not found"); - - if(!found_moment_centered) throw vpException(vpException::notInitialized,"vpMomentCentered not found"); if(!found_moment_cinvariant) throw vpException(vpException::notInitialized,"vpMomentCInvariant not found"); if(!found_FeatureMoment_centered) throw vpException(vpException::notInitialized,"vpFeatureMomentCentered not found"); @@ -256,8 +255,6 @@ void vpFeatureMomentCInvariant::compute_interaction(){ double mu12 = momentCentered.get(1,2); double mu11 = momentCentered.get(1,1); - - double mu12_2 = mu12*mu12; double mu21_2 = mu21*mu21; double mu21_3 = mu21*mu21_2; @@ -282,7 +279,6 @@ void vpFeatureMomentCInvariant::compute_interaction(){ vpMatrix Lmu41 = featureMomentCentered.interaction(4,1); vpMatrix Lmu50 = featureMomentCentered.interaction(5,0); - LI[1]= -Lmu20*mu02-mu20*Lmu02+2*mu11*Lmu11; LI[2]= (-2*mu20+2*mu02)*Lmu02+8*mu11*Lmu11+(2*mu20-2*mu02)*Lmu20; @@ -317,6 +313,7 @@ void vpFeatureMomentCInvariant::compute_interaction(){ double s2 = momentCInvariant.getS(2); double c3 = momentCInvariant.getC(3); double c2 = momentCInvariant.getC(2); + double I1 = momentCInvariant.getII(1); double I2 = momentCInvariant.getII(2); double I3 = momentCInvariant.getII(3); @@ -331,7 +328,6 @@ void vpFeatureMomentCInvariant::compute_interaction(){ vpMatrix LI2 = 2 * (mu03 - 3 * mu21) * (Lc2) + 2 * (mu30 - 3 * mu12) * (Ls2); vpMatrix LI3 = Lmu20 + Lmu02; - vpMatrix La(1,6); double a; if(momentObject.getType()==vpMomentObject::DISCRETE){ @@ -341,8 +337,8 @@ void vpFeatureMomentCInvariant::compute_interaction(){ a = momentObject.get(0,0); La = featureMomentBasic.interaction(0,0); } - interaction_matrices.resize(14); + interaction_matrices.resize(14); interaction_matrices[0] = (1./(momentCInvariant.getI(2)*momentCInvariant.getI(2)))*(momentCInvariant.getI(2)*LI[1]-momentCInvariant.getI(1)*LI[2]); interaction_matrices[1] = (1./(momentCInvariant.getI(4)*momentCInvariant.getI(4)))*(momentCInvariant.getI(4)*LI[3]-momentCInvariant.getI(3)*LI[4]); @@ -355,7 +351,6 @@ void vpFeatureMomentCInvariant::compute_interaction(){ interaction_matrices[5] = (1./(momentCInvariant.getI(6)*momentCInvariant.getI(6)))*(momentCInvariant.getI(6)*LI[9]-momentCInvariant.getI(9)*LI[6]); - interaction_matrices[6] = (1./(momentCInvariant.getI(10)*momentCInvariant.getI(10)))*(momentCInvariant.getI(10)*LI[11]-momentCInvariant.getI(11)*LI[10]); interaction_matrices[7] = (1./(momentCInvariant.getI(10)*momentCInvariant.getI(10)))*(momentCInvariant.getI(10)*LI[12]-momentCInvariant.getI(12)*LI[10]); @@ -364,12 +359,12 @@ void vpFeatureMomentCInvariant::compute_interaction(){ interaction_matrices[9] = (1./(momentCInvariant.getI(15)*momentCInvariant.getI(15)))*(momentCInvariant.getI(15)*LI[14]-momentCInvariant.getI(14)*LI[15]); - interaction_matrices[10] = (Lc2 * c3 + c2 * Lc3 + Ls2 * s3 + s2 * Ls3) * sqrt(a) / I1 * pow(I3, -0.3e1 / 0.2e1) + (c2 * c3 + s2 * s3) * pow(a, -0.1e1 / 0.2e1) / I1 * pow(I3, -0.3e1 / 0.2e1) * La / 0.2e1 - (c2 * c3 + s2 * s3) * sqrt(a) * pow(I1, -0.2e1) * pow(I3, -0.3e1 / 0.2e1) * LI1 - 0.3e1 / 0.2e1 * (c2 * c3 + s2 * s3) * sqrt(a) / I1 * pow(I3, -0.5e1 / 0.2e1) * LI3; interaction_matrices[11] = (Ls2 * c3 + s2 * Lc3 - Lc2 * s3 - c2 * Ls3) * sqrt(a) / I1 * pow(I3, -0.3e1 / 0.2e1) + (s2 * c3 - c2 * s3) * pow(a, -0.1e1 / 0.2e1) / I1 * pow(I3, -0.3e1 / 0.2e1) * La / 0.2e1 - (s2 * c3 - c2 * s3) * sqrt(a) * pow(I1, -0.2e1) * pow(I3, -0.3e1 / 0.2e1) * LI1 - 0.3e1 / 0.2e1 * (s2 * c3 - c2 * s3) * sqrt(a) / I1 * pow(I3, -0.5e1 / 0.2e1) * LI3; interaction_matrices[12] = (1/(I3*I3))*LI1-(2*I1/(I3*I3*I3))*LI3; + interaction_matrices[13] = (I2/(I3*I3*I3))*La+(a/(I3*I3*I3))*LI2-(3*a*I2/(I3*I3*I3*I3))*LI3; } #endif diff --git a/src/visual-feature/vpFeatureMomentCInvariant.h b/src/visual-feature/vpFeatureMomentCInvariant.h index b6218c45dc0cd5c79887a1005dff11a2e2602615..258266822e7b0fe4b753210c3f0f235d50f81819 100644 --- a/src/visual-feature/vpFeatureMomentCInvariant.h +++ b/src/visual-feature/vpFeatureMomentCInvariant.h @@ -3,7 +3,7 @@ * $Id: vpFeatureMomentImpl.h 3317 2011-09-06 14:14:47Z fnovotny $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -96,11 +96,11 @@ class VISP_EXPORT vpFeatureMomentCInvariant : public vpFeatureMoment{ /*! associated moment name */ - const char* momentName(){ return "vpMomentCInvariant";} + const char* momentName() const { return "vpMomentCInvariant";} /*! feature name */ - const char* name(){ return "vpFeatureMomentCInvariant";} + const char* name() const { return "vpFeatureMomentCInvariant";} /*! Shortcut selector for \f$C_1\f$. @@ -201,24 +201,24 @@ class VISP_EXPORT vpFeatureMomentCInvariant : public vpFeatureMoment{ public: /*! Initializes the feature with information about the database of moment primitives, the object plane and feature database. - \param moments : Moment database. The database of moment primitives (first parameter) is mandatory. It is used to access different moment values later used to compute the final matrix. - \param A : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. - \param B : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. - \param C : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. + \param data_base : Moment database. The database of moment primitives (first parameter) is mandatory. It is used to access different moment values later used to compute the final matrix. + \param A_ : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. + \param B_ : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. + \param C_ : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. \param featureMoments : Feature database. */ - vpFeatureMomentCInvariant(vpMomentDatabase& moments,double A, double B, double C,vpFeatureMomentDatabase* featureMoments=NULL) : - vpFeatureMoment(moments,A,B,C,featureMoments,16){} + vpFeatureMomentCInvariant(vpMomentDatabase& data_base,double A_, double B_, double C_,vpFeatureMomentDatabase* featureMoments=NULL) : + vpFeatureMoment(data_base,A_,B_,C_,featureMoments,16){} void compute_interaction(); /*! associated moment name */ - const char* momentName(){ return "vpMomentCInvariant";} + const char* momentName() const { return "vpMomentCInvariant";} /*! feature name */ - const char* name(){ return "vpFeatureMomentCInvariant";} + const char* name() const { return "vpFeatureMomentCInvariant";} /*! Shortcut selector for \f$C_1\f$. diff --git a/src/visual-feature/vpFeatureMomentCentered.cpp b/src/visual-feature/vpFeatureMomentCentered.cpp index 246230aa0241744c041d91029f4418fed6b1d7f9..36b7b62902362fb2cd61258d3868d912e8128b4f 100644 --- a/src/visual-feature/vpFeatureMomentCentered.cpp +++ b/src/visual-feature/vpFeatureMomentCentered.cpp @@ -3,7 +3,7 @@ * $Id: vpFeatureMomentImpl.cpp 3317 2011-09-06 14:14:47Z fnovotny $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -55,15 +55,15 @@ /*! Default constructor \param moments : Database of moment primitives. - \param A : First plane coefficient for a plane equation of the following type Ax+By+C=1/Z. - \param B : Second plane coefficient for a plane equation of the following type Ax+By+C=1/Z. - \param C : Third plane coefficient for a plane equation of the following type Ax+By+C=1/Z. + \param A_ : First plane coefficient for a plane equation of the following type Ax+By+C=1/Z. + \param B_ : Second plane coefficient for a plane equation of the following type Ax+By+C=1/Z. + \param C_ : Third plane coefficient for a plane equation of the following type Ax+By+C=1/Z. \param featureMoments : Database of features. */ vpFeatureMomentCentered::vpFeatureMomentCentered(vpMomentDatabase& moments, - double A, double B, double C, - vpFeatureMomentDatabase* featureMoments) : - vpFeatureMoment(moments,A,B,C,featureMoments) + double A_, double B_, double C_, + vpFeatureMomentDatabase* featureMoments) + : vpFeatureMoment(moments,A_,B_,C_,featureMoments), order(0) { } @@ -95,15 +95,15 @@ void vpFeatureMomentCentered::compute_interaction(){ bool found_feature_gravity_center; bool found_moment_gravity; - vpMomentObject& momentObject = moment->getObject(); + const vpMomentObject& momentObject = moment->getObject(); order = momentObject.getOrder()+1; interaction_matrices.resize(order*order); for(std::vector< vpMatrix >::iterator i=interaction_matrices.begin();i!=interaction_matrices.end(); ++i) i->resize(1,6); - vpFeatureMomentBasic& featureMomentBasic= (static_cast<vpFeatureMomentBasic&>(featureMoments->get("vpFeatureMomentBasic",found_featuremoment_basic))); - vpFeatureMomentGravityCenter& featureMomentGravityCenter= (static_cast<vpFeatureMomentGravityCenter&>(featureMoments->get("vpFeatureMomentGravityCenter",found_feature_gravity_center))); - vpMomentGravityCenter& momentGravity = static_cast<vpMomentGravityCenter&>(moments.get("vpMomentGravityCenter",found_moment_gravity)); + vpFeatureMomentBasic& featureMomentBasic= (static_cast<vpFeatureMomentBasic&>(featureMomentsDataBase->get("vpFeatureMomentBasic",found_featuremoment_basic))); + vpFeatureMomentGravityCenter& featureMomentGravityCenter= (static_cast<vpFeatureMomentGravityCenter&>(featureMomentsDataBase->get("vpFeatureMomentGravityCenter",found_feature_gravity_center))); + const vpMomentGravityCenter& momentGravity = static_cast<const vpMomentGravityCenter&>(moments.get("vpMomentGravityCenter",found_moment_gravity)); vpMatrix zeros(1,6); for(int i=0;i<6;i++) zeros[0][i]=0; @@ -147,15 +147,14 @@ void vpFeatureMomentCentered::compute_interaction(){ /*! Default constructor - \param moments : Database of moment primitives. - \param A : First plane coefficient for a plane equation of the following type Ax+By+C=1/Z. - \param B : Second plane coefficient for a plane equation of the following type Ax+By+C=1/Z. - \param C : Third plane coefficient for a plane equation of the following type Ax+By+C=1/Z. + \param data_base : Database of moment primitives. + \param A_ : First plane coefficient for a plane equation of the following type Ax+By+C=1/Z. + \param B_ : Second plane coefficient for a plane equation of the following type Ax+By+C=1/Z. + \param C_ : Third plane coefficient for a plane equation of the following type Ax+By+C=1/Z. \param featureMoments : Database of features. */ -vpFeatureMomentCentered::vpFeatureMomentCentered(vpMomentDatabase& moments,double A, double B, double C,vpFeatureMomentDatabase* featureMoments) : - vpFeatureMoment(moments,A,B,C,featureMoments) - +vpFeatureMomentCentered::vpFeatureMomentCentered(vpMomentDatabase& data_base,double A_, double B_, double C_,vpFeatureMomentDatabase* featureMoments) + : vpFeatureMoment(data_base,A_,B_,C_,featureMoments), order(0) { } @@ -165,7 +164,7 @@ Interaction matrix corresponding to \f$ \mu_{ij} \f$ moment \param select_two : second index (j) \return Interaction matrix corresponding to the moment */ -vpMatrix vpFeatureMomentCentered::interaction (unsigned int select_one,unsigned int select_two){ +vpMatrix vpFeatureMomentCentered::interaction (unsigned int select_one,unsigned int select_two) const { if(select_one+select_two>moment->getObject().getOrder()) throw vpException(vpException::badValue,"The requested value has not been computed, you should specify a higher order."); return interaction_matrices[select_two*order+select_one]; @@ -184,15 +183,15 @@ void vpFeatureMomentCentered::compute_interaction(){ bool found_moment_centered; bool found_moment_gravity; - vpMomentCentered& momentCentered= (static_cast<vpMomentCentered&>(moments.get("vpMomentCentered",found_moment_centered))); - vpMomentGravityCenter& momentGravity = static_cast<vpMomentGravityCenter&>(moments.get("vpMomentGravityCenter",found_moment_gravity)); + const vpMomentCentered& momentCentered= (static_cast<const vpMomentCentered&>(moments.get("vpMomentCentered",found_moment_centered))); + const vpMomentGravityCenter& momentGravity = static_cast<const vpMomentGravityCenter&>(moments.get("vpMomentGravityCenter",found_moment_gravity)); if(!found_moment_centered) throw vpException(vpException::notInitialized,"vpMomentCentered not found"); if(!found_moment_gravity) throw vpException(vpException::notInitialized,"vpMomentGravityCenter not found"); int delta; int epsilon; - vpMomentObject& momentObject = moment->getObject(); + const vpMomentObject& momentObject = moment->getObject(); order = momentObject.getOrder()+1; interaction_matrices.resize(order*order); for (std::vector< vpMatrix >::iterator i=interaction_matrices.begin(); i!=interaction_matrices.end(); ++i) @@ -299,4 +298,16 @@ void vpFeatureMomentCentered::compute_interaction(){ } } } + + std::ostream& operator<<(std::ostream & os, const vpFeatureMomentCentered& mu){ + vpTRACE(" << CENTRED MOMENTS >>"); + unsigned int order_m_1 = (unsigned int)(mu.order - 1); + for(unsigned int i=0; i<order_m_1; i++){ + for(unsigned int j=0; j<order_m_1-i; j++){ + std::cout << "L_mu[" << i << "," << j << "] = "; + mu.interaction(i,j).matlabPrint(std::cout); + } + } + return os; + } #endif diff --git a/src/visual-feature/vpFeatureMomentCentered.h b/src/visual-feature/vpFeatureMomentCentered.h index 80e9100cefc521b768b215a1eea085c0c4af81ac..ccbebc666364e87169e61035a85f33b03c328a1f 100644 --- a/src/visual-feature/vpFeatureMomentCentered.h +++ b/src/visual-feature/vpFeatureMomentCentered.h @@ -3,7 +3,7 @@ * $Id: vpFeatureMomentImpl.h 3317 2011-09-06 14:14:47Z fnovotny $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -85,11 +85,11 @@ private: /*! associated moment name */ - const char* momentName(){ return "vpMomentCentered";} + const char* momentName() const { return "vpMomentCentered";} /*! feature name */ - const char* name(){ return "vpFeatureMomentCentered";} + const char* name() const { return "vpFeatureMomentCentered";} }; @@ -117,7 +117,7 @@ class vpMomentDatabase; - vpMomentCentered */ class VISP_EXPORT vpFeatureMomentCentered : public vpFeatureMoment{ -private: +protected: unsigned int order; public: vpFeatureMomentCentered(vpMomentDatabase& moments,double A, double B, double C,vpFeatureMomentDatabase* featureMoments=NULL); @@ -130,18 +130,18 @@ private: } #endif - vpMatrix interaction (unsigned int select_one,unsigned int select_two); + vpMatrix interaction (unsigned int select_one,unsigned int select_two) const; /*! associated moment name */ - const char* momentName(){ return "vpMomentCentered";} + const char* momentName() const { return "vpMomentCentered";} /*! feature name */ - const char* name(){ return "vpFeatureMomentCentered";} - + const char* name() const { return "vpFeatureMomentCentered";} + friend VISP_EXPORT std::ostream & operator<<(std::ostream & os, const vpFeatureMomentCentered& v); }; #endif diff --git a/src/visual-feature/vpFeatureMomentCommon.cpp b/src/visual-feature/vpFeatureMomentCommon.cpp index 40a6e253df349e8be27dfcabc61729f4ed3e6328..7b4bf31653b49f55a721894db6543e592994153c 100644 --- a/src/visual-feature/vpFeatureMomentCommon.cpp +++ b/src/visual-feature/vpFeatureMomentCommon.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureMomentCommon.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeatureMomentCommon.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -57,7 +57,7 @@ vpFeatureMomentCommon::vpFeatureMomentCommon(vpMomentDatabase& moments,double A, featureAlpha(moments,A,B,C), featureCentered(moments,A,B,C), featureMomentBasic(moments,A,B,C), - feature_moment_area(moments,A,B,C) + feature_moment_area(moments,A,B,C) { featureGravity.linkTo(*this); diff --git a/src/visual-feature/vpFeatureMomentCommon.h b/src/visual-feature/vpFeatureMomentCommon.h index 911e9cb1ccdc3d73af57bafa07960d4a01a9a2c2..4bb96ae9c8f86136038c3392110ebec44758f7a8 100644 --- a/src/visual-feature/vpFeatureMomentCommon.h +++ b/src/visual-feature/vpFeatureMomentCommon.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureMomentCommon.h 4276 2013-06-25 12:36:48Z fspindle $ + * $Id: vpFeatureMomentCommon.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/visual-feature/vpFeatureMomentDatabase.cpp b/src/visual-feature/vpFeatureMomentDatabase.cpp index 908a8749bd1cb352a819dcced409233c9d31a07d..be3943425084e7e0086befbd2929a7932057f681 100644 --- a/src/visual-feature/vpFeatureMomentDatabase.cpp +++ b/src/visual-feature/vpFeatureMomentDatabase.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureMomentDatabase.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeatureMomentDatabase.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/visual-feature/vpFeatureMomentDatabase.h b/src/visual-feature/vpFeatureMomentDatabase.h index 747b08e6103465fb69575589c6a0a61772b4972b..2efa12a9999217b6c1fb3e0ccffdef4645e2a789 100644 --- a/src/visual-feature/vpFeatureMomentDatabase.h +++ b/src/visual-feature/vpFeatureMomentDatabase.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureMomentDatabase.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeatureMomentDatabase.h 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -162,7 +162,11 @@ class VISP_EXPORT vpFeatureMomentDatabase{ void add(vpFeatureMoment& featureMoment,char* name); public: /*! - virtual destructor. + Default constructor. + */ + vpFeatureMomentDatabase() {} + /*! + Virtual destructor that does nothing. */ virtual ~vpFeatureMomentDatabase() {} virtual void updateAll(double A=0.0, double B=0.0, double C=1.0); diff --git a/src/visual-feature/vpFeatureMomentGravityCenter.cpp b/src/visual-feature/vpFeatureMomentGravityCenter.cpp index 8a8f032b53014c1c9469161abcdf744b04f6e106..425d757d60da20660ef89eaae6f016a6bdf098ef 100644 --- a/src/visual-feature/vpFeatureMomentGravityCenter.cpp +++ b/src/visual-feature/vpFeatureMomentGravityCenter.cpp @@ -3,7 +3,7 @@ * $Id: vpFeatureMomentImpl.cpp 3317 2011-09-06 14:14:47Z fnovotny $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -63,8 +63,8 @@ void vpFeatureMomentGravityCenter::compute_interaction(){ bool found_featuremoment_basic; - vpFeatureMomentBasic& featureMomentBasic= (static_cast<vpFeatureMomentBasic&>(featureMoments->get("vpFeatureMomentBasic",found_featuremoment_basic))); - vpMomentObject& momentObject = moment->getObject(); + vpFeatureMomentBasic& featureMomentBasic= (static_cast<vpFeatureMomentBasic&>(featureMomentsDataBase->get("vpFeatureMomentBasic",found_featuremoment_basic))); + const vpMomentObject& momentObject = moment->getObject(); if(!found_featuremoment_basic) throw vpException(vpException::notInitialized,"vpFeatureMomentBasic not found"); @@ -104,11 +104,11 @@ void vpFeatureMomentGravityCenter::compute_interaction(){ bool found_moment_centered; bool found_moment_gravity; - vpMomentCentered& momentCentered= (static_cast<vpMomentCentered&>(moments.get("vpMomentCentered",found_moment_centered))); - vpMomentGravityCenter& momentGravity = static_cast<vpMomentGravityCenter&>(moments.get("vpMomentGravityCenter",found_moment_gravity)); + const vpMomentCentered& momentCentered= (static_cast<const vpMomentCentered&>(moments.get("vpMomentCentered",found_moment_centered))); + const vpMomentGravityCenter& momentGravity = static_cast<const vpMomentGravityCenter&>(moments.get("vpMomentGravityCenter",found_moment_gravity)); - vpMomentObject& momentObject = moment->getObject(); + const vpMomentObject& momentObject = moment->getObject(); if(!found_moment_centered) throw vpException(vpException::notInitialized,"vpMomentCentered not found"); if(!found_moment_gravity) throw vpException(vpException::notInitialized,"vpMomentGravityCenter not found"); diff --git a/src/visual-feature/vpFeatureMomentGravityCenter.h b/src/visual-feature/vpFeatureMomentGravityCenter.h index 6cdb1da1387b58932fcd067d218e0a1e1c711e25..e79af85c957a01e99e9e558bb721a45f1f8c28e0 100644 --- a/src/visual-feature/vpFeatureMomentGravityCenter.h +++ b/src/visual-feature/vpFeatureMomentGravityCenter.h @@ -3,7 +3,7 @@ * $Id: vpFeatureMomentImpl.h 3317 2011-09-06 14:14:47Z fnovotny $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -147,24 +147,24 @@ class VISP_EXPORT vpFeatureMomentGravityCenter: public vpFeatureMoment{ public: /*! Initializes the feature with information about the database of moment primitives, the object plane and feature database. - \param moments : Moment database. The database of moment primitives (first parameter) is mandatory. It is used to access different moment values later used to compute the final matrix. - \param A : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. - \param B : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. - \param C : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. + \param database : Moment database. The database of moment primitives (first parameter) is mandatory. It is used to access different moment values later used to compute the final matrix. + \param A_ : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. + \param B_ : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. + \param C_ : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. \param featureMoments : Feature database. */ - vpFeatureMomentGravityCenter(vpMomentDatabase& moments,double A, double B, double C,vpFeatureMomentDatabase* featureMoments=NULL) : - vpFeatureMoment(moments,A,B,C,featureMoments,2) + vpFeatureMomentGravityCenter(vpMomentDatabase& database,double A_, double B_, double C_,vpFeatureMomentDatabase* featureMoments=NULL) + : vpFeatureMoment(database,A_,B_,C_,featureMoments,2) {} void compute_interaction(); /*! Associated moment name. */ - const char* momentName(){ return "vpMomentGravityCenter";} + const char* momentName() const { return "vpMomentGravityCenter";} /*! Feature name. */ - const char* name(){ return "vpFeatureMomentGravityCenter";} + const char* name() const { return "vpFeatureMomentGravityCenter";} /*! Shortcut selector for \f$x_g\f$. @@ -208,24 +208,24 @@ class VISP_EXPORT vpFeatureMomentGravityCenter: public vpFeatureMoment{ public: /*! Initializes the feature with information about the database of moment primitives, the object plane and feature database. - \param moments : Moment database. The database of moment primitives (first parameter) is mandatory. It is used to access different moment values later used to compute the final matrix. - \param A : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. - \param B : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. - \param C : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. + \param data_base : Moment database. The database of moment primitives (first parameter) is mandatory. It is used to access different moment values later used to compute the final matrix. + \param A_ : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. + \param B_ : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. + \param C_ : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. \param featureMoments : Feature database. */ - vpFeatureMomentGravityCenter(vpMomentDatabase& moments,double A, double B, double C,vpFeatureMomentDatabase* featureMoments=NULL) : - vpFeatureMoment(moments,A,B,C,featureMoments,2) + vpFeatureMomentGravityCenter(vpMomentDatabase& data_base,double A_, double B_, double C_,vpFeatureMomentDatabase* featureMoments=NULL) : + vpFeatureMoment(data_base,A_,B_,C_,featureMoments,2) {} void compute_interaction(); /*! Associated moment name. */ - const char* momentName(){ return "vpMomentGravityCenter";} + const char* momentName() const { return "vpMomentGravityCenter";} /*! Feature name. */ - const char* name(){ return "vpFeatureMomentGravityCenter";} + const char* name() const { return "vpFeatureMomentGravityCenter";} /*! Shortcut selector for \f$x_g\f$. diff --git a/src/visual-feature/vpFeatureMomentGravityCenterNormalized.cpp b/src/visual-feature/vpFeatureMomentGravityCenterNormalized.cpp index b048413fb23519698ffb37803e60737fa1acabf8..88b590576726bd64f8ac59b1842fe2eb7b43e08d 100644 --- a/src/visual-feature/vpFeatureMomentGravityCenterNormalized.cpp +++ b/src/visual-feature/vpFeatureMomentGravityCenterNormalized.cpp @@ -3,7 +3,7 @@ * $Id: vpFeatureMomentImpl.cpp 3317 2011-09-06 14:14:47Z fnovotny $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -71,10 +71,10 @@ void vpFeatureMomentGravityCenterNormalized::compute_interaction(){ bool found_featuremoment_gravity; bool found_featuremoment_surfacenormalized; - vpMomentAreaNormalized& momentSurfaceNormalized = static_cast<vpMomentAreaNormalized&>(moments.get("vpMomentAreaNormalized",found_moment_surface_normalized)); - vpMomentGravityCenter& momentGravity = static_cast<vpMomentGravityCenter&>(moments.get("vpMomentGravityCenter",found_moment_gravity)); - vpFeatureMomentGravityCenter& featureMomentGravity = (static_cast<vpFeatureMomentGravityCenter&>(featureMoments->get("vpFeatureMomentGravityCenter",found_featuremoment_gravity))); - vpFeatureMomentAreaNormalized featureMomentAreaNormalized = (static_cast<vpFeatureMomentAreaNormalized&>(featureMoments->get("vpFeatureMomentAreaNormalized",found_featuremoment_surfacenormalized))); + const vpMomentAreaNormalized& momentSurfaceNormalized = static_cast<const vpMomentAreaNormalized&>(moments.get("vpMomentAreaNormalized",found_moment_surface_normalized)); + const vpMomentGravityCenter& momentGravity = static_cast<const vpMomentGravityCenter&>(moments.get("vpMomentGravityCenter",found_moment_gravity)); + vpFeatureMomentGravityCenter& featureMomentGravity = (static_cast<vpFeatureMomentGravityCenter&>(featureMomentsDataBase->get("vpFeatureMomentGravityCenter",found_featuremoment_gravity))); + vpFeatureMomentAreaNormalized featureMomentAreaNormalized = (static_cast<vpFeatureMomentAreaNormalized&>(featureMomentsDataBase->get("vpFeatureMomentAreaNormalized",found_featuremoment_surfacenormalized))); if(!found_moment_surface_normalized) throw vpException(vpException::notInitialized,"vpMomentAreaNormalized not found"); if(!found_moment_gravity) throw vpException(vpException::notInitialized,"vpMomentGravityCenter not found"); @@ -117,15 +117,15 @@ void vpFeatureMomentGravityCenterNormalized::compute_interaction(){ bool found_moment_gravity; bool found_moment_centered; - vpMomentCentered& momentCentered = static_cast<vpMomentCentered&>(moments.get("vpMomentCentered",found_moment_centered)); - vpMomentGravityCenter& momentGravity = static_cast<vpMomentGravityCenter&>(moments.get("vpMomentGravityCenter",found_moment_gravity)); - vpMomentAreaNormalized& momentSurfaceNormalized = static_cast<vpMomentAreaNormalized&>(moments.get("vpMomentAreaNormalized",found_moment_surface_normalized)); + const vpMomentCentered& momentCentered = static_cast<const vpMomentCentered&>(moments.get("vpMomentCentered",found_moment_centered)); + const vpMomentGravityCenter& momentGravity = static_cast<const vpMomentGravityCenter&>(moments.get("vpMomentGravityCenter",found_moment_gravity)); + const vpMomentAreaNormalized& momentSurfaceNormalized = static_cast<const vpMomentAreaNormalized&>(moments.get("vpMomentAreaNormalized",found_moment_surface_normalized)); if(!found_moment_surface_normalized) throw vpException(vpException::notInitialized,"vpMomentAreaNormalized not found"); if(!found_moment_gravity) throw vpException(vpException::notInitialized,"vpMomentGravityCenter not found"); if(!found_moment_centered) throw vpException(vpException::notInitialized,"vpMomentCentered not found"); - vpMomentObject& momentObject = moment->getObject(); + const vpMomentObject& momentObject = moment->getObject(); interaction_matrices[0].resize(1,6); interaction_matrices[1].resize(1,6); diff --git a/src/visual-feature/vpFeatureMomentGravityCenterNormalized.h b/src/visual-feature/vpFeatureMomentGravityCenterNormalized.h index e66685e221bb1d798b4b31c861780a287db00dea..f6a657e0670d1d75f7c463c6162a0bd3d191c1d2 100644 --- a/src/visual-feature/vpFeatureMomentGravityCenterNormalized.h +++ b/src/visual-feature/vpFeatureMomentGravityCenterNormalized.h @@ -3,7 +3,7 @@ * $Id: vpFeatureMomentImpl.h 3317 2011-09-06 14:14:47Z fnovotny $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -83,25 +83,25 @@ class VISP_EXPORT vpFeatureMomentGravityCenterNormalized : public vpFeatureMomen public: /*! Initializes the feature with information about the database of moment primitives, the object plane and feature database. - \param moments : Moment database. The database of moment primitives (first parameter) is mandatory. It is used to access different moment values later used to compute the final matrix. - \param A : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. - \param B : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. - \param C : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. + \param database : Moment database. The database of moment primitives (first parameter) is mandatory. It is used to access different moment values later used to compute the final matrix. + \param A_ : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. + \param B_ : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. + \param C_ : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. \param featureMoments : Feature database. */ - vpFeatureMomentGravityCenterNormalized(vpMomentDatabase& moments,double A, double B, double C,vpFeatureMomentDatabase* featureMoments=NULL) : - vpFeatureMoment(moments,A,B,C,featureMoments,2) + vpFeatureMomentGravityCenterNormalized(vpMomentDatabase& database,double A_, double B_, double C_,vpFeatureMomentDatabase* featureMoments=NULL) + : vpFeatureMoment(database,A_,B_,C_,featureMoments,2) {} void compute_interaction(); /*! associated moment name */ - const char* momentName(){ return "vpMomentGravityCenterNormalized";} + const char* momentName() const { return "vpMomentGravityCenterNormalized";} /*! feature name */ - const char* name(){ return "vpFeatureMomentGravityCenterNormalized";} + const char* name() const { return "vpFeatureMomentGravityCenterNormalized";} /*! Shortcut selector for \f$x_n\f$. @@ -219,25 +219,26 @@ class VISP_EXPORT vpFeatureMomentGravityCenterNormalized : public vpFeatureMomen public: /*! Initializes the feature with information about the database of moment primitives, the object plane and feature database. - \param moments : Moment database. The database of moment primitives (first parameter) is mandatory. It is used to access different moment values later used to compute the final matrix. - \param A : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. - \param B : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. - \param C : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. + \param data_base : Moment database. The database of moment primitives (first parameter) is mandatory. It is used to access different moment values later used to compute the final matrix. + \param A_ : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. + \param B_ : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. + \param C_ : Plane coefficient in a \f$ A \times x+B \times y + C = \frac{1}{Z} \f$ plane. \param featureMoments : Feature database. */ - vpFeatureMomentGravityCenterNormalized(vpMomentDatabase& moments,double A, double B, double C,vpFeatureMomentDatabase* featureMoments=NULL) : - vpFeatureMoment(moments,A,B,C,featureMoments,2) + vpFeatureMomentGravityCenterNormalized(vpMomentDatabase& data_base,double A_, double B_, double C_, + vpFeatureMomentDatabase* featureMoments=NULL) + : vpFeatureMoment(data_base,A_,B_,C_,featureMoments,2) {} void compute_interaction(); /*! associated moment name */ - const char* momentName(){ return "vpMomentGravityCenterNormalized";} + const char* momentName() const { return "vpMomentGravityCenterNormalized";} /*! feature name */ - const char* name(){ return "vpFeatureMomentGravityCenterNormalized";} + const char* name() const { return "vpFeatureMomentGravityCenterNormalized";} /*! Shortcut selector for \f$x_n\f$. diff --git a/src/visual-feature/vpFeaturePoint.cpp b/src/visual-feature/vpFeaturePoint.cpp index c2b590b16f7de7555650c031823dc00b59e3d5f0..0e216dac340e2c8808bf39f3851403c81f970eb0 100644 --- a/src/visual-feature/vpFeaturePoint.cpp +++ b/src/visual-feature/vpFeaturePoint.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeaturePoint.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeaturePoint.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -89,13 +89,12 @@ vpFeaturePoint::init() //default value Z (1 meters) Z = 1; - } /*! Default constructor that build a visual feature. */ -vpFeaturePoint::vpFeaturePoint() : vpBasicFeature() +vpFeaturePoint::vpFeaturePoint() : Z(1.) { init() ; } @@ -104,12 +103,12 @@ vpFeaturePoint::vpFeaturePoint() : vpBasicFeature() /*! Set the value of \f$ Z \f$ which represents the depth in the 3D camera frame. - \param Z : \f$ Z \f$ value to set. + \param Z_ : \f$ Z \f$ value to set. */ void -vpFeaturePoint::set_Z(const double Z) +vpFeaturePoint::set_Z(const double Z_) { - this->Z = Z ; + this->Z = Z_ ; flags[2] = true; } @@ -185,18 +184,18 @@ vpFeaturePoint::get_y() const parameters of the visual feature \f$ s \f$. \f$ Z \f$ is the 3D coordinate in the camera frame representing the depth. - \param x : \f$ x \f$ value to set. - \param y : \f$ y \f$ value to set. - \param Z : \f$ Z \f$ value to set. + \param x_ : \f$ x \f$ value to set. + \param y_ : \f$ y \f$ value to set. + \param Z_ : \f$ Z \f$ value to set. */ void -vpFeaturePoint::set_xyZ(const double x, - const double y, - const double Z) +vpFeaturePoint::set_xyZ(const double x_, + const double y_, + const double Z_) { - set_x(x) ; - set_y(y) ; - set_Z(Z) ; + set_x(x_) ; + set_y(y_) ; + set_Z(Z_) ; for(unsigned int i = 0; i < nbParameters; i++) flags[i] = true; } @@ -275,23 +274,23 @@ vpFeaturePoint::interaction(const unsigned int select) resetFlags(); } - double x = get_x() ; - double y = get_y() ; - double Z = get_Z() ; + double x_ = get_x() ; + double y_ = get_y() ; + double Z_ = get_Z() ; - if (Z < 0) + if (Z_ < 0) { vpERROR_TRACE("Point is behind the camera ") ; - std::cout <<"Z = " << Z << std::endl ; + std::cout <<"Z = " << Z_ << std::endl ; throw(vpFeatureException(vpFeatureException::badInitializationError, "Point is behind the camera ")) ; } - if (fabs(Z) < 1e-6) + if (fabs(Z_) < 1e-6) { vpERROR_TRACE("Point Z coordinates is null ") ; - std::cout <<"Z = " << Z << std::endl ; + std::cout <<"Z = " << Z_ << std::endl ; throw(vpFeatureException(vpFeatureException::badInitializationError, "Point Z coordinates is null")) ; @@ -301,12 +300,12 @@ vpFeaturePoint::interaction(const unsigned int select) { vpMatrix Lx(1,6) ; Lx = 0; - Lx[0][0] = -1/Z ; + Lx[0][0] = -1/Z_ ; Lx[0][1] = 0 ; - Lx[0][2] = x/Z ; - Lx[0][3] = x*y ; - Lx[0][4] = -(1+x*x) ; - Lx[0][5] = y ; + Lx[0][2] = x_/Z_ ; + Lx[0][3] = x_*y_ ; + Lx[0][4] = -(1+x_*x_) ; + Lx[0][5] = y_ ; L = vpMatrix::stackMatrices(L,Lx) ; } @@ -316,11 +315,11 @@ vpFeaturePoint::interaction(const unsigned int select) vpMatrix Ly(1,6) ; Ly = 0; Ly[0][0] = 0 ; - Ly[0][1] = -1/Z ; - Ly[0][2] = y/Z ; - Ly[0][3] = 1+y*y ; - Ly[0][4] = -x*y ; - Ly[0][5] = -x ; + Ly[0][1] = -1/Z_ ; + Ly[0][2] = y_/Z ; + Ly[0][3] = 1+y_*y_ ; + Ly[0][4] = -x_*y_ ; + Ly[0][5] = -x_ ; L = vpMatrix::stackMatrices(L,Ly) ; } @@ -435,32 +434,32 @@ vpFeaturePoint::print(const unsigned int select ) const See the vpFeaturePoint class description for more details about \f$ x \f$ and \f$ y \f$. - \param x : The \f$ x \f$ parameter. - \param y : The \f$ y \f$ parameter. - \param Z : The \f$ Z \f$ parameter. + \param x_ : The \f$ x \f$ parameter. + \param y_ : The \f$ y \f$ parameter. + \param Z_ : The \f$ Z \f$ parameter. */ void -vpFeaturePoint::buildFrom(const double x, const double y, const double Z) +vpFeaturePoint::buildFrom(const double x_, const double y_, const double Z_) { - s[0] = x ; - s[1] = y ; + s[0] = x_ ; + s[1] = y_ ; - this->Z = Z ; + this->Z = Z_ ; - if (Z < 0) + if (Z_ < 0) { vpERROR_TRACE("Point is behind the camera ") ; - std::cout <<"Z = " << Z << std::endl ; + std::cout <<"Z = " << Z_ << std::endl ; throw(vpFeatureException(vpFeatureException::badInitializationError, "Point is behind the camera ")) ; } - if (fabs(Z) < 1e-6) + if (fabs(Z_) < 1e-6) { vpERROR_TRACE("Point Z coordinates is null ") ; - std::cout <<"Z = " << Z << std::endl ; + std::cout <<"Z = " << Z_ << std::endl ; throw(vpFeatureException(vpFeatureException::badInitializationError, "Point Z coordinates is null")) ; diff --git a/src/visual-feature/vpFeaturePoint.h b/src/visual-feature/vpFeaturePoint.h index 4e56541fd549fd4863943c4f7c7964d3aeeda581..4efed37a93a1442c293781c3ef3616713036db46 100644 --- a/src/visual-feature/vpFeaturePoint.h +++ b/src/visual-feature/vpFeaturePoint.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeaturePoint.h 4233 2013-05-02 13:46:42Z fspindle $ + * $Id: vpFeaturePoint.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/visual-feature/vpFeaturePoint3D.cpp b/src/visual-feature/vpFeaturePoint3D.cpp index 72073ded50139931ac7baed93c20049b835fef52..3cea622347c2b44623289840797b226c226bec42 100644 --- a/src/visual-feature/vpFeaturePoint3D.cpp +++ b/src/visual-feature/vpFeaturePoint3D.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeaturePoint3D.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeaturePoint3D.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -96,7 +96,7 @@ vpFeaturePoint3D::init() initialize it to \f${\bf X} = (0, 0, 1)\f$. */ -vpFeaturePoint3D::vpFeaturePoint3D() : vpBasicFeature() +vpFeaturePoint3D::vpFeaturePoint3D() { init() ; } diff --git a/src/visual-feature/vpFeaturePoint3D.h b/src/visual-feature/vpFeaturePoint3D.h index 0fbb526ad4d61afaa551e199191fa3d615423398..b91984cb1b1e076a636a59b28b444530c8fe8ff2 100644 --- a/src/visual-feature/vpFeaturePoint3D.h +++ b/src/visual-feature/vpFeaturePoint3D.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeaturePoint3D.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeaturePoint3D.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/visual-feature/vpFeaturePointPolar.cpp b/src/visual-feature/vpFeaturePointPolar.cpp index f792b11943fcb6e447272524b9e4802f1d33a60f..d6775f9839f82f456f403629eb4b0cf6b8d4d92f 100644 --- a/src/visual-feature/vpFeaturePointPolar.cpp +++ b/src/visual-feature/vpFeaturePointPolar.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeaturePointPolar.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeaturePointPolar.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -108,7 +108,7 @@ vpFeaturePointPolar::init() matrix (see interaction()) is initialized to \f$Z=1\f$. */ -vpFeaturePointPolar::vpFeaturePointPolar() : vpBasicFeature() +vpFeaturePointPolar::vpFeaturePointPolar() : Z(1.) { init() ; } @@ -142,9 +142,9 @@ vpFeaturePointPolar::set_theta(const double theta) */ void -vpFeaturePointPolar::set_Z(const double Z) +vpFeaturePointPolar::set_Z(const double Z_) { - this->Z = Z ; + this->Z = Z_ ; flags[2] = true; } @@ -154,18 +154,18 @@ vpFeaturePointPolar::set_Z(const double Z) \param rho, theta : Polar coordinates \f$(\rho,\theta)\f$ of the image point. - \param Z : 3D depth of the point in the camera frame. + \param Z_ : 3D depth of the point in the camera frame. \sa set_rho(), set_theta(), set_Z() */ void vpFeaturePointPolar::set_rhoThetaZ(const double rho, const double theta, - const double Z) + const double Z_) { set_rho(rho) ; set_theta(theta) ; - set_Z(Z) ; + set_Z(Z_) ; for(unsigned int i = 0; i < nbParameters; i++) flags[i] = true; } @@ -311,10 +311,10 @@ vpFeaturePointPolar::interaction(const unsigned int select) double rho = get_rho() ; double theta = get_theta() ; - double Z = get_Z() ; + double Z_ = get_Z() ; - double c = cos(theta); - double s = sin(theta); + double c_ = cos(theta); + double s_ = sin(theta); double rho2 = rho*rho; @@ -326,20 +326,19 @@ vpFeaturePointPolar::interaction(const unsigned int select) "rho polar coordinate of the point is null")) ; } - - if (Z < 0) + if (Z_ < 0) { vpERROR_TRACE("Point is behind the camera ") ; - std::cout <<"Z = " << Z << std::endl ; + std::cout <<"Z = " << Z_ << std::endl ; throw(vpFeatureException(vpFeatureException::badInitializationError, "Point is behind the camera ")) ; } - if (fabs(Z) < 1e-6) + if (fabs(Z_) < 1e-6) { vpERROR_TRACE("Point Z coordinates is null ") ; - std::cout <<"Z = " << Z << std::endl ; + std::cout <<"Z = " << Z_ << std::endl ; throw(vpFeatureException(vpFeatureException::badInitializationError, "Point Z coordinates is null")) ; @@ -349,11 +348,11 @@ vpFeaturePointPolar::interaction(const unsigned int select) { vpMatrix Lrho(1,6) ; Lrho = 0; - Lrho[0][0] = -c/Z ; - Lrho[0][1] = -s/Z ; - Lrho[0][2] = rho/Z ; - Lrho[0][3] = (1+rho2)*s ; - Lrho[0][4] = -(1+rho2)*c ; + Lrho[0][0] = -c_/Z_ ; + Lrho[0][1] = -s_/Z_ ; + Lrho[0][2] = rho/Z_ ; + Lrho[0][3] = (1+rho2)*s_ ; + Lrho[0][4] = -(1+rho2)*c_ ; Lrho[0][5] = 0 ; // printf("Lrho: rho %f theta %f Z %f\n", rho, theta, Z); @@ -366,11 +365,11 @@ vpFeaturePointPolar::interaction(const unsigned int select) { vpMatrix Ltheta(1,6) ; Ltheta = 0; - Ltheta[0][0] = s/(rho*Z) ; - Ltheta[0][1] = -c/(rho*Z) ; + Ltheta[0][0] = s_/(rho*Z_) ; + Ltheta[0][1] = -c_/(rho*Z_) ; Ltheta[0][2] = 0 ; - Ltheta[0][3] = c/rho ; - Ltheta[0][4] = s/rho ; + Ltheta[0][3] = c_/rho ; + Ltheta[0][4] = s_/rho ; Ltheta[0][5] = -1 ; // printf("Ltheta: rho %f theta %f Z %f\n", rho, theta, Z); @@ -513,7 +512,7 @@ vpFeaturePointPolar::print(const unsigned int select ) const \param rho, theta : Polar coordinates \f$(\rho,\theta)\f$ of the image point. - \param Z : 3D depth of the point in the camera frame. + \param Z_ : 3D depth of the point in the camera frame. \exception vpFeatureException::badInitializationError: If the depth (\f$Z\f$ coordinate) is negative. That means that the 3D point is @@ -525,13 +524,13 @@ vpFeaturePointPolar::print(const unsigned int select ) const */ void vpFeaturePointPolar::buildFrom(const double rho, const double theta, - const double Z) + const double Z_) { s[0] = rho ; s[1] = theta ; - this->Z = Z ; + this->Z = Z_ ; if (Z < 0) { diff --git a/src/visual-feature/vpFeaturePointPolar.h b/src/visual-feature/vpFeaturePointPolar.h index 0be5c89151689d71088d73f515ed98feeb1c2342..a005d8d6639168ae173bf03b8921ffaaf1ee7f30 100644 --- a/src/visual-feature/vpFeaturePointPolar.h +++ b/src/visual-feature/vpFeaturePointPolar.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeaturePointPolar.h 4276 2013-06-25 12:36:48Z fspindle $ + * $Id: vpFeaturePointPolar.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/visual-feature/vpFeatureSegment.cpp b/src/visual-feature/vpFeatureSegment.cpp index 2892577089f5e52cbb7e2207d7ef127a569ba2ac..7ba11dd8222d9e7c6e5e038a720be67d0cb9716e 100644 --- a/src/visual-feature/vpFeatureSegment.cpp +++ b/src/visual-feature/vpFeatureSegment.cpp @@ -3,7 +3,7 @@ * $Id: vpFeatureThetaU.cpp 3530 2012-01-03 10:52:12Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -62,7 +62,6 @@ \brief class that defines the vpFeatureSegment visual feature */ - /*! Initialise the memory space requested for segment visual @@ -89,11 +88,9 @@ vpFeatureSegment::init() \param normalized : If true, use normalized features \f${\bf s} = (x_n, y_n, l_n, \alpha)\f$. If false, use non normalized features \f${\bf s} = (x_c, y_c, l_c, \alpha)\f$. */ -vpFeatureSegment::vpFeatureSegment(bool normalized): - vpBasicFeature() +vpFeatureSegment::vpFeatureSegment(bool normalized) + : xc_(0), yc_(0), l_(0), alpha_(0), Z1_(0), Z2_(0), cos_a_(0), sin_a_(0), normalized_(normalized) { - this->normalized_ = normalized; - init(); } diff --git a/src/visual-feature/vpFeatureSegment.h b/src/visual-feature/vpFeatureSegment.h index fc6d931bb63578054a7695e82050784a34b4124a..87a8f7627d5380799513ab1a10f6dfe529c1ad45 100644 --- a/src/visual-feature/vpFeatureSegment.h +++ b/src/visual-feature/vpFeatureSegment.h @@ -3,7 +3,7 @@ * $Id: vpFeatureThetaU.h 3530 2012-01-03 10:52:12Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/visual-feature/vpFeatureThetaU.cpp b/src/visual-feature/vpFeatureThetaU.cpp index 728948ac362034eda25fa915668e9e266766f726..cfee61e418b6779bdc8c7ccfb0909e084c58bb9b 100644 --- a/src/visual-feature/vpFeatureThetaU.cpp +++ b/src/visual-feature/vpFeatureThetaU.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureThetaU.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeatureThetaU.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -91,8 +91,8 @@ vpFeatureThetaU::init() visual feature. */ -vpFeatureThetaU::vpFeatureThetaU(vpFeatureThetaURotationRepresentationType r): - vpBasicFeature() +vpFeatureThetaU::vpFeatureThetaU(vpFeatureThetaURotationRepresentationType r) + : rotation(r) { //vpTRACE("0x%x", this); init() ; @@ -121,15 +121,12 @@ vpFeatureThetaU::vpFeatureThetaU(vpFeatureThetaURotationRepresentationType r): */ vpFeatureThetaU::vpFeatureThetaU(vpThetaUVector &tu, - vpFeatureThetaURotationRepresentationType r): - vpBasicFeature() + vpFeatureThetaURotationRepresentationType r) + : rotation(r) { init() ; buildFrom(tu) ; - - // kind of rotation representation - rotation = r; } /*! @@ -150,16 +147,13 @@ vpFeatureThetaU::vpFeatureThetaU(vpThetaUVector &tu, */ vpFeatureThetaU::vpFeatureThetaU(vpRotationMatrix &R, - vpFeatureThetaURotationRepresentationType r): - vpBasicFeature() + vpFeatureThetaURotationRepresentationType r) + : rotation(r) { init() ; vpThetaUVector tu(R) ; buildFrom(tu) ; - - // kind of rotation representation - rotation = r; } /*! @@ -182,17 +176,14 @@ vpFeatureThetaU::vpFeatureThetaU(vpRotationMatrix &R, */ vpFeatureThetaU::vpFeatureThetaU(vpHomogeneousMatrix &M, - vpFeatureThetaURotationRepresentationType r): - vpBasicFeature() + vpFeatureThetaURotationRepresentationType r) + : rotation(r) { init() ; vpRotationMatrix R ; M.extract(R) ; vpThetaUVector tu(R) ; buildFrom(tu) ; - - // kind of rotation representation - rotation = r; } /*! diff --git a/src/visual-feature/vpFeatureThetaU.h b/src/visual-feature/vpFeatureThetaU.h index 97c11da0875cd2e008d1e1892fc3ed8170746d74..431e19c2893415ada94f4b137d2fd661363e206c 100644 --- a/src/visual-feature/vpFeatureThetaU.h +++ b/src/visual-feature/vpFeatureThetaU.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureThetaU.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeatureThetaU.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/visual-feature/vpFeatureTranslation.cpp b/src/visual-feature/vpFeatureTranslation.cpp index 616e7f7f0b0ee363e4bee3afa42c15a5840c7767..7b7031b284fd309194ace4cacfea177878a5574d 100644 --- a/src/visual-feature/vpFeatureTranslation.cpp +++ b/src/visual-feature/vpFeatureTranslation.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureTranslation.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeatureTranslation.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -92,11 +92,10 @@ vpFeatureTranslation::init() \param r : Type of considered 3D translation feature. */ -vpFeatureTranslation::vpFeatureTranslation(vpFeatureTranslationRepresentationType r) : vpBasicFeature() +vpFeatureTranslation::vpFeatureTranslation(vpFeatureTranslationRepresentationType r) + : f2Mf1(), translation(r) { init() ; - - translation = r; } @@ -105,31 +104,30 @@ vpFeatureTranslation::vpFeatureTranslation(vpFeatureTranslationRepresentationTyp Constructor that build a 3D visual feature from an homogeneous matrix \f$ ^{{\cal{F}}_2}M_{{\cal{F}}_1} \f$ that represent the 3D transformation between two frames \f${\cal{F}}_1\f$ and \f${\cal{F}}_2\f$. - \param f2Mf1 [in] : 3D displacement that the camera has to achieve to + \param f2Mf1_ [in] : 3D displacement that the camera has to achieve to move from the frame \f${\cal{F}}_2\f$ to the frame \f${\cal{F}}_1\f$ (\f$ ^{{\cal{F}}_2}M_{{\cal{F}}_1} \f$). \param r : type of feature. It can be vpFeature::cdMc or vpFeature::cMo. */ -vpFeatureTranslation::vpFeatureTranslation(vpHomogeneousMatrix &f2Mf1, vpFeatureTranslationRepresentationType r) : vpBasicFeature() +vpFeatureTranslation::vpFeatureTranslation(vpHomogeneousMatrix &f2Mf1_, vpFeatureTranslationRepresentationType r) + : f2Mf1(), translation(r) { init() ; - translation = r; - - buildFrom(f2Mf1) ; + buildFrom(f2Mf1_) ; } /*! Build a 3D translation visual feature from an homogeneous matrix \f$ ^{{\cal{F}}_2}M_{{\cal{F}}_1} \f$ that represent the 3D transformation between two frames \f${\cal{F}}_1\f$ and \f${\cal{F}}_2\f$. - \param f2Mf1 [in] : 3D displacement that the camera has to achieve to + \param f2Mf1_ [in] : 3D displacement that the camera has to achieve to move from the frame \f${\cal{F}}_2\f$ to the frame \f${\cal{F}}_1\f$ (\f$ ^{{\cal{F}}_2}M_{{\cal{F}}_1} \f$). */ void -vpFeatureTranslation::buildFrom(const vpHomogeneousMatrix &f2Mf1) +vpFeatureTranslation::buildFrom(const vpHomogeneousMatrix &f2Mf1_) { - this->f2Mf1 = f2Mf1 ; + this->f2Mf1 = f2Mf1_ ; s[0] = f2Mf1[0][3] ; s[1] = f2Mf1[1][3] ; s[2] = f2Mf1[2][3] ; diff --git a/src/visual-feature/vpFeatureTranslation.h b/src/visual-feature/vpFeatureTranslation.h index 9a636cb27553bb3550d1019311188eb110763d8d..0636ff2248b7800def9a2cb332593fc39b1c689e 100644 --- a/src/visual-feature/vpFeatureTranslation.h +++ b/src/visual-feature/vpFeatureTranslation.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureTranslation.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeatureTranslation.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/visual-feature/vpFeatureVanishingPoint.cpp b/src/visual-feature/vpFeatureVanishingPoint.cpp index 287980279c101c2120862140df16891636e6bc00..c3cd4c4a5829d348046e57bb24361c60fb48d970 100644 --- a/src/visual-feature/vpFeatureVanishingPoint.cpp +++ b/src/visual-feature/vpFeatureVanishingPoint.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureVanishingPoint.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeatureVanishingPoint.cpp 4632 2014-02-03 17:06:40Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -77,7 +77,7 @@ vpFeatureVanishingPoint::init() //set_Z(1) ; } -vpFeatureVanishingPoint::vpFeatureVanishingPoint() : vpBasicFeature() +vpFeatureVanishingPoint::vpFeatureVanishingPoint() { init() ; } diff --git a/src/visual-feature/vpFeatureVanishingPoint.h b/src/visual-feature/vpFeatureVanishingPoint.h index a8467bcf0e6800b36eb61002689d67b458e79af5..d4dac922561a269201bc03a5d5956c094085849c 100644 --- a/src/visual-feature/vpFeatureVanishingPoint.h +++ b/src/visual-feature/vpFeatureVanishingPoint.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpFeatureVanishingPoint.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpFeatureVanishingPoint.h 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/src/visual-feature/vpGenericFeature.cpp b/src/visual-feature/vpGenericFeature.cpp index f4d2a3186d1c29b631d3eee01a8552be620ba099..0144fb5f016fd1c5f4adeae35b7cd0742cc8fe04 100644 --- a/src/visual-feature/vpGenericFeature.cpp +++ b/src/visual-feature/vpGenericFeature.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpGenericFeature.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpGenericFeature.cpp 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -81,6 +81,7 @@ void vpGenericFeature::init() */ vpGenericFeature::vpGenericFeature() + : L(), err(), errorStatus(errorNotInitalized) { /* vpERROR_TRACE("You are not allow to use this constructor ") ; @@ -96,28 +97,28 @@ vpGenericFeature::vpGenericFeature() /*! Constructor of the class you have to use. The feature table is initilialized with the good dimension. - \param dim_s : Dimension of the feature. It corresponds to the number of features you want to create. + \param dimension_gen_s : Dimension of the generic feature. It corresponds to the number of features you want to create. */ -vpGenericFeature::vpGenericFeature(unsigned int dim_s) +vpGenericFeature::vpGenericFeature(unsigned int dimension_gen_s) + : L(), err(), errorStatus(errorNotInitalized) { - this->dim_s = dim_s ; - s.resize(dim_s) ; - errorStatus = errorNotInitalized ; + this->dim_s = dimension_gen_s ; + s.resize(dimension_gen_s) ; } /*! Set the error vector \f$(s-s*)\f$. - \param error : Error vector \f$(s-s*)\f$. + \param error_vector : Error vector \f$(s-s*)\f$. \exception vpFeatureException::sizeMismatchError : If the size of the error vector is bad. */ void -vpGenericFeature::setError(vpColVector &error) +vpGenericFeature::setError(const vpColVector &error_vector) { - if (error.getRows() != dim_s) + if (error_vector.getRows() != dim_s) { vpERROR_TRACE("size mismatch between error dimension" "and feature dimension"); @@ -127,7 +128,7 @@ vpGenericFeature::setError(vpColVector &error) } errorStatus = errorInitialized ; - err = error ; + err = error_vector ; } @@ -448,80 +449,74 @@ vpGenericFeature::interaction(const unsigned int select) /*! \brief set the value of the interaction matrix. - \param L : The matrix corresponding to the interaction matrix you computed. + \param L_ : The matrix corresponding to the interaction matrix you computed. \exception an exception is thrown if the number of row of the interaction matrix is different from the dimension of the visual feature as specified in the constructor */ void -vpGenericFeature::setInteractionMatrix(const vpMatrix &L) +vpGenericFeature::setInteractionMatrix(const vpMatrix &L_) { - - if (L.getRows() != dim_s) + if (L_.getRows() != dim_s) { - std::cout << L.getRows() <<" " << dim_s << std::endl ;; + std::cout << L_.getRows() <<" " << dim_s << std::endl ;; vpERROR_TRACE("size mismatch between interaction matrix size " "and feature dimension"); throw(vpFeatureException(vpFeatureException::sizeMismatchError, "size mismatch between interaction matrix size " "and feature dimension")); - } - this->L = L ; - + this->L = L_ ; } /*! \brief set the value of all the features. - \param s : It is a vector containing the value of the visual features. + \param s_vector : It is a vector containing the value of the visual features. \exception an exception is thrown if the number of row of the vector s is different from the dimension of the visual feature as specified in the constructor */ void -vpGenericFeature::set_s(const vpColVector &s) +vpGenericFeature::set_s(const vpColVector &s_vector) { - if (s.getRows() != dim_s) + if (s_vector.getRows() != dim_s) { vpERROR_TRACE("size mismatch between s dimension" "and feature dimension"); throw(vpFeatureException(vpFeatureException::sizeMismatchError, "size mismatch between s dimension" "and feature dimension")); - } - this->s = s ; + this->s = s_vector ; } /*! \brief get the value of all the features. - \param s : It is a vector which will contain the value of the visual features. + \param s_vector : It is a vector which will contain the value of the visual features. \exception an exception is thrown if the number of row of the vector s is different from the dimension of the visual feature as specified in the constructor */ void -vpGenericFeature::get_s(vpColVector &s) const +vpGenericFeature::get_s(vpColVector &s_vector) const { - - if (s.getRows() != dim_s) + if (s_vector.getRows() != dim_s) { vpERROR_TRACE("size mismatch between s dimension" "and feature dimension"); throw(vpFeatureException(vpFeatureException::sizeMismatchError, "size mismatch between s dimension" "and feature dimension")); - } - s = this->s ; + s_vector = this->s ; } diff --git a/src/visual-feature/vpGenericFeature.h b/src/visual-feature/vpGenericFeature.h index 656519490c0aea29c7465cc49a7c86063e9fc04e..ffbccadcf24a89c4ab7fdf9a87a68ea9c355b2b0 100644 --- a/src/visual-feature/vpGenericFeature.h +++ b/src/visual-feature/vpGenericFeature.h @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: vpGenericFeature.h 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: vpGenericFeature.h 4649 2014-02-07 14:57:11Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -209,7 +209,7 @@ private: public: void setInteractionMatrix(const vpMatrix &L) ; vpMatrix getInteractionMatrix() const { return L ; } - void setError(vpColVector &error) ; + void setError(const vpColVector &error_vector) ; void set_s(const vpColVector &s) ; void set_s(const double s0) ; void set_s(const double s0, const double s1) ; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 87750a1ae0f8af0b8db0487700771b7f836a9653..a20846074244be4c62eb79483df54f473c75a24e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/test/camera/CMakeLists.txt b/test/camera/CMakeLists.txt index 5216126fe78750fbbd0875ddc15b8c61be1cc109..f5b4750f4681668b1d525b3c617652246b6430bb 100644 --- a/test/camera/CMakeLists.txt +++ b/test/camera/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/test/camera/testCameraParametersConversion.cpp b/test/camera/testCameraParametersConversion.cpp index 2d6ea7029e7ca5b54564ae6717dda5153ed09f7c..f8a70f9f77cfffe22ffa827638967bb1b5c9b52a 100644 --- a/test/camera/testCameraParametersConversion.cpp +++ b/test/camera/testCameraParametersConversion.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testCameraParametersConversion.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testCameraParametersConversion.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -62,6 +62,9 @@ #include <stdlib.h> #include <stdio.h> +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); + /*! Print the program options. @@ -93,15 +96,15 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -110,7 +113,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -121,56 +124,62 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } - vpCameraParameters cam; - double px,py,u0,v0; - px = 1657.429131; - py = 1658.818598; - u0 = 322.2437833; - v0 = 230.8012737; - vpCameraParameters camDist; - double px_dist,py_dist,u0_dist,v0_dist,kud_dist,kdu_dist; - px_dist = 1624.824731; - py_dist = 1625.263641; - u0_dist = 324.0923411; - v0_dist = 245.2421388; - kud_dist = -0.1741532338; - kdu_dist = 0.1771165148; - - cam.initPersProjWithoutDistortion(px,py,u0,v0); - camDist.initPersProjWithDistortion(px_dist,py_dist,u0_dist,v0_dist, - kud_dist, kdu_dist); - - double u1 = 320; - double v1 = 240; - double x1 = 0, y1 = 0; - double u2 = 0, v2 = 0; - vpPixelMeterConversion::convertPoint(cam,u1,v1,x1,y1); - vpMeterPixelConversion::convertPoint(cam,x1,y1,u2,v2); - if(!vpMath::equal(u1,u2) || !vpMath::equal(v1,v2)){ - vpTRACE("Error in convertPoint without distortion:\n" - "u1 = %f, u2 = %f\n" - "v1 = %f, v2 = %f\n",u1,u2,v1,v2); - return -1; + vpCameraParameters cam; + double px,py,u0,v0; + px = 1657.429131; + py = 1658.818598; + u0 = 322.2437833; + v0 = 230.8012737; + vpCameraParameters camDist; + double px_dist,py_dist,u0_dist,v0_dist,kud_dist,kdu_dist; + px_dist = 1624.824731; + py_dist = 1625.263641; + u0_dist = 324.0923411; + v0_dist = 245.2421388; + kud_dist = -0.1741532338; + kdu_dist = 0.1771165148; + + cam.initPersProjWithoutDistortion(px,py,u0,v0); + camDist.initPersProjWithDistortion(px_dist,py_dist,u0_dist,v0_dist, + kud_dist, kdu_dist); + + double u1 = 320; + double v1 = 240; + double x1 = 0, y1 = 0; + double u2 = 0, v2 = 0; + vpPixelMeterConversion::convertPoint(cam,u1,v1,x1,y1); + vpMeterPixelConversion::convertPoint(cam,x1,y1,u2,v2); + if(!vpMath::equal(u1,u2) || !vpMath::equal(v1,v2)){ + vpTRACE("Error in convertPoint without distortion:\n" + "u1 = %f, u2 = %f\n" + "v1 = %f, v2 = %f\n",u1,u2,v1,v2); + return -1; + } + vpTRACE("convertPoint without distortion :\n" + "u1 - u2 = %.20f\n" + "v1 - v2 = %.20f\n",u1 - u2,v1 - v2); + + vpPixelMeterConversion::convertPoint(camDist,u1,v1,x1,y1); + vpMeterPixelConversion::convertPoint(camDist,x1,y1,u2,v2); + if(!vpMath::equal(u1,u2) || !vpMath::equal(v1,v2)){ + vpTRACE("Error in convertPoint with distortion :\n" + "u1 = %f, u2 = %f\n" + "v1 = %f, v2 = %f\n",u1,u2,v1,v2); + return -1; + } + vpTRACE("convertPoint with distortion :\n" + "u1 - u2 = %.20f\n" + "v1 - v2 = %.20f\n",u1 - u2,v1 - v2); + return 0; } - vpTRACE("convertPoint without distortion :\n" - "u1 - u2 = %.20f\n" - "v1 - v2 = %.20f\n",u1 - u2,v1 - v2); - - vpPixelMeterConversion::convertPoint(camDist,u1,v1,x1,y1); - vpMeterPixelConversion::convertPoint(camDist,x1,y1,u2,v2); - if(!vpMath::equal(u1,u2) || !vpMath::equal(v1,v2)){ - vpTRACE("Error in convertPoint with distortion :\n" - "u1 = %f, u2 = %f\n" - "v1 = %f, v2 = %f\n",u1,u2,v1,v2); - return -1; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - vpTRACE("convertPoint with distortion :\n" - "u1 - u2 = %.20f\n" - "v1 - v2 = %.20f\n",u1 - u2,v1 - v2); - return 0; } diff --git a/test/device/CMakeLists.txt b/test/device/CMakeLists.txt index ee860dcab3c523bf2712ea1019ee2acf46045a8d..81849363e813313216f4011516e8c48766fbb8d1 100644 --- a/test/device/CMakeLists.txt +++ b/test/device/CMakeLists.txt @@ -3,7 +3,7 @@ # $Id: CMakeLists.txt 3057 2011-02-11 13:17:26Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/test/device/display/CMakeLists.txt b/test/device/display/CMakeLists.txt index 7a7a9c84203abe057070686a6814539e20fbbc18..a17dd0f155d0652d8334be45f9e5c2c8a61f08e2 100644 --- a/test/device/display/CMakeLists.txt +++ b/test/device/display/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/test/device/display/testClick.cpp b/test/device/display/testClick.cpp index 7b4648fef6e0362f93b9f4a20ceca642130f4305..00d141b04c843e91eb4d880a95c406198c48784c 100644 --- a/test/device/display/testClick.cpp +++ b/test/device/display/testClick.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testClick.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: testClick.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -77,6 +77,11 @@ typedef enum { vpCV } vpDisplayType; +void usage(const char *name, const char *badparam, std::string ipath, vpDisplayType &dtype); +bool getOptions(int argc, const char **argv, + std::string &ipath, vpDisplayType &dtype, bool &list, + bool &click_allowed, bool &display ); + /*! Print the program options. @@ -163,17 +168,17 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv, std::string &ipath, vpDisplayType &dtype, bool &list, - bool &click_allowed, bool &display ) + bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; std::string sDisplayType; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { - case 'i': ipath = optarg; break; + case 'i': ipath = optarg_; break; case 'l': list = true; break; - case 't': sDisplayType = optarg; + case 't': sDisplayType = optarg_; // Parse the display type option if (sDisplayType.compare("X11") == 0) { dtype = vpX11; @@ -197,7 +202,7 @@ bool getOptions(int argc, const char **argv, case 'd': display = false; break; default: - usage(argv[0], optarg, ipath, dtype); return false; break; + usage(argv[0], optarg_, ipath, dtype); return false; break; } } @@ -206,7 +211,7 @@ bool getOptions(int argc, const char **argv, // standalone param or error usage(argv[0], NULL, ipath, dtype); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -426,7 +431,6 @@ main(int argc, const char ** argv) vpERROR_TRACE("Error while displaying the image") ; exit(-1); } - } #else diff --git a/test/device/display/testDisplays.cpp b/test/device/display/testDisplays.cpp index 753a60c3f26cb39db24a596c2a02e4eebb522eb1..1a161cfa758e58f6cec6537702a3e5ee1f1a848e 100644 --- a/test/device/display/testDisplays.cpp +++ b/test/device/display/testDisplays.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testDisplays.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testDisplays.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -70,6 +70,10 @@ // List of allowed command line options #define GETOPTARGS "hl:dc" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv, bool &list, bool &click_allowed, bool &display); +void draw(vpImage<vpRGBa> &I); + /*! Print the program options. @@ -120,13 +124,12 @@ OPTIONS: Default\n\ \return false if the program has to be stopped, true otherwise. */ -bool getOptions(int argc, const char **argv, bool &list, - bool &click_allowed, bool &display ) +bool getOptions(int argc, const char **argv, bool &list, bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; std::string sDisplayType; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'l': list = true; break; @@ -135,16 +138,15 @@ bool getOptions(int argc, const char **argv, bool &list, case 'd': display = false; break; default: - usage(argv[0], optarg); return false; break; + 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; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } diff --git a/test/device/display/testMouseEvent.cpp b/test/device/display/testMouseEvent.cpp index c0f1796862a1d309ceb2a23375d7b6acbbf44054..66ef3a6a94afdbde9066f15a90789b59d7079c9e 100644 --- a/test/device/display/testMouseEvent.cpp +++ b/test/device/display/testMouseEvent.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testMouseEvent.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: testMouseEvent.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -91,6 +91,12 @@ typedef enum { vpD3D, } vpDisplayType; +void usage(const char *name, const char *badparam, std::string ipath, std::string ppath, + unsigned first, unsigned nimages, unsigned step, vpDisplayType &dtype); +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &ppath, + unsigned &first, unsigned &nimages, unsigned &step, + vpDisplayType &dtype, bool &list, bool &display, bool &click, bool &wait); + /*! Print the program options. @@ -106,8 +112,7 @@ typedef enum { */ void usage(const char *name, const char *badparam, std::string ipath, std::string ppath, - unsigned first, unsigned nimages, unsigned step, - vpDisplayType &dtype) + unsigned first, unsigned nimages, unsigned step, vpDisplayType &dtype) { fprintf(stdout, "\n\ Read an image sequence from the disk and display it.\n\ @@ -217,15 +222,15 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &pp unsigned &first, unsigned &nimages, unsigned &step, vpDisplayType &dtype, bool &list, bool &display, bool &click, bool &wait) { - const char *optarg; + const char *optarg_; int c; std::string sDisplayType; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click = false; break; case 'd': display = false; break; - case 't': sDisplayType = optarg; + case 't': sDisplayType = optarg_; // Parse the display type option if (sDisplayType.compare("X11") == 0) { dtype = vpX11; @@ -241,18 +246,18 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &pp } break; - case 'i': ipath = optarg; break; + case 'i': ipath = optarg_; break; case 'l': list = true; break; - case 'p': ppath = optarg; break; - case 'f': first = (unsigned) atoi(optarg); break; - case 'n': nimages = (unsigned) atoi(optarg); break; - case 's': step = (unsigned) atoi(optarg); break; + case 'p': ppath = optarg_; break; + case 'f': first = (unsigned) atoi(optarg_); break; + case 'n': nimages = (unsigned) atoi(optarg_); break; + case 's': step = (unsigned) atoi(optarg_); break; case 'w': wait = true; break; case 'h': usage(argv[0], NULL, ipath, ppath, first, nimages, step, dtype); return false; break; default: - usage(argv[0], optarg, ipath, ppath, first, nimages, step, dtype); + usage(argv[0], optarg_, ipath, ppath, first, nimages, step, dtype); return false; break; } } @@ -261,7 +266,7 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &pp // standalone param or error usage(argv[0], NULL, ipath, ppath, first, nimages, step, dtype); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } diff --git a/test/device/display/testVideoDevice.cpp b/test/device/display/testVideoDevice.cpp index 320ee3e255f308d9a223d5c070575a6d9cb2d9da..bc2bc73d2c6005db1d6ec43124c8cafec9e22fe1 100644 --- a/test/device/display/testVideoDevice.cpp +++ b/test/device/display/testVideoDevice.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testVideoDevice.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: testVideoDevice.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -77,6 +77,11 @@ typedef enum { vpCV } vpDisplayType; +void usage(const char *name, const char *badparam, std::string ipath, vpDisplayType &dtype); +bool getOptions(int argc, const char **argv, + std::string &ipath, vpDisplayType &dtype, bool &list, + bool &click_allowed, bool &display ); + /*! Print the program options. @@ -161,15 +166,15 @@ bool getOptions(int argc, const char **argv, std::string &ipath, vpDisplayType &dtype, bool &list, bool &click_allowed, bool &display ) { - const char *optarg; + const char *optarg_; int c; std::string sDisplayType; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { - case 'i': ipath = optarg; break; + case 'i': ipath = optarg_; break; case 'l': list = true; break; - case 't': sDisplayType = optarg; + case 't': sDisplayType = optarg_; // Parse the display type option if (sDisplayType.compare("X11") == 0) { dtype = vpX11; @@ -193,7 +198,7 @@ bool getOptions(int argc, const char **argv, case 'd': display = false; break; default: - usage(argv[0], optarg, ipath,dtype); return false; break; + usage(argv[0], optarg_, ipath,dtype); return false; break; } } @@ -202,7 +207,7 @@ bool getOptions(int argc, const char **argv, // standalone param or error usage(argv[0], NULL, ipath, dtype); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } diff --git a/test/device/display/testVideoDeviceDual.cpp b/test/device/display/testVideoDeviceDual.cpp index 6e4b1ab505ff1128a62e0f2cd2b854284bb3fa3e..a3bc6ba9507cdd2735b96e32910ed339c0dbb8ea 100644 --- a/test/device/display/testVideoDeviceDual.cpp +++ b/test/device/display/testVideoDeviceDual.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testVideoDeviceDual.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testVideoDeviceDual.cpp 4659 2014-02-09 14:11:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -60,6 +60,7 @@ */ + // List of allowed command line options #define GETOPTARGS "hlt:dc" @@ -71,6 +72,9 @@ typedef enum { vpCV } vpDisplayType; +void usage(const char *name, const char *badparam, vpDisplayType &dtype); +bool getOptions(int argc, const char **argv, vpDisplayType &dtype, bool &list, bool &click_allowed, bool &display); + /*! Print the program options. @@ -142,16 +146,16 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv, vpDisplayType &dtype, bool &list, - bool &click_allowed, bool &display ) + bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; std::string sDisplayType; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'l': list = true; break; - case 't': sDisplayType = optarg; + case 't': sDisplayType = optarg_; // Parse the display type option if (sDisplayType.compare("X11") == 0) { dtype = vpX11; @@ -175,7 +179,7 @@ bool getOptions(int argc, const char **argv, case 'd': display = false; break; default: - usage(argv[0], optarg, dtype); return false; break; + usage(argv[0], optarg_, dtype); return false; break; } } @@ -183,7 +187,7 @@ bool getOptions(int argc, const char **argv, // standalone param or error usage(argv[0], NULL, dtype); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -192,152 +196,158 @@ bool getOptions(int argc, const char **argv, int main(int argc, const char ** argv) { - bool opt_list = false; // To print the list of video devices - vpDisplayType opt_dtype; // Type of display to use - bool opt_click_allowed = true; - bool opt_display = true; + try { + bool opt_list = false; // To print the list of video devices + vpDisplayType opt_dtype; // Type of display to use + bool opt_click_allowed = true; + bool opt_display = true; - // Default display is one available + // Default display is one available #if defined VISP_HAVE_GTK - opt_dtype = vpGTK; + opt_dtype = vpGTK; #elif defined VISP_HAVE_X11 - opt_dtype = vpX11; + opt_dtype = vpX11; #elif defined VISP_HAVE_GDI - opt_dtype = vpGDI; + opt_dtype = vpGDI; #elif defined VISP_HAVE_D3D9 - opt_dtype = vpD3D; + opt_dtype = vpD3D; #elif defined VISP_HAVE_OPENCV - opt_dtype = vpCV; + opt_dtype = vpCV; #endif - // Read the command line options - if (getOptions(argc, argv, opt_dtype, opt_list, - opt_click_allowed, opt_display) == false) { - exit (-1); - } + // Read the command line options + if (getOptions(argc, argv, opt_dtype, opt_list, + opt_click_allowed, opt_display) == false) { + exit (-1); + } - // Print the list of video-devices available - if (opt_list) { - unsigned nbDevices = 0; - std::cout << "List of video-devices available: \n"; + // Print the list of video-devices available + if (opt_list) { + unsigned nbDevices = 0; + std::cout << "List of video-devices available: \n"; #if defined VISP_HAVE_GTK - std::cout << " GTK (use \"-t GTK\" option to use it)\n"; - nbDevices ++; + std::cout << " GTK (use \"-t GTK\" option to use it)\n"; + nbDevices ++; #endif #if defined VISP_HAVE_X11 - std::cout << " X11 (use \"-t X11\" option to use it)\n"; - nbDevices ++; + std::cout << " X11 (use \"-t X11\" option to use it)\n"; + nbDevices ++; #endif #if defined VISP_HAVE_GDI - std::cout << " GDI (use \"-t GDI\" option to use it)\n"; - nbDevices ++; + std::cout << " GDI (use \"-t GDI\" option to use it)\n"; + nbDevices ++; #endif #if defined VISP_HAVE_D3D9 - std::cout << " D3D (use \"-t D3D\" option to use it)\n"; - nbDevices ++; + std::cout << " D3D (use \"-t D3D\" option to use it)\n"; + nbDevices ++; #endif #if defined VISP_HAVE_OPENCV - std::cout << " CV (use \"-t CV\" option to use it)\n"; - nbDevices ++; + std::cout << " CV (use \"-t CV\" option to use it)\n"; + nbDevices ++; #endif - if (!nbDevices) { - std::cout << " No display is available\n"; + if (!nbDevices) { + std::cout << " No display is available\n"; + } + return (0); } - return (0); - } - // Create 2 images - vpImage<unsigned char> I1(240, 320), I2(240, 320); - I1 = 128; - I2 = 255; + // Create 2 images + vpImage<unsigned char> I1(240, 320), I2(240, 320); + I1 = 128; + I2 = 255; - // Create 2 display - vpDisplay *d1 = NULL, *d2 = NULL; + // Create 2 display + vpDisplay *d1 = NULL, *d2 = NULL; - // Initialize the displays - switch(opt_dtype) { - case vpX11: - std::cout << "Requested X11 display functionnalities..." << std::endl; + // Initialize the displays + switch(opt_dtype) { + case vpX11: + std::cout << "Requested X11 display functionnalities..." << std::endl; #if defined VISP_HAVE_X11 - d1 = new vpDisplayX; - d2 = new vpDisplayX; + d1 = new vpDisplayX; + d2 = new vpDisplayX; #else - std::cout << " Sorry, X11 video device is not available.\n"; - std::cout << "Use \"" << argv[0] - << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, X11 video device is not available.\n"; + std::cout << "Use \"" << argv[0] + << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - case vpGTK: - std::cout << "Requested GTK display functionnalities..." << std::endl; + break; + case vpGTK: + std::cout << "Requested GTK display functionnalities..." << std::endl; #if defined VISP_HAVE_GTK - d1 = new vpDisplayGTK; - d2 = new vpDisplayGTK; + d1 = new vpDisplayGTK; + d2 = new vpDisplayGTK; #else - std::cout << " Sorry, GTK video device is not available.\n"; - std::cout << "Use \"" << argv[0] - << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, GTK video device is not available.\n"; + std::cout << "Use \"" << argv[0] + << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - case vpGDI: - std::cout << "Requested GDI display functionnalities..." << std::endl; + break; + case vpGDI: + std::cout << "Requested GDI display functionnalities..." << std::endl; #if defined VISP_HAVE_GDI - d1 = new vpDisplayGDI; - d2 = new vpDisplayGDI; + d1 = new vpDisplayGDI; + d2 = new vpDisplayGDI; #else - std::cout << " Sorry, GDI video device is not available.\n"; - std::cout << "Use \"" << argv[0] - << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, GDI video device is not available.\n"; + std::cout << "Use \"" << argv[0] + << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - case vpD3D: - std::cout << "Requested D3D display functionnalities..." << std::endl; + break; + case vpD3D: + std::cout << "Requested D3D display functionnalities..." << std::endl; #if defined VISP_HAVE_D3D9 - d1 = new vpDisplayD3D; - d2 = new vpDisplayD3D; + d1 = new vpDisplayD3D; + d2 = new vpDisplayD3D; #else - std::cout << " Sorry, D3D video device is not available.\n"; - std::cout << "Use \"" << argv[0] - << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, D3D video device is not available.\n"; + std::cout << "Use \"" << argv[0] + << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - case vpCV: - std::cout << "Requested OpenCV display functionnalities..." << std::endl; + break; + case vpCV: + std::cout << "Requested OpenCV display functionnalities..." << std::endl; #if defined VISP_HAVE_OPENCV - d1 = new vpDisplayOpenCV; - d2 = new vpDisplayOpenCV; + d1 = new vpDisplayOpenCV; + d2 = new vpDisplayOpenCV; #else - std::cout << " Sorry, OpenCV video device is not available.\n"; - std::cout << "Use \"" << argv[0] - << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, OpenCV video device is not available.\n"; + std::cout << "Use \"" << argv[0] + << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - } + break; + } - if (opt_display){ - int winx1 = 100, winy1 = 200; - d1->init(I1, winx1, winy1, "Display 1"); + if (opt_display){ + int winx1 = 100, winy1 = 200; + d1->init(I1, winx1, winy1, "Display 1"); - int winx2 = winx1+10+(int)I1.getWidth(), winy2 = winy1; - d2->init(I2, winx2, winy2, "Display 2"); + int winx2 = winx1+10+(int)I1.getWidth(), winy2 = winy1; + d2->init(I2, winx2, winy2, "Display 2"); - vpDisplay::display(I1); - vpDisplay::display(I2); + vpDisplay::display(I1); + vpDisplay::display(I2); - vpDisplay::flush(I1); - vpDisplay::flush(I2); - } + vpDisplay::flush(I1); + vpDisplay::flush(I2); + } - std::cout << "A click in display 1 to exit..." << std::endl; - if ( opt_click_allowed ) - vpDisplay::getClick(I1); + std::cout << "A click in display 1 to exit..." << std::endl; + if ( opt_click_allowed ) + vpDisplay::getClick(I1); - delete d1; - delete d2; + delete d1; + delete d2; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } #else diff --git a/test/device/framegrabber/CMakeLists.txt b/test/device/framegrabber/CMakeLists.txt index a3cede79590ec1a742148040fb5841059a1b42d5..7f89c91819fdf50dafd6b00372b32bc599dec162 100644 --- a/test/device/framegrabber/CMakeLists.txt +++ b/test/device/framegrabber/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/test/device/framegrabber/test1394TwoGrabber.cpp b/test/device/framegrabber/test1394TwoGrabber.cpp index 9a5dc5df60145fb83cff1f4c854a4a6b9479e860..77ef541b3124e953aee931222ac8d8ead257dff0 100644 --- a/test/device/framegrabber/test1394TwoGrabber.cpp +++ b/test/device/framegrabber/test1394TwoGrabber.cpp @@ -1,10 +1,10 @@ /**************************************************************************** * - * $Id: test1394TwoGrabber.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: test1394TwoGrabber.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/test/device/framegrabber/test1394TwoResetBus.cpp b/test/device/framegrabber/test1394TwoResetBus.cpp index 029102904094298aa7df4822f86adb9247641375..14839c0f62c8743b369ae03e238947ac4b10cf28 100644 --- a/test/device/framegrabber/test1394TwoResetBus.cpp +++ b/test/device/framegrabber/test1394TwoResetBus.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: test1394TwoResetBus.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: test1394TwoResetBus.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/test/feature/CMakeLists.txt b/test/feature/CMakeLists.txt index e9629e672ea829f7ad6819b1ca11c0842522bc8f..a12fb14dd6c14e93c6e42baf653ba2c8638df683 100644 --- a/test/feature/CMakeLists.txt +++ b/test/feature/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/test/feature/testPoint.cpp b/test/feature/testPoint.cpp index 39407acc34d0f0da15fafe69466ea65ff18b9eea..a16f39cdb45418986a75c8f744407cd180792b4b 100644 --- a/test/feature/testPoint.cpp +++ b/test/feature/testPoint.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testPoint.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testPoint.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -61,6 +61,10 @@ #include <stdlib.h> #include <stdio.h> + +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); + /*! Print the program options. @@ -91,15 +95,15 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -108,7 +112,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -119,114 +123,119 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } - - vpHomogeneousMatrix cMo ; - cMo[0][3] = 0.1 ; - cMo[1][3] = 0.2 ; - cMo[2][3] = 2 ; - - vpPoint point ; - vpTRACE("set point coordinates in the world frame ") ; - point.setWorldCoordinates(0,0,0) ; - - - std::cout <<"------------------------------------------------------"<<std::endl ; - vpTRACE("test the projection ") ; - point.track(cMo) ; - - vpTRACE("coordinates in the world frame ") ; - std::cout << point.oP.t() << std::endl ; - vpTRACE("coordinates in the camera frame ") ; - std::cout << point.cP.t() << std::endl ; + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } - vpTRACE("2D coordinates ") ; - std::cout<< point.get_x() << " " << point.get_y() << std::endl ; + vpHomogeneousMatrix cMo ; + cMo[0][3] = 0.1 ; + cMo[1][3] = 0.2 ; + cMo[2][3] = 2 ; - std::cout <<"------------------------------------------------------"<<std::endl ; - vpTRACE("test the interaction matrix ") ; + vpPoint point ; + vpTRACE("set point coordinates in the world frame ") ; + point.setWorldCoordinates(0,0,0) ; - vpFeaturePoint p ; - vpFeatureBuilder::create(p,point) ; + std::cout <<"------------------------------------------------------"<<std::endl ; + vpTRACE("test the projection ") ; + point.track(cMo) ; - vpMatrix L ; - L = p.interaction() ; - std::cout << L << std::endl ; + vpTRACE("coordinates in the world frame ") ; + std::cout << point.oP.t() << std::endl ; + vpTRACE("coordinates in the camera frame ") ; + std::cout << point.cP.t() << std::endl ; - vpTRACE("test the interaction matrix select") ; - vpTRACE("\t only X") ; - L = p.interaction(vpFeaturePoint::selectX()) ; - std::cout << L << std::endl ; + vpTRACE("2D coordinates ") ; + std::cout<< point.get_x() << " " << point.get_y() << std::endl ; - vpTRACE("\t only Y") ; - L = p.interaction(vpFeaturePoint::selectY()) ; - std::cout << L << std::endl ; + std::cout <<"------------------------------------------------------"<<std::endl ; + vpTRACE("test the interaction matrix ") ; - vpTRACE("\t X & Y") ; - L = p.interaction(vpFeaturePoint::selectX() | - vpFeaturePoint::selectY()) ; - std::cout << L << std::endl ; + vpFeaturePoint p ; + vpFeatureBuilder::create(p,point) ; - vpTRACE("\t selectAll") ; - L = p.interaction(vpFeaturePoint::selectAll() ) ; - std::cout << L << std::endl ; + vpMatrix L ; + L = p.interaction() ; + std::cout << L << std::endl ; - std::cout <<"------------------------------------------------------"<<std::endl ; - vpTRACE("test the error ") ; + vpTRACE("test the interaction matrix select") ; + vpTRACE("\t only X") ; + L = p.interaction(vpFeaturePoint::selectX()) ; + std::cout << L << std::endl ; - try{ - vpFeaturePoint pd ; - pd.set_x(0) ; - pd.set_y(0) ; + vpTRACE("\t only Y") ; + L = p.interaction(vpFeaturePoint::selectY()) ; + std::cout << L << std::endl ; - pd.print() ; std::cout << std::endl ; - vpColVector e ; - e = p.error(pd) ; - std::cout << e << std::endl ; + vpTRACE("\t X & Y") ; + L = p.interaction(vpFeaturePoint::selectX() | + vpFeaturePoint::selectY()) ; + std::cout << L << std::endl ; - vpTRACE("test the interaction matrix select") ; + vpTRACE("\t selectAll") ; + L = p.interaction(vpFeaturePoint::selectAll() ) ; + std::cout << L << std::endl ; + + std::cout <<"------------------------------------------------------"<<std::endl ; + vpTRACE("test the error ") ; + + try{ + vpFeaturePoint pd ; + pd.set_x(0) ; + pd.set_y(0) ; + + pd.print() ; std::cout << std::endl ; + vpColVector e ; + e = p.error(pd) ; + std::cout << e << std::endl ; + + vpTRACE("test the interaction matrix select") ; + vpTRACE("\t only X") ; + e = p.error(pd,vpFeaturePoint::selectX()) ; + std::cout << e << std::endl ; + + vpTRACE("\t only Y") ; + e = p.error(pd,vpFeaturePoint::selectY()) ; + std::cout << e << std::endl ; + + vpTRACE("\t X & Y") ; + e = p.error(pd,vpFeaturePoint::selectX() | vpFeaturePoint::selectY()) ; + std::cout << e << std::endl ; + + vpTRACE("\t selectAll") ; + e = p.error(pd,vpFeaturePoint::selectAll() ) ; + std::cout << e << std::endl ; + } + catch(vpFeatureException me){ std::cout << me << std::endl ; } + catch(vpException me){ std::cout << me << std::endl ; } + std::cout <<"------------------------------------------------------"<<std::endl ; + vpTRACE("test the dimension") ; + unsigned int dim ; + dim = p.getDimension() ; + std::cout << "Dimension = " << dim << std::endl ; + + vpTRACE("test the dimension with select") ; vpTRACE("\t only X") ; - e = p.error(pd,vpFeaturePoint::selectX()) ; - std::cout << e << std::endl ; + dim = p.getDimension(vpFeaturePoint::selectX()) ; + std::cout << "Dimension = " << dim << std::endl ; vpTRACE("\t only Y") ; - e = p.error(pd,vpFeaturePoint::selectY()) ; - std::cout << e << std::endl ; + dim = p.getDimension(vpFeaturePoint::selectY()) ; + std::cout << "Dimension = " << dim << std::endl ; vpTRACE("\t X & Y") ; - e = p.error(pd,vpFeaturePoint::selectX() | vpFeaturePoint::selectY()) ; - std::cout << e << std::endl ; + dim = p.getDimension(vpFeaturePoint::selectX() | vpFeaturePoint::selectY()) ; + std::cout << "Dimension = " << dim << std::endl ; vpTRACE("\t selectAll") ; - e = p.error(pd,vpFeaturePoint::selectAll() ) ; - std::cout << e << std::endl ; + dim = p.getDimension(vpFeaturePoint::selectAll() ) ; + std::cout << "Dimension = " << dim << std::endl ; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - catch(vpFeatureException me){ std::cout << me << std::endl ; } - catch(vpException me){ std::cout << me << std::endl ; } - std::cout <<"------------------------------------------------------"<<std::endl ; - vpTRACE("test the dimension") ; - unsigned int dim ; - dim = p.getDimension() ; - std::cout << "Dimension = " << dim << std::endl ; - - vpTRACE("test the dimension with select") ; - vpTRACE("\t only X") ; - dim = p.getDimension(vpFeaturePoint::selectX()) ; - std::cout << "Dimension = " << dim << std::endl ; - - vpTRACE("\t only Y") ; - dim = p.getDimension(vpFeaturePoint::selectY()) ; - std::cout << "Dimension = " << dim << std::endl ; - - vpTRACE("\t X & Y") ; - dim = p.getDimension(vpFeaturePoint::selectX() | vpFeaturePoint::selectY()) ; - std::cout << "Dimension = " << dim << std::endl ; - - vpTRACE("\t selectAll") ; - dim = p.getDimension(vpFeaturePoint::selectAll() ) ; - std::cout << "Dimension = " << dim << std::endl ; - } diff --git a/test/homography/CMakeLists.txt b/test/homography/CMakeLists.txt index 42054ab176f9a6e4c692841af9869d54623d9895..f5aebdc1581e97358132cae6ad8bb977caf76a52 100644 --- a/test/homography/CMakeLists.txt +++ b/test/homography/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/test/homography/testDisplacement.cpp b/test/homography/testDisplacement.cpp index c0d9eb2718679ac106458690d5987e66e7bc457f..b23d2df3d73c7baba9544940203ee9c8a3d16087 100644 --- a/test/homography/testDisplacement.cpp +++ b/test/homography/testDisplacement.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testDisplacement.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testDisplacement.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -63,6 +63,9 @@ // List of allowed command line options #define GETOPTARGS "h" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); + /*! Print the program options. @@ -93,15 +96,15 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -110,7 +113,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -121,131 +124,114 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } - - { - vpThetaUVector tu(vpMath::rad(90), vpMath::rad(120), vpMath::rad(45)) ; + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } - std::cout << "Initialization " <<std::endl ; - // std::cout << tu << std::endl ; + { + vpThetaUVector tu(vpMath::rad(90), vpMath::rad(120), vpMath::rad(45)) ; + std::cout << "Initialization " <<std::endl ; + // std::cout << tu << std::endl ; - std::cout << "From vpThetaUVector to vpRotationMatrix " << std::endl ; - vpRotationMatrix R(tu) ; + std::cout << "From vpThetaUVector to vpRotationMatrix " << std::endl ; + vpRotationMatrix R(tu) ; + // pure rotation + vpHomogeneousMatrix M ; + M.insert(R) ; - // pure rotation - vpHomogeneousMatrix M ; - M.insert(R) ; + std::cout << "M" <<std::endl <<M << std::endl ; + vpPlane p(0,0,1,1) ; + vpHomography H(M,p) ; + std::cout << "H" <<std::endl <<H << std::endl ; - std::cout << "M" <<std::endl <<M << std::endl ; - vpPlane p(0,0,1,1) ; + vpColVector n ; + vpTranslationVector T ; - vpHomography H(M,p) ; + H.computeDisplacement(R,T,n) ; - vpTRACE(" ") ; - std::cout << "H" <<std::endl <<H << std::endl ; + std::cout << "R" <<std::endl << R ; + std::cout << "T" <<std::endl << T.t() << std::endl; + std::cout << "n" <<std::endl << n.t() << std::endl; + } + std::cout <<"------------------------------------------------------" << std::endl ; + { + vpThetaUVector tu(vpMath::rad(90), vpMath::rad(120), vpMath::rad(45)) ; - vpTRACE(" ") ; + std::cout << "Initialization " << std::endl ; + // std::cout << tu << std::endl ; - vpColVector n ; - vpTranslationVector T ; + std::cout << "From vpThetaUVector to vpRotationMatrix " << std::endl ; + vpRotationMatrix R(tu) ; - H.computeDisplacement(R,T,n) ; + // pure rotation + vpHomogeneousMatrix M ; + M.insert(R) ; - std::cout << "R" <<std::endl << R ; - std::cout << "T" <<std::endl << T.t() ; - std::cout << "n" <<std::endl << n.t() ; - vpTRACE(" ") ; - vpTRACE(" ") ; - } - std::cout <<"------------------------------------------------------" << std::endl ; + M[0][3] = 0.21 ; + M[1][3] = 0.31 ; + M[2][3] = 0.5 ; - { - vpThetaUVector tu(vpMath::rad(90), vpMath::rad(120), vpMath::rad(45)) ; + std::cout << "M" << std::endl << M << std::endl ; + vpPlane p(0,0,1,1) ; - std::cout << "Initialization " <<std::endl ; - // std::cout << tu << std::endl ; + vpHomography H(M,p) ; + std::cout << "H" << std::endl << H << std::endl ; - std::cout << "From vpThetaUVector to vpRotationMatrix " << std::endl ; - vpRotationMatrix R(tu) ; + vpColVector n ; + vpTranslationVector T ; + H.computeDisplacement(R,T,n) ; - // pure rotation - vpHomogeneousMatrix M ; - M.insert(R) ; - + std::cout << "R" <<std::endl << R ; + std::cout << "T" <<std::endl << T.t() << std::endl; + std::cout << "n" <<std::endl << n.t() << std::endl; + } - M[0][3] = 0.21 ; - M[1][3] = 0.31 ; - M[2][3] = 0.5 ; + std::cout <<"------------------------------------------------------" << std::endl ; + { + vpThetaUVector tu(vpMath::rad(-190), vpMath::rad(12), vpMath::rad(-45)) ; + vpRotationMatrix R(tu) ; - std::cout << "M" <<std::endl <<M << std::endl ; - vpPlane p(0,0,1,1) ; + // pure rotation + vpHomogeneousMatrix M ; + M.insert(R) ; - vpHomography H(M,p) ; + M[0][3] = 0.21 ; + M[1][3] =- 0.31 ; + M[2][3] = 0.5 ; - vpTRACE(" ") ; - std::cout << "H" <<std::endl <<H << std::endl ; + std::cout << "M" << std::endl << M << std::endl ; + vpPlane p(0.4,-0.5,0.5,1) ; + vpHomography H(M,p) ; - vpTRACE(" ") ; + std::cout << "H" << std::endl << H << std::endl ; - vpColVector n ; - vpTranslationVector T ; + vpColVector n ; + vpTranslationVector T ; + H.computeDisplacement(R,T,n) ; - H.computeDisplacement(R,T,n) ; + std::cout << "R" <<std::endl << R ; + std::cout << "T" <<std::endl << T.t() << std::endl; + std::cout << "n" <<std::endl << n.t() << std::endl; - std::cout << "R" <<std::endl << R ; - std::cout << "T" <<std::endl << T.t() ; - std::cout << "n" <<std::endl << n.t() ; - vpTRACE(" ") ; - vpTRACE(" ") ; + vpPlane p1(n[0],n[1],n[2],1.0) ; + H.buildFrom(R,T,p1) ; + std::cout << "H" << std::endl << H << std::endl ; + } + return 0; } - - std::cout <<"------------------------------------------------------" << std::endl ; - { - vpThetaUVector tu(vpMath::rad(-190), vpMath::rad(12), vpMath::rad(-45)) ; - - vpRotationMatrix R(tu) ; - - - // pure rotation - vpHomogeneousMatrix M ; - M.insert(R) ; - - M[0][3] = 0.21 ; - M[1][3] =- 0.31 ; - M[2][3] = 0.5 ; - - std::cout << "M" <<std::endl <<M << std::endl ; - vpPlane p(0.4,-0.5,0.5,1) ; - - vpHomography H(M,p) ; - - vpTRACE(" ") ; - std::cout << "H" <<std::endl <<H << std::endl ; - - vpTRACE(" ") ; - vpColVector n ; - vpTranslationVector T ; - H.computeDisplacement(R,T,n) ; - - std::cout << "R" <<std::endl << R ; - std::cout << "T" <<std::endl << T.t() ; - std::cout << "n" <<std::endl << n.t() ; - - vpPlane p1(n[0],n[1],n[2],1.0) ; - H.buildFrom(R,T,p1) ; - std::cout << "H" <<std::endl <<H << std::endl ; - + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } } diff --git a/test/image/CMakeLists.txt b/test/image/CMakeLists.txt index 90fcb462f1db6ca29793b31af171848ba6f3c63a..a879ba6481b805e6a8c40d2338e0c4eb0782c49f 100644 --- a/test/image/CMakeLists.txt +++ b/test/image/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/test/image/testConversion.cpp b/test/image/testConversion.cpp index aec83bcf7cecbae80e1e20d59fe9ceaed798533d..d1321216d62785c404389efbf0879ba3d4df82fd 100644 --- a/test/image/testConversion.cpp +++ b/test/image/testConversion.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testConversion.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: testConversion.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -61,6 +61,9 @@ // List of allowed command line options #define GETOPTARGS "i:o:h" +void usage(const char *name, const char *badparam, std::string ipath, std::string opath, std::string user); +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &opath, std::string user); + /* Print the program options. @@ -72,8 +75,7 @@ \param user : Username. */ -void usage(const char *name, const char *badparam, std::string ipath, - std::string opath, std::string user) +void usage(const char *name, const char *badparam, std::string ipath, std::string opath, std::string user) { fprintf(stdout, "\n\ Test image conversions.\n\ @@ -120,20 +122,19 @@ OPTIONS: Default\n\ \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) +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &opath, std::string user) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { - case 'i': ipath = optarg; break; - case 'o': opath = optarg; break; + 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; + usage(argv[0], optarg_, ipath, opath, user); return false; break; } } @@ -141,7 +142,7 @@ bool getOptions(int argc, const char **argv, // 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; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -151,410 +152,415 @@ bool getOptions(int argc, const char **argv, 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; - - // 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; - - // Set the default output path -#ifdef WIN32 - opt_opath = "C:/temp"; + try { + std::string env_ipath; + std::string opt_ipath; + std::string opt_opath; + std::string ipath; + std::string opath; + std::string filename; + std::string username; + + // 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; + + // Set the default output path +#if defined(_WIN32) + opt_opath = "C:/temp"; #else - opt_opath = "/tmp"; + opt_opath = "/tmp"; #endif - // Get the user login name - vpIoTools::getUserName(username); - - // Read the command line options - if (getOptions(argc, argv, opt_ipath, opt_opath, username) == false) { - exit (-1); - } + // Get the user login name + vpIoTools::getUserName(username); - // Get the option values - if (!opt_ipath.empty()) - ipath = opt_ipath; - if (!opt_opath.empty()) - opath = opt_opath; + // Read the command line options + if (getOptions(argc, argv, opt_ipath, opt_opath, username) == false) { + exit (-1); + } - // Append to the output path string, the login name of the user - opath += vpIoTools::path("/") + username; + // Get the option values + if (!opt_ipath.empty()) + ipath = opt_ipath; + if (!opt_opath.empty()) + opath = opt_opath; + + // Append to the output path string, the login name of the user + opath += vpIoTools::path("/") + username; + + // Test if the output path exist. If no try to create it + if (vpIoTools::checkDirectory(opath) == false) { + try { + // Create the dirname + vpIoTools::makeDirectory(opath); + } + catch (...) { + usage(argv[0], NULL, ipath, opt_opath, username); + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Cannot create " << opath << std::endl; + std::cerr << " Check your -o " << opt_opath << " option " << std::endl; + exit(-1); + } + } - // Test if the output path exist. If no try to create it - if (vpIoTools::checkDirectory(opath) == false) { - try { - // Create the dirname - vpIoTools::makeDirectory(opath); + // 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()) { + if (ipath != env_ipath) { + std::cout << std::endl + << "WARNING: " << std::endl; + std::cout << " Since -i <visp image path=" << ipath << "> " + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; + } } - catch (...) { + + // Test if an input path is set + if (opt_ipath.empty() && env_ipath.empty()){ usage(argv[0], NULL, ipath, opt_opath, username); std::cerr << std::endl << "ERROR:" << std::endl; - std::cerr << " Cannot create " << opath << std::endl; - std::cerr << " Check your -o " << opt_opath << " option " << std::endl; + std::cerr << " Use -i <visp image path> 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); } - } - - // 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()) { - if (ipath != env_ipath) { - std::cout << std::endl - << "WARNING: " << std::endl; - std::cout << " Since -i <visp image path=" << ipath << "> " - << " 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, opt_opath, username); - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Use -i <visp image path> 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); - } - // - // Here starts really the test - // - - vpImage<unsigned char> Ig ; // Grey image - vpImage<vpRGBa> Ic ; // Color image - - //-------------------- .pgm -> .ppm - vpTRACE("Convert a grey image (.pgm) to a color image (.ppm)"); - // Load a grey image from the disk - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); - vpCTRACE << "Load " << filename << std::endl; - vpImageIo::read(Ig, filename) ; - // Create a color image from the grey - vpImageConvert::convert(Ig, Ic); - filename = opath + vpIoTools::path("/Klimt_color.ppm"); - vpCTRACE << "Write " << filename << std::endl; - vpImageIo::write(Ic, filename) ; - - //-------------------- .ppm -> .pgm - vpTRACE("Convert a color image (.ppm) to a grey image (.pgm)"); - // Load a color image from the disk - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); - vpCTRACE << "Load " << filename << std::endl; - vpImageIo::read(Ic, filename) ; - // Create a grey image from the color - vpImageConvert::convert(Ic, Ig); - filename = opath + vpIoTools::path("/Klimt_grey.pgm"); - vpCTRACE << "Write " << filename << std::endl; - vpImageIo::write(Ig, filename) ; - - //-------------------- YUV -> RGB - unsigned char y=187, u=10, v=30; - unsigned char r, g, b; - - // Convert a YUV pixel value to a RGB value - vpImageConvert::YUVToRGB(y, u, v, r, g, b); - vpTRACE("y(%d) u(%d) v(%d) = r(%d) g(%d) b(%d)", y, u, v, r, g, b); + // + // Here starts really the test + // + + vpImage<unsigned char> Ig ; // Grey image + vpImage<vpRGBa> Ic ; // Color image + + //-------------------- .pgm -> .ppm + vpTRACE("Convert a grey image (.pgm) to a color image (.ppm)"); + // Load a grey image from the disk + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); + vpCTRACE << "Load " << filename << std::endl; + vpImageIo::read(Ig, filename) ; + // Create a color image from the grey + vpImageConvert::convert(Ig, Ic); + filename = opath + vpIoTools::path("/Klimt_color.ppm"); + vpCTRACE << "Write " << filename << std::endl; + vpImageIo::write(Ic, filename) ; + + //-------------------- .ppm -> .pgm + vpTRACE("Convert a color image (.ppm) to a grey image (.pgm)"); + // Load a color image from the disk + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); + vpCTRACE << "Load " << filename << std::endl; + vpImageIo::read(Ic, filename) ; + // Create a grey image from the color + vpImageConvert::convert(Ic, Ig); + filename = opath + vpIoTools::path("/Klimt_grey.pgm"); + vpCTRACE << "Write " << filename << std::endl; + vpImageIo::write(Ig, filename) ; + + //-------------------- YUV -> RGB + unsigned char y=187, u=10, v=30; + unsigned char r, g, b; + + // Convert a YUV pixel value to a RGB value + vpImageConvert::YUVToRGB(y, u, v, r, g, b); + vpTRACE("y(%d) u(%d) v(%d) = r(%d) g(%d) b(%d)", y, u, v, r, g, b); #ifdef VISP_HAVE_OPENCV - double t0 = vpTime::measureTimeMs(); - ///////////////////////// - // Convert a IplImage to a vpImage<vpRGBa> - //////////////////////// - IplImage* image = NULL; /*!< The image read / acquired */ - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); - - /* Read the color image */ - - vpCTRACE << "Reading the color image with opencv: "<< std::endl - << filename << std::endl; - if((image = cvLoadImage(filename.c_str(), CV_LOAD_IMAGE_COLOR)) == NULL) { - vpCTRACE<<"Cannot read image: "<< std::endl << filename << std::endl; - return (-1); - } - vpImageConvert::convert(image, Ic); - filename = opath + vpIoTools::path("/Klimt_color_cv.ppm"); - /* Save the the current image */ - vpImageIo::write(Ic, filename) ; + double t0 = vpTime::measureTimeMs(); + ///////////////////////// + // Convert a IplImage to a vpImage<vpRGBa> + //////////////////////// + IplImage* image = NULL; /*!< The image read / acquired */ + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); + + /* Read the color image */ + + vpCTRACE << "Reading the color image with opencv: "<< std::endl + << filename << std::endl; + if((image = cvLoadImage(filename.c_str(), CV_LOAD_IMAGE_COLOR)) == NULL) { + vpCTRACE<<"Cannot read image: "<< std::endl << filename << std::endl; + return (-1); + } + vpImageConvert::convert(image, Ic); + filename = opath + vpIoTools::path("/Klimt_color_cv.ppm"); + /* Save the the current image */ + vpImageIo::write(Ic, filename) ; - vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; + vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); - /* Read the pgm image */ + /* Read the pgm image */ - vpCTRACE << "Reading the greyscale image with opencv: "<< std::endl - << filename << std::endl; - if(image!=NULL) cvReleaseImage( &image ); - if((image = cvLoadImage(filename.c_str(), CV_LOAD_IMAGE_GRAYSCALE)) == NULL) { - vpCTRACE<<"Cannot read image: "<< std::endl << filename << std::endl; - return (-1); - } - vpImageConvert::convert(image, Ic); - filename = opath + vpIoTools::path("/Klimt_grey_cv.ppm"); - /* Save the the current image */ - vpImageIo::write(Ic, filename) ; - - vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; - - /////////////////////////// - // Convert a IplImage to a vpImage<unsigned char> - //////////////////////////// - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); - - /* Read the color image */ - - vpCTRACE << "Reading the color image with opencv: "<< std::endl - << filename << std::endl; - if(image!=NULL) cvReleaseImage( &image ); - if((image = cvLoadImage(filename.c_str(), CV_LOAD_IMAGE_COLOR)) == NULL) { - vpCTRACE<<"Cannot read image: "<< std::endl << filename << std::endl; - return (-1); - } - vpImageConvert::convert(image, Ig); - filename = opath + vpIoTools::path("/Klimt_color_cv.pgm"); - /* Save the the current image */ - vpImageIo::write(Ig, filename) ; + vpCTRACE << "Reading the greyscale image with opencv: "<< std::endl + << filename << std::endl; + if(image!=NULL) cvReleaseImage( &image ); + if((image = cvLoadImage(filename.c_str(), CV_LOAD_IMAGE_GRAYSCALE)) == NULL) { + vpCTRACE<<"Cannot read image: "<< std::endl << filename << std::endl; + return (-1); + } + vpImageConvert::convert(image, Ic); + filename = opath + vpIoTools::path("/Klimt_grey_cv.ppm"); + /* Save the the current image */ + vpImageIo::write(Ic, filename) ; - vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; + vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); + /////////////////////////// + // Convert a IplImage to a vpImage<unsigned char> + //////////////////////////// + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); - /* Read the pgm image */ + /* Read the color image */ - vpCTRACE << "Reading the greyscale image with opencv: "<< std::endl - << filename << std::endl; - if(image!=NULL) cvReleaseImage( &image ); - if((image = cvLoadImage(filename.c_str(), CV_LOAD_IMAGE_GRAYSCALE)) == NULL) { - vpCTRACE<<"Cannot read image: "<< std::endl << filename << std::endl; - - return (-1); - } - vpImageConvert::convert(image, Ig); - filename = opath + vpIoTools::path("/Klimt_grey_cv.pgm"); - /* Save the the current image */ - vpImageIo::write(Ig, filename) ; - - vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; - - //////////////////////////////////// - // Convert a vpImage<vpRGBa> to a IplImage - //////////////////////////////////// - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); - - /* Read the color image */ - - // Load a color image from the disk - vpCTRACE << "Load " << filename << std::endl; - vpImageIo::read(Ic, filename) ; - vpImageConvert::convert(Ic, image); - filename = opath + vpIoTools::path("/Klimt_ipl_color_cv.ppm"); - /* Save the the current image */ - vpCTRACE << "Write " << filename << std::endl; - if((cvSaveImage(filename.c_str(), image)) == 0) { - vpCTRACE<<"Cannot write image: "<< std::endl << filename << std::endl; + vpCTRACE << "Reading the color image with opencv: "<< std::endl + << filename << std::endl; if(image!=NULL) cvReleaseImage( &image ); - return (-1); - } - vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; + if((image = cvLoadImage(filename.c_str(), CV_LOAD_IMAGE_COLOR)) == NULL) { + vpCTRACE<<"Cannot read image: "<< std::endl << filename << std::endl; + return (-1); + } + vpImageConvert::convert(image, Ig); + filename = opath + vpIoTools::path("/Klimt_color_cv.pgm"); + /* Save the the current image */ + vpImageIo::write(Ig, filename) ; - //////////////////////////////////////// - // Convert a IplImage to a vpImage<unsigned char> - //////////////////////////////////////// - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); + vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; - /* Read the grey image */ + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); - // Load a color image from the disk - vpCTRACE << "Load " << filename << std::endl; - vpImageIo::read(Ig, filename) ; - vpImageConvert::convert(Ig, image); - filename = opath + vpIoTools::path("/Klimt_ipl_grey_cv.pgm"); - /* Save the the current image */ + /* Read the pgm image */ - vpCTRACE << "Write " << filename << std::endl; - if((cvSaveImage(filename.c_str(), image)) == 0) { - vpCTRACE<<"Cannot write image: "<< std::endl << filename << std::endl; + vpCTRACE << "Reading the greyscale image with opencv: "<< std::endl + << filename << std::endl; if(image!=NULL) cvReleaseImage( &image ); - return (-1); - } - vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; - - if(image!=NULL) cvReleaseImage( &image ); - double t1 = vpTime::measureTimeMs(); - std::cout << "Conversion c interface : " << t1 - t0 << " ms" << std::endl; + if((image = cvLoadImage(filename.c_str(), CV_LOAD_IMAGE_GRAYSCALE)) == NULL) { + vpCTRACE<<"Cannot read image: "<< std::endl << filename << std::endl; - /* ------------------------------------------------------------------------ */ - /* conversion for the new c++ interface */ - /* ------------------------------------------------------------------------ */ + return (-1); + } + vpImageConvert::convert(image, Ig); + filename = opath + vpIoTools::path("/Klimt_grey_cv.pgm"); + /* Save the the current image */ + vpImageIo::write(Ig, filename) ; + + vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; + + //////////////////////////////////// + // Convert a vpImage<vpRGBa> to a IplImage + //////////////////////////////////// + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); + + /* Read the color image */ + + // Load a color image from the disk + vpCTRACE << "Load " << filename << std::endl; + vpImageIo::read(Ic, filename) ; + vpImageConvert::convert(Ic, image); + filename = opath + vpIoTools::path("/Klimt_ipl_color_cv.ppm"); + /* Save the the current image */ + vpCTRACE << "Write " << filename << std::endl; + if((cvSaveImage(filename.c_str(), image)) == 0) { + vpCTRACE<<"Cannot write image: "<< std::endl << filename << std::endl; + if(image!=NULL) cvReleaseImage( &image ); + return (-1); + } + vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; + + //////////////////////////////////////// + // Convert a IplImage to a vpImage<unsigned char> + //////////////////////////////////////// + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); + + /* Read the grey image */ + + // Load a color image from the disk + vpCTRACE << "Load " << filename << std::endl; + vpImageIo::read(Ig, filename) ; + vpImageConvert::convert(Ig, image); + filename = opath + vpIoTools::path("/Klimt_ipl_grey_cv.pgm"); + /* Save the the current image */ + + vpCTRACE << "Write " << filename << std::endl; + if((cvSaveImage(filename.c_str(), image)) == 0) { + vpCTRACE<<"Cannot write image: "<< std::endl << filename << std::endl; + if(image!=NULL) cvReleaseImage( &image ); + return (-1); + } + vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; -#if VISP_HAVE_OPENCV_VERSION >= 0x020100 - double t2 = vpTime::measureTimeMs(); - ///////////////////////// - // Convert a cv::Mat to a vpImage<vpRGBa> - //////////////////////// - cv::Mat imageMat; - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); - vpCTRACE << "Reading the color image with c++ interface of opencv: "<< std::endl - << filename << std::endl; - imageMat = cv::imread(filename, 1);// force to a three channel color image. - if(imageMat.data == NULL){ - vpCTRACE<<"Cannot read image: "<< std::endl << filename << std::endl; - return -1; - } - vpImageConvert::convert(imageMat, Ic); - filename = opath + vpIoTools::path("/Klimt_color_cvMat.ppm"); - /* Save the the current image */ - vpImageIo::write(Ic, filename) ; - vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; - - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); - /* Read the pgm image */ - - vpCTRACE << "Reading the greyscale image with opencv: "<< std::endl - << filename << std::endl; - imageMat = cv::imread(filename, 0);// forced to grayscale. - if(imageMat.data == NULL) { - vpCTRACE<<"Cannot read image: "<< std::endl << filename << std::endl; - return (-1); - } - vpImageConvert::convert(imageMat, Ic); - filename = opath + vpIoTools::path("/Klimt_grey_cvMat.ppm"); - /* Save the the current image */ - vpImageIo::write(Ic, filename) ; - vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; - - /////////////////////////// - // Convert a cv::Mat to a vpImage<unsigned char> - //////////////////////////// - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); - - /* Read the color image */ - - vpCTRACE << "Reading the color image with opencv: "<< std::endl - << filename << std::endl; - imageMat = cv::imread(filename, 1);// force to a three channel color image. - if(imageMat.data == NULL){ - vpCTRACE<<"Cannot read image: "<< std::endl << filename << std::endl; - return -1; - } - vpImageConvert::convert(imageMat, Ig); - filename = opath + vpIoTools::path("/Klimt_color_cvMat.pgm"); - /* Save the the current image */ - vpImageIo::write(Ig, filename) ; - vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; - - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); - - /* Read the pgm image */ - - vpCTRACE << "Reading the greyscale image with opencv: "<< std::endl - << filename << std::endl; - imageMat = cv::imread(filename, 0); - if(imageMat.data == NULL){ - vpCTRACE<<"Cannot read image: "<< std::endl << filename << std::endl; - return (-1); - } - vpImageConvert::convert(imageMat, Ig); - filename = opath + vpIoTools::path("/Klimt_grey_cvMat.pgm"); - /* Save the the current image */ - vpImageIo::write(Ig, filename) ; - - vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; - - //////////////////////////////////// - // Convert a vpImage<vpRGBa> to a cv::Mat - //////////////////////////////////// - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); - - /* Read the color image */ - - // Load a color image from the disk - vpCTRACE << "Load " << filename << std::endl; - vpImageIo::read(Ic, filename) ; - vpImageConvert::convert(Ic, imageMat); - filename = opath + vpIoTools::path("/Klimt_ipl_color_cvMat.ppm"); - /* Save the the current image */ - vpCTRACE << "Write " << filename << std::endl; - if(!cv::imwrite(filename, imageMat)){ - vpCTRACE<<"Cannot write image: "<< std::endl << filename << std::endl; if(image!=NULL) cvReleaseImage( &image ); - return (-1); - } - vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; - - //////////////////////////////////////// - // Convert a IplImage to a vpImage<unsigned char> - //////////////////////////////////////// - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); - - /* Read the grey image */ + double t1 = vpTime::measureTimeMs(); + std::cout << "Conversion c interface : " << t1 - t0 << " ms" << std::endl; - // Load a color image from the disk - vpCTRACE << "Load " << filename << std::endl; - vpImageIo::read(Ig, filename); - vpImageConvert::convert(Ig, imageMat); - filename = opath + vpIoTools::path("/Klimt_ipl_grey_cvMat.pgm"); - /* Save the the current image */ + /* ------------------------------------------------------------------------ */ + /* conversion for the new c++ interface */ + /* ------------------------------------------------------------------------ */ - vpCTRACE << "Write " << filename << std::endl; - if(!cv::imwrite(filename, imageMat)){ - vpCTRACE<<"Cannot write image: "<< std::endl << filename << std::endl; - if(image!=NULL) cvReleaseImage( &image ); - return (-1); - } - vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; - double t3 = vpTime::measureTimeMs(); - std::cout << "Conversion c++ interface : " << t3 - t2 << " ms" << std::endl; +#if VISP_HAVE_OPENCV_VERSION >= 0x020100 + double t2 = vpTime::measureTimeMs(); + ///////////////////////// + // Convert a cv::Mat to a vpImage<vpRGBa> + //////////////////////// + cv::Mat imageMat; + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); + vpCTRACE << "Reading the color image with c++ interface of opencv: "<< std::endl + << filename << std::endl; + imageMat = cv::imread(filename, 1);// force to a three channel color image. + if(imageMat.data == NULL){ + vpCTRACE<<"Cannot read image: "<< std::endl << filename << std::endl; + return -1; + } + vpImageConvert::convert(imageMat, Ic); + filename = opath + vpIoTools::path("/Klimt_color_cvMat.ppm"); + /* Save the the current image */ + vpImageIo::write(Ic, filename) ; + vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; + + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); + /* Read the pgm image */ + + vpCTRACE << "Reading the greyscale image with opencv: "<< std::endl + << filename << std::endl; + imageMat = cv::imread(filename, 0);// forced to grayscale. + if(imageMat.data == NULL) { + vpCTRACE<<"Cannot read image: "<< std::endl << filename << std::endl; + return (-1); + } + vpImageConvert::convert(imageMat, Ic); + filename = opath + vpIoTools::path("/Klimt_grey_cvMat.ppm"); + /* Save the the current image */ + vpImageIo::write(Ic, filename) ; + vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; + + /////////////////////////// + // Convert a cv::Mat to a vpImage<unsigned char> + //////////////////////////// + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); + + /* Read the color image */ + + vpCTRACE << "Reading the color image with opencv: "<< std::endl + << filename << std::endl; + imageMat = cv::imread(filename, 1);// force to a three channel color image. + if(imageMat.data == NULL){ + vpCTRACE<<"Cannot read image: "<< std::endl << filename << std::endl; + return -1; + } + vpImageConvert::convert(imageMat, Ig); + filename = opath + vpIoTools::path("/Klimt_color_cvMat.pgm"); + /* Save the the current image */ + vpImageIo::write(Ig, filename) ; + vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; + + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); + + /* Read the pgm image */ + + vpCTRACE << "Reading the greyscale image with opencv: "<< std::endl + << filename << std::endl; + imageMat = cv::imread(filename, 0); + if(imageMat.data == NULL){ + vpCTRACE<<"Cannot read image: "<< std::endl << filename << std::endl; + return (-1); + } + vpImageConvert::convert(imageMat, Ig); + filename = opath + vpIoTools::path("/Klimt_grey_cvMat.pgm"); + /* Save the the current image */ + vpImageIo::write(Ig, filename) ; + + vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; + + //////////////////////////////////// + // Convert a vpImage<vpRGBa> to a cv::Mat + //////////////////////////////////// + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); + + /* Read the color image */ + + // Load a color image from the disk + vpCTRACE << "Load " << filename << std::endl; + vpImageIo::read(Ic, filename) ; + vpImageConvert::convert(Ic, imageMat); + filename = opath + vpIoTools::path("/Klimt_ipl_color_cvMat.ppm"); + /* Save the the current image */ + vpCTRACE << "Write " << filename << std::endl; + if(!cv::imwrite(filename, imageMat)){ + vpCTRACE<<"Cannot write image: "<< std::endl << filename << std::endl; + if(image!=NULL) cvReleaseImage( &image ); + return (-1); + } + vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; + + //////////////////////////////////////// + // Convert a IplImage to a vpImage<unsigned char> + //////////////////////////////////////// + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); + + /* Read the grey image */ + + // Load a color image from the disk + vpCTRACE << "Load " << filename << std::endl; + vpImageIo::read(Ig, filename); + vpImageConvert::convert(Ig, imageMat); + filename = opath + vpIoTools::path("/Klimt_ipl_grey_cvMat.pgm"); + /* Save the the current image */ + + vpCTRACE << "Write " << filename << std::endl; + if(!cv::imwrite(filename, imageMat)){ + vpCTRACE<<"Cannot write image: "<< std::endl << filename << std::endl; + if(image!=NULL) cvReleaseImage( &image ); + return (-1); + } + vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; + double t3 = vpTime::measureTimeMs(); + std::cout << "Conversion c++ interface : " << t3 - t2 << " ms" << std::endl; #endif #endif - - //////////////////////////////////// - // Split a vpImage<vpRGBa> to vpImage<unsigned char> - //////////////////////////////////// - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); - - /* Read the color image */ - - // Load a color image from the disk - vpCTRACE << "Load " << filename << std::endl; - vpImageIo::read(Ic, filename) ; - vpImage<unsigned char> R,G,B,a; - vpImageConvert::split(Ic, &R,NULL,&B); - double begintime = vpTime::measureTimeMs(); - for(int i=0; i<1000;i++){ + + //////////////////////////////////// + // Split a vpImage<vpRGBa> to vpImage<unsigned char> + //////////////////////////////////// + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); + + /* Read the color image */ + + // Load a color image from the disk + vpCTRACE << "Load " << filename << std::endl; + vpImageIo::read(Ic, filename) ; + vpImage<unsigned char> R,G,B,a; vpImageConvert::split(Ic, &R,NULL,&B); + double begintime = vpTime::measureTimeMs(); + for(int i=0; i<1000;i++){ + vpImageConvert::split(Ic, &R,NULL,&B); + } + double endtime = vpTime::measureTimeMs(); + + std::cout<<"Time for 1000 split (ms): "<< endtime - begintime <<std::endl; + + filename = opath + vpIoTools::path("/Klimt_RChannel.pgm"); + /* Save the the current image */ + vpCTRACE << "Write " << filename << std::endl; + vpImageIo::write(R, filename) ; + vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; + + filename = opath + vpIoTools::path("/Klimt_BChannel.pgm"); + /* Save the the current image */ + vpCTRACE << "Write " << filename << std::endl; + vpImageIo::write(B, filename) ; + vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - double endtime = vpTime::measureTimeMs(); - - std::cout<<"Time for 1000 split (ms): "<< endtime - begintime <<std::endl; - - filename = opath + vpIoTools::path("/Klimt_RChannel.pgm"); - /* Save the the current image */ - vpCTRACE << "Write " << filename << std::endl; - vpImageIo::write(R, filename) ; - vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; - - filename = opath + vpIoTools::path("/Klimt_BChannel.pgm"); - /* Save the the current image */ - vpCTRACE << "Write " << filename << std::endl; - vpImageIo::write(B, filename) ; - vpCTRACE<< "Convert result in "<<std::endl<< filename << std::endl; - } diff --git a/test/image/testCreateSubImage.cpp b/test/image/testCreateSubImage.cpp index 44105425a67d657265f9a749edac2e87847d5b25..c27d182e815c04aaf75dcb4a93b3c2072e89a611 100644 --- a/test/image/testCreateSubImage.cpp +++ b/test/image/testCreateSubImage.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testCreateSubImage.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: testCreateSubImage.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -62,6 +62,9 @@ // List of allowed command line options #define GETOPTARGS "i:o:h" +void usage(const char *name, const char *badparam, std::string ipath, std::string opath, std::string user); +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &opath, std::string user); + /* Print the program options. @@ -120,20 +123,19 @@ OPTIONS: Default\n\ \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) +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &opath, std::string user) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { - case 'i': ipath = optarg; break; - case 'o': opath = optarg; break; + 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; + usage(argv[0], optarg_, ipath, opath, user); return false; break; } } @@ -141,7 +143,7 @@ bool getOptions(int argc, const char **argv, // 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; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -151,112 +153,118 @@ bool getOptions(int argc, const char **argv, 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; - - // 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; - - // Set the default output path -#ifdef WIN32 - opt_opath = "C:/temp"; + try { + std::string env_ipath; + std::string opt_ipath; + std::string opt_opath; + std::string ipath; + std::string opath; + std::string filename; + std::string username; + + // 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; + + // Set the default output path +#if defined(_WIN32) + opt_opath = "C:/temp"; #else - opt_opath = "/tmp"; + opt_opath = "/tmp"; #endif - // Get the user login name - vpIoTools::getUserName(username); - - // Read the command line options - if (getOptions(argc, argv, opt_ipath, opt_opath, username) == false) { - exit (-1); - } + // Get the user login name + vpIoTools::getUserName(username); - // Get the option values - if (!opt_ipath.empty()) - ipath = opt_ipath; - if (!opt_opath.empty()) - opath = opt_opath; + // Read the command line options + if (getOptions(argc, argv, opt_ipath, opt_opath, username) == false) { + exit (-1); + } - // Append to the output path string, the login name of the user - opath += vpIoTools::path("/") + username; + // Get the option values + if (!opt_ipath.empty()) + ipath = opt_ipath; + if (!opt_opath.empty()) + opath = opt_opath; + + // Append to the output path string, the login name of the user + opath += vpIoTools::path("/") + username; + + // Test if the output path exist. If no try to create it + if (vpIoTools::checkDirectory(opath) == false) { + try { + // Create the dirname + vpIoTools::makeDirectory(opath); + } + catch (...) { + usage(argv[0], NULL, ipath, opt_opath, username); + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Cannot create " << opath << std::endl; + std::cerr << " Check your -o " << opt_opath << " option " << std::endl; + exit(-1); + } + } - // Test if the output path exist. If no try to create it - if (vpIoTools::checkDirectory(opath) == false) { - try { - // Create the dirname - vpIoTools::makeDirectory(opath); + // 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()) { + if (ipath != env_ipath) { + std::cout << std::endl + << "WARNING: " << std::endl; + std::cout << " Since -i <visp image path=" << ipath << "> " + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; + } } - catch (...) { + + // Test if an input path is set + if (opt_ipath.empty() && env_ipath.empty()){ usage(argv[0], NULL, ipath, opt_opath, username); std::cerr << std::endl << "ERROR:" << std::endl; - std::cerr << " Cannot create " << opath << std::endl; - std::cerr << " Check your -o " << opt_opath << " option " << std::endl; + std::cerr << " Use -i <visp image path> 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); } - } - // 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()) { - if (ipath != env_ipath) { - std::cout << std::endl - << "WARNING: " << std::endl; - std::cout << " Since -i <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; - } + // + // Here starts really the test + // + vpImage<unsigned char> I; // Input image + vpImage<unsigned char> C; // Cropped output image + + + // Read the input grey image from the disk + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); + std::cout << "Read image: " << filename << std::endl; + vpImageIo::read(I, filename) ; + + // Specify the cropping area + vpRect crop; + crop.setLeft(-10.2); + crop.setTop(10.0); + crop.setWidth(I.getWidth()); + crop.setHeight(20.0); + + // Create the cropped image + vpImageTools::createSubImage(I, crop, C); + + // Write the cropped image on the disk + filename = opath + vpIoTools::path("/Klimt_crop.pgm"); + std::cout << "Write cropped image: " << filename << std::endl; + vpImageIo::write(C, filename) ; + return 0; } - - // Test if an input path is set - if (opt_ipath.empty() && env_ipath.empty()){ - usage(argv[0], NULL, ipath, opt_opath, username); - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Use -i <visp image path> 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); + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - - // - // Here starts really the test - // - vpImage<unsigned char> I; // Input image - vpImage<unsigned char> C; // Cropped output image - - - // Read the input grey image from the disk - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); - std::cout << "Read image: " << filename << std::endl; - vpImageIo::read(I, filename) ; - - // Specify the cropping area - vpRect crop; - crop.setLeft(-10.2); - crop.setTop(10.0); - crop.setWidth(I.getWidth()); - crop.setHeight(20.0); - - // Create the cropped image - vpImageTools::createSubImage(I, crop, C); - - // Write the cropped image on the disk - filename = opath + vpIoTools::path("/Klimt_crop.pgm"); - std::cout << "Write cropped image: " << filename << std::endl; - vpImageIo::write(C, filename) ; - } diff --git a/test/image/testImagePoint.cpp b/test/image/testImagePoint.cpp index 87cb0b8fe2a49b5b89dfecf21e32127b118ee55a..d21b6404a148548fcf5fdcdf2cd50ca50ab1d397 100644 --- a/test/image/testImagePoint.cpp +++ b/test/image/testImagePoint.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testImagePoint.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testImagePoint.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 diff --git a/test/image/testIoPGM.cpp b/test/image/testIoPGM.cpp index d094fc6de71d1c4d9de5b8815bf9a8f873cde98e..8dd1a8bcd0eec03ff00b9d7116affb788bbdae7b 100644 --- a/test/image/testIoPGM.cpp +++ b/test/image/testIoPGM.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testIoPGM.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: testIoPGM.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -58,6 +58,8 @@ // List of allowed command line options #define GETOPTARGS "i:o:h" +void usage(const char *name, const char *badparam, std::string ipath, std::string opath, std::string user); +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &opath, std::string user); /* @@ -116,20 +118,19 @@ OPTIONS: Default\n\ \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) +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &opath, std::string user) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { - case 'i': ipath = optarg; break; - case 'o': opath = optarg; break; + 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; + usage(argv[0], optarg_, ipath, opath, user); return false; break; } } @@ -137,7 +138,7 @@ bool getOptions(int argc, const char **argv, // 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; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -147,128 +148,128 @@ bool getOptions(int argc, const char **argv, 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; - - // 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; - - // Set the default output path -#ifdef WIN32 - opt_opath = "C:/temp"; + try { + std::string env_ipath; + std::string opt_ipath; + std::string opt_opath; + std::string ipath; + std::string opath; + std::string filename; + std::string username; + + // 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; + + // Set the default output path +#if defined(_WIN32) + opt_opath = "C:/temp"; #else - opt_opath = "/tmp"; + opt_opath = "/tmp"; #endif - // Get the user login name - vpIoTools::getUserName(username); - - // Read the command line options - if (getOptions(argc, argv, opt_ipath, opt_opath, username) == false) { - exit (-1); - } + // Get the user login name + vpIoTools::getUserName(username); - // Get the option values - if (!opt_ipath.empty()) - ipath = opt_ipath; - if (!opt_opath.empty()) - opath = opt_opath; + // Read the command line options + if (getOptions(argc, argv, opt_ipath, opt_opath, username) == false) { + exit (-1); + } - // Append to the output path string, the login name of the user - opath += vpIoTools::path("/") + username; + // Get the option values + if (!opt_ipath.empty()) + ipath = opt_ipath; + if (!opt_opath.empty()) + opath = opt_opath; + + // Append to the output path string, the login name of the user + opath += vpIoTools::path("/") + username; + + // Test if the output path exist. If no try to create it + if (vpIoTools::checkDirectory(opath) == false) { + try { + // Create the dirname + vpIoTools::makeDirectory(opath); + } + catch (...) { + usage(argv[0], NULL, ipath, opt_opath, username); + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Cannot create " << opath << std::endl; + std::cerr << " Check your -o " << opt_opath << " option " << std::endl; + exit(-1); + } + } - // Test if the output path exist. If no try to create it - if (vpIoTools::checkDirectory(opath) == false) { - try { - // Create the dirname - vpIoTools::makeDirectory(opath); + // 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 <visp image path=" << ipath << "> " + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; + } } - catch (...) { + + // Test if an input path is set + if (opt_ipath.empty() && env_ipath.empty()){ usage(argv[0], NULL, ipath, opt_opath, username); std::cerr << std::endl << "ERROR:" << std::endl; - std::cerr << " Cannot create " << opath << std::endl; - std::cerr << " Check your -o " << opt_opath << " option " << std::endl; + std::cerr << " Use -i <visp image path> 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); } - } - // 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 <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; - } - } + // + // Here starts really the test + // - // Test if an input path is set - if (opt_ipath.empty() && env_ipath.empty()){ - usage(argv[0], NULL, ipath, opt_opath, username); - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Use -i <visp image path> 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); - } + // Create a grey level image + vpImage<unsigned char> I ; - // - // Here starts really the test - // - - // Create a grey level image - vpImage<unsigned char> I ; - - // Load a grey image from the disk - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); - std::cout << "Read image: " << filename << std::endl; - vpImageIo::read(I, filename); - // Write the content of the image on the disk - filename = opath + vpIoTools::path("/Klimt_grey.pgm"); - std::cout << "Write image: " << filename << std::endl; - vpImageIo::write(I, filename) ; - - // Try to load a non existing image (test for exceptions) - try - { - // Load a non existing grey image - filename = ipath + vpIoTools::path("/ViSP-images/image-that-does-not-exist.pgm"); + // Load a grey image from the disk + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); std::cout << "Read image: " << filename << std::endl; - vpImageIo::read(I, filename) ; - } - catch(vpImageException e) - { - vpERROR_TRACE("at main level"); - std::cout << e << std::endl ; - } - - // Try to write an image to a non existing directory - try - { - filename = opath + vpIoTools::path("/directory-that-does-not-exist/Klimt.pgm"); + vpImageIo::read(I, filename); + // Write the content of the image on the disk + filename = opath + vpIoTools::path("/Klimt_grey.pgm"); std::cout << "Write image: " << filename << std::endl; vpImageIo::write(I, filename) ; + + try { + // Try to load a non existing image (test for exceptions) + // Load a non existing grey image + filename = ipath + vpIoTools::path("/ViSP-images/image-that-does-not-exist.pgm"); + std::cout << "Read image: " << filename << std::endl; + vpImageIo::read(I, filename) ; + } + catch(vpException e) { + std::cout << "Catch an exception due to a non existing file: " << e << std::endl; + } + + try { + // Try to write an image to a non existing directory + filename = opath + vpIoTools::path("/directory-that-does-not-exist/Klimt.pgm"); + std::cout << "Write image: " << filename << std::endl; + vpImageIo::write(I, filename) ; + } + catch(vpException e) { + std::cout << "Catch an exception due to a non existing file: " << e << std::endl; + } + return 0; } - catch(vpImageException e) - { - vpERROR_TRACE("at main level"); - std::cout << e << std::endl ; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } } diff --git a/test/image/testIoPPM.cpp b/test/image/testIoPPM.cpp index 3327e51a54942d6342ed86505ff7eb8805554fcd..17dc62f1a0a9a4f19a53a07b9f10e432a63c364d 100644 --- a/test/image/testIoPPM.cpp +++ b/test/image/testIoPPM.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testIoPPM.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: testIoPPM.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -59,6 +59,8 @@ // List of allowed command line options #define GETOPTARGS "i:o:h" +void usage(const char *name, const char *badparam, std::string ipath, std::string opath, std::string user); +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &opath, std::string user); /* @@ -118,20 +120,19 @@ OPTIONS: Default\n\ \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) +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &opath, std::string user) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { - case 'i': ipath = optarg; break; - case 'o': opath = optarg; break; + 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; + usage(argv[0], optarg_, ipath, opath, user); return false; break; } } @@ -139,7 +140,7 @@ bool getOptions(int argc, const char **argv, // 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; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -149,170 +150,167 @@ bool getOptions(int argc, const char **argv, 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; - - // 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; - - // Set the default output path -#ifdef WIN32 - opt_opath = "C:/temp"; + try { + std::string env_ipath; + std::string opt_ipath; + std::string opt_opath; + std::string ipath; + std::string opath; + std::string filename; + std::string username; + + // 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; + + // Set the default output path +#if defined(_WIN32) + opt_opath = "C:/temp"; #else - opt_opath = "/tmp"; + opt_opath = "/tmp"; #endif - // Get the user login name - vpIoTools::getUserName(username); - - // Read the command line options - if (getOptions(argc, argv, opt_ipath, opt_opath, username) == false) { - exit (-1); - } + // Get the user login name + vpIoTools::getUserName(username); - // Get the option values - if (!opt_ipath.empty()) - ipath = opt_ipath; - if (!opt_opath.empty()) - opath = opt_opath; + // Read the command line options + if (getOptions(argc, argv, opt_ipath, opt_opath, username) == false) { + exit (-1); + } - // Append to the output path string, the login name of the user - opath += vpIoTools::path("/") + username; + // Get the option values + if (!opt_ipath.empty()) + ipath = opt_ipath; + if (!opt_opath.empty()) + opath = opt_opath; + + // Append to the output path string, the login name of the user + opath += vpIoTools::path("/") + username; + + // Test if the output path exist. If no try to create it + if (vpIoTools::checkDirectory(opath) == false) { + try { + // Create the dirname + vpIoTools::makeDirectory(opath); + } + catch (...) { + usage(argv[0], NULL, ipath, opt_opath, username); + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Cannot create " << opath << std::endl; + std::cerr << " Check your -o " << opt_opath << " option " << std::endl; + exit(-1); + } + } - // Test if the output path exist. If no try to create it - if (vpIoTools::checkDirectory(opath) == false) { - try { - // Create the dirname - vpIoTools::makeDirectory(opath); + // 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 <visp image path=" << ipath << "> " + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; + } } - catch (...) { + + // Test if an input path is set + if (opt_ipath.empty() && env_ipath.empty()){ usage(argv[0], NULL, ipath, opt_opath, username); std::cerr << std::endl << "ERROR:" << std::endl; - std::cerr << " Cannot create " << opath << std::endl; - std::cerr << " Check your -o " << opt_opath << " option " << std::endl; + std::cerr << " Use -i <visp image path> 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); } - } - // 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 <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; - } - } + // + // Here starts really the test + // - // Test if an input path is set - if (opt_ipath.empty() && env_ipath.empty()){ - usage(argv[0], NULL, ipath, opt_opath, username); - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Use -i <visp image path> 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); - } + ///////////////////////////////////////////////////////////////////// + // Create a grey level image + vpImage<unsigned char> I ; - // - // Here starts really the test - // - - ///////////////////////////////////////////////////////////////////// - // Create a grey level image - vpImage<unsigned char> I ; - - // Load a color image from the disk and convert it to a grey level one - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); - std::cout << "Read image: " << filename << std::endl; - vpImageIo::read(I, filename); - // Write the content of the image on the disk - filename = opath + vpIoTools::path("/Klimt_grey.ppm"); - std::cout << "Write image: " << filename << std::endl; - vpImageIo::write(I, filename) ; - - // Try to load a non existing image (test for exceptions) - try - { - // Load a non existing grey image - filename = ipath + vpIoTools::path("/ViSP-images/image-that-does-not-exist.ppm"); + // Load a color image from the disk and convert it to a grey level one + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); std::cout << "Read image: " << filename << std::endl; - vpImageIo::read(I, filename) ; - } - catch(vpImageException e) - { - vpERROR_TRACE("at main level"); - std::cout << e << std::endl ; - } - - // Try to write an image to a non existing directory - try - { - filename = opath + vpIoTools::path("/directory-that-does-not-exist/Klimt.ppm"); + vpImageIo::read(I, filename); + // Write the content of the image on the disk + filename = opath + vpIoTools::path("/Klimt_grey.ppm"); std::cout << "Write image: " << filename << std::endl; vpImageIo::write(I, filename) ; - } - catch(vpImageException e) - { - vpERROR_TRACE("at main level"); - std::cout << e << std::endl ; - } - ///////////////////////////////////////////////////////////////////// - // Create a color image - vpImage<vpRGBa> Irgba ; - - // Load a color image from the disk - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); - std::cout << "Read image: " << filename << std::endl; - vpImageIo::read(Irgba, filename); - // Write the content of the color image on the disk - filename = opath + vpIoTools::path("/Klimt_color.ppm"); - std::cout << "Write image: " << filename << std::endl; - vpImageIo::write(Irgba, filename) ; - - // Try to load a non existing image (test for exceptions) - try - { - // Load a non existing color image - filename = ipath + vpIoTools::path("/ViSP-images/image-that-does-not-exist.ppm"); - std::cout << "Read image: " << filename << std::endl; - vpImageIo::read(Irgba, filename) ; - } - catch(vpImageException e) - { - vpERROR_TRACE("at main level"); - std::cout << e << std::endl ; - } + // Try to load a non existing image (test for exceptions) + try + { + // Load a non existing grey image + filename = ipath + vpIoTools::path("/ViSP-images/image-that-does-not-exist.ppm"); + std::cout << "Read image: " << filename << std::endl; + vpImageIo::read(I, filename) ; + } + catch(vpImageException e) + { + vpERROR_TRACE("at main level"); + std::cout << e << std::endl ; + } - // Try to write a color image to a non existing directory - try - { - filename = opath + vpIoTools::path("/directory-that-does-not-exist/Klimt.ppm"); + // Try to write an image to a non existing directory + try { + filename = opath + vpIoTools::path("/directory-that-does-not-exist/Klimt.ppm"); + std::cout << "Write image: " << filename << std::endl; + vpImageIo::write(I, filename) ; + } + catch(vpException e) { + std::cout << "Catch an exception due to a non existing file: " << e << std::endl; + } + + ///////////////////////////////////////////////////////////////////// + // Create a color image + vpImage<vpRGBa> Irgba ; + + // Load a color image from the disk + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); + std::cout << "Read image: " << filename << std::endl; + vpImageIo::read(Irgba, filename); + // Write the content of the color image on the disk + filename = opath + vpIoTools::path("/Klimt_color.ppm"); std::cout << "Write image: " << filename << std::endl; vpImageIo::write(Irgba, filename) ; + + try { + // Try to load a non existing image (test for exceptions) + // Load a non existing color image + filename = ipath + vpIoTools::path("/ViSP-images/image-that-does-not-exist.ppm"); + std::cout << "Read image: " << filename << std::endl; + vpImageIo::read(Irgba, filename) ; + } + catch(vpException e) { + std::cout << "Catch an exception due to a non existing file: " << e << std::endl; + } + + try { + // Try to write a color image to a non existing directory + filename = opath + vpIoTools::path("/directory-that-does-not-exist/Klimt.ppm"); + std::cout << "Write image: " << filename << std::endl; + vpImageIo::write(Irgba, filename) ; + } + catch(vpException e) { + std::cout << "Catch an exception due to a non existing file: " << e << std::endl; + } + return 0; } - catch(vpImageException e) - { - vpERROR_TRACE("at main level"); - std::cout << e << std::endl ; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } } diff --git a/test/image/testReadImage.cpp b/test/image/testReadImage.cpp index 59eb8c4570b0a75f8604745df4e26354e40bbd40..eb1c363e9d05df96a3a3ff88ef6ee4aaaa260dac 100644 --- a/test/image/testReadImage.cpp +++ b/test/image/testReadImage.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testReadImage.cpp 4314 2013-07-16 17:41:21Z fspindle $ + * $Id: testReadImage.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -57,6 +57,8 @@ // List of allowed command line options #define GETOPTARGS "i:p:h" +void usage(const char *name, const char *badparam, std::string ipath, std::string ppath); +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &ppath); /* @@ -112,20 +114,19 @@ OPTIONS: Default\n\ \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 getOptions(int argc, const char **argv, std::string &ipath, std::string &ppath) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { - case 'i': ipath = optarg; break; - case 'p': ppath = optarg; 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; + usage(argv[0], optarg_, ipath, ppath); return false; break; } } @@ -133,7 +134,7 @@ bool getOptions(int argc, const char **argv, // standalone param or error usage(argv[0], NULL, ipath, ppath); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -143,102 +144,100 @@ bool getOptions(int argc, const char **argv, int main(int argc, const char ** argv) { - - std::string env_ipath; - std::string opt_ipath; - std::string opt_ppath; - std::string ipath; - std::string ppath; - std::string filename; - - // 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) == false) { - exit (-1); - } - - // Get the option values - if (!opt_ipath.empty()) - ipath = opt_ipath; - if (!opt_ppath.empty()) - ppath = opt_ppath; - - // 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 <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + try { + std::string env_ipath; + std::string opt_ipath; + std::string opt_ppath; + std::string ipath; + std::string ppath; + std::string filename; + + // 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) == false) { + exit (-1); } - } + // Get the option values + if (!opt_ipath.empty()) + ipath = opt_ipath; + if (!opt_ppath.empty()) + ppath = opt_ppath; + + // 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 <visp image path=" << ipath << "> " + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; + } + } - // - // Here starts really the test - // - ///////////////////////////////////////////////////////////////////// - // Create a grey level image - //vpImage<vpRGBa> I; - vpImage<unsigned char> I; - vpImage<vpRGBa> Irgb; - - try { - if (opt_ppath.empty()) - { - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); - vpImageIo::read(I,filename); - printf("Read ppm ok\n"); - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); - vpImageIo::read(I,filename); - printf("Read pgm ok\n"); - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.jpeg"); - vpImageIo::read(I,filename); - printf("Read jpeg ok\n"); - filename = ipath + vpIoTools::path("/ViSP-images/mire/mire.jpg"); - vpImageIo::read(I,filename); - printf("Read jpg ok\n"); - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.png"); - vpImageIo::read(I,filename); - printf("Read png ok\n"); - - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); - vpImageIo::read(Irgb,filename); - printf("Read ppm ok\n"); - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); - vpImageIo::read(Irgb,filename); - printf("Read pgm ok\n"); - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.jpeg"); - vpImageIo::read(Irgb,filename); - printf("Read jpeg ok\n"); - filename = ipath + vpIoTools::path("/ViSP-images/mire/mire.jpg"); - vpImageIo::read(Irgb,filename); - printf("Read jpg ok\n"); - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.png"); - vpImageIo::read(Irgb,filename); - printf("Read png ok\n"); - } - else - { - filename = opt_ppath; - vpImageIo::read(I,filename); - vpTRACE("image read without problem"); - } + // + // Here starts really the test + // + + ///////////////////////////////////////////////////////////////////// + // Create a grey level image + //vpImage<vpRGBa> I; + vpImage<unsigned char> I; + vpImage<vpRGBa> Irgb; + + if (opt_ppath.empty()) + { + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); + vpImageIo::read(I,filename); + printf("Read ppm ok\n"); + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); + vpImageIo::read(I,filename); + printf("Read pgm ok\n"); + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.jpeg"); + vpImageIo::read(I,filename); + printf("Read jpeg ok\n"); + filename = ipath + vpIoTools::path("/ViSP-images/mire/mire.jpg"); + vpImageIo::read(I,filename); + printf("Read jpg ok\n"); + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.png"); + vpImageIo::read(I,filename); + printf("Read png ok\n"); + + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); + vpImageIo::read(Irgb,filename); + printf("Read ppm ok\n"); + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); + vpImageIo::read(Irgb,filename); + printf("Read pgm ok\n"); + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.jpeg"); + vpImageIo::read(Irgb,filename); + printf("Read jpeg ok\n"); + filename = ipath + vpIoTools::path("/ViSP-images/mire/mire.jpg"); + vpImageIo::read(Irgb,filename); + printf("Read jpg ok\n"); + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.png"); + vpImageIo::read(Irgb,filename); + printf("Read png ok\n"); + } + else + { + filename = opt_ppath; + vpImageIo::read(I,filename); + vpTRACE("image read without problem"); + } } - catch(...) { - std::cout << "Unsupported image format" << std::endl; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; } - return 0; } diff --git a/test/image/testUndistortImage.cpp b/test/image/testUndistortImage.cpp index 6c8001ded1a9ad7a5e91f3fd72f5279d56110f4b..73a12efa84e92cbc29385cb15669aab65973eb14 100644 --- a/test/image/testUndistortImage.cpp +++ b/test/image/testUndistortImage.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testUndistortImage.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: testUndistortImage.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -66,6 +66,9 @@ //#define COLOR #define BW +void usage(const char *name, const char *badparam, std::string ipath, std::string opath, std::string user); +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &opath, std::string user); + /* Print the program options. @@ -125,20 +128,19 @@ OPTIONS: Default\n\ \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) +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &opath, std::string user) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { - case 'i': ipath = optarg; break; - case 'o': opath = optarg; break; + 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; + usage(argv[0], optarg_, ipath, opath, user); return false; break; } } @@ -146,7 +148,7 @@ bool getOptions(int argc, const char **argv, // 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; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -155,130 +157,137 @@ bool getOptions(int argc, const char **argv, 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; - - // 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; - - // Set the default output path -#ifdef UNIX - opt_opath = "/tmp"; -#elif WIN32 - opt_opath = "C:\\temp"; + try { + std::string env_ipath; + std::string opt_ipath; + std::string opt_opath; + std::string ipath; + std::string opath; + std::string filename; + std::string username; + + // 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; + + // Set the default output path +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX + opt_opath = "/tmp"; +#elif defined(_WIN32) + opt_opath = "C:\\temp"; #endif - // Get the user login name - vpIoTools::getUserName(username); - - // Read the command line options - if (getOptions(argc, argv, opt_ipath, opt_opath, username) == false) { - exit (-1); - } + // Get the user login name + vpIoTools::getUserName(username); - // Get the option values - if (!opt_ipath.empty()) - ipath = opt_ipath; - if (!opt_opath.empty()) - opath = opt_opath; + // Read the command line options + if (getOptions(argc, argv, opt_ipath, opt_opath, username) == false) { + exit (-1); + } - // Append to the output path string, the login name of the user - opath += vpIoTools::path("/") + username; + // Get the option values + if (!opt_ipath.empty()) + ipath = opt_ipath; + if (!opt_opath.empty()) + opath = opt_opath; + + // Append to the output path string, the login name of the user + opath += vpIoTools::path("/") + username; + + // Test if the output path exist. If no try to create it + if (vpIoTools::checkDirectory(opath) == false) { + try { + // Create the dirname + vpIoTools::makeDirectory(opath); + } + catch (...) { + usage(argv[0], NULL, ipath, opt_opath, username); + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Cannot create " << opath << std::endl; + std::cerr << " Check your -o " << opt_opath << " option " << std::endl; + exit(-1); + } + } - // Test if the output path exist. If no try to create it - if (vpIoTools::checkDirectory(opath) == false) { - try { - // Create the dirname - vpIoTools::makeDirectory(opath); + // 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()) { + if (ipath != env_ipath) { + std::cout << std::endl + << "WARNING: " << std::endl; + std::cout << " Since -i <visp image path=" << ipath << "> " + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; + } } - catch (...) { + + // Test if an input path is set + if (opt_ipath.empty() && env_ipath.empty()){ usage(argv[0], NULL, ipath, opt_opath, username); std::cerr << std::endl << "ERROR:" << std::endl; - std::cerr << " Cannot create " << opath << std::endl; - std::cerr << " Check your -o " << opt_opath << " option " << std::endl; + std::cerr << " Use -i <visp image path> 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); } - } - - // 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()) { - if (ipath != env_ipath) { - std::cout << std::endl - << "WARNING: " << std::endl; - std::cout << " Since -i <visp image path=" << ipath << "> " - << " 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, opt_opath, username); - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Use -i <visp image path> 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); - } - // - // Here starts really the test - // + // + // Here starts really the test + // #if defined BW - vpImage<unsigned char> I; // Input image - vpImage<unsigned char> U; // undistorted output image + vpImage<unsigned char> I; // Input image + vpImage<unsigned char> U; // undistorted output image #elif defined COLOR - vpImage<vpRGBa> I; // Input image - vpImage<vpRGBa> U; // undistorted output image + vpImage<vpRGBa> I; // Input image + vpImage<vpRGBa> U; // undistorted output image #endif - vpCameraParameters cam; - cam.initPersProjWithDistortion(600,600,192,144,-0.17,0.17); - // Read the input grey image from the disk + vpCameraParameters cam; + cam.initPersProjWithDistortion(600,600,192,144,-0.17,0.17); + // Read the input grey image from the disk #if defined BW - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.pgm"); #elif defined COLOR - filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); + filename = ipath + vpIoTools::path("/ViSP-images/Klimt/Klimt.ppm"); #endif - std::cout << "Read image: " << filename << std::endl; - vpImageIo::read(I, filename) ; + std::cout << "Read image: " << filename << std::endl; + vpImageIo::read(I, filename) ; - std::cout << "Undistortion in process... " << std::endl; - vpImageTools::undistort(I, cam, U); + std::cout << "Undistortion in process... " << std::endl; + vpImageTools::undistort(I, cam, U); - double begintime = vpTime::measureTimeMs(); + double begintime = vpTime::measureTimeMs(); - // For the test, to have a significant time measure we repeat the - // undistortion 100 times - for(unsigned int i=0;i<100;i++) - // Create the undistorted image - vpImageTools::undistort(I, cam, U); + // For the test, to have a significant time measure we repeat the + // undistortion 100 times + for(unsigned int i=0;i<100;i++) + // Create the undistorted image + vpImageTools::undistort(I, cam, U); - double endtime = vpTime::measureTimeMs(); + double endtime = vpTime::measureTimeMs(); - std::cout<<"Time for 100 undistortion (ms): "<< endtime - begintime - << std::endl; + std::cout<<"Time for 100 undistortion (ms): "<< endtime - begintime + << std::endl; - // Write the undistorted image on the disk + // Write the undistorted image on the disk #if defined BW - filename = opath + vpIoTools::path("/Klimt_undistorted.pgm"); + filename = opath + vpIoTools::path("/Klimt_undistorted.pgm"); #elif defined COLOR - filename = opath + vpIoTools::path("/Klimt_undistorted.ppm"); + filename = opath + vpIoTools::path("/Klimt_undistorted.ppm"); #endif - std::cout << "Write undistorted image: " << filename << std::endl; - vpImageIo::write(U, filename) ; + std::cout << "Write undistorted image: " << filename << std::endl; + vpImageIo::write(U, filename) ; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } diff --git a/test/key-point/CMakeLists.txt b/test/key-point/CMakeLists.txt index 8d743b3c452e8c34c2ea953d930722312dd00246..f9921338d1c6b98dab7cf73a4a3d3cb8a7095235 100644 --- a/test/key-point/CMakeLists.txt +++ b/test/key-point/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/test/key-point/testSurfKeyPoint.cpp b/test/key-point/testSurfKeyPoint.cpp index 06d3318375808b50764aa5705a60bd055a61086c..8f3dd418d3eaa86a311cbb59e131b6fdb97effa4 100644 --- a/test/key-point/testSurfKeyPoint.cpp +++ b/test/key-point/testSurfKeyPoint.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testSurfKeyPoint.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: testSurfKeyPoint.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -71,6 +71,10 @@ // List of allowed command line options #define GETOPTARGS "cdi:h" +void usage(const char *name, const char *badparam, std::string ipath); +bool getOptions(int argc, const char **argv, std::string &ipath, + bool &click_allowed, bool &display); + /*! Print the program options. @@ -128,18 +132,18 @@ OPTIONS: Default\n\ bool getOptions(int argc, const char **argv, std::string &ipath, bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; case 'd': display = false; break; - case 'i': ipath = optarg; break; + case 'i': ipath = optarg_; break; case 'h': usage(argv[0], NULL, ipath); return false; break; default: - usage(argv[0], optarg, ipath); + usage(argv[0], optarg_, ipath); return false; break; } } @@ -148,7 +152,7 @@ bool getOptions(int argc, const char **argv, std::string &ipath, // standalone param or error usage(argv[0], NULL, ipath); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -159,114 +163,114 @@ bool getOptions(int argc, const char **argv, std::string &ipath, int main(int argc, const char ** argv) { - std::string env_ipath; - std::string opt_ipath; - std::string ipath; - std::string dirname; - std::string filenameRef; - std::string filenameCur; - bool opt_click_allowed = true; - 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_click_allowed, opt_display) == false) { - exit (-1); - } + try { + std::string env_ipath; + std::string opt_ipath; + std::string ipath; + std::string dirname; + std::string filenameRef; + std::string filenameCur; + bool opt_click_allowed = true; + 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_click_allowed, 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 <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + // 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 <visp image path=" << ipath << "> " + << " 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 <visp image path> 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); - } + // 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 <visp image path> 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); + } - // 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<unsigned char> Iref ; - vpImage<unsigned char> Icur ; + // 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<unsigned char> Iref ; + vpImage<unsigned char> Icur ; - // Set the path location of the image sequence - dirname = ipath + vpIoTools::path("/ViSP-images/cube/"); + // Set the path location of the image sequence + dirname = ipath + vpIoTools::path("/ViSP-images/cube/"); - // Build the name of the image file - filenameRef = dirname + "image.0000.pgm"; - filenameCur = dirname + "image.0079.pgm"; + // Build the name of the image file + filenameRef = dirname + "image.0000.pgm"; + filenameCur = dirname + "image.0079.pgm"; - // 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: " << filenameRef << std::endl; + // 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: " << filenameRef << std::endl; - vpImageIo::read(Iref, filenameRef) ; + vpImageIo::read(Iref, filenameRef) ; - vpCTRACE << "Load: " << filenameCur << std::endl; + vpCTRACE << "Load: " << filenameCur << std::endl; - vpImageIo::read(Icur, filenameCur) ; - } - catch(...) - { - // an exception is throwned if an exception from readPGM has been catched - // 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 " << filenameRef << "or" << filenameCur <<std::endl; - std::cerr << " Check your -i " << ipath << " option " << std::endl - << " or VISP_INPUT_IMAGE_PATH environment variable." - << std::endl; - exit(-1); - } + vpImageIo::read(Icur, filenameCur) ; + } + catch(...) + { + // an exception is throwned if an exception from readPGM has been catched + // 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 " << filenameRef << "or" << filenameCur <<std::endl; + std::cerr << " Check your -i " << ipath << " option " << std::endl + << " or VISP_INPUT_IMAGE_PATH environment variable." + << std::endl; + exit(-1); + } - // We open a window using either X11, GTK or GDI. + // We open a window using either X11, GTK or GDI. #if defined VISP_HAVE_X11 - vpDisplayX display[2]; + vpDisplayX display[2]; #elif defined VISP_HAVE_GTK - vpDisplayGTK display[2]; + vpDisplayGTK display[2]; #elif defined VISP_HAVE_GDI - vpDisplayGDI display[2]; + vpDisplayGDI display[2]; #endif - if (opt_display) { - try{ + if (opt_display) { // Display size is automatically defined by the image (I) size display[0].init(Iref, 100, 100, "Reference image") ; // Display the image @@ -278,99 +282,97 @@ main(int argc, const char ** argv) //Flush the display vpDisplay::flush(Iref) ; } - catch(...) - { - vpERROR_TRACE("Error while displaying the image") ; - exit(-1); - } - } - vpKeyPointSurf surf; - unsigned int nbrRef; + vpKeyPointSurf surf; + unsigned int nbrRef; - if (opt_click_allowed && opt_display) - { - std::cout << "Select a part of the image where the reference points will be computed. This part is a rectangle." << std::endl; - std::cout << "Click first on the top left corner and then on the bottom right corner." << std::endl; - vpImagePoint corners[2]; - for (int i=0 ; i < 2 ; i++) + if (opt_click_allowed && opt_display) { - vpDisplay::getClick(Iref, corners[i]); + std::cout << "Select a part of the image where the reference points will be computed. This part is a rectangle." << std::endl; + std::cout << "Click first on the top left corner and then on the bottom right corner." << std::endl; + vpImagePoint corners[2]; + for (int i=0 ; i < 2 ; i++) + { + vpDisplay::getClick(Iref, corners[i]); + } + + vpDisplay::displayRectangle(Iref, corners[0], corners[1], vpColor::red); + vpDisplay::flush(Iref); + unsigned int height, width; + height = (unsigned int)(corners[1].get_i() - corners[0].get_i()); + width = (unsigned int)(corners[1].get_j() - corners[0].get_j()); + + //Computes the reference points + nbrRef = surf.buildReference(Iref, corners[0], height, width); } - vpDisplay::displayRectangle(Iref, corners[0], corners[1], vpColor::red); - vpDisplay::flush(Iref); - unsigned int height, width; - height = (unsigned int)(corners[1].get_i() - corners[0].get_i()); - width = (unsigned int)(corners[1].get_j() - corners[0].get_j()); - - //Computes the reference points - nbrRef = surf.buildReference(Iref, corners[0], height, width); - } - - else - { - nbrRef = surf.buildReference(Iref); - } + else + { + nbrRef = surf.buildReference(Iref); + } - if(nbrRef < 1) - { - vpTRACE("No reference point"); - exit(-1); - } + if(nbrRef < 1) + { + vpTRACE("No reference point"); + exit(-1); + } - unsigned int nbrPair; - if (opt_display) { - display[1].init(Icur, (int)(100+Iref.getWidth()), 100, "Current image") ; - // display variable. - vpDisplay::display(Icur) ; - //Flush the display - vpDisplay::flush(Icur) ; - } + unsigned int nbrPair; + if (opt_display) { + display[1].init(Icur, (int)(100+Iref.getWidth()), 100, "Current image") ; + // display variable. + vpDisplay::display(Icur) ; + //Flush the display + vpDisplay::flush(Icur) ; + } - if (opt_click_allowed && opt_display) - { - std::cout << "Select a part of the current image where the reference will be search. This part is a rectangle." << std::endl; - std::cout << "Click first on the top left corner and then on the bottom right corner." << std::endl; - vpImagePoint corners[2]; - for (int i=0 ; i < 2 ; i++) + if (opt_click_allowed && opt_display) { - vpDisplay::getClick(Icur, corners[i]); + std::cout << "Select a part of the current image where the reference will be search. This part is a rectangle." << std::endl; + std::cout << "Click first on the top left corner and then on the bottom right corner." << std::endl; + vpImagePoint corners[2]; + for (int i=0 ; i < 2 ; i++) + { + vpDisplay::getClick(Icur, corners[i]); + } + vpDisplay::displayRectangle(Icur, corners[0], corners[1], vpColor::green); + vpDisplay::flush(Icur); + unsigned int height, width; + height = (unsigned int)(corners[1].get_i() - corners[0].get_i()); + width = (unsigned int)(corners[1].get_j() - corners[0].get_j()); + + //Computes the reference points + nbrPair = surf.matchPoint(Icur, corners[0], height, width); } - vpDisplay::displayRectangle(Icur, corners[0], corners[1], vpColor::green); - vpDisplay::flush(Icur); - unsigned int height, width; - height = (unsigned int)(corners[1].get_i() - corners[0].get_i()); - width = (unsigned int)(corners[1].get_j() - corners[0].get_j()); - - //Computes the reference points - nbrPair = surf.matchPoint(Icur, corners[0], height, width); - } - else - { - nbrPair = surf.matchPoint(Icur); - } + else + { + nbrPair = surf.matchPoint(Icur); + } - if(nbrPair < 1) - { - vpTRACE("No point matched"); - } + if(nbrPair < 1) + { + vpTRACE("No point matched"); + } - if (opt_display) - { - surf.display(Iref, Icur, 7); - vpDisplay::flush(Iref) ; - vpDisplay::flush(Icur) ; - if (opt_click_allowed) + if (opt_display) { - std::cout << "A click on the reference image to exit..." << std::endl; - vpDisplay::getClick(Iref); + surf.display(Iref, Icur, 7); + vpDisplay::flush(Iref) ; + vpDisplay::flush(Icur) ; + if (opt_click_allowed) + { + std::cout << "A click on the reference image to exit..." << std::endl; + vpDisplay::getClick(Iref); + } } + return (0); + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return (1); } - - return (0); } #else int diff --git a/test/math/CMakeLists.txt b/test/math/CMakeLists.txt index 506d8e6ba4a5240d6373628a2cfff056a373b3bc..ebd2ddd155743d1b092d8ac7e1895ae3cec7bc84 100644 --- a/test/math/CMakeLists.txt +++ b/test/math/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/test/math/testColvector.cpp b/test/math/testColvector.cpp index 972acefaf364d35bdbfd98bf993ddc89ede0487d..64ccecfcdb3a8a41ba683cb3bec6470629e0c5bb 100644 --- a/test/math/testColvector.cpp +++ b/test/math/testColvector.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testColvector.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testColvector.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -55,6 +55,8 @@ // List of allowed command line options #define GETOPTARGS "h" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); /*! @@ -86,15 +88,15 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -103,7 +105,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -114,24 +116,30 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } - - vpColVector V(4) ; - V = 1.0; + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } - vpTRACE("------------------------"); - vpTRACE("call std::cout << V;"); - std::cout << V << std::endl; + vpColVector V(4) ; + V = 1.0; - vpTRACE("------------------------"); - vpTRACE("call V.normalize();"); - V.normalize(); + vpTRACE("------------------------"); + vpTRACE("call std::cout << V;"); + std::cout << V << std::endl; - vpTRACE("------------------------"); - vpTRACE("call std::cout << V;"); - std::cout << V << std::endl; + vpTRACE("------------------------"); + vpTRACE("call V.normalize();"); + V.normalize(); + vpTRACE("------------------------"); + vpTRACE("call std::cout << V;"); + std::cout << V << std::endl; + return (0); + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return (1); + } } diff --git a/test/math/testKalmanAcceleration.cpp b/test/math/testKalmanAcceleration.cpp index 02afce193a44c541b495500abedd63745806599c..e3ed84c08e2a6a1c1ced0d29989bb3747c76f50c 100644 --- a/test/math/testKalmanAcceleration.cpp +++ b/test/math/testKalmanAcceleration.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testKalmanAcceleration.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testKalmanAcceleration.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -53,64 +53,70 @@ int main() { - unsigned int nsignal = 1; // Number of signal to filter - unsigned int niter = 100; + try { + unsigned int nsignal = 1; // Number of signal to filter + unsigned int niter = 100; - std::string filename = "/tmp/log.dat"; - std::ofstream flog(filename.c_str()); + std::string filename = "/tmp/log.dat"; + std::ofstream flog(filename.c_str()); - vpLinearKalmanFilterInstantiation kalman; + vpLinearKalmanFilterInstantiation kalman; - vpLinearKalmanFilterInstantiation::vpStateModel model; - model = vpLinearKalmanFilterInstantiation::stateConstAccWithColoredNoise_MeasureVel; - kalman.setStateModel(model); + vpLinearKalmanFilterInstantiation::vpStateModel model; + model = vpLinearKalmanFilterInstantiation::stateConstAccWithColoredNoise_MeasureVel; + kalman.setStateModel(model); - unsigned int size_state_vector = kalman.getStateSize()*nsignal; - unsigned int size_measure_vector = kalman.getMeasureSize()*nsignal; + unsigned int size_state_vector = kalman.getStateSize()*nsignal; + unsigned int size_measure_vector = kalman.getMeasureSize()*nsignal; - vpColVector sigma_measure(size_measure_vector); - for (unsigned int signal=0; signal < nsignal; signal ++) - sigma_measure = 0.0001; - vpColVector sigma_state(size_state_vector); - for (unsigned int signal=0; signal < nsignal; signal ++) { - sigma_state[3*signal] = 0.; // not used - sigma_state[3*signal+1] = 0.000001; - sigma_state[3*signal+2] = 0.000001; - } - - vpColVector velocity_measure(size_measure_vector); + vpColVector sigma_measure(size_measure_vector); + for (unsigned int signal=0; signal < nsignal; signal ++) + sigma_measure = 0.0001; + vpColVector sigma_state(size_state_vector); + for (unsigned int signal=0; signal < nsignal; signal ++) { + sigma_state[3*signal] = 0.; // not used + sigma_state[3*signal+1] = 0.000001; + sigma_state[3*signal+2] = 0.000001; + } - double rho = 0.9; // correlation - double dt = 0.2; // sampling period + vpColVector velocity_measure(size_measure_vector); - for (unsigned int signal=0; signal < nsignal; signal ++) - velocity_measure[signal] = 3+2*signal; + double rho = 0.9; // correlation + double dt = 0.2; // sampling period - kalman.verbose(false); - kalman.initFilter(nsignal, sigma_state, sigma_measure, rho, dt); + for (unsigned int signal=0; signal < nsignal; signal ++) + velocity_measure[signal] = 3+2*signal; + kalman.verbose(false); + kalman.initFilter(nsignal, sigma_state, sigma_measure, rho, dt); - for (unsigned int iter=0; iter <= niter; iter++) { - std::cout << "-------- iter " << iter << " ------------" << std::endl; - for (unsigned int signal=0; signal < nsignal; signal ++) { - velocity_measure[signal] = 3+2*signal - + 0.3*sin(vpMath::rad(360./niter*iter)); - } - std::cout << "measure : " << velocity_measure.t() << std::endl; - flog << velocity_measure.t(); + for (unsigned int iter=0; iter <= niter; iter++) { + std::cout << "-------- iter " << iter << " ------------" << std::endl; + for (unsigned int signal=0; signal < nsignal; signal ++) { + velocity_measure[signal] = 3+2*signal + + 0.3*sin(vpMath::rad(360./niter*iter)); + } + std::cout << "measure : " << velocity_measure.t() << std::endl; - // kalman.prediction(); - kalman.filter(velocity_measure); - flog << kalman.Xest.t(); - flog << kalman.Xpre.t(); + flog << velocity_measure.t(); - std::cout << "Xest: " << kalman.Xest.t() << std::endl; - std::cout << "Xpre: " << kalman.Xpre.t() << std::endl; + // kalman.prediction(); + kalman.filter(velocity_measure); + flog << kalman.Xest.t(); + flog << kalman.Xpre.t(); - flog << std::endl; - } + std::cout << "Xest: " << kalman.Xest.t() << std::endl; + std::cout << "Xpre: " << kalman.Xpre.t() << std::endl; + + flog << std::endl; + } - flog.close(); - return 0; + flog.close(); + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 0; + } } diff --git a/test/math/testKalmanVelocity.cpp b/test/math/testKalmanVelocity.cpp index e5f3f7700ab12250d8ab8686a834e5225ad9672d..25f5b7c02a299ce1a6e99a9a8292f03728715ae5 100644 --- a/test/math/testKalmanVelocity.cpp +++ b/test/math/testKalmanVelocity.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testKalmanVelocity.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testKalmanVelocity.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -58,79 +58,85 @@ typedef enum { int main() { - unsigned int nsignal = 2; // Number of signal to filter - unsigned int niter = 200; - unsigned int size_state_vector = 2*nsignal; - unsigned int size_measure_vector = 1*nsignal; - //vpMeasureType measure_t = Velocity; - vpMeasureType measure_t = Position; - - std::string filename = "/tmp/log.dat"; - std::ofstream flog(filename.c_str()); - - vpLinearKalmanFilterInstantiation kalman; + try { + unsigned int nsignal = 2; // Number of signal to filter + unsigned int niter = 200; + unsigned int size_state_vector = 2*nsignal; + unsigned int size_measure_vector = 1*nsignal; + //vpMeasureType measure_t = Velocity; + vpMeasureType measure_t = Position; + + std::string filename = "/tmp/log.dat"; + std::ofstream flog(filename.c_str()); + + vpLinearKalmanFilterInstantiation kalman; + + vpColVector sigma_measure(size_measure_vector); + for (unsigned int signal=0; signal < nsignal; signal ++) + sigma_measure = 0.000001; + vpColVector sigma_state(size_state_vector); + + switch (measure_t) { + case Velocity: + for (unsigned int signal=0; signal < nsignal; signal ++) { + sigma_state[2*signal] = 0.; // not used + sigma_state[2*signal+1] = 0.000001; + } + break; + case Position: + for (unsigned int signal=0; signal < nsignal; signal ++) { + sigma_state[2*signal] = 0.000001; + sigma_state[2*signal+1] = 0; // not used + } + break; + } - vpColVector sigma_measure(size_measure_vector); - for (unsigned int signal=0; signal < nsignal; signal ++) - sigma_measure = 0.000001; - vpColVector sigma_state(size_state_vector); + vpColVector measure(size_measure_vector); - switch (measure_t) { - case Velocity: for (unsigned int signal=0; signal < nsignal; signal ++) { - sigma_state[2*signal] = 0.; // not used - sigma_state[2*signal+1] = 0.000001; + measure[signal] = 3+2*signal; } - break; - case Position: - for (unsigned int signal=0; signal < nsignal; signal ++) { - sigma_state[2*signal] = 0.000001; - sigma_state[2*signal+1] = 0; // not used - } - break; - } - - vpColVector measure(size_measure_vector); - for (unsigned int signal=0; signal < nsignal; signal ++) { - measure[signal] = 3+2*signal; - } + kalman.verbose(true); + + vpLinearKalmanFilterInstantiation::vpStateModel model; + double dt = 0.04; // Sampling period + double rho = 0.5; + double dummy = 0; // non used parameter + switch (measure_t) { + case Velocity: + model = vpLinearKalmanFilterInstantiation::stateConstVelWithColoredNoise_MeasureVel; + kalman.setStateModel(model); + kalman.initFilter(nsignal, sigma_state, sigma_measure, rho, dummy); + break; + case Position: + model = vpLinearKalmanFilterInstantiation::stateConstVel_MeasurePos; + kalman.setStateModel(model); + kalman.initFilter(nsignal, sigma_state, sigma_measure, dummy, dt); + break; + } - kalman.verbose(true); - - vpLinearKalmanFilterInstantiation::vpStateModel model; - double dt = 0.04; // Sampling period - double rho = 0.5; - double dummy = 0; // non used parameter - switch (measure_t) { - case Velocity: - model = vpLinearKalmanFilterInstantiation::stateConstVelWithColoredNoise_MeasureVel; - kalman.setStateModel(model); - kalman.initFilter(nsignal, sigma_state, sigma_measure, rho, dummy); - break; - case Position: - model = vpLinearKalmanFilterInstantiation::stateConstVel_MeasurePos; - kalman.setStateModel(model); - kalman.initFilter(nsignal, sigma_state, sigma_measure, dummy, dt); - break; - } + for (unsigned int iter=0; iter <= niter; iter++) { + std::cout << "-------- iter " << iter << " ------------" << std::endl; + for (unsigned int signal=0; signal < nsignal; signal ++) { + measure[signal] = 3+2*signal + 0.3*sin(vpMath::rad(360./niter*iter)); + } + std::cout << "measure : " << measure.t() << std::endl; - for (unsigned int iter=0; iter <= niter; iter++) { - std::cout << "-------- iter " << iter << " ------------" << std::endl; - for (unsigned int signal=0; signal < nsignal; signal ++) { - measure[signal] = 3+2*signal + 0.3*sin(vpMath::rad(360./niter*iter)); - } - std::cout << "measure : " << measure.t() << std::endl; + flog << measure.t(); - flog << measure.t(); + // kalman.prediction(); + kalman.filter(measure); + flog << kalman.Xest.t() << std::endl; - // kalman.prediction(); - kalman.filter(measure); - flog << kalman.Xest.t() << std::endl; + std::cout << "Xest: " << kalman.Xest.t() << std::endl; + } - std::cout << "Xest: " << kalman.Xest.t() << std::endl; + flog.close(); + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - - flog.close(); - return 0; } diff --git a/test/math/testMatrix.cpp b/test/math/testMatrix.cpp index e3c392afeafba6b149a1120947a8931eb17d5917..619a2936ca28c21e21ca7d4223f142f6cd9bca15 100644 --- a/test/math/testMatrix.cpp +++ b/test/math/testMatrix.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testMatrix.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testMatrix.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -60,6 +60,9 @@ // List of allowed command line options #define GETOPTARGS "h" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); + /*! Print the program options. @@ -90,15 +93,15 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -107,7 +110,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -118,137 +121,143 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } - - vpTRACE("------------------------"); - vpTRACE("--- TEST PRETTY PRINT---"); - vpTRACE("------------------------"); - vpMatrix M ; - M.eye(4); - - vpTRACE("call std::cout << M;"); - std::cout << M << std::endl; - - vpTRACE("call M.print (std::cout, 4);"); - M.print (std::cout, 4); - - vpTRACE("------------------------"); - M.resize(3,3) ; - M.eye(3); - M[1][0]=1.235; - M[1][1]=12.345; - M[1][2]=.12345; - vpTRACE("call std::cout << M;"); - std::cout << M; - vpTRACE("call M.print (std::cout, 6);"); - M.print (std::cout, 6); - - vpTRACE("------------------------"); - M[0][0]=-1.235; - M[1][0]=-12.235; - - vpTRACE("call std::cout << M;"); - std::cout << M; - - vpTRACE("call M.print (std::cout, 10);"); - M.print (std::cout, 10); - - vpTRACE("call M.print (std::cout, 2);"); - M.print (std::cout, 2); - - vpTRACE("------------------------"); - M.resize(3,3) ; - M.eye(3); - M[0][2]=-0.0000000876; - vpTRACE("call std::cout << M;"); - std::cout << M; - - vpTRACE("call M.print (std::cout, 4);"); - M.print (std::cout, 4); - vpTRACE("call M.print (std::cout, 10, \"M\");"); - M.print (std::cout, 10, "M"); - vpTRACE("call M.print (std::cout, 20, \"M\");"); - M.print (std::cout, 20, "M"); - - - vpTRACE("------------------------"); - vpTRACE("--- TEST RESIZE --------"); - vpTRACE("------------------------"); - vpCTRACE << "5x5" << std::endl; - M.resize(5,5,false); - vpCTRACE << std::endl<< M; - vpCTRACE << "3x2" << std::endl; - M.resize(3,2,false); - vpCTRACE <<std::endl<< M; - vpCTRACE << "2x2" << std::endl; - M.resize(2,2,false); - vpCTRACE << std::endl<<M; - vpTRACE("------------------------"); - - - vpVelocityTwistMatrix vMe; - vpMatrix A(1,6),B; - - A=1.0; - //vMe=1.0; - B=A*vMe; - - vpTRACE("------------------------"); - vpTRACE("--- TEST vpRowVector * vpColVector"); - vpTRACE("------------------------"); - vpRowVector r(3); - r[0] = 2; - r[1] = 3; - r[2] = 4; - - vpColVector c(3); - c[0] = 1; - c[1] = 2; - c[2] = -1; - - double rc = r * c; - - r.print(std::cout, 2, "r"); - c.print(std::cout, 2, "c"); - std::cout << "r * c = " << rc << std::endl; - - vpTRACE("------------------------"); - vpTRACE("--- TEST vpRowVector * vpMatrix"); - vpTRACE("------------------------"); - M.resize(3,3) ; - M.eye(3); - - M[1][0] = 1.5; - M[2][0] = 2.3; - - vpRowVector rM = r * M; - - r.print(std::cout, 2, "r"); - M.print(std::cout, 10, "M"); - std::cout << "r * M = " << rM << std::endl; - - vpTRACE("------------------------"); - vpTRACE("--- TEST vpGEMM "); - vpTRACE("------------------------"); - M.resize(3,3) ; - M.eye(3); - vpMatrix N(3, 3); - N[0][0] = 2; - N[1][0] = 1.2; - N[1][2] = 0.6; - N[2][2] = 0.25; - - vpMatrix C(3, 3); - C.eye(3); - - vpMatrix D; - - //realise the operation D = 2 * M^T * N + 3 C - vpGEMM(M, N, 2, C, 3, D, VP_GEMM_A_T); - std::cout << D << std::endl; + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } + vpTRACE("------------------------"); + vpTRACE("--- TEST PRETTY PRINT---"); + vpTRACE("------------------------"); + vpMatrix M ; + M.eye(4); + + vpTRACE("call std::cout << M;"); + std::cout << M << std::endl; + + vpTRACE("call M.print (std::cout, 4);"); + M.print (std::cout, 4); + + vpTRACE("------------------------"); + M.resize(3,3) ; + M.eye(3); + M[1][0]=1.235; + M[1][1]=12.345; + M[1][2]=.12345; + vpTRACE("call std::cout << M;"); + std::cout << M; + vpTRACE("call M.print (std::cout, 6);"); + M.print (std::cout, 6); + + vpTRACE("------------------------"); + M[0][0]=-1.235; + M[1][0]=-12.235; + + vpTRACE("call std::cout << M;"); + std::cout << M; + + vpTRACE("call M.print (std::cout, 10);"); + M.print (std::cout, 10); + + vpTRACE("call M.print (std::cout, 2);"); + M.print (std::cout, 2); + + vpTRACE("------------------------"); + M.resize(3,3) ; + M.eye(3); + M[0][2]=-0.0000000876; + vpTRACE("call std::cout << M;"); + std::cout << M; + + vpTRACE("call M.print (std::cout, 4);"); + M.print (std::cout, 4); + vpTRACE("call M.print (std::cout, 10, \"M\");"); + M.print (std::cout, 10, "M"); + vpTRACE("call M.print (std::cout, 20, \"M\");"); + M.print (std::cout, 20, "M"); + + + vpTRACE("------------------------"); + vpTRACE("--- TEST RESIZE --------"); + vpTRACE("------------------------"); + vpCTRACE << "5x5" << std::endl; + M.resize(5,5,false); + vpCTRACE << std::endl<< M; + vpCTRACE << "3x2" << std::endl; + M.resize(3,2,false); + vpCTRACE <<std::endl<< M; + vpCTRACE << "2x2" << std::endl; + M.resize(2,2,false); + vpCTRACE << std::endl<<M; + vpTRACE("------------------------"); + + + vpVelocityTwistMatrix vMe; + vpMatrix A(1,6),B; + + A=1.0; + //vMe=1.0; + B=A*vMe; + + vpTRACE("------------------------"); + vpTRACE("--- TEST vpRowVector * vpColVector"); + vpTRACE("------------------------"); + vpRowVector r(3); + r[0] = 2; + r[1] = 3; + r[2] = 4; + + vpColVector c(3); + c[0] = 1; + c[1] = 2; + c[2] = -1; + + double rc = r * c; + + r.print(std::cout, 2, "r"); + c.print(std::cout, 2, "c"); + std::cout << "r * c = " << rc << std::endl; + + vpTRACE("------------------------"); + vpTRACE("--- TEST vpRowVector * vpMatrix"); + vpTRACE("------------------------"); + M.resize(3,3) ; + M.eye(3); + + M[1][0] = 1.5; + M[2][0] = 2.3; + + vpRowVector rM = r * M; + + r.print(std::cout, 2, "r"); + M.print(std::cout, 10, "M"); + std::cout << "r * M = " << rM << std::endl; + + vpTRACE("------------------------"); + vpTRACE("--- TEST vpGEMM "); + vpTRACE("------------------------"); + M.resize(3,3) ; + M.eye(3); + vpMatrix N(3, 3); + N[0][0] = 2; + N[1][0] = 1.2; + N[1][2] = 0.6; + N[2][2] = 0.25; + + vpMatrix C(3, 3); + C.eye(3); + + vpMatrix D; + + //realise the operation D = 2 * M^T * N + 3 C + vpGEMM(M, N, 2, C, 3, D, VP_GEMM_A_T); + std::cout << D << std::endl; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } diff --git a/test/math/testMatrixException.cpp b/test/math/testMatrixException.cpp index fb81e5b277a8f7baf4f6c2c97b1f62753046cb20..d9b8b88db1011e606bdcd88362a12fd7cf74c5e4 100644 --- a/test/math/testMatrixException.cpp +++ b/test/math/testMatrixException.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testMatrixException.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testMatrixException.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -58,6 +58,9 @@ // List of allowed command line options #define GETOPTARGS "h" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); + /*! Print the program options. @@ -88,15 +91,15 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -105,7 +108,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -116,39 +119,42 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } - vpMatrix M ; - vpMatrix M1(2,3) ; - vpMatrix M2(3,3) ; - vpMatrix M3(2,2) ; + vpMatrix M ; + vpMatrix M1(2,3) ; + vpMatrix M2(3,3) ; + vpMatrix M3(2,2) ; - vpTRACE("test matrix size in multiply") ; + vpTRACE("test matrix size in multiply") ; - try - { - M = M1*M3 ; - } - catch (vpMatrixException me) - { - vpCTRACE ; - std::cout << me << std::endl ; - } + try + { + M = M1*M3 ; + } + catch (vpMatrixException me) + { + std::cout << me << std::endl ; + } - vpTRACE("test matrix size in addition") ; + vpTRACE("test matrix size in addition") ; - try - { - M = M1+M3 ; + try + { + M = M1+M3 ; + } + catch (vpMatrixException me) + { + std::cout << me << std::endl ; + } } - catch (vpMatrixException me) - { - vpCTRACE ; - std::cout << me << std::endl ; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - } diff --git a/test/math/testMatrixInverse.cpp b/test/math/testMatrixInverse.cpp index 708025a9f1eb8f64c8e6c8e14acef96859e581d0..6051083539767d48694fc0925a16d1fa18832944 100644 --- a/test/math/testMatrixInverse.cpp +++ b/test/math/testMatrixInverse.cpp @@ -3,7 +3,7 @@ * $Id: testSvd.cpp 3857 2012-07-25 11:47:30Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -61,6 +61,14 @@ // List of allowed command line options #define GETOPTARGS "n:i:pf:r:c:vh" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv, + unsigned int& nb_matrices, unsigned int& nb_iterations, + bool& use_plot_file, std::string& plotfile, + unsigned int& nbrows, unsigned int& nbcols, bool& verbose); +void writeTime(const char *name, double time); +vpMatrix makeRandomMatrix(unsigned int nbrows, unsigned int nbcols); + /*! Print the program options. @@ -129,36 +137,36 @@ bool getOptions(int argc, const char **argv, bool& use_plot_file, std::string& plotfile, unsigned int& nbrows, unsigned int& nbcols, bool& verbose) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'h': usage(argv[0], NULL); return false; break; case 'n': - nb_matrices = (unsigned int)atoi(optarg); + nb_matrices = (unsigned int)atoi(optarg_); break; case 'i': - nb_iterations = (unsigned int)atoi(optarg); + nb_iterations = (unsigned int)atoi(optarg_); break; case 'f': - plotfile = optarg; + plotfile = optarg_; use_plot_file = true; break; case 'p': use_plot_file = true; break; case 'r': - nbrows = (unsigned int)atoi(optarg); + nbrows = (unsigned int)atoi(optarg_); break; case 'c': - nbcols = (unsigned int)atoi(optarg); + nbcols = (unsigned int)atoi(optarg_); break; case 'v': verbose = true; break; default: - usage(argv[0], optarg); + usage(argv[0], optarg_); return false; break; } } @@ -167,20 +175,20 @@ bool getOptions(int argc, const char **argv, // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } return true; } -void writeTime(const char *name, double time){ +void writeTime(const char *name, double time) +{ std::cout << name << " time=" << time << " ms." << std::endl; } - - -vpMatrix makeRandomMatrix(unsigned int nbrows, unsigned int nbcols){ +vpMatrix makeRandomMatrix(unsigned int nbrows, unsigned int nbcols) +{ vpMatrix A; A.resize(nbrows,nbcols); @@ -195,113 +203,121 @@ int main(int argc, const char ** argv) { #ifdef VISP_HAVE_LAPACK - unsigned int nb_matrices=1000; - unsigned int nb_iterations=10; - unsigned int nb_rows = 6; - unsigned int nb_cols = 6; - bool verbose = false; - std::string plotfile("plot.txt"); - bool use_plot_file=false; - std::ofstream of; - - double t, qr_time, lu_time,pi_time,chol_time; - // Read the command line options - if (getOptions(argc, argv, nb_matrices,nb_iterations,use_plot_file,plotfile,nb_rows,nb_cols,verbose) == false) { - exit (-1); - } - - if(use_plot_file){ - of.open(plotfile.c_str()); - } - - for(unsigned int iter=0;iter<nb_iterations;iter++){ - std::vector<vpMatrix> benchQR; - std::vector<vpMatrix> benchLU; - std::vector<vpMatrix> benchCholesky; - std::vector<vpMatrix> benchPseudoInverse; - if(verbose) - std::cout << "********* generating matrices for iteration " << iter << "." << std::endl; - for(unsigned int i=0;i<nb_matrices;i++){ - vpMatrix cur; - double det=0.; - //don't put singular matrices in the benchmark - for(cur=makeRandomMatrix(nb_rows,nb_cols);std::abs(det=cur.AtA().det())<.01;cur = makeRandomMatrix(nb_rows,nb_cols)) - if(verbose){ - std::cout << "Generated random matrix A*tA=" << std::endl << cur.AtA() << std::endl; - std::cout << "generated random matrix not invertibleL: det="<<det<< ". Retrying..." << std::endl; - } - benchCholesky.push_back(cur); - benchQR.push_back(cur); - benchLU.push_back(cur); - benchPseudoInverse.push_back(cur); + try { + unsigned int nb_matrices=1000; + unsigned int nb_iterations=10; + unsigned int nb_rows = 6; + unsigned int nb_cols = 6; + bool verbose = false; + std::string plotfile("plot.txt"); + bool use_plot_file=false; + std::ofstream of; + + double t, qr_time, lu_time,pi_time,chol_time; + // Read the command line options + if (getOptions(argc, argv, nb_matrices,nb_iterations,use_plot_file,plotfile,nb_rows,nb_cols,verbose) == false) { + exit (-1); } - if(verbose) - std::cout << "\t Inverting " << benchCholesky[0].AtA().getRows() << "x" << benchCholesky[0].AtA().getCols() << " matrix using cholesky decomposition." << std::endl; - t = vpTime::measureTimeMs() ; - for(unsigned int i=0;i<nb_matrices;i++){ - benchCholesky[i]=benchCholesky[i].AtA().inverseByCholesky()*benchCholesky[i].transpose(); - } - chol_time = vpTime::measureTimeMs() - t ; - - if(verbose) - std::cout << "\t Inverting " << benchLU[0].AtA().getRows() << "x" << benchLU[0].AtA().getCols() << " matrix using LU decomposition." << std::endl; - t = vpTime::measureTimeMs() ; - for(unsigned int i=0;i<nb_matrices;i++) - benchLU[i] = benchLU[i].AtA().inverseByLU()*benchLU[i].transpose(); - lu_time = vpTime::measureTimeMs() -t ; - - if(verbose) - std::cout << "\t Inverting " << benchQR[0].AtA().getRows() << "x" << benchQR[0].AtA().getCols() << " matrix using QR decomposition." << std::endl; - t = vpTime::measureTimeMs() ; - for(unsigned int i=0;i<nb_matrices;i++){ - benchQR[i]=benchQR[i].AtA().inverseByQR()*benchQR[i].transpose(); - } - qr_time = vpTime::measureTimeMs() - t ; - - if(verbose) - std::cout << "\t Inverting " << benchPseudoInverse[0].AtA().getRows() << "x" << benchPseudoInverse[0].AtA().getCols() << " matrix while computing pseudo-inverse." << std::endl; - t = vpTime::measureTimeMs() ; - for(unsigned int i=0;i<nb_matrices;i++){ - benchPseudoInverse[i]=benchPseudoInverse[i].pseudoInverse(); - } - pi_time = vpTime::measureTimeMs() - t ; - - double avg_err_lu_qr=0.; - double avg_err_lu_pi=0.; - double avg_err_lu_chol=0.; - double avg_err_qr_pi=0.; - double avg_err_qr_chol=0.; - double avg_err_pi_chol=0.; - - for(unsigned int i=0;i<nb_matrices;i++){ - avg_err_lu_qr+= (benchQR[i]-benchLU[i]).euclideanNorm(); - avg_err_lu_pi+= (benchPseudoInverse[i]-benchLU[i]).euclideanNorm(); - avg_err_qr_pi+= (benchPseudoInverse[i]-benchQR[i]).euclideanNorm(); - avg_err_qr_chol+= (benchCholesky[i]-benchQR[i]).euclideanNorm(); - avg_err_lu_chol+= (benchCholesky[i]-benchLU[i]).euclideanNorm(); - avg_err_pi_chol+= (benchCholesky[i]-benchPseudoInverse[i]).euclideanNorm(); - } - - avg_err_lu_qr/=nb_matrices; - avg_err_lu_pi/=nb_matrices; - avg_err_qr_pi/=nb_matrices; - if(use_plot_file){ - of << iter << "\t" << lu_time << "\t" << qr_time << "\t" << pi_time << "\t" << chol_time << "\t" << avg_err_lu_qr << "\t" << avg_err_qr_pi << "\t" << avg_err_lu_pi << "\t" << avg_err_qr_chol << "\t" << avg_err_lu_chol << "\t" << avg_err_pi_chol << std::endl; + of.open(plotfile.c_str()); } - if(verbose || !use_plot_file){ - writeTime("LU",lu_time); - writeTime("QR",qr_time); - writeTime("Pseudo-inverse",pi_time); - writeTime("Cholesky",chol_time); + + for(unsigned int iter=0;iter<nb_iterations;iter++){ + std::vector<vpMatrix> benchQR; + std::vector<vpMatrix> benchLU; + std::vector<vpMatrix> benchCholesky; + std::vector<vpMatrix> benchPseudoInverse; + if(verbose) + std::cout << "********* generating matrices for iteration " << iter << "." << std::endl; + for(unsigned int i=0;i<nb_matrices;i++){ + vpMatrix cur; + double det=0.; + //don't put singular matrices in the benchmark + for(cur=makeRandomMatrix(nb_rows,nb_cols);std::abs(det=cur.AtA().det())<.01;cur = makeRandomMatrix(nb_rows,nb_cols)) + if(verbose){ + std::cout << "Generated random matrix A*tA=" << std::endl << cur.AtA() << std::endl; + std::cout << "generated random matrix not invertibleL: det="<<det<< ". Retrying..." << std::endl; + } + benchCholesky.push_back(cur); + benchQR.push_back(cur); + benchLU.push_back(cur); + benchPseudoInverse.push_back(cur); + } + + if(verbose) + std::cout << "\t Inverting " << benchCholesky[0].AtA().getRows() << "x" << benchCholesky[0].AtA().getCols() << " matrix using cholesky decomposition." << std::endl; + t = vpTime::measureTimeMs() ; + for(unsigned int i=0;i<nb_matrices;i++){ + benchCholesky[i]=benchCholesky[i].AtA().inverseByCholesky()*benchCholesky[i].transpose(); + } + chol_time = vpTime::measureTimeMs() - t ; + + if(verbose) + std::cout << "\t Inverting " << benchLU[0].AtA().getRows() << "x" << benchLU[0].AtA().getCols() << " matrix using LU decomposition." << std::endl; + t = vpTime::measureTimeMs() ; + for(unsigned int i=0;i<nb_matrices;i++) + benchLU[i] = benchLU[i].AtA().inverseByLU()*benchLU[i].transpose(); + lu_time = vpTime::measureTimeMs() -t ; + + if(verbose) + std::cout << "\t Inverting " << benchQR[0].AtA().getRows() << "x" << benchQR[0].AtA().getCols() << " matrix using QR decomposition." << std::endl; + t = vpTime::measureTimeMs() ; + for(unsigned int i=0;i<nb_matrices;i++){ + benchQR[i]=benchQR[i].AtA().inverseByQR()*benchQR[i].transpose(); + } + qr_time = vpTime::measureTimeMs() - t ; + + if(verbose) + std::cout << "\t Inverting " << benchPseudoInverse[0].AtA().getRows() << "x" << benchPseudoInverse[0].AtA().getCols() << " matrix while computing pseudo-inverse." << std::endl; + t = vpTime::measureTimeMs() ; + for(unsigned int i=0;i<nb_matrices;i++){ + benchPseudoInverse[i]=benchPseudoInverse[i].pseudoInverse(); + } + pi_time = vpTime::measureTimeMs() - t ; + + double avg_err_lu_qr=0.; + double avg_err_lu_pi=0.; + double avg_err_lu_chol=0.; + double avg_err_qr_pi=0.; + double avg_err_qr_chol=0.; + double avg_err_pi_chol=0.; + + for(unsigned int i=0;i<nb_matrices;i++){ + avg_err_lu_qr+= (benchQR[i]-benchLU[i]).euclideanNorm(); + avg_err_lu_pi+= (benchPseudoInverse[i]-benchLU[i]).euclideanNorm(); + avg_err_qr_pi+= (benchPseudoInverse[i]-benchQR[i]).euclideanNorm(); + avg_err_qr_chol+= (benchCholesky[i]-benchQR[i]).euclideanNorm(); + avg_err_lu_chol+= (benchCholesky[i]-benchLU[i]).euclideanNorm(); + avg_err_pi_chol+= (benchCholesky[i]-benchPseudoInverse[i]).euclideanNorm(); + } + + avg_err_lu_qr/=nb_matrices; + avg_err_lu_pi/=nb_matrices; + avg_err_qr_pi/=nb_matrices; + + if(use_plot_file){ + of << iter << "\t" << lu_time << "\t" << qr_time << "\t" << pi_time << "\t" << chol_time << "\t" << avg_err_lu_qr << "\t" << avg_err_qr_pi << "\t" << avg_err_lu_pi << "\t" << avg_err_qr_chol << "\t" << avg_err_lu_chol << "\t" << avg_err_pi_chol << std::endl; + } + if(verbose || !use_plot_file){ + writeTime("LU",lu_time); + writeTime("QR",qr_time); + writeTime("Pseudo-inverse",pi_time); + writeTime("Cholesky",chol_time); + } } + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } + #else (void)argc; (void)argv; std::cout << "You don't have lapack installed" << std::endl; -#endif return 0; +#endif } diff --git a/test/math/testRobust.cpp b/test/math/testRobust.cpp index 6c3370f971c973f8f8a72e0affc15e8af43c8bf3..5bf3cd4d90a5c86e702f66d16200439883324579 100644 --- a/test/math/testRobust.cpp +++ b/test/math/testRobust.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testRobust.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testRobust.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -57,6 +57,9 @@ // List of allowed command line options #define GETOPTARGS "ho:" +void usage(const char *name, const char *badparam, std::string ofilename); +bool getOptions(int argc, const char **argv, std::string &ofilename); + /*! Print the program options. @@ -107,16 +110,16 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv, std::string &ofilename) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { - case 'o': ofilename = optarg; break; + case 'o': ofilename = optarg_; break; case 'h': usage(argv[0], NULL, ofilename); return false; break; default: - usage(argv[0], optarg, ofilename); + usage(argv[0], optarg_, ofilename); return false; break; } } @@ -125,7 +128,7 @@ bool getOptions(int argc, const char **argv, std::string &ofilename) // standalone param or error usage(argv[0], NULL, ofilename); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -137,74 +140,81 @@ bool getOptions(int argc, const char **argv, std::string &ofilename) int main(int argc, const char ** argv) { - std::string ofilename; - std::string username; + try { + std::string ofilename; + std::string username; - // Set the default output filename -#ifdef WIN32 - ofilename = "C:/temp"; + // Set the default output filename +#if defined(_WIN32) + ofilename = "C:/temp"; #else - ofilename = "/tmp"; + ofilename = "/tmp"; #endif - // Get the user login name - vpIoTools::getUserName(username); + // Get the user login name + vpIoTools::getUserName(username); + + // Append to the output filename string, the login name of the user + ofilename = ofilename + "/" + username; + + // Test if the output path exist. If no try to create it + if (vpIoTools::checkDirectory(ofilename) == false) { + try { + // Create the dirname + vpIoTools::makeDirectory(ofilename); + } + catch (...) { + usage(argv[0], NULL, ofilename); + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Cannot create " << ofilename << std::endl; + std::cerr << " Check your -o " << ofilename << " option " << std::endl; + exit(-1); + } + } - // Append to the output filename string, the login name of the user - ofilename = ofilename + "/" + username; + // Append to the output filename string, the name of the file + ofilename = ofilename + "/w.dat"; - // Test if the output path exist. If no try to create it - if (vpIoTools::checkDirectory(ofilename) == false) { - try { - // Create the dirname - vpIoTools::makeDirectory(ofilename); + // Read the command line options + if (getOptions(argc, argv, ofilename) == false) { + exit (-1); } - catch (...) { + + double sig = 1 ; + + double w ; + std::ofstream f; + std::cout << "Create file: " << ofilename << std::endl; + f.open(ofilename.c_str()); + if (f.fail()) { usage(argv[0], NULL, ofilename); std::cerr << std::endl << "ERROR:" << std::endl; - std::cerr << " Cannot create " << ofilename << std::endl; + std::cerr << " Cannot create the file: " << ofilename << std::endl; std::cerr << " Check your -o " << ofilename << " option " << std::endl; exit(-1); - } - } - // Append to the output filename string, the name of the file - ofilename = ofilename + "/w.dat"; - - // Read the command line options - if (getOptions(argc, argv, ofilename) == false) { - exit (-1); - } - - double sig = 1 ; - - double w ; - std::ofstream f; - std::cout << "Create file: " << ofilename << std::endl; - f.open(ofilename.c_str()); - if (f == NULL) { - usage(argv[0], NULL, ofilename); - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Cannot create the file: " << ofilename << std::endl; - std::cerr << " Check your -o " << ofilename << " option " << std::endl; - exit(-1); - - } - double x = -10 ; - while (x<10) - { - if (fabs(x/sig)<=(4.6851)) - { - w = vpMath::sqr(1-vpMath::sqr(x/(sig*4.6851))); } - else + double x = -10 ; + while (x<10) { - w = 0; + if (fabs(x/sig)<=(4.6851)) + { + w = vpMath::sqr(1-vpMath::sqr(x/(sig*4.6851))); + } + else + { + w = 0; + } + f << x <<" "<<w <<std::endl ; + x+= 0.01 ; } - f << x <<" "<<w <<std::endl ; - x+= 0.01 ; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } } diff --git a/test/math/testRotation.cpp b/test/math/testRotation.cpp index 9dec934feabe7030f585ae8ecdbc1c6d73c3e078..d87369fda53c734f2b66afff9176f1e5f4d31a4e 100644 --- a/test/math/testRotation.cpp +++ b/test/math/testRotation.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testRotation.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testRotation.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -59,6 +59,9 @@ // List of allowed command line options #define GETOPTARGS "h" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); + /*! Print the program options. @@ -89,15 +92,15 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -106,7 +109,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -117,90 +120,97 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } - vpRotationMatrix R; - for(int i=-10;i<10;i++){ - for(int j=-10;j<10;j++){ - vpThetaUVector tu(vpMath::rad(90+i), vpMath::rad(170+j), vpMath::rad(45)) ; - tu.buildFrom(vpRotationMatrix(tu)); //put some coherence into rotation convention - - std::cout << "Initialization " <<std::endl ; - - double theta; - vpColVector u; - tu.extract(theta, u); - - std::cout << "theta=" << vpMath::deg(theta) << std::endl ; - std::cout << "u=" << u << std::endl ; - - std::cout << "From vpThetaUVector to vpRotationMatrix " << std::endl ; - R.buildFrom(tu) ; - - std::cout << "Matrix R" ; - if (R.isARotationMatrix()==1) std::cout <<" is a rotation matrix " << std::endl ; - else std::cout <<" is not a rotation matrix " << std::endl ; + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } + vpRotationMatrix R; + for(int i=-10;i<10;i++){ + for(int j=-10;j<10;j++){ + vpThetaUVector tu(vpMath::rad(90+i), vpMath::rad(170+j), vpMath::rad(45)) ; + tu.buildFrom(vpRotationMatrix(tu)); //put some coherence into rotation convention - std::cout << R << std::endl ; + std::cout << "Initialization " <<std::endl ; + + double theta; + vpColVector u; + tu.extract(theta, u); + + std::cout << "theta=" << vpMath::deg(theta) << std::endl ; + std::cout << "u=" << u << std::endl ; + + std::cout << "From vpThetaUVector to vpRotationMatrix " << std::endl ; + R.buildFrom(tu) ; + + std::cout << "Matrix R" ; + if (R.isARotationMatrix()==1) std::cout <<" is a rotation matrix " << std::endl ; + else std::cout <<" is not a rotation matrix " << std::endl ; + + std::cout << R << std::endl ; + + std::cout << "From vpRotationMatrix to vpQuaternionVector " << std::endl ; + vpQuaternionVector q(R); + std::cout << q <<std::endl ; + + R.buildFrom(q); + std::cout << "From vpQuaternionVector to vpRotationMatrix " << std::endl ; + + std::cout << "From vpRotationMatrix to vpRxyzVector " << std::endl ; + vpRxyzVector RxyzBuildFromR(R) ; + std::cout << RxyzBuildFromR <<std::endl ; - std::cout << "From vpRotationMatrix to vpQuaternionVector " << std::endl ; - vpQuaternionVector q(R); - std::cout << q <<std::endl ; - - R.buildFrom(q); - std::cout << "From vpQuaternionVector to vpRotationMatrix " << std::endl ; - - std::cout << "From vpRotationMatrix to vpRxyzVector " << std::endl ; - vpRxyzVector RxyzBuildFromR(R) ; - std::cout << RxyzBuildFromR <<std::endl ; - - - std::cout << "From vpRxyzVector to vpThetaUVector " << std::endl ; - std::cout << " use From vpRxyzVector to vpRotationMatrix " << std::endl ; - std::cout << " use From vpRotationMatrix to vpThetaUVector " << std::endl ; - - - vpThetaUVector tuBuildFromEu ; - tuBuildFromEu.buildFrom(R) ; - - std::cout << std::endl ; - std::cout << "result : should equivalent to the first one " << std::endl ; - - - double theta2; - vpColVector u2; - - tuBuildFromEu.extract(theta2, u2); - std::cout << "theta=" << vpMath::deg(theta2) << std::endl ; - std::cout << "u=" << u2 << std::endl ; - - assert(vpMath::abs(theta2-theta)<std::numeric_limits<double>::epsilon()*1e10); - assert(vpMath::abs(u[0]-u2[0])<std::numeric_limits<double>::epsilon()*1e10); - assert(vpMath::abs(u[1]-u2[1])<std::numeric_limits<double>::epsilon()*1e10); - assert(vpMath::abs(u[2]-u2[2])<std::numeric_limits<double>::epsilon()*1e10); + + std::cout << "From vpRxyzVector to vpThetaUVector " << std::endl ; + std::cout << " use From vpRxyzVector to vpRotationMatrix " << std::endl ; + std::cout << " use From vpRotationMatrix to vpThetaUVector " << std::endl ; + + + vpThetaUVector tuBuildFromEu ; + tuBuildFromEu.buildFrom(R) ; + + std::cout << std::endl ; + std::cout << "result : should equivalent to the first one " << std::endl ; + + + double theta2; + vpColVector u2; + + tuBuildFromEu.extract(theta2, u2); + std::cout << "theta=" << vpMath::deg(theta2) << std::endl ; + std::cout << "u=" << u2 << std::endl ; + + assert(vpMath::abs(theta2-theta)<std::numeric_limits<double>::epsilon()*1e10); + assert(vpMath::abs(u[0]-u2[0])<std::numeric_limits<double>::epsilon()*1e10); + assert(vpMath::abs(u[1]-u2[1])<std::numeric_limits<double>::epsilon()*1e10); + assert(vpMath::abs(u[2]-u2[2])<std::numeric_limits<double>::epsilon()*1e10); + } + vpRzyzVector rzyz(vpMath::rad(180), vpMath::rad(120), vpMath::rad(45)) ; + std::cout << "Initialization vpRzyzVector " <<std::endl ; + std::cout << rzyz << std::endl ; + std::cout << "From vpRzyzVector to vpRotationMatrix " << std::endl ; + R.buildFrom(rzyz) ; + std::cout << "From vpRotationMatrix to vpRzyzVector " << std::endl ; + vpRzyzVector rzyz_final ; + rzyz_final.buildFrom(R) ; + std::cout << rzyz_final << std::endl ; + + + vpRzyxVector rzyx(vpMath::rad(180), vpMath::rad(120), vpMath::rad(45)) ; + std::cout << "Initialization vpRzyxVector " <<std::endl ; + std::cout << rzyx << std::endl ; + std::cout << "From vpRzyxVector to vpRotationMatrix " << std::endl ; + R.buildFrom(rzyx) ; + std::cout << R << std::endl ; + std::cout << "From vpRotationMatrix to vpRzyxVector " << std::endl ; + vpRzyxVector rzyx_final ; + rzyx_final.buildFrom(R) ; + std::cout << rzyx_final << std::endl ; } - vpRzyzVector rzyz(vpMath::rad(180), vpMath::rad(120), vpMath::rad(45)) ; - std::cout << "Initialization vpRzyzVector " <<std::endl ; - std::cout << rzyz << std::endl ; - std::cout << "From vpRzyzVector to vpRotationMatrix " << std::endl ; - R.buildFrom(rzyz) ; - std::cout << "From vpRotationMatrix to vpRzyzVector " << std::endl ; - vpRzyzVector rzyz_final ; - rzyz_final.buildFrom(R) ; - std::cout << rzyz_final << std::endl ; - - - vpRzyxVector rzyx(vpMath::rad(180), vpMath::rad(120), vpMath::rad(45)) ; - std::cout << "Initialization vpRzyxVector " <<std::endl ; - std::cout << rzyx << std::endl ; - std::cout << "From vpRzyxVector to vpRotationMatrix " << std::endl ; - R.buildFrom(rzyx) ; - std::cout << R << std::endl ; - std::cout << "From vpRotationMatrix to vpRzyxVector " << std::endl ; - vpRzyxVector rzyx_final ; - rzyx_final.buildFrom(R) ; - std::cout << rzyx_final << std::endl ; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } } diff --git a/test/math/testSvd.cpp b/test/math/testSvd.cpp index c37bc71943549a3952ca8f4a53e4c2881a0d32c6..5963321ef4b1a8e2d7eadb5bf2b9cd66b3bba349 100644 --- a/test/math/testSvd.cpp +++ b/test/math/testSvd.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testSvd.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testSvd.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -60,6 +60,13 @@ // List of allowed command line options #define GETOPTARGS "h" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); +bool testSvdOpenCvGSLCoherence(double epsilon); +#ifdef VISP_HAVE_GSL +bool testRandom(double epsilon); +#endif + /*! Print the program options. @@ -90,15 +97,15 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -107,7 +114,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -116,7 +123,6 @@ bool getOptions(int argc, const char **argv) #define abs(x) ((x) < 0 ? - (x) : (x)) #ifdef VISP_HAVE_GSL - bool testRandom(double epsilon) { vpMatrix L0(6,6); @@ -126,8 +132,6 @@ bool testRandom(double epsilon) for (unsigned int j=0 ; j < L0.getCols() ; j++) L1[i][j] = L0[i][j] = (double)rand()/(double)RAND_MAX; - - vpColVector W0(L0.getCols()) ; vpMatrix V0(L0.getCols(), L0.getCols()) ; vpColVector W1(L1.getCols()) ; @@ -151,7 +155,8 @@ bool testRandom(double epsilon) #endif -bool testSvdOpenCvGSLCoherence(double epsilon){ +bool testSvdOpenCvGSLCoherence(double epsilon) +{ #if (VISP_HAVE_OPENCV_VERSION >= 0x020101) && defined (VISP_HAVE_GSL) // Require opencv >= 2.1.1 vpMatrix A; vpMatrix vA; @@ -188,72 +193,78 @@ bool testSvdOpenCvGSLCoherence(double epsilon){ int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } - unsigned int i,j ; - vpMatrix L(60000,6), Ls ; - for (i=0 ; i < L.getRows() ; i++) - for (j=0 ; j < L.getCols() ; j++) - L[i][j] = 2*i+j + cos((double)(i+j))+((double)(i)) ; - // std::cout << L << std::endl ; - Ls = L ; - std::cout << "--------------------------------------"<<std::endl ; + vpMatrix L(60000,6), Ls ; + for (unsigned int i=0 ; i < L.getRows() ; i++) + for (unsigned int j=0 ; j < L.getCols() ; j++) + L[i][j] = 2*i+j + cos((double)(i+j))+((double)(i)) ; + // std::cout << L << std::endl ; + Ls = L ; + std::cout << "--------------------------------------"<<std::endl ; - vpColVector W(L.getCols()) ; - vpMatrix V(L.getCols(), L.getCols()) ; + vpColVector W(L.getCols()) ; + vpMatrix V(L.getCols(), L.getCols()) ; - double t = vpTime::measureTimeMs() ; - L.svdNr(W,V) ; - t = vpTime::measureTimeMs() -t ; + double t = vpTime::measureTimeMs() ; + L.svdNr(W,V) ; + t = vpTime::measureTimeMs() -t ; - std::cout <<"svdNr Numerical recipes \n time " <<t << std::endl; - std::cout << W.t() ; - std::cout << "--------------------------------------"<<std::endl ; + std::cout <<"svdNr Numerical recipes \n time " <<t << std::endl; + std::cout << W.t() ; + std::cout << "--------------------------------------"<<std::endl ; #ifdef VISP_HAVE_GSL - L = Ls ; - t = vpTime::measureTimeMs() ; - L.svdGsl(W,V) ; - t = vpTime::measureTimeMs() -t ; - std::cout <<"svdGsl_mod \n time " <<t << std::endl; - std::cout << W.t() ; - - std::cout << "--------------------------------------"<<std::endl ; - std::cout << "TESTING RANDOM MATRICES:" ; - - bool ret = true; - for(int i=0;i<2000;i++) - ret = ret & testRandom(0.00001); - if(ret) - std:: cout << "Success"<< std:: endl; - else - std:: cout << "Fail"<< std:: endl; - - std::cout << "--------------------------------------"<<std::endl ; + L = Ls ; + t = vpTime::measureTimeMs() ; + L.svdGsl(W,V) ; + t = vpTime::measureTimeMs() -t ; + std::cout <<"svdGsl_mod \n time " <<t << std::endl; + std::cout << W.t() ; + + std::cout << "--------------------------------------"<<std::endl ; + std::cout << "TESTING RANDOM MATRICES:" ; + + bool ret = true; + for(unsigned int i=0;i<2000;i++) + ret = ret & testRandom(0.00001); + if(ret) + std:: cout << "Success"<< std:: endl; + else + std:: cout << "Fail"<< std:: endl; + + std::cout << "--------------------------------------"<<std::endl ; #endif - std::cout << "--------------------------------------"<<std::endl ; - std::cout << "TESTING OPENCV-GSL coherence:" ; - - bool ret2 = true; - for(int i=0;i<1;i++) - ret2 = ret2 & testSvdOpenCvGSLCoherence(0.00001); - if(ret2) - std:: cout << "Success"<< std:: endl; - else - std:: cout << "Fail"<< std:: endl; - - std::cout << "--------------------------------------"<<std::endl ; - - L = Ls ; - t = vpTime::measureTimeMs() ; - L.svdFlake(W,V) ; - t = vpTime::measureTimeMs() -t ; - std::cout <<"svdFlake\n time " <<t << std::endl; - std::cout << W.t() ; + std::cout << "--------------------------------------"<<std::endl ; + std::cout << "TESTING OPENCV-GSL coherence:" ; + + bool ret2 = true; + for(unsigned int i=0;i<1;i++) + ret2 = ret2 & testSvdOpenCvGSLCoherence(0.00001); + if(ret2) + std:: cout << "Success"<< std:: endl; + else + std:: cout << "Fail"<< std:: endl; + + std::cout << "--------------------------------------"<<std::endl ; + + L = Ls ; + t = vpTime::measureTimeMs() ; + L.svdFlake(W,V) ; + t = vpTime::measureTimeMs() -t ; + std::cout <<"svdFlake\n time " <<t << std::endl; + std::cout << W.t() ; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } diff --git a/test/math/testTwistMatrix.cpp b/test/math/testTwistMatrix.cpp index c061d764880b318f5bbe833abececf30dee70536..f0cd2dba11d93198ad70994de8a881ca50e67861 100644 --- a/test/math/testTwistMatrix.cpp +++ b/test/math/testTwistMatrix.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testTwistMatrix.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testTwistMatrix.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -64,6 +64,8 @@ // List of allowed command line options #define GETOPTARGS "h" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); /*! @@ -95,15 +97,15 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -112,7 +114,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -123,56 +125,62 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } - - vpTRACE("--------------------------"); - vpTRACE("--- TEST vpVelocityTwistMatrix ---"); - vpTRACE("--------------------------"); + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } - // Set the translation - vpTranslationVector cte; - cte[0] = 1.; - cte[1] = 0.5; - cte[2] = -1.; + vpTRACE("--------------------------"); + vpTRACE("--- TEST vpVelocityTwistMatrix ---"); + vpTRACE("--------------------------"); - // Set the rotation - vpRxyzVector cre; - cre[0] = M_PI/2.; - cre[1] = -M_PI/2.; - cre[2] = -M_PI/4.; + // Set the translation + vpTranslationVector cte; + cte[0] = 1.; + cte[1] = 0.5; + cte[2] = -1.; - // Build rotation matrix - vpRotationMatrix cRe(cre); + // Set the rotation + vpRxyzVector cre; + cre[0] = M_PI/2.; + cre[1] = -M_PI/2.; + cre[2] = -M_PI/4.; - // Build the twist matrix - vpVelocityTwistMatrix cVe(cte, cRe); + // Build rotation matrix + vpRotationMatrix cRe(cre); - vpTRACE("cVe twist matrix:"); - cVe.print (std::cout, 6); + // Build the twist matrix + vpVelocityTwistMatrix cVe(cte, cRe); + vpTRACE("cVe twist matrix:"); + cVe.print (std::cout, 6); - // Set a speed skew - vpColVector ev(6); - ev[0] = 1.; - ev[1] = 0.1; - ev[2] = -0.5; - ev[3] = M_PI/180.; - ev[4] = M_PI/18.; - ev[5] = M_PI/10.; + // Set a speed skew + vpColVector ev(6); - vpTRACE("ev colvector:"); - ev.print (std::cout, 6); + ev[0] = 1.; + ev[1] = 0.1; + ev[2] = -0.5; + ev[3] = M_PI/180.; + ev[4] = M_PI/18.; + ev[5] = M_PI/10.; - // Set a speed skew - vpColVector cv; + vpTRACE("ev colvector:"); + ev.print (std::cout, 6); - cv = cVe * ev; + // Set a speed skew + vpColVector cv; - vpTRACE("cv = cVe * ev:"); - cv.print (std::cout, 6); + cv = cVe * ev; + vpTRACE("cv = cVe * ev:"); + cv.print (std::cout, 6); + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } diff --git a/test/network/CMakeLists.txt b/test/network/CMakeLists.txt index 40b5481fbfacc218f12bb7581591bd2422adae1d..f8cace71163520e7842b5c3c310f93ee438c98a1 100644 --- a/test/network/CMakeLists.txt +++ b/test/network/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/test/network/testClient.cpp b/test/network/testClient.cpp index 0e5a9e92640f76ca90c132bcd29d318bd8913252..bdf7eb6516dc100cbf8fc9f1d5b61432dfb5fb66 100644 --- a/test/network/testClient.cpp +++ b/test/network/testClient.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testClient.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testClient.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -50,27 +50,32 @@ int main() { - std::string servername = "localhost"; - unsigned int port = 35000; + try { + std::string servername = "localhost"; + unsigned int port = 35000; - vpClient client; - client.connectToHostname(servername, port); - //client.connectToIP("127.0.0.1",port); + vpClient client; + client.connectToHostname(servername, port); + //client.connectToIP("127.0.0.1",port); - int val = 0; + int val = 0; - while(1) - { - if(client.send(&val) != sizeof(int)) //Sending the new value to the first client - std::cout << "Error while sending" << std::endl; - else - std::cout << "Sending : " << val << std::endl; - - if(client.receive(&val) != sizeof(int)) //Receiving a value from the first client + while(1) + { + if(client.send(&val) != sizeof(int)) //Sending the new value to the first client + std::cout << "Error while sending" << std::endl; + else + std::cout << "Sending : " << val << std::endl; + + if(client.receive(&val) != sizeof(int)) //Receiving a value from the first client std::cout << "Error while receiving" << std::endl; - else - std::cout << "Received : " << val << std::endl; + else + std::cout << "Received : " << val << std::endl; + } + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - - return 0; } diff --git a/test/network/testServer.cpp b/test/network/testServer.cpp index 1bb222f25b361c3d19504443252d341eb00b3b7d..e71f13b64524f01a7e9e822014af0deee7411014 100644 --- a/test/network/testServer.cpp +++ b/test/network/testServer.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testServer.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testServer.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -50,30 +50,35 @@ int main() { - int port = 35000; - vpServer serv(port); //Launch the server on localhost - serv.start(); - - bool run = true; - int val; - - while(run){ - serv.checkForConnections(); - - if(serv.getNumberOfClients() > 0) - { - if(serv.receive(&val) != sizeof(int)) //Receiving a value from the first client - std::cout << "Error while receiving" << std::endl; - else - std::cout << "Received : " << val << std::endl; - - val = val+1; - if(serv.send(&val) != sizeof(int)) //Sending the new value to the first client - std::cout << "Error while sending" << std::endl; - else - std::cout << "Sending : " << val << std::endl; + try { + int port = 35000; + vpServer serv(port); //Launch the server on localhost + serv.start(); + + bool run = true; + int val; + + while(run){ + serv.checkForConnections(); + + if(serv.getNumberOfClients() > 0) + { + if(serv.receive(&val) != sizeof(int)) //Receiving a value from the first client + std::cout << "Error while receiving" << std::endl; + else + std::cout << "Received : " << val << std::endl; + + val = val+1; + if(serv.send(&val) != sizeof(int)) //Sending the new value to the first client + std::cout << "Error while sending" << std::endl; + else + std::cout << "Sending : " << val << std::endl; + } } + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - - return 0; } diff --git a/test/pose/CMakeLists.txt b/test/pose/CMakeLists.txt index 1343a5565635e0bfad53633e553991e0fdc0589e..6191d5d6655313effc7f5d944f71371b0b2a47a3 100644 --- a/test/pose/CMakeLists.txt +++ b/test/pose/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/test/pose/testFindMatch.cpp b/test/pose/testFindMatch.cpp index ea11e5dd6c43bf50f113d3c1c9a9f66646d63a3d..62223fb3846d66909081e4ebb57779d302cff051 100644 --- a/test/pose/testFindMatch.cpp +++ b/test/pose/testFindMatch.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testFindMatch.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testFindMatch.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -62,60 +62,66 @@ int main() { + try { + std::cout << "Find Matches using Ransac" << std::endl; + unsigned int nb3D = 5; + unsigned int nb2D = 5; + std::vector<vpPoint> P(nb3D); + std::vector<vpPoint> p(nb2D); + + P[0].setWorldCoordinates(-L,-L, 0 ) ; + P[1].setWorldCoordinates(L,-L, 0 ) ; + P[2].setWorldCoordinates(L,L, 0 ) ; + P[3].setWorldCoordinates(-L,L, 0 ) ; + P[4].setWorldCoordinates(-0,L/2., L ) ; + + vpHomogeneousMatrix cMo_ref(0, 0.2, 1, vpMath::rad(3), vpMath::rad(-2), vpMath::rad(10)) ; + + for(unsigned int i=0 ; i < nb3D ; i++) + { + vpPoint pt = P[i]; + pt.project(cMo_ref); + p[i].set_x(pt.get_x()); + p[i].set_y(pt.get_y()); + } + + unsigned int ninliers ; + std::vector<vpPoint> inliers; + double threshold = 1e-6; + unsigned int nbInlierToReachConsensus = nb3D; + + vpHomogeneousMatrix cMo ; + + vpPose::findMatch(p,P,nbInlierToReachConsensus,threshold,ninliers,inliers,cMo); + + std::cout << "Inliers: " << std::endl; + for (unsigned int i = 0; i < inliers.size() ; i++) + { + inliers[i].print() ; + std::cout << std::endl; + } + + std::cout << "cMo :\n" << vpPoseVector(cMo).t() << std::endl << std::endl; + + vpPoseVector pose_ref = vpPoseVector(cMo_ref); + vpPoseVector pose_est = vpPoseVector(cMo); - std::cout << "Find Matches using Ransac" << std::endl; - unsigned int nb3D = 5; - unsigned int nb2D = 5; - std::vector<vpPoint> P(nb3D); - std::vector<vpPoint> p(nb2D); - - P[0].setWorldCoordinates(-L,-L, 0 ) ; - P[1].setWorldCoordinates(L,-L, 0 ) ; - P[2].setWorldCoordinates(L,L, 0 ) ; - P[3].setWorldCoordinates(-L,L, 0 ) ; - P[4].setWorldCoordinates(-0,L/2., L ) ; - - vpHomogeneousMatrix cMo_ref(0, 0.2, 1, vpMath::rad(3), vpMath::rad(-2), vpMath::rad(10)) ; - - for(unsigned int i=0 ; i < nb3D ; i++) - { - vpPoint pt = P[i]; - pt.project(cMo_ref); - p[i].set_x(pt.get_x()); - p[i].set_y(pt.get_y()); - } - - unsigned int ninliers ; - std::vector<vpPoint> inliers; - double threshold = 1e-6; - unsigned int nbInlierToReachConsensus = nb3D; - - vpHomogeneousMatrix cMo ; - - vpPose::findMatch(p,P,nbInlierToReachConsensus,threshold,ninliers,inliers,cMo); - - std::cout << "Inliers: " << std::endl; - for (unsigned int i = 0; i < inliers.size() ; i++) - { - inliers[i].print() ; std::cout << std::endl; - } - - std::cout << "cMo :\n" << vpPoseVector(cMo).t() << std::endl << std::endl; + std::cout << "reference cMo :\n" << pose_ref.t() << std::endl << std::endl; + std::cout << "estimated cMo :\n" << pose_est.t() << std::endl << std::endl; - vpPoseVector pose_ref = vpPoseVector(cMo_ref); - vpPoseVector pose_est = vpPoseVector(cMo); + int test_fail = 0; + for(unsigned int i=0; i<6; i++) { + if (std::fabs(pose_ref[i]-pose_est[i]) > 0.001) + test_fail = 1; + } - std::cout << std::endl; - std::cout << "reference cMo :\n" << pose_ref.t() << std::endl << std::endl; - std::cout << "estimated cMo :\n" << pose_est.t() << std::endl << std::endl; + std::cout << "Matching is " << (test_fail ? "badly" : "well") << " performed" << std::endl; - int test_fail = 0; - for(unsigned int i=0; i<6; i++) { - if (std::fabs(pose_ref[i]-pose_est[i]) > 0.001) - test_fail = 1; + return test_fail; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - - std::cout << "Matching is " << (test_fail ? "badly" : "well") << " performed" << std::endl; - return test_fail; } diff --git a/test/pose/testPose.cpp b/test/pose/testPose.cpp index 57b1fa8d2acb06337f8af374c86cc880b10e8526..00b39226ca19ae6c0a80f90b5c79d481d7085f7b 100644 --- a/test/pose/testPose.cpp +++ b/test/pose/testPose.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testPose.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testPose.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -66,6 +66,14 @@ Non-Linear approach. */ + +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); +void print_pose(const vpHomogeneousMatrix &cMo, const std::string &legend); +int compare_pose(const vpPose &pose, const vpHomogeneousMatrix &cMo_ref, const vpHomogeneousMatrix &cMo_est, + const std::string &legend); + + /*! Print the program options. @@ -97,15 +105,15 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -114,7 +122,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -137,7 +145,8 @@ void print_pose(const vpHomogeneousMatrix &cMo, const std::string &legend) } // test if pose is well estimated -int compare_pose(const vpPose &pose, const vpHomogeneousMatrix &cMo_ref, const vpHomogeneousMatrix &cMo_est, const std::string &legend) +int compare_pose(const vpPose &pose, const vpHomogeneousMatrix &cMo_ref, const vpHomogeneousMatrix &cMo_est, + const std::string &legend) { vpPoseVector pose_ref = vpPoseVector(cMo_ref); vpPoseVector pose_est = vpPoseVector(cMo_est); @@ -149,10 +158,16 @@ int compare_pose(const vpPose &pose, const vpHomogeneousMatrix &cMo_ref, const v if (std::fabs(pose_ref[i]-pose_est[i]) > 0.001) fail = 1; } + std::cout << "Based on 3D parameters " << legend << " is " << (fail ? "badly" : "well") << " estimated" << std::endl; // Test done on the residual double r = pose.computeResidual(cMo_est); + if (pose.listP.size() < 4) { + fail = 1; + std::cout << "Not enough point" << std::endl; + return fail; + } r = sqrt(r)/pose.listP.size(); //std::cout << "Residual on each point (meter): " << r << std::endl; fail = (r > 0.1) ? 1 : 0; @@ -163,97 +178,103 @@ int compare_pose(const vpPose &pose, const vpHomogeneousMatrix &cMo_ref, const v int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } - vpPoint P[5] ; // Point to be tracked - vpPose pose ; - pose.clearPoint() ; - - P[0].setWorldCoordinates(-L,-L, 0 ) ; - P[1].setWorldCoordinates(L,-L, 0 ) ; - P[2].setWorldCoordinates(L,L, 0 ) ; - P[3].setWorldCoordinates(-2*L, 3*L, 0 ) ; - P[4].setWorldCoordinates(-L,L, 0.01 ) ; - //P[3].setWorldCoordinates(-L,L, 0 ) ; - - int test_fail = 0, fail = 0; - vpPoseVector cpo_ref = vpPoseVector(0.01, 0.02, 0.25, vpMath::rad(5), 0,vpMath::rad(10)); - vpHomogeneousMatrix cMo_ref(cpo_ref) ; - vpHomogeneousMatrix cMo ; // will contain the estimated pose - - for(int i=0 ; i < 5 ; i++) { - P[i].project(cMo_ref) ; - //P[i].print(); - pose.addPoint(P[i]) ; // and added to the pose computation class - } + vpPoint P[5] ; // Point to be tracked + vpPose pose ; + pose.clearPoint() ; + + P[0].setWorldCoordinates(-L,-L, 0 ) ; + P[1].setWorldCoordinates(L,-L, 0 ) ; + P[2].setWorldCoordinates(L,L, 0 ) ; + P[3].setWorldCoordinates(-2*L, 3*L, 0 ) ; + P[4].setWorldCoordinates(-L,L, 0.01 ) ; + //P[3].setWorldCoordinates(-L,L, 0 ) ; + + int test_fail = 0, fail = 0; + vpPoseVector cpo_ref = vpPoseVector(0.01, 0.02, 0.25, vpMath::rad(5), 0,vpMath::rad(10)); + vpHomogeneousMatrix cMo_ref(cpo_ref) ; + vpHomogeneousMatrix cMo ; // will contain the estimated pose + + for(int i=0 ; i < 5 ; i++) { + P[i].project(cMo_ref) ; + //P[i].print(); + pose.addPoint(P[i]) ; // and added to the pose computation class + } - // Let's go ... - print_pose(cMo_ref, std::string("Reference pose")); // print the reference pose + // Let's go ... + print_pose(cMo_ref, std::string("Reference pose")); // print the reference pose - std::cout <<"-------------------------------------------------"<<std::endl ; - pose.computePose(vpPose::LAGRANGE, cMo) ; + std::cout <<"-------------------------------------------------"<<std::endl ; + pose.computePose(vpPose::LAGRANGE, cMo) ; - print_pose(cMo, std::string("Pose estimated by Lagrange")); - fail = compare_pose(pose, cMo_ref, cMo, "pose by Lagrange"); - test_fail |= fail; + print_pose(cMo, std::string("Pose estimated by Lagrange")); + fail = compare_pose(pose, cMo_ref, cMo, "pose by Lagrange"); + test_fail |= fail; - std::cout <<"--------------------------------------------------"<<std::endl ; - pose.computePose(vpPose::DEMENTHON, cMo) ; + std::cout <<"--------------------------------------------------"<<std::endl ; + pose.computePose(vpPose::DEMENTHON, cMo) ; - print_pose(cMo, std::string("Pose estimated by Dementhon")); - fail = compare_pose(pose, cMo_ref, cMo, "pose by Dementhon"); - test_fail |= fail; + print_pose(cMo, std::string("Pose estimated by Dementhon")); + fail = compare_pose(pose, cMo_ref, cMo, "pose by Dementhon"); + test_fail |= fail; - std::cout <<"--------------------------------------------------"<<std::endl ; - pose.setRansacNbInliersToReachConsensus(4); - pose.setRansacThreshold(0.01); - pose.computePose(vpPose::RANSAC, cMo) ; + std::cout <<"--------------------------------------------------"<<std::endl ; + pose.setRansacNbInliersToReachConsensus(4); + pose.setRansacThreshold(0.01); + pose.computePose(vpPose::RANSAC, cMo) ; - print_pose(cMo, std::string("Pose estimated by Ransac")); - fail = compare_pose(pose, cMo_ref, cMo, "pose by Ransac"); - test_fail |= fail; + print_pose(cMo, std::string("Pose estimated by Ransac")); + fail = compare_pose(pose, cMo_ref, cMo, "pose by Ransac"); + test_fail |= fail; - std::cout <<"--------------------------------------------------"<<std::endl ; - pose.computePose(vpPose::LAGRANGE_LOWE, cMo) ; + std::cout <<"--------------------------------------------------"<<std::endl ; + pose.computePose(vpPose::LAGRANGE_LOWE, cMo) ; - print_pose(cMo, std::string("Pose estimated by Lagrange than Lowe")); - fail = compare_pose(pose, cMo_ref, cMo, "pose by Lagrange than Lowe"); - test_fail |= fail; + print_pose(cMo, std::string("Pose estimated by Lagrange than Lowe")); + fail = compare_pose(pose, cMo_ref, cMo, "pose by Lagrange than Lowe"); + test_fail |= fail; - std::cout <<"--------------------------------------------------"<<std::endl ; - pose.computePose(vpPose::DEMENTHON_LOWE, cMo) ; + std::cout <<"--------------------------------------------------"<<std::endl ; + pose.computePose(vpPose::DEMENTHON_LOWE, cMo) ; - print_pose(cMo, std::string("Pose estimated by Dementhon than Lowe")); - fail = compare_pose(pose, cMo_ref, cMo, "pose by Dementhon than Lowe"); - test_fail |= fail; + print_pose(cMo, std::string("Pose estimated by Dementhon than Lowe")); + fail = compare_pose(pose, cMo_ref, cMo, "pose by Dementhon than Lowe"); + test_fail |= fail; - // Now Virtual Visual servoing + // Now Virtual Visual servoing - std::cout <<"--------------------------------------------------"<<std::endl ; - pose.computePose(vpPose::VIRTUAL_VS, cMo) ; + std::cout <<"--------------------------------------------------"<<std::endl ; + pose.computePose(vpPose::VIRTUAL_VS, cMo) ; - print_pose(cMo, std::string("Pose estimated by VVS")); - fail = compare_pose(pose, cMo_ref, cMo, "pose by VVS"); - test_fail |= fail; + print_pose(cMo, std::string("Pose estimated by VVS")); + fail = compare_pose(pose, cMo_ref, cMo, "pose by VVS"); + test_fail |= fail; - std::cout <<"-------------------------------------------------"<<std::endl ; - pose.computePose(vpPose::DEMENTHON_VIRTUAL_VS, cMo) ; + std::cout <<"-------------------------------------------------"<<std::endl ; + pose.computePose(vpPose::DEMENTHON_VIRTUAL_VS, cMo) ; - print_pose(cMo, std::string("Pose estimated by Dementhon than by VVS")); - fail = compare_pose(pose, cMo_ref, cMo, "pose by Dementhon than by VVS"); - test_fail |= fail; + print_pose(cMo, std::string("Pose estimated by Dementhon than by VVS")); + fail = compare_pose(pose, cMo_ref, cMo, "pose by Dementhon than by VVS"); + test_fail |= fail; - std::cout <<"-------------------------------------------------"<<std::endl ; - pose.computePose(vpPose::LAGRANGE_VIRTUAL_VS, cMo) ; + std::cout <<"-------------------------------------------------"<<std::endl ; + pose.computePose(vpPose::LAGRANGE_VIRTUAL_VS, cMo) ; - print_pose(cMo, std::string("Pose estimated by Lagrange than by VVS")); - fail = compare_pose(pose, cMo_ref, cMo, "pose by Lagrange than by VVS"); - test_fail |= fail; + print_pose(cMo, std::string("Pose estimated by Lagrange than by VVS")); + fail = compare_pose(pose, cMo_ref, cMo, "pose by Lagrange than by VVS"); + test_fail |= fail; - std::cout << "\nGlobal pose estimation test " << (test_fail ? "fail" : "is ok") << std::endl; + std::cout << "\nGlobal pose estimation test " << (test_fail ? "fail" : "is ok") << std::endl; - return test_fail; + return test_fail; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } diff --git a/test/pose/testPoseFeatures.cpp b/test/pose/testPoseFeatures.cpp index 1004757d5bcb2efc0e70329bff3c0c9c749e8e3e..19d2a598ae999a5b2e6fd5fdb5761450bec79f72 100644 --- a/test/pose/testPoseFeatures.cpp +++ b/test/pose/testPoseFeatures.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testPoseFeatures.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testPoseFeatures.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -87,127 +87,130 @@ void vp_createLine(vpFeatureLine &fp,const vpLine &v){ int main() { - vpImage<unsigned char> I(600,600); - - vpHomogeneousMatrix cMo_ref(0., 0., 1., vpMath::rad(0), vpMath::rad(0), vpMath::rad(60)); - vpPoseVector pose_ref = vpPoseVector(cMo_ref); + try { + vpImage<unsigned char> I(600,600); - std::cout << "Reference pose used to create the visual features : " << std::endl; - std::cout << pose_ref.t() << std::endl; - - vpPoseFeatures pose; - - vpPoint pts[6]; + vpHomogeneousMatrix cMo_ref(0., 0., 1., vpMath::rad(0), vpMath::rad(0), vpMath::rad(60)); + vpPoseVector pose_ref = vpPoseVector(cMo_ref); + + std::cout << "Reference pose used to create the visual features : " << std::endl; + std::cout << pose_ref.t() << std::endl; + + vpPoseFeatures pose; + + vpPoint pts[6]; - double val = 0.25; - double val2 = 0.0; - - //2D Point Feature - pts[0].setWorldCoordinates(0.0,-val,val2); - pts[1].setWorldCoordinates(0.0,val,val2); - pts[2].setWorldCoordinates(-val,val,val2); - - //Segment Feature - pts[3].setWorldCoordinates(-val,-val/2.0,val2); - pts[4].setWorldCoordinates(val,val/2.0,val2); - - //3D point Feature - pts[5].setWorldCoordinates(0.0,0.0,-1.5); - - //Line Feature - vpLine line; - line.setWorldCoordinates(0.0,1.0,0.0,.0, - 0.0,0.0,1.0,0.0); - - //Vanishing Point Feature - vpLine l1; - l1.setWorldCoordinates(0.0,1.0,0.2,0.0, - 1.0,0.0,0.0,-0.25); - - vpLine l2; - l2.setWorldCoordinates(0.0,1.0,0.2,0.0, + double val = 0.25; + double val2 = 0.0; + + //2D Point Feature + pts[0].setWorldCoordinates(0.0,-val,val2); + pts[1].setWorldCoordinates(0.0,val,val2); + pts[2].setWorldCoordinates(-val,val,val2); + + //Segment Feature + pts[3].setWorldCoordinates(-val,-val/2.0,val2); + pts[4].setWorldCoordinates(val,val/2.0,val2); + + //3D point Feature + pts[5].setWorldCoordinates(0.0,0.0,-1.5); + + //Line Feature + vpLine line; + line.setWorldCoordinates(0.0,1.0,0.0,.0, + 0.0,0.0,1.0,0.0); + + //Vanishing Point Feature + vpLine l1; + l1.setWorldCoordinates(0.0,1.0,0.2,0.0, + 1.0,0.0,0.0,-0.25); + + vpLine l2; + l2.setWorldCoordinates(0.0,1.0,0.2,0.0, -1.0,0.0,0.0,-0.25); - - //Ellipse Feature - vpCircle circle; - circle.setWorldCoordinates(0.0, 0.0, 1.0 , 0.0, 0.0, 0.0, 0.25); - - pts[0].project(cMo_ref); - pts[1].project(cMo_ref); - pts[2].project(cMo_ref); - - pts[3].project(cMo_ref); - pts[4].project(cMo_ref); - - pts[5].project(cMo_ref); - - line.project(cMo_ref); - - l1.project(cMo_ref); - l2.project(cMo_ref); - - circle.project(cMo_ref); - - pose.addFeaturePoint(pts[0]); -// pose.addFeaturePoint(pts[1]); - pose.addFeaturePoint(pts[2]); - - pose.addFeaturePoint3D(pts[5]); - - pose.addFeatureVanishingPoint(l1,l2); - -// pose.addFeatureSegment(pts[3],pts[4]); -// -// pose.addFeatureLine(line); - - pose.addFeatureEllipse(circle); + + //Ellipse Feature + vpCircle circle; + circle.setWorldCoordinates(0.0, 0.0, 1.0 , 0.0, 0.0, 0.0, 0.25); + + pts[0].project(cMo_ref); + pts[1].project(cMo_ref); + pts[2].project(cMo_ref); + + pts[3].project(cMo_ref); + pts[4].project(cMo_ref); + + pts[5].project(cMo_ref); + + line.project(cMo_ref); + + l1.project(cMo_ref); + l2.project(cMo_ref); + + circle.project(cMo_ref); + + pose.addFeaturePoint(pts[0]); + // pose.addFeaturePoint(pts[1]); + pose.addFeaturePoint(pts[2]); + + pose.addFeaturePoint3D(pts[5]); + + pose.addFeatureVanishingPoint(l1,l2); + + // pose.addFeatureSegment(pts[3],pts[4]); + // + // pose.addFeatureLine(line); + + pose.addFeatureEllipse(circle); #ifdef VISP_HAVE_CPP11_COMPATIBILITY - vpFeaturePoint fp; - vpFeatureLine fl; - vpFeatureSegment fs; - void (*ptr)(vpFeatureSegment&, vpPoint&, vpPoint&) = &vpFeatureBuilder::create; - vp_createPointClass cpClass; - int (vp_createPointClass::*ptrClass)(vpFeaturePoint&, const vpPoint&) = &vp_createPointClass::vp_createPoint; - pose.addSpecificFeature(&cpClass, ptrClass, fp, pts[1]); - pose.addSpecificFeature(&vp_createLine, fl, line); - pose.addSpecificFeature(ptr, fs, pts[3], pts[4]); + vpFeaturePoint fp; + vpFeatureLine fl; + vpFeatureSegment fs; + void (*ptr)(vpFeatureSegment&, vpPoint&, vpPoint&) = &vpFeatureBuilder::create; + vp_createPointClass cpClass; + int (vp_createPointClass::*ptrClass)(vpFeaturePoint&, const vpPoint&) = &vp_createPointClass::vp_createPoint; + pose.addSpecificFeature(&cpClass, ptrClass, fp, pts[1]); + pose.addSpecificFeature(&vp_createLine, fl, line); + pose.addSpecificFeature(ptr, fs, pts[3], pts[4]); #endif - - pose.setVerbose(true); - pose.setLambda(0.6); - pose.setVVSIterMax(200); - pose.setCovarianceComputation(true); - - vpHomogeneousMatrix cMo_est(0.4, 0.3, 1.5, vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); - vpPoseVector pose_est = vpPoseVector(cMo_est); - std::cout << "\nPose used as initialisation of the pose computation : " << std::endl; - std::cout << pose_est.t() << std::endl; - - pose.computePose(cMo_est); -// pose.computePose(cMo_est, vpPoseFeatures::ROBUST_VIRTUAL_VS); - - std::cout << "\nEstimated pose from visual features : " << std::endl; - pose_est.buildFrom(cMo_est); - std::cout << pose_est.t() << std::endl; - - std::cout << "\nResulting covariance (Diag): " << std::endl; - vpMatrix covariance = pose.getCovarianceMatrix(); - std::cout << covariance[0][0] << " " - << covariance[1][1] << " " - << covariance[2][2] << " " - << covariance[3][3] << " " - << covariance[4][4] << " " - << covariance[5][5] << " " << std::endl; - - int test_fail = 0; - for(unsigned int i=0; i<6; i++) { - if (std::fabs(pose_ref[i]-pose_est[i]) > 0.001) - test_fail = 1; - } + pose.setVerbose(true); + pose.setLambda(0.6); + pose.setVVSIterMax(200); + pose.setCovarianceComputation(true); + + vpHomogeneousMatrix cMo_est(0.4, 0.3, 1.5, vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); + vpPoseVector pose_est = vpPoseVector(cMo_est); + std::cout << "\nPose used as initialisation of the pose computation : " << std::endl; + std::cout << pose_est.t() << std::endl; - std::cout << "\nPose is " << (test_fail ? "badly" : "well") << " estimated" << std::endl; + pose.computePose(cMo_est); + // pose.computePose(cMo_est, vpPoseFeatures::ROBUST_VIRTUAL_VS); - return test_fail; + + std::cout << "\nEstimated pose from visual features : " << std::endl; + pose_est.buildFrom(cMo_est); + std::cout << pose_est.t() << std::endl; + + std::cout << "\nResulting covariance (Diag): " << std::endl; + vpMatrix covariance = pose.getCovarianceMatrix(); + std::cout << covariance[0][0] << " " << covariance[1][1] << " " + << covariance[2][2] << " " << covariance[3][3] << " " + << covariance[4][4] << " " << covariance[5][5] << " " << std::endl; + + int test_fail = 0; + for(unsigned int i=0; i<6; i++) { + if (std::fabs(pose_ref[i]-pose_est[i]) > 0.001) + test_fail = 1; + } + + std::cout << "\nPose is " << (test_fail ? "badly" : "well") << " estimated" << std::endl; + + return test_fail; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } diff --git a/test/pose/testPoseRansac.cpp b/test/pose/testPoseRansac.cpp index 0a8892b3a4320dd52419e05fe25bca7309e30692..70e8acca73cd532fa747da22f3dbc5585e6413fa 100644 --- a/test/pose/testPoseRansac.cpp +++ b/test/pose/testPoseRansac.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testPoseRansac.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testPoseRansac.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -62,6 +62,7 @@ int main() { + try { std::cout << "Pose computation with matched points" << std::endl; int size = 8; vpPoint *P = new vpPoint [size] ; // Point to be tracked @@ -81,7 +82,7 @@ main() vpHomogeneousMatrix cMo_ref(0, 0.2, 1, 0, 0, 0) ; for(int i=0 ; i < size ; i++) - { + { P[i].project(cMo_ref) ; P[i].print() ; std::cout << std::endl; @@ -131,4 +132,9 @@ main() std::cout << "Pose is " << (test_fail ? "badly" : "well") << " estimated" << std::endl; delete [] P; return test_fail; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } diff --git a/test/servo-afma4/CMakeLists.txt b/test/servo-afma4/CMakeLists.txt index ac0fe331bad77acca8e62fbae6c702f662099553..0211f577b0106d93444b7ec18379d9c10e2135be 100644 --- a/test/servo-afma4/CMakeLists.txt +++ b/test/servo-afma4/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/test/servo-afma4/testAfma4.cpp b/test/servo-afma4/testAfma4.cpp index 1df849ba4796a90cfdd46a58d8e724570e5b3c69..03583ed57f7368725e91d9de5618e533dcf72fc4 100644 --- a/test/servo-afma4/testAfma4.cpp +++ b/test/servo-afma4/testAfma4.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testAfma4.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testAfma4.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -67,10 +67,9 @@ int main() return 0; } - catch(...) { - vpERROR_TRACE(" Test failed"); - return 0; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - } diff --git a/test/servo-afma4/testRobotAfma4.cpp b/test/servo-afma4/testRobotAfma4.cpp index 60f1919e16629cd67f3fa02cd6e0811aff5fedc5..96a26fffff9d52de60366c60d2785173e7148583 100644 --- a/test/servo-afma4/testRobotAfma4.cpp +++ b/test/servo-afma4/testRobotAfma4.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testRobotAfma4.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testRobotAfma4.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -64,14 +64,11 @@ int main() vpRobotAfma4 afma4; std::cout << afma4 << std::endl; - - return 0; } - catch(...) { - vpERROR_TRACE(" Test failed"); - return 0; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; } - + return 0; } #else int main() diff --git a/test/servo-afma6/CMakeLists.txt b/test/servo-afma6/CMakeLists.txt index 0ccf349fc1e1556a7c45b64d28c74a30de751dab..e445bda22982f6c1d6273dfff2a33419f9985424 100644 --- a/test/servo-afma6/CMakeLists.txt +++ b/test/servo-afma6/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/test/servo-afma6/testAfma6.cpp b/test/servo-afma6/testAfma6.cpp index 0c11f6d80997d6409008dd752d1c253db75296e4..06657867cf707ae478dd3f80d33db897e90f337f 100644 --- a/test/servo-afma6/testAfma6.cpp +++ b/test/servo-afma6/testAfma6.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testAfma6.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testAfma6.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -104,10 +104,9 @@ int main() return 0; } - catch(...) { - vpERROR_TRACE(" Test failed"); - return 0; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - } diff --git a/test/servo-afma6/testRobotAfma6.cpp b/test/servo-afma6/testRobotAfma6.cpp index 62cd515677e3a1cd5ff5fa1db64dae18c9b37792..9ac60a2789e63f20ee803377281fc41d91524b84 100644 --- a/test/servo-afma6/testRobotAfma6.cpp +++ b/test/servo-afma6/testRobotAfma6.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testRobotAfma6.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testRobotAfma6.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -101,14 +101,11 @@ int main() std::cout << afma6 << std::endl; afma6.getCameraParameters(cam, 640, 480); std::cout << cam << std::endl; - - return 0; } - catch(...) { - vpERROR_TRACE(" Test failed"); - return 0; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; } - + return 0; } #else int main() diff --git a/test/servo-afma6/testRobotAfma6Pose.cpp b/test/servo-afma6/testRobotAfma6Pose.cpp index 2d223720c184d6bf31e9c5d523d9f3113a8c7f44..038212ae7ad1d753340cb0d499b6c9c11fabd6da 100644 --- a/test/servo-afma6/testRobotAfma6Pose.cpp +++ b/test/servo-afma6/testRobotAfma6Pose.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testRobotAfma6Pose.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testRobotAfma6Pose.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -223,12 +223,11 @@ int main() << vpMath::deg(r[1]) << " " << vpMath::deg(r[2]) << " deg" << std::endl << std::endl; - return 0; } - catch(...) { - std::cout << "Test failed" << std::endl; - return 0; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; } + return 0; } #else int main() diff --git a/test/servo-viper/CMakeLists.txt b/test/servo-viper/CMakeLists.txt index 8d859e099e14e26564b05c8f3ca6d93cd9a018fe..9ac4f3bf6f3398b071cc88249dd39c1833983cfb 100644 --- a/test/servo-viper/CMakeLists.txt +++ b/test/servo-viper/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/test/servo-viper/testRobotViper850.cpp b/test/servo-viper/testRobotViper850.cpp index 48105bcc9f112fe0b33d319596de727affb43cb6..cad8251d1683a6ffd1cc858cbb5786ccd1cfb381 100644 --- a/test/servo-viper/testRobotViper850.cpp +++ b/test/servo-viper/testRobotViper850.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testRobotViper850.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testRobotViper850.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -110,13 +110,11 @@ int main() << " " << vpMath::deg(rzyz[1]) << " " << vpMath::deg(rzyz[2]) << std::endl; - return 0; } - catch(...) { - vpERROR_TRACE(" Test failed"); - return 0; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; } - + return 0; } #else int main() diff --git a/test/servo-viper/testRobotViper850Pose.cpp b/test/servo-viper/testRobotViper850Pose.cpp index 223026b2f90a016a70c2aa218746c35363afc790..9748bb893907b3eb52cc140baecc54c1beba511b 100644 --- a/test/servo-viper/testRobotViper850Pose.cpp +++ b/test/servo-viper/testRobotViper850Pose.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testRobotViper850Pose.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testRobotViper850Pose.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -226,12 +226,11 @@ int main() << vpMath::deg(r[1]) << " " << vpMath::deg(r[2]) << " deg" << std::endl << std::endl; - return 0; } - catch(...) { - std::cout << "Test failed" << std::endl; - return 0; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; } + return 0; } #else int main() diff --git a/test/servo-viper/testViper850.cpp b/test/servo-viper/testViper850.cpp index 9a84e287b0fdda717a7eb3a358be406064b57df6..20c35abbe37ed5fb5ad9f28021af295ddb7938ee 100644 --- a/test/servo-viper/testViper850.cpp +++ b/test/servo-viper/testViper850.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testViper850.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testViper850.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -120,9 +120,9 @@ int main() return 0; } - catch(...) { - vpERROR_TRACE(" Test failed"); - return 0; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } } diff --git a/test/tools/CMakeLists.txt b/test/tools/CMakeLists.txt index d309b045a556031654e9204db7c54230a63a19ab..ad1e05ed3ebbcb963e0ac841aa506fabe4990889 100644 --- a/test/tools/CMakeLists.txt +++ b/test/tools/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/test/tools/geometry/CMakeLists.txt b/test/tools/geometry/CMakeLists.txt index ebcd2a82d48fb05482f842c21eb699ee351a78a4..7ace752d23fc1bfc6453ef8a127964cd0c36aa0b 100644 --- a/test/tools/geometry/CMakeLists.txt +++ b/test/tools/geometry/CMakeLists.txt @@ -3,7 +3,7 @@ # $Id: CMakeLists.txt 2897 2010-11-04 11:17:58Z rtallonn $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/test/tools/geometry/testPolygon.cpp b/test/tools/geometry/testPolygon.cpp index a56236fa714a2d0e097f9d074bd60b71932b29c0..d56c5ba7f40a8ed3be8ba592bc537ee551363753 100755 --- a/test/tools/geometry/testPolygon.cpp +++ b/test/tools/geometry/testPolygon.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testPolygon.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testPolygon.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -60,6 +60,9 @@ //! List of allowed command line options #define GETOPTARGS "cdh" +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv, bool& opt_display, bool& opt_click); + /*! Print the program options. @@ -103,12 +106,11 @@ OPTIONS: \n\ \param opt_click : activates the mouse click. \return false if the program has to be stopped, true otherwise. */ -bool getOptions(int argc, const char **argv, - bool& opt_display, bool& opt_click) +bool getOptions(int argc, const char **argv, bool& opt_display, bool& opt_click) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': opt_click = false; break; @@ -116,7 +118,7 @@ bool getOptions(int argc, const char **argv, case 'h': usage(argv[0], NULL); return false; break; default: - usage(argv[0], optarg); return false; break; + usage(argv[0], optarg_); return false; break; } } @@ -124,7 +126,7 @@ bool getOptions(int argc, const char **argv, // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -140,111 +142,117 @@ bool getOptions(int argc, const char **argv, int main(int argc, const char** argv) { - bool opt_display = true; - bool opt_click = true; - vpImage<unsigned char> I(480, 640, 255); - - // Read the command line options - if (getOptions(argc, argv, opt_display, opt_click) == false) { - return (-1); - } + try { + bool opt_display = true; + bool opt_click = true; + vpImage<unsigned char> I(480, 640, 255); + + // Read the command line options + if (getOptions(argc, argv, opt_display, opt_click) == false) { + return (-1); + } - std::vector <vpImagePoint> vec1; - vec1.push_back(vpImagePoint(200, 200)); - vec1.push_back(vpImagePoint(200, 400)); - vec1.push_back(vpImagePoint(320, 400)); - vec1.push_back(vpImagePoint(380, 300)); - vec1.push_back(vpImagePoint(280, 280)); - vpPolygon p1; - p1.buildFrom(vec1); - - std::vector <vpImagePoint> vec2; - vec2.push_back(vpImagePoint(20, 20)); - vec2.push_back(vpImagePoint(100, 20)); - vec2.push_back(vpImagePoint(100, 100)); - vec2.push_back(vpImagePoint(20, 100)); - vpPolygon p2(vec2); - - - std::vector <vpImagePoint> vec3; - vec2.push_back(vpImagePoint(250, 250)); - vec2.push_back(vpImagePoint(150, 250)); - vec2.push_back(vpImagePoint(250, 250)); - vpPolygon p3(vec3); + std::vector <vpImagePoint> vec1; + vec1.push_back(vpImagePoint(200, 200)); + vec1.push_back(vpImagePoint(200, 400)); + vec1.push_back(vpImagePoint(320, 400)); + vec1.push_back(vpImagePoint(380, 300)); + vec1.push_back(vpImagePoint(280, 280)); + vpPolygon p1; + p1.buildFrom(vec1); + + std::vector <vpImagePoint> vec2; + vec2.push_back(vpImagePoint(20, 20)); + vec2.push_back(vpImagePoint(100, 20)); + vec2.push_back(vpImagePoint(100, 100)); + vec2.push_back(vpImagePoint(20, 100)); + vpPolygon p2(vec2); + + + std::vector <vpImagePoint> vec3; + vec2.push_back(vpImagePoint(250, 250)); + vec2.push_back(vpImagePoint(150, 250)); + vec2.push_back(vpImagePoint(250, 250)); + vpPolygon p3(vec3); #if defined VISP_HAVE_X11 - vpDisplayX display; + vpDisplayX display; #elif defined VISP_HAVE_GTK - vpDisplayGTK display; + vpDisplayGTK display; #elif defined VISP_HAVE_GDI - vpDisplayGDI display; + vpDisplayGDI display; #else - opt_display = false; + opt_display = false; #endif - std::cout << " Polygon 1 : " << std::endl; - std::cout << " area : " << p1.getArea() << std::endl; - std::cout << " center : " << p1.getCenter() << std::endl << std::endl; + std::cout << " Polygon 1 : " << std::endl; + std::cout << " area : " << p1.getArea() << std::endl; + std::cout << " center : " << p1.getCenter() << std::endl << std::endl; - std::cout << " Polygon 2 : " << std::endl; - std::cout << " area : " << p2.getArea() << std::endl; - std::cout << " center : " << p2.getCenter() << std::endl << std::endl; + std::cout << " Polygon 2 : " << std::endl; + std::cout << " area : " << p2.getArea() << std::endl; + std::cout << " center : " << p2.getCenter() << std::endl << std::endl; - std::cout << " Polygon 3 : " << std::endl; - std::cout << " area : " << p3.getArea() << std::endl; - std::cout << " center : " << p3.getCenter() << std::endl; + std::cout << " Polygon 3 : " << std::endl; + std::cout << " area : " << p3.getArea() << std::endl; + std::cout << " center : " << p3.getCenter() << std::endl; - if(opt_display){ + if(opt_display){ #if (defined VISP_HAVE_X11) || (defined VISP_HAVE_GTK) || (defined VISP_HAVE_GDI) - display.init(I, 10, 10, "Test vpPolygon"); + display.init(I, 10, 10, "Test vpPolygon"); #endif - vpDisplay::display(I); - p1.display(I, vpColor::green, 1); - vpDisplay::displayCross(I, p1.getCenter(), 5, vpColor::green); - p2.display(I, vpColor::red, 1); - vpDisplay::displayCross(I, p2.getCenter(), 5, vpColor::red); - p3.display(I, vpColor::blue, 1); - vpDisplay::displayCross(I, p3.getCenter(), 5, vpColor::lightBlue); - vpDisplay::displayCharString(I, vpImagePoint(10, 10), "Click to finish", vpColor::red); - vpDisplay::flush(I); - - if (opt_click) - vpDisplay::getClick(I); - - - vpDisplay::display(I); - vpDisplay::displayCharString(I, vpImagePoint(10, 10), "Left click to add a point", vpColor::red); - vpDisplay::displayCharString(I, vpImagePoint(20, 10), "Right click to build the polygon", vpColor::red); - vpDisplay::flush(I); - if (opt_click) { - vpPolygon p4; - p4.initClick(I); - p4.display(I, vpColor::green, 1); - std::cout << std::endl; - std::cout << " Polygon 4 : " << std::endl; - std::cout << " area : " << p4.getArea() << std::endl; - std::cout << " center : " << p4.getCenter() << std::endl; - std::cout << "Click to continue." << std::endl; + vpDisplay::display(I); + p1.display(I, vpColor::green, 1); + vpDisplay::displayCross(I, p1.getCenter(), 5, vpColor::green); + p2.display(I, vpColor::red, 1); + vpDisplay::displayCross(I, p2.getCenter(), 5, vpColor::red); + p3.display(I, vpColor::blue, 1); + vpDisplay::displayCross(I, p3.getCenter(), 5, vpColor::lightBlue); + vpDisplay::displayCharString(I, vpImagePoint(10, 10), "Click to finish", vpColor::red); vpDisplay::flush(I); - vpDisplay::getClick(I); - vpRect bbox = p4.getBoundingBox(); - for(unsigned int i= (unsigned int)floor(bbox.getTop()); i<(unsigned int)ceil(bbox.getBottom()); ++i){ - for(unsigned int j=(unsigned int)floor(bbox.getLeft()); j<(unsigned int)ceil(bbox.getRight()); ++j){ - if(p4.isInside(vpImagePoint(i, j))){ - vpDisplay::displayPoint(I, vpImagePoint(i, j), vpColor::orange); + if (opt_click) + vpDisplay::getClick(I); + + + vpDisplay::display(I); + vpDisplay::displayCharString(I, vpImagePoint(10, 10), "Left click to add a point", vpColor::red); + vpDisplay::displayCharString(I, vpImagePoint(20, 10), "Right click to build the polygon", vpColor::red); + vpDisplay::flush(I); + if (opt_click) { + vpPolygon p4; + p4.initClick(I); + p4.display(I, vpColor::green, 1); + std::cout << std::endl; + std::cout << " Polygon 4 : " << std::endl; + std::cout << " area : " << p4.getArea() << std::endl; + std::cout << " center : " << p4.getCenter() << std::endl; + std::cout << "Click to continue." << std::endl; + vpDisplay::flush(I); + vpDisplay::getClick(I); + + vpRect bbox = p4.getBoundingBox(); + for(unsigned int i= (unsigned int)floor(bbox.getTop()); i<(unsigned int)ceil(bbox.getBottom()); ++i){ + for(unsigned int j=(unsigned int)floor(bbox.getLeft()); j<(unsigned int)ceil(bbox.getRight()); ++j){ + if(p4.isInside(vpImagePoint(i, j))){ + vpDisplay::displayPoint(I, vpImagePoint(i, j), vpColor::orange); + } } } - } - vpDisplay::flush(I); - std::cout << "Click to finish." << std::endl; + vpDisplay::flush(I); + std::cout << "Click to finish." << std::endl; - vpDisplay::getClick(I); + vpDisplay::getClick(I); + } } - } - return 0; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } diff --git a/test/tools/time/CMakeLists.txt b/test/tools/time/CMakeLists.txt index 189f0140d23a01ae49fcaf2050b66ac422c6c848..655203e61668efd968916661b14f8b7d8969c722 100644 --- a/test/tools/time/CMakeLists.txt +++ b/test/tools/time/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/test/tools/time/testTime.cpp b/test/tools/time/testTime.cpp index b9665a1fe8b62ae9bde1885123e9d4cb969337e6..259d9e602343d202f0cbca25732466deefd42428 100644 --- a/test/tools/time/testTime.cpp +++ b/test/tools/time/testTime.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testTime.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testTime.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -47,9 +47,9 @@ */ #include <visp/vpConfig.h> -#if defined UNIX +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX # include <unistd.h> -#elif defined WIN32 +#elif defined(_WIN32) # include <windows.h> # include <mmsystem.h> # include <winbase.h> @@ -61,7 +61,8 @@ #include <visp/vpTime.h> #include <visp/vpParseArgv.h> - +void usage(const char *name, const char *badparam); +bool getOptions(int argc, const char **argv); // List of allowed command line options #define GETOPTARGS "h" @@ -96,15 +97,15 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + 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); + usage(argv[0], optarg_); return false; break; } } @@ -113,7 +114,7 @@ bool getOptions(int argc, const char **argv) // standalone param or error usage(argv[0], NULL); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -124,65 +125,71 @@ bool getOptions(int argc, const char **argv) int main(int argc, const char ** argv) { - // Read the command line options - if (getOptions(argc, argv) == false) { - exit (-1); - } + try { + // Read the command line options + if (getOptions(argc, argv) == false) { + exit (-1); + } - double v = 0; + double v = 0; - double t0 = vpTime::measureTimeMs(); - for (int i =0 ; i < 100000; i ++) - for (int j =0 ; j < 100; j ++) - v = i * 2 / 3. + j; - std::cout << "Computed dummy value: " << v << std::endl; + double t0 = vpTime::measureTimeMs(); + for (int i =0 ; i < 100000; i ++) + for (int j =0 ; j < 100; j ++) + v = i * 2 / 3. + j; + std::cout << "Computed dummy value: " << v << std::endl; - double t1 = vpTime::measureTimeMs(); - vpTime::wait(t1, 40); + double t1 = vpTime::measureTimeMs(); + vpTime::wait(t1, 40); - double t2 = vpTime::measureTimeMs(); + double t2 = vpTime::measureTimeMs(); - // Sleep 10ms -#if defined UNIX - usleep(10*1000); -#elif defined WIN32 - Sleep(10); + // Sleep 10ms +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX + usleep(10*1000); +#elif defined(_WIN32) + Sleep(10); #endif - double t3 = vpTime::measureTimeMs(); + double t3 = vpTime::measureTimeMs(); - // Sleep 2ms -#if defined UNIX - usleep(2*1000); -#elif defined WIN32 - Sleep(2); + // Sleep 2ms +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX + usleep(2*1000); +#elif defined(_WIN32) + Sleep(2); #endif - double t4 = vpTime::measureTimeMs(); + double t4 = vpTime::measureTimeMs(); - vpTime::wait(t4, 19); + vpTime::wait(t4, 19); - double t5 = vpTime::measureTimeMs(); + double t5 = vpTime::measureTimeMs(); - vpTime::wait(5); + vpTime::wait(5); - double t6 = vpTime::measureTimeMs(); + double t6 = vpTime::measureTimeMs(); - vpTime::wait(21); + vpTime::wait(21); - double t7 = vpTime::measureTimeMs(); + double t7 = vpTime::measureTimeMs(); - vpTime::wait(2); + vpTime::wait(2); - double t8 = vpTime::measureTimeMs(); + double t8 = vpTime::measureTimeMs(); - std::cout << "t1-t0: computation time: " << t1 - t0 << std::endl; - std::cout << "t2-t1: wait(t1, 40 ms): " << t2 - t1 << std::endl; - std::cout << "t3-t2: sleep(10 ms): " << t3 - t2 << std::endl; - std::cout << "t4-t3: sleep(2 ms): " << t4 - t3 << std::endl; - std::cout << "t5-t4: wait(t, 19 ms): " << t5 - t4 << std::endl; - std::cout << "t6-t5: wait(5 ms): " << t6 - t5 << std::endl; - std::cout << "t7-t6: wait(21 ms): " << t7 - t6 << std::endl; - std::cout << "t8-t7: wait(2 ms): " << t8 - t7 << std::endl; + std::cout << "t1-t0: computation time: " << t1 - t0 << std::endl; + std::cout << "t2-t1: wait(t1, 40 ms): " << t2 - t1 << std::endl; + std::cout << "t3-t2: sleep(10 ms): " << t3 - t2 << std::endl; + std::cout << "t4-t3: sleep(2 ms): " << t4 - t3 << std::endl; + std::cout << "t5-t4: wait(t, 19 ms): " << t5 - t4 << std::endl; + std::cout << "t6-t5: wait(5 ms): " << t6 - t5 << std::endl; + std::cout << "t7-t6: wait(21 ms): " << t7 - t6 << std::endl; + std::cout << "t8-t7: wait(2 ms): " << t8 - t7 << std::endl; - return 0; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } diff --git a/test/tools/xml/CMakeLists.txt b/test/tools/xml/CMakeLists.txt index 4a1b57aa8a92fa1b3efa3741b45bae595a07a651..deb112f53eb25b9b3336605496f881ceccbe25b8 100644 --- a/test/tools/xml/CMakeLists.txt +++ b/test/tools/xml/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/test/tools/xml/testXmlParser.cpp b/test/tools/xml/testXmlParser.cpp index 1d725605e6adccaf65f7116ed66ff12597af167c..18a1e5ca342756bf9cdbaca03f51265bc64e942a 100755 --- a/test/tools/xml/testXmlParser.cpp +++ b/test/tools/xml/testXmlParser.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testXmlParser.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testXmlParser.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -212,6 +212,9 @@ vpExampleDataParser::writeMainClass(xmlNodePtr node) // List of allowed command line options #define GETOPTARGS "o:h" +void usage(const char *name, const char *badparam, const std::string& opath, const std::string& user); +bool getOptions(int argc, const char **argv, std::string &opath, const std::string& user); + /*! Print the program options. @@ -225,25 +228,23 @@ Print the program options. void usage(const char *name, const char *badparam, const std::string& opath, const std::string& user) { fprintf(stdout, "\n\ - Write and read data in a xml file.\n\ +Write and read data in a xml file.\n\ \n\ - SYNOPSIS\n\ - %s [-o <output image path>] [-h]\n \ - ", name); - - fprintf(stdout, "\n\ - OPTIONS: Default\n\ - -o <output data path> %s\n\ - Set data output path.\n\ - From this directory, creates the \"%s\"\n\ - subdirectory depending on the username, where \n\ - dataTestXml.xml file is written.\n\ +SYNOPSIS\n\ + %s [-o <output image path>] [-h]\n", name); + + fprintf(stdout, "\n\ +OPTIONS: Default\n\ + -o <output data path> %s\n\ + Set data output path.\n\ + From this directory, creates the \"%s\"\n\ + subdirectory depending on the username, where \n\ + dataTestXml.xml file is written.\n\ \n\ - -h\n\ - Print the help.\n\n", - opath.c_str(), user.c_str()); + -h\n\ + Print the help.\n\n", opath.c_str(), user.c_str()); - if (badparam) { + if (badparam) { fprintf(stderr, "ERROR: \n" ); fprintf(stderr, "\nBad parameter [%s]\n", badparam); } @@ -258,19 +259,18 @@ void usage(const char *name, const char *badparam, const std::string& opath, con \param user : Username. \return false if the program has to be stopped, true otherwise. */ -bool getOptions(int argc, const char **argv, - std::string &opath, const std::string& user) +bool getOptions(int argc, const char **argv, std::string &opath, const std::string& user) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { - case 'o': opath = optarg; break; + case 'o': opath = optarg_; break; case 'h': usage(argv[0], NULL, opath, user); return false; break; default: - usage(argv[0], optarg, opath, user); return false; break; + usage(argv[0], optarg_, opath, user); return false; break; } } @@ -278,7 +278,7 @@ bool getOptions(int argc, const char **argv, // standalone param or error usage(argv[0], NULL, opath, user); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -293,88 +293,93 @@ bool getOptions(int argc, const char **argv, int main(int argc, const char** argv) { - std::string opt_opath; - std::string opath; - std::string filename; - std::string username; - - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << " testXmlParser.cpp" <<std::endl << std::endl ; - std::cout << " writing and readind data using a xml parser" << std::endl ; - std::cout << "-------------------------------------------------------" << std::endl ; - std::cout << std::endl ; - - // Set the default output path -#ifdef UNIX - opt_opath = "/tmp"; -#elif WIN32 - opt_opath = "C:\\temp"; + try { + std::string opt_opath; + std::string opath; + std::string filename; + std::string username; + + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << " testXmlParser.cpp" <<std::endl << std::endl ; + std::cout << " writing and readind data using a xml parser" << std::endl ; + std::cout << "-------------------------------------------------------" << std::endl ; + std::cout << std::endl ; + + // Set the default output path +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX + opt_opath = "/tmp"; +#elif defined(_WIN32) + opt_opath = "C:\\temp"; #endif - // Get the user login name - vpIoTools::getUserName(username); + // Get the user login name + vpIoTools::getUserName(username); - // Read the command line options - if (getOptions(argc, argv, opt_opath, username) == false) { - exit (-1); - } + // Read the command line options + if (getOptions(argc, argv, opt_opath, username) == false) { + exit (-1); + } + + // Get the option values + if (!opt_opath.empty()) + opath = opt_opath; + + // Append to the output path string, the login name of the user + std::string dirname = opath + vpIoTools::path("/") + username; + + // Test if the output path exist. If no try to create it + if (vpIoTools::checkDirectory(dirname) == false) { + try { + // Create the dirname + vpIoTools::makeDirectory(dirname); + } + catch (...) { + usage(argv[0], NULL, opath, username); + std::cerr << std::endl + << "ERROR:" << std::endl; + std::cerr << " Cannot create " << dirname << std::endl; + std::cerr << " Check your -o " << opath << " option " << std::endl; + exit(-1); + } + } + + filename = dirname + vpIoTools::path("/") + "dataTestXml.xml"; - // Get the option values - if (!opt_opath.empty()) - opath = opt_opath; + // Write data using a parser. + { + vpExampleDataParser parser1; - // Append to the output path string, the login name of the user - std::string dirname = opath + vpIoTools::path("/") + username; + // Acquire data from measurments or tests. + parser1.setRange(3.5); + parser1.setStep(2); + parser1.setSizeFilter(5); + parser1.setName("cube"); - // Test if the output path exist. If no try to create it - if (vpIoTools::checkDirectory(dirname) == false) { - try { - // Create the dirname - vpIoTools::makeDirectory(dirname); + std::cout << "Write data to " << filename << std::endl; + parser1.save(filename); } - catch (...) { - usage(argv[0], NULL, opath, username); - std::cerr << std::endl - << "ERROR:" << std::endl; - std::cerr << " Cannot create " << dirname << std::endl; - std::cerr << " Check your -o " << opath << " option " << std::endl; - exit(-1); + + // Read data using another parser. + { + vpExampleDataParser parser2; + + parser2.parse(filename); + + std::cout << "Read from " << filename << std::endl ; + std::cout << "Range : " << parser2.getRange() << std::endl; + std::cout << "Step : " << parser2.getStep() << std::endl; + std::cout << "Filter size : " << parser2.getSizeFilter() << std::endl; + std::cout << "name : " << parser2.getName() << std::endl; } - } - filename = dirname + vpIoTools::path("/") + "dataTestXml.xml"; - - // Write data using a parser. - { - vpExampleDataParser parser1; - - // Acquire data from measurments or tests. - parser1.setRange(3.5); - parser1.setStep(2); - parser1.setSizeFilter(5); - parser1.setName("cube"); - - std::cout << "Write data to " << filename << std::endl; - parser1.save(filename); + // Clean up memory allocated by the xml library + vpXmlParser::cleanup(); + return 0; } - - // Read data using another parser. - { - vpExampleDataParser parser2; - - parser2.parse(filename); - - std::cout << "Read from " << filename << std::endl ; - std::cout << "Range : " << parser2.getRange() << std::endl; - std::cout << "Step : " << parser2.getStep() << std::endl; - std::cout << "Filter size : " << parser2.getSizeFilter() << std::endl; - std::cout << "name : " << parser2.getName() << std::endl; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - - // Clean up memory allocated by the xml library - vpXmlParser::cleanup(); - - return 0; } #else diff --git a/test/tracking/CMakeLists.txt b/test/tracking/CMakeLists.txt index 43a83546ea981e97418e5e21dfcd55f2943340a4..a6170f72921e4a50cbd7b0c6dd67152c1f1613e4 100644 --- a/test/tracking/CMakeLists.txt +++ b/test/tracking/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/test/tracking/testTrackDot.cpp b/test/tracking/testTrackDot.cpp index 1f527e5ed66d858c9093b54d00e6aa5ca2bde507..ba8eb0eeb371609aa4261dc0653880d4b6b131da 100644 --- a/test/tracking/testTrackDot.cpp +++ b/test/tracking/testTrackDot.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testTrackDot.cpp 4323 2013-07-18 09:24:01Z fspindle $ + * $Id: testTrackDot.cpp 4658 2014-02-09 09:50:14Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -55,7 +55,7 @@ #include <visp/vpDisplayX.h> #include <visp/vpDisplayGTK.h> #include <visp/vpDisplayGDI.h> -#include <visp/vpDot.h> +#include <visp/vpDot2.h> #include <visp/vpFeatureEllipse.h> #include <visp/vpCameraParameters.h> #include <visp/vpFeatureBuilder.h> @@ -71,6 +71,10 @@ // List of allowed command line options #define GETOPTARGS "cdi:h" +bool getOptions(int argc, const char **argv, std::string &ipath, + bool &click_allowed, bool &display); + +void usage(const char *name, const char *badparam, std::string ipath); /*! Print the program options. @@ -128,18 +132,18 @@ OPTIONS: Default\n\ bool getOptions(int argc, const char **argv, std::string &ipath, bool &click_allowed, bool &display) { - const char *optarg; + const char *optarg_; int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { switch (c) { case 'c': click_allowed = false; break; case 'd': display = false; break; - case 'i': ipath = optarg; break; + case 'i': ipath = optarg_; break; case 'h': usage(argv[0], NULL, ipath); return false; break; default: - usage(argv[0], optarg, ipath); + usage(argv[0], optarg_, ipath); return false; break; } } @@ -148,7 +152,7 @@ bool getOptions(int argc, const char **argv, std::string &ipath, // standalone param or error usage(argv[0], NULL, ipath); std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg << std::endl << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; return false; } @@ -159,107 +163,107 @@ bool getOptions(int argc, const char **argv, std::string &ipath, int main(int argc, const char ** argv) { - std::string env_ipath; - std::string opt_ipath; - std::string ipath; - std::string dirname; - std::string filename; - bool opt_click_allowed = true; - 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_click_allowed, opt_display) == false) { - exit (-1); - } + try { + std::string env_ipath; + std::string opt_ipath; + std::string ipath; + std::string dirname; + std::string filename; + bool opt_click_allowed = true; + 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_click_allowed, 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 <visp image path=" << ipath << "> " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + // 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 <visp image path=" << ipath << "> " + << " 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 <visp image path> 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); - } + // 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 <visp image path> 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); + } - // 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<unsigned char> I ; + // 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<unsigned char> I ; - // Set the path location of the image sequence - dirname = ipath + vpIoTools::path("/ViSP-images/ellipse/"); + // Set the path location of the image sequence + dirname = ipath + vpIoTools::path("/ViSP-images/ellipse/"); - // Build the name of the image file - filename = dirname + "ellipse.pgm"; + // Build the name of the image file + filename = dirname + "ellipse.pgm"; - // 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; + // 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; - vpImageIo::read(I, filename) ; - } - catch(...) - { - // an exception is throwned if an exception from readPGM has been catched - // 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); - } + vpImageIo::read(I, filename) ; + } + catch(...) + { + // an exception is throwned if an exception from readPGM has been catched + // 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); + } - // We open a window using either X11, GTK or GDI. + // We open a window using either X11, GTK or GDI. #if defined VISP_HAVE_X11 - vpDisplayX display; + vpDisplayX display; #elif defined VISP_HAVE_GTK - vpDisplayGTK display; + vpDisplayGTK display; #elif defined VISP_HAVE_GDI - vpDisplayGDI display; + vpDisplayGDI display; #endif - if (opt_display) { - try{ + if (opt_display) { // Display size is automatically defined by the image (I) size display.init(I, 100, 100,"Display...") ; // Display the image @@ -271,38 +275,40 @@ main(int argc, const char ** argv) //Flush the display vpDisplay::flush(I) ; } - catch(...) - { - vpERROR_TRACE("Error while displaying the image") ; - exit(-1); - } - } - vpDot dot ; - dot.setMaxDotSize(0.50); // dot max size = 50% of the image size - vpImagePoint ip; - ip.set_i( 140 ); - ip.set_j( 140 ); - dot.initTracking(I, ip) ; - if (opt_display) { - dot.setGraphics(true) ; - } - else { - dot.setGraphics(false) ; - } - dot.setComputeMoments(true) ; - dot.track(I) ; - - vpFeatureEllipse e ; - - vpCameraParameters cam ; - vpFeatureBuilder::create(e,cam,dot) ; - if (opt_display) { - e.display(cam, I, vpColor::red) ; - if (opt_click_allowed) { - std::cout << "A click to exit..." << std::endl; - vpDisplay::getClick(I) ; + vpDot2 dot ; + std::cout << "debut 1\n"; + //dot.setMaxDotSize(0.50); // dot max size = 50% of the image size + vpImagePoint ip; + ip.set_i( 140 ); + ip.set_j( 140 ); + dot.initTracking(I, ip); + if (opt_display) { + dot.setGraphics(true) ; } + else { + dot.setGraphics(false) ; + } + dot.setComputeMoments(true); + dot.track(I) ; + + vpFeatureEllipse e ; + + vpCameraParameters cam ; + vpFeatureBuilder::create(e,cam,dot) ; + if (opt_display) { + e.display(cam, I, vpColor::red) ; + vpDisplay::flush(I); + if (opt_click_allowed) { + std::cout << "A click to exit..." << std::endl; + vpDisplay::getClick(I) ; + } + } + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } } #else diff --git a/test/visual-feature/CMakeLists.txt b/test/visual-feature/CMakeLists.txt index 5b1c83e7319c6eafb0e5bbd4c59181723fa76b14..f62c16b81157afd9cebde84e4bc8972f90548138 100755 --- a/test/visual-feature/CMakeLists.txt +++ b/test/visual-feature/CMakeLists.txt @@ -1,9 +1,9 @@ ############################################################################# # -# $Id: CMakeLists.txt 4056 2013-01-05 13:04:42Z fspindle $ +# $Id: CMakeLists.txt 4574 2014-01-09 08:48:51Z fspindle $ # # This file is part of the ViSP software. -# Copyright (C) 2005 - 2013 by INRIA. All rights reserved. +# Copyright (C) 2005 - 2014 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 diff --git a/test/visual-feature/testFeature.cpp b/test/visual-feature/testFeature.cpp index c6fe49d0f624308e85b8ca9ef3d44970a3853a50..cd8a2cc8877fa99b69f51f174fbc2f8c28a5ab3f 100644 --- a/test/visual-feature/testFeature.cpp +++ b/test/visual-feature/testFeature.cpp @@ -1,9 +1,9 @@ /**************************************************************************** * - * $Id: testFeature.cpp 4056 2013-01-05 13:04:42Z fspindle $ + * $Id: testFeature.cpp 4574 2014-01-09 08:48:51Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -96,8 +96,8 @@ int main() } return 0; } - catch(vpServoException e) { - std::cout << e << std::endl; - return -1; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } } diff --git a/test/visual-feature/testFeatureMoment.cpp b/test/visual-feature/testFeatureMoment.cpp index fd5f8b52dfff6a968aa1b8f911f37f41956d65d9..cfd2ada0b59199af3e3f87842068fbcfcfe7208a 100644 --- a/test/visual-feature/testFeatureMoment.cpp +++ b/test/visual-feature/testFeatureMoment.cpp @@ -3,7 +3,7 @@ * $Id: testFeatureMoment.cpp 3323 2011-09-13 15:23:56Z fnovotny $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -51,43 +51,36 @@ #include <iostream> //initialize scene in the interface -void initScene(); +void initScene(const vpHomogeneousMatrix& cMo, const vpHomogeneousMatrix& cdMo, + vpMomentObject &src, vpMomentObject &dst); -void init(vpHomogeneousMatrix& cMo, vpHomogeneousMatrix& cdMo); -vpMatrix execute(); //launch the test -void _planeToABC(vpPlane& pl, double& A,double& B, double& C); +vpMatrix execute(const vpHomogeneousMatrix& cMo, const vpHomogeneousMatrix& cdMo, + vpMomentObject &src, vpMomentObject &dst); //launch the test +void planeToABC(const vpPlane& pl, double& A,double& B, double& C); int test(double x,double y,double z,double alpha); -//start and destination positioning matrices -vpHomogeneousMatrix cMo; -vpHomogeneousMatrix cdMo; - -vpServo::vpServoIteractionMatrixType interaction_type; //current or desired - -//source and destination objects for moment manipulation -vpMomentObject src(6); -vpMomentObject dst(6); - -using namespace std; - //Compute a set of parallel positions and check if the matrix is in the right form; int main() { - int sum=0; - for(double i=-0.2;i<0.2;i+=0.1){ - for(double j=-0.2;j<0.2;j+=0.1){ - for(double k=-vpMath::rad(30);k<vpMath::rad(30);k+=vpMath::rad(10)){ - for(double l=0.5;l<1.5;l+=0.1){ - sum+=test(i,j,l,k); + try { + int sum=0; + for(double i=-0.2;i<0.2;i+=0.1){ + for(double j=-0.2;j<0.2;j+=0.1){ + for(double k=-vpMath::rad(30);k<vpMath::rad(30);k+=vpMath::rad(10)){ + for(double l=0.5;l<1.5;l+=0.1){ + sum+=test(i,j,l,k); + } } - } + } } + if(sum<0) return -1; + else return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; } - - - if(sum<0) return -1; - else return 0; } int test(double x,double y,double z,double alpha){ @@ -96,48 +89,51 @@ int test(double x,double y,double z,double alpha){ //Desired pose vpHomogeneousMatrix cdMo(vpHomogeneousMatrix(0.0,0.0,1.0,vpMath::rad(0),vpMath::rad(0),-vpMath::rad(0))); + //source and destination objects for moment manipulation + vpMomentObject src(6); + vpMomentObject dst(6); + //init and run the simulation - init(cMo,cdMo); - vpMatrix mat = execute(); + initScene(cMo, cdMo, src, dst); //initialize graphical scene (for interface) + + vpMatrix mat = execute(cMo, cdMo, src, dst); - if(fabs(mat[0][0]-(-1)) > numeric_limits<double>::epsilon()*1e10) return -1; - if(fabs(mat[0][1]-(0)) > numeric_limits<double>::epsilon()*1e10) return -1; - if(fabs(mat[0][2]-(0)) > numeric_limits<double>::epsilon()*1e10) return -1; + if(fabs(mat[0][0]-(-1)) > std::numeric_limits<double>::epsilon()*1e10) return -1; + if(fabs(mat[0][1]-(0)) > std::numeric_limits<double>::epsilon()*1e10) return -1; + if(fabs(mat[0][2]-(0)) > std::numeric_limits<double>::epsilon()*1e10) return -1; - if(fabs(mat[1][0]-(0)) > numeric_limits<double>::epsilon()*1e10) return -1; - if(fabs(mat[1][1]-(-1)) > numeric_limits<double>::epsilon()*1e10) return -1; - if(fabs(mat[1][2]-(0)) > numeric_limits<double>::epsilon()*1e10) return -1; + if(fabs(mat[1][0]-(0)) > std::numeric_limits<double>::epsilon()*1e10) return -1; + if(fabs(mat[1][1]-(-1)) > std::numeric_limits<double>::epsilon()*1e10) return -1; + if(fabs(mat[1][2]-(0)) > std::numeric_limits<double>::epsilon()*1e10) return -1; - if(fabs(mat[2][0]-(0)) > numeric_limits<double>::epsilon()*1e10) return -1; - if(fabs(mat[2][1]-(0)) > numeric_limits<double>::epsilon()*1e10) return -1; - if(fabs(mat[2][2]-(-1)) > numeric_limits<double>::epsilon()*1e10) return -1; - if(fabs(mat[2][5]-(0)) > numeric_limits<double>::epsilon()*1e10) return -1; + if(fabs(mat[2][0]-(0)) > std::numeric_limits<double>::epsilon()*1e10) return -1; + if(fabs(mat[2][1]-(0)) > std::numeric_limits<double>::epsilon()*1e10) return -1; + if(fabs(mat[2][2]-(-1)) > std::numeric_limits<double>::epsilon()*1e10) return -1; + if(fabs(mat[2][5]-(0)) > std::numeric_limits<double>::epsilon()*1e10) return -1; - if(fabs(mat[3][0]-(0)) > numeric_limits<double>::epsilon()*1e10) return -1; - if(fabs(mat[3][1]-(0)) > numeric_limits<double>::epsilon()*1e10) return -1; - if(fabs(mat[3][2]-(0)) > numeric_limits<double>::epsilon()*1e10) return -1; - if(fabs(mat[3][5]-(0)) > numeric_limits<double>::epsilon()*1e10) return -1; + if(fabs(mat[3][0]-(0)) > std::numeric_limits<double>::epsilon()*1e10) return -1; + if(fabs(mat[3][1]-(0)) > std::numeric_limits<double>::epsilon()*1e10) return -1; + if(fabs(mat[3][2]-(0)) > std::numeric_limits<double>::epsilon()*1e10) return -1; + if(fabs(mat[3][5]-(0)) > std::numeric_limits<double>::epsilon()*1e10) return -1; - if(fabs(mat[4][0]-(0)) > numeric_limits<double>::epsilon()*1e10) return -1; - if(fabs(mat[4][1]-(0)) > numeric_limits<double>::epsilon()*1e10) return -1; - if(fabs(mat[4][2]-(0)) > numeric_limits<double>::epsilon()*1e10) return -1; - if(fabs(mat[4][5]-(0)) > numeric_limits<double>::epsilon()*1e10) return -1; + if(fabs(mat[4][0]-(0)) > std::numeric_limits<double>::epsilon()*1e10) return -1; + if(fabs(mat[4][1]-(0)) > std::numeric_limits<double>::epsilon()*1e10) return -1; + if(fabs(mat[4][2]-(0)) > std::numeric_limits<double>::epsilon()*1e10) return -1; + if(fabs(mat[4][5]-(0)) > std::numeric_limits<double>::epsilon()*1e10) return -1; - if(fabs(mat[5][0]-(0)) > numeric_limits<double>::epsilon()*1e10) return -1; - if(fabs(mat[5][1]-(0)) > numeric_limits<double>::epsilon()*1e10) return -1; - if(fabs(mat[5][2]-(0)) > numeric_limits<double>::epsilon()*1e10) return -1; - if(fabs(mat[5][5]-(-1)) > numeric_limits<double>::epsilon()*1e10) return -1; + if(fabs(mat[5][0]-(0)) > std::numeric_limits<double>::epsilon()*1e10) return -1; + if(fabs(mat[5][1]-(0)) > std::numeric_limits<double>::epsilon()*1e10) return -1; + if(fabs(mat[5][2]-(0)) > std::numeric_limits<double>::epsilon()*1e10) return -1; + if(fabs(mat[5][5]-(-1)) > std::numeric_limits<double>::epsilon()*1e10) return -1; return 0; } - - - - -void initScene(){ - vector<vpPoint> src_pts; - vector<vpPoint> dst_pts; +void initScene(const vpHomogeneousMatrix& cMo, const vpHomogeneousMatrix& cdMo, + vpMomentObject &src, vpMomentObject &dst) +{ + std::vector<vpPoint> src_pts; + std::vector<vpPoint> 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 }; @@ -160,21 +156,14 @@ void initScene(){ } dst.setType(vpMomentObject::DENSE_POLYGON); dst.fromVector(dst_pts); - } -void init(vpHomogeneousMatrix& _cMo, vpHomogeneousMatrix& _cdMo) +vpMatrix execute(const vpHomogeneousMatrix& cMo, const vpHomogeneousMatrix& cdMo, + vpMomentObject &src, vpMomentObject &dst) { - cMo = _cMo; - cdMo = _cdMo; - interaction_type = vpServo::CURRENT; + vpServo::vpServoIteractionMatrixType interaction_type = vpServo::CURRENT; ; //current or desired - - initScene(); //initialize graphical scene (for interface) -} - -vpMatrix execute(){ vpServo task; task.setServo(vpServo::EYEINHAND_CAMERA); //A,B,C parameters of source and destination plane @@ -186,11 +175,11 @@ vpMatrix execute(){ vpPlane pl; pl.setABCD(0,0,1.0,0); pl.changeFrame(cMo); - _planeToABC(pl,A,B,C); + planeToABC(pl,A,B,C); pl.setABCD(0,0,1.0,0); pl.changeFrame(cdMo); - _planeToABC(pl,Ad,Bd,Cd); + planeToABC(pl,Ad,Bd,Cd); //extracting initial position (actually we only care about Zdst) vpTranslationVector vec; @@ -228,8 +217,8 @@ vpMatrix execute(){ } -void _planeToABC(vpPlane& pl, double& A,double& B, double& C){ - +void planeToABC(const vpPlane& pl, double& A,double& B, double& C) +{ A=-pl.getA()/pl.getD(); B=-pl.getB()/pl.getD(); C=-pl.getC()/pl.getD(); diff --git a/test/visual-feature/testFeatureSegment.cpp b/test/visual-feature/testFeatureSegment.cpp index aef937bf031bb6408b226d7390bc1e27959b7318..d82915a6f2dd2e726966f04a0c5b109aaf2908b4 100644 --- a/test/visual-feature/testFeatureSegment.cpp +++ b/test/visual-feature/testFeatureSegment.cpp @@ -3,7 +3,7 @@ * $Id: testFeature.cpp 3530 2012-01-03 10:52:12Z fspindle $ * * This file is part of the ViSP software. - * Copyright (C) 2005 - 2013 by INRIA. All rights reserved. + * Copyright (C) 2005 - 2014 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 @@ -69,19 +69,20 @@ */ int main(int argc, const char **argv) { + try { #if (defined (VISP_HAVE_X11) || defined (VISP_HAVE_GDI)) - int opt_display = 1; - int opt_curves = 1; + int opt_display = 1; + int opt_curves = 1; #endif - int opt_normalized = 1; + int opt_normalized = 1; - // Parse the command line to set the variables - vpParseArgv::vpArgvInfo argTable[] = + // Parse the command line to set the variables + vpParseArgv::vpArgvInfo argTable[] = { - #if (defined (VISP_HAVE_X11) || defined (VISP_HAVE_GDI)) + #if (defined (VISP_HAVE_X11) || defined (VISP_HAVE_GDI)) {"-d", vpParseArgv::ARGV_CONSTANT, 0, (char *) &opt_display, "Disable display and graphics viewer."}, - #endif + #endif {"-normalized", vpParseArgv::ARGV_INT, (char*) NULL, (char *) &opt_normalized, "1 to use normalized features, 0 for non normalized."}, {"-h", vpParseArgv::ARGV_HELP, (char*) NULL, (char *) NULL, @@ -89,128 +90,86 @@ int main(int argc, const char **argv) {(char*) NULL, vpParseArgv::ARGV_END, (char*) NULL, (char*) NULL, (char*) NULL} } ; - // Read the command line options - if(vpParseArgv::parse(&argc, argv, argTable, - vpParseArgv::ARGV_NO_LEFTOVERS | - vpParseArgv::ARGV_NO_ABBREV | - vpParseArgv::ARGV_NO_DEFAULTS)) { - return (false); - } + // Read the command line options + if(vpParseArgv::parse(&argc, argv, argTable, + vpParseArgv::ARGV_NO_LEFTOVERS | + vpParseArgv::ARGV_NO_ABBREV | + vpParseArgv::ARGV_NO_DEFAULTS)) { + return (false); + } - std::cout << "Used options: " << std::endl; + std::cout << "Used options: " << std::endl; #if (defined (VISP_HAVE_X11) || defined (VISP_HAVE_GDI)) - opt_curves = opt_display; - std::cout << " - display : " << opt_display << std::endl; - std::cout << " - curves : " << opt_curves << std::endl; + opt_curves = opt_display; + std::cout << " - display : " << opt_display << std::endl; + std::cout << " - curves : " << opt_curves << std::endl; #endif - std::cout << " - normalized: " << opt_normalized << std::endl; + std::cout << " - normalized: " << opt_normalized << std::endl; - vpCameraParameters cam(640.,480.,320.,240.); + vpCameraParameters cam(640.,480.,320.,240.); #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) - vpDisplay *display = NULL; - if (opt_display) { + vpDisplay *display = NULL; + if (opt_display) { #if defined(VISP_HAVE_X11) - display = new vpDisplayX; + display = new vpDisplayX; #elif defined VISP_HAVE_GDI - display = new vpDisplayGDI; + display = new vpDisplayGDI; #endif - } + } #endif - vpImage<unsigned char> I(480,640,0); + vpImage<unsigned char> I(480,640,0); #if (defined (VISP_HAVE_X11) || defined (VISP_HAVE_GDI)) - if (opt_display) - display->init(I); + if (opt_display) + display->init(I); #endif - vpHomogeneousMatrix cMo (-0.5, 0.5, 4., vpMath::rad(10), vpMath::rad(20), vpMath::rad(90)); - vpHomogeneousMatrix cdMo(0., 0., 1., vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); + vpHomogeneousMatrix cMo (-0.5, 0.5, 4., vpMath::rad(10), vpMath::rad(20), vpMath::rad(90)); + vpHomogeneousMatrix cdMo(0., 0., 1., vpMath::rad(0), vpMath::rad(0), vpMath::rad(0)); - vpPoint P[4]; // 4 points in the object frame - P[0].setWorldCoordinates( .1, .1, 0.); - P[1].setWorldCoordinates(-.1, .1, 0.); - P[2].setWorldCoordinates(-.1, -.1, 0.); - P[3].setWorldCoordinates( .1, -.1, 0.); + vpPoint P[4]; // 4 points in the object frame + P[0].setWorldCoordinates( .1, .1, 0.); + P[1].setWorldCoordinates(-.1, .1, 0.); + P[2].setWorldCoordinates(-.1, -.1, 0.); + P[3].setWorldCoordinates( .1, -.1, 0.); - vpPoint Pd[4]; // 4 points in the desired camera frame - for (int i=0; i<4; i++) { - Pd[i] = P[i]; - Pd[i].project(cdMo); - } - vpPoint Pc[4]; // 4 points in the current camera frame - for (int i=0; i<4; i++) { - Pc[i] = P[i]; - Pc[i].project(cMo); - } - - vpFeatureSegment seg_cur[2], seg_des[2]; // Current and desired features - for (int i=0; i <2; i++) - { - if (opt_normalized) { - seg_cur[i].setNormalized(true); - seg_des[i].setNormalized(true); + vpPoint Pd[4]; // 4 points in the desired camera frame + for (int i=0; i<4; i++) { + Pd[i] = P[i]; + Pd[i].project(cdMo); } - else { - seg_cur[i].setNormalized(false); - seg_des[i].setNormalized(false); + vpPoint Pc[4]; // 4 points in the current camera frame + for (int i=0; i<4; i++) { + Pc[i] = P[i]; + Pc[i].project(cMo); } - vpFeatureBuilder::create(seg_cur[i], Pc[i*2], Pc[i*2+1]); - vpFeatureBuilder::create(seg_des[i], Pd[i*2], Pd[i*2+1]); - seg_cur[i].print(); - seg_des[i].print(); - } - - //define visual servoing task - vpServo task; - task.setServo(vpServo::EYEINHAND_CAMERA); - task.setInteractionMatrixType(vpServo::CURRENT); - task.setLambda(1) ; - - for (int i=0; i <2; i++) - task.addFeature(seg_cur[i], seg_des[i]); - -#if (defined (VISP_HAVE_X11) || defined(VISP_HAVE_GDI)) - if (opt_display) { - vpDisplay::display(I); - for (int i=0; i <2; i++) { - seg_cur[i].display(cam, I, vpColor::red); - seg_des[i].display(cam, I, vpColor::green); - vpDisplay::flush(I); + + vpFeatureSegment seg_cur[2], seg_des[2]; // Current and desired features + for (int i=0; i <2; i++) + { + if (opt_normalized) { + seg_cur[i].setNormalized(true); + seg_des[i].setNormalized(true); + } + else { + seg_cur[i].setNormalized(false); + seg_des[i].setNormalized(false); + } + vpFeatureBuilder::create(seg_cur[i], Pc[i*2], Pc[i*2+1]); + vpFeatureBuilder::create(seg_des[i], Pd[i*2], Pd[i*2+1]); + seg_cur[i].print(); + seg_des[i].print(); } - } -#endif - -#if (defined (VISP_HAVE_X11) || defined (VISP_HAVE_GDI)) - vpPlot *graph = NULL; - if (opt_curves) - { - //Create a window (700 by 700) at position (100, 200) with two graphics - graph = new vpPlot(2, 500, 500, 700, 10, "Curves..."); - - //The first graphic contains 3 curve and the second graphic contains 3 curves - graph->initGraph(0,6); - graph->initGraph(1,8); -// graph->setTitle(0, "Velocities"); -// graph->setTitle(1, "Error s-s*"); - } -#endif - //param robot - vpRobotCamera robot ; - float sampling_time = 0.010f ; // Sampling period in seconds - robot.setSamplingTime(sampling_time) ; - robot.setPosition(cMo) ; - int iter=0; - - do{ - double t = vpTime::measureTimeMs(); - robot.getPosition(cMo); - for (int i=0; i <4; i++) - Pc[i].project(cMo); + //define visual servoing task + vpServo task; + task.setServo(vpServo::EYEINHAND_CAMERA); + task.setInteractionMatrixType(vpServo::CURRENT); + task.setLambda(1) ; for (int i=0; i <2; i++) - vpFeatureBuilder::create(seg_cur[i], Pc[i*2], Pc[i*2+1]); + task.addFeature(seg_cur[i], seg_des[i]); #if (defined (VISP_HAVE_X11) || defined(VISP_HAVE_GDI)) if (opt_display) { @@ -223,34 +182,82 @@ int main(int argc, const char **argv) } #endif - vpColVector v = task.computeControlLaw(); - robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; - #if (defined (VISP_HAVE_X11) || defined (VISP_HAVE_GDI)) + vpPlot *graph = NULL; if (opt_curves) { - graph->plot(0, iter, v); // plot velocities applied to the robot - graph->plot(1, iter, task.getError()); // plot error vector + //Create a window (700 by 700) at position (100, 200) with two graphics + graph = new vpPlot(2, 500, 500, 700, 10, "Curves..."); + + //The first graphic contains 3 curve and the second graphic contains 3 curves + graph->initGraph(0,6); + graph->initGraph(1,8); + // graph->setTitle(0, "Velocities"); + // graph->setTitle(1, "Error s-s*"); } #endif - vpTime::wait(t, sampling_time * 1000); // Wait 10 ms - iter ++; - - } while(( task.getError() ).sumSquare() > 0.0005); - - // A call to kill() is requested here to destroy properly the current - // and desired feature lists. - task.kill(); + //param robot + vpRobotCamera robot ; + float sampling_time = 0.010f ; // Sampling period in seconds + robot.setSamplingTime(sampling_time) ; + robot.setPosition(cMo) ; + int iter=0; + + do{ + double t = vpTime::measureTimeMs(); + robot.getPosition(cMo); + for (int i=0; i <4; i++) + Pc[i].project(cMo); + + for (int i=0; i <2; i++) + vpFeatureBuilder::create(seg_cur[i], Pc[i*2], Pc[i*2+1]); + +#if (defined (VISP_HAVE_X11) || defined(VISP_HAVE_GDI)) + if (opt_display) { + vpDisplay::display(I); + for (int i=0; i <2; i++) { + seg_cur[i].display(cam, I, vpColor::red); + seg_des[i].display(cam, I, vpColor::green); + vpDisplay::flush(I); + } + } +#endif + + vpColVector v = task.computeControlLaw(); + robot.setVelocity(vpRobot::CAMERA_FRAME, v) ; + +#if (defined (VISP_HAVE_X11) || defined (VISP_HAVE_GDI)) + if (opt_curves) + { + graph->plot(0, iter, v); // plot velocities applied to the robot + graph->plot(1, iter, task.getError()); // plot error vector + } +#endif + + vpTime::wait(t, sampling_time * 1000); // Wait 10 ms + iter ++; + + } while(( task.getError() ).sumSquare() > 0.0005); + + // A call to kill() is requested here to destroy properly the current + // and desired feature lists. + task.kill(); #if (defined (VISP_HAVE_X11) || defined (VISP_HAVE_GDI)) - if (graph != NULL) - delete graph; + if (graph != NULL) + delete graph; #endif #if (defined (VISP_HAVE_X11) || defined (VISP_HAVE_GDI)) - if (opt_display && display != NULL) - delete display; + if (opt_display && display != NULL) + delete display; #endif - std::cout << "final error=" << ( task.getError() ).sumSquare() << std::endl; + std::cout << "final error=" << ( task.getError() ).sumSquare() << std::endl; + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } } diff --git a/tutorial/CMakeLists.txt b/tutorial/CMakeLists.txt index d713a785ab369f2d697f51f23ebadfa8746d5721..e89e18e3a248baa5ad76fdf7f3509c7f961cf3b4 100644 --- a/tutorial/CMakeLists.txt +++ b/tutorial/CMakeLists.txt @@ -2,15 +2,18 @@ project(ViSP-tutorial) cmake_minimum_required(VERSION 2.6) -subdirs(computer-vision) -subdirs(grabber) -subdirs(image) -subdirs(robot/pioneer) -subdirs(simulator/image) -subdirs(tracking/blob) -subdirs(tracking/keypoint) -subdirs(tracking/model-based/edges) -subdirs(tracking/model-based/hybrid) -subdirs(tracking/model-based/keypoint) -subdirs(tracking/moving-edges) -subdirs(visual-servo/ibvs) +add_subdirectory(computer-vision) +add_subdirectory(grabber) +add_subdirectory(image) +add_subdirectory(matching) +add_subdirectory(robot/pioneer) +add_subdirectory(simulator/image) +add_subdirectory(trace) +add_subdirectory(tracking/blob) +add_subdirectory(tracking/keypoint) +add_subdirectory(tracking/model-based/edges) +add_subdirectory(tracking/model-based/hybrid) +add_subdirectory(tracking/model-based/keypoint) +add_subdirectory(tracking/template-tracker) +add_subdirectory(tracking/moving-edges) +add_subdirectory(visual-servo/ibvs) diff --git a/tutorial/computer-vision/CMakeLists.txt b/tutorial/computer-vision/CMakeLists.txt index 83f990ddf34d465fb4b79f85260d25ba790a6246..002df71fd441250497904786467cae4d11d019cf 100644 --- a/tutorial/computer-vision/CMakeLists.txt +++ b/tutorial/computer-vision/CMakeLists.txt @@ -3,20 +3,19 @@ project(tutorial-computer-vision) cmake_minimum_required(VERSION 2.6) find_package(VISP REQUIRED) -if(VISP_FOUND) - include(${VISP_USE_FILE}) -endif(VISP_FOUND) -# build the examples -add_executable(tutorial-pose-from-points-image tutorial-pose-from-points-image.cpp) -add_executable(tutorial-pose-from-points-tracking tutorial-pose-from-points-tracking.cpp) +set(tutorial_cpp + tutorial-homography-from-points.cpp + tutorial-pose-from-points-image.cpp + tutorial-pose-from-points-tracking.cpp) -# copy the data -get_target_property(target_location tutorial-pose-from-points-image LOCATION) -get_filename_component(target_location "${target_location}" PATH) -set(data "${CMAKE_CURRENT_SOURCE_DIR}/square.pgm" ) -add_custom_command( - TARGET tutorial-pose-from-points-image - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy "${data}" "${target_location}" -) +set(tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/square.pgm" ) + +foreach(cpp ${tutorial_cpp}) + visp_add_target(${cpp}) +endforeach() + +# Copy the data files to the same location than the target +foreach(data ${tutorial_data}) + visp_copy_data(tutorial-pose-from-points-image.cpp ${data}) +endforeach() diff --git a/tutorial/computer-vision/tutorial-homography-from-points.cpp b/tutorial/computer-vision/tutorial-homography-from-points.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f4ca29a351200909034d434faa2fabeeee8180e5 --- /dev/null +++ b/tutorial/computer-vision/tutorial-homography-from-points.cpp @@ -0,0 +1,63 @@ +/*! \example tutorial-homography-from-points.cpp */ +#include <visp/vpHomography.h> +#include <visp/vpMeterPixelConversion.h> + +int main() +{ + double L = 0.1; + std::vector<vpPoint> oP(4); + oP[0].setWorldCoordinates( -L,-L, 0); + oP[1].setWorldCoordinates(2*L,-L, 0); + oP[2].setWorldCoordinates( L, 3*L, 0); + oP[3].setWorldCoordinates( -L, 4*L, 0); + + vpHomogeneousMatrix bMo(0.1, 0, 1, 0, vpMath::rad(15), 0); + vpHomogeneousMatrix aMb(0.2, -0.1, 0.1, vpMath::rad(-3), vpMath::rad(20), vpMath::rad(5)); + vpHomogeneousMatrix aMo = aMb*bMo; + + std::vector<vpPoint> aP(4), bP(4); + std::vector<double> xa(4), ya(4), xb(4), yb(4); + for(unsigned int i=0 ; i < 4; i++) + { + oP[i].project(aMo); + xa[i] = oP[i].get_x(); + ya[i] = oP[i].get_y(); + oP[i].project(bMo); + xb[i] = oP[i].get_x(); + yb[i] = oP[i].get_y(); + } + + vpHomography aHb ; + vpHomography::DLT(xb, yb, xa, ya, aHb, true); + std::cout << "Estimated homography using DLT:\n" << aHb/aHb[2][2] << std::endl; + + vpHomography::HLM(xb, yb, xa, ya, true, aHb); + std::cout << "Estimated homography using HLM:\n" << aHb/aHb[2][2] << std::endl; + + vpRotationMatrix aRb; + vpTranslationVector atb; + vpColVector n; + aHb.computeDisplacement(aRb, atb, n); + + std::cout << "\nEstimated displacement:" << std::endl; + std::cout << " atb: " << atb.t() << std::endl; + vpThetaUVector atub; + atub.buildFrom(aRb); + std::cout << " athetaub: "; + for(unsigned int i=0; i<3; i++) + std::cout << vpMath::deg(atub[i]) << " "; + std::cout << std::endl; + std::cout << " n: " << n.t() << std::endl; + + vpImagePoint iPa, iPb; + vpCameraParameters cam; + vpMeterPixelConversion::convertPoint(cam, xb[3], yb[3], iPb); + vpMeterPixelConversion::convertPoint(cam, xa[3], ya[3], iPa); + + std::cout << "Ground truth: Point 3 in pixels in frame b: " << iPb << std::endl; + std::cout << "Ground truth: Point 3 in pixels in frame a: " << iPa << std::endl; + + // Project the position in pixel of point 3 from the homography + std::cout << "Estimation from homography: Point 3 in pixels in frame a: " + << vpHomography::project(cam, aHb, iPb) << std::endl; +} diff --git a/tutorial/computer-vision/tutorial-pose-from-points-image.cpp b/tutorial/computer-vision/tutorial-pose-from-points-image.cpp index b310f50062f3363b01a08700562840101f323ec1..2ed43da571409fb5943668a93238f78470a26d20 100644 --- a/tutorial/computer-vision/tutorial-pose-from-points-image.cpp +++ b/tutorial/computer-vision/tutorial-pose-from-points-image.cpp @@ -6,6 +6,9 @@ #include <visp/vpPixelMeterConversion.h> #include <visp/vpPose.h> +void computePose(std::vector<vpPoint> &point, const std::vector<vpDot2> &dot, + const vpCameraParameters &cam, bool init, vpHomogeneousMatrix &cMo); + void computePose(std::vector<vpPoint> &point, const std::vector<vpDot2> &dot, const vpCameraParameters &cam, bool init, vpHomogeneousMatrix &cMo) { @@ -23,44 +26,49 @@ void computePose(std::vector<vpPoint> &point, const std::vector<vpDot2> &dot, int main() { - vpImage<unsigned char> I; - vpImageIo::read(I, "square.pgm"); + try { + vpImage<unsigned char> I; + vpImageIo::read(I, "square.pgm"); #if defined(VISP_HAVE_X11) - vpDisplayX d(I); + vpDisplayX d(I); #elif defined(VISP_HAVE_GDI) - vpDisplayGDI d(I); + vpDisplayGDI d(I); #endif - vpCameraParameters cam(840, 840, I.getWidth()/2, I.getHeight()/2); - std::vector<vpDot2> dot(4); - dot[0].initTracking(I, vpImagePoint(193, 157)); - dot[1].initTracking(I, vpImagePoint(203, 366)); - dot[2].initTracking(I, vpImagePoint(313, 402)); - dot[3].initTracking(I, vpImagePoint(304, 133)); - std::vector<vpPoint> point(4); - point[0].setWorldCoordinates(-0.06, -0.06, 0); - point[1].setWorldCoordinates( 0.06, -0.06, 0); - point[2].setWorldCoordinates( 0.06, 0.06, 0); - point[3].setWorldCoordinates(-0.06, 0.06, 0); - vpHomogeneousMatrix cMo; - bool init = true; + vpCameraParameters cam(840, 840, I.getWidth()/2, I.getHeight()/2); + std::vector<vpDot2> dot(4); + dot[0].initTracking(I, vpImagePoint(193, 157)); + dot[1].initTracking(I, vpImagePoint(203, 366)); + dot[2].initTracking(I, vpImagePoint(313, 402)); + dot[3].initTracking(I, vpImagePoint(304, 133)); + std::vector<vpPoint> point(4); + point[0].setWorldCoordinates(-0.06, -0.06, 0); + point[1].setWorldCoordinates( 0.06, -0.06, 0); + point[2].setWorldCoordinates( 0.06, 0.06, 0); + point[3].setWorldCoordinates(-0.06, 0.06, 0); + vpHomogeneousMatrix cMo; + bool init = true; - while(1){ - vpImageIo::read(I, "square.pgm"); - vpDisplay::display(I); - for (unsigned int i=0; i < dot.size(); i ++) { - dot[i].setGraphics(true); - dot[i].track(I); - } - computePose(point, dot, cam, init, cMo); - vpDisplay::displayFrame(I, cMo, cam, 0.05, vpColor::none); - vpDisplay::flush(I); + while(1){ + vpImageIo::read(I, "square.pgm"); + vpDisplay::display(I); + for (unsigned int i=0; i < dot.size(); i ++) { + dot[i].setGraphics(true); + dot[i].track(I); + } + computePose(point, dot, cam, init, cMo); + vpDisplay::displayFrame(I, cMo, cam, 0.05, vpColor::none); + vpDisplay::flush(I); - if (init) init = false; // turn off pose initialisation + if (init) init = false; // turn off pose initialisation - if (vpDisplay::getClick(I, false)) break; + if (vpDisplay::getClick(I, false)) break; - vpTime::wait(40); + vpTime::wait(40); + } + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; } } diff --git a/tutorial/computer-vision/tutorial-pose-from-points-tracking.cpp b/tutorial/computer-vision/tutorial-pose-from-points-tracking.cpp index aa000b87aece23a002be1e3b1499a923da0eb3e5..68cd68c2645f29c739607764023c1dbd1a8217a5 100644 --- a/tutorial/computer-vision/tutorial-pose-from-points-tracking.cpp +++ b/tutorial/computer-vision/tutorial-pose-from-points-tracking.cpp @@ -7,6 +7,12 @@ #include <visp/vpPixelMeterConversion.h> #include <visp/vpPose.h> +void computePose(std::vector<vpPoint> &point, const std::vector<vpDot2> &dot, + const vpCameraParameters &cam, bool init, vpHomogeneousMatrix &cMo); +#if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) +void track(vpImage<unsigned char> &I, std::vector<vpDot2> &dot, bool init); +#endif + void computePose(std::vector<vpPoint> &point, const std::vector<vpDot2> &dot, const vpCameraParameters &cam, bool init, vpHomogeneousMatrix &cMo) { @@ -45,48 +51,52 @@ void track(vpImage<unsigned char> &I, std::vector<vpDot2> &dot, bool init) int main() { #if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI)) && (defined(VISP_HAVE_DC1394_2) || defined(VISP_HAVE_CMU1394)) - vpImage<unsigned char> I; + try { vpImage<unsigned char> I; #if defined(VISP_HAVE_DC1394_2) - vp1394TwoGrabber g; + vp1394TwoGrabber g; #elif defined(VISP_HAVE_CMU1394) - vp1394CMUGrabber g; + vp1394CMUGrabber g; #endif - g.open(I); + g.open(I); - // Parameters of our camera - vpCameraParameters cam(840, 840, I.getWidth()/2, I.getHeight()/2); + // Parameters of our camera + vpCameraParameters cam(840, 840, I.getWidth()/2, I.getHeight()/2); - // The pose container - vpHomogeneousMatrix cMo; + // The pose container + vpHomogeneousMatrix cMo; - std::vector<vpDot2> dot(4); - std::vector<vpPoint> point(4); - double L = 0.06; - point[0].setWorldCoordinates(-L, -L, 0); - point[1].setWorldCoordinates( L, -L, 0); - point[2].setWorldCoordinates( L, L, 0); - point[3].setWorldCoordinates(-L, L, 0); + std::vector<vpDot2> dot(4); + std::vector<vpPoint> point(4); + double L = 0.06; + point[0].setWorldCoordinates(-L, -L, 0); + point[1].setWorldCoordinates( L, -L, 0); + point[2].setWorldCoordinates( L, L, 0); + point[3].setWorldCoordinates(-L, L, 0); - bool init = true; + bool init = true; #if defined(VISP_HAVE_X11) - vpDisplayX d(I); + vpDisplayX d(I); #elif defined(VISP_HAVE_GDI) - vpDisplayGDI d(I); + vpDisplayGDI d(I); #endif - while(1){ - // Image Acquisition - g.acquire(I); - vpDisplay::display(I); - track(I, dot, init); - computePose(point, dot, cam, init, cMo); - vpDisplay::displayFrame(I, cMo, cam, 0.05, vpColor::none, 3); - vpDisplay::flush(I); - if (init) init = false; // turn off the initialisation specific stuff + while(1){ + // Image Acquisition + g.acquire(I); + vpDisplay::display(I); + track(I, dot, init); + computePose(point, dot, cam, init, cMo); + vpDisplay::displayFrame(I, cMo, cam, 0.05, vpColor::none, 3); + vpDisplay::flush(I); + if (init) init = false; // turn off the initialisation specific stuff - if (vpDisplay::getClick(I, false)) + if (vpDisplay::getClick(I, false)) break; + } + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; } #endif } diff --git a/tutorial/grabber/CMakeLists.txt b/tutorial/grabber/CMakeLists.txt index 8c3b9879497245a3ec5a4bf2c1400ce75c4100c5..ff523884e62a3e292cc01aba5cdc66fcf771fc78 100644 --- a/tutorial/grabber/CMakeLists.txt +++ b/tutorial/grabber/CMakeLists.txt @@ -3,24 +3,24 @@ project(tutorial-grabber) cmake_minimum_required(VERSION 2.6) find_package(VISP REQUIRED) -if(VISP_FOUND) - include(${VISP_USE_FILE}) -endif(VISP_FOUND) -# build the examples -add_executable(tutorial-grabber-1394 tutorial-grabber-1394.cpp) -add_executable(tutorial-grabber-CMU1394 tutorial-grabber-CMU1394.cpp) -add_executable(tutorial-grabber-opencv tutorial-grabber-opencv.cpp) -add_executable(tutorial-grabber-opencv-bis tutorial-grabber-opencv-bis.cpp) -add_executable(tutorial-grabber-video tutorial-grabber-video.cpp) -add_executable(tutorial-grabber-v4l2 tutorial-grabber-v4l2.cpp) +# set the list of source files +set(tutorial_cpp + tutorial-grabber-1394.cpp + tutorial-grabber-1394-writer.cpp + tutorial-grabber-CMU1394.cpp + tutorial-grabber-opencv.cpp + tutorial-grabber-opencv-bis.cpp + tutorial-grabber-video.cpp + tutorial-grabber-v4l2.cpp) -# copy the data -get_target_property(target_location tutorial-grabber-video LOCATION) -get_filename_component(target_location "${target_location}" PATH) -set(data "${CMAKE_CURRENT_SOURCE_DIR}/video.mpg" ) -add_custom_command( - TARGET tutorial-grabber-video - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy "${data}" "${target_location}" -) +set(tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/video.mpg") + +foreach(cpp ${tutorial_cpp}) + visp_add_target(${cpp}) +endforeach() + +# Copy the data files to the same location than the target +foreach(data ${tutorial_data}) + visp_copy_data(tutorial-grabber-video.cpp ${data}) +endforeach() diff --git a/tutorial/grabber/tutorial-grabber-1394-writer.cpp b/tutorial/grabber/tutorial-grabber-1394-writer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d764956eb6301872165835af02de69242f5ef3ee --- /dev/null +++ b/tutorial/grabber/tutorial-grabber-1394-writer.cpp @@ -0,0 +1,62 @@ +/*! \example tutorial-grabber-1394-writer.cpp */ +#include <visp/vp1394TwoGrabber.h> +#include <visp/vpDisplayX.h> +#include <visp/vpImage.h> +#include <visp/vpVideoWriter.h> + +int main(int argc, char **) +{ +#ifdef VISP_HAVE_DC1394_2 + try { + bool save = false; + if(argc == 2) { + save = true; + } + + vpImage<unsigned char> I; // Create a gray level image container + bool reset = true; // Enable bus reset during construction (default) + vp1394TwoGrabber g(reset); // Create a grabber based on libdc1394-2.x third party lib + + g.setVideoMode(vp1394TwoGrabber::vpVIDEO_MODE_640x480_MONO8); + g.setFramerate(vp1394TwoGrabber::vpFRAMERATE_60); + g.open(I); + + std::cout << "Image size: " << I.getWidth() << " " << I.getHeight() << std::endl; + +#ifdef VISP_HAVE_X11 + vpDisplayX d(I); +#else + std::cout << "No image viewer is available..." << std::endl; +#endif + + vpVideoWriter writer; + writer.setFileName("./I%04d.pgm"); + if (save) + writer.open(I); + + while(1) { + g.acquire(I); + + if (save) + writer.saveFrame(I); + + vpDisplay::display(I); + vpDisplay::flush(I); + + if (vpDisplay::getClick(I, false)) + break; + } + + if (save) + writer.close(); + + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + } +#else + (void)argc; +#endif + + return 0; +} diff --git a/tutorial/grabber/tutorial-grabber-1394.cpp b/tutorial/grabber/tutorial-grabber-1394.cpp index 36535bb3213fb1ed2c7d9ca5f914ea38765159e2..7007b63cb627410b64444bcf514ea8afd96115e4 100644 --- a/tutorial/grabber/tutorial-grabber-1394.cpp +++ b/tutorial/grabber/tutorial-grabber-1394.cpp @@ -6,28 +6,33 @@ int main() { #ifdef VISP_HAVE_DC1394_2 - vpImage<unsigned char> I; // Create a gray level image container - bool reset = true; // Enable bus reset during construction (default) - vp1394TwoGrabber g(reset); // Create a grabber based on libdc1394-2.x third party lib + try { + vpImage<unsigned char> I; // Create a gray level image container + bool reset = true; // Enable bus reset during construction (default) + vp1394TwoGrabber g(reset); // Create a grabber based on libdc1394-2.x third party lib - g.setVideoMode(vp1394TwoGrabber::vpVIDEO_MODE_640x480_MONO8); - g.setFramerate(vp1394TwoGrabber::vpFRAMERATE_60); - g.open(I); + g.setVideoMode(vp1394TwoGrabber::vpVIDEO_MODE_640x480_MONO8); + g.setFramerate(vp1394TwoGrabber::vpFRAMERATE_60); + g.open(I); - std::cout << "Image size: " << I.getWidth() << " " << I.getHeight() << std::endl; + std::cout << "Image size: " << I.getWidth() << " " << I.getHeight() << std::endl; #ifdef VISP_HAVE_X11 - vpDisplayX d(I); + vpDisplayX d(I); #else - std::cout << "No image viewer is available..." << std::endl; + std::cout << "No image viewer is available..." << std::endl; #endif - while(1) { - g.acquire(I); - vpDisplay::display(I); - vpDisplay::flush(I); - if (vpDisplay::getClick(I, false)) - break; + while(1) { + g.acquire(I); + vpDisplay::display(I); + vpDisplay::flush(I); + if (vpDisplay::getClick(I, false)) + break; + } + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; } #endif } diff --git a/tutorial/grabber/tutorial-grabber-CMU1394.cpp b/tutorial/grabber/tutorial-grabber-CMU1394.cpp index 5b596aeae73230bcba73cdff82081c2517c8dad8..a7b527dac8029a1b974f8a8d9b351c02a1a6be39 100644 --- a/tutorial/grabber/tutorial-grabber-CMU1394.cpp +++ b/tutorial/grabber/tutorial-grabber-CMU1394.cpp @@ -6,29 +6,34 @@ int main() { #ifdef VISP_HAVE_CMU1394 - vpImage<unsigned char> I; + try { + vpImage<unsigned char> I; - vp1394CMUGrabber g; - g.setVideoMode(0, 1); // 640x480 MONO8 - g.setAutoShutter(); - g.setAutoGain(); - g.setFramerate(4); // 30 fps - g.open(I); + vp1394CMUGrabber g; + g.setVideoMode(0, 1); // 640x480 MONO8 + g.setAutoShutter(); + g.setAutoGain(); + g.setFramerate(4); // 30 fps + g.open(I); - std::cout << "Image size: " << I.getWidth() << " " << I.getHeight() << std::endl; + std::cout << "Image size: " << I.getWidth() << " " << I.getHeight() << std::endl; #ifdef VISP_HAVE_GDI - vpDisplayGDI d(I); + vpDisplayGDI d(I); #else - std::cout << "No image viewer is available..." << std::endl; + std::cout << "No image viewer is available..." << std::endl; #endif - while(1) { - g.acquire(I); - vpDisplay::display(I); - vpDisplay::flush(I); - if (vpDisplay::getClick(I, false)) // A click to exit - break; + while(1) { + g.acquire(I); + vpDisplay::display(I); + vpDisplay::flush(I); + if (vpDisplay::getClick(I, false)) // A click to exit + break; + } + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; } #endif } diff --git a/tutorial/grabber/tutorial-grabber-opencv-bis.cpp b/tutorial/grabber/tutorial-grabber-opencv-bis.cpp index 334be3ce7e7b2095f6673573688dd405c110839e..626db671f0dcd1f539179d58c6fc92b35b158ce8 100644 --- a/tutorial/grabber/tutorial-grabber-opencv-bis.cpp +++ b/tutorial/grabber/tutorial-grabber-opencv-bis.cpp @@ -14,27 +14,32 @@ int main(int argc, char** argv) std::cout << "Use device: " << device << std::endl; #if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100) - cv::VideoCapture cap(device); // open the default camera - if(!cap.isOpened()) { // check if we succeeded - std::cout << "Failed to open the camera" << std::endl; - return -1; - } - cv::Mat frame; - cap >> frame; // get a new frame from camera - std::cout << "Image size: " << frame.rows << " " << frame.cols << std::endl; - - //vpImage<vpRGBa> I; // for color images - vpImage<unsigned char> I; // for gray images - vpImageConvert::convert(frame, I); - vpDisplayOpenCV d(I); - for(;;) { + try { + cv::VideoCapture cap(device); // open the default camera + if(!cap.isOpened()) { // check if we succeeded + std::cout << "Failed to open the camera" << std::endl; + return -1; + } + cv::Mat frame; cap >> frame; // get a new frame from camera - // Convert the image in ViSP format and display it + std::cout << "Image size: " << frame.rows << " " << frame.cols << std::endl; + + //vpImage<vpRGBa> I; // for color images + vpImage<unsigned char> I; // for gray images vpImageConvert::convert(frame, I); - vpDisplay::display(I); - vpDisplay::flush(I); - if (vpDisplay::getClick(I, false)) // a click to exit - break; + vpDisplayOpenCV d(I); + for(;;) { + cap >> frame; // get a new frame from camera + // Convert the image in ViSP format and display it + vpImageConvert::convert(frame, I); + vpDisplay::display(I); + vpDisplay::flush(I); + if (vpDisplay::getClick(I, false)) // a click to exit + break; + } + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; } #endif } diff --git a/tutorial/grabber/tutorial-grabber-opencv.cpp b/tutorial/grabber/tutorial-grabber-opencv.cpp index 16356f172947f92ae62734b940b376e917f8eab3..05f937007042e49a11546cbbcaf14a295650cd11 100644 --- a/tutorial/grabber/tutorial-grabber-opencv.cpp +++ b/tutorial/grabber/tutorial-grabber-opencv.cpp @@ -5,20 +5,25 @@ int main() { #ifdef VISP_HAVE_OPENCV - vpImage<unsigned char> I; + try { + vpImage<unsigned char> I; - vpOpenCVGrabber g; - g.open(I); + vpOpenCVGrabber g; + g.open(I); - std::cout << "Image size: " << I.getWidth() << " " << I.getHeight() << std::endl; - vpDisplayOpenCV d(I); + std::cout << "Image size: " << I.getWidth() << " " << I.getHeight() << std::endl; + vpDisplayOpenCV d(I); - while(1) { - g.acquire(I); - vpDisplay::display(I); - vpDisplay::flush(I); - if (vpDisplay::getClick(I, false)) - break; + while(1) { + g.acquire(I); + vpDisplay::display(I); + vpDisplay::flush(I); + if (vpDisplay::getClick(I, false)) + break; + } + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; } #endif } diff --git a/tutorial/grabber/tutorial-grabber-v4l2.cpp b/tutorial/grabber/tutorial-grabber-v4l2.cpp index a05efe27abd31524dea08f7d9e7524e0e20c35c2..ff9087b123fb286f9a4d0082b7f4385cd3316948 100644 --- a/tutorial/grabber/tutorial-grabber-v4l2.cpp +++ b/tutorial/grabber/tutorial-grabber-v4l2.cpp @@ -6,24 +6,29 @@ int main() { #ifdef VISP_HAVE_V4L2 - vpImage<unsigned char> I; + try { + vpImage<unsigned char> I; - vpV4l2Grabber g; - g.open(I); + vpV4l2Grabber g; + g.open(I); - std::cout << "Image size: " << I.getWidth() << " " << I.getHeight() << std::endl; + std::cout << "Image size: " << I.getWidth() << " " << I.getHeight() << std::endl; #ifdef VISP_HAVE_X11 - vpDisplayX d(I); + vpDisplayX d(I); #else - std::cout << "No image viewer is available..." << std::endl; + std::cout << "No image viewer is available..." << std::endl; #endif - while(1) { - g.acquire(I); - vpDisplay::display(I); - vpDisplay::flush(I); - if (vpDisplay::getClick(I, false)) break; + while(1) { + g.acquire(I); + vpDisplay::display(I); + vpDisplay::flush(I); + if (vpDisplay::getClick(I, false)) break; + } + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; } #endif } diff --git a/tutorial/grabber/tutorial-grabber-video.cpp b/tutorial/grabber/tutorial-grabber-video.cpp index 80b870c16f680ea073895130fd0182d2e73c0527..9098299973cdca118eaa54e5814b7c48a8ae5c7e 100644 --- a/tutorial/grabber/tutorial-grabber-video.cpp +++ b/tutorial/grabber/tutorial-grabber-video.cpp @@ -5,28 +5,33 @@ int main() { #ifdef VISP_HAVE_FFMPEG - vpImage<unsigned char> I; + try { + vpImage<unsigned char> I; - vpVideoReader g; - g.setFileName("./video.mpg"); - g.open(I); + vpVideoReader g; + g.setFileName("./video.mpg"); + g.open(I); - std::cout << "video framerate: " << g.getFramerate() << "Hz" << std::endl; - std::cout << "video dimension: " << I.getWidth() << " " << I.getHeight() << std::endl; + std::cout << "video framerate: " << g.getFramerate() << "Hz" << std::endl; + std::cout << "video dimension: " << I.getWidth() << " " << I.getHeight() << std::endl; #ifdef VISP_HAVE_X11 - vpDisplayX d(I); + vpDisplayX d(I); #else - std::cout << "No image viewer is available..." << std::endl; + std::cout << "No image viewer is available..." << std::endl; #endif - vpDisplay::setTitle(I, "Video grabber"); - while (! g.end() ) { - double t = vpTime::measureTimeMs(); - g.acquire(I); - vpDisplay::display(I); - vpDisplay::flush(I); - if (vpDisplay::getClick(I, false)) break; - vpTime::wait(t, 1000. / g.getFramerate()); + vpDisplay::setTitle(I, "Video grabber"); + while (! g.end() ) { + double t = vpTime::measureTimeMs(); + g.acquire(I); + vpDisplay::display(I); + vpDisplay::flush(I); + if (vpDisplay::getClick(I, false)) break; + vpTime::wait(t, 1000. / g.getFramerate()); + } + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; } #endif } diff --git a/tutorial/image/CMakeLists.txt b/tutorial/image/CMakeLists.txt index a5f0bb85708e7185af486fbffb1c448ae45ca218..98cbd4630224502f43c5976a8e35b48c5a3e6d9c 100644 --- a/tutorial/image/CMakeLists.txt +++ b/tutorial/image/CMakeLists.txt @@ -3,29 +3,29 @@ project(tutorial-image) cmake_minimum_required(VERSION 2.6) find_package(VISP REQUIRED) -if(VISP_FOUND) - include(${VISP_USE_FILE}) -endif(VISP_FOUND) -# build the examples -add_executable(tutorial-image-converter tutorial-image-converter.cpp) -add_executable(tutorial-image-manipulation tutorial-image-manipulation.cpp) -add_executable(tutorial-image-reader tutorial-image-reader.cpp) -add_executable(tutorial-image-viewer tutorial-image-viewer.cpp) -add_executable(tutorial-undistort tutorial-undistort.cpp) -add_executable(tutorial-viewer tutorial-viewer.cpp) +set(tutorial_cpp + tutorial-image-converter.cpp + tutorial-image-manipulation.cpp + tutorial-image-reader.cpp + tutorial-image-viewer.cpp + tutorial-undistort.cpp + tutorial-viewer.cpp + tutorial-image-filter.cpp) -# copy the data -get_target_property(target_location tutorial-image-reader LOCATION) -get_filename_component(target_location "${target_location}" PATH) -list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/lena.bmp" ) -list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/lena.ppm" ) -list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/chessboard.pgm" ) -list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/camera.xml" ) -foreach(data ${data2copy}) - add_custom_command( - TARGET tutorial-image-reader - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy "${data}" "${target_location}" - ) +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/lena.bmp" ) +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/lena.ppm" ) +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/lena.pgm" ) +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/lena.jpeg" ) +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/lena.png" ) +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/chessboard.pgm" ) +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/camera.xml" ) + +foreach(cpp ${tutorial_cpp}) + visp_add_target(${cpp}) +endforeach() + +# Copy the data files to the same location than the target +foreach(data ${tutorial_data}) + visp_copy_data(tutorial-image-reader.cpp ${data}) endforeach() diff --git a/tutorial/image/lena.jpeg b/tutorial/image/lena.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..3ca83964d5876a3b61a3bbce47436c3308193338 Binary files /dev/null and b/tutorial/image/lena.jpeg differ diff --git a/tutorial/image/lena.pgm b/tutorial/image/lena.pgm new file mode 100644 index 0000000000000000000000000000000000000000..992d1f0a1e42249eb221a30fe33f44e1407f3533 --- /dev/null +++ b/tutorial/image/lena.pgm @@ -0,0 +1,4 @@ +P5 +225 225 +255 + ŸŸžž¡Ÿœ™˜˜™›¡¤§ª¬¬«ª˜’†td\^bghhijkkklkjikmqswxy{|~€‚‚‚ƒƒƒ‚‚ƒƒ„„„„‡‡‡‡‡‡‡‡††††††††‡†††………„ƒƒƒƒƒƒƒƒ…………………………„„ƒ‚‚€€~}|{{vqkhkt~…–”•œ£¢›’———˜˜™™™šš™™™˜˜˜››››››››»ÑÓÑÙßÜÛtijlqzxxyz{{||yyzz{{{{zzz{|}}~‡yusq… ¨‘ ŸŸžžž¡Ÿœ™˜™š›¢¤§ª¬«ª©˜’…td\]agghijjkklkiijmprwxyz|~‚‚ƒƒƒ‚‚ƒƒ„„„„‡‡‡‡‡‡‡‡……………………††††……„„ƒƒƒƒƒƒƒƒ…………………………„„ƒ‚€}|{{vrlhks|ƒ“’•›¢¢›”˜˜˜˜™™™šššš™™™˜˜››››››››´ÌÔÔ×ÛÜÆŸudhqvxxxyyz{||yyzz{{{{zz{||}~~wsxxtˆ©¸“ŸŸŸŸžžž ž›™˜š›£¥¨ª««©¨—‘„sc[\`gghiijkkkjihjlprwwyz|}~‚‚‚ƒƒ‚‚ƒƒ„„„„††††††††……………………†††………„„ƒƒƒƒƒƒƒƒ…………………………„ƒ‚‚€~}|{wsmjkqyŽ“š ¡œ–™™™ššš››››ššš™™™ššššššššœªÀÓ×ÔÖÜͬbdtytwxxyzz{{yyzz{{{{z{{|}~~ƒwtz€‰‹‚\ŸŸžžŸ›™™›Ÿ¤¦¨ª«©§¦–ƒrbZ[_ggghijjkkjhhiloqvwxz{}~€€‚‚‚‚‚‚ƒƒ„„„„††††††††……………………††………„„„‚‚‚‚‚‚‚‚………………………„„ƒ‚€€€€€€€€€‚€~}||xtokkpuyˆ‹’™žŸœ™šš››œœœœœ›››šššššššššššššŸ³Í×ÑÒÛÕÀ–nbntovwwxyzz{yyzz{{{{{||}~Œ{€rR51žžœœœœš™šœŸ¡¥§©ªª¨¥¤”Ž‚p`YZ^ffghiijjjigghknpvwxy{}~~€€€‚‚‚‚ƒƒ„„„„……………………„„„„„„„„………„„„ƒƒ‚‚‚‚‚‚‚‚……………………„„ƒ‚‚€€€€€€€€€€‚‚€~}||xuqmlmqs‡˜œœœœžžžœœœœ›››ššššššššš™—¦ÁÑÐÒÙÚÔµ‡hekkvvwwxyyzyyzz{{{{||}~€€}‡Š~eG0(0œœ›››œ›š™›ž¡£¦¨©ª©§¤¢“o_XY]ffgghijjihgfgjmovvwy{|}~€€€‚‚‚ƒƒ„„„„……………………„„„„„„„„……„„„ƒƒƒ‚‚‚‚‚‚‚‚……………………„ƒƒ‚€€€ƒ‚€~}|yvrnlllm{ƒ—šœž žžžŸŸŸ œœœ››™™™™™™™™—”œ±ÆÑÕ×ÜÜÍ¥zeekuuvwwxyyyyzz{{{{}}~€€Š‚fG.*7/œœœ›››š›š™™›Ÿ¢¥§¨ªª©¦¢ ’Œ€n^WX\effghiijigfegimouvwyz|}~€€€‚‚ƒƒ„„„„……………………„„„„„„„„……„„ƒƒƒƒ……………………ƒƒƒ‚€€ƒ‚‚€~}}zwtpljiiv€Ž–™šŸ£ŸŸŸŸ ¡¡žžœœœ™™™™™™™™•”•¡ºÓÚÖÚÛÕ½“ofmtuuvwxxxyyzz{{{{}~~€‚†|^A7.*41œœœ›››šš›š™™›Ÿ£¥¨©ªª¨¥¢Ÿ’Œn^VW[effghiiihgfefilnuvwyz|}~€€€‚‚ƒƒ„„„„……………………ƒƒƒƒƒƒƒƒ…„„„ƒƒƒ‚……………………ƒƒ‚‚€ƒƒ‚~}}zxtpliggs–˜šŸ¤ŸŸ ¡¡¡žžžœœ™™™™™™™™”•’—³ÔÞÕØ××Ê¥zjottuvvwxxyyzz{{{{~~€‚‚td?*12,13››œœœŸš™›Ÿ¤§¥¥¤£¢¢¡¡•‚qaYZ^acgikjihhgffhknpuvwxz|}}€€€‚‚‚‚‚‚ƒƒƒƒƒƒƒƒƒƒƒƒ„„„…………„„„ƒƒ‚‚‚ƒƒƒ‚‚ƒ„„…†‡‡‡ƒƒ‚‚€€€~~~€€~~~zyvspmjity‹“šžŸ¤¤£££¢¢¢ ŸŸžœ™™˜˜˜————žš–²ËÔÙÚÛÜÊŽhqhmqruz{zxwxz}‚{}‡‰|U>++0113-››œœŸ››œ ¤§¥¤¤£¢¡¡¡•‚qaYZ^acgikjihhgffhknpuvwxz|}}€€€‚‚‚‚ƒƒƒƒƒƒƒƒƒƒƒƒƒ„„„………ƒƒƒƒ‚‚‚ƒ‚‚‚€ƒƒ„„…†‡‡ƒƒ‚‚€€€~~~€€~~~zyvspmkisxŠ“™Ÿ££££¢¢¡¡ ŸŸžœœ™™™˜˜˜——–š˜’•©ÂÑ×ÛÝÜÑ«~ggmtvvwy|{zxwx{~{€ƒ…Œ‹w^F6,174.,4œœœœžžŸžŸ¢¥§¤¤¤£¢¡¡ ”‚paYZ^acgikjihhgffhknpuvwxz|}}€€€€‚‚‚‚ƒƒƒƒƒƒƒƒƒƒƒƒƒ„„………‚‚‚€€‚‚€€€€‚‚ƒ„„…††ƒƒ‚‚€€€~~~€€~~~zywtpmkjsx€Š’™ž££¢¢¢¡¡¡ Ÿžœœšš™™˜˜˜˜””–•”œ³ËÖÛÞÛØÎ gdkuzxstx|zyxy{~€|‚‡Šƒ`==/(/63..7œœœžžžŸŸŸ ¢¤¦§¤¤£¢¢¡ ”Ž‚p`XZ^acgikjihhgffhknpuvwxz|}}€€€€€‚‚‚‚‚‚‚‚‚‚‚‚ƒƒƒƒ„„„…€€€€€~‚‚ƒ„……ƒƒ‚‚€€€~~~€€~~~{ywtqnkjrw‰’˜œž¢¢¢¡¡ ŸŸžœœ››ššš™™™˜”‘”˜“¤¿ÕØÝÛÚÞ¾€eir{zssy|{yxy{~€…ƒ‰€]>0;,#'./285œžžžŸŸ ¢¤¥¦§§¤££¢¡ Ÿ”Žp`XY]acgikjihhgffhknpuvwxz|}}€€€€€€‚‚‚‚‚‚‚‚‚‚‚‚ƒƒƒ„„„~~}}}~~~}}€€€‚ƒƒ„ƒƒ‚‚€€€~~~€€~~~{zwtqnljqv~ˆ‘—›¡¡¡ ŸŸŸŸžœ›››››ššš™™•‘“˜’Œš¯ÐÑÙÚÙÞÒ©slmwzuv~|{yyy|‡‰‹~\7*/6+%*/.2:6žžžŸŸž¡¤§©©¨§££¢¢¡ ŸŸ“o_XY]acgikjihhgffhknpuvwxz|}}~€€€€€€€‚‚‚‚‚‚‚‚‚‚‚‚ƒƒƒ„„~}}}|||{~~~}}}||~€‚‚ƒƒƒ‚‚€€€~~~€€~~~{zxuqnlkpu~‡–šœ ŸŸŸžŸžžœ›››œœœ››ššš˜••–“•ÀÉÕØØÝÛÍ‘yjqwuv~}{zyz|‰Z5'+/.*-792/3:žžžŸŸŸž¡¦©«ª¨§££¢¡ ŸŸ“€o_WY\acgikjihhgffhknpuvwxz|}}~~€€€€€€‚‚‚ƒƒƒ„||||{{zz}}}|||{{~~~€‚ƒƒ‚‚€€€~~~€€~~~|zxurolkpu}‡–š› ŸŸŸžžžžžžœ››šœœ››››››—’”˜•ލÂÓÕÚßÞÝ·kjsqqx}|zyz|zt];')130.3<;2/38žžžŸŸŸž¢§«¬«©§£¢¢¡ ŸŸ“€o_WX\acgikjihhgffhknpuvwxz|}}~~~€€€€€€‚‚ƒƒƒƒ||{{{zzz}}|||{{{}}~€€ƒƒ‚‚€€€~~~€€~~~|{xurolkot}†–™› ŸŸŸžžžžžœ›ššœœ›››Ÿ˜•ž–„–¿ÒÓÞãÞÞÌœmgomlr}|zyz}|[:-,,2;:548502;1ŸŸ ¡¢¤¤¥¨©ªª©§¥¤¡ ŸŸŸŸ•Žk[TW]`bfhjihfgfeegjmottuvxyzz}}}~~~~~~€€€€€ƒ‚‚‚€€}|zxwvwx{}}|zysvz~€‰‡„~~~€€€€~~~yxvurqonpt|„‹’“™™š›œžžŸœœ›››žžœ››šš——–•“’‘‘ƒªÏØ×ÚáåØ¿†aekks~ut}}}„=81+),1498754210/ŸŸ ¡£¤¥¥§§¨¨§¥¤£¡¡ ŸŸŸ•Žk[TW]`bfhjihfgfeegjmptuuwxyzz}}}~~~~~€€€€€‚‚€~~€€~|{zzxy{{yvsqwxz}€‚„…‚‚‚‚|yv€€€€~~~~yxvtrponpt{„‹’“˜™™›œžžœœ››››œ›šš™—–•”“’‘‡»ÐÖÖÛãÛΡsejopswxzƒ‡xb95/++.3788653210/Ÿ ¡¢£¤¥¥¥¥¤££¢¡¡¡¡¡ ŸŸŸ•Žk[TW]`bfhjihfhgeegjnptuvwxyz{}}}~~~~€€€€€€‚‚~}|{}}}|||||~~|xtqtvz~€€~|}}~€€€€~~}}xxvtrponpt{ƒŠ’“——˜™›œœœœ››šššœœ›š™™˜–•”“’‘Œ¢ÁÓÕ×ÞÝÛÅ’jhqnmty~„~`@41.,-27;8764310// ¡¢£¤¥¦£¢ žžŸ¡¡¡¡ Ÿ•Žk[TW]`bfhjihfhgffgjnpuuvwyz{{}}}~~~€€€€€€~}|{z{{|}~€‚ƒ‚|zutsux~ƒ‡‚€}{|€„‡€€~~}}}xwvtrpnnos{ƒŠ‘“•–—˜™š›œ›››ššš™™›››š™˜˜—•”“’‘Ž‹“®ÊØÛÚááÛ³xdmlsszƒxY=1.-,-05:=765420/// ¡¢¤¥¦¦¡ž›˜—˜›¢¢¡¡¡ •Žk[TW]`bfhjihfhgffhknquvwxyz{{}}}~~~€€€€€€€€€€€‚„†ˆ‹Œ¢¤¨«¬«¦œŒ}vvz~~}||{{{€€~~~}}}|wwusqonmosz‚‰Ž‘’””•–—™™š›ššš™™™˜šš™™˜—––““’‘ŽŽ‘ž½ØÞØäàâÍ’kimvz~uV3'.++-/37;>654310../ ¡¢£¤¥¦§Ÿ›–’’”˜›¢¢¢¡¡¡ •Žk[TW]`bfhjihfihgfhkoqvvwxyz{|}}}~~~€€€€‚€€}~€‚„‡‰‰Ž‘”˜›žŸ£¦«¯³´´´Â½´§˜Š~xlqw|~}yw€€~~~}}}||wvusqommnsz‚‰Ž‘’’“”•–—˜˜šš™™˜˜˜˜™™˜——–••’’‘ŽŒŒ‘”¬ÍÚØâÜàÚ³ƒnosyW3$'*+,.148:<55420/.-/¡¡¢£¤¦¦§™“Ž‘•™£¢¢¢¡¡¡ •Žk[TW]`bfhjihfihgghloqvvwxz{||}}}~~~€€€‚‚€€{}€…ŠŽ‘“‘”˜¡¤¦©«¯³µ¶µ´«°¸½»´©¢‚€|zy{}€€~~}}}|||wvusqomlnrz‚‰Ž‘‘‘’“•–——™™™˜˜˜——˜˜——–•””‘‘ŽŒŒ‹Ž‹ž·ÏØßÝÝßѧquq]<(',,,.03678854310.-,/¡¡¢£¥¦§§œ˜‘Œ‹”˜££¢¢¡¡¡¡•Žk[TW]`bfhjihfihggiloqvwwyz{||}}}~~~€€€‚‚‚€€z|†“—š‰‹”™¡£ª¬¯±±°®¬²²²´¸¼Áĸ¨ynox€€€~~}}}|||wvtspomlnry‚‰Ž‘‘’“”•–—™™˜˜˜———˜——–•”””‘ŽŒ‹‹‡†–¥ÂØÝâÝßßÂs|]>2/,,1-/2467664431/.-,/šŸ¦««¦Ÿ›•‰…‰Š‘›¦¦¥¤¤£¢¢™‘€kXPRV^`dghhgffghjkmnouuvwxz{{z{{|}~~€z|‚~†u{xyz|}}}~}ƒ‹’–‘’”—šœžŸ§§¨ª«®¯²³´¶¸º¼¼ÂÇëŠtrxs}ƒ‚ƒ‡‚y}|zywwuusqomlkpt{ƒ‰Ž‘‘’”•––•–˜šš˜–”‘‘‘‘‘‘‘‘ŽŒŒŒ‹”‡…ŒŽ«ÎÕæÑÞäÏ·Ž\B'+76/23345667*06972-+3¡¨¬«¦Ÿš”„z‡Œ“œ¦¦¥¤¤£¢¢™‘€jXPQV\^beffedfghiklnntuvwxyz{z{{|}~~~ƒ}z€}~„w}‡“’Ž‹{‰ŒŒŒ’‘“–™›ž¦§¨ª«®¯²³´¶¸º¼½ÂÄÆÃ´š{fstƒ‚stƒ~}|{yxwvutsqomkkot{ƒŠŽ‘’‘‘’“”•––—™š™—”’‘‘‘‘‘‘‘‘ŽŽŒŒŒŒ”‰‡ŽŒ‹£ÃÖåÛßßà×—>4)&+12055544444/14431/./¡¥«®¬¥—‘|nv…—¦¦¥¤¤£¢¢˜jXOQUY[_bccbaefgijlmnstuvwxyzzz{|}}~~…y}„‹—˜š˜“Š€zx†‰ˆˆŠŽ‘”–™›œ¤¥§©«®¯°²³µ·¹»¼½Ã¿¾Åɽ¡Šj}‚tp{|p{zzyxwvvttrpnlkjnszƒŠ’“‘‘’’““””—˜™™—”‘ŽŽŽŒŒŒ”ŒŒ‘‡–®ÔÙÝãÛàà¡%+-++.287653210630..0233¦©®ª¢˜’‡pbmƒ’šŸ¦¦¥¤¤£¢¢˜iWNPUVY\_aa`_eefhjklmrstuvwxxzz{{|}}~ƒ}}}z–€ƒ“‹…v|ƒ†„ƒ…ˆ‹ŒŽ‘”–˜š¢¤¦¨«®°±³´µ·¹»¼½Ã¿½ÀÄÆÂ½|pqussvwwvvvvuutsqomkjimqy‚Š“•’’’’’’’’–—˜˜–’ŽŒŽŽŽŒŒ“Ž“…‹™ÅÓÙÞÝáËu#-0+).4:97520.-;4-),0457¨«®§œ‘ŠxcYh‚“› ¦¦¥¤¤£¢¢—Ž~hVNOTVX\_aa_^ddfgijklqqrtuvwwyzz{||}}}y‚v®ut|zwvw{€„v|ƒ„‚‚…ˆ‰‹Ž‘”–— ¢¤¨«¯±³³´¶·º»½¾½ÀÄÆÅÄÄÅÅ¡zjhjqxssssttttsrqomkihkpx‚Š‘•–”““’‘‘“”•–”’ŽŒŽŽŽ’‘“‡ˆŽ©ÏØÙäÛ*'+..,-16:97520.-;3+*/331-©«¬ª¢–‰eWTh’›¢¦¦¥¤¤£¢¢–Ž}hUMNSXZ]abba`cdefhjkkppqrtuvvyyzz{|}}{wƒ‚x§ljzz{{zxwvx~„…‚€„…‡‰‹Ž‘“”ž £§«¯²´´´¶¸º¼½¾¸º½ÂÆÈÇÆÇÏ»Šhgnmoopqrsstrqpnljhhinw‚‹’–˜•”“’‘ŽŽ’“”’ŽŽŽ‘’Œ”¼ÕäÚ—G42/--0467654210/60,0681)¨©ª¦ySMSj𣦦¥¤¤£¢¢•|gULNSZ\`cedcbbcdfgijkoopqstuuyyyz{||}|y~„€llwxyyz{||{†‡ƒ‚„ƒ…‡‰Œ‘’Ÿ¢¦«°³µ´µ¶¸º¼¾¾¸¸º¾ÂÇÊËÆÆÍʤtdpllmoprssqqomkihghmw‹’—™–•”’ŽŒ‡ŠŽ‘“”“’ŽŽŽ’““’¥ÉÏ“D%//00//14733333222/,.7@=. §¨¨£™‹}tHHTl‚Ž™¤¦¦¥¤¤£¢¢•|gTLNR\^beffedbcdegijjoopqrstuxyyz{||}}x……Yps‚}uppu|}‚ˆˆ…‚‚…‚ƒ…ˆ‹Ž‘œž¡¦«°³µ´µ¶¸º¼¾¾ºÁÈÈþ½¿ÃÄÄÆÆ³…Yjklnoqrsqpomkigggmv‹“˜š––”’ŽŒŒ„‡‹“•••ŽŽŽŽŽŽ“˜™—‘£·Š;*7*#*12003701123445**0<F@,1°¬¦Ÿ”hVOLVn„𣧍©©§¤ ž”Œ{fTLNSZ\_bddcbfeccdgjlopqrstuvxxyyzzzz}z„Ÿornnoprtwz|}‚ƒ„…†‡‡†‡ˆ‰‹ŒŽŽ•𠣤§®³³µ¸¼¾½º¸½ÁÄÄÁ¿ÂŽÇÎÊÎÛ¸tfU^leV|mlmnnliecdkw…–™šš˜—˜˜’ˆƒ€ƒ‰“”•ŒŽ”–’‘‘Š š‡Œ–”“ž v>-0,**-157520(+046520'9@@>, )s¬©¢™ŠvaSPMWn„™¢§¨©©§¤ ž”Œ{fTLNSZ\_bddcbfeccdgjlopqrstuvxyyyzzz{|~ŒŒrnskopruwz|}€‚ƒ„…††‡ˆ‰‹ŒŽŽ’˜Ÿ£¥©°¶±´¶·¹½ÃȾ¼½ÃÊÉÁ¸ÊÀº¶½ÕÝ˽ª`Q[wa|jklmkhecdkw„–™šš˜—˜˜’ˆ{yy~‡”••Ž“•’‘‘‘—’“™™™¢„T3/1-*-/35541.+.1454100=DB5#3\ž¦¤{gYQQNXo„™¢§¨©©§¤ ž”Œ{fTLNSZ\_bddcbfedcegjmopqrstuvyyyzzz{{}„uuitjqrsuxz{|z{}~€‚ƒ„†‡ˆ‰‹ŒŽŽŽ•¢¥ª²¹·»¾½ºº¾ÂÄÅÆÄÀ»¸·Ã¼ÅÕÖÕÜáéà§R[l\sghjkjgdbckw„–™™š˜—˜˜’ˆ€plkr€“•“Ž’”‘Ž‘‘’‘——šŸ —\-'.0.*234541.,013553106HK9(.Z©¢¡™†o]UTSPYp„˜ §¨©©§¤ ž”Œ{fTLNSZ\_bddcbgfddehkmopqrstuvyyzzz{{{…ˆjvfnpssuvxyz{wwy|~‚ƒ†‡ˆ‰‹ŒŽŽ‹’›¡¥«´»Á¿½º¹º¼½ÇÆÃ»µ·ÁÊÔËÒßÛÎÑÞÞàä‰PMiZceghhfcacjw„•˜™›™˜™˜“ˆ€g`[ct†“’‘‘’‘‘‘ŒŠ–œ•š¡˜r;$*,0+766420-,44555432;NI,+Tƒœ¦¡‘}gZWYURZp„Ž—Ÿ§¨©©§¤ ž”Œ{fTLNSZ\_bddcbgfedehkmopqrstuvzzzz{{{|wmtgfwuuvwxxyytvx{~ƒ…†‡ˆ‰‹ŒŽŽ‹’𠥫´»¾¹³³¸¾ÁÁ¼µ°´ÁÏ×ÚÙÓÏÓÕÏÐÙÛààÌYJaT_acefdbacjvƒŽ•˜™›™˜™™“‰€eXLPd{‰‘’‘‘’‘‘•——¢™xB+%)%*2-97531/..65545567FG<3L}—‘¢”ƒp`XY\WT\q„Ž–ž§¨©©§¤ ž”Œ{fTLNSZ\_bddcbgfedfhlnopqrstuvzzz{{|||yxjqqmfzwwwwxxxxtvy|€„†ˆ†‡ˆ‰‹ŒŽŽ“›¡¤©±¸°´º¿À»´®²µ¼ÄÍÔ××ÏÒÐÒÚÕÊÈÜáÞç§WPY[]`cdca`bjvƒŽ”—˜œš˜™™”‰lV@=Ql€ˆŽ‘”’Ž“‘‘’¤L%*0-'-4286310023543359<>T=:Uy’–‰˜–ˆr`WVXZYU]r„•§¨©©§¤ ž”Œ{fTLNSZ\_bddcbhgeefilnopqrstuvzz{{{|||opinnsovxxxxxxwwvwz~ƒ‡Š‹†‡ˆ‰‹ŒŽŽ–¡£§®´©·ÅÄ·«§©¾ÇÑÓÎÊËÎ××ÌÉÑÏÊÑÕÖääéŠZQXZ^abba`biuƒ”—˜œš™š™”ŠuX7.A_v’•“Ž•‘‘’““ ’_0%0/*/578641/025822126<BFTCS|“˜”‹•‘~fUQTWWZV]r„”œ§¨©©§¤ ž”Œ{fTLNSZ\_bddcbhgeefilnopqrstuvz{{{||||fllimwxqyyyxxwwwwx|€…‰ŒŽ†‡ˆ‰‹ŒŽŽ“˜ž¡¢¥¬±®º¾¯›š²ËÒÏÌÍÐÐÍÉÊÏÌÐÙÑËÙÔÏÎÜåÖsCWY\`aa`_biuƒ”—˜œš™šš”Š|Z3%7Wp|’–”ŽŒ•‘‘‹–˜œž{E*15(%6=9=530.038;10027>EJJRt’—™™Žƒq]TX][WWX]k~™œ¤¦§¨§¥¢ “‡ylZKKT\]^`acdeccdfghiinpsvwwutw‡tr}whoppqrsssvtrqqsvx„}xzƒŠŒŠŒŒŽ‘‡•š§µ³§»® Ÿ¬¾ÊÐÅÈÌÏÐÎËÉÍÍÍÍÌÌÌÌÓÒÙäÛâÇfYFO^WW_Y_jy…Œ’˜œš™˜š›—ކwV6,6H`sŠ”™—”””Ÿ“”žƒF'411113589=0%'3:6..686<JOK\m„“–“ŽžykZUY][VWX]k~™œ¤¥§¨§¥¢ “‡ylZKKT\]^`acdeccdfghiinpsvwwutw€ty{wioppqrsssvtsrrtwy‚}z~…‹‹ˆŒŒŽŽŒŽ• ¨®°Ÿ¨¹ËÓÎÆÉÊËÌÌËÊÉÆÇÉËÎÐÒÓÖÕÖÛÖäá¥MMMOTYZX^ix„Œ’˜š™˜š›—ކxW6+3CXi|…•”‘š‘™•h8()/024666680*,484/2139AHOUm~‘˜”‘–¢j`WV[^ZUWX]k~™œ¤¥§¨§¥¢ “‡ylZKKT\]^`acdeccdfghiinpsvwwutvvw‚€wvkoppqrsssvusrtvy{~ƒ‰‹‰†ŒŒŒŒ~—›Ž›¶¬†›¬ÁËÊÈÌÒÎÌÊÈÈÈÉÉËÌÌÌÍÍÍÎÏÐÎÏÍ×ãÒ£}NAPTPW\gwƒ‹‘˜š™˜š›—ކxX7+/:JYs}Š‘‘ŽŽŽ‘‘‘—–˜|D)(!-0589742001344202/4>@CVlƒœ›–¡¥\XUW\^ZUWX]k~™œ¤¥§§§¤¡Ÿ“‡ylZKKT\]^`acdeccdfghiinpsvwwutvp|ˆ|suloppqrsssvuttuy|~„‰Œ‹ˆ…ŒŒŒ‹‹ŠŠŠŽˆ’§ª™²ÀÌÊÀ¿ÍÜÐÍÉÅÄÅÈÊÎÎÎÍÌËËËÓÖÖØØÖÚÞïÄ…WHOUQYdu‚Š‘˜š™˜š›—ކyY8++1<Hiu…‘ŽŽŒŽ’““œ ‡S-%'&,17;<82.)078410215:<;Ff†‘—𖑍¤TSUY]^[XWX]k~™œ£¤¦§¦¤¡Ÿ“‡ylZKKT\]^`acdeccdfghiinpsvwwutwt„†toqmoppqrsssvutuw{‚€„‰ŒŒŠ‡†ŒŒ‹Š‰ˆ‡†”Œš”ŠœºÀÀÁÆÌÏÎÌÍÊÆÃÃÅÈÊÆÇÉËÎÐÒÓÑÑÓÖÚÔÎ×Ýà×—LEXLVbr€Š‘˜žš™˜š›—ކyZ:,*+2:\j~Œ’’’’‹‹‘“”•ŸŸh-'*&2/38<<71-(1::4/147;96@^~‘“‘ŽŽ“›¤©¡TUWZ\]]\WX]k~™œ£¤¦§¦£ Ÿ“‡ylZKKT\]^`acdeccdfghiinpsvwwutxŽ}jllloppqrsssvuuvy~‚…„ˆŒŒ‰‡ˆŠŒŒŠ‰‡…„ƒ…’Ž€Œ°ÅÂÉÆÃÅÈÈÄ¿ÅÅÄÄÅÇÉËÉÊËÌÍÎÏÐÊÅÉÈÍÐÌÕÊÐèÑx;>LS_p‰‘™žš™˜š›—ކx[=/,),2IZr…’“”‰ŠŒŽ‘”•–™„E+.(:358:961.,2872/26=:5;Y‘Ž‹‰š£§§¡XYZ[[\_`WX]k~™œ¢¤¥¦¥£ ž“‡ylZKKT\]^`acdeccdfghiinpsvwwuty—rakhkoppqrsssvuuw{€„‡‰ŒŽ‹†…ŠŒ‹Šˆ…ƒ‚‡|…¤¸·ºÇÊÉÆÀº¸¼À¼¾ÂÆÉÊËËÏÏÎÍÌËÊÊÎË×ÏÌ×ÖÙÛÐÕá¹^2JQ]o~ˆ‘™Ÿš™˜š›—ކw[?3.**/4HczˆŽ‘’ˆ‰‹Ž‘”–˜‡T+&-+-5888764212443014844=Uw•ŠŒ‘™¡¦¦¥¤\]\[Z\`cWX]k~™œ¢¤¥¦¥£ ž“‡ylZKKT\]^`acdeccdfghiinpsvwwutzšj[jejoppqrsssvuvx{†‰ŒŠ„ƒ‹’Œ‹Š‡…‚€u†¦¿½¯²Â¾º¸ºÀþ¶ºÁÇËÍÌËÈÈÊÌÍÏÑÑÉËáÕÇÒÎÊÒéÛÛãžJBP\n}ˆ™Ÿš™˜š›—ކw\@50+*.&:Xr‚Ї‰‹Ž‘•—˜w.6,&1,<:753333741//269%.JqŠ‘•ˆœ£¥¥¥¥¨YYYZZZ[[YWZfx‹—œ¡£¥¦¦¤¡Ÿ—Ž}hULNRUX\`bcbbcdefhjkkjrrusqrezÀ‘]ikomlmnpqstuzyyz~„ŠŽ’Œ†„‡Š‹Š‡•Œ|}ypqœ®»¼»¾½¸³½ÆÄ»µºÁÂÃÅÇÊÌÎÏÉÉÊËÌÌÍÍÊËÌÍÎÏÐÑÒÖÑèãÉ›6MZ{}…‘¤’˜œ™š›’„nU;11/+)"3EVjyˆ– £~Ž“‰.-++-27;887766660357:<5+>o‘›”‹†—˜›ž¡¤§¨ŸYYYZZ[[[YWZfx‹—œ¡£¥¦¦¤¡Ÿ—Ž}gTLMRUX\`bcbbccefhikkpmpprumgŸ½ƒ^ifkmlmnpqstuyyz|€„ˆŠ…ˆˆ„€ƒ™ƒ„†ƒvi{ž¾³³¿Àµ³½½¿¾¸³µÀËÄÅÆÇÉÊËÌÉÉÊÊËÌÍÍÊËÌÍÎÏÐÐÆÜ×ÙÝäÀQ@Xf€Œ’›•˜œ™š›’„r^@+-61").7:P‘ÇÍÔÔ¸²Â©Q,,,-036877766655/15:93..0T€–“ŠˆŒš›œž¡£¤¥ŸYYZZZ[[[YWZfx‹—œ¢£¥¦¦¤¡ –}gTKMQUX\`bcbbccdfhijkvhpkovgqÅ·taiaimmmnprstu|}‚€Š„€€„ˆŠ{xwstˆ¡Â»²¯µ¾Á¾¸¹¹¹¹½ÂÇÆÆÆÆÆÇÇÇÈÉÉÊËËÌÌÊÊËÌÎÏÐÐÍäÛÔÚíØz,S]ˆ”—˜˜œ™š›’„v_E62/..+##\³ÔÒàÉËÇÌÖÈ&(*-13455666555440.6>6'(6Rr”›‹‰—ŸŸŸŸ ŸZZZZ[[\\YWZfx‹—œ¢¤¦§¦¤¢ •|fSJLPUX\`bcbbbcdfgijkueujkqd‡Ð«ofhbllmnoprtuuvy~‚„„‚€Žˆƒƒ……yrknvˆ¬¼«¹¼´©½Âºµµµ¹¾ÂÄÄÇÆÆÅÄÃÃÂÇÈÈÉÊËËÌÊÊËÌÍÎÏÐÔÙÓÙÛáݱ1Fg{|—›–˜œ™š›’„x_C631+'aÆàÕȸÌÐÚßààº'&).36542555444331-6@4!*Et‰›™Š„‘¢£¢¡ ŸžœŸZZ[[[\\\YWZfx‹—œ¢¤¦§§¥¢ ”Œ{eRJKOUX\`bcbbbbdeghijoezoigh¥ÈŸrjgfqkmnoqrtuvosz…‡‡†u~‰Œ†€}}kd|¥ªµ·º²±·²¦¨´¼·²±¶¾ÆÊÅÄÄÃÂÁÁÀÇÇÈÈÉÊÊËÉÊËÌÍÎÏÏÈÈÊ××Öâßh9gv}™œ•˜œ™š›’„z`<&(.%&‹ÏÓȵ¸ÙßàéèâêÜX&).36542443332224/6>3&:\Œ’—”‘œ§¥¤¢¡ž›šžZ[[[\\\]YWZfx‹—œ£¤¦¨§¥£¡”‹zdRIJOUX\`bcbbabcefhijjiytlbsÀÀ—rhdiqinnpqstuv~€€€~|{x~†‰†~vqp›°°¯°¦«²µ¯©ª¯´¶¹º»½ÀÂÀÀÀÁÁÁÁÁÆÆÇÈÈÉÊÊÉÉÊËÍÎÏÏÃËÏÐÍÒßâ´JXr‹—˜—˜œ™š›’„{Q3.!$K¯ÊÞÀ¡ÃêàÙÙÜÜÛçí–(*-1345533222111745847Ux–“•œ¢¤¤£¢ Ÿœ›ž[[[\\\]]YWZfx‹—œ£¥§¨§¥£¡“‹zdQHJNUX\`bcbbabcdfhiiilpwtcƒÍÁ’kacgjhnopqsuvvˆ†‚~{xxw‰„~~€|ri¦°«³¤œ«±«º»±©µÃÈû··»¼½¾ÀÁÂÃÅÆÆÇÈÉÉÉÉÉÊËÌÍÎÏÍÒÒÍÎÓÕÕÙˆSjŒ˜œ˜œ™š›’„sH/1$!\®åˤ¤Ìà×ÔÝÛÓ×ÞÝê¹,,,-036822111000;9515Kq‘˜“Ž˜žŸž¡¡¡ Ÿžžžž[[[\\\]]YWZfx‹—œ£¥§¨¨¦£¡“ŠycQHINUX\`bcbbabcdfgiiknhx{fÒÇ‘bZbcbhnoprsuvw{zxx{€…‰ytsx}®·µ²¯Ÿž³´ª§±¸µ³¶®ºÆÅ¼´¶¼¸¹»½ÀÂÄÅÅÅÆÇÇÈÉÉÈÉÊËÌÍÎÏÒÊÉÏÙÙÕØáÅ\b‹ ˜œ™š›’„fS/'i¶åî²ÐßÙÕÕÒÏÃÑãØåË.-++-27;111100//=<5-6X„ —“’˜œ›˜ ŸŸŸŸ````aabb`^`izŠ•™¡£¦¨¨§¥¤˜~hULMQY[_bdedchgeefilndwhofe²Î²”p^`ijgg_`oyz{|€|su„~Žscs”ª£§ª©¦§ª¦²½¼²²¹½´³º¼¶µº³±²¸ÂÉÊÈ÷ÁÍÄ¿ÉÍÄÆÌÓÖÓÊÃÎÎÎÎÎÎÎÎÞÓ¥uuœ¥š–œœ|^>";ŽÚྸÀÌÖÙÕÎÉÀÊÑÏÛÛåÐ)'(.8;72).20*(,10-&-Q›’•™Ÿ ŸŸžžžœœ```aabbba_`jzŠ•™¢¤¦¨©§¥¤˜~hULMQY[_beedchgeefilngyntig¾Í©Žn_bijfhnssruz~|{tr|‰†yŠrkuŒž¤««¤¢©±µµ²±³··»¶°¸Å»¥±´¸»¾ÂÆÈÕÀ½ÆÄÃÅÁÈÆÂ½»¼ÀÃÍÍÍÍÍÍÍÍËÕϳ“Ž™– ž’Ž‘†rJJp´ÛÏ·®ÆËÒ××ÓÌÇÅÍÒÐÛÝæÉ((+06864/1320/13/'%:e›—“•™Ÿ Ÿžžžžœœœaaaabbbca_aj{‹–𢤧©©¨¦¤™iULMRY[_ceedcgfedfhlnhytxikÊÉœ†ladjidnz}spvyuxwuv€ˆƒw„pfu‘¡¡œ§’‘§©™ º®°´·¶²®·¶·º¹³¯®±·½½ºº¿ÅÏÄÅÇÀ¾ÄÇÐÁ²±½ÇÇÃËËËËËËËËÊÐÛÞ‰˜‘¥˜•œ“zfmÕæÍ°²ÅÔÕ×ÖÓÏÊÇÌÒÔÑÚßç¹%*03435642136764,"+R‚›™•—›ž Ÿžžžœœœœaabbccccb`ak{Œ–›£¥¨ªª©§¥™iVMNRY\`cefedgfedehkmgutuetÑÀlcfjhdttqosyvnsz€€}{zypkv“¤ —–‰šž’“§³±¨«°·¹¶¯©±¶¿Àœ§Àµ¸»º¸¸º½»¾ÆÈÃÂÇÌ´«§±ÃÍǽÈÈÈÈÈÈÈÈÏÊÉÚݱ¡••—žŸ€‹¢ÇÖж±ÆÓÏ×ÕÓÐÍËÉÈÒÖÕÔÙáç¢%-4620384/,06:72)&=p™¡–Ž—™œŸ žœœ›››bbcccdddcabl|—›¤¦¨ª«ª¨¦š‘€iVMNRZ\`dffedgfddehkmdool_„Ò´‹}mfgjhemfdmsrqsx}‚ƒ{srupw‹¢£•–”›˜Ž—¬Ÿ«¯¯®®°²®½½ªž¦³¸¹·´¶¹º¸µ·º½ÃÌÌú¡¬¹ÁÃÃÅÇÅÅÅÅÅÅÅÅÆÊÅÌÙÌ™œ‰–˜‹¨ÅÒѾ¯·ÊÖÖÒÎÌÊÈÇÈÊËÓ×Ö×Ùãäƒ'/662026/*(,3750*7[‰¢ž”’š›ž ¡Ÿžœœœœ››››cccddeeedbcm}˜œ¥§©«¬ª¨§š‘€jVMNSZ]`dffeefedcegjmfkkd[ŸÏªqhgijia_eooio}zz~}vrt‡Š’˜–‘˜œˆ‹¥«šœ±µ°©¢ §³½¼¯¢ «¶µ¬¸´°²¸»·²µÀÁ¾ÃÁ¶°¸¼ÁÃÃÃÆÈÃÃÃÃÃÃÃÃÂÆÂÃÏÕ—‘‘Š›½ÕÕȱ²¿ÒÔÉÆÍÆÆÅÆÇÉËÍÐÕÖÚÚãÞc,0454223*(),14436Px—Ÿ—“–œž ¡¡Ÿ›œœœ›››ššcdddeeefdbdm~Ž˜¥§ª¬¬«©§š‘€jWNOS[]adfgfefeccdgjllmj_\¼Ì¨“†vjfhkmadjnnnt{zttzzux–˜”“—–”¡¡ §«©µ¤¡¥²´´ 𬹴®±±±³µ··¶°ÂÀ³²³²¸¿¶®±¼ÃÀ¹ÁÁÁÁÁÁÁÁõ·ÀÄ̳œ ´ÌÏÀ¼ÅÅÈÉÉÌÏȽÇÇÉÊËÌÌÌËÑÕÝÛã×G1014662.(+/1248;Hiš—””•žŸ¡¢¡Ÿœ›œœœ›››šš™dddeeeffebdn~Ž™¦§ª¬¬«©¨š’€jWNOS[]adfgfefeccdgjlrpk^_ËÊ©˜‹ykeglohmlip{zqoou{up}“”œšŽ—™’“—ž¥«ª¢™¦¢ªµ·¡‘¥´³¯±±ª¯´´²²·¼³» »»¾µ²±¶¿ÆÅÃÀÀÀÀÀÀÀÀ½¥³ÂµµÓ¥Ÿ¹Íɽ»ÀÃÊÔÚÔÈÃÈÐËÌÎÐÐÎÌËÇÏÔßÛâÓ740/2882+(/5645;BVy–˜’“•“Ÿ ¢£¢Ÿœšœœœ›››šš™eedddccc`afn{Š˜ ¨ª¬®¯®¬ª”‚kWMMQY[^accbabbccdefffklZ~Ôø–‹|rmlif[qqkv{ttrz{tt~‡ˆ“›‡•ˆ›¡žž£¡›š¬º·®¨Ÿ•«¯±°¬¯²§«®¯¯´»Â³±°´»À¿¼ÆÀ»¼ÀÁ½·³º¼¶µ»»µ½»·´µ¹ÀÄÏʼ»ÀÇËÇÇÈÈÈÉÉÉÉÐÐÈÈÍÊÀÒÖÐáÙç»+/*(+374/-).9<;ET’›–”šœ˜ŸŸŸŸžž›ddddccbb`afn{Š˜ ¨ª¬®¯«ª”‚kWMNQY[^bccbabbccdefffjkYÔø™Ž€vrpliaoqjmuxzwr{•’”…“ž‡~ŒŽš–›¢›š°¯¦¦¯«žŸ¬²¬¨«±´°ª·¯©ª±¶´°²¶¹¸µ´¸¼Â¿½¼½½»¸¹®¿Ã¶®°¯±±¯®µÂͼ½ÀÃÈÌÐÒÇÇÈÈÈÉÉÉÌÉËÑÏĽ¼ÊÍÚÔ×ä/+),263/*-5823Jg‡’—“”›ž™ŸŸŸŸžž›ddcccbbb`afn{Š˜ ¨©¬®®«ª”‚kWMNRY[_bdcbabbccdefffhjW‡ÓÁ¶ž”‡}yvrniknifq||~|ww‡™›“‹Œ–Œx‰‘šœ““¢³¬ ˜›¦¯²«¬¬¬¯°¯®¬«¬°²´·º·³°³¶¼½¾¼¸¶·¹±ª®¹¾µ©®¦£®ÀǾ±³ºÃÍÒÓÑÏÇÈÈÈÉÉÉÊÏÄÈ×ϵ¬¸ÇÌÛÌÏÝS!/-+-2420'2;5'.V€“’•ž ›ŸŸŸŸžžœcccbbaaa`afn{Š˜ §©¬®®«©”ƒlXNNRY\_bddcbbbccdeffffhVŽÓ¾µ¢™…}wsmdhlit}thu€…–”ŒŠ™ƒn…š˜™š•‰ŽŸ¥žª©ž“›®´¦«¯¨§«°£§«ª§©²¹¶²¯±µ·´°¶º¾º³°³¸®³°ª°¸°¦²¾À¹³´¸ÀÅÌÐÑÍÈÄÈÈÈÉÉÉÊÊÏÇÊп¤£·ÃÌÏÏÐÂ,20/./1110*5<2'7g“˜“Ž— ¢žŸŸŸŸžžœbbbaaa```afn{Š˜ §¨«®¬ª©ž•ƒlXNOSZ\`cddcbbbccdeffgcfS–Ó»³¥“‹‡‚{ul^cpsyyjbzމ‹’‘ƒpž—‹ž›Ž‹˜ž™–œ¤˜—§¯ª¦ª¬§£¦«®ª¦©¤Ÿ¡©¯¯¬ª©´·¶³²·º¶°¬¯´·®®·´¥ž¢»¿Àº³µÁÍÍÍÌËÉÆÃÂÈÈÉÉÊÊÊÊÍÏ˼¦š¤´¸ÃÏß…201210//0.6947Qy™œ“Ž’š ¢¢ŸŸŸŸžžœaaaa```_`afn{Š˜ ¦¨«¬ª¨ž•ƒlXNOSZ\`ceecbbbccdeffgaeRžÓ¹²¥Ÿ–‹…}vh^bqxxskv‰•‚†‘˜‚pƒž˜“•‹‹Ž•œœ˜””—™ «°¬¤ §¦¥¦¨¨¨§ª¥¢¢¢¢¢£¨®®¯´¹±³³±®¬®²«¥¢£©µÀƹ°·ÉÔÑÉËÉÅÃÂÄÆÈÉÉÉÊÊÊËËÍÑĨ˜§¨“¿ÊÜA #1353/,.1048=QpŠ–š“’™žž ¥ŸŸŸŸžžaa```___`afn{Š˜ ¦¨ª¬¬ª¨ž•„mYOOSZ]`ceedcbbccdeffh_dP£Ò·°¥ž—‘†}uddentmmyŠŽŒ„ƒ‰Š…r|•™Š”œ†ƒ’™“–Ÿš‹“£©¡ ª©ŸŸ¥ª¨¢ ¥«¦ªª¤›™ž¤¥©®««¯³²¯¬«¨¨«¢–ŸºÈůºÇÎÎËËÍÄÂÁ¿ÀÂÅÇÉÉÉÊÊËËËÏÉ´œ›©§–Ÿ·Î¯%$1574.+-1,3<LjŠ–’•’˜¡¢œž§ŸŸŸŸžža```___^`afn{Š˜ ¦¨ª¬«©¨Ÿ–„mYOOS[]`ceedcbbccdeffh^cO¦Òµ°¤ž—’†|tbjijlcj‡ˆ~}‰~fxІ‘Šž•ˆ†” œ“ޤ ¡£ž™¢°¦£¡¢¦¨¦£¥ œœ¡¤¥£°¬¨©®«§³¨©®¯ª¤®¥¥µ¿¹®©¼ÀÇËÌÉÅÃÂÂÂÁÀ¿¾¾ÉÉÊÊÊËËËÒÁ¦˜¥´¥ˆœ´®×x)51695-*,1'2AWy—œ‘’œ§¤šœ¨ŸŸŸŸžž````````_bisŒ—ž§©«¬¬«©§¡—…mXNNQX[^accbaccccccccac]UÉʼ«–—™Š|wmiil€ŽŠ‚„…†y|‚ˆŠŽŽŠˆŽ–œŽ‚•¶›™ š¥ªš˜¤›£©¦§£–†¤»¥¡«¤¢««³¬ ™ªª¨¦£ª˜¡¬¸º¶µ¼ÅÉÈÆÃÁ¾½¼ÃÃÄÅÇÈÉÉÍÊÉËÑÖ××Ò°Ÿ¢®Ÿ¥ÂÎ:/A('8@5,19:,5Lp™™š›œž ¡¢œœœœœœœœœ`````````cis˜ž§©««©§¡—…mXNNQX[^accbacccccccc_a[TÉË¿±±œ›Œ}wfcmv‚‰ƒ„Œ‚„rŽŽŽŒ‰†…‰——ˆ†•œ–Ÿ‹§«–˜’—ªªŸ¥œ¡Ÿ¡¨¡ª£¥ž“¦«¥›¥˜®©’ž¥œÄ¹®ª±ºÀÂÂÂÁ¿¾½¼»ÃÄÅÆÇÈÉÊËËËËÊÉÇÆÓ‘—¢œ¨–°Þª".,806502::2.6S}—˜’“šš›ž ¡¡œœœœœœœœœ`````````cjt€˜Ÿ§©««©§ —„mXMMQX[^accbacccccccc\^XRÉÍÄ··¥¢Ÿ’ƒ{a_uƒ{ˆ„ˆj{{“Ž“‘‰†…„„œ“†‚¤©¢™§ŸŒœ™Žuzta^¨•¨¦¢¥ ¡ª¯¬—¥¤ª¨¢œ˜–›¤Ï½µ°µÂÉž»»¼¼½½¾¾ÄÅÆÇÈÉÊÊÍÊÆÅÈÎÔØ¥›¦ ’‡to•Àæc2 853/.5=9/0>cŽ’•›œœžŸ œœœœœœœœ›aaaaaaaaadktŽ™Ÿ¨©¬¬©¨ —„lXMMPX[^accbaccccccccZ[UPÊÏɾ·©¥ ““—ƒed|…€€ˆ‡l{t—ŒŒˆ„ƒ„†ˆŠ€Œž¤ž™hqppvu‚¡‡„šŽz\•«£Ÿ¤‘³¢§œŽ“ š’˜§–˜’’¼Ñ³«´ÂÌÏËþ¹º¼¾ÀÂÄÄÅÆÇÈÉÊËÌÌËÎÖÛ×ɽ«™–}b_ev³ÖÍ'#*%2222247744Ox˜‘Ž•žžžŸŸŸœœœœœœœœ››››››››šbbbbbbbbbeku‚š ¨ª¬®®¬ª¨Ÿ–„lWLLPX[^accbaccccccccZ[TNÉÐÌ´«§Ÿ••›šŠom€€zŠ…r|v—‡…†„‚‚†‹Ž€ˆ—œ•|b}…‚zs`\p_ƒ¥§¬pnqˆ©“’šnŠ¢›kXNp›£’žÃ»¢¥»ÄÌËþÀļ½ÀÂÅÈÊËÇÇÈÉÊÌÌÍÌÈÉÔÝÕ½§–`?]dg¬Îá‰!-330035555>eš–”””ŸŸŸŸžžžžœœœœœœœœ››››››››™cccccccccflv‚›¡©ª¬®®¬ª©Ÿ–ƒlWLLPX[^accbacccccccc]]TMÈÏÌö°©ž”’™‰ts~{x€†tzy˜‰Ž~‹~~„‡‹…’ž™„rm‰•‰plpfVSŠ¥¤±ƒxouYc€‹—emM_YsJ>ŽŽ§Â¬“§¶ÅÅÃÁÀÂÆÉÀÁÂÅÇÉËÌÈÈÉÊÌÍÎÎÊÈÊÓ×Ê”uK[eWv¡²ÞÁ;*".2,8.*29842Qy˜—•›˜¡¡ Ÿžžœœœœœœœœœšššššššš™cccccccccfmwƒ›¡©ª®®ª©Ÿ•ƒkVLLOX[^accbacccccccca`UMÇÏ˽¹®‹–€rqxy|{qqxŒ“†„|~€ƒ…††…”‹Œ“Œ}ƒ–qcg\G?@E™˜—€|uxyX_hRNBJT8</@"{»¶˜®ÂËÀ¾½ÀÅÈÈÆÀÀÁÃÅÆÇÈÉÉÊËÌÎÎÏÈÌÏʸ™u\XXb`p‘°Õ×q*.97$5--57217i…™”Œ’¢£¢¡ Ÿœœ››››››››šššššššš˜ddddddddcgmwƒ›¢©«¯¯«©Ÿ•ƒkVLLOX[^accbaccccccccdbVMÆÎÊÁÄÀ²„†Žwlmtz€u]s‚‰ŒˆŽ†~}€ƒ††ƒ€}Žš”|r€ŒŠaalnfkiV[}‰Š}{pJC=GjT?V=(2,6,.0M«§ÆÅÈÇÉÆÂ¿¾¿Á¾¿¿ÀÁÂÂÃÉÊÊÌÍÎÏÏЧ„eVW^Oa_ZŒ·ÁÜ¿,2$8,9*-.6;2'/@z‰–”ŒŽœª¤£¢ Ÿœ›››››››››šššššššš˜ggfecbaagiox„›¡¬¬¬¬¬¬¬¬Ÿ™‰oUHJQY\_bddcbddddddddb`ZEÓÏÅÐɨ Œs‚„zuwjtzgt†ˆ‹Š†|zƒƒƒ„†ˆ‰Š† •cw|Ž€s}pu…ˆr?OdR~qUI7?]qEH@W:)5,Dz¼›™¦ÂÔÐĽÃÃÂÁÀÀ¿¿ÁÆÅ¾ÄÌŽͿÂÒÂÊÐȇoVNYcc]Zo}°Á×°--./00110)420'([Ž’•”“—¢«£¢¢¡ ŸŸžžœ›šš››ššš™™™™ggfedcbagiox„›¡¬¬¬¬¬¬¬¬Ÿ™‰oUHJQY\_bddcbdddddddddZ]KxÕÍÉËÇ»™{u‘€€{npqkyŒŽ‰zww††ƒ|wz†‹ƒxkƒŠybƒukWCD>HGZkjdn\p`WW72L:6-&&’¿‚œ«»ÃÃÂÁÁÂÂÁÁÀ¿¿¿ÀÀÁÂÃÂÃÇËÏÎÍØÑ”[RSTWY\_as…©½µÌa%..//001102983,;l’“”–›£©££¢¡ ŸŸžžžœ››š››ššš™™™™hhgfdcbbfiox„š ««««««««Ÿ™‰oUIKRY[_bdcbaccccccccfU`SZÏÑËÀÔ³›{j’ˆŒ{qmjv†‡‡ƒ~|~„†‰‰‰ŠŽ’~l~‡ƒ…quwlSH>6>@<B_loj[e`dp+G/t:2$J°ªuª½Æ½µºÁÁ¿¿¿¿¿¿¿¿Ä¹´¿ÃÂÎØÅÊι°…XhdaZSTc|޵º¶Üu!00000000/<=?72Xƒ”’‘”𡤥££¢¢¡ ŸŸŸžžœ›››››ššš™™™˜ihgfedccfioxƒš «««««««« š‰pVIKRY[^bccbaccccccccfX_XI·ØÊȽÁ˜€‰€”Žtqqo†‡…€{z}ƒ„‹ƒ|}…Œ‹‡‚]€Œ†‚d^7Q_WG>:2BihvXF%a\^hS?+j=Zª¼xy¿À»´¶¾Á¿¼½½½¾¾¿¿ÆÂÁÍÊÄÌÈͧlt€a[^^ak}ž¦³»¼Ðz&.>22211000+@<@8<q“–’–Ÿ¦¥¢¤££¢¡ ŸŸŸžœ››››ššš™™™˜jihgfedcehnwƒš «««««««« šŠpVILRXZ^accbaccccccccda^YIŒÛƾȰ±‘ŽŒ„jqy’ŠŒvv}‚~x€‚ˆŒ‰€x}^kWD9ZXN8,046e„n`($9fSMbU(,m0$X¬ tŠÌÃÆ¸®²»¾¿Á¹¹º»½¾¾¿ÆÅ½ÅÄÉÕ¾¶qXmŠŠmntx„–§®ª£´Æ„&*,>543210//*=7::K‚—–“’™£¨¦¢¤¤£¢¢¡ ŸŸžœœ›››ššš™™™—jjihgfedehnw‚™Ÿªªªªªªªª¡šŠpWJLSXZ^abba`bbbbbbbbcj`ZQgÓÅijɷ¡™ž…wjt€‹“…ysv„€{o|‰‡ƒ‡~iŒbF5GLR83;@7(-€g^8%AZ@YT+<dDj¯žp¢Å¿Ã¼±¯·º¶¹Ã¶·¸º»½¾¿Á»±ÆÍȵtRdgnj›š¦§¨¨§§ª¾È‰1/.6765320/.0623?cŒ’“”˜ž¤¨§¥¤¤¤£¢¡¡ Ÿžœœ››ššš™™™—kkjhgfeeehmw‚Ž™Ÿªªªªªªªª¡›‹qWJLSXZ]`bba`bbbbbbbbene\VU¼ÉÅÇÀº«››š~nu|ƒ‰}mqv{~€ƒ…t|tgj€–‹bSAGMYM1+:7'#8hnCH'Kh†\ZW&@"PG…µ“x˜Âɸ½¯²¶¹¶³³·³´¶¸º¼¾¿»ÁÅÖ¸ˆg&Q~ete}”³™¢©ª¦¨±»Ô•,4+@%986420.-;11/H~“‹–£¤¥¦¨¥¤¤£¢¡¡¡ ŸŸžœœ››ššš™™™—kkjihffeegmv‚Ž™Ÿªªªªªªªª¡›‹qWJLSWZ]`bba`bbbbbbbbgni]WQ¥ÌÒÅë©¶ šyj€ƒ‚wiv‚‚zuz‚x‡•’€lccmR>GJIG9.4D3$.CgJ@B*_fP|^>ca¡um–Î½ÆÆ±ªµº¶µ¶°¦²³µ·º¼¾¿ÀÎȯY'Uf:pnh“𥍫«©©²ÃÏ'+5452:97520.-D/3.O˜‡—¡¦¤£¦ª¥¥¤£¢¢¡¡ ŸŸžœ››ššš™™™—mlkihfedgdcl|œ¢©©ªª«¬Ÿ›ŒsXIHMTW[_abaa``aabccdmnlecLcÉÒÉ˪¡¶¤›W|…x|€sj‚‚€}zyyˆ‹gBSUNRSOPRE/6`D,-6[H158GX8iY,@‘4'–y‰¢¿É¹ºÀµµµµ´³±±¶²°µ¾Ä¾¾½ g;;WnXe‰v|p”’¥¦¬®¸Æ®y)*+-/1348;;6.+06922Hp’†Ž˜£ªª©¨©££££££££ ŸŸŸžžžœœ›šš™˜˜™mlkihfedgcck|Ž›¢©©ª««¬Ÿ›ŒsXIHMTW[_abaa``aabcdd^fkfgVUŽÔÐÏ¿ ±»†p~„‚yst…‡…{onz†ƒvvth[LD;NYN=52.Nu/$E^L,;<;A*dW sj)_n‡¬¶ÂÅÀ¹µ´²·»ºµ®©¹µ³¶¼¿¼¸¾¼¤xSKT\][z‚vi‡—¢©¼Á§_*+,.02448::5.,066/6SvŠ‹„’›¥ª©§¦§££££££££ ŸŸžžžžœœ››š™˜˜™mlkihfedfbbj{›¡©ªª«¬¬Ÿ›ŒsXIHMTW[_abaa``abccdd_gkfjdRV¶×Ðɱ°¼rŒ~€‰ru€ƒ„~ury‹ƒ†nijOQ:Q\K0"&/hy$/FWI&;<44&XF#‚pvm]s·Â¿½¿Á¿¹´®±¶¹¸´®ª»¸¶¶¹º¸µ¿Æ·‹]JUckXh…|t™¬±ÊÏ“A!*+,.024567873..152.?d€„€‚˜ ¨ª§¤£¤££££££££ ŸŸŸžžžœœœ›š™™˜˜mlkihfedeaaizŒ™ ªªª«¬®Ÿ›ŒsXIHMTW[_abaa`aabcddepnmhjn_LtÔÒÁȺ¥u”zz„xp|†|zy{€}zwwVQVJTQ\WD2'*7le1S2B=9EFIK>]GMui£pr§¹Â¾º»¾¾¸²¶´±®®¯°²¸···¹ºº¹ÁÌÇ¡nRVeqe_p‰•§Ã´l0+4--.0145787641/02401Lv‡}yƒŸ¤ªª¥¡ ¢££££££££ ŸŸŸžžœ›šš™™˜mlkihfedd`_hy‹˜žªª«¬®®Ÿ›ŒsXIHMTW[_abaaaabccdeeumkonmhYP¼Û¾ÆÇ¥‹‰vtwot‚ƒ~wrs{‚qtN:CHKCabP=5.1CVZ0AQ)11>?=JH;WPStZ‚x¡³®º¼¾¼¶°ª¨·´¯««°²³µ¸º¼¾ÀÃÂÈȶ“nWOZk`O„™¯]6((,//023679:630/02342<^ƒ‰yx‰¢§ª©¤ ¢££££££££¡¡ ŸŸŸœœ›š™™—mlkihfedb_^gxŠ—ª««¬®®¯Ÿ›ŒsXIHMTW[_abaaabbcdeeehfgutgf`Vœã̷θ•{uqmnz€ytx}€|ywƒ}PEG@G6W[L<8-1L:aLK,2..1.)2&#L]JYZ|˜žº´º·®§¨¬¯°°°°®¬«³¸½¿¿ÁÆËÅÇÉ¿ x\R9Z_?gˆ}‹g1$58-123579;<51,-04438MpІw~’¤§©§¢ ¢¥££££££££¡¡¡ ŸŸžœ›ššš—mlkihfedb^]fw‰–œ««¬¬®¯¯Ÿ›ŒsXIHMTW[_abaabbbcdeefcjfsvggdY”â×ÁЮwztnw|vpt|‡‰{i\pcVO?11,EPJEF51L*]lS82112+-"1\o_JeŽŸ£¦±¯³´®¥¤«´°¯¯®¬¬»ÀÅÅÂÂÇÌÇÇÈÀ£{a[19RNKy~œzL64*&433579;<=4/*+1552@^€‹x‡œ£¦¨¦¢¡¥©££££££££¡¡¡¡ ŸŸžžœ››šš—mlkihfeda^]evˆ–œ««¬¬®¯¯Ÿ›ŒsXIHMTW[_abaabbccdeffjvhmtjmkKÛÖÛÏdy€wt€|mjŠ…ƒ†‡{cNJ3GK=8+0=JHNYE5H(N…Y*362/4+.,HilRt˜–µ»»³ÄÀ¶©ž¦®¸³«¥¤©¯´ÂÇËÉÃÁÅÊȾ¾Ä¶ŽbK> Be@x…’›…N$(4/*3468:<=>4.(*1652EiŠŠzx¢¢¥§¥¢¢§¬££££££££¢¡¡¡ Ÿžžœœ›šš—jjihgeedb^^fw‰–¦¨«®«ª¤™‹x^IITVY]acddcgecbcegihmtxwqjdRŸÓÐÒ¹ekxjl~€rp||–ytˆQ"49OB/,*,4OP:]F/Z+1c„X<7%0-$PŽsY™…¨¸¬¸½Àº°¦¡£ª°±«¤¡¥¯»ÃÃÄÅÆÈÉËËÍÊÈÆ¶•oV?/-CNO›˜§€$3/2/46459?@;7-61+2537Q‚“~{——œž ¡£¤¥¨§¦¤£¡ Ÿ¥¤¢ žœ›šžžžœœ•jjihfeddb^^fw‰–œ¦¨«®¬ª¤™‹x^IITWY]adddcgfdbcegicglqrqmj]wØÐÓ˜ljcoyyss|‡‡wty}b0)SG=+%501BIHPG4S0-2ua\WE#(Vtq©©z¶¬½·½¹°¢™»¬©¥¤©²½ÃÃÄÅÇÈÊËÌÐÎÍʼw]C*+9MJާ(303/47559>?;6.30/40/:_‡‘~‘™˜››œžŸ ¡¢¤¤££¢¡¡¡¥¤£¡Ÿžœœžžœœœ•jihgfedda^]fw‰–œ¦¨«®®®¬«¤™‹x^IITWY^adedcgfdccehioopqqqpoiUÍ×Ï{nmooopx€‚wbXZVJN'+c?+'336.5>OCD9O%E<ƒQ!!@Їl™µ¤§…‹±¡»º¸³«¢Ÿ£«²¥¥¦ª°·¿ÃÄÄÆÇÉÊËÌÓÓÑÎé‚eI&&.GFw£©ƒ030315866:>?:5./.46+,Btއ˜œš™™š›œžžŸŸ ¡¡¢¢¥¥¤¢¡ Ÿžœœœ››•iihgfedca^]evˆ–œ§©¬®¯®¬«¤šŒy_JIUWZ^bdeddhfdccehj‡ƒ}wsqqrqV¤àËuku„mbqƒ„}z\QIP<>ND9b5*J+;.24B>:9UIS(_b&15;†€f”µµš¬•™±¢·¼¶¥§®®£˜Ÿ¢¨¯¶¼ÁÃÅÅÆÈÊËÌÍÒÓÑÎDzŒjP**:D]¤«†:21426977:>>93.-.77'/Q‡’‹‚ŸŸ˜˜™™™ššš™š›ž ¡¢£££¢¡ œœœœ›››š•iihgedcca]\evˆ•›§©¬®¯®«¥šŒy_JJUXZ^beeedhgecdfhjŠ…~wsrtuvl{ÓÏynyupqz~}…}raU,6&*:f( 3D3<18/-C-5_wg2@{%.y—p‹º©¤µ•ž®±¹¾µ¥§¬ªŸ£ª²¹¿ÂÃÅÆÇÉÊÌÍÎÏÑÐÌɺ”mW5,,CJœˆE12547;98:==72..075);d’’ˆ‡š¤¡¡š™™™˜˜˜˜–—˜šœžŸ ŸŸŸŸœ›››šššš•ihgfedcb`]\euˆ•›¨ª¬¯°¯¬¥›Œz`KJUX[_cefeehgeddfikyvsppswyxxm®Ó~vvew€yz†‰€[TBA6B",,l(38.G74;-*F&3_P^YUžA'y‹w´±µ²®¿˜™¡±¼Ê±®©¡œ›ž¡¤§³º¾ÁÃÆÇÈÉËÍÎÎÍÒÐÌÍÄr^B!/%>CН‹O13658=:9;=<60,34300M{’ކޢ¦¡¥œœ›š™˜˜––—˜˜™šššš››œœ››ššš™™™•hhgfeccb`\\du‡”›¨ª¯°¯¬¥›z`KKVX[_ceffeigeddfikqqppruwyvvp†ÅŠxqw€zƒŽ€dJK5?U8!)(XB82:J/77/?D'4SEL9&tXOxx¥Æ»°¼›¡¯¼Æ¥§¥ž—™£®«¬¯³¸½ÀÃÇÇÉÊÌÍÎÏÐÖÔÐÔϨzeL/.&3Gu±V04779>;9;=;5/+98-+8`Œ‡„”¨¦ ¨ Ÿœ›™™˜——––•””••–—˜™ššššš™™™˜˜•hhgfdcbb`\\du‡”š¨ª¯°¯®¬¦›z`KKVY[_cfffeigedegikyyxwwvvurpsu¬™tn“Š‚†‹ƒiP1>,Ao()619a-)\=(700W?+7E=J*Qu;¨xsž¨¤µ´¼µ°„²¼¼¬š›žŸ¡¤¨«°°±²¶»ÀÃÇÈÉÊÌÎÏÏÔÛÙÔÚÔ°iP:++*Mf±Ž[04779?<:;=;4.)<;)'>l›‡ƒ„—«¦Ÿª£¢¡Ÿœ›š™˜—–”’‘‘‘’“”•—˜˜šš™™™˜˜˜•eeeddcccd^[bs‡–ž¨ª®°²±°®¡œŽu[LLQXZ_cfggfihfefhkmq~winsmght€ƒi~cz{„ˆ‹{lf.6@&5R#P.3"0I\P$+?8/G98-/<e"X ƒk £Ÿ ¢¶¹Á¾»‚©±®®š™ •œ™¬´©®³¶¶¸¾ÃÁÂÄÆÉËÍÎÐÒÙÚÕϸ”h\?+)*<^ªŸR923;99>CA:300688,0^Šˆ” ¨©¤Ÿ¢¢¢¢££¤¤ Ÿš–“‘ŽŽ””•–——˜˜˜eeedddccc^[bs‡–ž¨ª®°²±°®¡œŽu[LLQXZ_cfggfihfefhkmqyvtxv}y|d`‡wƒ†q‚oP/O?D_E5(19F[YG&-.&QE&[F(MP# !xs`¥« Ÿ¥§±µ¶¼º¢´³£›™Ÿª©ª¤¨ªª¬®±´¹¿ÃÁÂÄÆÈÊÌÍÓÑÓÏÉÊÀ¨mZ?-(*<U¡¨\838>:9>B@9301664-8gŒŽŠ—¢¦¥£¡¡¡¢¢¢£££¢¡ž›˜•“’‘‘‘’’““”•••–eeeedddcc^[bs†–ž¨ª®°²±°®¡œŽu[LLQXZ_cfggfigfeehkmrtpvyotqƒ¦|·Ÿ{|ƒŽf]5@c0$Fx7(1;SNZF5$)<"\7'f1+W57lŽU¹§©ª¡¡ÃÀ¸¬»³˜ŠŒœ ¢§¥³»°«²¹¾ÀÁÁÃÄÆÈÉÊÑÎÓ×ÔЦjN8-'-?L’´k95?A<:>A?821273/1GtŒ‚ޤ¢ ¡¤ ¡¡¡¢¢¢¤¢¡žœ™—–““’’’‘‘‘‘“ffeeedddc^[ar†–¨ª®°²±°®¡v\MLRXZ_cfggfhgedegjltrovzoo¸‘ˆ;=Ujm{~„uzL-Hc!/Q{+;:Q8>0,+,5)E:l%II1*N›mǰ¡¹³šœ©Æ·È¼¬tQj}|ˆŽ¢¢¯«°¸³®®²·»¼ÀÁÂÃÄÅÆÆÐÅÅËÌÉ·œlJ5-"'57¾|=6DE><?@=611381,7Yˆ…“¢¥Ÿ›Ÿ¥ŸŸ ¡¡¡¤£¢ žœ›š•••”””““ŽŽŽŒŒŒfffeeeddb]Zar†•¨ª®°²±°®¢v\MMRXZ_cfggfhfedegjlqtty}y…£¿`5&r²¦€T`N>JcK!%mn-3,@+20/55);HCc7J-6'˜m]¸ª¶¯Â®•£®½ÂÌ©y^\qZ`b^pw” ¯¸¶³±±³¶·ÀÀÁÁÂÂÂÃÈÄÎÓů˜X9+)#*9;qÀ‰E6DG?=??:301481-@j‹„‹˜¤¥ž™ž¥žžžŸŸŸ £¢¡ Ÿžœ˜˜——––––ŽŽŒ‹Š‰‰Šgfffeeeeb]Zaq…•¨ª®°²±°®¢žw]NMRXZ_cfggfgfdcdgjlmuuv{}‰ ¨g628B‡¥œuCX2;[f)*Bhw0)2>=@E2-+16OROCE=3|ƒd °˜·Àä•®ÁÇǦ~{•˜’}€kL?A]vŠ¥«°°¬°µÀÀÀÀ¿¿¿¿ÅÁĹ“se^P;/-),7@e»’O3>G@>?>81/26952Jw‹“›££žš¡žžžŸŸ ŸŸžžœšš™™™˜˜˜‘ŽŒŠ‰ˆ†ggfffeeeb\Z`q…•œ¨ª®°²±°®¢žw]NNSXZ_cfggfgfdcdfikgrrr€‡†ˆx.,9‹XXV`CQP=%Fc=€#+-G8DC[=&!*"6Z]7H;'L°a›Éµ¶Å±›¢¹Ç¼„€™ž“ˆ³žˆoUMEEB„”¥ª¦¤¬¶À¿¿¾¾½½¼µš„nQJ[jh\I:0#$2]²–Y07F??@=70.27:99T€‘†~› Ÿœœœžžœœœœœ›››œœ››šššš”“’‹Š‰ƒgggffeeeb\Y`q…”œ¨ª®°²±°®£žw]NNSXZ_cfggfgfdcdfikaory“¢–ˆ—NtG@‡‘VRM/3bT9;jUsO2N#13gN2*%6)0V<78~‡¶Ÿ±¿ÅÅ–‘·Ç¸‹h{v~vˆd†uch^_Wi›¤ Ÿª·¿¿¾¾½¼»»h`jov‚†caOA;,,BZ«—_.1E?@@=6/-27:<>Y„‚| ŸžŸ Ÿ›››œœššššššššœœ››››–•”‘ŒŠ‰jjihfeddc^RWr‡’¨ª®°²±°¯§œŽz`KJU[]aeggfemRcn]Zfvcup€“˜Ÿ”Ÿº ´ŽriqL7->R|:KUm(?\+1Y*!$O`2'$2*$;4w†j¯´¥ÇÁ©ÅÃq^_qRScC+he;aiveupy|ˆ—ž§³ÂÀÄÂÀ½¬žƒaiE<<UDGA<7,0EM·r:4E=A9/,/46752IuކРŸž››šœœœœœœœœœœ›››ššš˜™™š›œœ˜˜—•‘‰‡…hggedcbba]QVq‡’¨«®±²±°¯§œŽz`KJUY\_ceeddmaf__neZyƒ§›¦£—““ƒˆ‚?0!!XEFˆW2]Wx& FM91Y#'%CdQ.055,, +@œj¦¾§ªØÌï¿´UQXMC=5+9?2*;(,U…z{}ˆ–›œ¥±´¾ÎǷ®fWLA-0/K:AC>95+/DI·‘mA5E>@8/,/46612Q}Œ†† Ÿžœ›ššœœœœœœœœœ›››ššš™˜˜™™šš››‘‘‹‰ˆ‡edcba`_^_[OTp†‘©«®±²²°¯§œŽz`KJUWZ]accbbh`gbb\Z£È£w˜™ƒ¢’J=o6(QdSnjVPaZ~%)J9F1i+6+,Kl])63!( €‰Œ¾¨«¬ÌÅË®ÉÊP;A5&3<;1.5AM9#%a~ƒ~‡”˜™¢¯¶ËÃÎË™hE<1(D--65;>952(-CC¶—eL6E?>70-0454,6`‡Š‡’ Ÿžœ›šš›››››››››››šš™™™——˜˜˜˜˜˜ŽŽŒ‹‹‹‡baa_^]\\\XMSo…‘©«®±²²±¯§œŽz`KJUVX\`bba``Zdb_K\¼Áß”ªƒ{MU&%2Qt>Qe"RiVat(+D,D/s31,%)YjTK?+"\¡_º£ž·¹ÂǾÿZSC,-)B2/$#5|³hR7:g…~†‘•– ®ÊÐÃÕµR+66JO„]@&848420'-C<²ž_V:G?<60.2442)?p‰‰–˜ŸŸžœ›š™ššššššššššš™™™˜˜——––••””’‘ŽŒ‹‹‹Œ‚aa`_]\[[YUJQn…‘žª¬¯²³²±°§œŽz`KJUWY]accbaa^aU`YaÁ¹¯‘¬d|ˆEC!=:cC4X9':q^k`,)7*5,d@$#2%0;4O05’h’»¤¿²¼ÌÁ¿Å^SK7!5GS69=LxÞ¸—F<^W}}|‚’•¡°ÑÈØÉe,>+/[uˆ™a;-0410/(/E5¤^[@J?:5003530-N~’‰Œ›žŸŸž›š™™™™™™™™™™™™™™˜˜——–••”’‘‘‘ŽŠ…ƒƒ…†bba`^]\\URHOm„‘žª¬¯²³³±°§œŽz`KJUY\`cefedl^b\fPGªœ¬«••¢’uP)3,^d2*RE936|WyQ+*,.*)Rd5"1/(+644<h†kư͹įÈrb`L8/RgEPHLB~ØÏÄ„Px_pyx~‰•¤´ÊÐÒL;NG4LTŠ«~A0-2000*2I0§§bZGO=8411452.6bˆŽŠ›£Ÿžœ›š™˜™™™™™™™™™˜˜˜————••“’ŽŒ‰†}|ƒ…Œddcba__^SPFMl„‘žª¬°²´³²°§œŽz`KJU]_cfiihgo_h\V8.”nh¯È¦šr770)/RR='<S3I/FC†P&2)3*'Aq>,'128/('&*ƒY™¥“¬¶ÅÃÄÃrsp`a,<YpSHPDYºÐÄ̰imuhusy…Ž–§¹ÑÞ»rlkKaKKP |?6-2113.6M-¡©iVMS;7312551-AvއŒ“™¦žžœ›™™˜˜˜˜˜˜˜˜˜˜˜˜——–––•”’ŽŒŠ‰…ƒ~‚‰•¡feecba``RNEMkƒ‘žª¬°²´³²±§œŽz`KJU_aeikkjihjn>7<5{Ÿª´áæ”A/-,;QM;:HEVI\^…SŽU :+5/',U'3'0+)* 0zkzº“·ºÌÃÃËopyŒ‰zl*]h~aPf°ÒÅÒ½’“q…gqpwƒ—©½àÞ·gu—aO\a”ÀfR*-212408P,žªnSQV:6313651,H‚–˜§žžœš™˜˜˜˜˜˜˜˜˜˜˜˜——––––”“’Љˆ‡…„†˜£ª²kjheb_]\[UHLi¨«¯³¶¶¶µª ‘ePOZ]dhotifs[6+/pt¢¶šÙÛs-J:/J|lP8&GJVOGb…A¤cJ,!83'48/+3:82ZŒ`°§ÎƸ½zq}}†‹‚ycb}’¤½º¿º®š…zz~~{}‚…ާÁÞݤo^hƒŒ†¥³¨Œ^<9D79/02GG4»zR]L;*64-11+)d…’Ž’•— ™™˜˜————››šš™™™™š™˜–”’‘‘Œ‡‡‰‰…€ƒ‹—¤±±°¼jigda^\[YTFKh¨«¯³¶¶¶µª ‘ePOZaeflsnp‚6)9Vž–˜š¤É•;02BlLt|`P&)0c7VQQ`€Py~8TC,)(25/-34/,0g“±¨ÅÅÂËrns€ƒŠ†~xiqxs‚•Ž˜¢®²ª›‹|~‚…¦¿ÛäǤ“‰Œ–ŠnU>8FE89/03GF2Ž»UZJ:+510951=l…Ž‹’—™Ÿ™™˜˜————ššš™™™˜˜š™—•“‘Ž‹‡…†‰Œ’™£®µ··¶¼hgeb_]ZYVQDJg€¨«¯³¶¶¶µª ‘ePOZdfeirqx=3r˜ž‡p€P4<.-pz>"iJ/!1cGeN7hb‹_na331*/1/13-#" d\²«¥ºÄÇÍ}fb|††‰”“Žˆ‘}zzrzu{„’ž¢˜ˆ|~‚„Œ£¼ÏßǪ›Œ€uwiSE@K^H99/14GE/Šº‡YVH8,3-4B55Wx…ˆˆ“›œŸ™™˜˜————™™™˜˜˜——˜˜–”’Ž‹†ƒˆ”Ÿ¦«²¹¾¿½¼½fec`]ZXWSNBGfލ«¯³¶¶¶µª ‘ePOZbeejrns†ƒ‚z€ªˆ_TSLF:235nšaT3"@LSi=ih~‡*/98),,-042'@“xƒ§µ¬ÁÃˉXaƒ‹•˜˜–”•‹‰‹‹€“‘’–š•Š€„€ƒƒŠ ¹ÑàÆ¨š’“‰~xk_XZbL;9/36GB+„¹‘^PF502*5B.4g„…ƒˆ”ž™™˜˜————˜˜˜———––—–•“‘Œˆˆ‡‡‹—§³¶¹½ÀÁÁ¿½½cb`]ZXVUOJ>Ed~Žœ¨«¯³¶¶¶µª ‘ePOZ]cfmrigv›®£…XG@Q`HB10?†‹fwG//FW=xkY;en…UJ?10".++260%)xŠh¥»·ÅÜ~Mlc‰Ž‘•™šœž“’˜š““—•¨¦¦¨§Œ~‡ƒ‚ƒ‚‡µÎáи« ›‹…|rmnmP=9/58F@'~¸œdKC241*49%5oŒ„ƒŒ–žŸœ™™˜˜——————–––••••”“‘Œ‹†„…Ž®ºÀ¾¿ÀÀÀ¾¼»¾a`^[XUSRLG<Cb}œ¨«¯³¶¶¶µª ‘ePOZ[bgnrgcpu“„r~\:N]K6/HR;]f`HVo6*%Y<4mv\YZbV,#6+/+,45.((Nšc·ººÀÕ¤@Ul|r”˜››¡¥¥¥¤ž—™¤«¥¦§§¢—ˆ}Š…ƒƒ…š±ÉßϹ¢œŒƒ€yxvnT>9/6:F="y·§iE@/6/.4."?wŽƒ†”™Ÿ›™™˜˜————––•••””””“‘ŒŠ‰…‡Žž±¿ÄÃÁÁÀ¾½»º¹¿_^\YVTRQID9Aa|œ¨«¯³¶¶¶µª ‘ePOZ^cekqjj{rkyvT_}‚H28+A\]pkUBj884/:qm&Ot|IN„Š+F14/+.64,.6|„c ´ÀÁÅ®<X\sw}„”™›šœ£ª´±«¦¥¨³©««¦“ŠŒ‡„ƒ€ƒ˜¯Ñãѹ®§¦š”‡……{wp_W@8/7;F;u¶¯mA>-6-38'(T„‹œœšš™™˜˜————••”””““““’ŽŒŠ‰ˆˆ’¢´ÀÅÃÀÃÂÀ¾¼¼»»À^][XUSQPGC8@`|œ¨«¯³¶¶¶µª ‘ePOZbdchpnu‰’𲕓‚P?:L>YWS~eccj9%*7:jkbUb†¢€CbN@02/,073+2@›Y„±µ¯ÏÈK;Ovix‡„Ž”šš™›¤¬«©¦©°±¬©¦²Ÿ‘‰‡ˆ…„€‚–ÍâѼ²©¦™˜†€€|€‚tY@8/8<F:r¶³o?=+4+7;%0e‹¢ž™œ™™™˜˜————””””““’’’‘ŽŒŠˆˆŠœ´ÄÈþ»ÅÄÁ¿¾½¾¾À[ZYXVUSSK?7@[{“Ÿª±´¶¶¶µ© ”ƒhQNXaZgl}”𩉠›jAMW42>H=kUkbg‰o@"3/0.5DXurtdR2PbQ3++1-(7$.‘d®É±ÏÛZ0C\mtx~…ŒŽ’—œ¡¥§©«®°±°¯³°¬¦Ÿ™”’’Š……ƒ„‘¢ÎáÕ蜥•ƒ~}}{ye<3=:4K4$c¬‰72)6*;1+B|‡†Œ•ž£¡™“›š™˜—–•”••”““’‘‘Ž‹ˆ…ƒ¯³ºÁÆÈÇÆÇÄÀ½¼¾ÁÃÄXXWUSRQPJ?7@[{“žª¬°´¶¶µ´© ”‚hQNWYf|w|y‚}}Q7;WL@D0GVKSrr‚m8+075(9,8TJBf5#0eq`600(-0,#Xs‚¼ÍÕ‰/4G`pux~„‹‘–œ¡¤¦ª¬¯²²²°®²°«¥ž˜“‘‘‰„„‚ƒ‘¢ËßÕŧœ¤—†€|ya;3<:5L3(]¬¢E0&509.)L€ˆ†Ž™ ¡ž™–šš™˜—–•”•””“’‘‘‘‰†‡‹³·¼ÂÅÆÅÄÅÃÀ¾¾ÀÄÆÆTTRQONMLI>6?Zz’©«¯³µµ´³©Ÿ“‚gPMWXbmegwy{YNoWaR9:+He]3jƒsUNB?1/0#E,:W8G;0p~b,;2 -52ƒ†^¹°Áĵ,';Meswy~ƒŠŒ•šŸ£¥¬®±³´³±°°®©£œ–’ˆƒƒ‚ ÆÜ×ȧœ¢™’‰…ƒ}y\83;97N2+T¬–—W,&496+(\…‰†‘ž¢ž™˜ššš™˜–•””””“’’‘’‘Œ„€‡–£º¼¿ÂÃÃÂÁÃÂÁÁÂÅÈÊÉPPOMKJIHH=5>Yy‘œ¨ª®²´´³²¨Ÿ’fPMV[eick‚{EZQbaXu:5qi?<qƒdU>A,%%9:2.$-0-VE)7lˆ}‚:%--0WtxÃ¹ÃÆL%4@Rhvyz~ƒ‰‹“™ž¢¤¬®±³´³²°®«§¡š”‡‚‚€ŽŸÀ×ÙÍ®¦¡›”Œˆ†ƒ}wT5299:P1)J¯™f*(3@3)/mŠŠˆ•¢¤œ–˜žš™˜—–•””““’’‘”‘‰€‹£¶ÀÁÁÂÂÁÀÀÁÂÃÄÇÊÌÎÌNNMKIHGFG<4=Xx›§©°²³²±§ž’€fOLUSgqpmmkaR‚‚qFnPPoeC+KKw]c4@)/<698*4167?5&=hui¯r"&%+%-xj¾ÄÍ38@Rivzz„‡‰’—œ ¢«¯²³²°¯¬©¤ž˜‘Š…€€~Œ¹ÒÛÒ®¥žžš”ŽŠ‡‚zsL2179=S0#C±‘•r-+3B0)>{‹Œ˜¤£›•™Ÿ™™˜—–•”““’’‘ޓކ€„–°ÃÅÄÂÁÀÀÀÁÂÄÆÉÌÍÎÏÍNNMKIHGFF;2<VvŽš¥¨¬¯±²±°¦‘eNKTmgZals|y tV7qsBra2A@B4ib:IC@9&9.89*TK%5$<kzVŒ“t&)&"P“ezÅÇÓÃ/-);<Nftyz…†ˆ‹–›ž¡§©¬®¯®«©§¢œ•Šˆ‹ƒ~~|}‹œ³ÍÝ×®¥žœ˜“‰†€vnE/068@U/ =ª—}5(4@.,S„Œ“›¢¢œ˜šž™™˜—•”““’‘‘ŽŽ‰‚ƒ¤ºÈÆÄÂÀÀÁÃÄÆÈËÎÏÏÎÍÌPONLKIHGE:2;VvŽ™¥§«®°±°¯¦œdMJT‘qSi‡š—7=*d¤Hqc0(gZ:R…~xZ57=8.1:$*9FM59F}™kE{«0&+x‡h ÅË×c!6?6Iaqwz€†„†Š•šŸ£¥¨ª«ª©§§¥ 𔉆Ђ}}{|Š›®ÉÞÛ¯¤Ÿ›•‹ˆ„|qh?,/58BW."9œ‹@5:,0i‰ŒŒšŸŸœ››™˜—–•”““‘‘Ž‹ƒ~‡œ²ÁÆÆÄÁ¿¿ÂÆÈÊÌÐÒÒÐÍËÊQPOMLJIHE91:Uu™¤§ª®°°¯¯¥œ~dMJSneŒ„ug90o\Q#9Fy]C{p^vBC;02 0'<n]H3L\“°™2V„:!5’suÁÀߘ +>G2E^ovz€‡„†Š”™Ÿ¡£¦¨©¨¦¥§¤Ÿ™“Œˆ…Š‚}}{|‰š¬Çßݯ¤Ÿš“Їƒzne<+/48CX.&7¡Œ”G65,3w‹‹ŒžŸžœ™™˜—–•”“’‘‘ŽŽˆ|Š¥»ÄÄÅÃÀ¾¿ÃÈËÍÏÒÔÓÐÌÉÈQQOLJHFE:6,6Xuˆ˜¨©ª¬®°±²¢œ“_EDQb’}jl{lBKŠgQ[XK8`^?aŠ^‚>!7@87>7\z<@YvˆÈ¦E7b$jiˆÕÚ¤(( 9M@K[iqx„…‡‰”–˜›œž ¢££Ÿ©¢”‡€„‡ƒzqq{‰‘¢¾ÕàÈ—¥–’’Š€lS&(43GKF4&@~¦’œE//0M}‘ŒŽ Ÿž›š˜˜˜˜˜—–••”“”••’‹‰Š‚‰¢¸ÀÃȾ¿ÂÅÉÍÏÑÏÏÏÏÏÏÏÏÎRQOMJHFE;6+3Utˆ™¨©ª¬®°±²«|gTPWVck}€{~o.>j_iaNIWEpgGja”ZU? 21/+*'&]bKMtvtHir<":#3‰mÅÀ´R.*"?`AL\iqx„…†‰Œ“–—››œž ¡¢£ ¤•‚|„‚‡‰‚zzƒ£¼ÕãÌ• •”‘‰‚|eI')43HJF3!5t¥”žT#-+2W„Œ’ Ÿžœ›™˜—˜˜——–•””“”””’‹ˆ‡„ލ¼ÁÂÆ¿ÀÃÆÉÍÏÐÏÏÏÏÏÏÏÏÎRQOMJHFE<6)0Rrˆš¨©ª¬®°±²«|dMFJ\irwt}|YIVVSjWN_TGvATcRŸ}D`%'*/2+#)@;UR‘wVEdB#(*)Ylf‰Ç¥˜$-)"BdBN]jrx~ƒ„†ˆŒ“•—ššœŸ ¡¢¡–•|u…………ƒ€†Œ¤·ÔäÏ“™”–‘ˆƒvX;',34HHG2(e£–žh/)%7hŽ‹˜ŸŸœš™˜—˜˜—––•””’“””’ŽŠˆ„‰™°ÀÃÁÃÁÂÄÇÊÍÏÐÏÏÏÏÏÏÏÏÎRQPMKHGF=6)/Rrˆ›¨©ª¬®°±²¬¢“{[FJ[}qhvpGG_\hoNIR5pd&W=™ƒ2x1*?C7-@@VVnŒeNL#'28–Šsp{ z 0#(JcEP_krx~‚ƒ…‡‹’•–™™šœžŸ ¡¡˜‘–‘wp…„ƒ…‰…~~„¢°ÒâÍ‘“’–‡ƒ~kJ.)/36IFG0$"W¡™šw7&#Ay—ŽŒžžž›™˜—–˜——–•”””‘’““‘‰‡ƒ¥ºÄÄÂÁÄÄÆÈËÍÏÐÐÐÐÐÐÐÐÐÏSRPNKIGF>8,4VuŠœ¨©ª¬®°±²³¦“{aVf~‡g`nxzgO6OYtiJD6CˆO(H‰>€‰,sI2B?+B#'<ZY,0etD!4!„Ÿ¦±¨¡¹¢D(%"#-MkGRalsx}ƒ„‡ŠŽ‘”•—˜™›œžŸ ˜‘•vo…‰ˆŽ”€ˆš¨ÍÚÄ‘‘”‡‚v]=(*327JDH.-$IœŸ’;$(O‡š¢žœš™—–•——––•”““‘‘’’Œ‰†„˜²ÁÅÅÃÁÇÇÈÊÌÍÏÏÐÐÐÐÐÐÐÐÏSRPNLIHG>;2<^{œ¨©ª¬®°±² ’„q_]d\U\gxzcVESZziN=+zrJ>4qRhM\e22:;V)1,;<'TeO0$''.§¢±·¿µ’K&11&?mJTcmsw}‚ƒ†‰“•–—˜š›žŸŸœ•”zt„…jZeuy~†Ž¡Ç̶‘”‘Ї€lM4*+629KBI,4(<–¦Œ„A&1_—“£œ›š˜–••——–•””““‘’‘Œˆ…‡¡¼ÅÄÄÅÅÉÊÊËÍÎÎÏÐÐÐÐÐÐÐÐÏSRQNLJHG==8Ehœ¨©ª¬®°±²§ž”‡nRDDH`nblqZ[K[`tM*:QRQ0k\g¨lA{/,ER3 0!"A;v•06!&&B§·ÁªÈ£E&"<4 ;pKVdnsw|€ƒ…‰Œ“”•–—™šœžž¢›“Žz‚wR;H]ekt‚›Áº¦’˜‘Šˆ‡~a?/0,92:K@I+3*0ޮЉK)=m“’Œ—¡œœš™—–•”—––•”““’‘‘‹‡…‹©ÃÇÁÃÇÉËÌÌÍÍÎÎÎÑÑÑÑÑÑÑÑÐTSQOLJHG=?=Kn†‘›¨©ª¬®°±²°§—^FIYefecujOhP[K[W6%rzCXW8~Wrˆ‚=*!3.ek!3! Vw:"=B&7Ds”’³®Áp-)(2;,'M~LWdotw|€‚…ˆŒ’”••—˜š›§ ’…~‚‚z}†{ffxz—¾¯œ“›‘†‡‡|[7-5-:2:K?J*0)'‰´ŠS+Du“Œš œ›š™—•””–––•”““’‘Ž‹‡…ŽÇÇ¿ÂÉËÍÍÍÍÎÎÎÎÑÑÑÑÑÑÑÑÐRNKKOOLHFFK[s‹œ¤¦§¨«°±²¯¥—„gNJSZ_`t…n[=AYKT.dzJZMS9oZZz£Z8!>)ƒ’P#n^.%VWkdir|”Ém' '?F1-+,TxWTdwvtxy‚ƒ…‡Š”•–—™›œœž›˜•’zxƒŒ€t“£±µ§˜”–•„p8+.504;DVGJ750 `´…[!Z‹“”œ›š™˜—––•••”””““”’Œ”ˆ‡£»Ã½¿ÂÅÎÐÐÐÐÐÐÐÐÑÑÑÑÑÑÑÑÒQMJKNOKGDEL^uŒ›¢¦§©«°±²¯¥—„gNJS\`ekrs-,ZPA"N|;4JNQMuhlVx—]*v›q%P?=GCa_ˆ¸‹gft¾³!'85>E3.+,RvZVewwv{zƒ…‡Š“”•—˜š›œŸžœ™–”’‘††’’‰—¶ÅÌÈ´¡—’Œ……„V321007:GSHH8;2V«‡a0bŽ“”Ÿœ›š™˜—–••••””“““”’ŒŽ“ˆ€‰¤¼Ã¾ÀÃÆÎÐÐÐÐÐÐÐÐÑÑÑÑÑÑÑÑÒPLIJMNJF@CNay™ž¦§©«®°²³¯¥—„gNJSZeabsu,2a@Ibv]'%ARP]rjxQt…‰†15>J€V:EE*@ty†‘®®cd€°ËF+9H%;C71,+Nt_Xfxzz~}‚„‡Š’“”•—˜ššŸž›™–•”’Œ§¹§¥Æ¿Â»«žš“‹ˆˆ{8/65,0;:MOJE9?3KŸˆeGp‘”Ž”ž ››š™˜––•••”””““““’ŒŽ‘†§½Ã¾ÂÆÈÏÐÐÐÐÐÐÐÐÒÒÒÒÒÒÒÒÓOKGHKLIE=BOd{Ž˜›§§©¬®°²³¯¥—„gNJSVf[j‡‹]<?TFu‚^58+FQMYcYua^{p’_=gTbG:Q -i‡—›µÁsW]zËj $>-:8A<4,+Hpd[ew{}‚„‡ŠŒŽ‘’“•—˜˜žž›š˜—–Œ‘µÌ¸¥ÁÆÅº¨žš’‡Š‰^+-37+0?;QKJC:=1#C˜“†c`}”””¡›šš˜—–••””””““’’‘’Ž…ƒ‘ª¾Ã¿ÅÊÊÏÐÐÐÐÐÐÐÐÒÒÒÒÒÒÒÒÓMIFGJJGC=BOd{Ž˜›§¨ª¬®±³³¯¥—„gNJST[g„„‚Y??Fq…>+A:6IFIJTHoWLvpƒu0qmGR ,>H”“¥¯¹¢]]U§v 2-,,64?B7-*Bmh[btz~‚€„†‰ŒŽŽ‘“”––››šš™˜———–—·Ï½¨¿Éƹ¥š—†ˆ€9/0+6/1B?TKHB;6.)?”™ƒ\s…••‘•œŸ›š™˜—–•”””“““’’’‘ŒŒƒ„—®ÀÃÀÈÎÍÏÐÐÐÐÐÐÐÐÒÒÒÒÒÒÒÒÓLHDEHIEB@CNay™ž§¨ª¬¯±³´¯¥—„gNJSUW{“j}f7N\] )NE=A=GEMCjFIszwzM‹Q5275[a†˜¤Ê½lLX†©./)C06 1=G;-*=iiY^px}~€ƒ†‰‹ŒŽ‘“””——–––––•šž¥¿ÒűºÆÅ¹£•‘އh%63)232CDSMDB;4,-8ŒZ~ˆ“–•–šœšš™˜–•”””“““’’’‘Ž‘‹‰†œ²ÁÃÁËÒÏÐÐÐÐÐÐÐÐÐÓÓÓÓÓÓÓÓÔJFCDGHD@DEL^uŒ›¢¨©ª¯±³´¯¥—„gNJSVo‚f~ZBVho8;>FMH:BKOHD\MMXp}z†.1'lvfll™¤º—ZMv¬:*0E+?%:.;K=.*9giWYku{{€ƒ†ˆ‹Ž‹‹ŒŽ‘’“’’’’““““˜ ¬»Èƾ»ÎÐÄ©’‹‰‡yF*460,53BJQP?D;8--,‚^‚‡–˜——™š™™—–•””“““’’’‘‘‘Šˆ€‡Ÿ´ÃÃÂÎÕÑÐÐÐÐÐÐÐÐÐÓÓÓÓÓÓÓÓÔJFBCFGD@FFK[s‹œ¤¨©ª¯²³´¯¥—„gNJSUufx~:[CMn88;I;U9NQ\DBKYL5\Œt ^Qv¥—‡–»Æ•Neežs&0&aO7,6-:M>.)6ehUVhrz~y€ƒ…ˆ‹ŽŠŠŒ‘’‘‘‘Ÿ¡¤¥«½Êɯ¶°š‡…Œt.8-68'64BNOS<E;>/,#wœ„d‚…Ž—š˜––š™˜—–•”““““’’’‘‘Œ‘Їˆ¡¶ÃÃÂÏÖÒÐÐÐÐÐÐÐÐÐÓÓÓÓÓÓÓÓÔ?<:=BEC@9EIUu™ª«¬®°²´µ®¨œ€aUQHR`y‹@1,fsC9:N.9ERlc[RV3vP2NqvƒL!lj‡ÉÊÏÒª]MW–•#*09W6%1?8A>E4+5^S^M_mz‚‰€ƒ…‡ŠŒŒ‹Š–Ž}zƒ…ˆ‹Š†ƒŒ{ˆ“™‰…—sp‚Ž20--0456<CCSFSD0D-+(i¦z{Ž‘”—šž˜——–•””“””“’’‘‹’‘Œ†}†¡ºÂÌÑÑÐÑÓÑÑÑÑÑÑÑÑÔÔÔÓÓÓÒÒÖ?<:<ADB?;HMWw‘šŸª«®±²´µµ²“ylKFn†cSc†C.NGG8E?E=;6YzlkXTJB`^aHwq`ˆŸq›ÆÃϰfbbt·J!1..H>-168@>E5,4]R]L]kx€‡€‚„‡‰‹Œ’ŽŽ‹{dZ^uw{~~|zxjksrƒƒqZcldh‹•u20..0357?A@PIXE-F2*'d£~€Ž‘”—šž˜˜—–••””””“’’‘Œ’‹†}‡¢»ÃÍÒÒÐÑÓÒÒÒÒÒÒÒÒÖÕÕÕÔÔÔÓÖ>:8;@CA>>LR[y’œ¢««¯±³´µ˜~dM\‹sMe}w@;X2*1HEBBJ+[‰onaZi>Un‘SO7JŒ†u«ÎÎÍ|TYl³u&.1.)9D./08@=F7.4ZP[J[hu|‚}~€‚…‡‰Š”’‘kaa[]adfffe^U[axwwntr€|—‹I10///258A=@LL[F-I9)&ZŸ…‡‘“•˜šœ™˜˜—–••”””“’’‘Œ’Š…~‰¥½ÅÏÔÓÑÑÓÒÒÒÒÒÒÒÒ××××ÖÖÕÕÔ<97:?A@<@PW_z‘œ¤«¬¯±³µµ§˜›…^oˆrVNy’zu?CC<11;DK6\-X–hVdeeb[mv\<9_ˆ…†“ÔÕ¨_an–¥!35,0,0C(-28><F:04WNXGWdpw}{|~€‚…‡‡‘““ƒ|zvxz~ƒ„…Œ„ˆ‹¢¥¤—€Œ’“’m00120/05:=:FKLXF2KB((PšŽŽ’“”–˜š›œ™™˜˜—–••””“’’‘Œ‘Žˆ„~Œ©ÁÈÑÕÔÑÑÓÓÓÓÓÓÓÓÓØØØ×××ÖÖÓ:758=@>;@SZay›¤«¬®°²´µ¶¬—”„t‹ƒCJ^‡…ovI<BR80*=W0_8[£g<[elk[Z8[bjz¤¦ƒkÒ»rho§²F*41.2++@+008=;G<33SKVDT_kqwyy{~€‚„…ˆ€y{|}‚…ˆŠ¨¯¹µÂþ§}ˆŠ“™xD,.242./6<67PLIQF:JK),H•–“••–—™š››šš™˜˜—––””“’’‘‘‡ƒŽÄËÔ×ÕÒÑÒÔÔÔÔÔÔÔÔ××ÖÖÖÕÕÕÑ9646<><9?S[avŠ—£¬®°²´µ¶ªšˆˆsN<Js—kp^N?fW-,&AY<SCm§m?O_gnaKCZh‡s–’s‰Ì_€©g&;1774&,=67,8<:H?63PISAP[flrvwy{~€‚ƒŠŽŽ‡{€…ˆ‹˜£«›¦«ª“›”“[(--363--6>23WKINF?GQ+2C’•——˜˜™šš›››š™˜˜——””“’’‘‘‹…‚€‘°ÇÎÖÙÖÓÒÒÔÔÔÔÔÔÔÔÔÔÓÓÓÒÒÒÐ8535:=;8=R[_r†” ¬®°²´¶¶¨²Ÿ‹{P6M[‰Š^uIDJ‡H)-0XPHLO…”k_LdEgzj`[]‰’…vÀ¹h{¤Àp"=-6;96)559=/7;9HA83NHQ>MXchntuwy|~€…‹”›”†€~|zz}ƒŠ”…‡’ޔބqD&-,384-,6@4/VGKQG?CV,8A‘¡•™™™™™ššš›››š™˜˜—””“’’‘ޑЄ€“³ÉÑØÛ×ÓÒÒÕÕÕÕÕÕÕÕÐÐÐÏÏÏÎÎÏ7425:<;7;QZ^pƒ‘Ÿ¬®°²´¶·´Ÿ“…eLIMw–d[zP6JŽ9229oHKPW•{a|PpN>e†d…€f®›’m»ž„©È‹:>4330493@+3?87;8HB93LGP=LVafkttvy{}€ˆ‰ˆ˜€…‚~{z}€‚ƒˆ‰~ˆŒœ–‘~X7)#,495,+6A8-SCOUH<AX.=@£”ššššššššœ››š™™˜˜””“’’‘Ž‘Šƒ€”µËÒÙÛØÓÒÒÕÕÕÕÕÕÕÕÎÎÍÍÍÌÌÌÎ72.06950@X]Yp‹•”¤«±´²±´·¤˜…gLDJt`b[=:^%,$Fe91IX‰HyurjA1k‹xnaw•qίšÁ§@*>9863=-/97463@?=;::;;DOA9WSi`glrssuz‡‡ˆ‰‰Š‹‹‰ˆ„€|xuspprw€Œ—žŒŒRH'/,,644>:4:71fHNXI:D]055¥™¡’”žœšœ™šššššššš˜˜–•“’‘ГЀ}p„ºÑÕÙØÕÔØÜÙØ×ÖÕÔÓÒÐÏÏÎÌËÊÊÑ62.16851F]`]r‹“”¤ª±´²±´·¤˜…gLDJ–p[dZ8>gu*/(GY66+r¢ˆbZ„zh[ahq€rRppv|ǘ³´J!/;++4<=-/97463<<==<;:9@KG:NM^^fkqttw|‚†‡‡ˆ‰Š‹‹†††…„„ƒƒƒ†‹‘•—˜—Œ•u@I-)/-645=:4972gIOXI<E[364Œ¦™¡’”žœšœ™™™™™™™™™˜—–•“‘Š’‰€|q†¼ÒÖÙØÕÔ×ÛØØ×ÖÕÓÓÒÑÒÒÓÔÔÕÕÑ42015642Ocebu‹’“¤ª±³²±³¶¤˜…gLDJŽr_`P=LfT00+KJ2<,ˆ¦ƒ€\‹Œpfr\]‹yAvns‰ÚÐÂk(%78/687=-/9746369<??<85>EM9BHOWbhostx………†ˆ‰‹ŒŒ‡ˆŠ“–—œž ¡Ÿ›–“Œ•Q.H2#3/656<94865iJQXH?GV873‹©š¡’”žœšœ™™™™™™™™™——–”’‘Šˆ€{r‹ÀÓ×ÚÙÕÓÖÚØØ×ÖÔÓÒÒÔÔÔÕÕÕÕÕÒ22123443XgigyŠ“¤ª±³²±³¶¤˜…gLDJwyjWEI]Z:5.,QC.<3g—gtt{“vdeYS{JqR‚†ËËw59;704?=8=-/9746315;@@<73>>K8:HCKY`hnrw†ƒ„…‡‰‹’–›Ÿ£¤«¨£ž™–”““.-B1%52678:85559lKSYHCIQ?91‰š¡’”žœšœ™˜˜˜˜˜˜˜˜—–•“’ŽŠ‡€ys‘ÄÕØÛÙÔÒÕØØ×ÖÕÔÓÒÑÔÔÒÐÎÌËÊÔ01332234\hij{ˆ”£©°³±°²µ¤˜…gLDJdwiTEJ_V.8-*UD,98Nƒ]Uzs’xvigO]‡b’@\o˜/5.51,.0;H=-/97463-28>?<73@9B77K??LS]ejr{ƒ‚„†‰ŒŽ–—š¡¥§©ª¨¥ œ˜•“šY:8-,5669;98634=pLUYGHKLF;/‡°›¡’”žœšœ™————————–•”’‘ŽŠŠ…€wu—É×ÚÜÙÔÑÓ×××ÖÕÔÒÒÑÎÎÎÍÍÍÌÌË.1430025[efj{†‹•£©°²±°²µ¤˜…gLDJ]oYQI=Tb-92)TG*8@e~o>Vcy‚tu^`i©^Bd–{;>)0073+9H=-/97463-059;:86=99;6KB9<DOX`it|€‚†‰Œš› £¦¨©£§¬®ª¢—‘“:F0/3496;=77713AsMWYGLNFM=-…´›¡’”žœšœ™––––––––•”“’Ž‹‡„€uwÎØÛÝÙÔÑÒÕ×ÖÖÔÓÒÑÑÉÊÌÎÐÒÓÔÌ-154/.26X`ai{„Š—¢©¯²°°²µ¤˜…gLDJZpK@B3Pp0:>+NG(;4o}q43AZ}…wwq‰rŠuZi]LH>574>8/<==-/97463./2478994<6B5EH;-5BLU`lt}…‰‘–˜›Ÿ£§ª¬£§°¬£—..E.743;6<?668/2CuNXYFOOBR?,ƒ¶œ¡’”žœšœ™––––––––””“‘ŽŒ‹„ƒ€tx¢ÑÙÜÝÚÔÐÑÔ×ÖÕÔÓÒÑÐÎÍÌËÊÉÈǺ,164/-17U\^gzƒ‰—¢¨¯²°¯²µ¤˜…gLDJVyH+43Ut2:H-HE'?'f…pDB8cek{„oz‰šiWd><@2/66:*&??=-/97463//0147:<-?7I4?L?$-9EOZgo|~…‰‘‘“—¢¨¬®©©¨¦¡›•‘m.=@/@23<6<@668.2EvNYYFQP@U@+‚¸œ¡’”žœšœ™––––––––”“’‘ŽŒŒ‹ƒ‚€sx¤ÓÚÝÞÚÓÐÐÓÖÖÕÔÓÒÑÐ×ÔÎÇ¿·±®z52/-.158;Yjoz…Ž™§«¯¯±µ««‘ƒkD>Bme-*<AYS;18JGE.7*T’€`9SNXtzd‘…Šr©D^oC<+3>4/08K;B.&E7380;71--28=>9??5;HH;504?KPQcfkqx~ƒ†…‹’–˜œ£©žŸ¡ —’Žc4;G?>6489?C:--5DNpTT]QP\SFF2ªž–„ƒŠ’•”““““““““ŽŽ„Šz|o½ÏÜÛÙ×ÕÓÒÑËÑØÚÔÍÏÖÃËÆ°–|X8120.,+*++>Wcer‚‘Ÿ§«¯¯¬°µª˜˜ƒcC;i›Pƒ:$TU?@<8G?9.3)C¡’sK^6Rr„Zhtqˆž†—Ÿ¡‚1:,9A+8:SA.'G7280:61..28<>9??6:FFH@747::7GKS]is{€ˆ”—™œ£© Ÿœ—Š„€P+5?43362>C:2254CNoTT\QP[SGF5‘¨Ž†~|‚‰ŒŒ‘’“““–•“‘‹Š‚ˆxzp‘¿ÐÚÚØ×ÕÓÒÑÛÓÏÔÓÌÉ˵•iE3-*0211/,(%#?SYXi“¥¦ª®®¬¬°´°˜œ}OLÒqQ”1*8RGCD=C63,/*@‹~˜`PGDh†RY…g‹¨‘it•¢h,+4)/>>BM>-)I8170851//27:<:?>79BDKJJQ[dijvwy{~€‚ƒ‹–™™œ¢§©¦¢™–•”a5-32:==;879;;98BOmTT[ROZRHF9•¥›{usw|‡ˆ‰‹Ž˜—”‘Ž‹ˆ‡ƒ†xxršÅÒØ×ÖÕÔÒÑÑØÏËÑÒÇ·®‹jC+##*0-34653-($:KPPd|¡¥©««¯³¬ª€gÓkOb},<$SM=>F?2=*1.Aym”wTG,MnQm–^a šoCJ’~3 907.KQ;-,K906064200368:;?>98=@QT\gs}ƒ†…†ˆ‰‹ŽŽ“˜™˜šŸ¤¤£¢¤¨®µ¹ÃcL943.267532/+APkTTXSMXQIG>›¡˜wtpnortu{|~€‚„…†‘Ž‹‰ˆ‡…†ywx©ÎØÕÕÔÓÓÒÑÑÐÏÊÅĽ©”_=#%268=A568850*'3DILbyŠ—¤©ªª®³§ž—v½ÊPPDSb$-4\G62M;3S.81:€p„{<$9]q–’jcƒ~d>V«£†1>+9DQ7-/N9/50432123567=?=:78<SZepx}€‚wy{ƒ†‰Š“——••™ž“”—ž¨´¾ÅÆÍѸ{G86+@G8.34-?QhTTUTLVOJGD¡œ•ttspooprqqrtuvwx‚ƒ„…††…ƒyu|¶ÖÛÑÑÑÑÑÑÑÑÕÕÈ··¹žyF4*2:>HUNA@>;61,)3ACE\tƒ¤¨¬¬ªª®²§žžÂ¦M@[1xC((ZM63I45a>@2;]yu}€pAHf‹UP^isjkKH›„•!769DR4,1Q:.40222233445>?<<639OZjw~‚…‡‡‡‡††……„Ž’•”“–“˜ ª´¼ÁÈÂÀÔÚ¼Œ[I4,8>65>>RfTTSUJTNKHJ§˜’z|}zvsuwnnnmmmmmrstwy|~~€{rlz¼×ÙÎÏÏÏÐÑÑÑÔÓÈ»¸ª}L0*+7EMRVN_ZRI@830:B<:Ql£§««©©±¢·µŸe8@=`˜7)6@QAE:,4_VF5K/K‹vi}}ƒ’«uMQ\hY[I~“ŠO´\81$Fb2,3S:-30112344333??<=6/6LYkvyyyzƒ„…†ˆŠ‹‹Œ’‹ŠŒ“˜ ©²¹¾ÁÄÏÉÉýÉʇU135'#/=RdTTQUISMLHN«•ƒ‡Š‡€|}€rqpnljhgijklnoppuog`r»ÒÑÌÌÍÎÏÐÑÑÐÉÁµšqG-248@NUM@X|uhYLB=:BE81Hg~Ž£§««©©±Á¬£SJWuœD$'&4*MLY,'2WiH9W+-€|d/Kaq€IaeYmpnkw޵jMN:+HEO0,4T:,30013444322@?<>5-5BRhv{|~€|}ƒ…‡ˆŠˆ†ˆ‹‹’©´»¿Á»ÊÅÊÍÉÖÕËÀŽE %(<ScTSPVHRLMHQ®“‰“ˆ‚„‡xvtqmjhgggfffeeele^Vj·ÌÊËËÌÍÏÐÑÑÖÆµšd- 20BLHHRWRX€„ƒxeRGCLA52@\}’Ÿ¥«¬ª¬¯¯¤‘‡mVv¨p1% .--+Uo-5LvOUa/"3…ŠbW}o5wmo`pŒs{”J8l*>JL)+-O13603.8;B334:49J6=:2EWhov}{t}~€‚…‡‰ŠŽŒ‹‹‘ž¡¥¬²¸½À¿ÀÂÅÈËÍÎË×Û¹o+-=TaQLM@<OCM:_©ˆŽ‹Šˆ‡††„}yurpog`^YWbqssgBX§ËÏÇÌ××ÐÔÕÇ»·¥q5'AUMKKNSWYYU†‰‰ƒvg[UOC50=ZzŸ¥¬®¬«¯³¡˜„m}o«G&'(.2>UTc/^tC_e48SOgtu€JLE}hqW—ˆ}d…k,R”W0=I.12T78;53.8;B344;7?CA=:0IXfkpz}z~ƒ…ˆ‰ŠŽŒ‹ŒŽ’ž¡¥«±·¼¾¾¿ÁÄÇÊÌÍÈÂÍÚ€A"H-e`CNSHPCH9f©‡‘ŒŠ‰ˆˆ‡„€|xvtsjec^\etwteFbÍÎÊÎ×ÖÏÓÔÆ»‘c?*3LWMMORVXXXVŠŠ‹‹‡}ofWI7/:VwŽ ¦¬®«°µ™„†£a‹3+(("$-Q€y[Yi…k9MF%5tZ3L„d];HYVješŽ€ŠMV†U*hŠ76C/13U79;53.8;C344<>D=PB9.IYehmx€„†‰Š‹Œ‹Œ’”ž ¥ª°¶º¼¼½ÀÂÅÈÊËÈÍÐÖâÔ‘I+'`E;RHJQC?7q©†”“’‘ŽŒŒŒŠˆ…~{zxqlkfclz}wdOt·ÏÌÏÐ×ÔÍÒÑÁ•Z/.<KRNMQVZ[ZWVY‡‡‰Ž‰{nbQ:.7RuŒ¡§¯¬®±²œ‘‹º£`X?=**""8IFq~hV?Q<NUeo4,r^C;@7tJdn‡‹}‡™scž<9–X-<*,.P24614.8;C344:GD>ZO8.AVglpx~~€ƒ…‡Š‹ŒŽŒŒ‘”–ž ¤©®³·¹º»½ÀÃÆÈÉÌÝÚÊÒâÍ¢<4G?9I:JQC76~¦†—–•“’Ž‹‰†ƒ€~wttokrƒ{d]‰ÁÑÌÔÓÖÓËÍȵc7(BWZVOPW_b`[WV\‚„Š“˜“…yp\A05QtŒ¡§®°®¯²©£•Ú‚yL;@,4483EF1IOD->KW][4? 3=???Ov[N}„w—”2.©‹Gm&7*-.P34714/9<C4557L@F_b;/6Qktvz{y‚„†‰‹ŽŒŒŒ’–™ž £¨¬±´¶¸¹»½ÀÃÅÆÍÏÕØÓÍÒÜ£I)Y78GPMD16Š ŽŠ˜—–”“‘‹‰‡†…‚|{|wqwƒ‡€gmŸÊÓÎØÕ×ÒÈÆ¹ M13OZXY[V^ghb[XX`t|‰—Ÿœ“‹hH36Qu¢¨¯±¯®°²£«’›ØbŽ_".)47;EQP<PF5.>JF3&443K|W2AHKAhkRY‘‡€~tA{¦n8ž@2024V8:=75/9<D4554K>LeqE0.Nmyyzzx‚ƒ…‡ŠŒŽŒŒ‹”™›ž £¦ª®±²µ¶¸»¾ÁÃÄÈÇÍÕÕÏÒÜáŽ3@14BLGE/9”—Œ––•“‘ŽŽŒŠ‰ˆ‡ƒ|uz…ˆ…n~²ÎÕÓÙÖØÓÆ½¦‡E6?UYWYY^fmkbZZ]dYi’œ›™ŒsO78Sx’£©¯±¯®°³¥«˜™»\xS$*/0-B?@<:03=]=6,%0S;0Ey:9KJO>rmNŽˆ|k–jik’2“z%034V8:=750:<D5562CAKmxS1.Nmvux|}ƒ„†ˆ‹‹‹‹•šž ¢¥©¬¯°´µ·¹¼¿ÁÂÅËÌÉÌÖÙÕÝÓ|--35BAF/;šŠ•””“‘ŽŒŒ‹Š‰ˆˆ„€ƒw{…‡Št‹¿ÐÕØÙÖÙÔÅ´•nCCR`]\]Wfmrl`Y\bf@Ur‰”™œŸ“yS99Ty”£©°²°¯±³¬¦™•šfO-*)025-E2.4)%/:pFF;("g>(<Ze><I>LYvVy‚„‘}•h}/±Rr¥+-/Q358250:=D5661;EIuz]12Pkqpu~ƒ„…†‰‹‹‹‹‘–›žž ¢¥¨«®¯³´¶¸»¾ÀÁÇÅËÕÓËÑáÞÝÌ[0)>B=G0=žŠ‰™“’‘ŽŒ‹ŠŒ‹‹Š‰‰ˆˆƒ€„€x{…†Œx“ÅÐÕÜØÖÙÕįŠ_KScdZ]gejqtl^X]eh+F`z“œŸ¨ž‹e01O~£©°²°¯±´¨žœ¹e[A.,.!%@]'4*90-Mq?B@');f/6W<dAA]T<c[ugn‰ ŸP-I“ZÇ*$.%R>;:4,+3?A947/=A\usaB)Dcsxƒƒ„…ˆŠŽŽŽ‘“”•–œž ¢¥¨ª«¯°³¶º½ÀÁÆÇÉÌÏÒÔÕÛÝß½>(7A(B"Rž†‰–““’‘ŽŒŠ‰‰Œz€|ˆ†„Œ¦ÆØÔÊØÜÔÍÈ¡fEUVW[_eilym`[_dfei%8Mm“¤¤¦›j2-I}“£ª°²°¯±´§¦˜Š™}\4!1+-4FG%41/5-Lz;0M3,.RG0NLIcHmbVBXu]†ws¥Ÿh+%wtÄ3%,(R:B66-,3>@8474:?[tve<)Edry€ƒƒ„†ˆŠŒŽŽ‘’”•–œŸ¢¥§©«®°²¶¹½¿ÁÆÇÉÌÏÒÔÕÖÜäÍw)0;*=!ZŸ…ˆ˜““’‘ŽŒ‹Š‰‰‰€|~z”¡µÊÖØÕÕØÑÉ»]HWX[^bgkmrh^Z^dffg )7^“ª¦šn3)D{–¤ª°²±¯±´¬§š~u`(5'4<F4*28(7+U…49R,,%&RJTS<YRYxmRN_I‘‡~ž…I,"q ×9').Q5K080.3=?74729Galph<)Gdr{‚„…†ˆŠŒŽ’“”•›œž¡¤§©ª¯±µ¹¼¿ÀÆÇÉÌÏÑÓÔÒÚèÞ¼>%1,3 f „†›““’‘ދЉˆˆ…‚€zz‡— ¬»ÇÏÕÜáÒÓÎħvSO[]`cgkmoga[Z^dfge %/V®¨žl0(D{”¤ª±³±°²´«ª¡„l‰d$-/(47:200:,3)k‡.7R,&-HXMO7IMKojmDVN‰œ˜‰~*BB\ È+(&5N1S-:303<=537+>XlbfkC)Jer}ƒ‚ƒ†‡‡ˆŠ‹‹ŒŒŽ‘“””š› £¥§©¬®°´·»½¿ÅÇÉËÎÑÓÔÑÙäâàq'-*"tŸ…‡““’‘Œ‹Š‰ˆ‡‡‚‚}x~’¦´¾ÉÑÓÖÜáÓÑÌ»’bPZ_aeilnoo\ZZ\`cfgg$)3UЍ¬¦‘f+(G{¥«±³±°²µ¯« Ž„{b 8"293/7)/46-0ƒ*Q>@/6B-F1U@cUb^Ka\›ƒ§F/=Vʪ")%;J2U/9723;;427.EapcioF*Nfq€„†ˆˆˆ‰‰ŠŠŠ‹Œ’“”™šœŸ¡¤¦§«¬¯²¶º¼¾ÅÆÈËÎÐÒÔÔÙÙÞá±."+"'€›ŠŠœ““’‘‹‹Š‰ˆ‡†…~ƒ‚|{Ф¸ÆÇËÐÖÙÙØ×ÐÇ®€[Vb`chmoonmUX]`bdfgi$*3Rƒ¡©¯«’d('Gz¥«²´²°²µµ©˜ŸsR 6=?4.61+5-HŽq, @;$L8&<$68BFeXrUXSGv’„j"$IÉi3('@F7R57:44992179O`moxsC*Qgqƒ†ˆ‰‰‰‰‰‰‰‰Š‹ŒŽ‘’“˜™› £¥¦ª«®±µ¸»¼ÅÆÈÊÍÐÒÓÕØÒØÚÜ\#&.ˆ•˜““’‘ŠŠ‰ˆ‡……„~‚€z‚›¹ÊÒÌÉÎÖÛ×Ñ×ͼ™n[_b`dinpoliRZbgfeefg#*I|§®ª”h)#Bx¥«²´²±³µ´¦™‡¢m5,3+=7-2-$4%&8k…e1/..4G1);209(ML\€lK;8†{ d’{Vo¥d')BA=K>4<5487117?[dlx‚uG*Sgq…‡€‰‹ŠŠ‰‰ˆˆ‡ŠŠŒ’’—˜šŸ¢¤¥©ª°´¸º¼ÄÅÇÊÍÐÒÓÓ×ÕÚàäš) 5—–”““’‘‰‰ˆ‡†…„ƒ~}y‰¬ÌÖØÑÌÏ×Û×ÒÔǬ]^f[^cinpmieT^imjfdea@x§¬§•m+<w”¥«²´²±³¶¬¥¡–f;6>7)"5&27#B†x^5#*6A=7<!39(8CDFwz-<O’‹ edyQ¥¥½&+D?BFD2>6486017<cmp{uO*Thq†ˆ€Š‹‹Š‰‰ˆ‡‡‰Š‹Ž‘’–—™œŸ¢¤¥¨ª¬°´·º»ÄÅÇÊÍÐÒÓÐÖÜßêÞÇ.:‹œš‘““’‘‰‰ˆ†…„ƒƒ€zxŽ·ÓÜÚÕÐÒ×ÛÙÖÐÁ¡pR`iT]bhnolgcVamqmgdd[!*Cv©¬¥”w< ;i—£©°²°¯±³¬¬ …Y.:31.,+,-.,anKhI:--2M118!)O+*O/8uvWPo„œ‹~z¡¡^8*6(S.,7E,6:;6118@Pt€xoyq76Wj|€ŠŠŠŠ‰‰‰ˆˆ‰Š‹ŒŽ•–—šœž ¡§¨«¯³·º¼ÁÂÄÇËÎÐÑÜÜÛàÎߨg J–†”ƒŽŒŒŒŒ‹Šˆ†„‚‚|zwœÃÙÝ×ÌÏÝÛÖ×ÔÍ©€nid_^`dqzp^\f^adggea^U!)As›©¬¥•x=!<i–£©°²°¯±³¨¬ ‚a6D..--./00=?Q<8nY//)2O:&...=F#MF3Q^lttIm‰ ¦žh$7M1B3>9E5799624;CWvyt|p79Yl}Š‚ŠŠŠ‰‰‰ˆˆ‰‰ŠŒŽ”•—™œž ¡¦¨«®³¶¹»ÀÂÄÇÊÍÐÑÖ×ÔÜÑÞÞ‡QŒ–˜˜ŽŒŒŒ‹Šˆ†„ƒ‚}zw€ŸÄÖÖÕËÐÝÛÖÕÐÄ¢~plf`^dfovo_[bacegfb_\S"'=o˜§¬¦—z@#=h•£©°²°¯±³²§“‘†v@>*,.01110_;6$7cZ;,.8E>#+3*@C3GY0)6_‡‡|€k[]v†¦}VRM<>+KO787548AHax~{{m7@]q~‚‰ƒ‹ŠŠŠ‰‰‰ˆ‰‰Š‹ŒŽŽ”•–™›Ÿ ¥§©±µ¸ºÀÁÃÆÊÍÏÐÑÓÌÖÖÜá´`…’“Ž¤ŽŽŒŒŒŒŠˆ†„ƒ‚~zw„¦ÉÖÑÒÊÑÜÚÕÒʱ•{rpia_ghmqj^Z^effec_\YR#$8i”¥«¨™}C&>h“£©°²°¯±³·¢”‘ˆuB5./1221/-M21/:XSH'8@2=00,$H18\E;1Io~vˆrvH'.V0Plhs†tpd]486437>IPly}|‚ƒf8Ibw…‰†‹‹ŠŠŠ‰‰‰ˆ‰Š‹ŒŽ“”–˜šžŸ£¥¨¬°´·¸¿ÀÃÆÉÌÎÐÒÔÈÒÙ×àÖCp…ˆ›ŽŒŒ‹‰‡…ƒ‚~zz‰ÑÙÔÎÉÒÜÙÕÎÀˆvsskb`ekolaXZ`hhfc`\YXU#"3c£«©›G)@g‘£©°²°¯±³®¢¦“„^:444320.-,/>>8.XM=.:;(?;1()<0/r.>4/Ou|n|huqM`3E)MCWtclU95129EQWry}~…€\:Rg}€‡ˆˆ‹‹‹‹ŠŠ‰‰ˆˆ‰ŠŒŽŽ’“•—šœžŸ¢£¦ª®²µ·¾¿ÂÅÈËÎÏÖ×ÊÒÚÒÙãxu‹Š’’‘‘‘ŽŽ‹‰‡…„ƒ~|}Œ®ÐÚ×ÉÈÓÛØÔÊ·}qrrjbaakpfXT\eihea^[YY\"$.^‹¡««ž„K,Ag£©°²°¯±³¯¤¥‹_6.751.-/13:C6<,J<7:31-A=+-25)CSH/NJUiyxsjŠKR,:<O=D=$Ii:3.0<KX_sw~…yQ<[lƒ‚‰ˆŠŒŒ‹‹‹ŠŠŠˆˆ‰Š‹ŒŽ‘’”–™›ž ¢¥©±³µ½¿ÁÄÇÊÍÎÖÖÎÓÙÑÒᤠqŽˆ—‘‘ŽŽ‹Š‡†„ƒ€‚ФÃÑÒÃÇÔÛÖÓÆ®ƒvnpogaa_hi]TWagheb^\[[\`$%*Zˆ «¬Ÿ†M.BfŽ£©°²°¯±³´¨—‹—u8-40+(+2;AH<*75=5<93327?,/6;%\2\@Ej^Rf…t_Ox—bG@,*0D<(>B28A:2,/>P^dqu€‚pF>ap‡ƒ‹‡ŒŒŒŒ‹‹ŠŠŠ‡ˆ‰Š‹Œ‘’“–˜›œŸ¡¤§¬¯²´½¾ÀÃÇÊÌÍÐÐÏÔÚÕÑØÉ?sމ”–‘’‘‘ŽŽŽŒŠˆ†„„„‡…ƒ‘ª¾Ä¾ÆÕÙÕÓçsklkc_bbc[RUbgceb_[Z\^`_%%(W†Ÿ« ‡O/Bf£©°²°¯±³–“˜9;/*%$*6DM7:0&3CF90;=1'E3,:;5T>Er%7x‹z€ojDKnŒXL`;#98.8785/;2*/?Sagot€€j@?erŠƒŒ‡ŒŒŒ‹‹‹ŠŠ‡ˆˆŠ‹Œ‘“•˜šœž £§«¯²³¼¾ÀÃÆÉÌÍÉÊÏÔÚÚÓÒÝ_yŽ‹‹†Ž’‘‘ŽŽŽŽŒŠˆ†„„ˆ‹†}‚—¬µ¼ÅÕØÔÑÁ£}qjjg`^bf_PIXll_c`\ZZ]`c\%*$%Gz›£ Šc5Gk„Ÿ¥°¯¯²µ´«›Œ©mLQ.)$7UR>:(/26:E=+7AHD826>3@_:;+fP!Vio€yd96w†Žž,17/47.05-1028EVgqm†xyZ3Xvz‡‹Œ‹ŽŽŽŒŠŠŠŠŠŠŠŠ‘’“•—™››Ÿ ¢¥©¬®¯µºÀÃÃÆÌÒÐÑÒÓÕרØÞ™v”ƒtˆ‰Š‹Ž‘’މ‡‰Œ‘‡‡˜¬ÆØÚÙѰ†nrsl`YZ^`ZOLZkj]\\\\]]^_L%*$%Ey›¤¡¢Œf6Fj„Ÿ¥°¯¯²µ¬¬›…›oMJ8+"/B?2-&31<4E80A@?;7556+?_+1?YfA$C.U…n=9Jq¸l!44.58013+004<IZjts‚}}uI:Yw{‡‹ŒŒ‹ŽŽŽŒŠŠŠŠŠŠŠŠ‘‘“•—™š›ž ¢¥¨«®¯´ºÀÂÃÆÌÑÐÑÒÓÕÖØØÚ¸~‹saroy{~ƒˆŒ’ˆ†ŠŽ“’Ž’ˆ…’¯ÇÙÙÕË©‚ppmdZW\b[SPWbfdaZ[^__][YE%(%%Avœ¥¤¤l9Eg…ž¥¬°¯¯²µ§¬œŠqNF?*#,230*&82A1B47L@41572,%U5.47jDD8 -X‘/GT]\”.%:0.48210)/17BPaoxv…yg6D^{~‚‡ŠŒŒŒŽŽŽŒŠŠŠŠŠŠŠŠ’”–˜™šŸ¡¤§ª®³¸¾ÁÂÄÊÐÐÐÑÓÕÖרÔÙv^M`Wcfls{ƒˆ‹ˆ‹ŒŠ‡ˆŽ”˜˜Œƒ„•¸ÍÚØÐŸ|ojbZVX]bQMUdia^cX[`cb\TO<&'&%<rž¦¨§•s=Cd…ž¥¬¯¯®±µ¬«›†sOL;&'31382)98=592<OA1,03/)'K"EAEn‚}:DD54D>,qZVh(15-.3640-(05>JYht{u‚€uM1Mi„‡ŠŒŽŽŽŒŠŠŠŠŠŠŠŠ‘“•—˜™œž £¦©¬±·½ÀÀÃÉÎÏÐÑÓÔÖרÑã©ZRHSGRUZahotw{~‚ƒ‰“œœž–Œ…|‡£ÅÕÞ×˶”vh^TT[_\WGO^kja]`W\cgcYME8&%'%6nŸ¨¬«›zA@a†ž¤¬¯®®±´¶ª›‘xtPV4&-92/3./8>5?13=JB6/,---.#BN=uZs”X;A;?-9;RdX-,1-0112/*)4:FTbnw{p{†]4=Xu„„…‡‰‹ŽŽŽŒŠŠŠŠŠŠŠŠŽ‘”•—˜›œŸ¢¥¨ª¬°µ»¾¾ÁÇÍÏÐÑÒÔÕ××ÔÝÂJQRPEMNPSVXZ[gknqvšŸŸ•Œˆ„‘®ÑÝßÖç†mZPIRbfYJEWgidb_[X^ehcUF<8'$'%1k ©°® ‚E>^†¤«®®®°´»ªš–lvQ\1+06-#$&78>.G.3=BA=5.,/36-F<)kceoœY@2VhRPe38:+41/2.+.,).:BO]jswyosuA,Pgˆˆ††ˆ‹ŽŽŽŽŒŠŠŠŠŠŠŠŠŒŽ’”–—š›ž¡¤§©«®´º¼½ÀÆËÎÏÐÒÓÕÖ×ÙÒÓVSZWORQPNLJIHQTVX]iy…•™—˜›–³×ÝÞѵ“s`IFGR_aVIO`ic]_^X\afg_QA78'#(%.h¡ª³°¤‡G=\‡£«®°³¶ª›’[xRX220/,"%5=;7.H30==??:41367D3.'7]ax…mQkX~@4!"49</24*$**)2@IWepuvvumO+5`y‚ŒŠ‡†‡ŠŽ‘ŽŽŽŒŠŠŠŠŠŠŠŠ‹ŒŽ’“•–™š £¦¨ª²¸»¼¾ÄÊÎÏÐÒÓÕÖ×ÜÓÙzSZb]ZYUQMIED?@>=>HVav‘©³®ž£»ÕØÖŤ}_O;BLRRRTVbed_ZYZZadfd[M>45'"(%,f¢«´²¦ŠI<[‡£«®°³®ª›‹MySQ16/,0+4OA>00F8-=<=>=:8652/;17%,aw†‚Š~n`Dm;.84/%/46('()5DM[isvus{j-!Cg†‚Ž‹ˆ†‡ŠŽ‘ŽŽŽŒŠŠŠŠŠŠŠŠ‹Œ‘“”•™šœŸ£¦¨©¬²¸»»¾ÄÉÎÏÐÑÓÕÖÖÝÚÚ™QTjea_[VQLIG540*(/;FVŒ¿Ê¸›£ÆÐÒλ˜oPC2CRPFDSdqf^^ZSU^dffbXJ<318<>>Gd°¸¼§‡V<_— «±²²³¶´³¥†XS7.32(8017094299;D<9:<-@9"1Q/8'.9Yrªl€eQinR1H(+(&)*'$'2<RWdqrntm9;h{„ˆˆ‰Š‹‹ŒŒ‹ŒŒŽŒŒŒ‹Š‰‰ˆŒŽ‘—˜š ¢¤¥¯²·»¿ÃÄÈÉËÎÑÔÖ×ÐÚ×ÇTaekjihd_XRN<<7-$"*2q±ÆË³–³ÅÛ×̰€Q?BCLSOIM^ngb[TRUZ^ijh]NB<;5STRNSiŒ§¶¼ª]A`€— «±²²³¶³±£~`€S7'/51@3..1851657A?F:A01/ ,.$D;<3..[‚–˜^j`z],/7(/-121.,1=GGjtktztG1.Mq‚ˆˆˆ‰Š‹‹ŒŒ‹ŒŒŽŒ‹ŠŠ‰‰ŒŽ–—šœŸ¢¤¥¬®±¶º¾ÂÃÈÉËÎÑÓÕÖÓרÎkW`jkjifa[UQGE>3($(.„ÂÎŪ™½ÏÒÓ¿ŠV=9:JKJHJTdpb]VQQV]bmhaYPF>89cb^[`rŽ£´¼®•hIc}— «±²²³¶²¯ qk€T6(.62?30.1870110==I4A:,))1/&6F@;/16Wz•˜~JqT:.)-0-%%$$(3BNIcrq|…j?)6Mfz…‰‹ˆˆ‰Š‹‹ŒŒ‹ŒŒŽŽŒ‹‹ŠŠŒŒŽ•—™›ž¡£¤«¬°´¸½ÀÂÇÈÊÍÐÒÔÖÖÑÚØKZgkkkie_ZWSOG;0**-|ÁÒɳªÅÌÍ¿—^6.6;OHADP_joZUOLOWahof[TPI?6?Y[]`i|•§±»±rRe{— «±²²³¶±¬ŸfrS3103,606517:/..*;<?+:F=(74-N&;B6;NDKG\w€Y65.)4,()'%&-;KV^an‚j> .Mkw|‚ƒ}ˆˆ‰Š‹‹ŒŒ‹ŒŒŽŽŒŒ‹‹ŒŒŽ”•—š ¢£¨ª²¶º¾¿ÆÇÉÌÏÑÓÔÙÍÛà´JTdkklkhd`]YUND<766j²ÍÉÀ¾Ç¼½“aC52;GNE@J]jjeQNJJPZfmle[RMF?:CMV_gp™«®¹± xWgx— «±²²³¶²« bszR03.4.508516?0,.(>H;+5OR(9(>]9+J59MZ<Yq<f}W+--.7('0-+-7DPXmr}yT*%9Hdyz{ƒ‚xˆˆ‰Š‹‹ŒŒ‹ŒŒŽŽŒŒ‹ŒŒŽŽ“”–™œŸ¡¢¦¨«¯´¸»½ÅÆÈÊÍÐÒÓÙÌÛáÎ[P_hikkjgcaZVQMKIGFu±ÊÆÅÄ»¥‹fA58>FNJGJYjncVIIJNV`ipfd]RG@?ACIYips}”§¶®ŸzZgw— «±²²³¶³ª¤fksO+,*88;37,05C2-1*EWI/8SZ/. B]D=9O.EIB_—jH;d9-)-3',&%'1@PZ_b]R>'#>^`pyy}‡ˆ€ˆˆ‰Š‹‹ŒŒ‹ŒŒŽ‘‘ŽŽ‹‹ŒŒŽ’“•˜›Ÿ¡¤¥©±¶¹»ÃÅÇÉÌÏÑÒ×ÎÛÞÙ{O[dfhiigec[XUUXYWT´ÏÎȶ—{QL>16FMJIOZgnhYLCGNV^flodc]PC=@E@:RjplrŠ¡¬³©›xZgv— «±²²³¶¶«©nalL&.)99;38,.4G506/MS[.AWWH,+2[A?-`FA;TMu“N7QB0%+/*-))-9HTXWF6()9Pcoty{|€†ˆ†ˆˆ‰Š‹‹ŒŒ‹ŒŒŽ’’‘‘ŽŽ‹‹‹ŒŽŽ‘’”—šœŸ ¢¤§«°´·¹ÃÄÆÈËÎÐÑÓÒÙØÛžPW_adggged`\Z]bc_Zv©ËÌ»–mYCGC>BLLDO\joh[OJAHS_hlmlf`WLC@AC;%Baichƒ¬²¦˜vYgv— «±²²³¶·¬¬tZhJ$6+6220=3.4I61:2SEc'I[Rc29'PJ=Rt645b|˜h-,</"+/,)2.-2893,/1AZgiq~ƒ‚‚‚€‚„ˆˆ‰Š‹‹ŒŒ‹ŒŒŽ“’’‘Š‹‹ŒŽŽ‘’”–™œžŸ¡£¦ª¯³¶¸ÂÃÅÈËÎÐÑÑÔØÓÙµQU\_beffdcea^afgb[n›½·›tXWWHCOXRHCVesq`PKL?IWenomjj_PGEEC@7.<GQ`i}›¤©¦§†`ky•ž©°²³µ¸µ‡=R+6*13/2:<795V0>1-HRS)>WohK//:o5!=kT@?d|{œb?A$.#(40,--+*/9BMS\gqy~€~~€‚‚††‡‡ˆ‰ŠŠ‹ŒŒŽ‘‘‘‘‘‘‘‘ŽŽŽŽŽŽŽŽ‘’”•˜™›œŸ¡¥ª¯µ¸º»½ÀÃÇËÎÐÐÛÏØÕÕnMV\dhghknadhlnonnt~…|hUNNDOYUJELUekl`MBEL;Nbmv|uiiWD<?C?:-/;DNZbx˜§¬©¨ˆahu•ž©°²³µ¸¨¥ŽEG'8+2302;<796N@032@\B&2akk^(,L^W8TrA=`ipZ|X1$/:-#(*.48;BLT]ahpv{}~~~€‚‚†††‡ˆ‰‰Š‹‹ŒŽŽ‘‘‘‘‘‘‘‘ŽŽŽŽŽŽŽŽ‘’”•˜™›œŸ¡¥ª¯´·¹º¼¿ÃÇËÎÏÏ×ÐÙÕÔƒISZbfghlpfiloqpontsqlcZRMTWWPIJS]gd^VNHEECTfow{shcTC<?@<581:@HQWp–¯´±®ges•ž©°²³µ¸µ²¬„JI5=+2403;=899BP)23<f0**h^h}.)<sr.>T]5NnqZZ[),(;, 4)2?JQZcjnquy|||{~€‚‚ƒ…††‡ˆ‰‰‰‹‹ŒŽ‘‘‘‘‘‘‘‘‘’”•˜™›œ ¡¥©®²µ·¹»¾ÂÆÉÌÎÎÑÒÛÕÓ¥GNU_eginrnprttsqoqmgb_^^^g`VNLS]eeZNKMMG?O_mrvxocYNA<>=71548;AGKi–»¿¾¹žtgv•ž©°²³µ¸·¯š\9A70,3514<>9:@8R6++Hn*.-fSZG*/pvD&FrH&SfyP;05'.*+@.:KYbipuuwz}~~|{€€‚ƒƒ……†‡‡ˆ‰‰‹‹‹ŒŽŽ‘‘‘‘‘‘‘‘‘’”•˜™›œ ¢¤¨¬°³´¸¹¼ÀÄÈËÌÍÍÓÚÔÒÅOJR\cfiosuvxyxvsqoole`doyqfYSV]bd^RFDJNJD^ktutsi[MF?<=;602665;>BfœÆÊËů„l{•ž©°²³µ¸»¬Y?832-4624=>9=F4EN'#_s.*3eWH„t24>kI>JXs43Y`d5B+-,,088EVcimpsrtx|~~}|€€‚ƒƒƒ„……†‡ˆˆ‰ŠŠ‹ŒŽŽ‘‘‘‘‘‘‘‘’’’’’’’’‘’”•˜™›œ¡¢¤§«®°±¶¸»¾ÃÆÉËÌËÓØÒÒÚfHPZadgmrxy{{zxuspnkggmx€nf]\ac`ZUOHEHMPRlvzvpk_QC?;:;;97B74169=h¥ÉÎÑ˺n•ž©°²³µ¸½¬–uW5-?.5635=?:AI98X-&tj4$8hb>f›E!/WQA;7MdT/R\a^\"$(-3;EO^gkmoqprvz}~~}€€‚ƒƒ„„„…†‡‡ˆˆŠŠ‹‹ŒŽŽ‘‘‘‘‘‘‘‘““““““““‘’”•˜™›œ¡¢¤¦©¬®¯µ¶¹½ÁÅÈÉËÌÒÔÐÑÞ‰IQZ`beinuwy{{zxvskehqxxtgc`adbYQQPMJIOZcw~~tjbTF<977:>BDR82.47;k¯ÅÊÐʾ•l•ž©°²³µ¸¯ªlO3'1.5736>@;EHC1M=8L7.=ka;Q‰g$4Ql5E9SCE+?ccenH&&2;JOXcjmoruuwz}~}|€€‚‚ƒ„„„„……†‡ˆˆ‰ŠŠ‹ŒŽ‘‘‘‘‘‘‘‘””””””””‘’”•˜™›œ¡¢¤¦¨ª¬³µ¸¼ÀÄÇÈÊÏÑÏÏÑÛ¬LS[_`aeiqswz{{zyvqnt~€xna`_`_[TNSRPMOWeo~ƒ€reZK<76449ALSY81-36;n¶¿ÅÍÆ¾•i|•ž©°²³µ¸®·ŠW@D3$/6746>@;GFL1<KI‚.8>DiV<MU…X_…D'?7^D<01`8q†=0<AOT\florw{{}}{€€‚ƒƒ„„„„……†‡‡ˆ‰ŠŠ‹Œ‘‘‘‘‘‘‘‘””””””””‘’”•˜™›œ¡¢¤¥¨©«¬³´·»¿ÃÆÇÊÒÑÌÎÑÕÂMT\___bfmptx{{{zx{†‡ƒzt`_^[XTQNWTPOT_lu…€paVF654228DR]a,707/2Y¨ÂÉÈÀ¾•i‘œ©²´³³´µ²ƒY?@.%/D#?0FG>F@MA5^i,F1;k[$SAZ‚>P€30.2GMB,.\G9\dGGRT\^bglquwzz{|}~€~~‚ƒ„„ƒ†ˆ‰ˆ†…‡‡ˆŠ‹Œ‘‘‘‘‘‘‘‘’•——–”“––˜™›œžž£§§¥¦ª®¯³·½ÀÂÂÂÈÊÎÑÒÒÑÐ|k][\\`hkqz‚…„{|~ƒ‰‹„wl][UMHJRZZYWTVaq}~xiUC84*-3=IU`fj \ No newline at end of file diff --git a/tutorial/image/lena.png b/tutorial/image/lena.png new file mode 100644 index 0000000000000000000000000000000000000000..ec368fd292ac2acb2a980cac57bb9ef7112b2300 Binary files /dev/null and b/tutorial/image/lena.png differ diff --git a/tutorial/image/tutorial-image-converter.cpp b/tutorial/image/tutorial-image-converter.cpp index 46ac957cc259771cd2013b9b7d70c3323d6c9624..14b1d0c7eecfcabd209dc0df68a126fb7cbe9941 100644 --- a/tutorial/image/tutorial-image-converter.cpp +++ b/tutorial/image/tutorial-image-converter.cpp @@ -5,14 +5,19 @@ int main() { #if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100) - cv::Mat A; - A = cv::imread("lena.bmp", CV_LOAD_IMAGE_GRAYSCALE); + try { + cv::Mat A; + A = cv::imread("lena.bmp", CV_LOAD_IMAGE_GRAYSCALE); - vpImage<unsigned char> I; - vpImageConvert::convert(A, I); + vpImage<unsigned char> I; + vpImageConvert::convert(A, I); # ifdef VISP_HAVE_LIBPNG - vpImageIo::write(I, "lena.png"); // Gray + vpImageIo::write(I, "lena.png"); // Gray # endif + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + } #endif } diff --git a/tutorial/image/tutorial-image-filter.cpp b/tutorial/image/tutorial-image-filter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7ba75c417b4f272b6af8a7436d605699d32ba182 --- /dev/null +++ b/tutorial/image/tutorial-image-filter.cpp @@ -0,0 +1,107 @@ +/*! \example tutorial-image-filter.cpp */ + +#include <visp/vpDisplayD3D.h> +#include <visp/vpDisplayGDI.h> +#include <visp/vpDisplayGTK.h> +#include <visp/vpDisplayX.h> +#include <visp/vpDisplayOpenCV.h> +#include <visp/vpImageIo.h> +#include <visp/vpImageFilter.h> + +void display(vpImage<unsigned char> &I, const std::string &title); +void display(vpImage<double> &D, const std::string &title); + +void display(vpImage<unsigned char> &I, const std::string &title) +{ +#if defined(VISP_HAVE_X11) + vpDisplayX d(I); +#elif defined(VISP_HAVE_OPENCV) + vpDisplayOpenCV d(I); +#elif defined(VISP_HAVE_GTK) + vpDisplayGTK d(I); +#elif defined(VISP_HAVE_GDI) + vpDisplayGDI d(I); +#elif defined(VISP_HAVE_D3D9) + vpDisplayD3d d(I); +#else + std::cout << "No image viewer is available..." << std::endl; +#endif + + vpDisplay::setTitle(I, title.c_str()); + vpDisplay::display(I); + vpDisplay::displayCharString(I, 15,15, "Click to continue...", vpColor::red); + vpDisplay::flush(I); + vpDisplay::getClick(I); +} + +void display(vpImage<double> &D, const std::string &title) +{ + vpImage<unsigned char> I; // Image to display + vpImageConvert::convert(D, I); + display(I, title); +} + +int main(int argc, char** argv ) +{ + try { + if(argc != 2) { + printf( "Usage: %s <image name.[pgm,ppm,jpeg,png,bmp]>\n", argv[0] ); + return -1; + } + + vpImage<unsigned char> I; + + try { + vpImageIo::read(I, argv[1]); + } + catch(...) { + std::cout << "Cannot read image \"" << argv[1] << "\"" << std::endl; + return -1; + } + + display(I, "Original image"); + + vpImage<double> F; + vpImageFilter::gaussianBlur(I, F); + display(F, "Blur (default)"); + + vpImageFilter::gaussianBlur(I, F, 7, 2); + display(F, "Blur (var=2)"); + + vpImage<double> dIx; + vpImageFilter::getGradX(I, dIx); + display(dIx, "Gradient dIx"); + + vpImage<double> dIy; + vpImageFilter::getGradY(I, dIy); + display(dIy, "Gradient dIy"); + + +#if (VISP_HAVE_OPENCV_VERSION >= 0x020100) + vpImage<unsigned char> C; + vpImageFilter::canny(I, C, 5, 15, 3); + display(C, "Canny"); +#endif + + vpMatrix K(3,3); // Sobel kernel along x + K[0][0] = 1; K[0][1] = 0; K[0][2] = -1; + K[1][0] = 2; K[1][1] = 0; K[1][2] = -2; + K[2][0] = 1; K[2][1] = 0; K[2][2] = -1; + vpImage<double> Gx; + vpImageFilter::filter(I, Gx, K); + display(Gx, "Sobel x"); + + size_t nlevel = 3; + std::vector< vpImage<unsigned char> > pyr(nlevel); + pyr[0] = I; + for (size_t i=1; i < nlevel; i++) { + vpImageFilter::getGaussPyramidal(pyr[i-1], pyr[i]); + display(pyr[i], "Pyramid"); + } + return 0; + } + catch(vpException &e) { + std::cout << "Catch an exception: " << e << std::endl; + return 1; + } +} diff --git a/tutorial/image/tutorial-image-manipulation.cpp b/tutorial/image/tutorial-image-manipulation.cpp index 9847ff05698c1426f3f66764d5839e96f08fd125..fe230a7252968d7a9eb79e8f14a986e639b7365d 100644 --- a/tutorial/image/tutorial-image-manipulation.cpp +++ b/tutorial/image/tutorial-image-manipulation.cpp @@ -3,23 +3,28 @@ int main() { - vpImage<unsigned char> gray_image(240, 320); - vpImage<vpRGBa> color_image(240, 320); + try { + vpImage<unsigned char> gray_image(240, 320); + vpImage<vpRGBa> color_image(240, 320); - gray_image = 128; - vpRGBa color(255, 0, 0); - color_image = color; + gray_image = 128; + vpRGBa color(255, 0, 0); + color_image = color; - unsigned int igray_max = gray_image.getHeight() - 1; - unsigned int jgray_max = gray_image.getWidth() - 1; - std::cout << "Gray image, last pixel intensity: " - << (int)gray_image[igray_max][jgray_max] << std::endl; + unsigned int igray_max = gray_image.getHeight() - 1; + unsigned int jgray_max = gray_image.getWidth() - 1; + std::cout << "Gray image, last pixel intensity: " + << (int)gray_image[igray_max][jgray_max] << std::endl; - unsigned int icolor_max = color_image.getHeight() - 1; - unsigned int jcolor_max = color_image.getWidth() - 1; - std::cout << "Color image, last pixel RGB components: " - << (int)color_image[icolor_max][jcolor_max].R << " " - << (int)color_image[icolor_max][jcolor_max].G << " " - << (int)color_image[icolor_max][jcolor_max].B - << std::endl; + unsigned int icolor_max = color_image.getHeight() - 1; + unsigned int jcolor_max = color_image.getWidth() - 1; + std::cout << "Color image, last pixel RGB components: " + << (int)color_image[icolor_max][jcolor_max].R << " " + << (int)color_image[icolor_max][jcolor_max].G << " " + << (int)color_image[icolor_max][jcolor_max].B + << std::endl; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + } } diff --git a/tutorial/image/tutorial-image-reader.cpp b/tutorial/image/tutorial-image-reader.cpp index ab0caf23b2e7e67ed196ef54bb16ab907ef234e2..bd0ff9d62bcf56de26b357c92767cae4a8b38c44 100644 --- a/tutorial/image/tutorial-image-reader.cpp +++ b/tutorial/image/tutorial-image-reader.cpp @@ -8,6 +8,9 @@ int main() vpImageIo::read(I, "lena.jpg"); vpImageIo::write(I, "lena.png"); } + catch(vpException e) { + std::cout << e.getMessage() << std::endl; + } catch(...) { std::cout << "Unsupported image format" << std::endl; } diff --git a/tutorial/image/tutorial-image-viewer.cpp b/tutorial/image/tutorial-image-viewer.cpp index 9bade45c49338ecc37de00f4b6a427cbb54d43e9..bc6ce276124a6ab4e25e42b9ae81bca05f4d3e16 100644 --- a/tutorial/image/tutorial-image-viewer.cpp +++ b/tutorial/image/tutorial-image-viewer.cpp @@ -6,32 +6,37 @@ int main() { - vpImage<vpRGBa> I; - vpImageIo::read(I, "lena.ppm"); + try { + vpImage<vpRGBa> I; + vpImageIo::read(I, "lena.ppm"); #if defined(VISP_HAVE_X11) - vpDisplayX d(I); + vpDisplayX d(I); #elif defined(VISP_HAVE_GDI) - vpDisplayGDI d(I); + vpDisplayGDI d(I); #else - std::cout << "No image viewer is available..." << std::endl; + std::cout << "No image viewer is available..." << std::endl; #endif - vpDisplay::setTitle(I, "Lena"); - vpDisplay::display(I); + vpDisplay::setTitle(I, "Lena"); + vpDisplay::display(I); - vpDisplay::displayRectangle(I, vpImagePoint(90,90), 70, 90, vpColor::red, false, 2); - vpDisplay::flush(I); + vpDisplay::displayRectangle(I, vpImagePoint(90,90), 70, 90, vpColor::red, false, 2); + vpDisplay::flush(I); - vpImage<vpRGBa> O; - vpDisplay::getImage(I, O); + vpImage<vpRGBa> O; + vpDisplay::getImage(I, O); - try { - vpImageIo::write(I, "lena-out.jpg"); - vpImageIo::write(O, "lena-out-with-overlay.jpg"); + try { + vpImageIo::write(I, "lena-out.jpg"); + vpImageIo::write(O, "lena-out-with-overlay.jpg2"); + } + catch(...) { + std::cout << "Cannot write the image: unsupported format..." << std::endl; + } + + vpDisplay::getClick(I); } - catch(...) { - std::cout << "Cannot write the image: unsupported format..." << std::endl; + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; } - - vpDisplay::getClick(I); } diff --git a/tutorial/image/tutorial-undistort.cpp b/tutorial/image/tutorial-undistort.cpp index 410a30d78a97f3a6f8b0c8ac27d5fe1e7cb0b8fa..7964119f5ab7d979cd6b03a499df1ce723f9c3d2 100644 --- a/tutorial/image/tutorial-undistort.cpp +++ b/tutorial/image/tutorial-undistort.cpp @@ -5,26 +5,31 @@ int main() { - vpImage<unsigned char> I; - vpImageIo::read(I, "chessboard.pgm"); + try { + vpImage<unsigned char> I; + vpImageIo::read(I, "chessboard.pgm"); - vpCameraParameters cam; + vpCameraParameters cam; #ifdef VISP_HAVE_XML2 - vpXmlParserCamera p; - vpCameraParameters::vpCameraParametersProjType projModel; - projModel = vpCameraParameters::perspectiveProjWithDistortion; - if (p.parse(cam, "camera.xml", "Camera", projModel, I.getWidth(), I.getHeight()) != vpXmlParserCamera::SEQUENCE_OK) { - std::cout << "Cannot found parameters for camera named \"Camera\"" << std::endl; - } + vpXmlParserCamera p; + vpCameraParameters::vpCameraParametersProjType projModel; + projModel = vpCameraParameters::perspectiveProjWithDistortion; + if (p.parse(cam, "camera.xml", "Camera", projModel, I.getWidth(), I.getHeight()) != vpXmlParserCamera::SEQUENCE_OK) { + std::cout << "Cannot found parameters for camera named \"Camera\"" << std::endl; + } #else - cam.initPersProjWithDistortion(582.7, 580.6, 326.6, 215.0, -0.3372, 0.4021); + cam.initPersProjWithDistortion(582.7, 580.6, 326.6, 215.0, -0.3372, 0.4021); #endif - std::cout << cam << std::endl; + std::cout << cam << std::endl; - vpImage<unsigned char> Iud; - vpImageTools::undistort(I, cam, Iud); - vpImageIo::write(Iud, "chessboard-undistort.pgm"); + vpImage<unsigned char> Iud; + vpImageTools::undistort(I, cam, Iud); + vpImageIo::write(Iud, "chessboard-undistort.pgm"); + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + } return 0; } diff --git a/tutorial/image/tutorial-viewer.cpp b/tutorial/image/tutorial-viewer.cpp index ae58d7b898b871eb0c6ef54685f94d6a47d6737b..de619c59550396926a0363d0c88f3c3a516fb842 100644 --- a/tutorial/image/tutorial-viewer.cpp +++ b/tutorial/image/tutorial-viewer.cpp @@ -6,7 +6,7 @@ #include <visp/vpDisplayOpenCV.h> #include <visp/vpImageIo.h> -int main(int argc, char** argv ) +int main(int argc, char** argv) { if(argc != 2) { printf( "Usage: %s <image name.[pgm,ppm,jpeg,png,tiff,bmp,ras,jp2]>\n", argv[0] ); @@ -23,22 +23,27 @@ int main(int argc, char** argv ) return -1; } + try { #if defined(VISP_HAVE_X11) - vpDisplayX d(I); + vpDisplayX d(I); #elif defined(VISP_HAVE_OPENCV) - vpDisplayOpenCV d(I); + vpDisplayOpenCV d(I); #elif defined(VISP_HAVE_GTK) - vpDisplayGTK d(I); + vpDisplayGTK d(I); #elif defined(VISP_HAVE_GDI) - vpDisplayGDI d(I); + vpDisplayGDI d(I); #elif defined(VISP_HAVE_D3D9) - vpDisplayD3d d(I); + vpDisplayD3d d(I); #else - std::cout << "No image viewer is available..." << std::endl; + std::cout << "No image viewer is available..." << std::endl; #endif - vpDisplay::setTitle(I, "My image"); - vpDisplay::display(I); - vpDisplay::flush(I); - std::cout << "A click to quit..." << std::endl; - vpDisplay::getClick(I); + vpDisplay::setTitle(I, "My image"); + vpDisplay::display(I); + vpDisplay::flush(I); + std::cout << "A click to quit..." << std::endl; + vpDisplay::getClick(I); + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + } } diff --git a/tutorial/matching/CMakeLists.txt b/tutorial/matching/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..08d5b176899449f783615daaa7ce7405873f57bd --- /dev/null +++ b/tutorial/matching/CMakeLists.txt @@ -0,0 +1,21 @@ +project(tutorial-matching-keypoint) + +cmake_minimum_required(VERSION 2.6) + +find_package(VISP REQUIRED) + +# set the list of source files +set(tutorial_cpp + tutorial-matching-surf.cpp + tutorial-matching-surf-homography.cpp) + +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/video-postcard.mpeg" ) + +foreach(cpp ${tutorial_cpp}) + visp_add_target(${cpp}) +endforeach() + +# Copy the data files to the same location than the target +foreach(data ${tutorial_data}) + visp_copy_data(tutorial-matching-surf.cpp ${data}) +endforeach() diff --git a/tutorial/matching/tutorial-matching-surf-homography.cpp b/tutorial/matching/tutorial-matching-surf-homography.cpp new file mode 100644 index 0000000000000000000000000000000000000000..aa052bd86e86e3685741bddb6b005630c5563bbb --- /dev/null +++ b/tutorial/matching/tutorial-matching-surf-homography.cpp @@ -0,0 +1,117 @@ +/*! \example tutorial-matching-surf-homography.cpp */ +#include <visp/vpDisplayOpenCV.h> +#include <visp/vpHomography.h> +#include <visp/vpKeyPointSurf.h> +#include <visp/vpPixelMeterConversion.h> +#include <visp/vpVideoReader.h> + +int main(int argc, const char **argv) +{ +#if defined(VISP_HAVE_OPENCV_NONFREE) && defined(VISP_HAVE_FFMPEG) + int method = 0; + + if (argc > 1) + method = atoi(argv[1]); + + if (method == 0) + std::cout << "Uses Ransac to estimate the homography" << std::endl; + else + std::cout << "Uses a robust scheme to estimate the homography" << std::endl; + + vpImage<unsigned char> I; + + vpVideoReader reader; + reader.setFileName("video-postcard.mpeg"); + reader.acquire(I); + + vpKeyPointSurf surf; + surf.buildReference(I); + + vpImage<unsigned char> Idisp; + Idisp.resize(I.getHeight(), 2*I.getWidth()); + Idisp.insert(I, vpImagePoint(0, 0)); + Idisp.insert(I, vpImagePoint(0, I.getWidth())); + + vpDisplayOpenCV d(Idisp, 0, 0, "Homography from matched Surf keypoints") ; + vpDisplay::display(Idisp); + vpDisplay::flush(Idisp); + + vpImagePoint corner_ref[4]; + corner_ref[0].set_ij(115, 64); + corner_ref[1].set_ij( 83, 253); + corner_ref[2].set_ij(282, 307); + corner_ref[3].set_ij(330, 72); + for (unsigned int i=0; i<4; i++) { + vpDisplay::displayCross(Idisp, corner_ref[i], 12, vpColor::red); + } + vpDisplay::flush(Idisp); + + vpCameraParameters cam(840, 840, I.getWidth()/2, I.getHeight()/2); + + vpHomography curHref; + + while ( ! reader.end() ) + { + reader.acquire(I); + Idisp.insert(I, vpImagePoint(0, I.getWidth())); + vpDisplay::display(Idisp); + vpDisplay::displayLine(Idisp, vpImagePoint(0, I.getWidth()), vpImagePoint(I.getHeight(), I.getWidth()), vpColor::white, 2); + + unsigned int nbMatch = surf.matchPoint(I); + + std::vector<vpImagePoint> iPref(nbMatch), iPcur(nbMatch); // Coordinates in pixels (for display only) + std::vector<double> mPref_x(nbMatch), mPref_y(nbMatch); + std::vector<double> mPcur_x(nbMatch), mPcur_y(nbMatch); + std::vector<bool> inliers(nbMatch); + + for (unsigned int i = 0; i < nbMatch; i++) { + vpImagePoint matched_ref, matched_cur; + surf.getMatchedPoints(i, matched_ref, matched_cur); + vpPixelMeterConversion::convertPoint(cam, matched_ref, mPref_x[i], mPref_y[i]); + vpPixelMeterConversion::convertPoint(cam, matched_cur, mPcur_x[i], mPcur_y[i]); + + // Store the image coordinates in pixel of the matched points + iPref[i] = matched_ref; + iPcur[i] = matched_cur; + } + + double residual; + if (method == 0) + vpHomography::ransac(mPref_x, mPref_y, mPcur_x, mPcur_y, curHref, inliers, residual, + mPref_x.size()/2, 2.0/cam.get_px(), true); + else + vpHomography::robust(mPref_x, mPref_y, mPcur_x, mPcur_y, curHref, inliers, residual, + 0.4, 4, true); + + vpImagePoint corner_cur[4]; + for (int i=0; i< 4; i++) { + corner_cur[i] = vpHomography::project(cam, curHref, corner_ref[i]); + } + + vpImagePoint offset(0, I.getWidth()); + for (int i=0; i< 4; i++) { + vpDisplay::displayLine(Idisp, + corner_cur[i] + offset, + corner_cur[(i+1)%4] + offset, + vpColor::blue, 3); + } + + for (unsigned int i = 0; i < nbMatch; i++) { + if(inliers[i] == true) + vpDisplay::displayLine(Idisp, iPref[i], iPcur[i] + offset, vpColor::green); + else + vpDisplay::displayLine(Idisp, iPref[i], iPcur[i] + offset, vpColor::red); + } + + vpDisplay::flush(Idisp); + + if (vpDisplay::getClick(Idisp, false)) + break; + } + + vpDisplay::getClick(Idisp); +#else + (void)argc; (void)argv; +#endif + return 0; +} diff --git a/tutorial/matching/tutorial-matching-surf.cpp b/tutorial/matching/tutorial-matching-surf.cpp new file mode 100755 index 0000000000000000000000000000000000000000..2477038450e30e10f755cc5b1ba7f20161e2e73d --- /dev/null +++ b/tutorial/matching/tutorial-matching-surf.cpp @@ -0,0 +1,53 @@ +/*! \example tutorial-matching-surf.cpp */ +#include <visp/vpKeyPointSurf.h> +#include <visp/vpDisplayOpenCV.h> +#include <visp/vpVideoReader.h> + +int main() +{ +#if defined(VISP_HAVE_OPENCV_NONFREE) && defined(VISP_HAVE_FFMPEG) + vpImage<unsigned char> I; + + vpVideoReader reader; + reader.setFileName("video-postcard.mpeg"); + reader.acquire(I); + + vpKeyPointSurf surf; + surf.buildReference(I); + + vpImage<unsigned char> Idisp; + Idisp.resize(I.getHeight(), 2*I.getWidth()); + Idisp.insert(I, vpImagePoint(0, 0)); + Idisp.insert(I, vpImagePoint(0, I.getWidth())); + + vpDisplayOpenCV d(Idisp, 0, 0, "Matching surf keypoints") ; + vpDisplay::display(Idisp); + vpDisplay::flush(Idisp); + + while ( ! reader.end() ) + { + reader.acquire(I); + Idisp.insert(I, vpImagePoint(0, I.getWidth())); + + vpDisplay::display(Idisp); + vpDisplay::displayLine(Idisp, vpImagePoint(0, I.getWidth()), vpImagePoint(I.getHeight(), I.getWidth()), vpColor::white, 2); + + int nbMatch = surf.matchPoint(I); + + vpImagePoint iPref, iPcur; + for (int i = 0; i < nbMatch; i++) + { + surf.getMatchedPoints(i, iPref, iPcur); + vpDisplay::displayLine(Idisp, iPref, iPcur + vpImagePoint(0, I.getWidth()), vpColor::green); + } + vpDisplay::flush(Idisp); + + if (vpDisplay::getClick(Idisp, false)) + break; + } + + vpDisplay::getClick(Idisp); +#endif + + return 0; +} diff --git a/tutorial/matching/video-postcard.mpeg b/tutorial/matching/video-postcard.mpeg new file mode 100644 index 0000000000000000000000000000000000000000..21fca4da9ab753228612066dac3ce24272eff30d Binary files /dev/null and b/tutorial/matching/video-postcard.mpeg differ diff --git a/tutorial/robot/pioneer/CMakeLists.txt b/tutorial/robot/pioneer/CMakeLists.txt index 342717b4e918597d75f1ebb413998d4c8fb11362..321f5e2e9f4468e46cfb47bbb940f326ec44c329 100644 --- a/tutorial/robot/pioneer/CMakeLists.txt +++ b/tutorial/robot/pioneer/CMakeLists.txt @@ -3,11 +3,14 @@ project(tutorial-robot) cmake_minimum_required(VERSION 2.6) find_package(VISP REQUIRED) -if(VISP_FOUND) - include(${VISP_USE_FILE}) -endif(VISP_FOUND) - -# build the examples -add_executable(tutorial-pioneer-robot tutorial-pioneer-robot.cpp) -add_executable(tutorial-simu-pioneer tutorial-simu-pioneer.cpp) -add_executable(tutorial-simu-pioneer-pan tutorial-simu-pioneer-pan.cpp) + +set(tutorial_cpp + tutorial-pioneer-robot.cpp + tutorial-simu-pioneer.cpp + tutorial-simu-pioneer-continuous-gain-constant.cpp + tutorial-simu-pioneer-continuous-gain-adaptive.cpp + tutorial-simu-pioneer-pan.cpp) + +foreach(cpp ${tutorial_cpp}) + visp_add_target(${cpp}) +endforeach() diff --git a/tutorial/robot/pioneer/tutorial-pioneer-robot.cpp b/tutorial/robot/pioneer/tutorial-pioneer-robot.cpp index 91c3ec57c7eaea343e2578b35ceee6d663677a3d..40c100848d903bb84952321036d9e1722bedaa46 100644 --- a/tutorial/robot/pioneer/tutorial-pioneer-robot.cpp +++ b/tutorial/robot/pioneer/tutorial-pioneer-robot.cpp @@ -5,35 +5,40 @@ int main() { #ifdef VISP_HAVE_PIONEER - ArArgumentBuilder args; - args.add("-rp"); -#ifdef UNIX - args.add("/dev/ttyUSB0"); + try { + ArArgumentBuilder args; + args.add("-rp"); +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX + args.add("/dev/ttyUSB0"); #else - args.add("COM3"); + args.add("COM3"); #endif - ArSimpleConnector conn(&args); + ArSimpleConnector conn(&args); - vpRobotPioneer robot; + vpRobotPioneer robot; - if (!conn.connectRobot(&robot)) - return -1; + if (!conn.connectRobot(&robot)) + return -1; - robot.useSonar(false); - vpTime::wait(2000); + robot.useSonar(false); + vpTime::wait(2000); - vpColVector v(2); - v = 0; - v[0] = 0.10; // Translational velocity in m/s - robot.setVelocity(vpRobot::REFERENCE_FRAME, v); + vpColVector v(2); + v = 0; + v[0] = 0.10; // Translational velocity in m/s + robot.setVelocity(vpRobot::REFERENCE_FRAME, v); - vpTime::wait(1000); - vpColVector v_mes = robot.getVelocity(vpRobot::REFERENCE_FRAME); - std::cout << "Measured vel: " << v_mes.t() << std::endl; - vpTime::wait(1000); + vpTime::wait(1000); + vpColVector v_mes = robot.getVelocity(vpRobot::REFERENCE_FRAME); + std::cout << "Measured vel: " << v_mes.t() << std::endl; + vpTime::wait(1000); - robot.stopRunning(); - robot.waitForRunExit(); + robot.stopRunning(); + robot.waitForRunExit(); + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + } #endif } diff --git a/tutorial/robot/pioneer/tutorial-simu-pioneer-continuous-gain-adaptive.cpp b/tutorial/robot/pioneer/tutorial-simu-pioneer-continuous-gain-adaptive.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cfd27088d47b411139828f11f2861c8049f5f13f --- /dev/null +++ b/tutorial/robot/pioneer/tutorial-simu-pioneer-continuous-gain-adaptive.cpp @@ -0,0 +1,148 @@ +/*! + \example tutorial-simu-pioneer-continuous-gain-adaptive.cpp + + Example that shows how to simulate a visual servoing on a Pioneer mobile robot equipped with a camera. + The current visual features that are used are s = (x, log(Z/Z*)). The desired one are s* = (x*, 0), with: + - x the abscisse of the point measured at each iteration + - x* the desired abscisse position of the point (x* = 0) + - Z the depth of the point measured at each iteration + - Z* the desired depth of the point equal to the initial one. + + The degrees of freedom that are controlled are (vx, wz), where wz is the rotational velocity + and vx the translational velocity of the mobile platform at point M located at the middle + between the two wheels. + + The feature x allows to control wy, while log(Z/Z*) allows to control vz. + + */ +#include <iostream> + +#include <visp/vpFeatureBuilder.h> +#include <visp/vpFeatureDepth.h> +#include <visp/vpFeaturePoint.h> +#include <visp/vpHomogeneousMatrix.h> +#include <visp/vpPlot.h> +#include <visp/vpServo.h> +#include <visp/vpSimulatorPioneer.h> +#include <visp/vpVelocityTwistMatrix.h> + +int main() +{ + try { + vpHomogeneousMatrix cdMo; + cdMo[1][3] = 1.2; + cdMo[2][3] = 0.5; + + vpHomogeneousMatrix cMo; + cMo[0][3] = 0.3; + cMo[1][3] = cdMo[1][3]; + cMo[2][3] = 1.; + vpRotationMatrix cRo(0, atan2( cMo[0][3], cMo[1][3]), 0); + cMo.insert(cRo); + + vpSimulatorPioneer robot ; + robot.setSamplingTime(0.04); + vpHomogeneousMatrix wMc, wMo; + robot.getPosition(wMc); + wMo = wMc * cMo; + + vpPoint point; + point.setWorldCoordinates(0,0,0); + point.track(cMo); + + vpServo task; + task.setServo(vpServo::EYEINHAND_L_cVe_eJe); + task.setInteractionMatrixType(vpServo::DESIRED, vpServo::PSEUDO_INVERSE); + task.setLambda(2, 0.2, 10); + vpVelocityTwistMatrix cVe; + cVe = robot.get_cVe(); + task.set_cVe(cVe); + + vpMatrix eJe; + robot.get_eJe(eJe); + task.set_eJe(eJe); + + vpFeaturePoint s_x, s_xd; + vpFeatureBuilder::create(s_x, point); + s_xd.buildFrom(0, 0, cdMo[2][3]); + task.addFeature(s_x, s_xd, vpFeaturePoint::selectX()); + + vpFeatureDepth s_Z, s_Zd; + double Z = point.get_Z(); + double Zd = cdMo[2][3]; + s_Z.buildFrom(s_x.get_x(), s_x.get_y(), Z, log(Z/Zd)); + s_Zd.buildFrom(0, 0, Zd, 0); + task.addFeature(s_Z, s_Zd); + +#ifdef VISP_HAVE_DISPLAY + // Create a window (800 by 500) at position (400, 10) with 3 graphics + vpPlot graph(3, 800, 500, 400, 10, "Curves..."); + + // Init the curve plotter + graph.initGraph(0,2); + graph.initGraph(1,2); + graph.initGraph(2,1); + graph.setTitle(0, "Velocities"); + graph.setTitle(1, "Error s-s*"); + graph.setTitle(2, "Depth"); + graph.setLegend(0, 0, "vx"); + graph.setLegend(0, 1, "wz"); + graph.setLegend(1, 0, "x"); + graph.setLegend(1, 1, "log(Z/Z*)"); + graph.setLegend(2, 0, "Z"); +#endif + + int iter = 0; + for (; ;) + { + robot.getPosition(wMc) ; + cMo = wMc.inverse() * wMo; + + point.track(cMo); + + vpFeatureBuilder::create(s_x, point); + + Z = point.get_Z() ; + s_Z.buildFrom(s_x.get_x(), s_x.get_y(), Z, log(Z/Zd)) ; + + robot.get_cVe(cVe); + task.set_cVe(cVe); + robot.get_eJe(eJe); + task.set_eJe(eJe); + + vpColVector v = task.computeControlLaw(iter*robot.getSamplingTime()); + robot.setVelocity(vpRobot::ARTICULAR_FRAME, v); + +#ifdef VISP_HAVE_DISPLAY + graph.plot(0, iter, v); // plot velocities applied to the robot + graph.plot(1, iter, task.getError()); // plot error vector + graph.plot(2, 0, iter, Z); // plot the depth +#endif + + iter ++; + + if (task.getError().sumSquare() < 0.0001) { + std::cout << "Reached a small error. We stop the loop... " << std::endl; + break; + } + } +#ifdef VISP_HAVE_DISPLAY + graph.saveData(0, "./v2.dat"); + graph.saveData(1, "./error2.dat"); + + const char *legend = "Click to quit..."; + vpDisplay::displayCharString(graph.I, (int)graph.I.getHeight()-60, (int)graph.I.getWidth()-150, legend, vpColor::red); + vpDisplay::flush(graph.I); + vpDisplay::getClick(graph.I); +#endif + + + // Kill the servo task + task.print() ; + task.kill(); + + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + } +} diff --git a/tutorial/robot/pioneer/tutorial-simu-pioneer-continuous-gain-constant.cpp b/tutorial/robot/pioneer/tutorial-simu-pioneer-continuous-gain-constant.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bfe5484d48f35300394dbc37da39a2a4aec5e354 --- /dev/null +++ b/tutorial/robot/pioneer/tutorial-simu-pioneer-continuous-gain-constant.cpp @@ -0,0 +1,148 @@ +/*! + \example tutorial-simu-pioneer-continuous-gain-constant.cpp + + Example that shows how to simulate a visual servoing on a Pioneer mobile robot equipped with a camera. + The current visual features that are used are s = (x, log(Z/Z*)). The desired one are s* = (x*, 0), with: + - x the abscisse of the point measured at each iteration + - x* the desired abscisse position of the point (x* = 0) + - Z the depth of the point measured at each iteration + - Z* the desired depth of the point equal to the initial one. + + The degrees of freedom that are controlled are (vx, wz), where wz is the rotational velocity + and vx the translational velocity of the mobile platform at point M located at the middle + between the two wheels. + + The feature x allows to control wy, while log(Z/Z*) allows to control vz. + + */ +#include <iostream> + +#include <visp/vpFeatureBuilder.h> +#include <visp/vpFeatureDepth.h> +#include <visp/vpFeaturePoint.h> +#include <visp/vpHomogeneousMatrix.h> +#include <visp/vpPlot.h> +#include <visp/vpServo.h> +#include <visp/vpSimulatorPioneer.h> +#include <visp/vpVelocityTwistMatrix.h> + +int main() +{ + try { + vpHomogeneousMatrix cdMo; + cdMo[1][3] = 1.2; + cdMo[2][3] = 0.5; + + vpHomogeneousMatrix cMo; + cMo[0][3] = 0.3; + cMo[1][3] = cdMo[1][3]; + cMo[2][3] = 1.; + vpRotationMatrix cRo(0, atan2( cMo[0][3], cMo[1][3]), 0); + cMo.insert(cRo); + + vpSimulatorPioneer robot ; + robot.setSamplingTime(0.04); + vpHomogeneousMatrix wMc, wMo; + robot.getPosition(wMc); + wMo = wMc * cMo; + + vpPoint point; + point.setWorldCoordinates(0,0,0); + point.track(cMo); + + vpServo task; + task.setServo(vpServo::EYEINHAND_L_cVe_eJe); + task.setInteractionMatrixType(vpServo::DESIRED, vpServo::PSEUDO_INVERSE); + task.setLambda(0.2); + vpVelocityTwistMatrix cVe; + cVe = robot.get_cVe(); + task.set_cVe(cVe); + + vpMatrix eJe; + robot.get_eJe(eJe); + task.set_eJe(eJe); + + vpFeaturePoint s_x, s_xd; + vpFeatureBuilder::create(s_x, point); + s_xd.buildFrom(0, 0, cdMo[2][3]); + task.addFeature(s_x, s_xd, vpFeaturePoint::selectX()); + + vpFeatureDepth s_Z, s_Zd; + double Z = point.get_Z(); + double Zd = cdMo[2][3]; + s_Z.buildFrom(s_x.get_x(), s_x.get_y(), Z, log(Z/Zd)); + s_Zd.buildFrom(0, 0, Zd, 0); + task.addFeature(s_Z, s_Zd); + +#ifdef VISP_HAVE_DISPLAY + // Create a window (800 by 500) at position (400, 10) with 3 graphics + vpPlot graph(3, 800, 500, 400, 10, "Curves..."); + + // Init the curve plotter + graph.initGraph(0,2); + graph.initGraph(1,2); + graph.initGraph(2,1); + graph.setTitle(0, "Velocities"); + graph.setTitle(1, "Error s-s*"); + graph.setTitle(2, "Depth"); + graph.setLegend(0, 0, "vx"); + graph.setLegend(0, 1, "wz"); + graph.setLegend(1, 0, "x"); + graph.setLegend(1, 1, "log(Z/Z*)"); + graph.setLegend(2, 0, "Z"); +#endif + + int iter = 0; + for (; ;) + { + robot.getPosition(wMc) ; + cMo = wMc.inverse() * wMo; + + point.track(cMo); + + vpFeatureBuilder::create(s_x, point); + + Z = point.get_Z() ; + s_Z.buildFrom(s_x.get_x(), s_x.get_y(), Z, log(Z/Zd)) ; + + robot.get_cVe(cVe); + task.set_cVe(cVe); + robot.get_eJe(eJe); + task.set_eJe(eJe); + + vpColVector v = task.computeControlLaw(iter*robot.getSamplingTime()); + robot.setVelocity(vpRobot::ARTICULAR_FRAME, v); + +#ifdef VISP_HAVE_DISPLAY + graph.plot(0, iter, v); // plot velocities applied to the robot + graph.plot(1, iter, task.getError()); // plot error vector + graph.plot(2, 0, iter, Z); // plot the depth +#endif + + iter ++; + + if (task.getError().sumSquare() < 0.0001) { + std::cout << "Reached a small error. We stop the loop... " << std::endl; + break; + } + } +#ifdef VISP_HAVE_DISPLAY + graph.saveData(0, "./v2.dat"); + graph.saveData(1, "./error2.dat"); + + const char *legend = "Click to quit..."; + vpDisplay::displayCharString(graph.I, (int)graph.I.getHeight()-60, (int)graph.I.getWidth()-150, legend, vpColor::red); + vpDisplay::flush(graph.I); + vpDisplay::getClick(graph.I); +#endif + + + // Kill the servo task + task.print() ; + task.kill(); + + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + } +} diff --git a/tutorial/robot/pioneer/tutorial-simu-pioneer-pan.cpp b/tutorial/robot/pioneer/tutorial-simu-pioneer-pan.cpp index e18d02aa01c9d0817109a40b1bbee559c758880d..453a74fae16e28a859b7017a907a83e649812c7d 100644 --- a/tutorial/robot/pioneer/tutorial-simu-pioneer-pan.cpp +++ b/tutorial/robot/pioneer/tutorial-simu-pioneer-pan.cpp @@ -29,93 +29,92 @@ int main() { - // Set the position the camera has to reach - vpHomogeneousMatrix cdMo ; - cdMo[1][3] = 1.2; // t_y should be different from zero to be non singular - cdMo[2][3] = 0.5; - - // Set the initial camera position - vpHomogeneousMatrix cMo; - cMo[0][3] = 0.3; - cMo[1][3] = cdMo[1][3]; - cMo[2][3] = 1.; - vpRotationMatrix cdRo(0, atan2(cMo[0][3], cMo[1][3]), 0); - cMo.insert(cdRo); - - vpSimulatorPioneerPan robot ; - robot.setSamplingTime(0.04); - vpHomogeneousMatrix wMc, wMo; - - // Get robot position world frame - robot.getPosition(wMc); - - // Compute the position of the object in the world frame - wMo = wMc * cMo; - - // Define the target - vpPoint point; - point.setWorldCoordinates(0,0,0); // Coordinates in the object frame - point.track(cMo); - - vpServo task; - task.setServo(vpServo::EYEINHAND_L_cVe_eJe); - task.setInteractionMatrixType(vpServo::CURRENT, vpServo::PSEUDO_INVERSE); - task.setLambda(0.2); - - vpVelocityTwistMatrix cVe; - cVe = robot.get_cVe(); - task.set_cVe(cVe); - - vpMatrix eJe; - robot.get_eJe(eJe); - task.set_eJe(eJe); - - // Current and desired visual feature associated later to the x coordinate of the point - vpFeaturePoint s_x, s_xd; - - // Create the current x visual feature - vpFeatureBuilder::create(s_x, point); - - // Create the desired x* visual feature - s_xd.buildFrom(0, 0, cdMo[2][3]); - - // Add the feature - task.addFeature(s_x, s_xd, vpFeaturePoint::selectX()); - - // Create the current and desired log(Z/Z*) visual feature - vpFeatureDepth s_Z, s_Zd; - // Initial depth of the target in front of the camera - double Z = point.get_Z(); - // Desired depth Z* of the target. - double Zd = cdMo[2][3]; - s_Z.buildFrom(s_x.get_x(), s_x.get_y(), Z, log(Z/Zd)); - s_Zd.buildFrom(0, 0, Zd, 0); // log(Z/Z*) = 0 that's why the last parameter is 0 - - // Add the feature - task.addFeature(s_Z, s_Zd); + try { + // Set the position the camera has to reach + vpHomogeneousMatrix cdMo ; + cdMo[1][3] = 1.2; // t_y should be different from zero to be non singular + cdMo[2][3] = 0.5; + + // Set the initial camera position + vpHomogeneousMatrix cMo; + cMo[0][3] = 0.3; + cMo[1][3] = cdMo[1][3]; + cMo[2][3] = 1.; + vpRotationMatrix cdRo(0, atan2(cMo[0][3], cMo[1][3]), 0); + cMo.insert(cdRo); + + vpSimulatorPioneerPan robot ; + robot.setSamplingTime(0.04); + vpHomogeneousMatrix wMc, wMo; + + // Get robot position world frame + robot.getPosition(wMc); + + // Compute the position of the object in the world frame + wMo = wMc * cMo; + + // Define the target + vpPoint point; + point.setWorldCoordinates(0,0,0); // Coordinates in the object frame + point.track(cMo); + + vpServo task; + task.setServo(vpServo::EYEINHAND_L_cVe_eJe); + task.setInteractionMatrixType(vpServo::CURRENT, vpServo::PSEUDO_INVERSE); + task.setLambda(0.2); + + vpVelocityTwistMatrix cVe; + cVe = robot.get_cVe(); + task.set_cVe(cVe); + + vpMatrix eJe; + robot.get_eJe(eJe); + task.set_eJe(eJe); + + // Current and desired visual feature associated later to the x coordinate of the point + vpFeaturePoint s_x, s_xd; + + // Create the current x visual feature + vpFeatureBuilder::create(s_x, point); + + // Create the desired x* visual feature + s_xd.buildFrom(0, 0, cdMo[2][3]); + + // Add the feature + task.addFeature(s_x, s_xd, vpFeaturePoint::selectX()); + + // Create the current and desired log(Z/Z*) visual feature + vpFeatureDepth s_Z, s_Zd; + // Initial depth of the target in front of the camera + double Z = point.get_Z(); + // Desired depth Z* of the target. + double Zd = cdMo[2][3]; + s_Z.buildFrom(s_x.get_x(), s_x.get_y(), Z, log(Z/Zd)); + s_Zd.buildFrom(0, 0, Zd, 0); // log(Z/Z*) = 0 that's why the last parameter is 0 + + // Add the feature + task.addFeature(s_Z, s_Zd); #ifdef VISP_HAVE_DISPLAY - // Create a window (800 by 500) at position (400, 10) with 3 graphics - vpPlot graph(3, 800, 500, 400, 10, "Curves..."); - - // Init the curve plotter - graph.initGraph(0,3); - graph.initGraph(1,2); - graph.initGraph(2,1); - graph.setTitle(0, "Velocities"); - graph.setTitle(1, "Error s-s*"); - graph.setTitle(2, "Depth"); - graph.setLegend(0, 0, "vx"); - graph.setLegend(0, 1, "wz"); - graph.setLegend(0, 2, "qdot_pan"); - graph.setLegend(1, 0, "x"); - graph.setLegend(1, 1, "log(Z/Z*)"); - graph.setLegend(2, 0, "Z"); + // Create a window (800 by 500) at position (400, 10) with 3 graphics + vpPlot graph(3, 800, 500, 400, 10, "Curves..."); + + // Init the curve plotter + graph.initGraph(0,3); + graph.initGraph(1,2); + graph.initGraph(2,1); + graph.setTitle(0, "Velocities"); + graph.setTitle(1, "Error s-s*"); + graph.setTitle(2, "Depth"); + graph.setLegend(0, 0, "vx"); + graph.setLegend(0, 1, "wz"); + graph.setLegend(0, 2, "qdot_pan"); + graph.setLegend(1, 0, "x"); + graph.setLegend(1, 1, "log(Z/Z*)"); + graph.setLegend(2, 0, "Z"); #endif - try - { - int iter = 1; + int iter = 0; for (; ;) { robot.getPosition(wMc) ; @@ -155,16 +154,16 @@ int main() } #ifdef VISP_HAVE_DISPLAY const char *legend = "Click to quit..."; - vpDisplay::displayCharString(graph.I, graph.I.getHeight()-60, graph.I.getWidth()-150, legend, vpColor::red); + vpDisplay::displayCharString(graph.I, (int)graph.I.getHeight()-60, (int)graph.I.getWidth()-150, legend, vpColor::red); vpDisplay::flush(graph.I); vpDisplay::getClick(graph.I); #endif + + // Kill the servo task + task.print(); + task.kill(); } - catch(...) - { + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; } - - // Kill the servo task - task.print(); - task.kill(); } diff --git a/tutorial/robot/pioneer/tutorial-simu-pioneer.cpp b/tutorial/robot/pioneer/tutorial-simu-pioneer.cpp index 021e95eba2eca0b5370170f2a3a501bb9e76d5da..13202d12c17db4cc8c7fd522c3bda006c3363f7b 100644 --- a/tutorial/robot/pioneer/tutorial-simu-pioneer.cpp +++ b/tutorial/robot/pioneer/tutorial-simu-pioneer.cpp @@ -28,72 +28,71 @@ int main() { - vpHomogeneousMatrix cdMo; - cdMo[1][3] = 1.2; - cdMo[2][3] = 0.5; - - vpHomogeneousMatrix cMo; - cMo[0][3] = 0.3; - cMo[1][3] = cdMo[1][3]; - cMo[2][3] = 1.; - vpRotationMatrix cRo(0, atan2( cMo[0][3], cMo[1][3]), 0); - cMo.insert(cRo); - - vpSimulatorPioneer robot ; - robot.setSamplingTime(0.04); - vpHomogeneousMatrix wMc, wMo; - robot.getPosition(wMc); - wMo = wMc * cMo; - - vpPoint point; - point.setWorldCoordinates(0,0,0); - point.track(cMo); - - vpServo task; - task.setServo(vpServo::EYEINHAND_L_cVe_eJe); - task.setInteractionMatrixType(vpServo::DESIRED, vpServo::PSEUDO_INVERSE); - task.setLambda(0.2); - vpVelocityTwistMatrix cVe; - cVe = robot.get_cVe(); - task.set_cVe(cVe); - - vpMatrix eJe; - robot.get_eJe(eJe); - task.set_eJe(eJe); - - vpFeaturePoint s_x, s_xd; - vpFeatureBuilder::create(s_x, point); - s_xd.buildFrom(0, 0, cdMo[2][3]); - task.addFeature(s_x, s_xd, vpFeaturePoint::selectX()); - - vpFeatureDepth s_Z, s_Zd; - double Z = point.get_Z(); - double Zd = cdMo[2][3]; - s_Z.buildFrom(s_x.get_x(), s_x.get_y(), Z, log(Z/Zd)); - s_Zd.buildFrom(0, 0, Zd, 0); - task.addFeature(s_Z, s_Zd); + try { + vpHomogeneousMatrix cdMo; + cdMo[1][3] = 1.2; + cdMo[2][3] = 0.5; + + vpHomogeneousMatrix cMo; + cMo[0][3] = 0.3; + cMo[1][3] = cdMo[1][3]; + cMo[2][3] = 1.; + vpRotationMatrix cRo(0, atan2( cMo[0][3], cMo[1][3]), 0); + cMo.insert(cRo); + + vpSimulatorPioneer robot ; + robot.setSamplingTime(0.04); + vpHomogeneousMatrix wMc, wMo; + robot.getPosition(wMc); + wMo = wMc * cMo; + + vpPoint point; + point.setWorldCoordinates(0,0,0); + point.track(cMo); + + vpServo task; + task.setServo(vpServo::EYEINHAND_L_cVe_eJe); + task.setInteractionMatrixType(vpServo::DESIRED, vpServo::PSEUDO_INVERSE); + task.setLambda(0.2); + vpVelocityTwistMatrix cVe; + cVe = robot.get_cVe(); + task.set_cVe(cVe); + + vpMatrix eJe; + robot.get_eJe(eJe); + task.set_eJe(eJe); + + vpFeaturePoint s_x, s_xd; + vpFeatureBuilder::create(s_x, point); + s_xd.buildFrom(0, 0, cdMo[2][3]); + task.addFeature(s_x, s_xd, vpFeaturePoint::selectX()); + + vpFeatureDepth s_Z, s_Zd; + double Z = point.get_Z(); + double Zd = cdMo[2][3]; + s_Z.buildFrom(s_x.get_x(), s_x.get_y(), Z, log(Z/Zd)); + s_Zd.buildFrom(0, 0, Zd, 0); + task.addFeature(s_Z, s_Zd); #ifdef VISP_HAVE_DISPLAY - // Create a window (800 by 500) at position (400, 10) with 3 graphics - vpPlot graph(3, 800, 500, 400, 10, "Curves..."); - - // Init the curve plotter - graph.initGraph(0,2); - graph.initGraph(1,2); - graph.initGraph(2,1); - graph.setTitle(0, "Velocities"); - graph.setTitle(1, "Error s-s*"); - graph.setTitle(2, "Depth"); - graph.setLegend(0, 0, "vx"); - graph.setLegend(0, 1, "wz"); - graph.setLegend(1, 0, "x"); - graph.setLegend(1, 1, "log(Z/Z*)"); - graph.setLegend(2, 0, "Z"); + // Create a window (800 by 500) at position (400, 10) with 3 graphics + vpPlot graph(3, 800, 500, 400, 10, "Curves..."); + + // Init the curve plotter + graph.initGraph(0,2); + graph.initGraph(1,2); + graph.initGraph(2,1); + graph.setTitle(0, "Velocities"); + graph.setTitle(1, "Error s-s*"); + graph.setTitle(2, "Depth"); + graph.setLegend(0, 0, "vx"); + graph.setLegend(0, 1, "wz"); + graph.setLegend(1, 0, "x"); + graph.setLegend(1, 1, "log(Z/Z*)"); + graph.setLegend(2, 0, "Z"); #endif - try - { - int iter = 1; + int iter = 0; for (; ;) { robot.getPosition(wMc) ; @@ -132,16 +131,18 @@ int main() graph.saveData(1, "./error2.dat"); const char *legend = "Click to quit..."; - vpDisplay::displayCharString(graph.I, graph.I.getHeight()-60, graph.I.getWidth()-150, legend, vpColor::red); + vpDisplay::displayCharString(graph.I, (int)graph.I.getHeight()-60, (int)graph.I.getWidth()-150, legend, vpColor::red); vpDisplay::flush(graph.I); vpDisplay::getClick(graph.I); #endif + + + // Kill the servo task + task.print() ; + task.kill(); + } - catch(...) - { + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; } - - // Kill the servo task - task.print() ; - task.kill(); } diff --git a/tutorial/simulator/image/CMakeLists.txt b/tutorial/simulator/image/CMakeLists.txt index 551651fe4979d34c18ae422e7f288a1491e1dba0..81252ba39d4d4c5ea15405b1421a78f0cb4bc8bc 100644 --- a/tutorial/simulator/image/CMakeLists.txt +++ b/tutorial/simulator/image/CMakeLists.txt @@ -3,21 +3,18 @@ project(tutorial-simulation-image) cmake_minimum_required(VERSION 2.6) find_package(VISP REQUIRED) -if(VISP_FOUND) - include(${VISP_USE_FILE}) -endif(VISP_FOUND) -# build the examples -add_executable(tutorial-image-simulator tutorial-image-simulator.cpp) +# set the list of source files +set(tutorial_cpp + tutorial-image-simulator.cpp) -# copy the data -get_target_property(target_location tutorial-image-simulator LOCATION) -get_filename_component(target_location "${target_location}" PATH) -list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/target_square.pgm" ) -foreach(data ${data2copy}) - add_custom_command( - TARGET tutorial-image-simulator - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy "${data}" "${target_location}" - ) +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/target_square.pgm" ) + +foreach(cpp ${tutorial_cpp}) + visp_add_target(${cpp}) +endforeach() + +# Copy the data files to the same location than the target +foreach(data ${tutorial_data}) + visp_copy_data(tutorial-image-simulator.cpp ${data}) endforeach() diff --git a/tutorial/simulator/image/tutorial-image-simulator.cpp b/tutorial/simulator/image/tutorial-image-simulator.cpp index efe9d0a84d202ce720b8db98fe8858fd4692348d..fbd89e985db0aba283822e284e6055ab78d24234 100644 --- a/tutorial/simulator/image/tutorial-image-simulator.cpp +++ b/tutorial/simulator/image/tutorial-image-simulator.cpp @@ -6,47 +6,52 @@ int main() { - vpImage<unsigned char> target; - vpImageIo::read(target, "./target_square.pgm"); - - vpColVector X[4]; - for (int i = 0; i < 4; i++) X[i].resize(3); - // Top left Top right Bottom right Bottom left - X[0][0] = -0.1; X[1][0] = 0.1; X[2][0] = 0.1; X[3][0] = -0.1; - X[0][1] = -0.1; X[1][1] = -0.1; X[2][1] = 0.1; X[3][1] = 0.1; - X[0][2] = 0; X[1][2] = 0; X[2][2] = 0; X[3][2] = 0; - - vpImage<unsigned char> I(480, 640); - vpCameraParameters cam(840, 840, I.getWidth()/2, I.getHeight()/2); - vpHomogeneousMatrix cMo(0, 0, 0.35, 0, vpMath::rad(30), vpMath::rad(15)); - - vpImageSimulator sim; - sim.setInterpolationType(vpImageSimulator::BILINEAR_INTERPOLATION); - sim.init(target, X); - - // Get the new image of the projected planar image target - sim.setCleanPreviousImage(true); - sim.setCameraPosition(cMo); - sim.getImage(I, cam); - try { - vpImageIo::write(I, "./rendered_image.jpg"); - } - catch(...) { - std::cout << "Unsupported image format" << std::endl; - } + vpImage<unsigned char> target; + vpImageIo::read(target, "./target_square.pgm"); + + vpColVector X[4]; + for (int i = 0; i < 4; i++) X[i].resize(3); + // Top left Top right Bottom right Bottom left + X[0][0] = -0.1; X[1][0] = 0.1; X[2][0] = 0.1; X[3][0] = -0.1; + X[0][1] = -0.1; X[1][1] = -0.1; X[2][1] = 0.1; X[3][1] = 0.1; + X[0][2] = 0; X[1][2] = 0; X[2][2] = 0; X[3][2] = 0; + + vpImage<unsigned char> I(480, 640); + vpCameraParameters cam(840, 840, I.getWidth()/2, I.getHeight()/2); + vpHomogeneousMatrix cMo(0, 0, 0.35, 0, vpMath::rad(30), vpMath::rad(15)); + + vpImageSimulator sim; + sim.setInterpolationType(vpImageSimulator::BILINEAR_INTERPOLATION); + sim.init(target, X); + + // Get the new image of the projected planar image target + sim.setCleanPreviousImage(true); + sim.setCameraPosition(cMo); + sim.getImage(I, cam); + + try { + vpImageIo::write(I, "./rendered_image.jpg"); + } + catch(...) { + std::cout << "Unsupported image format" << std::endl; + } #if defined(VISP_HAVE_X11) - vpDisplayX d(I); + vpDisplayX d(I); #elif defined(VISP_HAVE_GDI) - vpDisplayGDI d(I); + vpDisplayGDI d(I); #else - std::cout << "No image viewer is available..." << std::endl; + std::cout << "No image viewer is available..." << std::endl; #endif - vpDisplay::setTitle(I, "Planar image projection"); - vpDisplay::display(I); - vpDisplay::flush(I); - std::cout << "A click to quit..." << std::endl; - vpDisplay::getClick(I); + vpDisplay::setTitle(I, "Planar image projection"); + vpDisplay::display(I); + vpDisplay::flush(I); + std::cout << "A click to quit..." << std::endl; + vpDisplay::getClick(I); + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + } } diff --git a/tutorial/trace/CMakeLists.txt b/tutorial/trace/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..73f50743f4a8ebab157e7756beb982946b871ecb --- /dev/null +++ b/tutorial/trace/CMakeLists.txt @@ -0,0 +1,15 @@ +project(tutorial-trace) + +cmake_minimum_required(VERSION 2.6) + +find_package(VISP REQUIRED) +include_directories(${VISP_INCLUDE_DIRS}) +add_definitions(${VISP_DEFINITIONS}) + +# set the list of source files +set(tutorial_cpp + tutorial-trace.cpp) + +foreach(cpp ${tutorial_cpp}) + visp_add_target(${cpp}) +endforeach() diff --git a/tutorial/trace/tutorial-trace.cpp b/tutorial/trace/tutorial-trace.cpp new file mode 100644 index 0000000000000000000000000000000000000000..737e285510f7a0286755e99fc3d28b7d10802218 --- /dev/null +++ b/tutorial/trace/tutorial-trace.cpp @@ -0,0 +1,39 @@ +/*! \example tutorial-trace.cpp */ +//#define VP_TRACE // Activate the trace mode +//#define VP_DEBUG // Activate the debug mode +#define VP_DEBUG_MODE 2 // Activate debug level 1 and 2 + +#include <visp/vpDebug.h> + +int main() +{ + vpIN_FCT("main()"); // std::cout if VP_TRACE defined + + // Check the active debug levels set in VP_DEBUG_MODE + std::cout << "Debug level 1 active: " << vpDEBUG_ENABLE(1) << std::endl; + std::cout << "Debug level 2 active: " << vpDEBUG_ENABLE(2) << std::endl; + std::cout << "Debug level 3 active: " << vpDEBUG_ENABLE(3) << std::endl; + + // C-like trace printings if VP_TRACE defined + vpTRACE("C-like trace"); // std::cout + vpTRACE(1, "C-like trace level 1"); // std::cout + + vpERROR_TRACE("C-like error trace"); // std::cerr + vpERROR_TRACE(1, "C-like error trace level 1"); // std::cerr if VP_DEBUG_MODE value is >= 1 + + // C-like debug printings if VP_DEBUG defined + vpDEBUG_TRACE ("C-like debug trace"); // stdout + vpDERROR_TRACE("C-like error trace"); // stderr + + vpDEBUG_TRACE (2, "C-like debug trace level 2"); // std::cout if VP_DEBUG_MODE value >= 2 + vpDERROR_TRACE(2, "C-like error trace level 2"); // std::cerr if VP_DEBUG_MODE value >= 2 + + // C++-like trace printings if VP_TRACE defined + vpCTRACE << "C++-like trace" << std::endl; // std::cout + vpCERROR << "C++-like error trace" << std::endl; // std::cerr + + // C++-like debug printings if VP_DEBUG defined + vpCDEBUG(2) << "C++-like debug trace level 2" << std::endl; // std::cout if VP_DEBUG_MODE value >= 2 + + vpOUT_FCT("main()"); // std::cout if VP_TRACE defined +} diff --git a/tutorial/tracking/blob/CMakeLists.txt b/tutorial/tracking/blob/CMakeLists.txt index 8e482333c90295d82fe56f77706d308b2dc79494..a16031eb7b4a3f34ef99c048bcd5604a6518f91c 100644 --- a/tutorial/tracking/blob/CMakeLists.txt +++ b/tutorial/tracking/blob/CMakeLists.txt @@ -3,20 +3,19 @@ project(tutorial-tracking-blob) cmake_minimum_required(VERSION 2.6) find_package(VISP REQUIRED) -if(VISP_FOUND) - include(${VISP_USE_FILE}) -endif(VISP_FOUND) -# build the examples -add_executable(tutorial-blob-tracker tutorial-blob-tracker.cpp) -add_executable(tutorial-blob-auto-tracker tutorial-blob-auto-tracker.cpp) +# set the list of source files +set(tutorial_cpp + tutorial-blob-tracker.cpp + tutorial-blob-auto-tracker.cpp) -# copy the data -get_target_property(target_location tutorial-blob-auto-tracker LOCATION) -get_filename_component(target_location "${target_location}" PATH) -set(data "${CMAKE_CURRENT_SOURCE_DIR}/target.pgm" ) -add_custom_command( - TARGET tutorial-blob-auto-tracker - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy "${data}" "${target_location}" -) +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/target.pgm" ) + +foreach(cpp ${tutorial_cpp}) + visp_add_target(${cpp}) +endforeach() + +# Copy the data files to the same location than the target +foreach(data ${tutorial_data}) + visp_copy_data(tutorial-blob-auto-tracker.cpp ${data}) +endforeach() diff --git a/tutorial/tracking/blob/tutorial-blob-auto-tracker.cpp b/tutorial/tracking/blob/tutorial-blob-auto-tracker.cpp index 34be53647c1bf3d7e876586da2371e56481df244..2e16f7164c8611f9bf2ca79288f37afd15e74529 100644 --- a/tutorial/tracking/blob/tutorial-blob-auto-tracker.cpp +++ b/tutorial/tracking/blob/tutorial-blob-auto-tracker.cpp @@ -6,79 +6,84 @@ int main() { - bool learn = false; - vpImage<unsigned char> I; // Create a gray level image container + try { + bool learn = false; + vpImage<unsigned char> I; // Create a gray level image container - vpImageIo::read(I, "./target.pgm"); + vpImageIo::read(I, "./target.pgm"); #if defined(VISP_HAVE_X11) - vpDisplayX d(I, 0, 0, "Camera view"); + vpDisplayX d(I, 0, 0, "Camera view"); #elif defined(VISP_HAVE_GDI) - vpDisplayGDI d(I, 0, 0, "Camera view"); + vpDisplayGDI d(I, 0, 0, "Camera view"); #else - std::cout << "No image viewer is available..." << std::endl; + std::cout << "No image viewer is available..." << std::endl; #endif - vpDisplay::display(I); - vpDisplay::flush(I); + vpDisplay::display(I); + vpDisplay::flush(I); - vpDot2 blob; - if (learn) { - // Learn the characteristics of the blob to auto detect - blob.setGraphics(true); - blob.setGraphicsThickness(1); - blob.initTracking(I); - blob.track(I); - std::cout << "Blob characteristics: " << std::endl; - std::cout << " width : " << blob.getWidth() << std::endl; - std::cout << " height: " << blob.getHeight() << std::endl; + vpDot2 blob; + if (learn) { + // Learn the characteristics of the blob to auto detect + blob.setGraphics(true); + blob.setGraphicsThickness(1); + blob.initTracking(I); + blob.track(I); + std::cout << "Blob characteristics: " << std::endl; + std::cout << " width : " << blob.getWidth() << std::endl; + std::cout << " height: " << blob.getHeight() << std::endl; #if VISP_VERSION_INT > VP_VERSION_INT(2,7,0) - std::cout << " area: " << blob.getArea() << std::endl; + std::cout << " area: " << blob.getArea() << std::endl; #endif - std::cout << " gray level min: " << blob.getGrayLevelMin() << std::endl; - std::cout << " gray level max: " << blob.getGrayLevelMax() << std::endl; - std::cout << " grayLevelPrecision: " << blob.getGrayLevelPrecision() << std::endl; - std::cout << " sizePrecision: " << blob.getSizePrecision() << std::endl; - std::cout << " ellipsoidShapePrecision: " << blob.getEllipsoidShapePrecision() << std::endl; - } - else { - // Set blob characteristics for the auto detection - blob.setWidth(50); - blob.setHeight(50); + std::cout << " gray level min: " << blob.getGrayLevelMin() << std::endl; + std::cout << " gray level max: " << blob.getGrayLevelMax() << std::endl; + std::cout << " grayLevelPrecision: " << blob.getGrayLevelPrecision() << std::endl; + std::cout << " sizePrecision: " << blob.getSizePrecision() << std::endl; + std::cout << " ellipsoidShapePrecision: " << blob.getEllipsoidShapePrecision() << std::endl; + } + else { + // Set blob characteristics for the auto detection + blob.setWidth(50); + blob.setHeight(50); #if VISP_VERSION_INT > VP_VERSION_INT(2,7,0) - blob.setArea(1700); + blob.setArea(1700); #endif - blob.setGrayLevelMin(0); - blob.setGrayLevelMax(30); - blob.setGrayLevelPrecision(0.8); - blob.setSizePrecision(0.65); - blob.setEllipsoidShapePrecision(0.65); - } + blob.setGrayLevelMin(0); + blob.setGrayLevelMax(30); + blob.setGrayLevelPrecision(0.8); + blob.setSizePrecision(0.65); + blob.setEllipsoidShapePrecision(0.65); + } - std::list<vpDot2> blob_list; - blob.searchDotsInArea(I, 0, 0, I.getWidth(), I.getHeight(), blob_list); + std::list<vpDot2> blob_list; + blob.searchDotsInArea(I, 0, 0, I.getWidth(), I.getHeight(), blob_list); - if (learn) { - // The blob that is tracked by initTracking() is not in the list of auto detected blobs - // We add it: - blob_list.push_back(blob); - } - std::cout << "Number of auto detected blob: " << blob_list.size() << std::endl; - std::cout << "A click to exit..." << std::endl; + if (learn) { + // The blob that is tracked by initTracking() is not in the list of auto detected blobs + // We add it: + blob_list.push_back(blob); + } + std::cout << "Number of auto detected blob: " << blob_list.size() << std::endl; + std::cout << "A click to exit..." << std::endl; - while(1) { - vpDisplay::display(I); + while(1) { + vpDisplay::display(I); - for(std::list<vpDot2>::iterator it=blob_list.begin(); it != blob_list.end(); ++it) { - (*it).setGraphics(true); - (*it).setGraphicsThickness(3); - (*it).track(I); - } + for(std::list<vpDot2>::iterator it=blob_list.begin(); it != blob_list.end(); ++it) { + (*it).setGraphics(true); + (*it).setGraphicsThickness(3); + (*it).track(I); + } - vpDisplay::flush(I); + vpDisplay::flush(I); - if (vpDisplay::getClick(I, false)) - break; + if (vpDisplay::getClick(I, false)) + break; - vpTime::wait(40); + vpTime::wait(40); + } + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; } } diff --git a/tutorial/tracking/blob/tutorial-blob-tracker.cpp b/tutorial/tracking/blob/tutorial-blob-tracker.cpp index 23dae3bd1a388440f54e8b1527256de8520a9825..29081fa6c8c911cc27a99e6cad7e454c03dd6043 100644 --- a/tutorial/tracking/blob/tutorial-blob-tracker.cpp +++ b/tutorial/tracking/blob/tutorial-blob-tracker.cpp @@ -10,38 +10,43 @@ int main() { #if (defined(VISP_HAVE_DC1394_2) || defined(VISP_HAVE_CMU1394)) - vpImage<unsigned char> I; // Create a gray level image container + try { + vpImage<unsigned char> I; // Create a gray level image container #if defined(VISP_HAVE_DC1394_2) - vp1394TwoGrabber g(false); + vp1394TwoGrabber g(false); #elif defined(VISP_HAVE_CMU1394) - vp1394CMUGrabber g; + vp1394CMUGrabber g; #endif - g.open(I); - g.acquire(I); + g.open(I); + g.acquire(I); #if defined(VISP_HAVE_X11) - vpDisplayX d(I, 0, 0, "Camera view"); + vpDisplayX d(I, 0, 0, "Camera view"); #elif defined(VISP_HAVE_GDI) - vpDisplayGDI d(I, 0, 0, "Camera view"); + vpDisplayGDI d(I, 0, 0, "Camera view"); #else - std::cout << "No image viewer is available..." << std::endl; + std::cout << "No image viewer is available..." << std::endl; #endif - vpDisplay::display(I); - vpDisplay::flush(I); - - vpDot2 blob; - blob.setGraphics(true); - blob.setGraphicsThickness(2); - blob.initTracking(I); - - while(1) { - g.acquire(I); // Acquire an image vpDisplay::display(I); - blob.track(I); vpDisplay::flush(I); - if (vpDisplay::getClick(I, false)) - break; + + vpDot2 blob; + blob.setGraphics(true); + blob.setGraphicsThickness(2); + blob.initTracking(I); + + while(1) { + g.acquire(I); // Acquire an image + vpDisplay::display(I); + blob.track(I); + vpDisplay::flush(I); + if (vpDisplay::getClick(I, false)) + break; + } + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; } #endif } diff --git a/tutorial/tracking/keypoint/CMakeLists.txt b/tutorial/tracking/keypoint/CMakeLists.txt index a407530fad3463453c84fea6d04001d7e4c4682d..46c8adc0a7850fe33781f488a923359b349f5e5a 100644 --- a/tutorial/tracking/keypoint/CMakeLists.txt +++ b/tutorial/tracking/keypoint/CMakeLists.txt @@ -3,21 +3,18 @@ project(tutorial-tracking-keypoint) cmake_minimum_required(VERSION 2.6) find_package(VISP REQUIRED) -if(VISP_FOUND) - include(${VISP_USE_FILE}) -endif(VISP_FOUND) -# build the examples -add_executable(tutorial-klt-tracker tutorial-klt-tracker.cpp) +# set the list of source files +set(tutorial_cpp + tutorial-klt-tracker.cpp) -# copy the data -get_target_property(target_location tutorial-klt-tracker LOCATION) -get_filename_component(target_location "${target_location}" PATH) -list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/video-postcard.mpeg" ) -foreach(data ${data2copy}) - add_custom_command( - TARGET tutorial-klt-tracker - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy "${data}" "${target_location}" - ) +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/video-postcard.mpeg" ) + +foreach(cpp ${tutorial_cpp}) + visp_add_target(${cpp}) +endforeach() + +# Copy the data files to the same location than the target +foreach(data ${tutorial_data}) + visp_copy_data(tutorial-klt-tracker.cpp ${data}) endforeach() diff --git a/tutorial/tracking/keypoint/tutorial-klt-tracker.cpp b/tutorial/tracking/keypoint/tutorial-klt-tracker.cpp index 89f429b4ff332dbcde1f6b98cc3acafb6a801f37..39a362f2c01b9aa321de0588094b79c9328d2d02 100644 --- a/tutorial/tracking/keypoint/tutorial-klt-tracker.cpp +++ b/tutorial/tracking/keypoint/tutorial-klt-tracker.cpp @@ -7,50 +7,55 @@ int main() { #if (VISP_HAVE_OPENCV_VERSION >= 0x010100) && defined(VISP_HAVE_FFMPEG) - vpVideoReader reader; - reader.setFileName("video-postcard.mpeg"); - - vpImage<unsigned char> I; - reader.acquire(I); - - IplImage * cvI = NULL; - vpImageConvert::convert(I, cvI); - - // Display initialisation - vpDisplayOpenCV d(I, 0, 0, "Klt tracking"); - vpDisplay::display(I); - vpDisplay::flush(I); - - vpKltOpencv tracker; - // Set tracker parameters - tracker.setMaxFeatures(200); - tracker.setWindowSize(10); - tracker.setQuality(0.01); - tracker.setMinDistance(15); - tracker.setHarrisFreeParameter(0.04); - tracker.setBlockSize(9); - tracker.setUseHarris(1); - tracker.setPyramidLevels(3); - - // Initialise the tracking - tracker.initTracking(cvI); - - while ( ! reader.end() ) - { + try { + vpVideoReader reader; + reader.setFileName("video-postcard.mpeg"); + + vpImage<unsigned char> I; reader.acquire(I); - vpDisplay::display(I); + IplImage * cvI = NULL; vpImageConvert::convert(I, cvI); - tracker.track(cvI); - tracker.display(I, vpColor::red); + // Display initialisation + vpDisplayOpenCV d(I, 0, 0, "Klt tracking"); + vpDisplay::display(I); vpDisplay::flush(I); - } - vpDisplay::getClick(I); + vpKltOpencv tracker; + // Set tracker parameters + tracker.setMaxFeatures(200); + tracker.setWindowSize(10); + tracker.setQuality(0.01); + tracker.setMinDistance(15); + tracker.setHarrisFreeParameter(0.04); + tracker.setBlockSize(9); + tracker.setUseHarris(1); + tracker.setPyramidLevels(3); + + // Initialise the tracking + tracker.initTracking(cvI); + + while ( ! reader.end() ) + { + reader.acquire(I); + vpDisplay::display(I); - cvReleaseImage(&cvI); + vpImageConvert::convert(I, cvI); + tracker.track(cvI); - return 0; + tracker.display(I, vpColor::red); + vpDisplay::flush(I); + } + + vpDisplay::getClick(I); + + cvReleaseImage(&cvI); + + return 0; + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + } #endif } diff --git a/tutorial/tracking/model-based/edges/CMakeLists.txt b/tutorial/tracking/model-based/edges/CMakeLists.txt index 6eaad4a22124ad260b012874a2b2ece985d074d8..532d5015776ec4acac8f9c044921c9f7d89c9ed5 100644 --- a/tutorial/tracking/model-based/edges/CMakeLists.txt +++ b/tutorial/tracking/model-based/edges/CMakeLists.txt @@ -3,25 +3,22 @@ project(tutorial-tracking-mb-edges) cmake_minimum_required(VERSION 2.6) find_package(VISP REQUIRED) -if(VISP_FOUND) - include(${VISP_USE_FILE}) -endif(VISP_FOUND) -# build the examples -add_executable(tutorial-mb-edge-tracker tutorial-mb-edge-tracker.cpp) +# set the list of source files +set(tutorial_cpp + tutorial-mb-edge-tracker.cpp) +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/teabox.pgm" ) +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/teabox.xml" ) +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/teabox.cao" ) +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/teabox.wrl" ) +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/teabox.init" ) -# copy the data -get_target_property(target_location tutorial-mb-edge-tracker LOCATION) -get_filename_component(target_location "${target_location}" PATH) -list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/teabox.pgm" ) -list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/teabox.xml" ) -list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/teabox.cao" ) -list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/teabox.init" ) -foreach(data ${data2copy}) - add_custom_command( - TARGET tutorial-mb-edge-tracker - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy "${data}" "${target_location}" - ) +foreach(cpp ${tutorial_cpp}) + visp_add_target(${cpp}) +endforeach() + +# Copy the data files to the same location than the target +foreach(data ${tutorial_data}) + visp_copy_data(tutorial-mb-edge-tracker.cpp ${data}) endforeach() diff --git a/tutorial/tracking/model-based/edges/teabox.wrl b/tutorial/tracking/model-based/edges/teabox.wrl new file mode 100644 index 0000000000000000000000000000000000000000..a452ea0b7c54d955211974b893b38cf1e3df1eed --- /dev/null +++ b/tutorial/tracking/model-based/edges/teabox.wrl @@ -0,0 +1,33 @@ +#VRML V2.0 utf8 + +DEF fst_0 Group { +children [ + +# Object "teabox" +Shape { + +geometry DEF cube IndexedFaceSet { + +coord Coordinate { +point [ +0 0 0 , +0 0 -0.08, +0.165 0 -0.08, +0.165 0 0 , +0.165 0.068 0 , +0.165 0.068 -0.08, +0 0.068 -0.08, +0 0.068 0 ] +} + +coordIndex [ + 0,1,2,3,-1, + 1,6,5,2,-1, + 4,5,6,7,-1, + 0,3,4,7,-1, + 5,4,3,2,-1, + 0,7,6,1,-1]} +} + +] +} diff --git a/tutorial/tracking/model-based/edges/teabox.xml b/tutorial/tracking/model-based/edges/teabox.xml index c8a31267bb11f0e8ca0e943562af1376510849df..386970455ef26a3e67b3a97283d3335ef2543a44 100644 --- a/tutorial/tracking/model-based/edges/teabox.xml +++ b/tutorial/tracking/model-based/edges/teabox.xml @@ -18,16 +18,18 @@ <step>4</step> <nb_sample>250</nb_sample> </sample> - <face> - <near_clipping>0.1</near_clipping> - <far_clipping>100</far_clipping> - <fov_clipping>1</fov_clipping> - </face> <camera> <u0>325.66776</u0> <v0>243.69727</v0> <px>839.21470</px> <py>839.44555</py> </camera> + <face> + <angle_appear>70</angle_appear> + <angle_disappear>80</angle_disappear> + <near_clipping>0.1</near_clipping> + <far_clipping>100</far_clipping> + <fov_clipping>1</fov_clipping> + </face> </conf> diff --git a/tutorial/tracking/model-based/edges/tutorial-mb-edge-tracker.cpp b/tutorial/tracking/model-based/edges/tutorial-mb-edge-tracker.cpp index 1ee84758d6387c6f7a9f405a26de3fe6f2230120..5852550abb48bfb0673d3976e3fbe9a183b6be6a 100644 --- a/tutorial/tracking/model-based/edges/tutorial-mb-edge-tracker.cpp +++ b/tutorial/tracking/model-based/edges/tutorial-mb-edge-tracker.cpp @@ -6,62 +6,70 @@ int main() { - vpImage<unsigned char> I; - vpCameraParameters cam; - vpHomogeneousMatrix cMo; + try { + vpImage<unsigned char> I; + vpCameraParameters cam; + vpHomogeneousMatrix cMo; - vpImageIo::read(I, "teabox.pgm"); + vpImageIo::read(I, "teabox.pgm"); #if defined(VISP_HAVE_X11) - vpDisplayX display(I,100,100,"Model-based edge tracker");; + vpDisplayX display(I,100,100,"Model-based edge tracker");; #elif defined(VISP_HAVE_GDI) - vpDisplayGDI display(I,100,100,"Model-based edge tracker");; + vpDisplayGDI display(I,100,100,"Model-based edge tracker");; #else - std::cout << "No image viewer is available..." << std::endl; + std::cout << "No image viewer is available..." << std::endl; #endif - vpMbEdgeTracker tracker; + vpMbEdgeTracker tracker; #ifdef VISP_HAVE_XML2 - tracker.loadConfigFile("teabox.xml"); + tracker.loadConfigFile("teabox.xml"); #else - vpMe me; - me.setMaskSize(5); - me.setMaskNumber(180); - me.setRange(8); - me.setThreshold(10000); - me.setMu1(0.5); - me.setMu2(0.5); - me.setSampleStep(4); - me.setNbTotalSample(250); - tracker.setMovingEdge(me); - cam.initPersProjWithoutDistortion(839, 839, 325, 243); - tracker.setCameraParameters(cam); - tracker.setNearClippingDistance(0.1); - tracker.setFarClippingDistance(100.0); - tracker.setClipping(tracker.getClipping() | vpMbtPolygon::FOV_CLIPPING); + vpMe me; + me.setMaskSize(5); + me.setMaskNumber(180); + me.setRange(8); + me.setThreshold(10000); + me.setMu1(0.5); + me.setMu2(0.5); + me.setSampleStep(4); + me.setNbTotalSample(250); + tracker.setMovingEdge(me); + cam.initPersProjWithoutDistortion(839, 839, 325, 243); + tracker.setCameraParameters(cam); + tracker.setAngleAppear( vpMath::rad(70) ); + tracker.setAngleDisappear( vpMath::rad(80) ); + tracker.setNearClippingDistance(0.1); + tracker.setFarClippingDistance(100.0); + tracker.setClipping(tracker.getClipping() | vpMbtPolygon::FOV_CLIPPING); #endif - tracker.setDisplayFeatures(true); - tracker.setOgreVisibilityTest(false); - tracker.loadModel("teabox.cao"); - tracker.initClick(I, "teabox.init"); + tracker.setOgreVisibilityTest(false); + tracker.loadModel("teabox.cao"); + //tracker.loadModel("teabox.wrl"); + tracker.setDisplayFeatures(true); + tracker.initClick(I, "teabox.init"); - while(1){ - vpDisplay::display(I); - tracker.track(I); - tracker.getPose(cMo); - tracker.getCameraParameters(cam); - tracker.display(I, cMo, cam, vpColor::red, 2); - vpDisplay::displayFrame(I, cMo, cam, 0.025, vpColor::none, 3); - vpDisplay::flush(I); + while(1){ + vpDisplay::display(I); + tracker.track(I); + tracker.getPose(cMo); + tracker.getCameraParameters(cam); + tracker.display(I, cMo, cam, vpColor::red, 2); + vpDisplay::displayFrame(I, cMo, cam, 0.025, vpColor::none, 3); + vpDisplay::flush(I); - if (vpDisplay::getClick(I, false)) - break; - vpTime::wait(40); - } + if (vpDisplay::getClick(I, false)) + break; + vpTime::wait(40); + } #ifdef VISP_HAVE_XML2 - vpXmlParser::cleanup(); + vpXmlParser::cleanup(); #endif #ifdef VISP_HAVE_COIN - SoDB::finish(); + SoDB::finish(); #endif + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + } } diff --git a/tutorial/tracking/model-based/hybrid/CMakeLists.txt b/tutorial/tracking/model-based/hybrid/CMakeLists.txt index 220abfa3947394f5854ba8ed827ea4ec79587116..55f433305d8bfc9c17a10e7aa161fa6f7107ee05 100644 --- a/tutorial/tracking/model-based/hybrid/CMakeLists.txt +++ b/tutorial/tracking/model-based/hybrid/CMakeLists.txt @@ -3,24 +3,21 @@ project(tutorial-tracking-mb-hybrid) cmake_minimum_required(VERSION 2.6) find_package(VISP REQUIRED) -if(VISP_FOUND) - include(${VISP_USE_FILE}) -endif(VISP_FOUND) -# build the examples -add_executable(tutorial-mb-hybrid-tracker tutorial-mb-hybrid-tracker.cpp) +# set the list of source files +set(tutorial_cpp + tutorial-mb-hybrid-tracker.cpp) -# copy the data -get_target_property(target_location tutorial-mb-hybrid-tracker LOCATION) -get_filename_component(target_location "${target_location}" PATH) -list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/teabox.pgm" ) -list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/teabox.xml" ) -list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/teabox.cao" ) -list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/teabox.init" ) -foreach(data ${data2copy}) - add_custom_command( - TARGET tutorial-mb-hybrid-tracker - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy "${data}" "${target_location}" - ) +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/teabox.pgm" ) +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/teabox.xml" ) +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/teabox.cao" ) +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/teabox.init" ) + +foreach(cpp ${tutorial_cpp}) + visp_add_target(${cpp}) +endforeach() + +# Copy the data files to the same location than the target +foreach(data ${tutorial_data}) + visp_copy_data(tutorial-mb-hybrid-tracker.cpp ${data}) endforeach() diff --git a/tutorial/tracking/model-based/hybrid/teabox.xml b/tutorial/tracking/model-based/hybrid/teabox.xml index d25cdf11000c9d66a4fc1e055c604cc7f6aa9568..41a1afbf8e84411727a564d89507b0e32e571735 100644 --- a/tutorial/tracking/model-based/hybrid/teabox.xml +++ b/tutorial/tracking/model-based/hybrid/teabox.xml @@ -18,13 +18,6 @@ <step>4</step> <nb_sample>250</nb_sample> </sample> - <face> - <angle_appear>70</angle_appear> - <angle_disappear>80</angle_disappear> - <near_clipping>0.1</near_clipping> - <far_clipping>100</far_clipping> - <fov_clipping>1</fov_clipping> - </face> <klt> <mask_border>5</mask_border> <max_features>300</max_features> @@ -41,5 +34,12 @@ <px>839.21470</px> <py>839.44555</py> </camera> + <face> + <angle_appear>70</angle_appear> + <angle_disappear>80</angle_disappear> + <near_clipping>0.1</near_clipping> + <far_clipping>100</far_clipping> + <fov_clipping>1</fov_clipping> + </face> </conf> diff --git a/tutorial/tracking/model-based/hybrid/tutorial-mb-hybrid-tracker.cpp b/tutorial/tracking/model-based/hybrid/tutorial-mb-hybrid-tracker.cpp index 1e5b22c145aeaf8ec5a2544e83931a8505a24a2b..630546e52065c1a7111590c4fa1f00ef65228047 100644 --- a/tutorial/tracking/model-based/hybrid/tutorial-mb-hybrid-tracker.cpp +++ b/tutorial/tracking/model-based/hybrid/tutorial-mb-hybrid-tracker.cpp @@ -7,77 +7,81 @@ int main() { #ifdef VISP_HAVE_OPENCV - vpImage<unsigned char> I; - vpCameraParameters cam; - vpHomogeneousMatrix cMo; + try { + vpImage<unsigned char> I; + vpCameraParameters cam; + vpHomogeneousMatrix cMo; - vpImageIo::read(I, "teabox.pgm"); + vpImageIo::read(I, "teabox.pgm"); #if defined(VISP_HAVE_X11) - vpDisplayX display(I,100,100,"Model-based hybrid tracker");; + vpDisplayX display(I,100,100,"Model-based hybrid tracker");; #elif defined(VISP_HAVE_GDI) - vpDisplayGDI display(I,100,100,"Model-based hybrid tracker");; + vpDisplayGDI display(I,100,100,"Model-based hybrid tracker");; #else - std::cout << "No image viewer is available..." << std::endl; + std::cout << "No image viewer is available..." << std::endl; #endif - vpMbEdgeKltTracker tracker; + vpMbEdgeKltTracker tracker; #ifdef VISP_HAVE_XML2 - tracker.loadConfigFile("teabox.xml"); + tracker.loadConfigFile("teabox.xml"); #else - vpMe me; - me.setMaskSize(5); - me.setMaskNumber(180); - me.setRange(8); - me.setThreshold(10000); - me.setMu1(0.5); - me.setMu2(0.5); - me.setSampleStep(4); - me.setNbTotalSample(250); - tracker.setMovingEdge(me); - tracker.setAngleAppear(70); - tracker.setAngleDisappear(80); - tracker.setMaskBorder(5); - vpKltOpencv klt_settings; - klt_settings.setMaxFeatures(300); - klt_settings.setWindowSize(5); - klt_settings.setQuality(0.015); - klt_settings.setMinDistance(8); - klt_settings.setHarrisFreeParameter(0.01); - klt_settings.setBlockSize(3); - klt_settings.setPyramidLevels(3); - tracker.setKltOpencv(klt_settings); - cam.initPersProjWithoutDistortion(839, 839, 325, 243); - tracker.setCameraParameters(cam); - tracker.setNearClippingDistance(0.1); - tracker.setFarClippingDistance(100.0); - tracker.setClipping(tracker.getClipping() | vpMbtPolygon::FOV_CLIPPING); + vpMe me; + me.setMaskSize(5); + me.setMaskNumber(180); + me.setRange(8); + me.setThreshold(10000); + me.setMu1(0.5); + me.setMu2(0.5); + me.setSampleStep(4); + me.setNbTotalSample(250); + tracker.setMovingEdge(me); + tracker.setMaskBorder(5); + vpKltOpencv klt_settings; + klt_settings.setMaxFeatures(300); + klt_settings.setWindowSize(5); + klt_settings.setQuality(0.015); + klt_settings.setMinDistance(8); + klt_settings.setHarrisFreeParameter(0.01); + klt_settings.setBlockSize(3); + klt_settings.setPyramidLevels(3); + tracker.setKltOpencv(klt_settings); + cam.initPersProjWithoutDistortion(839, 839, 325, 243); + tracker.setCameraParameters(cam); + tracker.setAngleAppear( vpMath::rad(70) ); + tracker.setAngleDisappear( vpMath::rad(80) ); + tracker.setNearClippingDistance(0.1); + tracker.setFarClippingDistance(100.0); + tracker.setClipping(tracker.getClipping() | vpMbtPolygon::FOV_CLIPPING); #endif - tracker.setDisplayFeatures(true); - tracker.setOgreVisibilityTest(true); - tracker.loadModel("teabox.cao"); - tracker.initClick(I, "teabox.init"); + tracker.setOgreVisibilityTest(true); + tracker.loadModel("teabox.cao"); + tracker.setDisplayFeatures(true); + tracker.initClick(I, "teabox.init"); - while(1){ - vpDisplay::display(I); - tracker.track(I); - tracker.getPose(cMo); - tracker.getCameraParameters(cam); - tracker.display(I, cMo, cam, vpColor::red, 2, true); - vpDisplay::displayFrame(I, cMo, cam, 0.025, vpColor::none, 3); - vpDisplay::flush(I); + while(1){ + vpDisplay::display(I); + tracker.track(I); + tracker.getPose(cMo); + tracker.getCameraParameters(cam); + tracker.display(I, cMo, cam, vpColor::red, 2, true); + vpDisplay::displayFrame(I, cMo, cam, 0.025, vpColor::none, 3); + vpDisplay::flush(I); - if (vpDisplay::getClick(I, false)) - break; - vpTime::wait(40); - } + if (vpDisplay::getClick(I, false)) + break; + vpTime::wait(40); + } #ifdef VISP_HAVE_XML2 - vpXmlParser::cleanup(); + vpXmlParser::cleanup(); #endif #ifdef VISP_HAVE_COIN - SoDB::finish(); + SoDB::finish(); #endif - + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + } #endif } diff --git a/tutorial/tracking/model-based/keypoint/CMakeLists.txt b/tutorial/tracking/model-based/keypoint/CMakeLists.txt index 164edb88380913d2debf4a4e017eed45d44311fe..52732209648f5305ac762275f703889792f14850 100644 --- a/tutorial/tracking/model-based/keypoint/CMakeLists.txt +++ b/tutorial/tracking/model-based/keypoint/CMakeLists.txt @@ -3,25 +3,22 @@ project(tutorial-tracking-mb-keypoint) cmake_minimum_required(VERSION 2.6) find_package(VISP REQUIRED) -if(VISP_FOUND) - include(${VISP_USE_FILE}) -endif(VISP_FOUND) -# build the examples -add_executable(tutorial-mb-klt-tracker tutorial-mb-klt-tracker.cpp) +# set the list of source files +set(tutorial_cpp + tutorial-mb-klt-tracker.cpp) -# copy the data -get_target_property(target_location tutorial-mb-klt-tracker LOCATION) -get_filename_component(target_location "${target_location}" PATH) -list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/teabox.pgm" ) -list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/teabox.xml" ) -list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/teabox.cao" ) -list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/teabox-triangle.cao" ) -list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/teabox.init" ) -foreach(data ${data2copy}) - add_custom_command( - TARGET tutorial-mb-klt-tracker - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy "${data}" "${target_location}" - ) +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/teabox.pgm" ) +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/teabox.xml" ) +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/teabox.cao" ) +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/teabox-triangle.cao" ) +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/teabox.init" ) + +foreach(cpp ${tutorial_cpp}) + visp_add_target(${cpp}) +endforeach() + +# Copy the data files to the same location than the target +foreach(data ${tutorial_data}) + visp_copy_data(tutorial-mb-klt-tracker.cpp ${data}) endforeach() diff --git a/tutorial/tracking/model-based/keypoint/teabox.xml b/tutorial/tracking/model-based/keypoint/teabox.xml index 0937e9ee703b9a39de7c128e040d7961a1d3568b..6e1762b42c5ba2da16e3f001b0b62c9e9d64b294 100644 --- a/tutorial/tracking/model-based/keypoint/teabox.xml +++ b/tutorial/tracking/model-based/keypoint/teabox.xml @@ -1,12 +1,5 @@ <?xml version="1.0"?> <conf> - <face> - <angle_appear>70</angle_appear> - <angle_disappear>80</angle_disappear> - <near_clipping>0.1</near_clipping> - <far_clipping>100</far_clipping> - <fov_clipping>1</fov_clipping> - </face> <klt> <mask_border>5</mask_border> <max_features>300</max_features> @@ -23,5 +16,12 @@ <px>839.21470</px> <py>839.44555</py> </camera> + <face> + <angle_appear>70</angle_appear> + <angle_disappear>80</angle_disappear> + <near_clipping>0.1</near_clipping> + <far_clipping>100</far_clipping> + <fov_clipping>1</fov_clipping> + </face> </conf> diff --git a/tutorial/tracking/model-based/keypoint/tutorial-mb-klt-tracker.cpp b/tutorial/tracking/model-based/keypoint/tutorial-mb-klt-tracker.cpp index 46582dedb46b7983439f42ec9fe6bb1c84138fcb..b83463001706e722f375c57d7011c58f8b10fa3a 100644 --- a/tutorial/tracking/model-based/keypoint/tutorial-mb-klt-tracker.cpp +++ b/tutorial/tracking/model-based/keypoint/tutorial-mb-klt-tracker.cpp @@ -7,67 +7,72 @@ int main() { #ifdef VISP_HAVE_OPENCV - vpImage<unsigned char> I; - vpCameraParameters cam; - vpHomogeneousMatrix cMo; + try { + vpImage<unsigned char> I; + vpCameraParameters cam; + vpHomogeneousMatrix cMo; - vpImageIo::read(I, "teabox.pgm"); + vpImageIo::read(I, "teabox.pgm"); #if defined(VISP_HAVE_X11) - vpDisplayX display(I,100,100,"Model-based keypoints tracker");; + vpDisplayX display(I,100,100,"Model-based keypoints tracker");; #elif defined(VISP_HAVE_GDI) - vpDisplayGDI display(I,100,100,"Model-based keypoints tracker");; + vpDisplayGDI display(I,100,100,"Model-based keypoints tracker");; #else - std::cout << "No image viewer is available..." << std::endl; + std::cout << "No image viewer is available..." << std::endl; #endif - vpMbKltTracker tracker; + vpMbKltTracker tracker; #ifdef VISP_HAVE_XML2 - tracker.loadConfigFile("teabox.xml"); + tracker.loadConfigFile("teabox.xml"); #else - tracker.setAngleAppear(70); - tracker.setAngleDisappear(80); - tracker.setMaskBorder(5); - vpKltOpencv klt_settings; - klt_settings.setMaxFeatures(300); - klt_settings.setWindowSize(5); - klt_settings.setQuality(0.015); - klt_settings.setMinDistance(8); - klt_settings.setHarrisFreeParameter(0.01); - klt_settings.setBlockSize(3); - klt_settings.setPyramidLevels(3); - tracker.setKltOpencv(klt_settings); - cam.initPersProjWithoutDistortion(839, 839, 325, 243); - tracker.setCameraParameters(cam); - tracker.setNearClippingDistance(0.1); - tracker.setFarClippingDistance(100.0); - tracker.setClipping(tracker.getClipping() | vpMbtPolygon::FOV_CLIPPING); + tracker.setMaskBorder(5); + vpKltOpencv klt_settings; + klt_settings.setMaxFeatures(300); + klt_settings.setWindowSize(5); + klt_settings.setQuality(0.015); + klt_settings.setMinDistance(8); + klt_settings.setHarrisFreeParameter(0.01); + klt_settings.setBlockSize(3); + klt_settings.setPyramidLevels(3); + tracker.setKltOpencv(klt_settings); + cam.initPersProjWithoutDistortion(839, 839, 325, 243); + tracker.setCameraParameters(cam); + tracker.setAngleAppear( vpMath::rad(70) ); + tracker.setAngleDisappear( vpMath::rad(80) ); + tracker.setNearClippingDistance(0.1); + tracker.setFarClippingDistance(100.0); + tracker.setClipping(tracker.getClipping() | vpMbtPolygon::FOV_CLIPPING); #endif - tracker.setDisplayFeatures(true); - tracker.setOgreVisibilityTest(true); - tracker.loadModel("teabox-triangle.cao"); - tracker.initClick(I, "teabox.init"); + tracker.setOgreVisibilityTest(true); + tracker.loadModel("teabox-triangle.cao"); + tracker.setDisplayFeatures(true); + tracker.initClick(I, "teabox.init"); - while(1){ - vpDisplay::display(I); - tracker.track(I); - tracker.getPose(cMo); - tracker.getCameraParameters(cam); - tracker.display(I, cMo, cam, vpColor::red, 2, true); - vpDisplay::displayFrame(I, cMo, cam, 0.025, vpColor::none, 3); - vpDisplay::flush(I); + while(1){ + vpDisplay::display(I); + tracker.track(I); + tracker.getPose(cMo); + tracker.getCameraParameters(cam); + tracker.display(I, cMo, cam, vpColor::red, 2, true); + vpDisplay::displayFrame(I, cMo, cam, 0.025, vpColor::none, 3); + vpDisplay::flush(I); - if (vpDisplay::getClick(I, false)) - break; - vpTime::wait(40); - } + if (vpDisplay::getClick(I, false)) + break; + vpTime::wait(40); + } #ifdef VISP_HAVE_XML2 - vpXmlParser::cleanup(); + vpXmlParser::cleanup(); #endif #ifdef VISP_HAVE_COIN - SoDB::finish(); + SoDB::finish(); #endif + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + } #endif } diff --git a/tutorial/tracking/moving-edges/CMakeLists.txt b/tutorial/tracking/moving-edges/CMakeLists.txt index 93d9a6ded309d0a901a1e43d845d005868ebb30e..e1e7dd3410beef63ff5b4c56978a55f7ac990190 100644 --- a/tutorial/tracking/moving-edges/CMakeLists.txt +++ b/tutorial/tracking/moving-edges/CMakeLists.txt @@ -3,10 +3,12 @@ project(tutorial-tracking-me) cmake_minimum_required(VERSION 2.6) find_package(VISP REQUIRED) -if(VISP_FOUND) - include(${VISP_USE_FILE}) -endif(VISP_FOUND) -# build the examples -add_executable(tutorial-me-ellipse-tracker tutorial-me-ellipse-tracker.cpp) -add_executable(tutorial-me-line-tracker tutorial-me-line-tracker.cpp) +# set the list of source files +set(tutorial_cpp + tutorial-me-ellipse-tracker.cpp + tutorial-me-line-tracker.cpp) + +foreach(cpp ${tutorial_cpp}) + visp_add_target(${cpp}) +endforeach() diff --git a/tutorial/tracking/moving-edges/tutorial-me-ellipse-tracker.cpp b/tutorial/tracking/moving-edges/tutorial-me-ellipse-tracker.cpp index 319762e0498e32a8b4af522a653bd2c2224b000d..19b8fa40d0b42abd66a7056283cbf575bb36d29c 100644 --- a/tutorial/tracking/moving-edges/tutorial-me-ellipse-tracker.cpp +++ b/tutorial/tracking/moving-edges/tutorial-me-ellipse-tracker.cpp @@ -9,46 +9,50 @@ int main() { #if (defined(VISP_HAVE_DC1394_2) || defined(VISP_HAVE_CMU1394) || defined(VISP_HAVE_V4L2)) - - vpImage<unsigned char> I; + try { + vpImage<unsigned char> I; #if defined(VISP_HAVE_DC1394_2) - vp1394TwoGrabber g(false); + vp1394TwoGrabber g(false); #elif defined(VISP_HAVE_CMU1394) - vp1394CMUGrabber g; + vp1394CMUGrabber g; #elif defined(VISP_HAVE_V4L2) - vpV4l2Grabber g; + vpV4l2Grabber g; #endif - g.open(I); - g.acquire(I); + g.open(I); + g.acquire(I); #if defined(VISP_HAVE_X11) - vpDisplayX d(I, 0, 0, "Camera view"); + vpDisplayX d(I, 0, 0, "Camera view"); #elif defined(VISP_HAVE_GDI) - vpDisplayGDI d(I, 0, 0, "Camera view"); + vpDisplayGDI d(I, 0, 0, "Camera view"); #else - std::cout << "No image viewer is available..." << std::endl; + std::cout << "No image viewer is available..." << std::endl; #endif - vpDisplay::display(I); - vpDisplay::flush(I); - - vpMe me; - me.setRange(25); - me.setThreshold(15000); - me.setSampleStep(10); - - vpMeEllipse ellipse; - ellipse.setMe(&me); - ellipse.setDisplay(vpMeSite::RANGE_RESULT); - ellipse.initTracking(I); - - while(1) { - g.acquire(I); vpDisplay::display(I); - ellipse.track(I); - ellipse.display(I, vpColor::red); vpDisplay::flush(I); + + vpMe me; + me.setRange(25); + me.setThreshold(15000); + me.setSampleStep(10); + + vpMeEllipse ellipse; + ellipse.setMe(&me); + ellipse.setDisplay(vpMeSite::RANGE_RESULT); + ellipse.initTracking(I); + + while(1) { + g.acquire(I); + vpDisplay::display(I); + ellipse.track(I); + ellipse.display(I, vpColor::red); + vpDisplay::flush(I); + } + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; } #endif } diff --git a/tutorial/tracking/moving-edges/tutorial-me-line-tracker.cpp b/tutorial/tracking/moving-edges/tutorial-me-line-tracker.cpp index 4881a04fb26904e190e3d1392f6f171e93bbe10a..e01f9f6789b1a6e89150303a400c13b55fb911cf 100644 --- a/tutorial/tracking/moving-edges/tutorial-me-line-tracker.cpp +++ b/tutorial/tracking/moving-edges/tutorial-me-line-tracker.cpp @@ -9,46 +9,50 @@ int main() { #if (defined(VISP_HAVE_DC1394_2) || defined(VISP_HAVE_CMU1394) || defined(VISP_HAVE_V4L2)) - - vpImage<unsigned char> I; + try { + vpImage<unsigned char> I; #if defined(VISP_HAVE_DC1394_2) - vp1394TwoGrabber g(false); + vp1394TwoGrabber g(false); #elif defined(VISP_HAVE_CMU1394) - vp1394CMUGrabber g; + vp1394CMUGrabber g; #elif defined(VISP_HAVE_V4L2) - vpV4l2Grabber g; + vpV4l2Grabber g; #endif - g.open(I); - g.acquire(I); + g.open(I); + g.acquire(I); #if defined(VISP_HAVE_X11) - vpDisplayX d(I, 0, 0, "Camera view"); + vpDisplayX d(I, 0, 0, "Camera view"); #elif defined(VISP_HAVE_GDI) - vpDisplayGDI d(I, 0, 0, "Camera view"); + vpDisplayGDI d(I, 0, 0, "Camera view"); #else - std::cout << "No image viewer is available..." << std::endl; + std::cout << "No image viewer is available..." << std::endl; #endif - vpDisplay::display(I); - vpDisplay::flush(I); - - vpMe me; - me.setRange(25); - me.setThreshold(15000); - me.setSampleStep(10); - - vpMeLine line; - line.setMe(&me); - line.setDisplay(vpMeSite::RANGE_RESULT); - line.initTracking(I); - - while(1) { - g.acquire(I); vpDisplay::display(I); - line.track(I); - line.display(I, vpColor::red); vpDisplay::flush(I); + + vpMe me; + me.setRange(25); + me.setThreshold(15000); + me.setSampleStep(10); + + vpMeLine line; + line.setMe(&me); + line.setDisplay(vpMeSite::RANGE_RESULT); + line.initTracking(I); + + while(1) { + g.acquire(I); + vpDisplay::display(I); + line.track(I); + line.display(I, vpColor::red); + vpDisplay::flush(I); + } + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; } #endif } diff --git a/tutorial/tracking/template-tracker/CMakeLists.txt b/tutorial/tracking/template-tracker/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..385c9d6351f5740690860a06a31b3fe03f60ad02 --- /dev/null +++ b/tutorial/tracking/template-tracker/CMakeLists.txt @@ -0,0 +1,20 @@ +project(tutorial-tracking-template) + +cmake_minimum_required(VERSION 2.6) + +find_package(VISP REQUIRED) + +# set the list of source files +set(tutorial_cpp + tutorial-template-tracker.cpp) + +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/pattern-template-tracker.pgm" ) + +foreach(cpp ${tutorial_cpp}) + visp_add_target(${cpp}) +endforeach() + +# Copy the data files to the same location than the target +foreach(data ${tutorial_data}) + visp_copy_data(tutorial-template-tracker.cpp ${data}) +endforeach() diff --git a/tutorial/tracking/template-tracker/pattern-template-tracker.pgm b/tutorial/tracking/template-tracker/pattern-template-tracker.pgm new file mode 100644 index 0000000000000000000000000000000000000000..a9c08148ee6f68a970b8e1fed32b54511b7ca77e --- /dev/null +++ b/tutorial/tracking/template-tracker/pattern-template-tracker.pgm @@ -0,0 +1,4440 @@ +P5 +# CREATOR: GIMP PNM Filter Version 1.1 +640 480 +255 +>>?@?AAAAA@@@@?A@@?ABA??ACCBABBDCABCCDDDDCCCCCCDEEDCDDABDFDBDEEEEFEDDFFEFGDDDBEGEEEEDEFFCDECCDDEGHHHHGGFGGGGGIIHHJIGHIIHGIHHGHGHIJIIKLJHJHIKKKMMLKJKKKKLLMMMMLKKIKLLLMMMNNMLLNNKKMMLLKJJLNNMKNNLLMNONNMLLQPNNNMNOOMOQQPOOOONOPPOPPOOOOONNOPPQQQRQOPRRRQPPSQPQQQTTSPQTSSSTRRRSSTTPPQTVUVUTUUSQRTVUTTTVWWWVUUVVVYYWVWYXVVXXZZZZ[[Z[]\Y\\[YZ\[[[\[[]^_`][]`_]^_`aa`aaabbbbca_b`bccefdddfgffefgghgdfgjihhgghhjihijmnmmmooopommlmnopolhkkihggfeedbcaaaa_^]YZZXVTSPNNMHFFEEDB@>;:9974320./-((''&%" + + + !! + + + + +>>?=?@A@@@@?@AAAABA@AA@???AAABBCCABCB@CCCABAB@CCCDCBDDCCDEEBDDDADEDCFGFDEFDEEBDFFEEEEDFGEDDCDDDEGGHHFDGGHIFFEIJIJIGGIIIIIIHIHEGGIIJKLLKIKIJJJIMMMIIJIGJJKFJJLMMLMMLKMMLIMNLGLNNLLNMKLJJKMOONLHLJMOPONKNNNOOMNONNOONOOMOOOPQPONOPQQQMMNOKNORSROPPQPQRTTRNPRQNRTSQTSTSSSSSSRRSSPTTTPTUUTUQSRUSSUWWWUTUVWWVVVUUTUYXXWXZXWXYZZZZYY[YZ[[X\\[[\\\[[ZYY[^``_Y]`a`_```__aabcbbcdb^baabdffdfffedaefgchhggghijhehijjiiijklnllnpqpimkmmoopjggkjighihdfdccbba]a^]Y[[YSSSRNPNKGGEFDB@?=;686623./.-()(($&! "!! + + + +<=>??@@?@A=>@BBAACA@AA@??@ABBBBBABCCA?BDCCCBB@BB@CCDDDCC@DEDCBBCCDBDFGEDDDDEEEDEEECDEFFFFECDEEDFGGGHEEGHIJFFEHHJJGEGHIIIFFFHIHHIFGIKLMKJKKJJIJMNMKJJGHIJKJKLJMMMMMLLMMKJKMLKMMLLMNMNMLMNLNOPNLLMNOPQONOPOOONJPNOPONNMNOPQRQQPNNPQQQQQONNPQSTRPPPQPQQSSRQQQPPTVTQTUTTTSRRRSTSSRSTTUUVUTTSSTTRSWXWXWTTTVWVVVUUTTWXWWYZYWWZZXYYVY[YWZ[[\]\\\\\\\\[[]^_`^Z\^`a`_`_^_abbcccccb^cddcefedegfcbaeihgghggggiiihhijikkkiknmllnoponmkmmnpnlkklljiijiihgecbbbbbb^\[ZYYXVSRQOLJIHGFC@@=<;8677541.,++)((&$"!! !#$"! + +<;=>??@>@@?>@AAAB@@@BAA>@AA?BBAAABCBA@CDDDCBB@BBAACDDBBCDEECDDDBDDEEGHGEEEFFFEEDFEDCEFEFFCCCFFFGGFGGGGHIIHGFFGIJJGGGHGJJHGGGJJJJHGHIKLLHKKJJJGLLKJKKKKKKLLMMMMMMMMLLLJLKLKLJNONLLMNNNHLNNMNKONNNOOPPOMNKNOPNNOPQQPPMNNPPQQPQPLOPPQSRRQPNQQRPRKPOOPQQPPRRRRRRTSRQUUUSTPRRSSTSSOTPQSUVURUTSTTSVWWSVVUTUUWWVSUTTRVUXYZXZTWZZXYYYYZYXY[\\[\[\]]]]X\\\Z[\_Z\[^_`\`^`bcab_bccbb`dedbeeeaebgeddddikigfeggihihhhiiklkhknnjjjnnnjmllgljpnmmnlljjfihhadcc^cdcb`^\XXYZUTRQPOLLGHGE@B>=<:8:8655//+-))'(&%!" + +"! ! + <=??>>??@@?@@@<AB@>BBBCBA@?@BC@@@BCCCBBCDCBCCBBBABACCBCEFEEDEFEEDDEFFHGFCFGGFGGFFGFDCFFEFEDEFFFGFEEFGIJIGGFFFHIJJIGGIJJJIIJKKJJKJJIIJLKKMNMLKKLLKJLMLMMLKKKLMNONLLMMLLLLMMLKLONKKLMNMLMNMMMNOQPOOOPPMONLMOOMNOPRRPPOPQPOPOOOOOOQOQRQOQQRRQPQQPPRRRSSQOQRRRRRSRSUVVTTTSSSSTUSSSSPQRSVUTVWVWXXXWVTVVVVVVVWVUUWWWVXZ[ZZYVWYYYXYZYYZYXZ[[[[\]_^]^]]]\\^`_]]^^]_a_]abbbaaaccbccbddffefgfggfhhfciljhghhhiifijhhilmmklmmmkilomjllkhloopmlllkjiihhfdcedddfdc__^^^^[XURSQPMMKHGGFDC@=<9::887421.+))))&"! + + !! + + +?@A?@@@@A???A@??AAAABBCAA@BCDBBBAACBBBBBBCCCDDC@BBBCC@CEEDCCDDFFECDBFGHGFEGCGHHFGGFEEFFFDDEDFGGGEDDFHJJGHHHHIIIIHGFDIJKKIGKKKJKKKIIGJIKLLMLKKFKLKHKKKLLJIIIILNOOMHMMLKLIMMLKKNMKKFLNNNMLMLMJOOPLOPPOOPNMMMMMNNPQQPOKQQQMONMMPPPQRQQPPOSSSPPPOOQRRRTTSPPQSSRRROTUUUTSTTTRTUUSRRRQRSUUUUVTUUXYXUUTUVVVUUWWWSVWXVVWZXYUYVXVYUXXYXXXYY[XZZ\]_[^]^]^^][`a_]_``^``a^aa`]a`b^cbbccddffefgffhfiihejjjehiiejkjkkfgilnnlmmmllimjnkkkkjoooklfikljkghfgbd^eeeddda``]`^\UTRUSRMOKJFGHFAC??9:8:68521.*+)*''#" + + + + + + @AAA@@@AAA=>@@@??AA@?ABBAABCDDCCCBBA@AABCCDFDEDCCCBDDCDEDDCBEDEFCCDCEGHHGFFGHIHHGGEFFEEEBEFHGGHHDDEGHIIHHHIIIIIHFFEFILIJHFIIILLLJIIJJIHIIIHJJJJLKKKKJLJHHJKLLMOPMKLLJKMMMLLLKMMLLKLNOOOONMMKOPPPQRQNOPOMNNNOMMNQPPNOQRRRRQONPQQQRRQQQQSSROPPPQRRSSSTSRRRRSRQQOTUQTTTTUTSSTTSSRSTTUTTTTTTTTWWWVUSUVVVUVX[XVWWWXXWXUWYYXWVYYY[[\\[Z[\\\[[\^_^_^]]^][`b`^_`a`aabccc`]acbbbcacdedfgffgghgghiijjkifgihhjkklljhimonnmmklmnnponljmlnonkljijklkjiihgfgggfbddcbaa`^[YWVWWTRPLLGIJECDEB><;::951/..-++)(&$#! + + + + + + +?@AAA?BBAA?>@AA>@AA?ABBAABBCB@CCDCC??AACDDDEDDDDDEEDDDEECCDBEDEEDCEDFEGGGGFFHDIGFGHFFDFGFGHHGEHHGEFGHHHHGCHIHGHHHHHHKLJJIGJHJKLJIFJLKJJIIHHIJJKKKLKHJIIIJLMLNKNNNMMKKLNNMLLMMLMLNMMOPNOOOLMLOPPOPQQOPPPOOPQOOOQRQPOPRRSUTRQNPRQORRQQQRRSRQQOPQTTTRSQSRSSTQQPROSSTUTSTTURRRSSSQTUUPTRTTTUVTUTVVURUWWUWWYZYUWWVXYWUTWXXXWWZY[Z[\^[[\\\\Y[Z\]^^^^]\[[^aaZ_\```acbbaa_bba`deeceddfgffcfgfcggiikkiggggfiilkkkkionponllklmpoponlnjmlmjmkjihdjhiahhhehgfbbbbaaaa^\XWUWVVRPMMILLIEEED?=;::953/-,/-+()%&%#! + + + >@@AABBA@???@AABAAAABCAAABBBABCCDDCA@CCDDEDDCCDFFFEECCCCBDEFFEEFEEFGGFFFGGFFGGGFDGHFFDFGGGHGHHGGHHFGIIGGGGGHFGHIJJJJJJJKKKJIJKLKIHJLKKKJKJJJKKJKLKJKKKKJKMNNMNNNNNMMLLOOMMLMNMMMMMKPQPOOONNONOONNOPOOOQSQQQQPOPQQQNQQQRSTSQPQSRQQQRSRQRRRRRQPPSUUUTSSRQTUUTSSTSSTVTRSTTTSTTTSPSUUUVXWVVVVUUUUVVSUXXXWXXYXUWVTWYXVVWWWVWYZZ[[[]^]\\\\\Y\^^^]]__aa^[]_ab_\ab`bbaa`bbbcbbdggffdceffeefhgggiijjjiiijhfijkkkjmoopqqoonmjlnooomklklmlmmkijfghhghiihhgggfefdabba`^][XWXVTRNNNMNLHFFC???=:985320//-+*&&$$$" + + + + @@@?CCB>>>@???AAABBAABBBCBB@BCCBCBDBBDDCDFEDCCCEEEEFEBBBCDFFFDFFDCEFFEDEGGFEGEDDFFFGGEFGGGHDIIGEIIGGHGFGHGGFEEHIKJJHIFIKKLJIJKLJJHHIJJJKKJKKLMLMMKMMLLLKLMNOOONKNMMMMKOONHLMMMMLLLMPQPPPONOONMNMMOPNOMQQQPPONMLMPQQRRSSSSSQLPQQPPQRRRQQNRQQRRORQTTSTSPRSTUTTTSVUVTTSTVVTUSTUTPSTVUWWWTWWWTUUTUWTVWYUTTWWXWXUVVYSWXXWXXYZ[XZW\^^]]Y\\\[]]]\^^__aa_[^^aba^babcb__`ccbcc`egffedeef_ecfhiiihigjfijjjifijjhjimlnnoppomnnmnnokklmilnmlokkkhggggghhiihcgcd`fad`ab`_]XZZXRUPOOOLMHGDD@A>?;;772331-/,,&%$$$$ + + + + + @@??BBA@AAA@?ABB@BAAAABCBBCCCDCABDEECCBBEFDCCCACDEEFFEBABEEEEFFEDDDFFEEFFFEFFFFFFFGGHGGHGGGDHIGFHIHIIIIIHFFIJKJJJIIIIHGIIJKJKKKLKKIGIKKLLJKKLMNOMLNNMMILMLMONOONMMMMMOOOOONMKNNMKMMNONOPOOONNMNMKOQQPOPOOQPOOMMLOQQQSTSRRSRPPQPNPRPOONOQRRQSSTRQRSSTRRRSRRRTTUVWWWVURWVTTTSTUUTUVVVVVWVVVUVUUVXWVVWXWSUXXYXWWZZXXYYZ\\[[ZYZZ]_]]]]]\[\^][\^_``a`__^^`aaaaabc`_bccbacbaffceeefgfedegiijhhhijkkkkkjiijhjkkkmmnmmnminpnnooopqnklnmlnomkgghigfhghhgihddcded`bba^^^\[YXVVUSOMLJHGEECB@?=<9754320-,*((&%#! + + + + + + + + + + + +@?>=@A@AAAA@ABBCCCBCDDCCA@CDDDDCCDEEDCBADDCBBBBBDFEDFFE?CFFBEFEEEDEGFCFFFEFGGEGGGEFGHHHGHHGEFFFFGFFFIJJJJJIKKKIGJIIHKIGGIJKKJJLMKJJGJJLMKIIJJJMNMLMMNMLMLKKJMMNMNLMKMNNNOPONMMNNNMMMLMNNNMOMNNONMOQPPQROPPOOONMMOLPORSSOQSTRRQPLPQPPPPQRSSTSTQSRTQSPSSSQRRRSTRVUVWVVVVVTTTTRVWVQVUWWWWVSSTWVVVXXWTWVXTVVYYYXZ[[ZZYZ[\Z\W[X\\]__]]^^^^^^Y[]^__^a___^\a`a_aaba`___cbaccbfffdeegfeefcigedddiiijkllllgiiijljjlnnnklmmnnonmmmqqoilkminjjjihhiieifhdgijhhbeeebbab[__]ZZZYWVTQLOLJGGEFBCA@;;775410,-+*'("! + + + + + + + + +??>>@@@@@@ABA@@BDDADDDCCAAACDEEEDCCDDCBCCBABDDCCDDEEFFGFEGFEEFEFEEFHGEDEEFFGHHHGGDFFGIHGGHGGHGGFFGFGIJJKKKJKJIHIJJIKKJFHJJLKHJMMKJIJKLLLKJIKLLLLKLKKMNMNLKJLKLNNNMMMJMMMLNNNMMNNMLLLKMOOOQPMOPPPOOPORTRPPPOOONOOPQOMQSRPOTTSSTQMOQQRSSRSSSRSSSSUTRSSSSSTTTTTTTUVTUVVUTUVVUTTUVVWWWXXWWVSSSVUUVXYXWVUWWWYYYXX[\\[[ZZ[[[\^[[]]\^^\^^\^^^\Y]_^^^]````_`a`aa``bcbabbccaccdeggeefhgdefgiifbdfiiiiillklljjjllkjlmnnopqqopqommpqqnlkjlnljjiigfgikjjhghijjhfghgccddda_]][ZXVUTRQPPNLJIGEDDB@>;98541-..-+)'$!" ! + + + + + + +@@@@@@@?ABCCB@A>DDDDDDDACBBCDCDCCBCCEEDDDCCCDDDADDEEFGGGFFFEDEGHGFFGGFFFGGGEHHHHHDDEGEIHHHGGIHHGGHHHIIGFJKIHHHHIKJJJKJIIKKLKJJLMKKKLLKKILKLLKJLJKLJHKMMNMLLLLIMNNLNNNONMMMLKMJMMMMMKMOOOOOPNPPPQQNPOSTRLOMOPONQPQOOMQRRRSUUSTSQNMMSSTTSSRORQTTUSTQTUTRTTTRRQUTUTTTWWVUUVVVUSUQVWXVWVWVVUUSUUTTVWXVUUVVYZZZZX[ZZYYYZ[[W]^\Z]Y[]\\]^]\\]]Z\W[\\\_____`a``a`^cdbbcabccbefecfeffghdefhhhgdefiiiijllklmljlkmljkmmmnqqpmopojnoomlgkjjijgiiibecjkjejgghifgchhgdcceac]__[UUUUTTSRPOMLKIDEDCB@<;5445///0,+(&#$!"!! + + + + + + + + + + +@A@AAA@@ABACBCCCCCCCCDEDCCBCDDCBADEEDEDCEFEDDEEDEFEEDFFFFEEDCFHIHGDEGGGHHGFFFFGIIGGGGGHIGIIJJIHHGIHHIHFIJJIGIJJIJLGJJJJKLLLKJJLLKKKMLJFKMNNNMKLLLKJIHLMNNNMLLLLMLKNONOOMMLKKMONMNPOOOOOONMPPOOOPPOPQQSQPNLOQOOQSRPPPRTTTUVVUTTQONPSUUTSRQRRRSTUUSSTUTQSSSTSTTSRTTTVVWVUTVWSSUTSUVUWXWUVWVTVWVUUVVVVXXXY[ZZZ[[YXYYX[]\\\]\[\YY]\\]^^_^^]]\[[^__]^_``aba`a_acc`abbabcdegfeedeeggdefhgfghgfhiijjllklmkjlmmnmlllklnpmlnooooonnljjimmjghhjiggijiijhghihhggggeadeecbb`]\[ZWTUUSRPOOMLHFFDAA@=;9963220,+('&&%#! %(&# + + +@???@?@@AABCCEFDB?BCCDDCCBBBDDDCBCEFEDDCDFFEDDEDEFGDEEGFEBEEEFGGGFECGGGHHGFBFGHIIGHIHGIIIIIJJJJHHIHIIHFHIIIIJKLGLNKIIIJLMHKKKKMMLJLMMKKLMMNNMKLMLKKKLMNNNNMKMMMMLKLMMKLLMLLLNOONOPPNNMPONNOOOMNOQPRRRRQNPNPQPOPRRPQQSSTUTRUTUUSPPQSTTTSQSTTRRPSRTSSTSRSTSPSRSRSTTTURWTUTWWVTTSSSSTVUWXXWWTWWWSVQWWXYZYYYYUYZZWWYZX[]]YYZ^]]Y[]_\\[^^__^]]]]_`^^[aa``bcbbbacdaaaabcc^efeedefefffeeffehhhfhfhjkllfjkjhkllkkkkjlloonlnkprqlmnngkinolfffijhgifihiiggijjhgdhfeefeecea`[\]ZVWSTNQPQNNLHDEA@?@:9973210--''''$""!%&*)" + + + + +A@@@@@AABABCDEEC@?BCCDDCDCCCBDEECCEEECBCAEGFDCCDFGGFFFGGFDFGFFFEDEEEGGFGGGFDEGHHFHIIGHIIHJHKJKKIIHGIIHFGDIKLKKLMMNMJIIILLKLLLLLMLJKLLLLLMNMMMLLMLKKLLMOONNMMMLLLLLMMLKLNOONMNOOOOONNOPQRPOOOOONPRSSRQQPOOPQQQONPQPPQSRRTSRTUTTSQQPQSTTSQTVWVSORTTTSRSTTTSRRSSSTUTUUVVVUVVWVVVVUVVVUUWYYWXWVUXXVVXZZYWYXWYZYZYVY[[YX\\[[]_a_\[]^^]]^__^]]]^^^`__`bb`accccbacdbbcaccccegfecdefffffffeeghhihfgijmmkiihgjjklmmjkmmoonmmopqpkmnnlkjmnljhhhighhijjihghjjihijigeefgfeddb_`_\ZXWTSRRRQOMJEFEB?@@=986520./-+)'%##!!#&'&# + + + + + + + + + + +BBA?@AB@CBBBDDCCB@CCCCDDEDDCCDEBDEEABDDCCCFFECEFFFFFFFFGFFHIHFEDGGFGFFFDFFGEEDHHHHJJIIHFIJKJJHJKJHIJJIHHHIKMMLMMLKKJJHIJLKMMMMLKJILMMLLLLLKHLMMMLIKLMLOPONNMNIKJLLNNMIMNPONMNNONONPQQOPQROPPPPQPRSSOQNNMMMQRQPPPPOOPQPRSSPTNTRSPQQRTTSSQSWXUTQUVUTSQTTUUUQTUUTTRUVVUUUUUVTURWWWVWVWWVVXWXVVUXWXSXZZXWZZZ[YZZZX\Z\[[\]]]]^__]][]Y^Z_^^[\\]^^___`_bcccddcabac_acdcdeddegfcedfggdeegcgfhefeheefjllkjfigjjmmnnmnonponlnoonoiolnnliijmljghfiiihlkkiihhdgdjkjhfcccfacccaba]XXWWTUQRPPLKFFDB?@==99672201/,)(&%!# $"" "##" + + + + +BA@@ABABCDBAABABBBCEEFEEDDDCCDEEDEDDCFFEDDFGGEFFCEEEFFCFFFJJHEDFHHEHGFFFGGHIFDHIIIJKKIHIIHHJIGIJIJKJIIGHIIKKLLLLKJIHHIKLLLMNLLLMMLMOMLLLLLJGJNNMMKKMNMNONMMPPPNMLLMOMIMPPOOLMOOPPPQRQPPPPQPPPOPPQSRQQQQPPQQQRRRPLNPRQPRTSTSTTUSRRSSTSRRRTWWTSQUWUTTTTTUWVUVVTTRRVXTSUVVTUWVWWYWVVVXXTUXWXWVVXXXXXYXXW[Z\[[[\[\]\[[[[]^]\\]\]][\]^``_^]^_`_``____cccbcdcacdcaacdddddddefggfgiggfffgijiiiiiiiihiijklkjijmponnonoopnlnomnnmnonnlklmmljjhiikjhjmlljigcfiiijigedffeceedb`_^\[YXWVSRPLLHHGEA@=<<<:975420,*)''&#"!!$$""&((#"! + + B=ABB@A?CDCAA@BBA@CCEFEDDDDDCBFFEBDDEFEEEDEGHEGFECDBFFEEFEJKHDEGIHGHIGGFIIIJGEIGGFHIJJIIIEHJIEHGHJKKKJIIIIIIJKLHJIIJJILNMKKLKILNOONNLLLLMKLILNMNMMMNNMNMLKNPQPQMMMMKMHLNOPPLMNNLNOOLPQQOOQPNMNNNQRQQRPPORSQNPORMONQQPNOQSSRRTTTSTORRTQRRTTUSSPSRRQUTSTUWVUXWTTTTWVWVUTUUVWXXXYWRWWXVVVWWWWWVWXXWYYZZZYY[[Y\ZZX][\V[[^_^\\[]^^[\]`aa_^]`aa^```_`]bdc`abb`d`daacedcaaadcgihfgggcgghgjjjgjikklkjjjhlmkhjjlooimillppommklmljniojljmklhjijfjkjegilijfhcfghhhgicfefffgfbaa`]_]\[XTTPRMNIHHHCC>==>::8633/-,+(($$!""" "%+*$ "! + BAACCBBBBBCCBABBACDDDDDDDCBDDDEEDDDDEFFFFFEFGGFHGEFGFFGFFGIKHEDFGGGHIHHHJJJJHHHGEFFFGJJIIJIIHFGHHHIJKJHJIIJJIJKKKKKLLKKNMJIKJKLMMONMKNMMLMNONMKNNLMNNONMMLNPPPONOONNMLLLMPOMMNKKKMMNOQPOOQOMNNNNOQRSRQNORSRPOQRSQPRRQPRTSSQPRTTSSSSTTTUVTSUSSRRQQRTSRRVWTWXXUTUWXXWXVUUWWYYZYXWWWWXXXXWWWWWVUX[ZZY[\ZYXYZ[ZXYY\]\[[\^___^^__]]]]_```__``__`aaa`__ccbaabadeedefecdedbefhihfegfefhihkkiijilnmlmmlmllkgkilnnomllmpqpponnmljnpmllklmkhiikkjkieghiihihhhghhhiihgffgggfdcc`___][ZXURTTPNLLIGEDAA><:96520/--,)%%$$"!"#),,$ BBABBCCBB@BBCBBABDECDDEEECDDDDDDDDDEFGGDDCEFGFGHHGHHGEGGFGHHHFEFGGHHIGGHIJJJIIIGFCHIIJJJJJIHHEGGGGFFGHHJJIJJIKLMMMKKMMKLLHIKLMMKLMMMMNNILLOPONMMMLMNNNMMMMLMNMOLOOOONMMNNOPONNMMLLNNOOONONONOONNNNRRQQPORSRPPQQRRPSSQPTVUSQPPRSTTTTQTSUVUSVTTTTRQQTRRRWXXVWWURUVWVVTWVVWXVXUVRVUVVVVYXWUXYXVXZZ[ZYZZYYZX[[YWYZ\X\Z\^]^_]^]][[Z]^_Z__a``````_aa`_`ab``aaadddefeedecdaeghhgehhfghhhhjkjjkilllmmhlmmjlhljmjoooklmqmqprromnknmlfkjjjkgjhmlliieffhffehfjghghhhhhfgggdddcba^`\^\]ZYSTVSMMMKGHCC@@<<785432..**$&&%"!!# &*-.+'%#" + @AAAABCCDCABCCBBBDDCDEEGFEEEDDEDDDEFFGGEDDFGGGGGFGGGGFFGGHFGGFFEEFGHGEDHIIJKJIJJIGHKJJJJJIJJIHGHHGGGIJJKKJJJJLMMMMKKMNKKKKJMNOLKKLMMLMMNMMNPONLLLMNONLKNNMLNNLNONNNNNNOOOOPPNMNMMNPQPONMOPOOOOPPNNQRQQQOPSRQQQQRSPQRQPSUUUTQORTUTSSTTTTUUWVTTUTSQQUTTUWXWVUWUTTUUVWWXXVUWXVUVVVTTUVWXXWWXZZVXZZZZY\[UY[\]\YXZ\]^\Y\^^^]]]]\\]]]^___aaa```aa`aa`abcb`bdcbcddeffeeeec_behhghihgijidhklkkklkkjlkflnnmmllmlnoonnnpqrppqrpmopnmigikjjijkllmkjieijiiiigfiiijiihhhihgfdffebcca_`a_^[WWWTRPNKJIGEDCC?<:976420.,*'&&"! !$!!&(+,-..,**)(&$$ + + + AAAAAACDECCCDEDBCBECDEFFFFFAEDCCBAFGFGF@DEFGGBGEEDFFFGGHHFEEGGGFEEFEEDFGIIJKKFIKJGHJJEJHJJJKJIJJJGHIJKLLMKKLLKKIKLLKMLLILMMMNOONMMNNLKNNMIMOOLNMNOPPOKMOPLMOOLMMLMNNNPPMOOPLOOOJLOQRONNNQRQMPOPMMMRRQNRQRRRRRRRRTQPNOQSOTTTSRQSUTSSRTPTSVUUTTTTTSSUTVXWSVWVTUQVTXXXXWVVUXVWWXXWTTTWVVWWWXYZXWTZY[Z\[YZZ[^[YXZ\^^\ZZZ^^]\]^_]]]]^_``aa^a^_aa^bbbacddab`c^d`dbdadefee_bcffgfighiihhikkjhkkjjjijfllmmlkmgklnmlmooppomonomopokjejljghhlklihhjeiiihihgfhijjhggdgihcdehggcfdc]bb_^\YXWURSNMJLHHGECB<;:96532./+)&'""!!$)*(-(,+(%'(''()% + + + + + ABABAADFFEDCEEDDEFFDCDCEFGGFFECDDDEGFFECBEEGHHGFGFFFEGHIEDEFGIHGFGHHFGGHFHIIJJIJJHIJJJIIIIHJJKJJJIHJJLLLLKIMMKKJKLLMMNLKMNMMNNONMNNNMKLMLLNOOOOPPOPQONOPPOOPOONLKMONPROOPQQPOPONNOQQNMOQRSQPPQOLOQRQRRRSQPORRRQQSTRRRSSTUVUUSQSTTTTSTUVVVUUUVUUTUVVSVXUQUVUTUVWZZYYXVWVXZZZZYYXXWWXY[[YYYXZZYYYX[]ZZZ[[\]]\ZY[\]Y[[\]][\[_a`^]^_`a``aba^^```bdedcedba`beddccb`cfghedccdefhiihhihhjkjgilnljjijklmkkklmllmmnnnnopoknolmoooonlkkljgikklkkkkjfggghjkihgjjjihgeghhhhjigghgfdcbb^]]Z[YWVUSPNMJKIFFC=<:986420/-*'('&#" &+,--.,* !&('#$$! + + + + ABA?BADFEDCBDCCDFEFEDCBDFFGGFDEEFEEFGFFEDCFGHHGGHGFFFGHGEDFGHIIFGHIJHHHHHGHHIJKLKHJJJJHEFGIJJIIGIIIJKLLJJKLMLJKJLMMJNMLKLMMJNMMNNLNMLKLMLLOPOLPQPONMNNPPPNPPOOOMMOOMNNMLOQQONOPOOMPRPOPOQRQPQQPLPOPPQRSSRPPPSPRQTSSSTTTSUVUTSRTSUUUSSTXYWUUVWTTTSTVSTUURUSRRVTWXZWXUWWXYZ[ZWWXWYYWY[\[YWZYZWZYYYZ[[YYY\]^[][YY\^^]]\\[\]^abb^Z]\^__ab``^`^``ddfdeeecbaabfee`cacghhgfebefhhhjieigijkigjlnmkljkjkiljkmmmnnnookmlnnoqqmmnplnmlillmikijjiijijgfghgllighjkhjiichijihhhggggaecba`^_]^\ZXWURMNJLIGDD><:9974400-,''&'$# ',.+.--+'" &'%!"! + BABBCCDEDDDCCEECDDEFFDCEEFGGEDFFFFFGHGFGGFFGGGEEGGFEFFFEDEGHHHHHHHHJJJHHHGGGFJKLKIIKIIHFEIJJFHIIJIJKJMMJJKKMLJJJLMNOOLLLLMMMNNNNONMMNKLMMLNONNOPNMLLLNNOPOPPNNPQPQPNMMMNNOMOONPQOMORQQQQPRRRRRPNOPPPQQTTSRRRSTTTTUUUTRRSSTTUTSTVUUSTTSVXWVUVWWUUUTUUUUUVUUUUUVUVXXWXWXXXXXXYXXXZYWXZZYXYYZZZZ[[[XY[[[[\]^^\ZYZ]``^[]\[^_`aba^\]^^^`baa``bbbdeeffeeddbabbfgfeecchiihgfgfegiiiijiiikkihjlmlklnljjklllmllmnnoppmlnnnrrmoqpnllhgknonkjjjjijkkkjjklkjjhhjklkjkkjllkjjihghhffeecbaab`][ZYXSRPNLIGGEC@>=9855421.,+)('$"! !" %)-.+..-+,+(&%'((%! !#%&'''%##"! AABDDCDEEEDACEEDDACBFFFEDEGGECFFFEGGGGFFGFGGFGGFGGHHHGGGGHHGGFGHIHIJKJJIIGGGHHJKJJIJKKIHHJKJGGIJJKKLLLMJKJKKLKJILNOPOLKJLLMMMMOOOOLMMLMMLLMONNOLJJMKMNNMQPPOOMOPOOONNNNOPQPPPOPPOMOPPPRQPNRPSROMPOPNPQRSRNRQQRTUUTUSSNQPRRTUUTUQUUTPUSVQWVVVVVVWWVVVVTTTVSVUTTVUWSWWXXWUWVYZYSXYXTWYXUYYYYZZZ[[[[[[XWVZ\^]]XXX]`_[\\]]`_``a[_^^__^abb^^_ddceeaeddccdcabaefdceeefgeicedeefgjjiijfijkjiijkkjmmlijmmgmlllnklmqrplnmorrnnmoiklifjjnmkejikhjkkkjilligkiigjgkklllllgjkjiihjfhegbbbbbb^]X[[XUSLJIIIHBC>?;;765520..*)(&"# !# $)+*.,/..,++)")$(&$"!!"""#! $((('&&&%#!"%"$#AACEEDCEEFEDDEEDEDDDFFFEBDEFFFFGGFFFFFFEDEFEEFGGHIIJIHGGHJIIIGHHIJJJJJJJJIHHHHFIIIHILKJIIJKJHIIJKLLMMLMMLJKKJJJKLMNPPOMJKLMMJMMPOOLMOOPOOONPPOONNNNMMOPQQPOOONOONNOPOMMMPSRQQQQPOONPPPQQPMPRRQOOPSRRRQSSRRSSQTVUTTUSRSRRRRSUUSTUTTTTUWVVUUUUTTUVWXWWUTUUUUUVVTVWXYXWWXWVWXY[YWXYZWUYWWYYYY[YYZZZ\][[ZYZ\^]^^\[]_^Z\]^`a``a_^^^_`__`aaa`_cddddcddaccddbcdedadedbceghieabeefikihhfhhjjkkkkmmmmlklnnnmlmmnnmnpqqqpnoqrrponmmnkijlmmkjikllkjjijjkjijlljjjkkkkkkkjiijjklkkkjjhgeacdcc`^]\ZVTRPONLJHD@@<<<:98642/,))''%#!!#""'++*-..-.-+**+**)&!" &(&&&'%##$$#%'))(()'$"!A@ACFEDEFEEEDADCDDDEEEEFFFGGGFEFGFEDEBEEEEEEEFGHJFHFGGGFHIIJJHIIIIKJKIIIIIHJJIIIIJIGLJIIIHKKKKKJKLMLLLLLKILLJKKMMMNNONNHLKMMMMMPQPOMMNOPPOPQQOOPQOOMMLPQQONNOOOMNOPPNMMMPRRPQQQPQQQRQNQQQMONQOPMRSTPQSURRRSSTVVURRTTTRUTSRRSUTTUUQTUVWXUWVVUTTUTXWXWVUVVVVVVVSWXYYYWWVWTXZ[[ZUWZ\YWXYYYXZZYYZ[ZZ]^\[\[ZX^^^`_X^^_YZ[_aa_aa`^`_`_^^aaa_a_ccdcdcbdddeeecbbdceecbaaefhigbdfebhjhfhffekjlmmjmnnnnjklmnnlmmpponoppqrponokololoomhkjnmliihlmkijhjhkfjllkljkjkjjjjhhhjgjhljllkggghcedeac__[YWVSRRPNLHHBD>=<;8985/..,)''&$# #()(''(*+--,*++.-+(%$#"(&'$''&%"!#$%!&&''()'!! + A@BDEEEFEDCCCDDCDCEFFDDGFGGHGFEFDEEDDEEFGGFEDEHJIHGGFGGGGGIKJIJJFHJJKKJJIIHJKJJIIJJKLKHJJKKLKKKJLMKKLMKJKLMLJKLNNNKLMNNMMMMMMLMPPPONKLMOMNOPPOOPQQPPOLMNPQQRQOONNOOPNNOPPPPPNQQPPRTTQPQSRQOPQPRSSSSRSUUSPRSSSUTSQRUSUWVTTSRUVUTTUTTUUVWXXVUUVVVWWWWXWWWWWXXWTTVYZYXVWXWWX\\ZXVUZ[YXYZZZ[ZYYZZ[[\^^[[[\Z\^_\_^]_a_]]^`aa_a`aa`aa__acccbaacbcdccccdefffecbdeeedceffe`ihefggghiihhhhiklllljloopnmlklnmmnppopooqqrrpnnnonmmlmonklkkkjihikljjjklligilkjloljjihihgklkjijkkmomkjhjigedcbb_[][YVSSQNMLKIFDB?<:99600.-,*)'%$# !$() "$%'*++)*+,-+)(*+,+((('&"$$&%%%%#$%''''&$" +CADEEFFFDCDBDDDEEBEGHGGFFEFFFFFFGFEDEEGHHHGEEEGGHIIIHFHHGEHIHGIIHHIIJKJHJJIJJHIHKKJILKKKKJKHKLKIKLKIJLLKLLLMNNNOONLMMNNLMJNNNNNNPOPONLMONMOMOOPQQQQPOLLMPMOPQKOLNOPPPNPQPOOPQRRNOQVTQOQNQRQQQOSSSQRSTTUUSSTPPRQPRRSSVXXVTSUVUPTTTTTTTTUVVUTUWUWVUTVSWWVVXXXYWTX[[ZWVWWXXXZZXWWWYZXYZ[Z[[ZVWXZZ\]]^]\[XY[__^\^^__^]^^aaa_a_```aa`bbcddbc^cbc^bbcaccfeedccccdefcdfgggiighehhihiiiijjkllmlhlnnlllllmnnjlmnnmkqprnrnojonnjkkmmolkiihkgfeiiifjkmnkciiihlmkgjjjgfhnllijjljlmlhjgjjhddcd__\_^]XVTTPOKLHGFD??=;8710//,,*'$$#!#&*)% "% &#''%%''('()-,-()(('&%''&"$#!$&'%&#! DEFFEFFFCCDEEEEFEBCHIIGFCDEFGGFGHGDEFGHGFIHGGGFGHHHIIHGHGGGHHHHIIIIJJJGIJJHJJIIJKLKIJKKLLKJHKMLLKLKIJLMLMMMMOONNNNMNMNNMMMMNOOOOOOOOOPQOOOMMNPOPQQPOLLLPOLOOPPPOOOOOQRQQPOMQRSSSSTTTQOONLQRQQQRSQPPSTUVWVUTSSTTSSSTTUVWXTTUVVUUUUUUTTUWVUVVXWUVUUVVUVWUVWWXZYVY[[YWVWVWXXYYYXWWYZ[ZZZ[ZZZZZ\ZY\][^^][Z\____^^a`]]^^^^_``a`___`accccdddccdebabdcdcceecbfgedceedcfghijijihhghikkjlkjikkllnmllllmnnonnnlnmmnpqrrqpppqponlmnmmnmkjijllieiihhijmolkkmlmmkjjjjjjjlnomkkkkjkkkhijijhgghf```aa_\ZYWTQOLJIHFDB?><97541/-,(%%#" $(*)'%%&''%$#$ %)()+-*($$%''('((('&$"!&'&$" DEEDDGGFEDCDEEDEECFGGFECDEEHHGFEFFEFFHGEFGHGIHHIHHHIHHGEHHHGIIJJIGIFJJJJJHIJJIIGKKKIIJKKLKKIJJLLMLKJMMNMMMNNOONLMOONNMNMMMMMNLNNNNMKORROPNMJNPONQONNNNNONNOOOPPPPOOOPPQNQPOPQQRRRRRONLPNNNSQSRQNOPQRSRUTUUUUUUTRRSUUTRUVVTVUVSUVVUTTVWXVUVXXWUUVVWXVVUVWWVXXYWYZXVWWVVVUYYXYYWXXZWYYXWZZ\W\\[V]_^]]Y[]_`_^^^_aa]^]`^^]``a[`^^___ccbcccdbedc`ddffdccccbfeeeedddefghiijkjghfhikfjikijkkgnonllmllmnmnonnnnmpqqrpnmnoooklmlmliihjlmnnlkgljigkinnmimmmjlkjiihjjljoongkhiiijljjiiigfgegcb\bba^]\YUSONMKIHCD>A?=785400+)''$# ')*%""%*+)''%"&())+(' !##! ""$&'%%%&&&"! +CCBBDFFEDCCEEDBDDEFF@ECDEEEGGGEDDFEFFFFDFGGHHGIIHHIJJJIHFJJKJJJJIHIJJJKJIIIJJKJJKKJJJKLMKKLLLKLLJKKMNNOONMMNOPOLNOMMNNNMNONMNNLLLONMOQQOPOMKNPPPPPOPPONNOPQOOOPQPOOOOOONQRPPPOPQQRRRQPQRQRSSRSQOPRRRSUUUTTOUVUSRQRTTRSTUUVUUVTUVVUUVXYVUUUTWWUVVXWWWVUWXYYXXYYXYXUVWWVVXYZYZZYZ\[YZZYXYZZ[[\[\^`^[]]\^_`__`__a`^_bcb_]`bbba`aba`aaacdccedbbeedfgeeffdbedfhgdeeeefffgilkkhfhhiiijklljkmnoonnonlmmnoooonoqppqqompqqonikmkllkjiimnnnmklmljklomlljnpmhkkiihhjllllmllkijkkjkkjiihggffggebceb^]\ZUTSQNMLJFDCBB?=955520-+(&$"!!!%(($ #),,+*)((&'')*+*'# !!"$&%! + +EDDBDEEBBBDEFEDDEEFFFDDDFEEEGEFEFGGCFDFEIHGGHHIGIJKJJJJIJKKKJIIJIIIJJJKKJJKKKLLGKMKIKKLMJJLKLLLLLLMMLJNJNMLLNOOMMMLLMNONOOONONMLNONOOOOPPIJKNOOPPOOPPPOLOPQONNOPPPPOQPQORPQQROOPQRSSRORRSRRPOOPPQSSRUWVVVTSTUSSRRSTUTSUUTRRSUSUTURTVYYWUUUUVVUXWZTVVXWXXYZXSYYYYWVVUWVYZZVZ[YX[\[ZZYZWWXZZ[Y[\^^]\]]]]^]_`a_^_`]^_c`^]acc`bcbaa`b```dbdedbdeddgceefgfbedffgcffebfddeiklligggihifjkkjllooojnnnmmmnnnkpopnopqpnnrtroojlnnnmiklklnkllmmnfkklnniijopniihiijjkllkkgkkljmnliijkkjggfhdefgccda_^YYXUTSNOILHGAC<@=;67321/**$#"#"!#((!!%(,,+**))'())&)& #""! + +FFEEEFFEEEEEFGFGGFEFEDEFEFFGGFGGGGGGFFHIIIIHHIHGIJKJFIIIJIHIIHHIIHHJKKJLJJLNMMLKLMLLKKLLIJLLLMMMMNNMJLMMNNLLLNOMHKLLNOPOMNNOONKMOPMONNPRPMLMNNNOOOMPRSQPOPQONOQQQQQRRRRSRPQRSSRQQRPRSQRTSRQSQONRRRUWVVUUTSSTTSSRUTUUTSUUTTTUUUUVUUVXXXXVWVUVVWYZYUWXYYZZYZXXXYZZXXWXXWY[ZZZZYYYYXXXXZ[[[[[ZYY[^^^^^]^``__ba^^^aaaba``_bcb_bdcbcccca^bbddcbefghgecdehhffebbdfffgihgfghilmihhhiiijiijkmnoonommoomlnnnopqoononnnprsqqpompoolhlommnnmlmoliklklmmmnoomljiiiklllkkkkjjkjookjijllllkkjiggffffd``^^]ZWUTQPNMIBBAA@=<9632/+++(&$#" !%('"#'++**++)''('('$!!" ""!! +GFGFGGGFFEFDDEHIHGFEDDFFEEFGGFHEEFFFGGIIHGIIHHHGJJJJIHFFIIIJJHIHGGIJJKKKJILMMJKKMLLLKKLLIKLLLJLLMNNMMLMMNLMLMNOMLLMMOOPONNOOPONLNNNMMNPPQOOONLNNNOPQRPQQQOPPPORTRMRQQNRTSQRRSSSTTTPQSRSTSSUUTQRUUSSTVRRSSSTRTQTTVUUTSRVUVVWVUSWXXXXVXYWVWWVTWWWXYUWWZY[[\ZYXXYZZZVYZZVVXYXXY[Z[VVVYZZ[\[[\\ZZZ^[^__Z^__]]]`^^^`_`````_bcc`abbcdcb`_\bbdccbfggggeedfhhfffcabcfgijjiiihgjkjjkkjgikkkkkmnnlmnnlnpommllmqoqjolllopqoqqponnokmimnminnnklllgkhjkjjmilmmmljjilmmmlilmllljnljjkkmmnmmlljigghihfabb`][WWVTPONKCBADC@=;7521,+++(%!#" !$&%!$'+)(''(('''''("" $'&$""%# EGDFGGEEFFEEFHHHGGGFEDFGEEGGHGHIIHGGGGGHDGIIHIIJJIIJKJFIJJIIJKKJIIJJJJJJIJJLLKLMMMIKJKLLIJJLLKLMLMMMLLMNMKLLMPONNPPPOMPPOOPQPOOONMNMNPQQQONOONOONNOQQPNPQOPQQOSTQOPPQQRSTSRQSSRSTUPQSRPRTTVVTTTVWUSRTUVVRTUVUUTTVUUTSTUUUWWVUTWWVYXWWWUVVVVXXXXWWWWYYZX[[ZYWWZZZZZZZZYYYYZ[]\\\\ZY[\YZ[[[]^___^^_`_[\^_^[^__^`_^``aa``adddbabccb`^`abddeccefeeggfdfggfghfeefgghiiiiihgihiklnljjlnmlmlllloomlpqqponnoqsqpolmnoopqrsponlmmnpnmlklmlmnmmmjfijijkhilmnmlkjlnnnmjlmmnnmmllmnnnnnonmmmlkjjjjhbcca^\ZZYVSQQNKHGFDB>;875310,+)&%$""#"" #&'))'%#!#$%%%'''%%$%')*(&%%%%&'%" + EEFEFGFEFCDEFDFGFEGGFEFFFFGHHDHHJHHGGGHGFGHHHJKKIHIJKKJJKHHHJLLLKKLJKKKKKJJJKHMNMKJKLKLLLKKLMMMKLLMMMMMNMJLNOOONNOOOOMPPONPQQOONNNNNOPQPQLKKOPPOOMOPQPOQQOPQRPRSRMPOOORSSRRNSRRNSQRQSSQQSSURTOTUWWTRUUVWUTUWVOUTTUVQSRURVWXTVUVSWXXVWWVWWTVXZYXUWVWXYXXZ[VXVWZZZ[YZX[[\ZZ\\[][]\^^^^]\\\\]^^`]_`aa`\]^`a``aY]_`_`ac_]]a`ccb`ddcba^aacddcc]defcgffeeaedfhhhghgfefgfhffgihhfkklmlknommnmlknikkpqqppoonppoonmmhnmqrrqpomjllopolkjlijkolnnkhiklmmjjhlikglkkjmnmjmkmlpmnjkinnnnnkplnnmikkjjjedcb]]\[ZYTRPQMLHGDC=;:98653-+))&'! ##""#!!%'((& "!!$#$$&&&#())((%''(()% + ADEFFFFFEDDEFEFGFGHIIFEFGGGGGFGHIIEFFGGFEGGIHIJKIFFIKKILKGIJKLLKILMMLLKKKJKLKKNOLJGLMLKMMLLLMMJKLLMLMMKMMMNPPOONMNNOOOOPOOPPPOPPNNOPPPQQPOOOPPPOPOMPQQOQQOQQRRRRQRPOOQSSSSTTSRRSRSSSTTRRRSSRSQRSVWVUVVWWVSRVVUUUVWVTUUUUVXWVVUWWWXWUWVVYXUUXYYXWWVWWUWVYZZXUWYYYYXYZ\\[[Z[\]\[\]^^_^]\]\[[[]^\_````]]_aaaba^^a`_`ccc`_``abaacc_bb_a`adedddeffhgehgddeefhijjiffdgjkkkjhihijjijmlmopnnnmllllkloqpopqonopoopqolmoorqonnkhkmlmnnlklllonnnomlllmnnmkkklllmllimomilloqponnkjlmnpoopqpnlijjjllkheccba^\[ZVQQPNKHEDDA><;9642/-+*(%! !##%&&%$##$!%''#"! #%&'()(('&'(((&" +CDEGGDDCFFGGGFFFFFHIHGFFGDDEFDGDIGDEGIIHHHIJIGIIHCFHJKKMLIKIKLLJJLLKLLKHLJLMLLMNLJKMNMMLLMMLLKJKMMLJLLLLMMOPPOOJLMOPPNNONOPPONOPNMOOOLPQPOQPOONLNOQRQPPPRPRQRSSPQRQNQSTTRRUTRQSSSRRQSUTQRRSRRQQPUWVUVUVUUTTTTUVVXYXTVUVVVUXSVUVSVVVUUUWXYVUVXWWXXVXWWVVVYYXUWYZWWXZZ\\ZZZZ]]\YZZ\^^Y\]]\\[[]]]`__^`^^__^_]a``ba\`bcba\`aabbab_bcbaa`beecfgfdghhfghfcfeiiijkjjjijlkljjijgjjjjkennomnkmmllnoojoppmppompponqsqmoonnnmmhkhhihhnmmilmmimjmimlmknlnlllmjkllmkimonjllppmkonmknnnoqnqspllhhhkmmjjffeda`__ZZTQPPLKGGDD>==:6511--)('$! #$$" !!!!""#%&#""#" !#$%(''$&$''&$# +EFEFFEDEFGGHHHEFEEEFGHGGFDFHGGHIGFCFHKKKHGJLJGGGHHHIJKMNMMKIKLKIKLLJJLLLLLMMMKKLMMNNNNLJJNNLKJKKKMLLLLLLLMMNOONMLMOQPNMMLNOOLNONOPPONMPPPPPPKNMJEOQQQOQSROQRRTTSPQPPQRSSQQSSQPQSQPPQSVTRRRQTTSQRUVUTUVVTUWVTUUUVXZYXWWVVVXXYWUUTVXYXWUWXYVWWXXXYZYWXXVVXYXWVXYZZZ[[[]]YXY[\\][[Z[\\\\]]]\[[]\_aa__`baa_]^```aca_`aaba`acdb`bdedcbdebdedcggdbehhghiighhiigjhikkiklmkijkkllklklmmonklkmnnpppqqpqolnpqqpponpsqonnnnmmnnmkjkjhnpnmmmlkkllmkklmmnmklmlllkklljmnnnnopnjmoppppnnppopsqlnnnlkmmlihgffea```]ZUSRROIGDEC@?<86421/*)'&#!! $%" ""!!##"!"!"! !!"#$&'&#%&'%$" +EEEEECFFFFGHHGGFFCFEFGIJHEGHHIJHHFGHJKKKIEKMKHJKJJIJKHLLLLKHJKIIKKKHKLMKLLMNNKKKLNNMLLKILMMMKKLHJKMNMKMMLMMLOMMMNNNNNLOOONPPOOOLPRQMNNPPPPOOOONLMOOMPOQQQOQRSTSSSRQPRQQQPQPPPOQRQPQQRUTQSPTUVUTSUUUSUUWSVXWUUSUUVWYWWWVWWWXYWUVTXXZZXUYZZVXYXVVRZ[YVZWXYYWWWXZ[YZ\[[]][ZZZZ\]ZZZ[Y\[]\\Y\\]^^_`^^]babba]__`\`^a`____b`b_caacfgddeegccddchgdccdfefiiiihiiijihjikkjkkhjjklnmmklimmlkmkmloppponnonmnorooppppjqpnkmlmmnpomljijoomllknmkkmmlilmmnnkkklkkejkklllooooqmmmnnnmmnnnohpoqlnopmlhnnjigdggd`aa_\YVUTSJGEGCC??987611++(($##!"$% ! "###$$$%%#%%'$! + BDFFEFFGGEEHHHGFFGGFFFIJIGEGGJJHHGGIJKLLJJLNLJJKJJJJKLKIJLJIKKKMLKJKLNMKKLLLLJJKIMMMMLLKLLLMLLLKJKNONKLMNNNOOOMMNOOMNOPPPQPPOPPQRSQPOOOPNPPQQPNNOOPQPPOOQRPQRTSRSSRPRSRRQPPRSRQRSRRQQTSSUUUUUVUUVUVWWXWVWWWUUSUWWYXWWVVWVVWWVVWYXXY[YXZ\ZXXZYYVVWYZ[[YYYZXXXXZZYYZZ[\][ZZZZZ[Z[\ZZ]^^]\\\]^^]_`^_aaaaaaa``bca`bcb`aaabaabbbcffddefgfccfggecdeeffiihhihhiijkjiiklkjjhiklnnmkjjllmmnnmmmnomonmnnnmnpqpqqppnnpqpnnnmmnoomlmljmnmlllmonlnnlllljnnmklllkkklmooppnnopmnlmnnnoponnpopqqompronoolkfhhgebbb`^\XWVSQNLIHDA@><9851/,()(&$! $&%#"%%#$%$#$&&&%# CCFGFEGGGCDFHIIDFGGFFFFFIHGHIGIIIGHIIHKJJIKMMKJJJHHHKMKIKKKKJJJLMKLMMLLIKLLJJHJJKLMNNMMKLJKLMMLMMLNONJKNOMNNNNNNNNONNNOOQMMMPNPQSRPONLOPPNPPRQONNOPPQQQPRSRQQRSRROQQPPRSRPRSTTTSSSSSTTUUVVTRUUVUUUVVXVVUWWWTTSVWWXYUXWWVUTWWVTYYWVXZYWZ[YVYXZZYTXY[[[XZ[[YYVWYXWXXYW\[[WZ[ZYYY\^\Y^``]]]^Z[[]`a^`[b]`_``aabbbbbcbabaaacbdbb_bcdeeefedbfgfbccfgghjegfighihjjigglmkhighioonlkikhjjnnmkkjoomnomnlkloprssqpmmlprppollkopmikiljlkmijjllmmommlljloogkimmmmmholpqpmnmnonlmjpppmpnoloprrrnqrqnppmlllkahdda_^_ZZTTSQLLGF>A?>9953//)((' ! "$$!! !##$%%#"EFGHHHIGFDDFGHIIFEEFFGHIHGHHHGIJIHIIHIIHGIKLLLKJJIJIHMLKLLKKHIJLLMMMMMLJKMLLMKIJKKLMLMNNLKJJMNMNNMOONMNPONNOOMKONNNNNPQQQOOOPNNQSSQNMNOQPOPQQQPNMPQRRRRRSSSSRRRRRSSRPPRSSRSSSSTUVUSSSRTVVUTTUUTTRTTUVXVUUVUUTTSWXWXXWXVUUVWYWWXXWXXYYXXYY[ZZZZZYZ[[[Z[[[[[YXY[YXXWY[\ZZZ[[[ZY[]__]^`_^]___^\]`a`_`aaabbbbb_`bb``babbbcdfdcccaacgggeddcdeecehhhhhihhihfhiijjfehkkjhkllnnomlkkklnnmmkklnopnpolnooooprtsqoppoopponmmknolkjjlonklmnnllnnnnnmlikmnnmnmlmmlmoppqppolnonmopooooonnmorssrrqrqnoojmonlkhfeedca_\YVSRNLJHEC@><:8541/,('&%$" ! "## +FGGEGIIHFGGHGGIIFEECGHIIHFGFFGGHJIIFFGHHIIJKKILKJGJKKLLJKKKJJJKKLMMLLLLILMLNNMKIKKKJLMNNNMLJMMOOMMOOOOOOOKOONNOPPPOMOQQRQOOOPPPQRSRNPPPOONPQQQQOPRQQQORPQRSSQNRPRSSSRQSRTSRPONSTVUTRPPQRVTTTVTTQSUUTVWWSVVVTUUUVVVVVVTUTVWXWVUXWWWWYZYYZZ[[WYZYYZ[[XZZ[Y][Z[[YXXYX[\]\[X[Y\WZZ^``__\\[]^a]]\]]a````abbcbcbaaa[````a^ccddc`cdcacfggfabdedfdefihhhihjjhfghiijfhkjgiikmnjmmmiljllonmmlmoooopqpmopoppoqrsnoorpmkolnnolklnnnlmoommmpnmlnnmloomhjglhmnmjmilloppoopnknkmlonllnnnnpopqsrpmqmplmonmpmljjgedfdc_][XUTONMKHGBA>=7764/.)'''$" "" +FFEDEHHHHIIIIHHHFEFGHJJJGHGGHHHIIJIHHGGIJIJJIIKLKJKLKLKJJKIJJJJKILMMKLLLLMLMNNNMJKKKLMMONNNNLMNOLLOPNNMNPQPNKNPPPQPOPQQQQPNNPQQPQRRRRQOQQPPPNPQQQTSPPQQRRTTSQQSRRRSSRSSRTURPONQSSTUURPTUVVUVWUTTUVVUTWWUVXWWXYWWVUTUVUWXXXWXXXXWVUUWYYY[[[ZZYYXZ[\YXYZ\^\[\]ZWY[[]]\]_]][Z\^\\_baa_]][^aa`]]^`aba`a__abaacabaabbddbbccbbbccddeeeggeceggdfhfdgjighhiiggeiihjkklliiiknmllmlilmlmmmmllnpommopqqoooppprqqqonpqonoonnoomknppqoooomoonnnnnlkmomlklkjkmmmmnmmnoooonkloonmonmmopooppqrsropqqpopqppoomkklhcffd`]]YYXWTPNMIEDB?<;:730+))(&$" !" FEEDFEHEGIIIHGHFFFFFHIJJJJIGHGGHIJKJIHHIIHIDHGJLLIKLLLKJKLKHKKKLLLMMMKMMMMKKMOOOMKKJLMMMMJNNMNONLLNLKKNNPPPOMLMNOPPPQPPQRRQNRRPMQQPPQRRRRQPOPPRRRSSPPRSRSRTRRRSSRPSSSRSRTUTRROPQRRUTSPUTVWVVWQUTVVVUUUWVVVWWXWXVWUUUVVXYXWWYYZYUVVVVYUY[[X[[YVZ\\YXWZY\]\YZ[ZX[\]\][]Z^]\Y\]]^__aa`\[[_a``__``aba``__abacddcbadbfedbbdd`bcccebgfgdccgihdgbecfhihigghhhikjilkmnljjhimmmkglijlmmnmoomjokmnolppolnnpppoqppnnoqopnnmpnnknmnnolmikjnhmnommkkklmmlmimkmjlmnnnmmkpqplppnmnnmlopnoolqqrppqsrrlrsqnnnmkjjjdhhfca`]ZZXWQPMKFDB@>=<842-+)*%&"! FEEFFGGFDIJHFFGGEEGGGGFJJKJIGFFHGJLKIIIIGIIIIHJLKJLMJKKKKKKLKKKLLLLMNNMNMLKKKNONMLLLLLMMLMMMNNNNLONKKNNOPPOOOMNOOOQRPNPQRRQQQQOOOPOOQRRRPPPOPQPRRSSQMRTTTTSQRSSRQPRTSSRRSTTTSRRRSTTUTTTTSVVUVVVVUUTUUUVYXWWWXVWYWVVWVYYYUWWYZ[YSVWWVXYY[\[ZYYZZ\\YWXYZ\\\[ZZZ[\\\\[Z[[[]\YZ[]__^````_^_a`a```````_```aa`ceedccdfedb``ddcaadffgghgfefghhhfeeddfghiihhijlmkkkjjllkkjilnmjhijjmmnnopomnnlloooonnonmpoqrqqppooqromnqqomnnnnmnnlkkmlmlmonoonmllnnopoonjlmnomlknqsrqppnlmmlloonnnnqsrqqqstrqqsrnpoqomlkkjkieec_ZZZXTROMKHCA>?=:542.-+)&%#" !!! + + + + + + FEFFFFGHHHHFEDIJGEIIHGFIJLKIIIKJIGJKIFIJJJIGJJJKLLMMLMMLLHLLJILKLJKLNNMMMJKKLMLJMLMNMKLKMNMKNNNOOPNKMPOLQQOPPOOPOMPQPNOQQOQQPOPPPMPNPOQQONPNQQQOQSTRRRSSTSSPSTSRRQRSRRQPSRQRTTTTTTURVTUUTSVSVXXWTTWXWSVUXVWXXTVWXUVVXZZYYXYZ[[YSXWVVYYY[\[YVWWY[[ZZYZ[\]\[ZYYYZ[\W[Z\YYZ\[ZZ]]_^`aa____Z`a`\_^`^`]_``]a^`bcbccefecc_bdfdb`eefffffffegfgggeggfdfggfgegjmlkgkgghkjjklmmmkejkkjmkmnnmmknmppomolononrprssoqppqsrolorqlninlmnonmjmllkkjnoppponknmplnookmmmflloppoqpqpnhmjklnnoookqqrqqrstsqrrsprqspolmilkifg`a[\]ZUUQOLKDC>??<651//.*'&%"! !!! + + + + + + + + FFFFFFFIIHFDDFJLJIIIHGFHHLLJHJKKJGIKIHJKKKIHIIIJKMLMLLNOMLLLHJLKMMJIJLMMMLKLLKJKLMOPMKKLMONLMOOOPPNKNQPLPPOPPPPOOOOOQQOQQRQPOOSSQPPMORQPOOPQQQPNPTSQRROSSSSRSTRQSSRRQPQSSQORTVVUTTUUUUUVUVVSVXXXTUXYWTUUWWXYXWVWXXVVXZZYXYY\\\[YXWXVZ[[[\]ZYYXWZ[ZZZZ\\\\[ZZ[[[]]\[\]]\]^_]]]]^_acb___^\^``a```^``___`abbabbbdffdcdceggecbcdceeffeffggfhgfhiggggfffedhklkllkjkjjklllkljjlnmmmmmmllmnnpqqpoqqpoprsrrrropqrtsrpmoqqmmjmkmponmmmlmlmknpppoopononlloonnmmkmppomnooopoonnnmnoppqqppqqprrrsqrtsrsttspmmmliihggd`^^\ZVRPNLIDABB>6653/.-*&%#"! + + + + + + + GHHEFFGIIHGGGGIJJIHEGHHIKLLIHGJLKHIKJIJJJKJIIGIIIKLLKKKKLLLLKJLKNONLLMNMOMLMMMLMLNNNMKJKNNNJMMNLPNMKNPOLOPOPQQPPPOOORRPPRQOMOOQRQNPNNOQPONQRRQQOQRQPRRSTSQQQROQPRSRQTTTTSQQRSVVQTTTTVTVUVVUTUVUTUUWVUTUTVWWWWWXUWWVVWWXWXXYX[[\[XWWWZ[ZW[\[[ZXZ[\\ZW[[[Z[\\\\\]]][\X^^^^_^^V]]_`bca____]^_abbaa_a``_`abccaaaa`edcddafhfcddcdfgfcfdddggfhgehjjhjjhfeghgkjmmllllkillmljhijnonloonlkkllmlqrqrsrqprssooonnrsspropnolpjmkninmommlmnolnlopoonjoonhmjnnnmoqpmooohmnomoppoompmnmpnooqqropnqqrqsttnrqrrqmoonkjhhhgc`Z_\XRPNLJHDECA7656/-,,'&#"! + + + + + + + + GGGFDFGHHHHGHHHHHHHHHIIIJKHJHHJKKJIJJIGHGHJKJJJJHIKLLLIJJKGMLJMOOPONMNNNONMNNNONNNKKLKKMNNMLMOOOPNMMNNNNNPOPRQQRQPQPRRRQQRQONONPPQQPOOPQPRRTTRRSSQPQRRSTSSSRRQPPQQPSUTTUTRRQQVVTTTRSVXWWVUTUVWVUVXXVUTUUUVVUTVWVVVVVXYWVXYYZZZ[ZXYZZZZXVY\[[ZZ[\\\Z\\[[Z\\\]]]\\\[\\]]^__]]]]]]`a``_^_`aa_bbccbaabbb`abccabbabcdcddefgdddffgggfcfgfegfehgfhjklkjjhghklklmnlljlkklmnmjilnmnnpppmmlmmlmlossrrqqqqrsspoonsvtrqqqqopnmnonmmoonmlmmnonopponmjnonnnnmmopqsrooooooppopqonopppnnppqrsttsqrqqqrssstssqrqrrspmmkjihebba^ZYVSPNLKIFC@<:772.-+('%$#! + + + + + + FEGGGGGFGFFGGGGGHFHIIGIJJHIJKLKKKKIJJIJIHGIJKJKJIILMMLLKKKMMLJNNONNNMINNONOONNOOOMMMNNMMNNNMNLNOQPONNNNMPPPQQOPRQPONQRSRQOQPOPPPQQPOPNPQRSSTSQSUTOPQRSSSSSSQRRSQQMQSSQRTSRRRTUVUUTSSWXWVURTUVWWUWYYYWVXXWVWVUUXUVRUVYYXVWTYXZZ[ZYZ[ZZZXWXZ[ZZX\[ZZZ[[Z[\\[[\]^]VZ[]\\Z^__]^]^^``a[^^]\`bb^acbab_b^dddbbbc`cccbdcdbecdedbdfgffefdghhehffghhiejijijjihkjjknnmmmlmhijmnljklkkooqpooonnmmmqssoopqonnrrpmpnsutqrosqpinpqnokmnonmkklllllpqolkknopmonmmopqrpmpppoompopqolqqqlnorsrstttrqrrnrqsssrusrrrrtoqlllmkidcbc[]]ZTTSPKLGEAB;:760/**%&#$! + + +GHHGHIHHGFGGEEGIGEHIIIILKIIJKLLKKKJJIKLKFGHJIIJKKLLMMNMKJJLMLMMLLMMLLLNNNPPNOOMNMMNOPPOLLMMNNNNOQRQPPPPPPQQQONOQPNNNOQRRQQNNNPQPOPONOOQSSRRRRSSTROPPQRSSSSRQRTSSRQRSPPMRSQRSSTUTTUUVWWVVTSTVVXXWWYYZYZYXXXXXWXYYWUVXYZYXWXXYYYY[ZZ[[ZYXWYYZ[[[[Z[ZZZ\^]]]]\]]^[[ZZZ\\]]^___^_ba`a_^____aba^ba_adcdcddcbbcccccdcbdeeedddbcfffgffffghihggfhiiijkjjjjijjjkmnmklnmnnmmkomkmmmlmoqqqqpoopprrrqpknprppqqpoprrsqpqrqpnmnppmopnnnmmnnnnnlmqrnmnoopoonmnooooppqqqpnnopompoorsqppsturqsutrqqqsrqrrsvusostssrpnopomkihifca`\XWWQPOLHFDA<67631,(&%#" +FHHFGFHHHFIIGFGIHFHJJIIKKHIHJIJHKLKKKKLKJIJKKJKKLMMIMNMKJKMHMNMMNNNNMLNNOPOOPPNOOMNNPQPNMLKKOPPOPPQQPPPPPQQPOMPQNLPQPOPPQQPONPPQQQQOQPRTSPPQRSSNROPPQRSSRRQQSTTSSQRSSRRQRQROSTUUTSVWVWWVUTUTVXYUWWWUYXXSXXXUWVYXXVWXXWYXWVXYXWWWYZZXYXYWZYZ[[YZY\[ZY\]^\\\]]^Z\[\XVV_^][_a`Z`cb`_^__``^^aaabaaa]c``bdcc`cdcacddbeefccccbbaefhgfddeghhgfeijkikkjgihjklllmnjjfmkokomnnmkklmmlnqkqqonojpqrqqpnmqrqpqlplqrqppmololmnnmokoqpmojnnoonnmmqonnppomoonjommlnpqqqooonnqnpqqqrrqppqtprnrtsqrmrprqrnsvuttsssrqqnqrpnljjjieca^WXYUQQJGFE@?66661/(($& + +EGHHHHHHIJIHHHHIIGJKJIFIJHHIJIJJKLLKJJJKKKIJLLKJLNMLLMLLKMMLNPNOONNNNNNOPPPOPPPOPOOMOPPPNMKMPRNMNPQPOPONNQPPQRRQLNQTSQOQQRRPMPPPQRRRSTTTQPQSRRRSSRQQSSSTQQQPSTTTSSUUUUTTTRSTSTWWUTUVVVWWXXWWWWXXWVVWWXWXXVWWXYYYYWWXXXXXVWYZXXXVVXXYYYYZ[\\ZZYYY\^Y[]_]\\]\]^]^__^^___]]_a`^`ccba_``a`]^__acccbaabbccdcbccdcceffeffgfffeeddfhhfdddfhhgggkmmkjjjjihikllllllklmnmmnponmkklmmmnppqplmnonpqqrsqqrrqpoonopqonopoonoppqpnkoqqpoponpppoolnnnpqqnnmnnnopooprqqpqqoooppqrrttrrqopqsroqststuttsssrrtuuuvutpqrtrqolmjlmjfgea_]ZWRRPLGFA@><;7420,+(%"#! GGHIJJHHJJHHHFIJIHJIJIIIJGIIJIIHKLKIKKKKLKJLLKJJLLKKLKLLKMNKMOONMMMMMMMNPPOMNPQNOONLNLOONMLMQRPOOOONOQQQQONPRQQPPOQRRRRRRRRQPOPPPLQRRSSRQQRQTSSRUSQRTTTURRRQTTTSSTTSUTUUUSTTTSWWVRSTUTVWYYVWWWWXWTUWWXXWWUWWXYZZZXYYYXXXXZZ[ZYYVWXZ[ZXZV[[ZYYZZX\^^]^\]]^YY[__``_^`a`]^_`[^^_acba`___^___`bccbbabbcccddcccddcbfffaffggfdgdffghgaedghgegikmljjijljhhijhkjkhkkllminpoookmmmnnmpppnnjolmkpnrsrqqopmmkoopmponlnjnpqqsonknqrkomonpopoplllopppppomonqpporrqnpnsoqoqnnortsrrlonqprprstrtrutsssqqrssuwwwustutookolonmgigd_a][TUOPIICA@?<90420*+$$!! + +HIHHIKJHIHFGHHIJHJJJJKKKJIIJKJHHJKKJKLIJKKKLLKHKMMKLLKKKKNNLIMLMLMNNMJINMOOMNOPPNMLLMNMNPPNOQROPPOKNPQOTRNKRRQOOOOOQQRSSRRLQQPPPOPQQPRRQQRSSTTRRSSQQRRTUSSTUUURQSTTTSTUUTTUVWWVWWVUTVVTUXWUUVVVVVUWXXYXXWXXXWXZZY[[[ZZZYY[[[ZZXXY[[ZYZZZZ[ZX\]YZ\]]^]]\\_^^__^_`_]]`_^]^^^^`accb``______acccbacbbcbaaccdddeddeefgggihgffggggggghgeffgffhjkhihiijhhjiiijjjkkmmmmmnomoppnmnoppqqpopqplmopqrsqqqponmopqppqpnnmkmpqsrqomkoqpnlnpqqpppmmopqqpoqqqqpporsrrrrqnqsrsrrqqqsssrqoqqqrqrsttssssqrsrtuuttuwxxwvvtsqrrmqrpnlheda_\YWVRNMKGA@;97531/,)&$"! +HGHHJKJGFEFGIJKLLKKKKKLJKJJJKJIHIIJJKLKJIIKMLJJKLMMMLJKLMNNMMMNNMLNNNKJMOONMOPPONLLKNOPQQQPNPRPOPOMNOOQSROPRRRQNOMOPQRSPSTSQPOPNOQRQPRRQPPSPRRQORRRQPOSTSSTVTTRPTRSPSQTSVVUUWWVUWVUSVVTTVUTUWWXUUTTUVRYZYZZXWXXUXYZZZVZWYZZ\[VVV[\[VY[]Y\[ZW]][[\Z\Z^^]\ab`]]Z^^_ZY[`^^Y`a`\`aa``]]\]__`cccbbacbcccabcdcdeedddccfghiheeehgjhggghheefhhhhijidgeidghijkijjlmmnoknnmkmopoooonqqqqqqqqpnoprqrsrqrmppqsroppppponjmoqoplpnmmoonmoossqpojnonnqinlqrsqopqqqoqoqnpmsttstutssstrqsrorqttsntsssqnrstutssqstxuwvtrsqtnqqqnnihfc[ZYYXTQOMJBB<;88420.+)$$#! + + GGGIJJJJIGGHJKKLLJJKJJKKKKKJJKJJIIJKKLLKKKLMKIKKJNNMLKMMNNNMNONOJKMNONKMOOMNPQOOOOOOPQRRQPONPQQPNOKNMNOQPPPRRRQNOPNPPSRPRTTTRQQONRTRQRSSRRRRRRPNQQRQPSSTQSUURQRTRRRSSRUUVVUUVWUUWVUUUUVWVUUVVXXWUVVVUUXZXYZYZ[YXXYYYYXZZZYY\\\]^]\ZZZ\^^\[ZX]^]\\\]^^^^]aca^]\]^``_^`baabb`__^_`aa`^\`bdcbbdddcddddccceffffdeebceeggggffgjjigggfgefgghjigjjjhhjkkklmljijlllmnponllnppponnopqpqpqpomqrrqqstsssrqqstsomoqrqqponoonprponmlmorpqssrqpnnppoqppqrtsrqooopqpmqqpqrttsuwurrturrtsstuussrstutrqrsuwvtsstwwvuututtutqqrqnkjigfc`_]YSROLHDA>=;94//-+)'%$" GGHIHGJIIGGHJJIIIIKKIHIJJKKHJKLKJHJKLLLLKJMNMKLJJMNMLLMLNMMLNOPPMHMNNNNNPPPOPQPOOOOPPORQPNNOOOQRQPOPPMNOPPPQRQQNPQQRRSQNPOSSRPQPQSSRQQROSSSQQQQNQORRSTTSSSUTSRTTRRTSSSVVWUTSVSUUVRVVUSVXXWVUVXYXWXXVUVYYYXYXZ\\[ZZZXWWZ[[[[\][^^][[Y\\]]\YYX\]]\]^_]]\^___a`^[^^```]``b^a`_]^]_`abbabbcdcbceeccdeedcd_dfggfcefffeegdifgefhhhhihdhghcgijhhikljhijmlmnmkjjkiiimmmllmnookmjklooonmnnlorsponstrosrppporpporrpkqrqoomopolollkorqnrrrpqqoqrqsostsprsqpooqrqmsproqsspsutpsttssstuuvuqssstvuttutuvwstvwvwstsuutuuurlsspklkkjgaaZZTSRPGEDB?=:701.,()%&! FIIIHIIIHHHIJJFHJJLLJHGJIJJJKLLMKIJLILMLLLOOONNMKNMLLLMLMMKMNNOPNMNPNNOQRRPOOPPONMNOPPQPOOOPPNQRRQQPPOOPPPPPQRQQQRRSSRPOPRPQQQQRQRRQPOQRRSSRQQQRRSSSTTTTSSUVUVUTTSUVUUUUVWUSUUUVVTUVVUVWXWSUXZ[YXYXVWZYXXYYYY[\\ZZZYXVY[Z\\[[ZYZ\]]\\\\\[Z[[[\]][_^\]__^]^`aa`_`____`ba`_`__^_aabbcbddddccdfdbcddedcddcdefedfghhhghjjigcbfgghhhhikifgkkhjjhlkjijkljlmlmlkjihkmmmllmlmmllmnmmnopqqpprrpnnrtqqrqqqppqtttrpmnqsrpqqqpomnpoooppqrqppqqpqsurqstqprsqqrsqqqsturopqspqsssssrrsrstuuurtussuvvvvuuxwutvvuvtsrusqtuttutssqolljgec`\YWVRNKIFC@;8531-+*(&! +JJIHGIIIIIHGIIIGJLLKJIJKIIIILMMLKJLLKKKLLMOPMLMMNNNLMNNKLLMNONOONMPQPNOPQONLOOOKMKMOOOQOOOPPPMSTSQQPPOQRPNOPPPSSRQQRRQPOQQQQRRQRQNPQPNQSSPRTSPSTTRSSTRTSSTTUUUTTTSUVUTTPVVUTTTTUUTUVVSVWXXWUWZZYXVWXZ\ZWWTYY[\[WVWYVXWYYY[]Z[ZYY\]]]]\]Z[[]^^\_^_^^\^^_]]\_aa^^```aaba`_``____bba^bbddebbcefdaeecacbcdcaeed`fhhgidhijigcdfgegggfheieijkijjjlkkjijdiklkmkkkliljmlllnmmmmknmljnkppppqqqnnkqssrrqsrqoqsttqpnnqrsqsqrqonprrrqpprroplpprrttrmsrpoqqpnssrmoqtqrnojsprrsnrqoopqqrsstsvwvsvqtwwuuvwqurutvtututrrvxyvtsttqonlifeda[YWTOOLJDB=<652/.-''#"" + JJFIGIJJJJEGHJIHIKKKLMMKIHIKMNMLJKMMJIKLMMNNKKKMOPOOOOOMLLMNNOOONNOSRPOONMLMPOONNMMPOOOOOOPPPQRTSRQRQQRQONNQQQRSPRRRPPQRQQOQSSQRQOPRQOPTTPQUSSSTSRRSTTSRRUTTQSSSUSUVVUSSVXWWWWUUUTUWWUVVXZXTUXYXWWXZZ[ZXWXZ\\\YWWYYYYYYYYZ]]ZYYZ]]]^]\\[]]^``____^^_^]]^_^_`_]]_bcba```ba```__abbbbbccdddddfdaddcdccdccefecdfgefhgghghhggghghighiijljijihijlmkjiihhlmkjkkmopoonlmopolooppmlloponoqqonmnpqqqrrstsrrqqpqpoonpqrsqqqppqrssrqqqqrrqqqsstusrrrqpopqpoqsqnopqoqmoqqpsurmpqqqqrsrtsuuvxwwurruvttuwvuvuvuvvwvuvsvyyyxuutttqmkkjfd`]ZVUROLFEC?<:420.+)$$$! IIKJIGIGJJIJKJJIIJJJLLLJHILNMKMMLKLLKJLMNMLKLLLOPPOOOOONMMMNNLOONNPRQOMLKKLMPPOMOOOPPOOPQNPPPPRQQPQQQRSPPPQRQNQSTSRQPPSSRRPPSSSSRNQRRPQUUQQSRRRSTQSSUSTRTUSQSTTSSTWXWVTTUVUUXWWRVTVWWUVXXWYSTVZWXXYZZWYWWY[\[WYX[[[Z[WXW[[]ZYXYZ\\\^][[\]^^^_^^^`[^``]^_`__^`^^_a^`_`bbba`aa`^__cacbbcdeecefeccceeeaecdeggecefffhggfiiihiiheijijjglklfiihikkkjjgggignmknonprqppnopppppoqqmmnrrpnnnmlmmnoqpqorrspqqpoppqmomnprkpqpostsprmomqpqnrrrssssrroqnqnoopoqosopqpqrnspppvutmoqtrrpqrqprrqqvtttuuvtstywwuuvuvxwwvvuwuvxwvutuusmnjlfdba[YVUMOHIB?>>75/-,+%$$# HIKKJJJJJJJLLKJIHJKKLKKKLMNOMKMMLKLKJKLNJMJLMMLPPNKPPONNNNNNNMMNNNOPONLMNONNQRPOPPOOPQPPQRQPPQRQPOPOOTSPQRRSQPPSSTRPPQSRORORTTOTRQRSQPQUVRQQQRRSTTSTUWUUVUQSUVUSSUWXXWTSTTVXXWVVWXWVVWYXYYYXXZZZYYYYXXWVWYXXXVY[ZZ[\\[ZX[]]ZZZZ[[[\^^]\\]]__]\\__^_`aa_``a``aa`_`a_^ababaabbbccdcacdacdedbffee`efffgfeddfhgeeffghhghjkkkkkhhhiikkkjkjfijkkkkjjjlllkkmmmpomnopqpoprqqpppqrqqrsrpmlnnlnpqrqqspqrqqponnpqqqoloqqooqqqstrprqoopqqppqqqqqrtsrroqrrqopqssssqqssuuutuvxursvvtsrrrrqtvstusuvvuuvutxzxxyyyyxxwvxywuvvvuuuvuttqpnkhgd`^]XUROLIEC@=9630,(&$$# IIJIJJJIKKKJJJJJKLLLLLKKMMMKMKLLKJLMLILNMLLMMMLOOMMOPNNNOOONNMMNOOPPNKMORQPLQRPOPPPPPPPPPPQQPQSQPLONOSRQQRRRRQQQRSRQQRTSRQQRTTTSRRSSQORTUQPRTSSNTRRRUVUUVUUUUVVSSTVWWVUSUUVWXWWWWXWTWYYXYZYUZZZZYXYYXXWVXXXXYXZZYVZY\\ZVYZ\Z[[[X\Z\^_^^[\[^]]Z^__]__```_``a_`aa`_a``aaabb`aaabeedaddc`cdechffeedefffgeebfgfbfefciiihjllkkkjhhehgkkkijfjkmllmlhlmmklkmkmonijknoonopqmpppqrorqqmolnonmoqqqqqrortrrqnnnpmppqlmpqnooqpqrpptsqoonqmporqqpqssstpporrrrsstqtqqntvvuvrtwvpuuutttsrsqxwwvwswxvruwvuxzyyzzzuyvvvvvuuvrwwwvxtssrrpkjihbb^ZTUROJIGD?=860/)'&&#" +JKJJJJIHJJKLJJILLLLKKMKJJKKMMMLLKJLNLKLMKKLLMNMMNNLNOONNNOONNNNONPPOMMMOQRQOOQPOPQQQPPQQOOQQRRRRQPONPQPOOQRSRQQQQRRRPRSTRQQRRSTSSSSSRSSSSRQSTSTTTUSRSUTTTUVVVVUSSSUVWWVWVVSWWWWWWXXXWXXXXZZYYZYXVXYZYWWWYYYZ[Z[YXZZ\\\ZYXY[]\]\]]\]___^\\\]]\^^_]]_`^^^^\aa__`ba_^`bbbabbadeddccdeeedcadfghhfefedffgghggggefghgfhjihijkkjijigegikkjijilonmnnllmlmljmnonnmmnnmlmnlooooooqrsrqonoqqrrqqqmoqqqqsutsqoopponpqrpqqqqqqqrqppssssrnprqrstqqrsstutsrrtuuttsttrqrsttutssuuruvtsstutuxz|zzwvxyxuuxwyyzxyzyyyxwwuwvwzyxwyz{zxutrsqpoligd_ZXXWRLKHFC>98520,*'##" JKJKJFIHJILLLKLLLKLIKKJGJJLOONMIMKKLLLMMJKNNMMLMNNNNOMNKOONMMMOPOPONOOLIPQPOOPQPPQQRROQQPPPPRSQMQPOOPPOOOPQOQPPQTTSRPMRPRPRSRRSQTTSRTUTSSSSSSSUTVRTRRRSRSTUVVVUTTSVVWQWVUUWXXUXVXWXYXWVSYZZWWXZYXYZZYWXXYYZZ[ZYXYZYZ][Z[[Z[]^V]^_^```]`X]]_^]^_[^_^^^_^^aba^^]bbaabcc`bdcafge`bcddebedeegeggfef`dcgdhiighgggihgghfggggihhfkigfhjlkjiggmnmlnmmjmkmmnnopolonomnjonnmompopnrrrnpooprrrqqnmpqnqrtrqqqqokpppqqqstsppqqrsooprnrttnnotmtssqsqssttsqroussmuutppornututtturustqqrusvwxy{yvsyyzvwrwvyyxuzywvwwytywy{{{{{{x{wwwvvtqqhjhf__][WVMNIFDA:;761/))%%$! +HJJLKJJJKJKKKKKKKKLMKIJLLLMOOOMLMMKLMMOMKKNPMMLMMNOOOPONMMMNNMNPPONNOPLLOQLOPPPOPQPTSRQQQQNQRTQNNQQPOQQQQPOPQROSUTSRQRSQRRRRRTTSTUSRUUTTSSSTUUUUUVTSRSUUSTUUTTTTTVXYWVVVUUWYZYXXXXXYXXWWXZZWY[ZYYZ[ZZYYYYZYZZZZYZ[[\[Z\[[[[]]^^_``_``a`__```^^``__^^__^`bbba`abbacccccdeddefeccddcefeeeefffgfedbdhiiijiihiighghhhjiiiijkklkhfjjklmllkkmmiknnnonmmooooppoooooopomnoooqrqrrqqrqpstqqqromnppoprssrqstpooprsrprtttrprtsrrtssrsrnqsstrsssstsssssssptsstuvsrqrsuuuuvvvwvrrttssutuvvxzyvtxzzzyxwwwwwxywtsxzyyxxy{|}||zwzywyywwwsommkgca^\XTRQMHDB>:852/+&&$! + LLLLLKKKKHKKKKKJKLMMKIKLMMMLOOMLLMNNONOMKJOPOMNONMONQPPOMKLNONNOPNNLNPPOPQRRQPPNNOPSTQRPPQQRSTTRQRRQQQQSRMPQRTTSRQPORTURSRRQTUURSSRQUTTPTSRSTUVVVVUTUUVVUTTTUTVVUWYYXUUUVUXXYYXXVTWWWVWTWYZWYZYXY[ZYYZYVZZ[X[ZZXZ[\\[Z]Z[[\[[[___]]]a]`a```_^^``__`_b_`abaabbbdbaaa`dbededdddcdeecddeefdffeeeddadhjiifigghhhgghhiilfkkjijkkijllglnnlnnnljioopppmnmpqpmpnmmnkomomnnnoprqprorpprurpopqonpmpnqrtorqttrmnprkrrspusrormrqsttqrqqotuuqsotstqpqsssuupsrtttttptrssssvwvrxxutvsttvpwuvxxsxvyzzy{xxxvttvyutsy{zputy{}x}{ywzxxyywwvuommnjfcb\\SUSPMIEB;:540-''""! KLMLLKJJJJKLLKKLMMMLLKKLLLLLNOKMMNNOOONNLMORQOOQOOQQQPQQOMLOOONQQQPMNPPPQRTSNPMOOOMSTSRRQQRQNRTTRRRRQQQRRRRRRTSRPONORTTUTSSQSTSRQQPQSSTTTTSRSUWWTUTTUVVUUTSTVXXXVWXXWWVVWVWVUWVXTVWXWUVWWYZWXYXWY[YXYYXXZ[ZZ[[[YYZ\]\\][\[\]^^__]\\\`a`a`_`_^^__^`accbabb`aabccdb``bdeeeeecc`efeddddehgggfeeggfefgiigeggfgihfghgjklllljikklllllkkmmnoonnmnoooqqqpqqrpooonponooomnnnmopppqsrpoqsqppqrrrqqqrrtsrpqrsrrrtqqqsssssrrrqpqrtrrrsrrsuuuuvttssssrstvvtsrstuuuuttrtvvvwwwvwvtvuuvvxxvvxwwxyz{zzxxwwvuwwxyxyz|yvuwy{||}}yxyz{|{xxvutqpnligec_[XVSPKGDA<6420-)'&$ LJLLKKLKKJLJJJKLMMMLLLLMLKLKMMLMNLMMMNMNOOOPPNPQQPOQQSRPPPQQPNOQRQPOPQQQQRSOOOOOPPQRTTTSRPPOOQSSRQRQRRQQRSSRSSRPQRRQRRUVTRSRRPRPQPQRQRTTTSSRRSTVVVTTTSVWVVVVWXXWVTUWXVWXXUTTWXYYYYYXXVWYYX[XYXYWYYWVXXYZ[ZYYYYZZYX\[]\\[\[\\^_`]]]][`a_a`]^_^__`a`a`bba]a``_`^a`c`bbdcdcfggfdefec`ebcefggggfhhgehijgfehhffijieigijlklmkjklmllhllkkmonmmlmnnnnmppppppolpqqrqoqqomnonmnopoprsmnoonppoossrprqrosrqrrltorqsrrpssrmsttqqnrqrmttslrstuvsrpprvtrotuuptsstutwutrvvvwwtwuuturvwwvwuwwwwwwxvzyzyytvtxvuuyzzxzuyuwyz{|}}yxxz{{|zxxsvtrqqmkjied][XUQMHGB@87630,'(%# LKLKJKLLKMMKJJKMLMMMMNLMMLLLKMMNMKMNNNMMNPPOONQRQONOQSRPPQRRMNNOPQOOPPQROPQQPPPQRSRQRTTSRRSRQQRRQQRRRRQQQRSSOTRQRTTTTUUUTRRSRQRSRRRSSSSTSRRQRQRUUUTTUTSXXVSWWWVVUUTVXXXYYXVWXXZ[\[XWXVWYZ[[Y[[[[ZYWVWXYZZYY[[[[[ZY[^]\[Z]_^\]^``^]]^___a`^^^[^`bbba`aaa``a```a`accccdcccfghhfdcdbcefggegijhiihghijjhghjjhhillkkjjkllkljjlmmllmmllkmollljkmoommnpnmmmmopqqqqqrqpnnpnmopqonqrrrrrrtusqqstsstsrrrrssssqqqstrrrtrmsvuttuttstuuqoqtvvvtrpruvtrstutrsutuvxxwsruuwwvuuvvwvtuxyxwvvwx{zxxyy{z{zxwxyywxy{z{zyxuwzy{{{zyyy{{xxy{ytwxvttrpnmkgd_YWROMICB@;753/,*'% + LJLLJJLKMNMMKILLNNMIMNMKNLMMMMNNLKLKNONLNNPONNOPPLOOOQRRPNQRQPNMQRQNNNQROORSRQRSSRQNRSSSSTTTSPSRRRROQNPOQPTUTTTRSTUTSTTTSQQRSSTTSSSSRRQPONMOQQRTTSRTUSTVXTUVVTVUTTVXWVXXYWXWYZZ\[XWVVVWXXXYZ[\[[[ZXWYYYXZZ\]\[[Z[[[\^Y[[_a_\][^^\X]__Y^_b\__^___cdc^aba_``bbbbabc`bddbcdddgggdccddeghhgghhhhicghhgjhihjjifikjkkkllllkijiljnnmmmklkmmkkmlkloooooonllgnnolpoqqpooknnmkppqqpnpqqtsoturpqqttttttroopstsrrputsorqrkstuuuutssovsqitvwxxwtqtutrsrstuqtpuuwsyywrssxwwrsuxywwvvyyxwvqz}{uzyy{{w{{ywytyzzx{u{wwsy{yxyvyuyv{yxwy{zuyyzvvusqomjeb\[VSNLFEC?7853/,''"! + KKLMKIKLMMMMLLMOOOLLLMMNMLMNMMONKLMNNONMOPOOONMNNOPPOOQRQOORQPOMQRQPRRRQPPRSRRRSSRNQRSSSSSTUSSTTQSSSRQRSRRTTTUTRSTTSQRRRQPQQSTSRRSRPNLIDBAADINQRRQQSTSTVWWVUUUVUSTWXVUWVYZYYYYY[ZXXYYWXVVYXZZZY[[ZYZ[\[[ZZ[]\[ZZ\\Z[]^\\_`^\\]][YZ]`_^_bba``__`_bdc`aba_baccccbbb_bccadffeegfeffeddgggffggfggfeihfiiihhhiiiigikllllmkjkklnpommlklmmmlmlmnmpppponopopppoooopqnmooopppqqrtsnmppsrpppoprsstutstrnpqrtttttuusrqqpnruutttqqqrutqqtvwxxwttuuttttsuutuuuvvvwyyyxxyzxsvuxxwvvxyyyzxxy{yz|}|~yvy{zzxxzzzwy{xwvwz|{zxwxzz{{{zww{||{{{{ywtrolkhdb^XUSPNJFC?;950.,*'# KJLMKFKLMLMJKKMOOKMMMNNMNIMOONOOLMOOPOOMOPONONMNOPQQPPQNOORRQOOOQSQPSRRRQQQOQRRTTSRSSPPQRPRSSQTTQQUUTSTSSPSRTTTQRTTRPPRNRRQRSSRLOPNJC=5-'!$'19@FJOQRRQRRVVVTTTWUUVVUUUUUYZZYWVYZYXYZYWYWWWYZZZ[[[XZ[\[[[[YZ]][ZZ]ZYX]\\[[[\[]]^][[^`_^_ab_aa`^^^abb``a_^bbaac_ba_^babbfffeddedfgedefgfedgggbhhijififffgfihjjjillljklllmmmlpkmmmlmklmnnnmmmoppnoonnopqorqplmnnpqqqprsrrrsroprqpqrrpopsssrssrrsorsttttuqtsrqqpopsuuptpoorttussstuvwvuvwsrsutuussustouuvsyzzvxvxtvwxxvuuv{yy{zuxxyz}v}yyvwwzzyw|{zxxtvsxy|y|zywyx|z{x{xy{|z|{{zzwusrlljgbaYXTUPLFGB@:832.,'% ! + MLLLKLLMLMMLKLLONKMMLPOMONMOOOOOLNNPPPOOOONOOOMNOQPPQRQOMOQSPPPPQSQQQQQQNPPONQRTTSQTSPPQSRRRRQRUPSUVUTTRSTSSRSTSSUSQPRRQRTSRSRPOOOKB6* &0:DKOPRRQTVUUUUUTWWUTSVWWWWWWTUXYWXYYXWY[YWXYZZ[[ZYYY[[\[\\]]\Z\[\[ZX\\\\\]^`____]]^_^_``aaaaaa```abbcca`aa^_accda`aacffggfedddefceffggggghgfgiijjiiiiihijikkkklmkklmmmnnllnnnmllmnonnonloolmnnnnmnpqprssqonnnqrrrqrrooooppqssqsuussstutpqssttssuuttstsstsrssrssruvtqsttuvuuuutvwvtsuvvttttvuttttsttttvvwxxvuwxwxxxwuwy{yy{zxxyzzzzzwxyyyyzzz}|yywuwzz{{|}~{yy|{|{{{{z{{y{|{yzyvuurplhgd`\[XTOKJIC>:852.)(%" !% MLLKLLMLMLMMLMMONKMNNOONPMMOOJNOONOONKONOLNNONNLPSRQPQPOOPQQRQPPQQQNQPPPQPQQQOQQROSSRPRSTSRRRSTTTTUTTTTQSUUPRRTTTRSQSTTQRTSQRTSOQOF8( +",6=DJNPRTUUVVUTWSSSVXYWUTVWXWWYXVYXWVXZYXXYXY[YZZYYZ[[\\\^[ZZ][[XXY\[\Y_^_``^`\___^_`_```a`bcb_a]cddc`]_``_cccbc_bbcddegda`abeddfggiihbgggdgeijigghlkkjjhjlkhjlkglllknjkjmnnmlhlkoponnloolloonnokprrqqoqqqnoopprqqqoopmnkqrsqstuuusvutprstutrqssrtrsqssrqsssprruvusuuttvvvvvutturrtttvrvwwuuuvttutottvsxsxtwxwtxpwvvwxxyyxvvvz{yvvuxw|{zv|{~wttxuyzzz{x~z{wzu|w}}~|{zz{{{{x{zwwxssmlkhca[YWTMNJG?=6620**$% #$ + + LLKKKLMMMMMLLMNNMLMNMNLNOMNQOMNPOMNNLLOOPONQPNNNPSRQNPPPQQPPQPPQQQQRRQQQSRSSRRQQQQSSPRTSTSRRSTTSRSSTTTTSSTSSSSSSSSSTTUUSQSRPRUUTQL?, +$.9AHMQRRTUTVWVUVWXYWSTVXXVXZXWXYXYXYZXYYWXZ\[[ZY[Z[\X\]]\\__][[Z\Z\_aa^^_a`_``_^```_]```acbaacdec`^^``aadedddddddccdfdabegfecfgiijgfgihggghighikllkmljikkihljjlmkklllkjlnommljmponmloomnpqpopppqqonopqrrpnopqqnpsrqqopqrrssstuuwvurqrsttsrrsttstssrsrrrstsstuvtrttrrwzxxwurstuuvusuwwxwstuwwwvtuvwvxxxwvvvvxwvvxyyxxyyuxyyy{zyxwwv}|{|~|uwzzwxyzzz||{{||||||~~~{y|}|||zwy{ztponkieb]WVSPNIE@;862.+*'%"$' KLMMMMNNMMNLLMNMKLMMNNNNNNOQPNNONLLMMMPPOOPQQNMMPQPOPQQQQQONNNPSROQRRSRRSTTSRQQQRRSRQSSRRSTSSPRPRQQPSTURTRRRTSRSTTSQTUUSSRQNSUUTNE5 (09@FLOQUWWWVVWVVVUVXUYVWWVVYUXWZZYXYYYYZVZX[ZZZ[\\]^^][^_]\\\\\^`a`^_`aa^aa_^_`bbaba]`ab^cdcba___``a`dddeedeeeecdghffgfgfeegfhefdgkihihhhheijjklmmkkkkkkklmmhkjkkmljkooonmjllnkkkpnonpqqoonqqpmnmpqssoknponnotsrpqpqmrpuutqtvusrqrrtssrsvvqsqsrsrtsrsvwtrvtqpqrrsxxwowttttsxxwtvtxvtssuwwwwuuwtyyyxwtwsuwvtwxywxvzyzz{wz{{zzxxt|z|y{yxuy{zwwxxyyx|||||}}zz{~zyy|z~~~}|xyz}}wqssoijcbWWWSMMGE>=75.-+*%" %# LMNNNMNNMNNNLMMKKLMNNOONOOOOONLMLMMNMOPQPOPQNPPOPQONOQQPRQNMOMQSSQPQSSPQRTTSRQRSPRRRQRSRPSTSRSSRQQRSSSTUTRQRSSRSRUTRTVSTSRPPSTSRH:( + +&2>FMRVVVUUWXXXWWXYYYVYZZZYWWZZZXVZ\ZYYZZZYXYZ\]^_]\Z[^Y[\\]^^_`^^_``abba\\]_bccca^^`abbcca^`cddbbccddcadffbddehihgfeegfghhffeehjlkjhhihihhgkkklnnllmkjkmmllmnnmllknonmnlkjlnlmpqoonqqooprrpppopqsrmmoqpoprtsroqrpmqtuusqsutrrtutssrrsvwusssssttsssvvssutoprstvwvtsstvwvuwyxwwwwvtsvwwxwwwwvuxxwxwvvwwxutvyzxxwzz{z{{zzy{{zyz{|{xz}|{|~{yz}~}|{|}|{{{{|z|~}}}}|}~~|}~zxwurpmida^ZVQNIGEA=962/+&$!## LIMONJLMMLNNNMLLMMLLNONMMPPNNOOPONNNPPPQPNPQQQQONKNLPQPOQRPOONOPRRQOSSQQRRSTSRSRRRSSRRSQRTTSSQTOQPSSRORRSTTQSSTSSSSSTUSQRRQQPPONA, + ".8AHMPRPVXWWWVVVZZZZ[ZZXWWXZ[XXZ\XWX[YXWXY[\]\\\\[\]]\\[\]^``\^__\`a`_^^^_`bb^a^^_aa``ba`cefeeebddecbaegfdefeegcbafgggggfffdhiklkgfehghehijflmnijkkfkjmjmlnnlikkjkmmnlkimoonnmopqrrmlmsrqqppoornppqnqorrrsroqrrostustqqrqpsqvutqtuttssroqosttotsstssuwurrtuwxvuopqvuwvutvvvwxstttuuuxxxrxwvuwzzvxqxtwvwwxzzz{w|zyyxxyz{wz{|}zv{~~}~z|{}}}~~y{w{{zy~|~z}z{|~|~~~~~|xyvsqqjgcb[[UQIGFD<<65/-)'"!# KLMOMKHJLLMNNMIMMMLMNONLNOPOOPPPOOONOPQRRPPQQQQPONNPQPNOOQQPPQPQQQRRRSPRRRSTSRSSSSTVTSRQTUTTTUSRRSTSQRQQRTUUTTTTSTUTRSRSTTTRNROH8# + + +#0;CJPSVWVVXWXYZZZYYXVY[YY[[[\\YYZZYYYZ\\\]]\\\^^]]]\^\[\_`_^^^`ab`_^^^^]aa````aaa````adgfdffdddefdbbffedddefecdfgggefehgehihjkjhejjjjkkkkkkkhjkjjlonmmmmmllnpmhloonllnoqoonnrsrssqrrqpqpqqqrsttrrqpqrrrrrqrststuvvwuuvuttuvttttsrqpoprsttsuttttusuxwuwttwwwusqsuvvusrtvvuvuuvxxwvwxwvwywvwy{zxwwzyyyyxz||{x}~{{{yy||wxz||yw{}~~}}}}~}|}€€}|{x|~}|{{|~{y{~|||{|}zzywvsqmjfa]ZSPMKFA=:740*(&# "" + KLMNMKKJMNNMNNNLMKNNMMMMNPPONMNOPQONNMQSSQPPQOPPQQRSSPPOPPQPPQQQPQSSRRRSRNRSQMSTSSTTTPRRSTTQTTSSSRTSQSRQRTUUTTVTTVVRSTSTUTTTRRK@/ + &3;DKPTUVVVYXXSXXZWZ[YXZ[[Y\[[XZX[Y[]]\^]\Y\_`[_^^__\]]_^]^_`caa_^\^_`aa_a_aab_bba_abfecccbb_egfcccfecaedecddfgggghihgeijihhghejjkkllkjkijhijlllmokmlkilmppohkjnonnnmpoonnrsqrrqrrnpopqqqsuvuttsnrrsssqstutrpvvwxvwwutousvvsoqproqsuvuruvvsvuvprtvvvutrxwvtrotturrqtuwswvvvyxwwwswttuwtuvxxxrwxzyzyuwxxzw}}{x}{z~}vwy|xvw|}}~}{~|}{}}}{~zzy{w|~{{v}~}y|yyx|~~~€~~}{zxurrokb_^ZTRPKCA@;83+)'$ # +LMLLMMNOOONNMNNLNNNNKMNOLONMLKKPQRQONMNPPQNPPPQPQSSSSQONOQQPRSRPNQTVTSSTRPQROMSUQSSSRORRQTTTUVVUTTSRRTSQTVVTSWUSTUTRTUSTUUTTSPE3 + (8CLQRTVWXWVWYZ\[ZYZZ[Z[]][YYZZ[[]]]^_]\]____^\]_`^_^^]^_accba_^^_abbab`abb_bcdeddefcbccccehgedegecffffdddfgghiiiiiiijjkihhjjjijlmllkkijjkklllooomjlmooooommopoonloppnoprrpnorropnnpqrrtuutsrqrrsssstvvwvuvwwvuvwuutuvwvrqqqtuuvwvttuxwxwxwvvwvvvuuvvvvusstuutsstvyzxwwwwvvwwwwxxywvwxzyywvwxyzyuvxxyv}}{z|}{}|{{}|{zz|}z~}|~~}}}}|y|~|z{{{|~~~~~€~|{w|€€~}|{xutsmjda][WTOLHD?:61-(%" "# +MMLLMNNMNLNNNNMLNNNMNNOPPNNNMLNQRQPOOMLKPQQQPMPQQPQQQOPOQRQPRSSQQRTUSRSTSQTTRNSSSSSRQPSPSTUSUUVUUUTRTTRRUWVUUUTRSTSRUUTTTPRTRL=& *4<BHNQUVVVXY[ZYZ[[XZY[\[YYZ[[\\^^_Z^\]^]^^[]]^``_^__[aaccb`_\^_`aaac`abb`bbefebccbcdbedeggcdehhhhggfeebgfhhjejjjkjijkjiijjjiiljklkhgflmljkknoonmmnkkkppnoommnnlorqlopqqqlqsroonopqprouusnsqsuutqmtttttuvtwtstuuttuvvusqrrtruuuuusvqwxxqxxxsvtvvwtusvpuvvvutvpvwxwwswtvuyzywvvxxwsxz{x{{ywxvxzzyzywv|{{v|~{yzz~||||{}~}}{|}~~~}zyx{}}y|||||~}}€z}y~€~~~~zwvtpih^a][WSOKFB=911*(##$% +LMMMMMKKLMNONMLMNNOPQQPOONNOONMPPPOPPQOOPRRQPPPRRQPPPRQQRRQORSSSRSRRPOPTTUUUUTRPQSQPPPSTTTSSTTUUTTTUUTPTVWVTSSSUUVVVUTRUSQQSOE3!'2<DMQSUVVYYXZ\ZXXXZZ[[\\]]]^^_^^^_aa_^^^]]^___^__^acdb`^]\^__acccaabbabcddcb`cddeeeeefeeddgjihgffffghiijlmjikkjiijihijhkjhjjkkjhhiknmnmllmmmnoonmnppnnmknooporqonoqsrqqrpnpqrsttrsuusrsrutsrqrssqqrtvwvtstuwvuuuutssrssqqrsuvwvvvwwwxzwutuuvuvutuwwwxyuwwwwxwuuwwwwvy{zwwsuwvtxzzz{|yxxvwz{}||yv|}{||~{y|€}}}€€~}||}€€}yzy}€~}}€~}}~~~~€~€€~~~|xvurnkgc`]YUPMIEB=830+(%# &$MNMMLLLKNNOOMMNMOOOQQMOOOOPPPPOOOKOOQQPPQQPNPQSSRQPOPRRSSSQPPQRQRSRRQNSUUTSRUUSSTTTRQPSSTSRSTTTUUUUUVUUTUWUPQQRSUTTTUTQTTPQQI:' *4=FMOUWWXZRZXWWZZZ[[\\[^^^]]^^`aa_]_Z]Z]]^\^]]]`bca_]^]^_`accdba^`abed`aabdecfefddceffcfehggeefggiiihkkiihggfiggeiikkjiiklkkiiklmmnonljjhnnppoooonolknopqrrqpnmqssoropnopsttssrurssssrpsossttutttwxwttrvxvuvvtnsttptqoorovxwuvwvwxtsststovvvrtuvtwyyxyuyvvttwvvywx{zvwrvwvuywzzzxxtxxyyz{|{zw}~|{~zzz€}x}~€}|{~‚€{}z}}~~~€€{{|~}~€~~€€{}~}yyxuqpkgaa\YRPKHFB:80/((## %%MMMLJKMONPOOMMNOOPPQQOOOPPPOPQOOOPONPRQPPPPPPPQRQQQOPQRSSSTTRQQQRRRQRSUVVUSQRRRUVWUSRQSSTTTSTUUUUTUVVURSSVUTTTSTTRSSTSQRSSQM@- + .9CKQUXWWYZZ[[[YZZ[[[\^]][[\^__^^_`^]]__^]]\_``bb`]^]_`bb`abb_^_`bfec``bddbeggfeeghgfffghggfggggfdgjighgggjjjhfilkjjkklmkkjkllllmopoklmnoopppponommnnpqrqponopqrqrpppsssttssttttttsptuvussuvvuwwxvuuwvvuuvvsqrtuuuvtssrtwvvvvsvtqqsuuttuvurtuutvxyzzyz|{xxzyyzxxywtvwwyyzzxz{zzyxyy{zzyzyy{|}{{|~~~|w|~~}|||‚‚‚ƒ€|~~~|~~€€~}‚‚€€‚~{}~~}|xttrlgfe^TROMHDA<83/*'$" '& LKNLKJLNPQRPONNOPOOOPQQPQNOMOQPNQQOLNOROPOQSROOPPQPOPNRSRSSSRPRQSSRQRSTSUUTRRTSRVUSPPPTSUVVTSSTUUTUSVVUTSTWWWSSTTTSSTPQRRSNE4 + + +&3=EKOQVZ\\\\[Z[YZY\[\]][]]][^_``_^_``^^^_```abb^]\`bccb]`\_\a`beec`^ceecgfhhggiihfecefghgdfeedfhjiiiigikkijehjldklkjmmlkkmlhlimppkmnmmnmoppjnqpopopqplmoqqrqqqonqptsrsuottttttsprtvuursrvoustttqwwvtutvrqorrutvtwuupusrrvruvtoqrwwursrrruuuuvtx{|xz|{xxyzxyywuttuvxsyyzwxy{|{wxy{z{z{w{|||zxxy}x~~{y{{|yxy}}}€}z|~€‚}~~~€‚‚}‚€€yxwwspjkdbXTQQJGA@;82/('#"#'&NOOONMJNPQPPPPNOPOLLMRQQPPOOMPQQQROLMOQRQORTSQQQPQQQQQRTSSSRQPRSSSRSSRSTSTUUUUTTUSRRRSTUVVVURPQUUUTTUXWUSUWYXVSTUUTTTQRSSTJ9' +*3=GOVY[\\\\\\[[\[[]^]]]\]]___^_`_`^___^``^abcbbbabdbabcbbbabccb`acefgfefgffghggdcefdhhgfffehjjiijjiikkkjigjjjjlkhkmmkknlnmiloonnnkjlnopomoqqppqqqqoloqrrqnqrrqprrqrtttuttusqpstuuutuwwxutuuuwwxwutstutstttvvxxwutvvtsuuuuuuuvxxwwvvvvvutuvwx{zxxyxxxz{wvwvwxyyyxyyyzvwz|}||{{{z{z}~}~|}|xz}~€~}|}~}|zzy}~~~~~~~z{|‚ƒ‚~~‚‚ƒƒ‚„ƒ€ƒ„…‚‚‚|yvsqmiea[XVRLHC@;72.*%#!#)OQPLMMMNOMMIOPOPQPPNPPPNQPQQOQSSRRPMNMPQPORSQOQPORQQQPQSSQRRQOSSRRSTTSTTSUVUUSSSTSSSSTTRUTSSQPRVVRRRTWWUTVVTVVUUTUTTTQRRRPB- +#.8AIOSX[\[\\\]\]]^Z\]^]]\_^^^_]]^__]\___`bceda`a_cadeedbaabcdbadeefdddde`ddffebfgfdhgfeefjkkfigkeiijgjihgjiijlilnmjmnopnilmonoponnmnmmkppponopqrqqqrnqprrrsspqqqmrrsptsuqqquvvtuuxyxwvvvsvxxryvtqtvvuutuswxwqtuwxwsurstsquxxwxwvqxwwturwtyyxwwuvvwz{vupqrxyzzz{{zzvzz}w{z{{|{|{}||~}}}x}~~|€€x}€€~}}|y~}}{}x~€|~zz{€‚‚‚‚‚ƒ‚€|‚ƒ„€‚€~ƒ…†„€ƒ€|ywurqkid`\ZUOJGB?75..'%!%OPOLMLLMMNMMOOOPPQPOOOOPPQRQPQSTQPPPNMOOOPRRPNNNNQRQQQPRSRRQRSSTSRTTQTUTTVWUVUSRTSSTTUTUVVTRRSSWVTTUTSTUUVUTTTTTTSSTTPRROI8$ +$/;DMTXYZ[[]^]\^^\\\]^^^__^_^\]___]`ba``bcb_`bdcdeddecbbbdecacfggfeddeddeeeeffhgfffdefhjkkjiiijijiiihiijigjklnomlnononmmnnopqpqpooonnpppoooqsrrrrrrqrrrqrrqrsqoqttsssssqquvttttwxvtrvvuwxxyyywwvvvuuuvtvxvptuvwwvvvrsssuxwvvvvvwxxwvvvtwxwwvwvuvyzwvwwvwxx{{{{{{||}|xz|{|}}}}{{}}{|~~~~~~}~||~~~€€€~~€‚ƒƒ‚‚ƒ‚}€‚ƒ‚‚ƒƒ€€‚„ƒƒ‚€}}||yvtngea\VRLJGB<741.(%"LMOMMMLLLPOMPPOONJPPQPOPPMQQOOQRRQRQONNMOOPQQLLLORRQQQRSSSSRSSRQRRSSRSUUUUUVVVSNRSSSUVTVVVUNSTUVVSUUSQSTUTTSTSRRSQSSTPRRJ>, )2=HNSVX\^\Y]\\[]]___``_`a`_^^\\_ba`aaa_`acdbbdcd`bccacdcdeffggeddeefefffggeibdefggfijjhiijhjjjjjijkjhjjilnnmmmmmkonnkklpmpppooloppoooplqstssrrprrqqpprotutmtqussrrppqtruutrusrqsuvtwtxyxuvvwvusuvvsutuqustuvswvssvtutwwvuuqwyyvwttsttuvvvuuwxywxyyyzw{zzy{x||}}|x{w{z~x€}||{}z{|}~~~~€€{}~€€~€€~€‚|„‚„ƒ}}€€€}‚ƒ„€€€‚‚ƒƒƒ~|{vsjjb_YUOLJF@<740,%$MNOOMMLLLPQOPPMNMMPQPNMQOPQPOOMQRQQPOONLNMOQQPQQQQRRRRRTSSSTTSRRORRSRQSTTTQVVUTQPSTTUVTUVUTSTTUVVVUTRSSSRUTTVVUTSSSUUTSPD1 + +.9BKSW[\[Z[\^^_```a``aba`^^^^`a^`^baaaacedcefc_bdccdeeffefhfddffdffihffghhiihhhhdikigiklkjkkkjklmlkkkilnnopmklmnonnoqpqqqponjnqpoppooqrssttqrssrrrrsuvvuvutuvutsssttuuwutuvuuvwxyxyxwvuuvvwustvvvustvutsuvwvvuwxwvwwvwwvuwyxwwxxxwwwuvuwwwwxw{{z{{y|zyz{|{|{}}x{|||}€}|}~|€~}{~€€€~€€€€ƒ„†…„€€‚€~€€€€€ƒƒ„€ƒ„ƒ‚‚„…††…‚|zvsnhb^YTPLIE@961.+& MNPPPONKNOPPPQPMMNPPOKNPQQRQQPQQQOONPONLNNOQQQRRPPRSSSRSSSSTTTTSRQRTSPPQSSTUTSTSRSSTUVTQUTTTUSTUVVUTTSSSVWVWWVUTSSTUUSSM<# + + + "1<DLRVWZ\^^_a^aa`^`]`_`a``bbaaabcdb]abeedecabbdefffggcfggdghgcgiigfchffghiihhfjjhhjllijkkkkllmlklllmnlnonkklnoooompqqqqpplpnooonpqrqpqttsstqpqrrtuvrtrvrvvutvuuvvvxxwuuquvvwyxwvxuuqtvvuwsstwwvttttuutwyyxxwyyxuxxxwwtwwvtxrz{yuuuwvvvxwxx|zyy{x}zyz|y{w{|{z|{|w||~w}€~~z€}~|~€}~|€~~}~€€€~€~}}ƒƒ‚ƒƒ‚†…ƒ€}}}€~‚ƒ„……~‚„„…€„†……‡~‚~}yzvrnib^VTRLFC::31/*"!NOOPPPPONMOQQQRQONPPPQPOOOPPOPPSQQQPPPNMMOQQRRRQOQSTTTRRRRQSTTSSSSSVRQRSTUUTTRRSRRQTUWUQTUTTTTTUUUUUTUUVWVWXWUUUSSRTTSND1 + + + + &2<FMTY\\]^_``^]^__abb^`abbbbabdb`abddcccddeegggfffeefghijhgghhfhjigggghiihjjjhhillkklkkjlmliklmmoollmmnnmnpopnmoqpopqrsrrqpoprtssrrrrstropqstvwtqsuuuvuuuuuxxwvvxxvtstuwyyxuuwxusrwvvxxvuvtuuvstuutvyz{yxyzyxxxxwwwxxzzyyz|zyxxyxwwxyy{zyyxz{{{}~|{{{|}}z{{zz{~}}~~€€~€~}~~€€€€~}€‚ƒ€‚„ƒ‚……„‚‚ƒ‚‚ƒ„‚‚ƒ„………ƒƒ…ƒ‚…‡††……†…ƒƒ‚~}{vrnjd^YUQLGC>:60-)$!NOONNNQQOMOPQQQPOMOPQRRPOPQMOOQQQQQPPPMEMPOOOOPOQRSTTTSQRRRRTTUTTUVVTSTUUTTUTRQPQQSSUWVRTTTUTUVUUVWVUUVVWWWVVUVVVUSRQPG8& + + + + +(4>HOTYZZ^\\[]\_`bc`^_`cabaa```aaddcbegfefcghgbfbfffgihhhhfhiiiifghiikllkjjkjkmmkmnmlllnhjkommnonmlkkononmlomoponoorsqpsrqqrrsrrqppqqqornuststosuvvvutqsvxwusuwwvuuvrxxyxwuvrwutxwvwwyvtrsuvsuvvuwuxvyyzzyvytwwvxwx{yyyzyxyxxzzyt{{yxxsywyx{x}}{{|}}|}y|vww~|~~~~~}}{~|€€~|~z~~€€|}‚€€€€€{ƒ‚€„‚„ƒ‚€‚„…„„ƒƒƒ‚ƒ†‚……ƒ‚……‡†ƒ…‡…ƒ‚‚ƒzwpoli^[WUPLEC=:1/*("!MONNMOPPPPOOPQMMNNOQPQQPPQQQPPQPPQNPQPLIKPQQNPPQPQQSSSQSTTSRQTTUUUUUUUUUTTVVVSQQPQSUUUVVUSUVSVWVUWWVTTUUVYWVUTVWWVTQNK=* + + ++8CNTX[]\\]__`cdba``bcaaaabdccefddgigfffgigeeeegeehjghhgijiihfhijklmmmkkkjjlkkmnnnmmmlmnonkloqolopppooopoooopoopoqqrssrqpqstrqqqqqpstwvtttsstuwwuttsquuvuuuvtvuvwwxxxyxwuqwxvywuvvz{wstxwstuvwwyvvwyzzzzxuwwvwyyyyxxxxwwwxz{{{||xwxyzxyyyx|{yz{~~|}~~}|~~~}}}~~}|~}|~}~~~~€‚ƒ‚€‚€€€€€‚ƒ‚ƒ‚ƒ…„„€„„ƒƒ„„„„…„„††………………‡ˆ…‡„„††„‚~zwtrnjd^ZWQKFB=72.*'#OLMNNOONPPOOPQPMOOOOPOQMNOPQRQRRRQPPQONKKNQQPQQQQNQRSSRSTTTSTTSSUUTPTUWWVUWWUTSRQMRTUSWWUSTVWWVUUVVVVUURVXVPTTVWWUUSMC3 + +)4>HPUWW]\]]bcb__`bba`bcd`eddedcfgeegbhihdedfggchjihhfijiihfffiimjkilllkkjigmlmmomnnnnppmjkmolompommnoniooqmqqporsspqpolstsoonrstvvuuststotvxvtsuvuvxxxvvtuutrwyytwwxsuqwxyzxuuvwwvuuwwutsxxyyxtxxxxzvvwwsvxyzytuuyzytutzyyz|{zyyzzxxwwx|z{|||||~}}|||}}w}|~||~~z}}~~~‚‚~‚~€ƒ€€|„‚„ƒ‚€„€†…„~}|‚„…„…ƒ„‚‚…‡‡†‡‡†…†‡†„„…ƒ…†‡ˆ†‚ƒyzttnja^YVPKFA96/-'& QOLOONOOOPPPORRQQQQQSTRPMPRRQQRSSSQPPOOOJKOPMSSRQRRRTTQRSSQTUTSTTTTTUTTWWWVVUVURSRQRSTWXUUUUVVTUUVVXYXVVVWVUUVVVVVTSI9# + + ,7@GOUY\^`a____ababbcddeeddcddcdfffghggeeiihhijiihhijihfghhjlljijkmmllkigllnoonmmknpqonomopoonnmnmnnnnpqrrrqrrtsprroprtsspnrtuvtssrsstuuvvustvwwwxyywwwwwtswyxwxzxuuwwwyzxuvwtuvwvuvxxyyxyyyy{|yxyvwwxxxxzyxyyyz{yxxyz{zy{{{{zzzzxxy{|z{z{{z~~}}|{{|~€~|}~~}y}€}€€~‚ƒƒ„ƒ‚‚‚‚ƒ„‡††„‚‚ƒ„………„‚‚~‚…†‡ˆ††‡‡†…………„†††ˆˆˆ…„ƒ‚€€}{wsojc_[WQJF@:50-(%!RQPOOOOONMOOPRSRRRRRSTSQPRSSRPPPQRRNPOOQOJMPPRTRSSRSSSRRRRSSTPRQSTTUURRTTSSTVWVSUTRQSTVXWUUTTQUVUUUUXWVTWWUTUUTTTSSPB/ + + + ,5>HQY]\__^]acb]bbecedddeeebfhgeffhffdifhhihhiiijjighihhjllhifkmmmnkjhmlnmmnmllnnoooqnqqomnlonnoonnnrtsqprsttqssqqspttsntrttsrsrpptstpttsrvtwvxwyvvvxwwvwyyyz|yvxvwvyuuvvwwwwwwrvxwuutvvzx|{ywzuvvxyxwxxwwzxyxwvy{zwxzyz{{yyyywt|~z|z{|}}~x|z{}}}€€~|}~|z~~€ƒ‚„„„}‚‚‚~ƒ‚„……~„€„………ƒƒ‚‚~ƒƒ…‡‡‡††ƒƒƒ…‡†„†„†ˆ‰…ƒ‚…€~~}||vrnjd`ZVNIE>64/-$$MRQOOONPOMMOPQSRRRRRQQRRQRSQRRONOPQQQPOQPMJPQQRRSSRSTSRRRRRTTTSSTUTUVSQSTSRTVWVVVURSUVVWVUUTSSUVSSTUVVTVWVRTVVTSQRPI9$ + + + -;HQW\__^ab`_abceddeeefedeggfddgigdhihgfegiijjiiiiijhjllkjkkllmmmmonkllknnnmmnnmoqrqpomoqonnomprostrpoqsttsttrpsuttttuvutttttstuuuutrssuuvyxwwwwvwwxzxzxy{{ywxwxyyuvwxvwyyxwwwwvtvux{zzzzxxyyxvvyxxyzxwywy{yxzzyyy{|z{|zyyyux}€~}|{}}}|{{y}€~{~~~~~~|~€ƒ‚€‚‚‚ƒ„ƒ‚ƒ„ƒ‚„†„„„…„‚ƒƒƒ……†„„…„ƒ…ƒƒ„…‡ƒ……†………ƒ€…ˆ‡…†††ˆˆ‡„„†ˆ†„zsojd`[VNF@8860*'$!OPPNOMNOOMOOPQRRQQQOPPQRRNRSSRPOOOPQQQQPRQPORPRRSRSSSRRQRRRQTUUTWWTUUTSTUUTTUSVUWVUSUUVUTUUSSTUSTTUWWTTUXWTPUVUTTSK>- + + + + +&6AJRWZ\]`_``ddcadeebecedgffdghhdgghfedijiijjihigjiklkilmmkkklmmmnjjlmmonmlokmmoppoojqqphmmoqsqssrpprrrrprsqostsrssvwvuustrvuuqwxurstwxxtwvvwwuuuxyzzzxzvywxxyyxuvwxsstwvuuxuttxxxz{yyvuuyzzvwxxx{|zxzxxx{z|zzzzu~{|}{uz{zz{}€}z{y}}}w}{|}|~z€€~€z~€}~{€€~€‚ƒƒ‚ƒƒƒ~„……†……€„ƒƒƒ……„‚„ƒ‡ƒƒƒ‡‡‚€‚„…„„„‚~„‚††ˆ†…‡‚‡†‡‚…ƒƒ|~wslhb`ZRGF=<95,,'% NOPONMMMOQQOOPNPQPNQQQORRRRTSQQRRQOOOPSUTTSQRTTSSTTTSSSRQRRQQUUUVVSTUTTUVUUUUWWWWVUQTVVUTVVUUTUVVVXYXUUVVWVTTUUUUSE1 + + + #.8AKT[^acccdcccdeffffggghhfihedhhghhiihghkiggijkkllkkmlkkijmmlmmmnopppokmnlmnpppqrqqqpmloprpsutrotssroprqqssrtuuvvutttuwwvuvxzwsuwxyxvutwxwtuxxwxzzzyyxwxxzyuvvxwtrtwzxwwxvvxyty{yxvwwy{{ywxxyz|zz|}{{z{|zvyz||}w|{vz}||}~}|{|~~}~€}}€€€~€€~€‚€€€‚‚ƒ‚‚‚ƒ„ƒƒ„„…‡†…„ƒƒ„‚„…†…„†ˆ‡†…ƒ††ƒ††„„‚†„„…„……‡‡†…„………†‡……ƒ‡ˆ…ƒ€yvokhd_XQLID?:51.*&"NPPPPPONQRQPOPOMPPQRQPQRRRSQRPRSSQQPQQTTVVSPQSTRRSTTSRTTSSTTTSUUURRTVVTTURTTVWWVUTURTUVVUVWSUTUUWUVWWVWTUVVTTUUVSL<% #-;DMV\`abcdc_eggggdggghghgefghghhiffgghfdgfjiifmnmklmlhjllklloppopqqlnmlinpporrssrknkoqqnsuussttqrqqpqqstuvvvwwvttuvwwtxxyuwuwxwvxwvtwzwttsxvv{|vwvwxyvzxwuvtxvuvwwxwyxwtyyxz|zxvvwyzyzyxywxyxx{{zxyw{zwuyy||{z|v|~}w}~~{~}}~~{{{€€}€|€z€~~}€}}}~€‚„€‚‚‚‚‚‚€‚‚„……‚‚‚‚‚‡‰ˆ…‰Šˆ€ƒ‚…†‡ˆˆ„…‚ˆ„„„††…‡…†„……‡ˆˆ„„„ˆ‰†…ƒ}zqmkif_VQKID?963/&$" OQOOPQOORRPOPROMOQRSRRRQPRQPQQRSSQQSTUUUVWRPQSRRRSTTTTUUTSSUTTTTTSSUVVUTUUUUTWVTTVVVUUWVSUVVTSVWWUUVVWWVVUVVTUUVOB/ + !.>KTY]`cb^chhhfdeffgffgfefdfhhijjjhfhhffhihjlonlmnlkkkgkmnnpppmqponnlkmoooqttsqqonotsqqttqrtsssrsqrrsutuwwwwwuttuvwxyzyxwuwxxwxxvutwvssuwvuzywvvxyyxyyxwvvxyxyxwxxxywwyzyzzzywwwxx{{yyzyyzyxyzzzz{{zyxy{{{{|||}}z{}~{~€~~{}€€~€‚€}~€€€}{}}‚‚ƒ„„ƒ‚‚‚‚€ƒ„ƒ‚‚ƒ†Šˆˆˆ‰‡†„ƒƒ††‡‡ˆ‡ˆˆˆ…ƒ…†„†‰Šˆ‡†‡ˆˆˆˆ‡‰‰ˆ‡‡†„{vrnic[VRNHD?;83.+)%" PQPOPNNOQQOMQROKPQRRRQRQQQPOQRQPSSSTTTUTWUSQQSSPTSTQTTVVUTTSTTTTUTTOSRUUUVUVUUUSTVVVVUUVUTVVUUVVVUVWWWWWWUVVVVVTH6% + +8AJQY]^bfffecdefggeghgfecghikldhfiggdiijlmlnmnklhkkklnjmoppqpplponkonnnoosqqnpmosunrrrqqstrrrrqrrrsstwwvuuttsssvxxxxvxuwxyyyuvvutupuuxwxwxqttxyyyzwwwxtyxyyxxysxvxuyyz{zz{zyuww{|zyyyyyyuxx{{{{zzyy{}|y{||{}{}zyz|zz{~}~{|}|{€~€{ƒ‚~€‚‚~~}||~|€‚~‚‚…†„ƒ…„ƒ}}~ƒ…„€ƒ…„†€„ƒ†‡ˆ†……„…‡ˆŠˆ‰††…††‡‰‹‹Š‡ˆ‰ˆ†‰‰ˆ‡ˆ‰‰‡ˆ‡ƒ{vskg][YUKJGC<901,+%$!#"" PRRQPNPQQPNOQROOQRQPRRRRQPPQSTSSUUSSSUUVUTSRQSTUTSUVTTTUUUUSSSTUUVTSSTUUVVUVWVUSTVVVWWWVUUVVUUSUVVVWVVUWVVVVUVTP?* + + + + + + + -8DOY^acdccdeghgghjihhgghilkihihgijjjjllllmmnmmlllmmkjmnoqqoopooopqpnnmpoprqnoqtutsrsrruusssqttsuuuvvstuuvvtuuvwwvwwyyzzzxuvuvvuuuwy{zyyxuuvxyzzyyxyzzxxzzyyxxvyzzyyz{|||yxxx{|zyyy{{yxwx{|{z|~{|~}y}||{{}}|{{{|{z}~~|}€‚€€€‚€ƒ‚‚‚€€€‚‚ƒ‚ƒ…†ƒƒ†„†„‚‚…ƒ‚ƒ…„„ƒ‚…†ƒ‚ƒ„‡ˆ‡…††ˆ‰Š‹Š††ˆ‡‡ˆŠŠ‹Šˆˆ‰ˆ†Š‹‰…ˆ‰ŠŠŠŠ‡ƒ~yyulfca\UQNJFA=850,('&&%%%$###"#$#""#" PQRPPOPOPQQQRQQQQPPPSRQRRPOOTTTTUUUSSTUUTTTSSSTRQQUVVPTSSSWUSQTUUTWUTUUUWVVWYXWUVVVRXXWSVUVVVVUVVVVWXWWWVVWVTUOF4 + + + + +"4?HOW\_`abfgghihgdghhejmkiihiikljgggjijjkkmonkmllllmmlqpmjompqrqqmmmnoqssqqqsvttsssrvwvstqustuvuuttuvrwvtuutxyyxxyzy{xyvuuwwwuvsyzywyzzywvxxwwyy{y{yyzzyxxyvxzzyyz{z|xztyxzwvvyy||{wxy{}|s}~{|{}y}|}x}}~}|{}~}|||}}~~ƒ~z€‚€ƒƒ|‚‚~€‚‚‚ƒ‚ƒ„†‡„}„„††„‚ƒ€ƒƒƒ}„„…„‚†‡…ƒ‚…„†„ƒ…Љ‰‹Š„‡ˆ†‚ˆ‰Šˆ‰ˆ‡‰Š„‹‰‹‡‰‰ŠŠ‹‹Š†ƒ{~triiidZVRQJHB?:81-*+*))('''&%&'&$$%%!!!!! RRSSQOPPNQRRPPQRPOQSSRORRQQRSSSSSUUSRRTUUTRTTUTRRSRUVVVVUVWVSRTTTVWWTUUVWVUWXYXWVWVUWWVVUTSUVUUVVVVXWWTXWVWVURI9' + + + +'2>IQY_bdffhhgccchihjljghhjklljhjjjjkkkjlonmlljmnnmnoplnnnorssqooooqrsssprrtsssrtvuvuuuuuttuvutuuwwxwvrtuuxzzzyyxxyxxxxxxxxwwxxyxxyz{{xxzzxvz|{zzzyxxvuwyuwxvx{}|{||{{zzyxx{{{||{z{}}}}}||z||~}y}}~~€}|}}}~€~€€‚‚€ƒ‚€€ƒ‚€‚€‚‚ƒ„„‚‚‚ƒƒ…††„„…††…„ƒ…†……„ƒ„ƒ„ƒ†‡‡‡†„„„†‡†…„‡‰Šˆ‡‡‡ˆ‰……†‰‹ˆ†ˆ‰‰Š‰‰Œ‰Š‰ŠŠŒ‹‰†…|vrqpje`[VRNJGD@=96420///.-,,--,+++(&''&%%&%$#"!!!"!! !! RQRRPNPQQRRQOOQRQOQSSQQQQRRSSPRSTTUTRRTTSTSSUUTSTUUVUUWWWUVVUUTQTWXVSSTUWWVSXTWSVWWWXXWWVRTVVTUSVVWWXXWWWWWTTO@- 6I5! + + "4AKSY`cfhhfddhjgikjeiijhkkiglkllkhjkkmnkmklnnnnmopqonimorsroopqqqprsssrqrrstuusquuvwuqtsututvwwvvvuttvyuyyxxytywxwyzxzzxxyywyz{|{yyyzzzw|}{zywzsxvvwzwwuwy{{|}|xz{||{{{z|w{{|{|}}||}~z||~}z}~}|~€€}}~~{}€‚€€}€€€‚~}|~€‚€‚ƒƒ„„}~‚‚„……„ƒ€†‚‡„…‡…‡…†„…„…ƒ‡†ˆ‡‡ƒ„†‡ˆ‡~ƒ‚‡‰ˆˆ‡†ˆˆ‡…‡‡‹ˆˆ‰‰ˆ…‰ŠŒˆŒŒ‹Š‹‡ˆ‡„€xrtqnfdb]UTSPHEB@?=964321012220-0.,++**))**%&&&!&$###$%"!!!!""" PQQPOONQSRSQOPQRRQQSSSSRQSSRQQRUTUUTQUURPTUTUTRTUUVUUTSWVTTVVUUSSUUTRRSUWWVVWXWVUVTWXXXXXWWXWVVWXXXXXYXVXXWURI8% 3POB)" "-8DQY^dhfdehjhgjjjiiklkjijmonlkjmnmmnnmmmmmnnnnqqqnmmpppqqoprsrqqrssrrrrqttsstttvwtsssuvuttvwuvvuuvxyywvwxxyxxyz{{zz{{yxxyyz||{zyyxy{|}}{zzzxxyzy{|ywxxyzyy}{wwy{|||{y{||}}|||~~~|}}}~|y}}}}}}~~~~€‚ƒƒ€~€‚€€€€‚‚‚€ƒ„„†ƒ‚ƒ‚ƒ„„……„„…†…†‡†‡‡†‡ˆˆˆ†††ˆ‡ˆ‡ˆ‡†…†‡ˆ†„„†ˆŠŠŠˆ†…‡ˆ‡‰‹‹ˆˆ‰‰‰‰‰ŠŠ‹ŒŒŒŽ‰†€spvxtpliea^ZVROLIHFCBA?>=<=?=;666666655420//00.,,+*)**)''&&&&&%######" PQQOOOPQRRRQOPQRSSTSSSTTSTSQRSSTTUUTSTTQRTUTTTSTTSTTTSUVUSSTTTUTSVVSTTTTWUVUUVVUVUVVVWXYYXYYWVVXXXXTXSVUWWVTM?, +8EA7*&# &0>HRY\]chhgfijgkklnljjjklmnnklljimnmmmkmkmlpqrrpnprqkrsqruusrqqqqstsrqrrpttsrvvusssuusrtsxwvtutvvwwywxvzxxxz{|zxt{}zvyyzxzzzz{zy{|}|yzx{zxtzzzw}xwyz|{zzzzxwvyz{v{y|}}~x|{|}~{~~}y~|y}}}}€€~~y}€}€‚|‚‚€{€€}ƒ‚ƒƒƒ‚€€ƒƒ…‚………„…„„……ƒ„…„ƒ…„‡††‚ˆŠ‰‡ˆ‡‡ˆˆ‡…‰‰‡‚†‡†‚†‡ˆ‰Š‡‡‡…†‰‰ˆ‡‹Ž‡‡ˆŠ…‰ˆ‹ŠŽŒŒŒ‰ŽŠ‡€xt~}|vtkigda^XUQONMKKJIIHDFFEDA?>=>>=;;;987678631////0/****+**(('#((($! !"##" NPQQNQRQPPPPPQQRTTTSSTTTSTSRSTTTSTTSQRSUSTUUTTTTRRTVTSTVUUUSRTUUTVVVVWVVWWWURUUXXUUUUUWXWWYZVUWXVWWWVTTUVXVSF2181'&%$%%" + + + )5@JU]dfefhikkllmlijijjjnnlkijjkllnonnlmoqrrrqprsqpqrssttsrssrqstssqrrrsuvwwvusqtvvuuuvwxvvvwuswxyyxyyyyyxyzxwuz}zyzzzyyyyy{{{|}}zzzx{zyz}}{{|zyx{}}z{yyy{{{|zyz}~€}{|}~~€€€}|~~}z}|||€€€ƒ‚€€€‚ƒ…„……ƒ‚ƒ„ƒƒ‚„„„„†††……‚ƒ„„……„…„‚…ˆ…„‡‰ˆ‡‡‡†ˆˆˆ†‡‰‹ˆ‚„…†‡ˆ†‡ˆ‡†‡ˆŠŠ‰ˆ‰„ˆŒŒŠ‹‰†‰‹ŠŽŒŒŒŽ‹Šˆ†ˆˆ†ƒ€|vpmkifc^ZXXWVTTTRQPOONMMLIGHHGGEDDDBA@@=<<::989754443310/.,,-,+*)))))(%%&''%###"! !!!OORSQRSNPQRRRSSSTTSRTTTTTQTSSTUSTTUSRNRTTTTPTSTTSQUVVUUSUVVTTUVTUVUQVVWWXXXWWWXYYVUVVUTUVUWYXUXXVWWWUUUVWWSL<$&%"!"!"" + + +-9FQX_cfggjjkljijkkjlnlkjijkklloppolnoomrqpnqqnjorsprqqrrttrrsrrssssrovxwwwtttvwwuvvurutxywtwwzuttxwzuwvywxwxzyx{{{{zyxvz{||}|zy{y||z{}}{xyxwxz{}{|yz{}~}z{y||€€~x}}~~~€y€~|}z~|~~‚€~}~~~€~ƒ€‚€‚„††…„‚„…†„ƒ„…€ƒ€…†‡…„………„†ƒƒƒƒƒ‡€†„…„„…„…‰ƒ†ƒˆ‰ˆ…†ˆ‡Š‡‡„†‡‡‡‹‹‹ˆ‰ƒ‡‡‰‰Œ‡‡ˆ‹Š‹ŒŽŽŒ‹Œ‹Ž‹ŒŒŒŒŒ‰ˆ„„|wtrongdaaaa[[\\YYXVTTUTRPNNNMLMMMGKIHIFCCBA@?A?=<;;:976761120/.-/0/-,*++*)(&&%&&$"#$PORRQQQPPRRRTUTRRTSSTTSTTTTTTTTTSTVVTQQRQTSTUSSTUUVXXXWVTUWVVXWVVVTQTWWWXYWYYYYYYVVWVWVTVUVWXWWWVWWWVVVWWVNA/ + + + + + + "3?LX`bdgiflkhilmnonklkjkmmmmooonlnpoppqpnonlimstsrrrrpqsuttuvusttqntutvwxvtswwxxwtstuxyxxz|{zxwy{{{zzzxxxxyzyz{||{zxvz}|{|{y{{|~~|{w{ywyzvxzz}|{xz~~{|}~~~~€}x}}}|€€{|~€~}€€€€‚ƒ€‚ƒ‚‚ƒ„~„†ƒ„„‚‡‡„ƒ„„…„ƒ„†ˆˆ……††††‡‡†…†‡‡‡…ƒ…………„„‡ˆ‡‡‡ˆ‡†ˆŠŠ‹‹Šˆ…‰‹ŠŠ‹Œ‹Šˆ††‡Š‹‹‰‹ŠŒ‹ŒŒŠŒŒŒŽŽŽŒŠŒŒ‹‹ˆ„€~|zwspnlihhggdcdec`___]\[ZZZYYXXVTTSRPNNMLKJJIHHHGFDCB@?>=;:99:::864210110.-,,+))**OOPPPOQQQQRSTSSQSSRSSSTUTQSSTTSRTTUVUSRQTTTUVSSTUUVSWVVVUVWUXYYXWWURUVWUXXXWYWWXYUWXYYWTWVVVVVVWWWXSVUUUTSG5% + + + + +=FNT[bfjjiigmnpnnnmjlnnnnmollmppooooooommlpuuutosnposttpvtssssrossttvqvtvwwuyxurutttyz|{yvyyz{||{zzxvwwxzz{{|{zyxw{}|u{|{zzz|}|{ywvuz|{{zy~}|z{~€|~|~}}|||~x~y{|}€|{|}|}~€~}}€‚ƒ‚‚~€ƒƒ‚ƒ‚……„‚„ƒ„…‚~……‚~ƒ…‡‡†„…††ƒƒ„‡„ƒ„„„†‡ˆ†…„……ˆ††„…‡‡…ƒ‡‡‡†ˆ‰ˆ…ŠŠŠŠ‰‰Š…‰ŠŠ‹Š‰Œ‰‰„†‡‹Š‹ˆ‹‹ŽˆŒ‹ŠŽŽˆŠ‹ŒŒŒŠŠ‹‰‡†€|ywqqommoqninnmjhhhhfcaacbaaa\\][ZXXVTUVTSQQQPPOLJIHFEECCCC=BBB=:75457654210//..PQQPNOQQOQRTTSSTTTSSRRTVTPSSSRRTTSTVUSSTTTSTUTRTUUUVUUTTTWWXXXYYWWVVUVVWWXWVWXYZXVWZYYXWWXWUTVWWVYWVVUTUTN>* + + + +!*8CNYbfiijkmnonmmllnnnnnnoooppmnponnoonprvvvtsrrporstvuttsrrstsrsutquwwvvxxvuvvvwxy{vyxxxxx{||yyywwyyyyz|~}xxyvy||zz||{yzzyzzzyyyz{|}}|}}~}||~~}~|€€~~~}~~~€}{|~z}|~~~~}~}€„ƒƒ‚€€‚ƒ………„ƒ„…„„‚~ƒ„‚„„…‡ˆ‡†…„„††………†‡…ƒ†…†‡‡‡‡‡ˆˆˆ††‡ˆ‹Š…„ƒ†ˆ‡†ˆ‹Š‡Š‹‰‰‰‹ŠˆˆŠ‹‹ŒŒŒ‰Š‰ˆ‹Œ‹‹Š‹‹ŽŽŽŽŒ‰ŒŒŠ‹‹Š‡…ƒ{yxyyzzzwvvvwvttsrsrolmnmkiijjigffecbb`]]^[XXZXWVTSRQPPPMLKJJIHFDCDDBA@=;:8888RRRPPOOPRSTSSTUUUSSSSRTUTQSRRNRSSRTRVTSSTPQOUSRRTUUVUSUWWXWUVUVVVVWTTTVVVVWVUUXWYXYZZYYYXVVVUWXWXYWUVUUVPE4 + + &9FQZ`egimnmlmlmlmlkknnoknqpopppooppprtvvuqsrrqppvsuuurqqrttrsuvqtwwtvxwtvswwy{zxxwzzzwxy||yuxwzzzxww{}wyyz{{yyy{{{z{{zvyzzx||{vzx|{{|}z}{}}|z€|}~~~€z{z}{~€}}|z~}€€{ƒƒ‚~€‚„„€ƒ‚‚‚‚„‚„††…ˆ‰‡………ƒ††††…††ƒ„ƒ…‚††‡‡‰†ˆ…‰‰‡†Š…„„ˆ…ƒƒˆŒ‹ˆŠ‰ˆ„‡‚Љˆ‰ŠŠŒŒŒ‰Š‹‹ŒŠŠŠŠŠŒ‰ŽŒŽŽŠŠ‹ŒŽŒŽŠŒŽŽŒŒŠ„…}}|}}€|||{{zzxwwwzxxpsrrrppqqrlnomkjgidfge]_a`_``^\[ZZ[YXURQQQPNMMMLLJDCA@?>?RSRQQQPRTTTTQTVVUUTRRRSSSSTSSRRRRSTUVWUSUTSSTRRSTSSUTSUWXYWTSTUUTVWUTVVVSUVUWXXVYYYYYZZZYWWXWWXYYXVTTTSTK9" "$" "1?KU^diklmmmlllllnopommqrqqsrqqrqppsuvtrtusqsuustuttsqpstuuvvtrwvuxyxxxtwwz{zxyz{{ywwy{}{xxxzywwyww~~{zzz{{xz{{{z{{|{xx|{{}~|zyyzzy{}}|{{}}y~|y|}}}~}}|}|z}‚~}}z~€‚€|€‚~€€ƒ„‚ƒ„ƒ‚‚ƒ‚„‚…‡‰ˆˆˆ†…ƒ€„†…„……„†‡‰‡…††ˆ‰‰ˆ‡‰Œ‹Šˆ†‰‰ˆˆˆ‰†ƒˆŠŠ‰ˆ‰‡…†ˆ‰ŠŠˆ‹Œ‹ŠŠ‹ŒŒ‹Š‹‰‹‰ŒŽŽ‹ŽŽŒŒŒŽŒŽŽŽŒŒŠˆ†…………†…„‚‚„ƒ‚‚‚€€€~z|}{zz|zyxwwvuuttutronmmnmmkjhgffeedcb`]]\ZYXWVVSPONNNLJRRRQQRRSTUTSTUTSTVUSRPQRRSTSSTSQSSUUVVUSTUUUURTTTSTUUTUUVUVUTTUTUTWVWWVVVVVTWWYVXWWSYZZYYXXXWWYYXWVPWYVQC- !" + +'5AKT\bgjllilkknpooopqsrrrqpqpqmqstrrrstrppovstruuuqsvuouvvuvwwuxuxyxtuvxyyyzy{yyuvw{}|xyxxxxwzx{~~|zzyv|z|}|w{x{{{xy{|{}|~}|{{yzx}}{y}~z}}z{{{|||}y}~|~{~}€~~~~€€}€€‚‚€€~ƒ„„ƒ}„‚„‚‚€ƒ‚‚„‡‰ˆ‡„„€€€…‡†„„„„…†ˆ‚‡…‡ˆ‡†‡„‰‰‹Šˆ‡‰†Šˆ‰‰ˆ††††…‡‰Šˆ‡‰ŠŠ‰‹‹Šˆˆˆ‰ŠŠŠŠŠŒ‰Ž‹ŽŠŽŒŒŒŽŽŒ‹ŽŒŒŒŽ‹‘ދЉЋ‹†Œ‹Š‡‡‡Š‹Šˆˆ……„„…„„„„„……ƒ~}z|~}y~~yyyvuusrrrqpoopnfmmjggbbbaa^\[[XUWXUSPRRQPSTTTSQRTURQRUVUUSOQRRRTSSSUUTTUUVUSSTSVVVUUUTPUUUUTTUUVWWUTUVWWWWVVWVVTVXXXWWWWWZZZYXXWWYZYXZXWYZUK9$ !!"#"! + $4COYagjlkijnnmooqrsroqoprsrqrssrrsssrptuuvuuvxuuvwurtvuuuwwwwuxzwvuuuwxyzyz{zxyz{}}yywwwx{zz|}{{zyxz{|||{zzyz{{yyzz{|~~~~~|z{|}|||}~~}{y{~~|~~}}~€€}~~€€}€}€€€‚‚‚€~„„„ƒ„„……„ƒ„„ƒƒ„…‡†„ƒ„ƒƒ„…†‡††‡††…†ˆŠ‰‡†‡‡‡††‰Š‹Œ‹‡‰‰‰ŠŠŠˆ‡ˆ†ˆ†‡‰‹ŒŠŠˆˆ‰‹‹Š†ˆˆ‰ŠŠŠŠ‹Ž‘ŽŽ‘ŽŒ‹ŒŽŽ‘‘ŽŽ‹‹ŽŽŒŒŒ‹Š‰ˆ‡†††…„„†‡‡†…„„„|{|~|yyxvttvttrpponllkkifcdecaOQRRSTUTSPQRTTSRSSUVVUSRTOSTTTUUTSTUVUUSSSTUUVWUUTTUVVVSUUTTWXWWWUUUWWXWWVVSWXVRWVYXWV[ZZXYWXYYZ[[XVYXO@- # #%'& + + + +/:FS\bdehknlonoqqpprrqsutsttssstsqrqsstuvuuvvvvuttuuvwwwwxxuyzxwwtuuxz|yzyywz{|}|yyvvtuwyw{{||zyyz{}}yzxxxyy}{zzyxzz{{}z|x{}}{}~}y|~~|}}}~€|}~~}}€|z€~€€~€|€~~„€„‚„€…‚„„‚………„…„„„‡„„ƒ†ˆ†‚…ƒ‡„ˆˆˆ‰Šˆ…†‰ˆ‡††…‹‹‹ˆ‡‡Š†Šˆ†„ˆ…‡‡ˆ…‹ŒŠ‰…Š‹Œ‹‰ˆ‡†Š‰‹‡‹‘‘ŽŽ‰Ž‹ŽŽ‰Œ‰‘’‰ŽŽŽ‘‘‘ŽŽŒ‘““’‘’’’Ž‘’ŒŠŒŠ‰‹Œ‹Š‹‰ŠŠŠ‡‡„ƒ‚‚‚}}z{|~~wxywuvwurnlnomkPQSTUVUTSQSUTSQRSRTUUVUUUTTUTVVUTTSTVWUTTURVVXWWVUUVVVVTVUTTUWWYXWWVVWYYVVVVWXWWWXXXXZZ\[[ZZYXWYZZXVWTE1 + "%&&# #%$! + + + + 3BNU\djlnnooppppqssstttuttttusssqsrrttsrtuuttruwwxvwyyxxyzyswwwxxxz||zyzz{{{{z{yuxyywyzzz{||{zz|}|{yxz{{y{}|zyyyz}€}y{~|||}~~{yy}~}|~~}€€€|~~~~€€‚€€~ƒ‚‚ƒ‚ƒƒƒ„…„†…‚„…†††„†……†ˆŠˆ†‡‰‡„‚…ˆˆ‡†ˆ‰‰„ˆ‰‰‡††‡‰Š‰ˆ‰ŠŠ‡Š‰†…ˆ‰‰Šˆ„ŠŒ‹Š‹ŒŒ‹‹‹‹‹ŒŒŠŠ‹Š‘ŽŽŽŽŽŽ‘‘Ž‘“”‘’’’’“’’’“’‘“””‘”“”””•••’‘‘‘‘“““’““’‘‘’ŒŽŒŠˆ‡‡‰Šˆ††‡‡‡‡†„ƒƒ‚€~|{z{yxQQRSTSTTTRTTTSPORRSQTUUUVUTTUUURTTSSVWVTUVVUUVVVVUUUVWWUUUUVXXWXXWWTVUXXWWVUWXXVWWXVWXZW[ZZZYVWWXXWVSK: + "%')+)% + + + +")6@LV_fiinoopooqqqrtuututuvuuuqsrqrtpstuttstvxyzwvwwwy{{yyxxyzwxyztxyxy{z{{{|{vyyzxyzywz{||{|}{{{{z}{{yzw}{zvww|€z|~}y{z}{}{{|}~~}}y~~|€}€~}~}}}€€€~~ƒ„„‚€„„„…„„…†††‚…„…ƒ„„ˆ……ˆŠ‰‡ŠŠ†‚†ƒ…†ˆ………‰‰ˆ‰Š‡‰†ˆˆ‹‡‡†Š‹‰…‰Šˆ‡ŠŠŠ‹‰„Š‹‹ˆŒ‹‡Œ‹‹ŒŒŽŠŒŒŠ‰ŠŒŒ‹ŽŒŒŽŒŒ‹‘Œ‘““’‘”””“‘Œ†Š”•–“”“””–˜—‘•”•––——’•–”••••”•’”“ŽŽ‹ŽŽŒŠ‹ŠŠ‰ˆˆ†………„~ƒQQOTTQSUTTSRSTOQQQSTTVUUVUSQOPRSTUUVWVVVTWUSSSSUWYXVWXWWXXVVXXWXXWWWWXWVVXUVVWVUVZYXZZZ[YXW[ZWWWXWWUN@+ + #&''*+*'# + +%7FS\ejmkoqpopnqsuuuuuvwvuuuussuuuuuuwvruvy{xvuvuvy|||{zyyywxzywvxyzyy|}|||zxxywxzyvy{||{||{z{{}~~|y{|}||{ywy}~~||||||~}}~€€€€€~€‚€~~€~~}€€€€ƒƒ‚ƒ„……‚„„„„†…ƒƒ„„………„………„„……‡‡……‡‰ˆˆŠ‰††‡‡†‡ˆ†„‡‰‰ˆ‰Šˆ‰‹ŠŠŠ‹Š‰Š‹Š‰‰‰‰Š‹‹‰ŒŠŠŠŠ‰‡ŠŒ‹‹Œ‹Š‹ŽŒ‰‰ŠŽŽŠŽ‘‘‘ŒŒŒŽ‘‘‘’’’’Ž’““’“’’}€ˆ“”–˜–••——™–”•˜˜——˜——˜™˜™™™™™˜˜––˜™šš™——–••““–˜”““’’’‘ŽŒ‹ŠŠŒ‹‹RRSTSORTTTSSSSRQQRSUVVUUUTQJHGJLOSUVWUUVWWVSSTUVXYXVWXWWVVVUWTWYXVXXWWVTUXYXXXWXYZZXZ[[YXXZ\[XXWXWUTH3" !$&))')&))'!!! + +!.>JU_dkpqppporquutuvtvrtvvtuuwvvvuvwswuwwupvvvwy{{||wzxxwyxywwwxwyw|||{|zxxzxwwzxzyyyz{{{|w|~~||z{{zz{{{y|}~€~x|}}}~~~€€€€€}|{€‚|€~~~‚€„„ƒƒ€…………„~ƒ‚†…„„€……„…†…†€†„„ƒ‡ˆ‰ˆ‡ˆŠ‡…†‡††‡‰‡‡‡ˆ‡ˆˆŠˆŠ‹Š‡‰†‹‹Œ‰ŒŠˆ‡‰‹‹ŒŒ‹‰Š‰‡‡‡ŠŠ‰‰ŒŒ‹ˆŽŽŽŽ‹ŠŠŽŽ‹ŒŒ‹‘ŽŒŒ’’’‘’‘’‘ŽŽŽ•‘’’Ž‹’””––•””“•–•”–’˜––”™–š˜˜šš™›˜š˜˜—››Ÿž™œ››˜˜’™›—”———˜˜“‘‘““Ž‘‹RRTTSPPTTSSSQSSQRSTTVVUTSROLIF?AFMRVWWWUVWUTTUVXYYXWWWVVUVVVVVUXXWYZXWVUTWYYYYXZ[[XXYZZYXXZ\\ZZYYXUP@* $&*,+))(*+,+)'$" !"!! &5EQ\ekmmqrsttsptutuvuwwtvwwuuuuvwxwxuttvxxwwyzzz{{{yyx{zzzxxyzzz{zy}|{xyz{yvyzzzzzx||}|{}~{z|~|xxyz||}}~€}}~}~€€~€ƒ‚€€€~ƒ‚ƒ€€‚„„„„ƒ„…„ƒ‚‚„†……‚‚ƒ„……„„ƒ„…††‡‡‡‡ˆ††……†ˆˆ††ˆˆ‡†…‡†…‡‰ˆ‡‡‡ˆ‰‰Š‹‰‰‰‡ˆ‰ŠŒ‹‹‹‹‡†ˆŠ‹ŒŒ‹Š‰‰ŠŠŒŒŠ‹‰ŒŒ‹‹ŠŒŽŒŽŽŽŽ‘’‘‘’‘‘’‘“““““’“’’‘‘‘‘‘’””‘’“’‘’““”•••••”’’’““”“”——˜˜™š›™šœ›˜š›š˜›šœœžŸžžŸœœš™›™–ššœœœ›š˜˜™——–––•RQSTSRRRRRTSSSRQTUUQUVUTSRRQOMH:EFSVWXWVVVUVVVVWYXXYXUVWWXWSXXVXYWXVXUWWWVXWXXYZ[ZYYZZZWXXXYYWYZZYRG6 !%&,/,****,0//.,)'%&'&%$" !,8FQYaipqqqqrtuqtuvwusvxvuutwwvuvwwuxwyzwvyyys||{xxx|}{zzz{{zyzyz{{{{{zz{wxyyz{{||~y}z~}w|}}xy{}z{|}|€}}z}{|~~||€}‚‚}}€~|ƒ‚‚|‚€††ƒ~‚„……ƒ„††ƒ‚ƒ„„ƒ„€€†ƒ……‡ˆ‰‰‡…†ˆƒˆ††…‡…ˆ…††‡ˆŠˆ‡†‡ˆ‰„‰ˆ‰†Š‡ˆˆ‹‹Œ„Šˆˆ‡‰ŠŠ‹Œ‹ŒŠ‹ŒŽ‰‹‰ŠŠŒ‹ŒŠ‘’’‘‘’‘’’Š–“•“““”“•“““’”‘“””“”‘‘‘“’Ž‘“Ž™—š›™šš™œŸ™›˜™—˜™œžŸœ›žžž—šœžœ—œšžžœœœœ”š˜›™SQRTTSSSSSTTSQQSTTTTTUUUTTUTTURNNRUWWWVWVVUVVVVVWWXZXVVXYXWWXYVXYYWUXXXXWVXYXXYZYYYXYZXWXXXVTVXZZWM:$ "%'+.,,--.134442/.,,,,*)'" -:GUbhloqrrtsstvwtswyxvvwwwvuvwxzzzz{wxyyyz{}{yxy{}|zz{{xwzxz{{x|}}|{{zyyyy{{|}~~}|}~~}{}~}{}~~|{}|}}~~}}}|z|}}~}ƒ€‚€|€€€€‚‚ƒ†††ƒ~ƒ„…„ƒ„…„„„„„„ƒ‚„ƒ‚…†ƒƒ„…‰Šˆ…ˆ‡‡†‡ˆ‰‡†ˆ‹Šˆ‡ˆˆ‰ŠŠˆ‡‡‰‰Šˆ†ˆŠŠŠ‹ŒŽŽŒ‹Š‰Š‹ŒŒŽŽŽŒ‹ŒŒŽ‘‘ŽŽ“’’‘‘‘‘‘““Ž“–˜–“Ž‘”••”““”“””••“–——–•”•••–”’’“˜šœœ›˜˜šš žœ™™š››Ÿ œžžžžž››œ ŸœžŸžŸœœŸžžSQSUUSRRRSSTTTTTTRSSSTUUUVUSVVVSTUVUTUTUXXVSVUVSTUWXXWVVXXWVYYWXYWVUXXYYXXYZZYZYYWZZZWVWXWXVVUWZVRD- !$%'))+.001233333200/0.,*& + + + !3@LW`gjoprtvvvvuyzwqvvvvvuxuxwywyzyyyxzzyz{z{zz{|yzz{xy{zz{z{}}y}||}~~|u|y|}~~z~}}}{z|}~~}z~z{z}~}}}y~~~€€~€€}€€€~‚ƒ‚‚……†‚‚‚|ƒ‚‚ƒƒ~……„ƒ‚ƒ†…ƒ‡‡‚ƒ€…‰ŠˆˆŠŠ‰ˆ‚‰ˆ‡‚ˆŠŠ‹Š‰‹†Š‹‹‡‰‰ŠŠŠ‡‡ˆŒ‹ŒŽ‹Š‰Œ‹Œ‹‡ŒŒŠŽŽ†ŽŽŽŽŽ‘‰ŒŽŒ‘‘’‘‘‘Ž‘““‘‘”–––’‘‘‘“•••—‘’“““”—™™˜–“˜•——–Ž’‘““‘’›œ—˜—Ÿ›œžŸŸ™››œ• žžž¡žž ž—œ›ŸŸœ šŸšŸžžžRSTVVTRROSTTUWWVUTRQRTTTUVVVVWWVVWVSOTUWYYVUTVVUTVWWWWVVWXXYZZWWWWVWWYYZXYYZ[\[\\[[[ZYYYZZXWVUVXSH7# ""#$&*-011023256652112/+(#! + + + #5BNZekotxwuuvxxvtvxwxxxyzxwwwwxyzxyyyxxy{{zxyz{{zzzzzzyy{|}|{|}~~~~}}}z}~~~|~}~~}|{}}~~~~~~~}~~€€€€€~|}~}ƒ…ƒ‚‚ƒƒ„„ƒ€€€ƒƒ„„„„……ƒƒ„†…„‡‡…ƒ„†‰‰‰Š‹‹Šˆˆ‰ˆ‡‡ˆ‰ŠŒ‹‹ŒŒ‹‹‹ˆ‰‰‹‹‹‡‹‹ŽŽŒŒŠŠŒŽŽŒŠˆŠŒŒŽŽŽŽ‘’ŽŽŽ‘‘‘“‘’‘‘‘‘‘’‘’””””’‘••’“”–˜–”““’”–––˜˜˜™š˜–™›™˜——–—–•–˜šœš›Ÿ™šŸŸžŸ››œœ ¡ž ¡¤¡žœœŸŸ›žŸ¡ŸšžŸTTUVVVSSSSTSTVVTSTSRRTUUVWVVVUWWVWVSSTVWXWVUUVXXUVVUUUWWWXYZZZYXWXYYYZ[ZYYZY[[[\\\[ZZZ[WZYXWWVWWM=* !"!!"%)--/0..22666652332*)#" + + + + $9HT]gosutqvwwtvuwwxyzyywxwxyzzxxxxyyz{zzzyzz{{zw|{{wxyyz{{}~}yyy}}~yz|}w|}}z~xxy||~}~€€€~}~y€~{~€€}||~~‚€~~‚ƒƒ}ƒ~‚ƒƒ€€ƒ‚ƒ~ƒ…ƒƒ…††ƒƒ‡‡†……„†ƒˆ‡††Š‹Š‡††ˆˆˆˆ‰‰‹ˆ‡‡ŒŒŠŒ‰‰‡Š‹Š†‰ŒŽŠŠ…ŠŽŽ‹‹‹‹ŠŒ‰Œ‹Œ‘Ž‘‘Ž‘‘ŠŽŒ’‘‘Ž“““’““’“’Ž“’”——””’–˜–‘–——–˜–—‘˜—˜š˜–š“›˜˜—————š˜ššœœ››œ•›™›žœŸžš›š›Ÿ ˜¡ž¡Ÿ¢£¡žžžŸŸ›žžž¡› ¡¡TSTUVVSTRRSSPTUSSSTSSUUVWWVUSSUWVVTTVXXWUWWWUVYYWXXVVXXXVXYZYXXYXXZZY[[ZYYZ\[[[ZZ\[[[\[ZZ[[YYYXTE/ + !!$#"!$%(+,./0013554689994.)%$"! ""! + + + +%/=KYdlopsuuuuuwvtxxxwvxzzxyxxyz{z{||zz{|{z{zzy|~|||||{{}}}}}zy{~}|~€€}z|}}~~}}||}|}€€€~~}|}~}}~€‚|}|}}€€€‚‚ƒƒƒ~‚ƒ‚„„„………ƒ‚„†……„‚…‰‰‡††‡‡‡‡‡‡‡‰‰‡‡ˆˆˆ‰‹Š‰ŠˆŠ‹‹ŽŒ‹‹ŠŠ‹Ž‹‹ŒŽŽŒŠŠŒŒ‹ŒŒŠ‹Œ‘Ž‘•“ŽŽŽ’•““•–“““”’‘’’‘’’”––˜––—˜–”—™š›™–—’—˜—˜™˜™››œ™˜™———šš™™œ›››™—˜šœžŸžž žž¡¢ ¡¢¡ ¡¡ Ÿ Ÿ ŸŸ££¡¢¢¢TQTTTSUUTSUURRUTSRTRRTUUUSWVUTVVVVUTWXXXXXXXVSXYXXWWWWXXWXYXXVVTYYYYXYYXYYZ[Z[[XYZ[[\\ZU[[[XXXVM;! !$%'&&'(('**-/0/0331138;=?90+&%%%$" !#$$$"!" + + + $2ANYaglprtuuuwxxutsxyxuvuxzzv{x}{zx{{}{zyzz}{|}}}}yz|}{||{yzz|}€€}}}~~~~|~}€~}{~|~{~~~~~~‚‚}€~}~€{~€„ƒ‚‚|„„€€{‚‚‚ƒƒƒ………†……„…‚„‚„†‰‰‡‡‡ƒ‡…‰‰‰‰‰‡ˆ‰‰‡‰‹‹Š‰‡‹ŠŠ‹Š†ŒŽŒŠ‹‹ŒŽŽ‡‹‹‹Ž‹Œ‹‹ˆŒŒŒŒ‹ŒŒŒŒ’’’’‘‹’“”ŽŽ“”•‘””’’”Ž”’‘“’••—˜—””’‘‘™•™š˜—˜’˜˜˜˜™”™–›œ™“š™˜—˜•™š››˜˜—š›œžžž¢¢ ¡¢¢¡¡¢¡Ÿ¡›¡¡ ¡¢¡ Ÿ ¡¤ ŸŸ££TSSSRQTVVVUWSRUUTTTSOTUUUVVVUUVUUWWWXWWWXXXXVWXZVWWWWVVVWVVVVVUWYZYYXWUVXYYYWZ[[Z[[[[[ZYZ\[VWXQC, "&')*****+**,.-/.221369>@A<3-''&&%#!"#%&$$"""$#! !"#! + + + '4BP_gmqsvwxxvuuvxxwvuuwxxz{}}}||z{}~{zz||zz|{{|{z}}{z{||{yy|||x~}~}|~~~€€‚~~~€~~|€€‚ƒ‚‚|~‚ƒ„‚€„…„‚‚„„‚„„ƒ…†„……†………ƒ„ƒ…„‡ˆ‡‡‡‡‡‰‰‰Š‹Šˆ‡Š‰ˆ†‹‹‹ŠŠ‹ŒŠ‰‰Š‹Œ‹Š‰‹ŒŒŒ‹‹ŽŒŒŒŠŒŒŒŒŽŽŽŒŽŽŽ’“”“’’’‘““‘’“‘‘‘’“’”“’“””•“““•”“’“”•–––—––•”–™˜——–”—™š™˜˜—™š™ššš—˜™™ššš–™›œœš—šš›žžžž¡ ¢£¢¡Ÿ ¡¢£¤£¢ ¡ ¢¡ ¢¡¢¡¤£¤££¤££TTTQQRUVWVVVTRUVTRTTUVVUWVVRTUVUVVWWYSUUWWXSVVXYXVWWWUVWWTSSWXXXZYYYYUWWXWYYY[\][\][YXZZYZ[VWUK8# "&),---..*,+../1244056<???93,&'%(&$"$%'(&%%$%&&%$! !#" #%# 0ANYajnrtuusuwxvxsvtvwyz|zzy||zw|}{zzv|{yxzzz{|}}z{}~{yy}}~~|{|~~}€‚€~}~~|€~€€€‚€€€|ƒ€}€‚‚€‚ƒ„ƒ~€~„€ƒ€‚‚‚„„„ƒ‚„„‚}ƒ…„„…………†‚„†…ƒƒ‚‡‡‡††††‡‡‡†‡‹ŠŠ†‰‹‹ŠŠ‹‡‹ŒŒŠŠ†Š‹Š…Šƒ‹Š‹ŒŒ‰ˆˆŽŒŒ‹ŒŽˆŽŽŒ’Ž’’Ž”’”““’’’”Œ’”“”•–””’”–“””””””“——˜“™˜™™™‘’“š››–˜———š™˜—˜™š™š›—ššœœœ———›Ÿžžžœ£¢¢£¤¤¡Ÿ ¡£¢¤Ÿ¡ ŸŸŸŸ ¢£¢¡¤££¢¡££ŸTUUTTUUVWVRTTTUVUUSUVWWVWWWVUSTUUXVVVVWWXYXVTSSWWVWWWVVWWUUUXYXXZ[ZZYXXXWXYYY[]][[\\YXYYY[[WVQA-!&+024441.-/012456789:<>=:5/(%(+*'"#')**(&&&%&'('''))($!!! + + (7DQ[cjptuuwxzxwwwwxx{|{zz{|yvy{zz{{||yxz{zz|~}||~~z{}~~}~}|~€ƒ}}}€~‚€€‚ƒ‚ƒ‚€~ƒ‚€‚…„……„ƒƒƒ€‚‚ƒƒ‚„……†…„„ƒ‚„„„„„‡‰‡ƒ…††……‡‰‰‡†ˆˆˆŠ‰‰‰‰Š‹‰…‰‹ŠŒŒ‹Œ‹ŠŠ‹‹Šˆ…ŠŒŽŒŠŽŽŽ’‘ŽŒŽŽ‘‘‘‘“—–•”“’‘’•”““”””‘••”””–˜–“””“–—•“—˜™š™˜™œ™——šššš›™˜™šš™™™™™š›œžœœŸ˜œžžžŸ ž ¢£¢¢¢££¢¢ ¢¢¢¢¡¢¢Ÿ¢££¡¡¡¡¡£¤¢ ¡¢£UVVVXXVVVTQRUUUTUVVVWWWVWWWXWVUVVWWRUVWWVWWWRKHGLRVWWWWTWVVVWYYYZ\ZXZZXVXYYXY[[[[XY[[YYZ[[ZWQF5 #(-02552-/0223568:;==<==52)($+//($"&))'('%"$$&'('.0/-*&$! +%7BNYdkoqvxxxxtvsxz{z{|||ztvxyy{||xyy|{{zzy}|}}|y|}}z}~~~€€}x~€}}|€€€ƒ‚‚ƒ‚|~ƒ…„€‚€ƒ„„„„€‚~~ƒƒ„…„„…†…ƒƒ€€„…„„ˆ‡‡„†‡‡…‰‹Š‡††Šƒ‡‰Š‰ŒŠ‰‰‰…ŠˆŠ‹ŒˆŒŠ‰‰Œ‹†……ŒŽŽŽŽŠŽ‘ŽŽ‘‘ŒŽ‹Š‹Œ‘‘‘ŽŽ“––•“‘Œ””‘‘”“””””•‘—˜–“•’–—–’—˜™–••™—š’˜™š˜š›š–›››”š››››˜œ“œœŸžŸŸž™žžŸžŸ Ÿ›žžŸŸ¢ Ÿ ¢£ ¡ŸŸ ¡›£ ¥¥¥¢ ŸŸ ŸŸ œ¡ŸUVUXXXVTTSSUVVSTTUVWWXXXXWWWYYUWWWVUTVWVTVVVNC007KUYYWWXWXXWUWXYXZZXZZVVWXYYX[[ZZZYZ[ZXZ[[YVJ9' + #%)-031./002237:<>ABBA=81)'(/52+&"$&'('&%$##!$(-2540,(((%" + + + +#4FVaiptvxxuvvwzzyz{{{{zwwxyz{zzz|||{{{}}}||{|}~|{|~~~~~~~~~|~€~€|€~}~}ƒ„†„‚‚‚€‚ƒ‚~{€‚ƒ„„ƒ†††ƒƒ„‡††‡ˆ†„ƒ‡ˆŠ‹‹Š‡ˆŠ‰‡‡‰‹ŒŒŠ‰Šˆ‰ŠˆˆˆŠ‹‹Œ‹ŠŠŒŽ‹ˆ†…ŽŒŽŒŽŽŒŒ‘Ž‘‘‘‘‘‘’””’“’“““”•”••–””•—••””•–”•”’•———––˜š—•–—˜šš›ššœ›šššš›ž›š›ŸŸ ¡ ŸžžŸ ŸŸž›ž Ÿ ¢£¡ ¡£¢¢¡ ¡¢¢££¥¥¤¢¤¤¤¢¢ ž¢£¡ ¡¢VVWWVWVRSSSUUUTSSTXXWTWXXWWWWWXYXUVVVSVWVVUUM?6,<IUXXWVUWYYWUXZZXVWWYZYYXSYZZ\[Z[ZZ[YZZYZZWQA* " !!'*+,.0121168?ADFEE>71+**483,'#$!%%%$$#$$$$*.46520*++*'$" + + + + + +$3BMWagnrvwxxvxyz{{t||zxwvzz{{|z{{|{{}~z}|||}~}y|w}|||}}~w~}~|€€|~~}ƒ}}|{~}ƒ„ƒƒ‚‚|{‚‚~ƒ‚}‚ƒ††……„‚„…‚‡†„ƒ…ˆŠ‹Š†‡†‰ˆ‡‡‰ŠŒ…Œ‹‹Š‰Š‡‡…‰‰Š…‹ŠŒŒŽ‹‹‰ˆ…ŽŒ‰‹ŒŽŒŒˆ‹‹ŽŒ‰ŒˆŒ‘‘’““‘’Ž‘‘Ž”””””’‘‘“““’’’Ž—“’””•–”——•“““””˜™™—™–•“””˜”›™š›œœœš——˜žžšœŸŸ ¢¢¡žœ ¢ ž Ÿ ž¤¦£œ¡¢¡¢££¢¡£Ÿ¤¤£¡¢¥§¡¥¢¢ ¥¥¤£¢£VWWVVWVUTTTSSTTTVXXXWVUXTXWWRVWYXUTWWWWWWWVTNE?DJSXZXWUUWYYXVXYZXWWWXZ[\ZYZ[[[[ZYYY[Y[[ZYYTJ7# ",.-*&"!#(,/35446;AFFFFF>3/,-1674.)&$#$$$$""$&&',13554430.,)&%%&$! + + + +$2AKWcmruvvwyyyyz{|{zyz|}||{z{{|{{}|{|}z{~{|}~|{|}~}~}€€|€~€‚‚‚„…€}~€~~‚‚‚‚‚ƒ‚‚‚€€ƒ…‚‚‚„……………„„ƒ„…††„ƒ†‰‹‹ˆ…‡ˆˆˆ††‰ŒŠŠ‹‹‰‰‰ˆˆ‰Š‰ˆ‰Š‹ŽŠ‹Š‹ŽŽŽŽŒŽŒŽŠŒŒ‘’”•“‘’’Ž‘‘’““”””“’“““’’“”–™˜–“’“•–——–”•••˜šš™˜™™˜–••”˜››™››š››œœ›žŸŸŸŸŸ¢£¡Ÿ›¡£¢¡¡¡ žŸ ¢¥¡œŸ ¡¤¥¤¢¡¢¢£¥¦¥¦§¦¦§¨§¨§§¦¤££VWWVVRVTTTUSTTTTWWVUWVWYYXXVTVWWXWUVXVWWWWVVSNOPSVY[ZXWUWYZYWUYYYUXWXZZZ[[[YZ[ZVWYY[\\[YYVM?- +47752/+('%###"$(+032248=BDDDD;0,(/57630,%#"$%%$$ &()(/33466641.,*(%&'&#! + + + + $0COZemruwwxwvvxxxz|}}}yyz|{|z{||z||yx~}{~~|}~€{}}~~~}|€€}~‚}ƒy‚€~‚€}‚‚ƒ…ƒ„€ƒ„ƒ…‚ƒƒƒ„†ƒ„„ƒ€„†…†„ƒƒ„…‰ˆ‡„†‡ˆ…„……„‰‡Š„‰‡‡†ˆŠŠˆ‰ˆŠ…‹…Ž‹‹Š‰ŒŒŒŽŽŽŽŒ‹ˆŒŒŽŽ‹ŽŽ‘‘‘“’’’Ž““‘’’Ž’“‘“••””•“‘’”•–——“’’’”––•”•–•˜šš–˜˜™–••–––œ˜˜›š›—œ™™›Ÿ›œœœœœ ¡¡žž¡¢£££œ ŸŸ›¡š¡Ÿ¡¡£¡¢¢¢¢££¤£§¥¨¡¤¥§¡§¥¨¢¦¤£¡XXUVUUVWWWVUUTTUWVVUVVW[YWWWTWWWYYVVWXWVWXXWWWWWUUXZZWVUWYYZZYXXXUYYWYYY[\ZZ[][XWZYZ[[ZZXRD1! (3<>=;866784.*'"##%+/..124<?AA@7,'(078732/*$$%'&%$#%(+/36667763/-+*(%%%#""! )7GWekpvyyxxxywx|}~}|z{|}}||||}|{y{}}|{}~~~~~~~~~}}}€€~~€€€‚€€€‚€ƒ€~„„‚€ƒ„„„ƒ‚‚ƒ„„…ƒ„†††‡‡†…ƒ‚‚………‡ˆ‡†…„‡‡‡†‰Šˆ‡‡ˆ††‰Š‰ˆˆˆŠŠ‹ŒŒŠ‰‹ŠŠ‹ŒŒŒ‹‹Œ‹‹ŒŽŽŒŽ‹‰ŠŽŽ‘‘‘‘‘‘‘’‘“‘’’””’’’’“•”““••••““’’“–•””“”“““•—•“––”‘–˜—–—˜–“•–•˜šœ›››œ››œžœ›šœœ›œŸ£¡ žŸž¡¢£¥¤¡ ¡ ¢§¥¤£ ¢¤¤¤¢¤¤¥¦¨¨§¥¦¤ ¤¦¥¥£¤¥§WWUUTUXWWWVUUSTVVVVVVWXXYTXXVVXWYWWXXXXWXXYYYYWVVVXYXVUUYYXXZ[ZXXUZZYXXWZ[[[[Z[ZZZYW[ZZZTK:! +$/;CCA=5448:;<70,)('***),-0689982)('/899984/*&&&''%$%%,14552453/-)(&&$%!!!! !#$! + + 2ALYdmswxwyuvy||~{{y{{}{|y}}}w{}}}|y{}}|~~}|}~€~~~€€}{€‚~ƒ‚€€‚€ƒ„ƒ„ƒƒ„ƒƒ„…„‚…€†‡†ƒ‡ˆˆˆ…„ƒƒ†ƒ‡‰‹‰†„…‡‡‡ˆˆˆ‰Šˆˆ‰ŠŠŠŠŠ‰‰‡‡‡‹…‹ŽŽ‹Œ‰‹Š‹‰Š‰‹ŠŒ‰ŽŽŒ‹‘ŽŽŽ‘Ž‘’ŽŽ‘“’’““’’Ž’””••‘”“”””‘’”“‘••“‘•˜–“˜–—“˜˜—•—•™’˜˜™šœ–™—œ›ž–››ž›œœ››Ÿ££Ÿ¡ŸŸŸž¢¤¤£¢ Ÿž¡Ÿ¤¤¥¡ Ÿ £ž¢¥¤¤§¢¦¨§£¢¡¥Ÿ¥¤¢ž¦§QVTSVXXWWVUVUTUWWVWWUWWWYZYXTVWXXWWXYYVXWVY[ZYVWXYXXXXUWZ[WY[[ZXYZ[[ZXXYYYZZZYZZZYYY[\[XO@* )7@EEC=431/58@=58::60,))''*.//00/-**-7<?><93.)(&''&%%%+14530110.+(&###""!"""!!#'(&# + + + + +"5CQ_krvwwwx{~}}{{|}|{|~}}|{|}z||z}||}~}}~y{€~}€€€|~€€€‚€€‚‚‚‚‚ƒ„„ƒ……ƒƒ„„ƒ„…‡‡†…†‡ˆ‰‰†…‚ƒ……‡ŠŠˆ†…‡ˆ††‡‡ˆ‰‰‰‰‰ˆˆŠ‹Š‰‰‡Š‹Š‰ŠŽŽŒŒŒ‹‹‹‹Š‹‹ŒŽŽŒŒŒŒŽ‘‘‘‘‘Ž’’“‘Ž‘‘‘’“’‘’“’’“”“’‘’“••”“‘•–””•–––“””“•˜—’•–––—™˜˜™š˜”—–š››œœžœ›™™šœœœžŸ¡ž›››¡£¤¢¢£¢ Ÿ ¡¢¢¡ŸŸž¡¤¤££¤£¡Ÿ¡¢£¥¥¦¥¢¡¦§¥¥¦¥¡¤¥¤¥¦¨TVVSUVWVVVWXWWWWWVWWVUWXYXWUVWXWWWVWWYZZXVXYYXWWYXWXXXYXZ\[ZZ[ZWZ[[[YXXYZYZ\ZWZ[ZXXUYYXTH5! *7?DC@93113587B=DFFC?:2''')(+)**..-*07;>>=93/*('''&"$(+.674022/-+&#! "#%%##""&(((&""! + +":HUajpty{{}|}|~||||}||}z{|{y{y}||}|}{~~}{€~}~€€€‚‚‚}‚}€€~„ƒƒ„‚‚„‚„…„ƒ‚ƒ…‡……‰ˆˆˆ‡…„„„„„††……„‡„ƒ„‡…‡†††‰ˆ‡…‡‡‡ˆ‰ˆŒŒ‡ˆˆ‹†Œ‹‹ŒŒŠ‡ŽŽ†Œ‰ŠŠŠŽ‘’ЉГ’””’Ž‘’’‘‘‘“”•”’”Ž““”“––”’””˜—–––”˜š˜’““’’–—”™˜˜”˜—š™œšœœ™œš›œžŸŸ›Ÿž¡Ÿ ™ššž¡£ ¢¢¡ ¢Ÿ¢ŸŸ ¢£¤¢£¡¥¤¢ž£¡£Ÿ¦¥¦ž£¥¦¦¦¦§£¦§¦¥§§VVVUUUVVVVWZYXWWVWWWVVUWWVUUVWVVUWTUWX[[YXWVVWWWXWYYWYYYZ\\ZYYYZ[[YY[[ZZ[[Z\[Z[\[XWWWXVO>* #,59@@;410249=DOWTNJMHC:1--,,+*+,-.--158;<;52/)&)('$"$,158964340-*&""!""$&&%&'''&#&&&%#! + +(=N\hqvy|}~~~~}|{|}~}}}}{zzx|}|}~~~~~~€€‚~~~ƒ…ƒƒƒ€‚ƒ€€‚‚ƒƒ‚„‚ƒ„†‡ƒƒ‚‚„ƒ…†‡‰ˆˆˆ‰ˆˆ‡…ˆ†‡‡†‡„‚……‡‡ˆˆ‡†ˆ…‡‡††ˆˆ‰‹ŠŠ‹Ž‹‹ŒŒŒŒŒ‹ŠŽŽŒŒŒŽ’‘‘‘’”’“‘‘’’‘’“”‘‘‘’‘’”–”’‘””””•–”˜–’““•––”—•–—™—••˜––•”–—––˜™˜™™™›œ››žžœœž ¡¡ŸžŸ¢Ÿœž¡¡ž ¡¡¡ ¡¢¡£¥£¢¤¦¦£££¥¦¦¦¥¥¥¥¤¤¥§¨§¤¤£¦§¨§£¥¦¦§¨©WVUVWVWUSRVYYWXSUUVSVVUVWWUVVWWWYXTTUVYWYXWUWWXXXYZZYZZZ[\\YYVY[[XYY[[[[[ZZ[ZZ[][YYXYYRE3 '07;>;51047:=CK^npldVQ@<22//.-,,,-+-*01357620/**+)%$#)26998777641/*'$%%&#$$&()('&%&&&$#"! + + + *8FR]hpvy||yz{{{|||y}x|z{w}}~||~~~y€€~‚‚€}~‚€|ƒ€€‚ƒƒ‚‚€‚„ƒ€‚„†…‚€‚…†„…‡ˆˆ„‡…ˆ‡†‡‡‡††ˆ‡…ƒ……‰‡‡‡‡†ˆƒ†‡‡…‰‰Š‹‹Š‰ŠŽŒŒŒˆŒŠ‰ŠŽŽŒŽŒŽŽŽŽŽŽŽ’‘‘Ž’ŠŽ‹‘’‘‘‘’Ž‘‘’“”“•‹Œ’••••”—–””””–—–”“”–”—–˜š˜—˜•™—˜“˜˜˜“—˜™™›šžžž—Ÿž›¡Ÿ ˜Ÿ› Ÿš ž £ Ÿ ¢¢¡¡Ÿž¥¥¥¤¤¥¦¢¦§§§¦¢¥¢¥£ª¦¦£¢¡¦£¢¢¢¡¥¦©¨VVVVWVWWUTUYYZXXVUUVVVRUWXTVXXYZ[ZUTVYYWXXXWXZZZZZ[[ZZZZZ[[[ZWXZY[[\[ZZ[[[\]][[\ZZ[[YWK8# "(2;=:4,+/59>?CMau|yup`M=768740+)**,-....011.,--,+)$$$+5=>:79=>=<;973/+,-,+))('&%&%&&$"###" !"! + + +*7FTalswxz{||}}{y{||}{{}~y|~~~€€~}‚€‚‚€€€€‚ƒ€‚ƒ‚‚„ƒ€~‚ƒ…„€€‡‡†…††††„†‡†…†‡ˆ‡‡‡ˆ‰‡…‡‰ˆ…††ˆˆ‰‰‡‰‰ˆˆˆŠ‹ŒŠ‹ŽŽŒŒ‹‹‹‹Œ‹‹‹ŠŽ‘’ŽŽŽŽŒ‘’Ž‘‘‘‘““‘Ž’“’”•’•—••”“”––•“–•”–”’•—––—˜•–——˜š™™™ššš˜—™š––—šš˜š›œ žžŸ ž Ÿ ŸŸ¡¤¡ ¡¢££¢¡¡ £¤£ Ÿ ¢¤£££¦§¦£¥©¨¨¥£¥¨¦¦©©¥¢¢¤¥¢¤¦¤¡¦¦§¦UTTTUUWXVVXZYVXWWWVVWWTTWXWWXUYXYZWSXYZYWXXXYZZ[[V[\ZXYWXXZZYWXZ\]\[[ZYWZZ[]]\[YYZ\\XRC- + #%0:;4+$'+07;<<;M\cfioeQ=;<=:72*)(+-00/,.**)'%*+)&&$%%/8@@;9<AA<@BCDB?==>>952)'&'&&$%#$$%$" !"#"!! + + + + +)8JWakqvy{}z|y|z}y}|€~}~}€|~}}~‚‚‚‚‚‚ƒ€€‚ƒ„‚€}‚‚‚€€ƒ„€‡†„ƒ„„‡…†ƒ†„†‚‡‡‡ƒ…‡‡ƒ†‚‰‰‰‡‡ˆ†„†ˆ‰ƒ‰‰ˆ„Ї‰‡‹Š‰ŽŒŒŒŠŠ‰‹‹‹‰‹ŒŽ‘Ž‹ŒŒŒŒ‹‘ŒŒ‘“•”’Ž‘’’’•‘–˜—“–‘“‘“••••”””•’”‘”’“•˜˜——˜˜™™˜–˜–š•™“œœ™———œ˜›™›™Ÿ›œœž™ŸŸ œŸŸ¢£¢ŸŸ ¡œ¡¢¡¡¢¢¢¢ Ÿ¢¢¥ £¢¦§¦£¥¡¦£¤Ÿ¨©©¤§¥£¡£¥§¡§¦§¡§¥¤¥STTTTTVVUWYYWVWXWXWVWWVVWVVWXYXXVZYYYYXYXWXYY[[[ZZZ[XXYYWXYZXVWZ\]ZZZ[YYXY\^]\[ZZ[[ZUK:& + #$*/97, !$$$.342127<?G^\K?<??;61.,+,.3410/-+($$'(&%$(+.5;BC<=?BCCCEKNMLLMOOJD>830-+'&%$$$%$##"##" + + + +/?N[fovy{|}|{~~€€€~€~|}|‚ƒ‚‚‚ƒ„„€€ƒ…†€€ƒ‚‚ƒ‚€‚„…†…………„„†††††‡‡‰‰‡‡‡„‡†ƒ‡ŠŠ‰‰‰‰ˆˆ‡Š‹‰ˆˆˆˆ‰‹ŒŠ‰Š‹‹Ž‹ŒŽŽ‹‹ŒŠŒŽŽ‹Œ‘‘‘‘‹Œ‹““’’‘‘“’’’‘“““”•“‘‘‘’““•˜˜—•“““•–””–˜——••––•“••——˜————™š—˜—šœ™š›œžŸœš›š›žžšžœžžžž ¡ŸžŸ££Ÿ ŸŸ œ ¢¢¡¢¡Ÿ ¢£¢£¤¥¤¤¦¦¥¤££¤¥¥§¨©¨¦¦¥¦§¨ª¨¨¨©¨¨¨¨¥¥UVUTVUVUUUVVUVXYZXWWXXWUWXWUXVXYYYYZYXWWYZZYY[[ZZYZYYYYWXUZ[ZUY[[\[W[ZZ[ZZ[]\\[ZZZYVN@. !$(-074($""#)++--//12:HHB<:<=8121.*/079774/.+(%&&()+-049=CECADEFEGIMOSQSSWYVQLFA<851-*('&(''$%%$#! ! + + + +%4CR]fouz|{~~~}~€€~~€|‚}€€ƒ€€€„…‚‚‚ƒƒ‚~‚ƒ€†……‚ƒƒƒ‚ˆ…‡……†‰Š‰†…‡‰Š‡ƒ‰‹Š‡ˆ‰‰ˆ‰‰ŠŠ‰‡ˆ…‰ˆ‹Œ‹‹ŒŠŠ†ŽŽŽŠŠŒŽ‹‹‹ŽŽŽŽŒ‡“’Œ‘““’“‘“‘’Ž”‘”””’’’•‘’’””‘“‘–•”‘“••’’”—–—•””••••••˜————“—˜™š›™™™˜—œžŸŸ¡œ››œ›œ ››œœ› ŸœŸ¢£¡žžžŸŸ ¢ ¥£¢££¥ ¦¦¤¡ ¤££¢¥¥§¢¦¤¨¥¨©¨§¨¢¤¦©©§£UWVVVVVUUVVUWYXXYXWXXYWVWXXYXWWYZYWYYXXXZ[ZWXZZYZYZZZZWXZ[Z[[[[\\\\]\\Z[[[[[\\[ZZZVSF2 + "$',020+'!! "%(()*+,,+*576446720220.269;::851/,*++-//037;?CFFGGHIJJMNOUXWW[^^[WTPLJFDA<7200.,+**'%###"!##" ! + + + %7FTbmux{||~~}~€€€€€€‚‚€‚‚‚€€~‚„‚ƒ„‚„„…„‚‚ƒƒ„†‡ˆˆ‡„„ƒ‰Œ‰‡‡ˆ‡††„…‡‰‹‰ˆˆ‰ˆ†ƒ‰‰ˆˆŠŠ‰‰‡‡ˆ‰ŠŠ‰ŠŒŒŠŠŠŒŒ‹‹‹ŒŽŒŽŽ’‘ŒŽ’‘Ž‘“““‘“•–•””“‘••““’’””‘’“””“’“—•”•––––—˜˜••—˜™—•™š˜š™˜šœ›™›œ››œžŸ›žž›Ÿœžž››Ÿ ŸžŸ¡¢¢£ ¡¢¢¥¦¤¢¢¢£££¤¥££££¥¦¥¤¤ ££¤¦¥¤¥¤¥¦¥£§¦¦¥¦¨§¦¦§§©¨¦VVXWXUVVWXWVWXWVWXXXXYWWYVYXZUVWYYYYXXYZZ[Z[ZZYYYYZYYZYZ[Y[\[[[Y[\]]]]\Z[Z[Z[[\\[XUM=& !"!$01.,,#"!$$&&'&&&*),/1+*)-010210.6:;;:78520-+-.//..48<>ACFGIIKMOPPPWXWW]^^]\WVWWUSSOIFDB?:52/*&%$%""###"!#$#" + + *?LYcipv||w|}~|€€€~‚ƒ‚€‚€~„…†ƒƒ„†ˆ‡ƒƒƒ„…†ˆŠˆƒƒƒ‡Š‰†ˆƒ„‚…ƒ„†Šˆ†‰Šˆ‰ˆ†††Š‹‹ˆˆˆˆŠŠˆˆˆŒ‹ŠŠŒ‡‹‹‹ŠŽŽ‰‹‹Ž‘“ŽŽŽ‘‘‘“”•••••––•“’”’“”“‘“”“‘’”•–••”—“••˜™™––˜——––›”š™š™šœœœœœ™›˜—˜˜˜›˜žžœœ™žŸœŸžŸŸŸ¡¢¢£¡Ÿ£¢£¦§ ¡£¢£¥¤£¤¤ ££¤¦¤¤¦¡¦¤¥¥¥¦§¥¤¤¤£¨¦¥£¢¨¦§¤¦©©¡WXYYXVTUWXXWWXWUVXUXXXWWXYYZZXUXXYYYYXYYWY[\ZZZZYYZYYYY[[Z\]\[ZZ\]\[X]]]\\]]\[\][YQC-# +#! "*4BC>2$$()&#&(+-,)&&-.+(%%*/330/4:>=<:88730+,.10,,/5:;<?CEGIJKORSRTX\\]^abba_^_``^^[XWXXVOG;5-*(%&'''''#""#$%$#"! + + +$0?LYgsuux}~~}€€€€€}‚„‚€€‚‚€‚ƒ………„„…‡ˆ‡„„„ƒ………†‡‡…„„…‡ˆ‡ˆ††‡‡ˆ†…††ˆ‡…€‰Œ‰‰‰ˆˆˆŠ‹Œ‹‡Š‹‹‹Š‰Œ‹‹ŒŽŽ‘‘‘ŽŒŒŒ‘““‘Ž’’‘‘“”””””’—˜–””•–——–”••“’–˜———––—––••–˜˜˜˜—–•–˜››™™™šœŸœœ™˜˜™˜™›œžžœž ŸŸ¡ ¡ ¡ ¡¢¢¢£¤£¤¢Ÿ›¢¤¥¥¥¤¦¥£¡¢£¥¥¦¨ª§¦¦¤¡§¨§¥¢¥¤¨©¦£¢£§¨©¤¦¨¨§VXXVUTTWWUVWWWVVWXXXXXWWZZZYYZZYYYYYYXZYXX[ZYWXXYXZYZY[\][[\[WZ\]\[Z[[[Z[\]][Z\[YUI7# + &,'"+6FSTO>('25,,,2873-#&'((''()154004<?=;:69751.-00.)-1:=<:ADFHKLLLTXWUXZZZ^acdedc_fca__^^^bb_ZQF?51)+,--,(&!! !###%###"! +$2ES\cluyy~~€€~~€‚‚€€‚‚€„††ƒ„~‚„…‚…„††„‚‚‚…„„„…‚‚ƒˆ‡‰„‡ˆˆ†‡ƒˆ†ˆˆ…ˆ‡‰‹Šˆˆˆ‰ˆŒŒ‹ˆŒ‹‹ŠŠ…‹ŽŽŽŽŒ‡Ž‹‘ŽŒŽŒ‹Ž‹’‘Ž““‘Ž‘’’’’““““••‘“’———–––•”•••••–—”—––”•’——˜•˜˜˜–˜—šœš˜™˜™™ž›œ˜™™š•——™šœ™žžŸŸ›Ÿžž¡¡¡¢¡ŸŸž ¢¡£¡£¡ŸŸ¢¥¦¥ž¤¤¦¤¢žŸ£¦¦©¤§¦§ £¥§¦§££¤§¨¨¤¥¤§§©£¦£©©VWWWUTUYXVUVWVTWXWXXWY[\[YXXXY[ZYZYZZYYYYZZXXYYYZ\[YXZ[\]\[[[ZZ\\ZZ[ZZZZZZ[[[\]\WN?- +&7C>12ET^_ZF*+<FEAGIJC92-(###&/35443//6<>=<:89962011.)(-8?A@ADEGJLMORTZZVVTSV[adfhjjjjihggffffhjibZRI@953122.'$"!"$%%&$%%%$$# + + + )6DScmw|~~}€‚€€ƒƒ‚‚€„ƒ‚‚…‡…„€„„„‡ˆ‡…„ƒ„……„ƒƒ„†‡Š‰‰‰ˆˆˆ‡‰‰‰ˆˆ†…‡ˆŠŒ‰‰ˆˆŠ‹‹Œ‰ˆŒ‹ŠŠŠ…ŠŒ‹ŽŽŒŽ‘ŽŒŽŒŽŽ’’”“‘“”““““’‘‘‘’‘“”–—••—˜””—˜–””•—˜–•””•—˜—–“–™™›˜–—™˜™˜—™šš˜˜™™››™š›œœ›Ÿ œžŸ ŸŸŸŸ Ÿ ££¡£¤ ›¢¥££¥¦¥£££¥¤££¡¤¥¥¤¥¥¦¦¦¥¦§¨¨¨¦¦§§§¥§¨§§§§§¨§©WWWSVVWZYWVVXUVWXVXYYY[\[WXUWUZ[ZXY[ZXXVX[[YXZ[Y[\[XY[[Y\\\\]\[X[Y[\[ZZZZYZZ\\[[SF5 + +$*BWR@CNW^]UA*,CYgd\TRK?BB6"!!(487422-28;<<:959;85441,))1<CEDEGDHKMOQSW[ZVTJRR[]eilnonnnnnnoonmmnmifa[VRMGB?=93.+%&''&(&&&''&%$"&)%!!" !! + + + />M[fov{}€}~€ƒ~€€„…„ƒ„„ƒ‚„………†‡……€‚ƒ…†…ƒ‚~…„‡ƒ‰‹‹ˆŠŠ‰‹Œˆ‰‡†„ˆ†Ž‹Š‡Š‰ŒŽ‰‹ŒŒ‹‹…Š‹ŒŒŒŒ‹ŽŠŽ‘‘ŠŒ‹‹‘‘‘‘‘‘Ž“”“““““’“””‘“’‘‘””•–•”•‘””—˜–”••˜–••—‘˜™™——’•“š›™—–™™—”š™›š™•››š™œšž›žœž œœœ›š›› ¢£¥¥¢¤Ÿ ›¤ž¦¤¤£¦¤¤£¤ ¤¥¦¥¦ Ÿž¦¢¢¤¥¦¨¨§¦¦¦¦¦¦¤¨¨¨¤¨©ª¥££WXXWWWWZZXWXYYXXWUWYYXXYZXWYXXYZZZYYYYXWWZ[[YZZYZ\[XZ[[[[[[]]]\\[[Y]][ZZ[ZZZ[[YXM<( "),F`^GHOU[UH8(.Hi{vfTOMEVQC0&%+8852/135:=;:889;;86551+)*4>EGDHIIJKNQSUWYWVTSSXZ]elnpqqpsuuuvwuttpnlmjfee`XROKGC?8521/-+,*''('%&)251-(''&((***)&" + 3DTdqx}€€€‚‚€€ƒ…ƒ‚„„‚‚‚‚‚ƒ„…†………†„……†††…„„…‡†…ˆŠ‹Š‰‹‹ŒŠ‰ˆˆŠŠ‰‰ŠŠ‹ŽŠŽŒ‹‹Œ‘Œ‹ŠŒŒŠŒ‘‘‘‘ŒŽ’’‘’“’’’““’•”““””•••”“““““”–––“’•˜˜–—˜–•˜šš˜™š™˜˜™—–””˜š™™˜™šš™š›œŸž››šš›š™žžŸž¡ žžžžœžœœžŸ ¢£¤£¤¤¥£¤£¤¥¥¥£¥¥¥¥¥¥¦¥§©§§§©¨¦¥¤¨¨¨¨¨¥§©©¨§§§¨©§©©ªª¨§VXXVWXYZZWVUXXXXWUXVZZYY[ZYYYXYZ[[ZYXXYYYXZ[ZZZXYZ[Y[Z[[[[\\]]]\[[[\][[\\[[[[XWRE." + !(,Gb^G>=BGA4.(3Nkyo\H<?AEI@5.+5>:11.227<=:737;>:60231(*,7AGJJKLMONSTWTPLMOYX\__\hmppqrtwzzyxyxxvsrqokeghd]YUQKLKGCA>:6531))*'#(.7=933245444432/&#"! #!! + + #.BQ^ipuy~€€€‚‚€}‚ƒƒ€ƒƒƒ‚‚‚‚ƒ……†……„ƒ„„ƒƒ„„„„‡‡‡…‰‰Š…‡‰‹ŒŒ‹‰Šˆ‰Šˆ‹ŒŒŒ‰ŒŠ‘Ž‹‹ŒŽ‘ŽŒŒŒ‰’””‘Œ‘Œ’’’‘‘’’””“‘“‘“““”••••–”“Ž““”–•’’”˜—“”–•”˜›œ˜š••”˜™™˜—šš™–š››–›—š›œžž›š›™ššŸžž—› ¡¢¡ ž›œŸ ¡Ÿ ¡›¢Ÿ¤¥¥¢£Ÿ¤£¤£££¤£¥¦¥¢£¢¨¦¦§¨§§¥¨¥§ª©§¨©«¥¦§§£ª§©¨©«ª¨VXXWWXYZYVUTWWXXWXYYZYWX[[XXXXY[\]WYWWYZYYZZ[[[ZZ\]]]\Z[XZ\^^]\ZZ[\\[[Z]\[\\[ZUJ9& "/Je\?+*++*)$+9Zjm_J5221148657=D?430236;:7437<@?6/+10,+0<DHKMONQSVY\XPFBDXacegeejnqrqqsy}}|z}}zwuuuqledfea]VTOPRPNLID@??;750(&)29>;6:AFJHGFDA?:3-+))'&%$"$$#"!"$"! *7FQ\hs{ƒƒ„ƒ‚‚„††‡…ƒ‚ƒƒƒƒ„†…‚ƒ„„…„…ƒ„†‡‡‡ˆˆŠŠˆ‰ˆ‡ˆŠ‹‰Š‹‹Š‰‰‰ŒŽ‰ŠŠŽ‘Ž‹ŠŒŽŽŽŽŽŽ‰‘”’ŽŒ‘‘‘’“””’‘’””•“”•’‘“”•”••””–•”“•”‘“••””•–•—š›œš™–˜˜™™›œ››š™š››››š˜˜žžžœœžŸ ŸœœžŸ ¢¡ ŸŸžžžŸ ¡¢ Ÿ £¢¡ ¡¢¤£¡¢£¥¦¦¦¤¥¤¡£¦¦¥£¥¨ª¨¥§£¦¨¨§§©©ªª¨¨¨¨©©©ªª¨§WWXWVXXWXUUUXXWVXYYYXWVWYZYYYYYZ\\[YWXYZYVZZZ[[\\]^^]\\\[X[Y]]ZWZ\]Y\\Z[[[[YYXO?, + $5PeZ<,&%%+-39K_gdQ70..-.-3668?E@63///1420105<@B<1.--,06?EHFNQRRVZ[XQEFFTbhfhkjjloqpomqw{|{z~}{sssrrmhggfc_UWRSSSQRLJGHIHGE>5,05;=;8BIRVVVVTQMGC>840.,*))))('#'(%"%$$" '3FUclrw}€ƒƒƒƒ‚‚‚††‡…††‚„„††„„„‚†ˆˆ‡ŠŠ………‰‰‰ˆ‰‡ˆ‡ŠŠ‰ˆ‰ˆ‰‡ˆ‰‹‹ŒŒŒ‹Šˆˆ‰Š‹ŒŒ‹‹ŒŽŽ‹ŽŽŒŽŒŒ‘““–““Œ‘Ž””““””’’”’“‘“•”’••’••’Ž”‘–——–š˜––™›œ˜––™š™™œ›š—š™š™›œœšœ–˜œœŸžžžŸŸ ››ž ¡Ÿ›¡ŸŸžžžŸ£¢¡ž žœ ¡¤¢££¤¥¤¤¤£¥¡£¤¤£¢¢¨§¨¥£¡¢£¥¥§¡¨§¨©©¦§¨©ª©¨§§XWXXWXVXXXXYZZVVYYWWWWUWXWWZZ[YX[\ZYXY\\ZYZZY[Z\]]]]\\X\^^^]]\YYY\\[\]Z[[\[ZXTG3 + '9R`V@.'$*/2@KU_b^G1))))*-2577@FB:4,,,-0/..04:=A?80,+-3;AEHKNRTX]^WNBAHWckkgilklmopponntvwxx}~|xtqqplkjjhd_YXYXWWWUSQPRSSRQLB979=>;?ITY]_`a`_^\WLFB>;8653221.-,*'%%&'&$#" ->KXeox~€‚„„‚‚ƒ„‡‡††††…„„…………„…‡‰ˆˆ‰‹Š‡ˆŠ‰ŠŠŠ‰‰‰ŠŠŠŠ‹Š‡‰ŠˆŠ‹‹‹ŒŒŒŒŽŒŠŒŽŽŒŒ‹ŽŽ‘Ž’“•’’““”•“’’“”•“’””“‘’”““””•––”••”–˜™›™—“–——™™——™š™™šš™š™™›œš™›žœš›œ žžžžŸ Ÿžœ›ž žŸ ŸŸ ¢£¡ ¡¡£¤£¢¡¢ ¤¤£¤¤¥¥¤££¥¥¤¥¤£¦¨§§§¨§¦¦¦¦§¨©§¥¨©ª©§©ªª¨¦§ªXXWVWYYYXWZZZZYWXZZWXXWVWXYZZ[[YZZYYXY\][ZZ[\\\Z]Z]]^][Z^^`_^]\ZZZ[Z[\[[]^\YWP@&"" + !#)8KXPD8/,-04BNSRXXI/+''"(,/012=EEC<1/-...++,59<==:2)*)6=CEIKOPUWZWL=@DUdmpnikkkjjglnpjnppotx|~|xsnonlllljcb[[\]]ZVVTUUXYYYXTKA?>??@COX^_bedfghhfb]VOIC@==<;:930-,)**)'%%'($ + +!0>MYeov}‚ƒ„„‚‚ƒ„ƒ„‚„……‡‡ˆ††‡†„ˆ‡Š‡Œ‹Š‰‡‡‰ˆ‰ˆˆˆ‹Œ‹ŠŠ‹ŠŠŒ‹Œ‰‹ŒŽŒ†ŽŒŒ’‘‰ŽŒ’’”’•“–‘”’“‘“•”’’“’‘‘’“‘”““’–—”‘“”“”—˜˜”••—”™˜—–—™›››–œšš—›—›™œžœ››œžŸžš›››žŸ šžœœž ™Ÿ¡ ž¡¡¡œ¡¡¤£¢Ÿ£¥¥£¤¥¥ž£¤£¡¥§§§¤¢¤¤£¡¦¥©ª©¤¨©©©©¤§©©§¦§¨©«£¦¨ª¥ª¨©ªYYXVWZXZWXZZZZYXY[ZWYYXXVXYZZZY[VXXYXZ\]YYZ\[]\]\\]]^]\\]____^^^[Y[Z[ZYZ]^[ZVM;&$,# + + "#*7ELJB:30/.2@LLKLPG2/,)&'*+,+,6@GKE=861-+)++4::::6/((.6=CJNPOSTVQI?9?Q_lqpomllhfgfhnprqpinptxzzvrnnnmqppliecccdc`^[WWW[\`a]XPHDA?>AJT]_`egeejknoomjd]UOJEEDCB@;631/..+(('''%$#! + .;O^lv}‚„‚‚‚ƒƒ……‡…‚…†……†ˆˆˆˆˆ‡…ˆ‹‹ŒŒŒŠˆ†…ˆ‰‰‰‰‹Œ‹‰Ž‹‰‹ŒŒ‹‰Ž“‘‘‘““Ž’Ž‘‘Ž’“–‘’’”••–•““““””””•”””•”’•–””•–”‘—˜–”“–——–•—›š—••—™š›››œš—šœžžœ››œœžžœŸŸ›› ¡¢ ž ¡ £¥¡Ÿ¡¡¢¢¢££££¥¥¤¤¥¥§¥¢£¤£¢¤¦¦¦¥¢£¤¢¥§¨ª¬«¥§ª©ª©§¨¨¨¨©©§¨©§¦©©ª«¬ªªYZYXWY[ZYY[WXZ[[[ZZWYXWZ[[ZY[\[ZXWYYZ[\]YXYZ[\\Z[]]\\[[[]^^Z]^_^\ZYY[[ZZ\Z[ZTH:+28. + + +#&5<KLE93013209?><=?:2.,)%'+.0-&4<INI@<83&'')(04576-,'+29>EIQSSTRKG<=?N\emononlif_egjlrstrooposvuutsrqsttrpnjdgefhhfa][X]]bb^WPIFCA<ENX__`efddjjlnnnqpjd^YTOLHGEC@=755420.,*)#'&*($ #7GUbmv{€‚ƒƒ„…„……‚…†……†ƒ‰ˆŠ‰‡…‰ŒŒŒŒŒŠ„ˆ‡‰Š‰ˆˆ‡‹ˆ‹‰‰ŽŽ‹‹‹ŒŒŒŽŒŽŒŠ’Ž’“”“’’’Ž’‘ŒŽŠ‘‘’’—“”’“’–’“””””•–•–•–•’–––’”•”’—š™——”™š˜“”–š˜—’˜–••š˜›˜˜˜š›Ÿ Ÿ›˜—œœž¡¡ ŸžžŸ¡ žŸ¡¡££¡ ¢›¢¢£Ÿ¡¤§¦¢¤¤¥ ¤¢££¤£¤¡¡¡¥£¢¤¦¦¦¦¨«¥©¬««¨¢¨¦§¢ªª¨§©¦¦¦©¬ªª¥Z[ZXVYZZYY\\\^]\[ZZZYXWZ\][Z\\[YYYZZZ[[[XXXXZ\[XY[]]]][Z]^]\\\^_\\[[]]\[\[YUK>7<AC8# '9FPTQC4&(-330/0,(&(*(&''%'39;3,4DKNID?;3)&(**)0/442-'-6>CGKRVUSKA:CLS[ejkknnliebaelnprtxvrsrqpqoortuuuvvvuqnjhilnomga_^_ddc]UNGFDCAIT\aacdddehkklnoqqojkjfb\VQMKIFDBB?:5410/.,+),,+)'" %:IXeqy~ƒ…„„„ƒƒ„†‡ˆ‡‡‡ˆ‰‰††‰‹ŠŒ‹‹Š‰‰‰ˆ‰††‡ŠŒŒ‹‰‹†‹ŽŠŒŒ‹ŒŒŒŽ‘’‘’“““’‘’“““Ž‘‘””–˜™—•‘‘”•””•••—˜——–•”—•••——˜––—––š›ššš™š˜––—š™™——˜–”™œ›š˜š›šŸŸœœœ ŸžŸŸŸžŸžžŸ ž› ¡ £¢¡ Ÿ¡¡¡¡ ¡¤¦¥¡££¤¦¥¢ ¢¤§¥¢¦¦¥¤¥¨¨¨§¥¥ª«ª©«ª©¦¦§¨§¨©ª©§ª«¨¤¦¬¬«ªªZYXXYYYXYY^]]]]YZYZYYXYZ\]\\[ZZZ\][\\YZZ\\[X[[ZYZZ\\\]]Y^Z[\[Z]^^\\\\]\[\[RF<-:CEA4" + + $8JSYUL=.$%++(%" !"$%&'3=CC:.;GJHE?EE<1.+/1337::71(/:AGLNRSRMD6AKW_dimhjkjfh___hprqsw}{xuvrpiidlpssrrstrpmiknqssoiccdhifaYPJCBBCDO[acd_dbdfffklllmhikoonmic^XUTRMLKHB>9656631000.12/+& + + +(>LYeoyƒƒ€ƒ…‡‰‰…ƒƒˆ‰‰†‰Š‹Œ‰‰‰Š‹‰‡ˆˆ‹ŠŒ‰ŽŒŒ‹ŒŒ‹‹Š‹‰ŒŒ‹ŒŒŽ‘’““‘’’•”“‘”–––—•˜•‘’““”“’—–—––’’“–———™—–———–˜š™™™—–———˜š—™•—˜—•œ›žžš™›œœŸžœ¡¢Ÿšœš›–ŸžŸŸ Ÿœ¡¡¢£¢ž¢ ¡Ÿ ¤££¢¡¡¥¨§£££¥¨¦¡¦¦¥§§¨¨§¥§¥©¥¨§©¦¦¦¨¨©¦©§¨¨«ª©¥§¨§¨©©YWUWXZYY[]]\\]\[ZYXXXZYZY\]\XYYZ\^]\]\ZZ\^^]\[[]]]\[Y\]__\Z]\\\\]]\\[\\[\XI4(4>E?3& %-EVZWM>-& "! !%*17>CED<6?IHCBDNYXPB64:;:<?>93.1;CIMQPOJC=>IV^dhloolihhgffjottsw‚|zzywqkigglnoppqppojimpswuqmefhkje_VLDBA@FLV`dffhfefiijklllkjkoooqtrokfb_^]YUOLIEA>=<9854334431.,*&" *>O_mx}~€‚ƒ…‰‰†…‡ˆŠŠ‡‰‰ŠŒ‰Š‰‹Œ‹‡‰ŠŒŽŽŠ‹ŒŒŒ‹ŒŒ‰‹ŒŒŽŒŒŒ‘Ž‘’“•“‘‘‘’“’‘’””’“““••–”•––”“””“”••–”•––—•’–——˜˜˜˜™˜——•”˜™™šœš–——˜™™š™˜™™˜—››ŸŸžš››ššŸœž¢žšššœŸ¢¡¢¢¢ Ÿ ¢¥¤¢¡ŸŸ¡¢¢¡££¤¤£¢¥¦¤¥¨¨§¥£¥§¥¤¥¦¥¦§¨¤¥¥¥¨«©¨¨¨¨¨¨¨©©©¨ª«««ª©©§ª©¥¦©¨XWVUXYZYZ[[Y[\[XYXWYZ[YVZ\\\ZZZYZZ\\\ZYY[[]\[[[]^\\\\\\__]]]\]][^^\\\]\ZXQ@%*6;8- + %1GVSLB31'# !%,5;<99950:BA>DI[iiaQ=7==;>?<94.19AFJKIC>4;ALW]aijpqlfhgiknruwtlx€yyy{yrnkgfghioppmqrogonprrqnfhiifb\TIA;>@IP[cdbggiiiklmmmmmmloqonttutrkjccbcc]XURKDC>?=;78777533/32.(# "1FT_hpz~„††ˆ†‡ˆ‰‰‰…ŠŠ‹‹ŠŒ‹‹‹ˆ‰†‹‹‹Š‰‹Š‰ŽŒŒ‹‹ˆ‹‹ŽŽ‹Ž‘‘’’’‘Ž‘‘“‘’“Œ’ŽŒ•“”–––“—–“”••””•”–•”˜˜˜–˜™™™——˜’–™˜”š›œ—––˜—™››—˜™˜˜œ˜œžž˜›ššš™™œ–™›—Ÿ››˜ž¢£ ¡£¢¡ œ£¤¤ ¡ŸŸ ¤ž£¥¥££¢¤¦§¦¤¡¦¥¥¢£¥¥£§¥§¡§§¦¥¥¢©¬©¥©©¨©ªªª©¨¨«©ª¥©¨©§ª¨§¦«£XXZZYXZZ[[ZYZZYZXWXZZZYY[]]\\][XWY[\Z[ZZZ\[ZZ[\\^^\]]^\\]^^]\\]\__\\]][ZUH3*.84% + &1CLG<8<;7, !%*373000--268:FXgrpfWA8;=;<<975105>DDA<7327=GQZbhmqqmihhkotxxusqw~}xwyyvrnlhhhhhmoooqtrqpomllnnkkkig`YQF>;;@IW_ddehklopprsrnsvvwxyxwxywwwwrlfbgnrskaTOKIEDCBA@@@><97541/.-)# "1CTfr}ƒ†…†‡‡ˆ‰ˆ‡ŠŒ‹ŒŒŒŽŒŠŒŒŠŠŠ‹‹‹‹ŽŽŽ‘ŽŒŒ‹ŠŒŽ‘Ž‘’‘‘’’Œ‘’‘‘’“”•˜–”•––•’’“––••’’••–—˜˜˜—˜˜–“˜™™˜˜—–˜››ššš™™šœœž›™œ››››–™œš›œœœššœŸžžŸ¡¢Ÿ ¡¢¢¢¢¢¢¡ ¢¢¤§§¥¤¤¤£££¥¦¦¤¢£¤£¡¢£¦¨§¥¥¥¥¦¦¤¦¨©©¨§©¬«©¨©«¬ªª««ª¨¨©ª«ª§¦ª®YX[ZZXZZ[Z[ZYWZ[\[ZXWTYZZ[^^]]\XXX\]\\[Z\\[[[[]\^_^\^^][[[]]]\\\^^\\\[ZZP=.'-2) $-7=8.3:<:. !!! !&+,,,..,)+,.1B^pvodVD95<<=:;;9640;?<52+10138<MZenrqnjhensw{yurmtywrqpphllkhiiigkjomqssoqqpnkgnnljif`TLA>9>ALZadgglmmprstvtnvy~‚„‚€{||zx{|zxqafks{ytk_ZWRMMMLKKIE?@><863221-(" +.:O^jtz€…„‡ˆ‡„‰ŠŠˆ‹ŠŒŒ‹ŒŒ‹ŒŒ‹‹‹ŠŠŽ†ŒŽˆˆˆŒ‰ŽŽŽŽˆ‘ŒŠŒ‘’‘’’Œ“•’’’’’“–•’’’“’““•˜–”•–•”““••™™–’–•—™š–™—•”——š™›››š›š›žŸžœ›–›š›•›žŸšžžžœœœœž—ŸŸŸ žžž ¡¢Ÿ¡¡¡¡¡¡£¥¦§¦£££££¢¡¥¦¥ ££¢£¨§¦¥¤£¥¢££¦¨¨¦¨£©«©¦§¤ªª©©©ª©¨¨¦ª¬¬¥¨©¯°Z[\\ZYZZ[\[[X[\[^_]ZVWY\[Z\]\\\\[Z[]]\Z[\\[[\^^^_``_]^][Z\\]^][[[\\\\\[WH1"%&" +$***(+576-!""!!! "$$&),,*(''(-=gy|l`TD<:<?=;>GG?;9982.,1664434;N`ossoigepy}}ytplqsrnkiifgijfghhijjosuwurrsrolknnkhee]RJB?>AEO^ddilnnjnpqrvutw{Šˆƒ‚„ƒƒ€€‚|rc`ky‚„yrkc\UXWUSPKGECBA?>:520-*)*'!4CScs|„…ƒ…ˆ‰ˆˆ‰ˆ‹‹Œ‹‹Œ‹‹‹Œ‹ŒŽ‹‹‹‹‹Œ‹‹‹ŽŽ’ŽŽ’”’‘Ž‘••““”“’”•”•”‘‘””•–˜•“–˜–“’––”™›—”––™š™™˜–“•––šš™š™›–™›žœž›››ššœ Ÿž ž ¡ŸŸŸ ¡Ÿ¡ Ÿžž¡¢¡ž ¢¥¦¢Ÿ¡¦§¥¤¤£¤¤¤¢¡£¦§¦¤£¤¤£¤¨©£¤¥¥¦¦§¨¦§§¦§¨§§§¦¥¢¨¨¨¨¦§¨¨¨©ª¬ªª©®®[[][YXXYYZ[ZZ[[Z[]][ZYZ[[[\\\Z][[Y[[]][Z\Y[[\^_^____^[\Y\\\]^[]^]\\\^]XN<# #%'&+.1+(!"""! ! %&**'%$#-3XzŒ|b[IFCDEEFW`WH@;7/.+17;<974-6>Viprngffqyzxsooloomhe_eddegdffgijksuy{xuuruonnoolhgd[QKDC?BEVehgmooooopquvvwz~„‹Œ‰‰‰ˆ…†€„„‚}q[iq€ˆˆ†€{wqmid^ZSPKHDFACCA:632/0240)!#<MZfpx}ƒ‡†‡ƒˆ‰ŠŠŒ‡Œ‹‹Œ‹†‹ŽŽ‰ŒŒŽ‹ˆ‹…‹‰Œ‹‹ŒŽ“Ž‘ŒŽ‘“’Ž‘‘‘Ž‘’““’”•”””“•—–’Ž–”–”’’•”“–š˜”˜™˜’——š›™™™“”“–—™››™˜›œ™š›žžŸžœœœ››™›œŸžžš Ÿ¢ Ÿ ¢Ÿ ™žœ¢¡ ¡¢¢žŸ¡¥§¥ ¡§¦££¤¥¡¢ Ÿ §¤¥¤££¤Ÿ¨¨¥¡§£¦§¨¨§§§£¤¥§¥¨¥¢¡¨¨¨©©¥ªª««ª«¬ªªª«[[\[WUVWVYYYZ[YY[]Y\ZZ[[Z\]]]^\Z[\[Z]_][[[[[[]__^]]^^]]]\[Z]]]^`^\Y\]\RB, +#(,.12/&$#"! ""#"!!!"!"&()(#$$'2Wx”ŸŒwe]WTPQYdmqbLB92/.049==:96127Lalomnoqrvrmlmmnmmljecbbbdcbdegikmv{|}|zy{yxvuspnlhcZPKGFCCJ\imnoorsrqvxxwvx}‚†ŒŒ‹ŠŠ‰‰‡†„„„„}sjn|†‰‹‡„„…}vof`YTOJHIIJGEB@?><:874.*&" );L]ky„„…ˆŠŠŠ‹‹Œ‹Š‹ŠŒŒŒ‹‰ŒŒŒŽŽ’•‘Ž‘““’’ŽŒ’–”“”“•••””•˜˜–“’”•”––”‘”–——˜šš•––˜™˜š›™™™˜˜——–•˜šš——™›™™›œŸžœ››œžžŸœžŸ ¢¡Ÿ ¢¢¡¡Ÿ ¢£¡ ££¡ £¥¥£ ¤¥£¡¢¦¦¢¦¦¥¥¤¢£¢¢££¤¦§§¨¨§¦§¦¦¦¦¦¨©©¨¨¨©§§¨¨¦ªª«¬¬«ª««¬¬®¬ªZW[[XWXXXYYV\[[\]]]\ZXZ[[\\\]\[X\]][]__]\[\]]^__^][\^Z][\\\]^[_]]]]][WJ6% +!# !$*/37>A;,(" !#$###"&((&)+*&'&,2Uy’¡£ž‘wtrqlgjpplXF;31./18:ACCC@=9-FZgmmnuwvrk`hkkgjhkjigc_]Z[^cfghmmw{}~~y~~|{yuqqojdYLIGFDHP_knpqruusrx|zxwv}ƒ‡ŒŒŠŠ‡‰‰ˆƒ„„…†ƒzvr{…ˆˆ‚‚ƒŠ‡ƒzohb]WTPMKLEIHFDB@?=;9711,'! &.FWeov~ƒ…ˆ‰‹‹ŒŒŒ‰‹‡Š‰Š‰Œ‰‰‰‰‰ŽŽŽ‘‘Œ’”‘”’’“’‘Ž‹ŒŒŽ‘•“””–“’”—˜––””””“—˜–’–’˜•–“˜••”™™™•›˜˜—˜šš—•“––™˜––—˜›—œ›œœœœœžŸžšž›Ÿœœžž££¤Ÿžž¢›¡Ÿ ¢£¤£¡£¡¤¡ ¡¢ž¡£¥§§¢§¤¥¤¢¡¡¡¤¥£££¢¨¥¨¨¨§¤£¨¤¦¥ª«ª¦¨¡©§§§ª««¨®¬«¬«§ªªª©¨ZZZZYZZYZ[YZ\^]^]]]\ZWZ\[ZY[\\[Z[]^\[]^`^[]__`_]]]Z\^^][]_^]\Z]\Z\]^ZR@* ()%#""#$(-5=DJRNA1" !"#"$'*,,,-.,+,05Tw–¡¡œƒ‚ƒ„…‡‚woog]J921/,,3<BJ]b_[VH9?O`lnsxzvla`ehheghiiiid_WNLV`gjnoqv{|}}~€€||vtrsmdXJECAEKTbklnrvwwusx|{yxx|‚…ŠŽˆˆ‹‹‹‰‰Š‰‰†……„~y{†‡‰ˆŠŒŒ‹‰…zvod_[VQNMLKIFDBBCC@<9653,% +9IXgr|‚‡‰Š‹‹ˆ‹‹‹ŒŠŠŒŒ‹ŒŽŽ‘’‘’‘‘’Œ‘’’‘““‘’“‘‘’•––••––””•–”””••–•’—˜–——™˜˜•’––•”™™˜—™——–˜›šš˜˜–•˜™˜•——šœ››œœœŸœ™œžžžŸ ŸŸŸŸŸ ŸŸ£¥£¡ ¡£¥£¢¡¢£¤¤£¢£¤¥££ŸŸ ¢¥§¨ª§¦¦¥£¡¤¦§¨¦§¨¤¦¥§©©¨ª«©¤§¨¨¨§¦¨ª©§¦¤§ª©¨¬¬®¬««®¬««ZZZZ[[[Z\\\Z\^]\[[\\[XZ\\ZY\]\\ZZ\]]]\\\^[]_^_^]^]]]^_^[^`_\\Y]\[[\[TG3 !+,,299-('29?AOYWM7#"! !!$(*,-,///-56Uu‘¤¤œ{}€‡ˆŠŒŠoYND<010/*-6?B[t}urmX=<>Xjqvxzrda]aefdddgegcb]SEHO\dilqqvy}|€‚‚~zvuumbUCC?EGNVdhhhptwxwtyz{zzt~ƒƒŒŽ‹‡ŽŽˆ‹‹ŒŒŠ†‡ˆ‡…‚{‚…‡‰‰Š‹ŽŽŽŠ‡†‚zsmc\VSPNHH@CBEEFB@?@>82/)#*9M[iu}€†Š‹ˆŒŽŒŽŒŒ‹ŒŠŒ‹‘‘Œ’‘‘‘‘‘’‘’’’Ž’””—–“”–•”•–”””””•—–—™˜—˜™™•–’–——•˜˜˜™––˜˜š–š•š––—˜š™———˜™˜—˜™žŸœ–š›ŸŸŸŸ œ Ÿ¡ ›¤ ŸŸŸŸ¤¤¤¡¢£¤¡¡¡£¥ ¤£¢£¡¥¤¦¨§¥¦£££¤£§¦¦¦¨¥¥¦¨§¨©«¬ª¦¨§§¢¢£ª©«¨§¤¦¢©©©¨©ª«¬®¯®¬¦XYXYZZ[\Z\\Z\\YYYZ[\ZZ[][Z[\^^\[[[\]^^\Z^_Z]^^\_^^^_^_^]]^_]\\\\[]\XK8" "&&+5BLHB;7=>DPZYO;$#"""! !!%(+--.0003:Ss‘¢§ “‚}~†ŒŽŽŽ†qW<52.01.).8>Oj…Š…}cA8@Qiswyvnga\^bbbdededa^XOCDKXaekpuyz}}ƒ†…ƒ†ƒ~}|zul^QBDFINT]dhghnsuwwxy|~~‚…ŠŽŽŒŠŠ‹Šˆ‰ˆ‰ŠŠ‡‚…‰ŠŠŽŽ‰ŽŽŠ…~xpia[UQMJHHGEHIIIIFA>;840(! />Rcs{ƒ‡ˆŽŒŽŽŽ‹Š‹ŒŒŽŽ‘‘‘’’‘’‘’‘Ž’•—–•“”•”“”•••––—–—–”—›š˜˜˜™˜–’—˜—™™—šš˜—˜š›œ››™˜™˜›œœ›š˜˜š››œžŸœ–—šžŸŸŸ Ÿž¡¤£¤¢¡¡¡ ¡£££¢£¤£¡¡Ÿ¡¢£¤¥¥¤¡¡£¤¤¥¤¥¥¢¥¦¥¦§¦¤¦¨¨¦¨©¨§¨©««ªª©§¦¦¨ª¬««©§¦§©«ª«ª©©¬®¯¯«©YZYYYZ\]\[ZY[\\WWXZ[[[\Y[[[[^_]Y]][]^^[Y^_^^__^^]Z^__]^ZZ[]]]Z][\]ZSB+ !(0>FIGEFEEHONF4#$%$""!! %',//00/38Sp£ª§›‰€…Š‘’”•‘fK33/0041?JRZmƒ‡†€xcFFJ]nvxwmkhc\]]__bb`_caZPJADITZ`fmtwxy{ƒ‡†‚‡…‚|zyxuiZPCIHMQWafiiinpqptwy{€‚~}|€…Ћއ‹†ŒŒ‹‰‰‹Œ€kprz„‰‹Œˆ’Œˆ„}vnh_YSQPMGKKKJNLIDBB@;6/,(" "<M[ht}„‰ŠŒˆŒŒ‰ŒŽŽ‡ŽŒŒ‹Œ’’“‘““‘’‘‘’”–•’“”””“““””••™š—––”˜˜š˜˜–š™˜’—˜™›œ˜›™™•—–›››š™™›˜›žž››š™˜š›œššœ••—Ÿžž ¡£¤ žŸ¢ž š¡žž¡¥¥¤¢¡££¦¦¥ ¡Ÿ£ž¤¦¥¦¤¤§¦¤¥¦¥¤¢¨¨¨ª«¢§¢£¤©ªª«ª¦¨¨«¬ª¤¨¦¨§««ª¬«©ª¬«¬¬¨¥\[XXWZ\]\[Y[]]^\[[YZ\\\\\\]]]]]\]][\[\\\^`]]__\[\\]^^^^]]\Y]]^]^\[VK7% !&-6@DHD>7>>8,##$#! !""%*,./0/.7OnŒ «¤”„€€ˆ“”–œ™ŒvY?4115=ITcihlsvupj^QOXfsy{ztlje^\\[\]\[[__VJCACHNRYagmpruz„„…††ƒ}zxsqfWNLNPPSZbgkkmoolmqvwy~‚‚{{ƒˆŠ”””’Ž‹‹‹Ž|`VW`lw€†‰ˆ‹‹‹”“‹‹‡{wqjd]VTRQOOPPLIIIGD?;861,'",>O`mw‰ŒŒŒŒ‹‹ŽŽŒŽ‹’’’’’‘’““’“““’’“•—˜–••””“’“““”“”–˜™—•––šš˜–——™™˜—˜˜™šœžœ›š™˜™™˜—˜™››—›œššš˜—™›››œžœ››ŸŸž Ÿ ¡¢¢Ÿ¡¢¢¢ ¢¢¢£££¤¤¥¥¦¤£¤¦¦¦¥¢¢¤¤Ÿ¥¨§©¨§§¥¡¦££¦£¨¨¨ª«ª§¦§¨¦¦©¬«©©«ªª¨¨¨ª¨§¬®¬¬¬¬««¬¬«©¬«]\YZZZ[\][[]]\^]]^\Z[\ZZ\\\YY[\\]\[YZ\][]^\[^_^]]]^[^^_`_^^^^]]Z[YO?, !%)4862/*))$ ! !!!"&*+*.+/1Jh‰Ÿª®©‹x~€‰Ž•˜™žœ’„iJ>7=EPY^kqlbXXXXW[Z^bnx|€…‡rj`]XXU[[YXYZQFDADGKMTX\_hkory~€ƒ„ƒ{vrkbULLOPQS^dihoppnmmpotvxz€~‡‹’”—•Ž’’‘ŽŽŒŒ‹ŽyXQFQUbkqw}ƒ†ˆŒŠ‹ˆ†‚}xnhc^YUTSKNLLIJHF?=<84431,% *BQ`p|…‡‰‰‹ŠŠ‹ŽŽŽŽ‘‘‘‘’‘’’Ž“‘‘‘““”’”——”–’“””’“••”•–—’–““’”—›š–“——™•–˜š˜˜•š™™š–˜šš—–•™˜œ˜›šš™™™™˜˜˜ššžžžœ ŸžŸšŸŸ¢¡ Ÿ¡¢¡ž ž¤¥¥£¦¤¥Ÿ¥¢¥££¤¤¥¤ž¥£§£§©ªª§ ¦£¦¨§¦¨£©¨§¨ªªª¦ª¨¦¤§©ª¨ª¦«§©©ª©ª¨¬®¢©¬«««©¨¬\\Z\[[YYZ[\]]]]]]`^Z[[YZ\\[ZZ[Z\\\ZY[]]]]\\\^_^^^]_`^^`a`_`_Z^][XTG1 + "#$%'()(% "&)*,--06]„ž¬±¯¥”}z}‚ŠŽ”š›œš›—wYFCLX^cdhmiXKFJMR\gkmsz‚Œ’…rb^YXY[[YVVSLFCAEHLPRTWZ`fjnsvx{}€‚‚}ung]QJLNOQXahjoqroopqopqvvw{€‚‚ƒ„ˆ‹Ž’•”‘‘‘‘ŒuWNIJLMRWakt{€„ˆŠ‹‹ŒŽŠŠŠŠ‰†ƒ~xpib[USQOMKLLKJFC@>>??=7/' !0G\mu|„‰Š‹‹ŽŽ‘’’“’““”’‘’“’“““”–•—–•”””’“•–•••–—”‘““–˜™˜——————˜šš˜—•–—››˜—˜š›œ›››››œœžœš›ž›™šœœž žŸ¡žœœž ¡ ŸŸ ¢¤¦¦¦§©§§¦¦¥¦¦§¦¤¤¦¦§©«©©©§¥¤¥¦§¨¨©¨¨©¨§¦©««¬«¨§¦ª¨ª«««ª«ªªªª«¬«¬ªª«®®¯¯¯©¬\ZZ[[\[ZZZ\[]\]Y^^^\[Z[]]Y[Z\]]\\[[Z\\\]_Z]^]]^_^Z^``_^``^__^__]VM<# $''&$ "')*+-,.8a£®±¯¢ˆxs{ƒ‰“™Ÿ ”‹ycOLW__^a`fe\KGDHM`kmotuvz„•zaYWY\\\ZVSKFA@@FJQUUTWXXYaeiloprv{~{sl`WIKMOKTZcjosturntuuuuuvswy|„ƒƒ…‡…‘’ŒŽŽ‰“““Ž‘‹tXOHKJKLNQV[afmu{„ЋЋŒ…‹Œ‰†yrgb\XUSMMMMMKFECCEDC>70,(" 3ALXfr|ƒ‡‹Ž‘Ž‘‘’‘’‘‘’Ž‘Œ“‘•“”–—–•‘•’””’“‘–•”–••“““•—™———˜˜˜’˜™˜––•–—›™™”˜˜šš››žœš›œœ™œŸœ˜›œšžŸ—Ÿ›žœŸ¡ž¢ Ÿœž£££¤¥¤§¥©¦¦£¥ ¨¦¥¤¥£§¢¨©ªª§¥¤£¥¤§¨¨¥¤¤¨¨§£ª«ªª«©¦¦¬§ª¬¬¦ªª«§¨¨ªª«««§©«¯¯°°¯¨\[XYZ[\\Z\\[[[\]]^^^]\\]^\\\]^\]\\\]]][]^__`_]^^_]\^__\__^^]]]^]SC. + ""#$'&$"! %(*)*+,-1^‡ž©¯®Ÿ…vvz‡‹‘™Ÿ¡Ÿ™‚sbWY]ba`aaaa_]SDJWclnyvlcgq„wXJLT[^]ZWPGA>;AGLV]^\ZWVUY[]bdfhkottqi^SJJLPRV_fkqwwwuotwz|{zzxswz‚ƒ„……ˆŒŽ‘Œ‘‘’•”–—“‰pXPLJJIILNNOPQV_fmvŠ‹Œ‹Œ‹ŽŒ‰†|unic]YTPMNNNMMJFCC=60./.-+% %4J^ozƒ‹ŽŽŽ‘’’‘’’‘‘’‘””“–––––”‘””’”””–™˜—–•–•–––™˜——–˜›˜–——˜˜—••™›š™š˜—™›ššœž›™šœœœœž››››œžžžœŸ¡ŸœŸ ¡¢£¡ŸŸ¡¢¤££¢£££¥¨¦¥¦¦§©¨¦¥¥¥¤¦¡¦§¨«©¥¤¤¥¦¦¦§¥¥¤¦¨©ª¬«¨¬¬©¥©««¬««««ª¦¨§¨©¬¯¬¨¨¨¯±±°®®]\YYZZ\\\\[[\[\\]]]]]\]^^\]]^]]]]]]^]]\Z^^___]]]__^\__\\^\\[[Y\YL8& ""#"%''&$"! "%&((*)(*PwŒ— ¤šƒyxz{…†Ž˜››–…wl\]^_aaaca`Z`d]GO^inzyfa\cjt}oTJ<JU[][UOEC@BGKNZbb][XWWZV[ZYY[]bfghbZPEJJOPZdlptyywvotx|}}{ywxy‚†ˆ‰ŠŠŠŒ„’’’““˜›•‡jNMKKJIILLLLLLQPSU\ev‚ƒ…†ˆ‹Œ‹„ŠŠ‡…{xpid`VTQQQSQOHGC;/,)*,022.+! 4BUdr}„‡‹Š’’“’ŠŽ‘‘‘‘‘”–—”“–“““–‘Ž”‘•—˜˜—“—•—˜—””•˜—›™‘˜™˜˜—”—š›–˜–––˜›™–š›š–—˜œ™œ™œššœ Ÿ˜žŸ¡ŸŸ™ ž¢ž¡˜Ÿ ¤¤¤££¢£ž¤££§§¦§§£¡ ¥¤¥ ¥£§¤©§¦¤¥¥§¦¦¦¥¥¥¤©§¬ª¦¬«ª¥©¨¬¬«ª«¤¤¥ª«¬«®©©§«°°¯®¯]\ZZZ[[[[[[[[\Y\Y]\[\\^`_]]^^^]\]^^^\\\\\]^_^``_^__^``[\]]]]\\ZSB, !%%##%&&&%#""" #&))(('<cv}}–”vx{€ƒ‡Œ”•“…{phcbabcdecb`_^acNTeny€ynaXX[bkg^N:?OW[ZVOEGHKPSU\ccba``_\^_]YUTTTY[\XRJGIKNP]gouvz||xtvz~€€{}{|~€ƒ‡ˆŒŒ‡…‡ŠŒŽ’‘Ž’™œ”‚cROKLMLKKKJKIJNONNLQZcinswzƒˆ‡ƒˆŠ‰ˆˆ‡ƒ~xrold^[ZVSPNKF;-*'(((.36:<:9/# !6HZixˆŽ‘’’“‘‘’’‘’‘“•–”‘”••—˜–”““”———––—™™š˜––—™˜—š™˜—šš™˜—˜šš™™››››™™™—™™™š›››œœœœœœžžŸ ¡ Ÿ¡¡¡Ÿ ¡¤¤¢¡¡¢£¤£¢£¥¥¥¡£¥¦¥¤¥¤¥¥¤¤¦§¨¨¦¦¦¦¦§§¦§§¦¤¨ªª«©©ª««ª©«¬¬ª©¯¬¨¨©«¬¬«««¯¯¯«¯\YZ[Z[ZY\]^\]]\\]][Z\\]`_Y\]^^\[]]]^\Y]\]]__`aa_`__``_]\]^^^]\UI8! + "$%$" ')&#"!%%$#$%%##""""#'('&7OZao…Œ~yw|€‚„‹ŒŠ…{tjd^dbbcffdcb\ZSXXalsyyupkf\SCOTZXK:?JTTUWSI\dhi_U^acbbacddeffaVYJTQUSPFDDHIKN]gmmv{€}vy{}~~}~…‚‡‰Ž‹‡ˆ‡ŒŽ‘‡Œ‘—›}_NOKLMMMKEKJIINOMKLJPSUV[_bflrtux|„…ƒ€}vxyskhc_RONKF:,)%&$$%2:BFMTWP?& %>O]lz†‹Š‘‘‘’’“’’“’”•”””••”—”–’‘‘•–—”˜”™˜™™™˜—˜š™š›››™–˜™—”–˜™™œ™™™™œ›š™šœ››œœ˜™šŸœœšš›ŸŸ ™ ¡Ÿ ¡žž ¢¡£ŸŸŸ¢Ÿ¤¢£Ÿ¦¥¥¦¤¡¤£¦§¨¦¨¥£¢¦¥§¨¦¥¥¢¥¥§¦©ª©¤¨§¨¨«ªª¨ªªª«¬««©¬¦ªªª§©«¬§®©¬««®®¬¬ª«[[Z[[[XX\^^^^]\]^][[[\\`_]]]]\[\\\]^]^^]^``__``a`^^``]\]\_`_][N<' +"$%&'(())'$! &*&""# "$&((&'&$#"$&&'3DNQZt~}~|~†ˆ‰ˆ„}tkfccfgfegeeeb\XTZakrutogaaeeS=DLNLC:>HPUVWVh‚— •ƒnddcb^\`fhhjnlia[VUTPJDBEGHKNZdjpw}€€~€|}‚†‰ŒŒ‹Œ’Œ‹Š‰‰‹Œ‡Š”™v[MNMMMMNLJKLLKMOMKJIJJMNMMNQSUX[aiotwzz{{{{}{ttqi_UOKD9,(('''*5BHMS\fieO@4$ $?Thu‡‘“’’‘’’‘”•”“““•–””•—–””–—˜—–—–˜™˜™—–˜˜™™š››š˜”˜™—•™››œ›™›››š››œ››žœ–šžžžœœŸžžžžž¢£ Ÿ ¡ ¡££¡¡¡¢¤¤¦§¦£¨¨¥¤¥§¨©«ª§¤¢¤¥¦§¦¥££¥¦¦¦ª¬ª§§¦¨¨ª¬«««ª©©««¨¨§¨«««¬¬«¬¬¬ª¨©¬¯¯¬¬®[[ZZ[ZZ[_^]^^\][]]\\[\]__^^\\\\\\[^]^^_]^^^]^____^^_^]]_`ba_[UF- #'***((),-,+*$&'&! #"""%(*++*(&## )-9EH@O^ov{ƒ„€}vke`bafhhfhbffb^THUdnsoldSKF]iZ>?A@>8.;BIPUXjˆ¥¹¾¹£…i^`_]\aegdjmuywtj`WLKBCEIKLOU^fmtz{{|}€€t}~…‰Ž’‘Œ‘“‘Š‰ŠŠŠŠ‹‡‰‹–—‡mXLMLLMNNMILNMLNONHKJJFMNMLKNNLNPPQX]_bfjuvyutt|ytjbWUG?-,,+*+-<HMOSTaf`ZTOI@4 + "2JYjx€†ŠŽŽ’“’’•“““”•––•‘”‘—––—˜•—“”•˜“–’”“•–••˜”••••™›—™›–•–›˜˜™›œ››œœ˜œœ›œ–œ™šš˜žžžž›žž £¤£ œœ›¢¢¡Ÿ¡ž¡ ¥¤¦§§¦¨¨¦¥¨¡¨ª«§¦¡¥¤§§§ ¤¤¦§§§ª¬©¦§§§§¦¦«ªª¥¨¦¨©©©¦£¨©««««¬«¬§ª§¨ª¯®¬¯©[[ZXWZ\]_]\\]]\]]]]\[\]^__]\[]]]Y\^___^^^_^^[[Z^^^^^]\]_ab_\WL:&"%)-.,)((,./000.)(&$""$&$!$),-.+)('&%*6=DC@FYe|‚ƒ~~€|xutoe``a`ehijhgffb]PEQgprmf[L;=Sk_E6421146;AJPYv¸ÆÌȶ–o]ZZ[^`bdfjoy€…†~n^RMGDFJMNMKV^fmsuxz}€„Š’“’‹‘““”’‘ŽŽ’Ž‘••cOJKKKMMNMMMNMMMNNOMMLMNOMKLMLIIHHJKKJPVgsz|~ƒ…~xsme[K=61.-/5@LQTVY[YXWV[^]RH</ +:O^mz„ŠŽ’”’“”””“”••—–”“•––•••–—•–˜—–•–”“•––—˜—˜˜—–šš—™š™˜™™™˜™š™ššœœ›œœ›šœžšœœ›œžžœŸŸœž ¢¥¤¡ ££Ÿ›¡¢¢¡¢¢¢¤¥£¤¦§¤£§§¨¨©¨ªª¨¦¥¦¨¦§§§¥¥¨¨¨¨ª¬©¦©¬«¬¨¤©©©¨§¦§¨©ª§§¨¨¨©©¨ª¬¬¬¬««¬«®¯¯[Z[YW[]\ZY\[\[]]]]\\\^^Y]^^^^^^]]]_\_]^^^``]\[\]^]\Y^^^^_[YXO@. %'*/10/,),/1223441.)'&#'*(###*.1-+++*)'*8?B>;K_p„‚„…‚{shiig_``aaeghiheffb_RAUioood`NF;XifVI=:77799=BHPqš²ÂÈÆ¸uUUVWY^^`dhotx~ƒq]XRJHGHIMLOSXZciloty{|€‚„‡Š‹Œ‘’Œ”•““”‘””“‘““•‘“”}ZOHKJJIMNMMMLMMNLOPPONLOONHMNLJIHHHHCJMWlz…ˆŠŠ‹Œ†ƒzqeTC?8406:HRSVXZ[XWUWY``_\WOC1% +*:Q`o{„ŒŽ“’”””“•••”””–“—•””˜–•–—•••—”””˜™™——˜™™ššš—™šš˜š›š—›™™˜›œœ›š™™šžžŸ™›š›Ÿžœ¡ž ¢£¢ ¡¤¥£¡ ž£¤¢¢¦¢¢Ÿ¦¥¥¦§¤¥¥¥¦ª¥¥¤¨¡¡¡§¦¦¥¦§©ªªªª©ª©£ª¥§¨¨¨§§§§©¦§©¨¨©ªª¥§¨««¬¬§«¨®XYWZX\][[\\]]]\]]]\\]__]\\]___\\^_^____^]__^]]]]]]Y[__^_^[XSF2 %+/14530.-.35567678972)(*-.+(&+1451,-,*(+8?A:9Net}€…ˆƒ{mc^^__^_bddeghfddggdXOYkoqssj^U[fjlxyp^N<;:99=FTjŒž±º¼µ{URUWY[\^adhkklqrj]\UNLKMNLMRTUUX\`cjquy}€€ƒ‡‹‹‹Ž‘“•••“””‘–˜—™™™›š™™š•zWNIKJJILMJKLNPQPNPQQPNMNONMLLKLJIHFFHKPYrŒ‘’І…wiWJGFBABKU[]\Z]]][[\^_a`ba^ZQIA/! 1DVhyƒŒ‘’“““”““””“–šš——–——˜™˜•—˜–”–˜˜š™˜˜™œžœœœœš™™™››œœ›šš™šœž›œ›ššœŸžžžžœžžž ¡žŸž ¢¢ Ÿ¢¤¤¤¤¢ Ÿ¢¤£¢¢¥¥¡¤¨¦¨¨¨¨§¦©¨§¦¥§¦¥¦¥¥¦¦¨¨ªªª©¬®¬ªª«««¨©ª¨ª«««ª©ª¬«ªª«ªªªª©ª¬¬¬®®XYZ[Z\\X[]]Z]]\]]Y\]\]__]]\\\]\[]]]\___^]]^^^]^^__^^_^]_^\UK;" +!)0465420/.3788:;;;=?CA;544AB6*-2684..-+',3>B;1Jfupz{}|th^WQV[^]aeebffgdhihg_Tblpqz{tgfouip‹ŠlO:::>CT]j}Œ™ ¥¤–xUQRWXXXXY]_^[[Z]`_^WNOMPOOOVVWRWWVS]cglptz{ƒˆŠŠ‹Œ““”••–—“—š›œž ¡ž—xSOJLJJIMMLIMOQRRQQRRONLNLOKKHKLLJIEHKPUex†‘‹ˆ‡†…„ƒxiVIJJIIOYdljfdcca^\^`bdc``YVUZWND:&"=O`n{„Š’“••””““•˜™–—“•”˜™—–™˜—”–—š—š™™“œœš•œš™•™™™šžžœ—›˜–•šš›™˜˜›œ›šŸžŸ—š ¡¡¢¢ž¡ ¢£¢££¡£¤¥§¤££¦¡ Ÿ¤¢¦¨¨¦¨¥§¨¨¡¢¤¨§¨¢¦¦§§©¨¨¨ªª¬«ª©ª®¬¬¬§ª«¬¬«ª«¨¦«ª«ª«««¬®«ª«©®¯®¨W[\][\YY[\\\]^Z\\[\\\^`_^^\Z]_^]\Y[^_^^]__]][^`_]a`__^]^^[Q@+ +%.46732///27:;:===<=AHWYSJR]dU>.059731.+'(0<D>8Ghx}}~}{olbWNOW`]Y_dfhgghijjihdaflqy~€yqmr{mf”´¤€X;:>I\ejltˆ††Š„qSOQUXUSUWVUPKIKOU[]WOOOQQSVY[[\ZUQMLSW[`gnv}ƒ†ˆŒŽ’“–™š™›¡££¡ŸŸŸ –xTQKMNMMNONMNNPQRSPPQNOQPPOLKKLLLKKKJLQUlŒ“””‘ˆ……†„vfVKKJJKUapyzyrmhb\Z[^beec`]ZZ]_]ZWM@4$(@Rcr€‰””””””“””•–••–””””—˜—––™™™š›™—š›™™››——˜™™œš››œžœœœ›ž›œœŸ ŸŸž¡¡ ¡£¢¢¢¡¡¢¢£¢¢¡¥¦§§¨¦¦¥¦¥§¤¡¤¥¦¦¨¥§ª¨£¤§¨©¨§¨ªª¦¨¨§¨©««ª©«ªª¬«ªª««¨¬¯¬ª«¬«ªª¬¬°°®¬©¨¬®ªZ\\\[[YW[[\]]]\[]]\\\^_^]\[Z[]^]\Z[]^_^^`_^]^^``_____^^_]YK6% '/46640.//37:::>>=:<>SekkilsyiN4*28974/+%'):FC9Nqƒ†ˆŒ‹†}ndWTR]c_X\bdghgheifgddcgju}‚}wqkus{•«´£U@GLXglmjmprlhtrjRMLPSRLRRLBBAF@BFSXVPPNRQVYXX[_`ZTIIJQQSVafntyƒˆ‡…ŠŒŽ‘˜™š˜œ¡¤ž¡™ ”rTRLNNONPPOMLKNOSSQNQNQSRPNLKJLLKJLLLMQVt‹’–••’ŽŠ„„ƒzt]RKLCJJUes~ƒ~xpcaVZT[_a``]\[\]^Z^]VME=0" +EUdtˆ’’‘”•“‘—˜˜˜–’‘‘––——™›š˜›œ–›™›œ›™—”–˜œ›žŸœ–Ÿžžšš›žžžžŸ žœ¡¢¢ ›¡£¢¡¡¡¡ž£¤¤£¦§¥¤¦¡¦£§¥¦¢¢¢¦¨§¥¥¦© §¨§¤©ª¬¬«¥¥¤¤¥©«ªªªªªª¬¬««©««¬£ª®®¥«§¬«¬ª«¬®ª°ª©©ª«§[\Z[[ZZ[[[\^]\[[\\\]\\\\\]\Z[]^]\]]]\___`_^___`a`]\____^[TC, +"'.1331.-.0449:=>>=<=H\krvx{~}nV:+.57861+&')8GGGSy‹Ž‘“„vhYX_cgaWZ_dffeeiieefedeiv}€|uooq}”¦«›xOMQT\fjkinsrmmpphYKJJNOPOMA@ACDDBBIRUUSSRRX\YUYafg]RJKNRRRVXYciov}€‚…ŠŽ‘”•—˜šŸ£¤¢ ¢¥ŸmTRONOOPQQOMLLNORTTTRORSRQNLKLMLKIMPNNU_}“˜™““‘ˆˆ‰‰ƒ~r^OMKKLOWfv€…Ї~xqkgaZRW]`]\[\^``aa`^XUTUKA5!-FYk{ˆŽ”•““—š™™—””•——˜™œž›™šœœžœ™›ŸžŸœ™—”™œœšžžœœžŸžžžžžŸ Ÿžž¡ž ¡ žœŸŸ £££¤¤¢ ¢¦¥¡¥§¦¢¥§¥¢¦¨§§¤¢¥¦¦¤¦¨©«©¨§¦¨¬ª©©¨¨¨©ªª«ª©©©ª¬«ª«¬«¬«ª«¬ª«¬ª«¬¬«¬¬®¯°¨©«®ZZZZ[\\]\[\\]Z]\[X\^^\^___^]^^^^^__^^_`^`^_a`\_``]^_`__]VJ7 +$%)*++*)+-2589:;><><>L`lpuy{xncT>(*/2551*$&(5EJGU|Ž’†{lY\`fibVXYdgfegjjfghgachu{|}~|xniZs›ž‹gKNSTVUa_ipuvsqpoi^RFIMTRRQNKJHKKICEKSYYWVU[ZWU]cikc[URSVVQWTXYY[ejrx}‡ŒŽ“”šœŸ ¡ ¢¤™‡fVTQONPNQQOKLLOORTUTSORTTSQNMLLKKJOQOKZj…˜››—’‘‹ˆ‰‡„s_PMKHOS_j{ƒˆŽ‡|xsppke^S`_VMSW__abb][VVUZ^\SE6-&6Pcrˆ‘“—–˜”–•••˜——š˜—–—–™›ž——™–˜˜š›œ›šš›œ˜Ÿ œ››œŸ˜Ÿ Ÿ¡žŸžœ ¡¢¡ ¤¥¤Ÿ ¡¥¡¤¦¥¤¦§¥¡¥¦§¡¤¢¢£¦¥¤£¨©ª§§¢§¢¬«ªª«©©¨©¥¦¦¬«¤¥¥¬©«©«©ªª«¦ª««¦«©¬¬®®®®¯¬¦ªZZVZ[\^^[]^^_^^][Z\^^\^`aa]__`^^^`]^__`a``aa``______^^]ZN;% $$%%%$$%*/3678:;=?><@ObknxzyujWN>+&(,00-&$#%1FKJWzŒŽ‡}n\]ejkcYXYcjihgghgikifberz}~~{reVbŒ{]GKPSW_dgjostsplkkdXGIXaehhhhaYSPLFDEP[^`]]]ZTYagikg^ZUTY[][ZXVVWV\bjou|„‰Œ‘•—˜••˜œŸ “`SSSQQQPPOMMLMNOORRSROQUUTQQOONKMNOQRR_w‹˜šš˜˜•‘Ї…‚€q\PKIHPUetˆŒŽ…xrppqojhdb\MHMZ_`^__^ZWVWZ`ed\TJC9- 3FZl{†Ž’“•’”•–˜—––™›˜–˜˜—˜œ›››ž–œžšœžœœœ›œœžœŸžŸŸŸŸž Ÿ ¡¢¡¡¡Ÿž ¡¡¡ ¡¢£¤¥£££¤¥§¦¥§§¥¤¦§¨¥£¤¤¦§§¤¢¦¨¦¥§©©ª¬¬©ªªªª©ª©©«¬®¬©§©¯®««¬«ªªª«¬«««¬¯¯°®®®«ª¨ª®®®[[\\\]^]^^_^__^\[[\\_]^\_`_]_`_]^__^^^ab``````__^]^^_^ZSD*$&$##$!! (/233478=@>:>Qcgowy||qbJA/)$&('%$""$8LNGRq„ŽŽ‹Šƒzpalyvpe\WV_efefbdcgihecdow{|€vfU_s|u`RGLVl€†ˆ…|xupjhijh^M[iu||{{|ysi`\OJ=O\beb]bb``gmmle\[VY\]^^^ZYZZYY[\]aiqz‚ˆŒ…{ƒ•›Žv_NQPRQPNPLJJLHMLOQQQQNQTURSRQQOJMNOQTWd|Ž˜˜’——”‹Œ…ˆ~}{mVRMJEPSfw‰‹Œ‚mf`ggfegf^RPLW`aYXWZ\\YXY]`efbZZYSJ@3( %=K]lw‚Š‘”––˜–˜—š˜šš˜˜™œ•žžžœ˜žŸ›œœœžžž ™š œ Ÿ¢¡ ¢£ ¡¡ œ¡££¡œ¡¥§¥¢£¤¨¨¦£¥¥¤¤§©©§¥¦§§©££¢¦¦¦¦§¨«®¬ª©©¦ª©«««§ª¦««ªª¬®®ªª§¨¨¬¬©¯¯¬¬¦¯®°ª«¨®«¢©¬¬Y]^^\]]^^^[_`^]]\\^_`a`__`^]^_``_^_^]^aca`^_``^`_]]__^VJ9" &)+.1/)#"&+-./137:><7<Qenqwy|p[E2+$"!!!!!%<QOFMfz„ˆ‹‰†€xpl|“™zjXTX^addabbfhgfcelsy|ƒ€wgU\jpqpl[FAPt‘›™”‹|ma_eiga`m}…‰‡ƒƒ„…†„sfTEO\dhecdedcimmiaZ[Z[^^]dd[[bfeb\YVWZ`fpw~€~pfew‰•ˆq^QPPRPQPONMKLMMMNPQPOOQTTSRRQPOONMNQSWi}›˜‘””ŠŠ‰‡‡‚yiTQMJINQdxƒˆ‰ˆt`\[ZY[^^TPU[`ca^[XUY\\[[^bfgc```_][[bJ7) ":K\o‰•–—™˜˜šœ››™™šœœ›œžœžŸœžŸžžŸŸŸœ›œž›Ÿ¡¡¢¡Ÿž ¡¢¢¢¡ ž£¤¢¡¡£¤¦¤¡¤§¨¨§£¤¤¥¤¥¨©¨¨¨ª«ª¨§§¨©««©¨©«ªª¨§¨©«®««©¦¨«®®¬¬¬©¦¬¯¬¬¬¬¬®¯°®¬ª«¯¬¨ª°[]^_^\\]^]^``__`^]]]`bbaaa]^^___^_`^_`a\`b`]^_``_]\Z][O@- "5?GJLMOKC7)($'(*,/158639Meoqqvy{|oZD3,%#"';NN>H_ov{‚{vpnª³†vXWX]\\[^cffd_][gnuz~€}ueWY`b_gkdPLLm…‘—–—~fRW^bccfw…ˆˆƒ~yt{ƒ……xjWFQY`ddcc\`_\Y[ZVVY]]^^_ii^\flkkga\XWY\]_cilbW]d€k]POPROPQOLLLOONKNOOPQQSSTNRPQPONNNOQSUg‚’›™‘’ŠŽ‹‹†‡„„weQNIHGLQg|‡‡ˆ‰‰~p^_VSQPNRS`fd^^_^[ZYaa^V^acdcba[\\ahh`QD9( &BTdr€Œ”””™™˜—™”›››™šœ˜œšž›žŸŸž˜›”Ÿ ž™œ˜™ššš ¡¢ž¢šžŸž¢¢¡žŸŸ¢¡¡¡¡ ¢¢¡ ¡¢§¨§£¦¥¦¦¥¥©©¨§©ª©§¨©©««¬«§¨¤¬¨«¬ª£¨¦ª©¬«©§¨«®®¬¦«¬¦®¯«ª«¬¥«ª¬«¬¬««¬®®©°¯\]^^]ZY[\_____`a`_^\]ba```^^]__^\`aa`a`]_b`\^_``^]Z[ZVH4 + 3O^dfefjg_P@-(''&)+-15316E]jklkkkj`Q@7/&# #(9LMBC[gjluxyvrp ¸¿½¶«™{f]ZXVU[bde_YU]cjpuy|ypbUPTVX^eijc^at~„†Š‡|]QP]_^`gr~~yqmjkv{{qeWORW[]`ca[ZTD@BBDNYabcejnj`\gmoqpmhc`^\YYY\^USW`y‰|d[QPQPOPPNLMNQRPNPRSRSRSTSQPPNONMMNPRSSf†–™—’Ž‹Šƒs`NKHFFLRl‚Œ‘‘“Š~rjf_UJFSakobZY^_\]aglga`bcbbb``_\aeea\WRMD9.#(CXm{…Œ’–—––˜œšššš–š››œž™ ž›œž žšœŸ žž¡£¢¢ œŸ¡¢£¡ £¡ ¡¡¤£¤¥£¡¤§§¦¦¥¥¦§¦¥¦¨«ª¥§¨¦¦§©«¬««¬ªªª¨«¬«©ª¬ª§ª¨©ªª¬¬«ª©¬®®ª«¬ªª«ª©¬«««¬®¯¯®®®°±\]^][ZZ[\]^__]_]``^\_a`\^]____`___```a`^^_`]___`__^\VN>' + +=\nwwrrswsj]L70(''+,020(/;OZXTQNOOMKA5-$# !%(:LNGKZddgijmkgpŒ«»Àþ®‘mY\ZXW[^__\V_efgnnqusk_PRJKJQXfrspljihjlsvpd]ZXS_gimspicegghfb\PQLSVYV_b`\WIIIE@@AO\cfjooj`_hmorqpmifb^ZYQVWRJS`y‡x_YSQMQOQQNKMORSROTWVUSQRTSPPPPNMMMMQQRTl‡—žœ˜•Ž’Ž‚p_EKFEFOUp†”•’’‘†zrkbWNEUdpugPSSVX\bmurmkii`ca`_`\`__[[V[XSMD;2( $5N\jy†‘’™œ›šœœš–ššš›š—š›žœŸžŸ¡ œž¡£šŸœ¢££ž¡œŸŸ ¢££¡¤¢Ÿ¡¡¦¥¥¥¥¢¤¦¦¥¥Ÿ¤ §£¡¡¨««¥§¨¨¦§ª«¨§§¬¬«¦ª¨§¦«¨«¬©¤¦¨«ª§«¬««¬¬¬®©ªª¬«¬««««¨©ª«¤«¯¯¯¬¯«°¯\][[\\[\\\\`_^^___^\^a`\\]`a_`__``^]^_`_^__^_____a_[RC/" +*C^r}~}}€~wgR;0)'*00.+&'3BGA;657>BE;/&$"!&*)(();JMIMW`dedbcaarš±¼ÂÆÅĸŸu[]``a`^_\[^elmkkiglli\]^YNJGQ^t€‚ztmgZWZiqh^UPQ`nqtoh^dmrpkaXOPQRSVX[gssiTXbjaR>9>Q`kmpoh`djnpqqroigd`_\XUSOJPaz„uZTRRQQSRPOOOPSTTWZZYVSQRSRPPPPONMMMPPPYq‹™ ™–•““•••‘‚m\NKFEGR[tˆ–•’“’‰{rh]VPFPdsypcOJLPVdr|{yxvrnjgd`_[_^\YZ[YVQKHCRQ= "5Mas€‹•››šœœšš›šš˜˜™šššžžžŸ ¢¡ŸŸ ¢¢¢¡¡ ¡ ¢¤¢¢¡¢¡Ÿ ¦¦¦§§¢£¤¤¤££¤§¦£¢¢¦©©¥§©¨¦¨ªª©¨¨©«©¨«®«©ª«««¨¥¨«¬ª©¬®¬¬ª«««¬¬¬««©¬®«¨ª¯°¯°¯®¬¬]\\\^_^^][^``\]Y___]]]`]^^`aa`^_``_^^^^]]^^]^^^]^`]XK6'2GWmt{|ƒ„‡ˆ„udP;0$)-/,(!'/;?7.,*-124-%$"!!'-0,,+=HGEKT[cffc`^[¤·¿ÅÆÆÃ¿‹a^^^\WUTSV\ekkiiijjqrxzn_VWWam„Œ~zwo`^VZ\SKKL`nrrj`fnwzwqh[XVVTTUY^q„…{nky…~mS:=C\joqpbekptssuwrigeddb]YRNHPby‚nUSRRQQRQLNOQSY^`defcZWRSPQLPPPKNKLMPPU\uŽš œ–•””””••Žl\OLGHIXczŠ‘—–Šuk\YVPDMas{xo]EMLYgt||yxxwvrkjbb\a^]YZ[WLM<;>RcH% +*<Tfw„Œ—™š™›•›šœœ›˜™šž˜ ŸžžžŸ œŸ £¤£Ÿ¢¡£¡£££žŸž¡ŸŸž¤¥¥¦¨¡£¤¥¤¤¡¤¤¦¥¤¤§£¥§¦¦§§§¥¨ª©£¤¨§¥¬®§¨¨¬¥ª¨ª¨«ª©©ª©£«ª«°ªªªªª®¬¬¨ª«®¯®¯¨¦¦]\]_```_][]a`]\[^``_^^__^^^`___``_[\\]]]^__^^_^\Y_[RA, + (<KZjtv|€‚ƒ‡‰…|n]K:,&)++'$'/9;0,)(#*'+$$#!!!"+1559AGC?BNW_cc`[ZjŒ½ÃÆÆÅÇż£ƒe`ZQFBAEOYaggfilmmz‰•œ”mcbecd~”Ÿ–ŒƒxlaTPD@EK^nomgenx|}zwrnhd_VRQU\p†Š‚ys…Žƒc=5EZipuqii~ŠŽ…tledfihd\SMJQfy|dSSSRRRRPNMNNTbrywvwsj^WSPQRSRPONMNPPQW_y›ž˜–—˜—”’“‘Šl[ONMMQ]oŒ–•“„wjb]ZUNJKat~}wj\VU]htzzwtuxywupkhhf`^[Z]YSKA86@PB + .DYk~Š’–™ššššžœŸ ŸŸžžŸ¡Ÿœœž¡ ¡£¤¤£¡¡¢¤£££¤ ž žŸ¢¦§¨¦£¢£¤¤¤¥¥£¥§¦¨©¨¦©¨§¨«©¦£ªª©ª©¦¨¬®¬«ª¬«ª¬®¬¯««¯¯®ª¨ª©§¨««¬°±¯«©«ªª¬«¬®¬®©ª[Z]]^^_^^\^`a_]\^`ba__``_^ab`^^^^^^_^^___`^[\]\\]]VH6 1ER^jsx|€„ƒƒ}yqcTD0*&)(%$,59642100.-*&#!""$%/8?CGJD7;EOVY[YVZq˜´¿ÃÅÇÄÇÉÆ¹¤‹ldPI=??KQY]_bdgiky’¡§œ|jifhev‹ž©¢˜Œ„|riYUCCCS^_^]amvxy{~}vjeZOHFHH[lpomn|€‰„e??K]jouuo‡Ÿ®µ¶µ¯¡‹qkcjonh\OKBUnzw`SSRRRRRQPONPR^€‘•Ž‹†}mYUPRSSSQQQOPQQPYa}“šš—’šš›’‘‘ˆ|kZNNKKL]q‚Ž”—–•q]`_[OMMZgv~yshc\ejvyzusnvxyzumprpd`]\][VOE<1;D4 + + + + <MhwŠ’—˜šš™œžŸžœœ› œœ›œœ› œ ž¢¢¢¢¡ ¢¤¢Ÿ¤¤£ž£Ÿ ¡£¦§£¦¢¤£¤¢¥§§££¢¦§©§©©©¥©ªª§¦¢©§©ª¨¨«©ªªª¬¥®¯°°©ª©¯®¯««ª«¥ª«®¬®®°°®«ª«®§«¬¦¬®¦°®«Z\\\Z]^__`_``_]\_abbabba_^bd]__^__`aa````_Z\\^^^]ZN;% + + + + + +&9LW]isz}†ƒ~wwwsfYL8.&&%#!$,3569:9961+'# ""$%*8AGKMD83=FPVWUSZ|¢¹¿ÂÆÈÅÇÈÉÆ½ª•pVIBCGLQUWZ]_bgu‘ ¡šŽrpponnvŠ—™“‹…„ƒ~yreNEENPRRYfmjqw|rf^J?7<?@ANVY^gpy}{`==O^intvŠ¥¾ÈÌÎÎɼ¤Švnosqi\OICYt{r\RRQRSRQPQPPQQ[~œ©¥”ˆwbUQRRRRPRSSRQQS\h€”šš˜™ žœ˜—’‰zfWMLKJI[p„“˜˜˜”Œ€idb^YRR[dlx€ysooqux{zxuqswz{xpvyvsmh`^\XRKA9;@. + + + #6HVgy‡”––ššœŸŸ¡ ››œ›œž Ÿ¡¡¢¤£¢£¤¡ž¢¤¢¢¤¥¥¢¦§¦£¦§¥¥¦¤¦§¦¦¥¥¦§¨©©ª©©©©©§¨¨§¨«©§ªª¬¬¬¬¬°±°°¬««®°®¯®¯¬«¬¯®¬¯ª¬¯¯¯¯®°¯¯±²ª[]]]^]^__````]\\___`aba``_aa``a``___`aa``]^__^]]ZTE.! ,<NW\hszy~‚|yutoeZO?/$# $%,1369;70*"" !"$%.5<AJME;:<FOQQONZ€¥¼¿ÀÄÇÇÆÆÄÊÆ½²¦™‡o^JKKNHNMQRSTf{††yvsrpmhd_t€€~xry~€‚„€rcXDCCKS]bfkqto`deV:88889<HNU[`fggV=DKZcmv{˜¶ÉÍÐÓÖÔ˳˜€ptupg[OJE_yykYORQSPPNOQQRRPWgˆ §¤™ˆvcSNQPQRQRSSSPRV_n‚•š›š— žœ›–’ŠwZQGKIKK_rˆ—™–‘Œ‹ƒwoh\YUakno|ƒ…„~usty}|}{yxtuuwwvpwyxutqlcaZUME<EC+ + + + + + + + )GYhwŠ“šœžŸ ›š™›™Ÿ žž ¡Ÿž¢££ ¡ Ÿ ¢¡£¥¤¡§¨§¡§§¦¤§¦¥¦¦¦¦¦§¨§¤©¤©¨ª¤©§ª§¦¥«¬ª¥«¨¬«¬®±®¯®©¬«¬¦®©¨¨®§¬«®¬«¬°¯°®°«ª°°±®¦\\]]]]^`___aa`^]^^]]____aa`^^```^^_^^```````_^\[VL:& #0?NX^hrwwy|}|ytpibZQD0! ""%'-262+! !"#'*-036?IMF:9=HPQOOQYr¡·¾À¼ÄÄÄÇÊÊÇÃÀ¿º¯›~dVTNLKKIHEEI\db`bhvurjd`cn~{rkkiqs|„‹Š‚nU<;DLU[bijh`cjulYG:9766AJNNJQRSQOMMV`lw€™µÅËÏÓÔÓʶš‡{wunbWOKGc|xcURQRSTQPOORTRPT\oŸ–ˆp]QLOPPQQRRTSQSV`o„“™œ› Ÿœœ›š”ŠtYOGIJLPdwŒš™‘ŒŠˆ…~tl]X^nz{{~…Šˆwqt|‚ƒ‚}yyywtuvtsvxz|{ytof`XPGDKF( + + + + + + + -G\q„–™›œ›žžžœžžžŸ¡£¡Ÿ¡¢¢¡¡££££¡¢¡¢¥¤¡¥¨¦¤¥§¦¥¦¦¤¤§©§¦¤§§¥¨©¨¨§©¨§©§¨©©©ª«¨¬¯®«ª«¬«¬¬¬¬¬«¬¬«¬ªª¯®¬¯°««®®®°®«¬®®¯®«¯]]\]]X^^^Z___`^[^]\\^__```___^___]``_^``a`a`_^][QA- )0=NX_empqtvvusqld^VPE1 !""#$(,*" !#$&*/32.4>IME88=IPRQONS^„¦·½¿ÃÄÃÉËÊÄÃÅÇÆÁ´š~hTPOPOKID9DBOISYjvunjbdhz|udknnputz‚†‡v_H:FGUWadcbv€ˆ…uZ>:434@IMOMMTWXXVNVWgqxŠ¥»ÇÊÐÏÉ¿—ƒwusmaZMNKf|x^WQOOSSPQPNQSRQSViƒŒŠ}m]IMLOOPQRQRPURSP_p„‘”—›ž š“››—‹tWPGICNSj~™–‰„„ƒ|sk[\gz†‚vyˆŠ‚yrn{ƒ„„€uyzxtuvutww|{{yvmje]SIDND$ + + + + + + + 1?Tdq~‹–š™œŸšž ¡¤£Ÿ¢Ÿ¢¢¢££Ÿ¤¡£¡£¦¥££¤¥ŸŸ¡¦¤¥£¥¡§¨¥¥¦¦§¤¨¨§¢£¥©©©§«ª¨¦©¬¬§«¬¥¤¤©ªª¤®««¯¬¨¨ª©©®°¯ª®±±¬¬«ª©®®¯««¬®]^\^_^^^]]]\]]\\_`^]_```_^]_`__`aa``````aaa`_^\XJ4 + $/5<MW^bghkmnnkkmicZRMD2 ! $"! !#$&+152/4@HKD86;IQSTOKHNd‹¦·¾ÄÈÉÉÉÆÄÅÉÉÇÆ¿®–wWKOPNLIDBBFKLNUfoogiqu|~sghovxyxrsuwzp\KFJSY^][[sŠšžŸ—‡f>7226BINRRTWYZ[[YVZdijsŠÃÈȶª›Šzwsplg^TOUj|lYQOOQQOQPPRRSUVWbszr`SHGKNPPNQRQQTVTSO^u…‘”–› ˜’™—‹qTOMKKOVp†‘•‘І„‚}vog_`u…„tu}…‡zspxƒ„ƒ{{zz{}}{y{{{{ywtpkaTLLMA! + + + + + + + + + #5Pg{Š”šœ›™ ¡¡ ¢¢£££££ŸŸŸŸ£¥£¢¥¥¥££££££¤¦¦¥¥¦¦¦¦¤£¦¦¥§¨§¨£¥§¨©©ª¬«¨§©°¬ª©©¨¨¨©©«®¯±¯¬©¬¬«ª¯±¯®¯²°®¬ª¬®¯¯®¯°±°¯¯_]]]_]]\]^]]^]]]_a_]````_]]]````ba_\`a`````^][YQA) 2:>HNZabdddgjjfkjg`WKJD6$""""" !"! !"%+152(5AFGB98;IQRSPKG?Qf®½ÄÅÆÅÃÄÅÆÇž·§—wYIEKNKFFAIMQPQR]b_\et{vdikv{~}vutsnfTKFMVZ[WM_}•££¡˜ˆd94/6:FKMORUVWY[___^ec]U{£»Á¹œŽ…zxwumkif]_cŠiVSPQRRRQQQORTUSVZXUPEHJNPRRPPQQPSTTUQbyˆ“–—™Ÿ¡œ•š–ˆnQQOMLP[u‹Œ…†ƒ€wnedcm~‹‘†uu|„‚‚zujsyƒ…„ƒ{{{€€€~}x}|}zyxuoeTPMK; + + + + + + + +@[n‹’——˜ŸŸŸžŸžž¤¡¢¢¡¡ ¤¤£¢£¤¤£¢¡£¥¥¥¦¢¥¦¦¤¤£¤¤¦Ÿ¥¨©§ª¥§¨¨£©¥ª«ª§¨¤®®«¦¦¨©«ª§ª¨®®®¯¬®©®¬¬¨¯¯¨¯©¬¯¯ª¯±²²±°¯^[\`_^]]\_`________^`a]__^^^__`_``__ab____[Z\]VH6' '?NVX[_bb_\]cgjkjid]ULID:85.)*)$! !!"!!"!$.34315ADE@:8>IQRRPME>CSs¤ºÂÄÿÁÄÆÅÅÀ¸¬œ‹ydN??EKIGEGLPSTRQUXVU`owwohnu|‚ƒ‚~{yuoeZLGMRTTNRe…˜£¤¢—„]956;BHKLMOQORW^bcdfd^SKp®®£”€xtstvtpkipz‰—¦¯Ÿzmg]UTTSPOOPPPRSRPILJJKNPQSSQPRQPRQUWYg}Š’“–—˜œž›š”…lQQOMMR`|ŽŒ‡…„…ƒ|rhb`etƒ’ˆxv|„‚vkkv„ŒŒ‰†ƒƒ…†‚€}|zzwsj^UTJ4 + + + + + + + + + + + + 8Pfv†Ž”šžžžžŸ¡¡¡¡¡¢¢££¤££¤¨§£ ¡£¦¤¦¦¢£¦¥¦§§§¨¨¥¥©ª«ª¦§ªªªªª©§§¨©¬¬ª¨§©©«¬«¬ªª¬®¯¯®¬¬®®¯¯®®««¬¬ª§®«ª¬®®¯±±±±°°]X]a_[\]^`a]````__```a`__^^]___^^^__``_]`^^^_\O=, + 2L[dedc^]ZXU`ilnlfaZRKF@FLNLIE<0$!! "##"#!*37;94:BD@=:<AIORRPJD<?Ek¸ÂÄÂÁÃÈÊÉÇ¿¯”qaE=763=CC<DFLMQSRNSUUO[ehihfox}~„€{wpeYKJHNSZb|›¢¤¢–‚`??AHONMMJKKNPX_dffeaYOHo™žŠzjb\aemqqikmuŒ£¸¼Ãº¬žŽsbTVTPONOQNPRQONMMNOQSSSSRQSSSSTUVXm‚‹‹Ž’“’•—›š’jRPMMNVfމ‚ƒwgfdgj{‡“–‰zzyz}‚yoor†‘‘‰ˆ†„‚†††…ƒ€€€€z{sxulbZVH- + + + + + + + + + + +*DXl}†•˜œ˜Ÿ¢¢ ¢££¢¢£Ÿ¥§¨¤¤¥¦¦¥¡¦¢¥§§¦¦¦§¦©¦¥¦ª©©¦§¤«ªªª¨§¦§ª¬©«¨©©«ª©ª§¨¨®¯©®°¯±¯®®¬«®«ª¨®®«¡–¤¯¯±¬®°°][^_][\\]_aa_`^_\^acaa^^^]]]^^]^^```^^__`__`^VE/ + +#=Vckllhd\WUT_muxtm_WMGCAKX]^\XI3%! ""!#$$$%&.;@A?=@DE@<9>FILPSOIC<<Ecš¸ÆÇÆÇÊÊËËȽ§„`D4.121279:?FLNOPOOORSQTYZ]aeouz|„‚€€ƒƒ{reWMFLXn}Š•™œžž•„cNQ_msriUNILNPW]cgebZQJFl“ŽtTGCKP[dlkilpvŠœ¦¯·¾ÁÁÀ±”qTUSRQPPQRQQOOOOOQRQSRSTRRUUUUSTWYq…‹ŒŽ‘Ž‹‹“•–™œ’€hRRPPS[jŽˆƒ‚‚|rgegnx…’––‹zzw~‚€~zvnp†••”‘ŒŠˆŠ‰…ƒ„…„‚}xwtk_YVF& + + + + + + + + + + + + $2K]oŒ”šžž ¢£¥£¢££ ¥¦§¦¦§¦¦§©¦¤¥§¨©¨§¥¤ª¬©¨¨©©©©«ª©ª«©¨¨§¨¬¬¬©«¬«ª«ª««ªª®¯°¯°¯°°¯±¯ª©«®«¬¬®¬”›ª¯°¯«®°¯\Z^^]\\]__a`___^^_abba^^]\\]^^^`_`aa```_`\__XK8! + +-DXemoplbWNRWdq{ƒ‚|oWNB>:JV[_^ZH/# """"#!$&%$&(5BEBABDGD?:6AHJJNNNID=JMi—ºÈÈÈÉÊËÆÈȶšuS<-0220/-/1<GJLLKKKORSPQRUT`dnov|€ƒƒ„„ƒ€xgUG9ERaov|~‚ˆ‹‚mYpƒ›–‹xbXMROW]cfc[VKLEh‡}\K?GKMO[cloqtux€…‹•¢«´¾¹¡oSRPRRPLQSRONNOOPRQOPKMOQRUVWXWRY\t‡ŠŒ‹ˆ‹ŽŽ‘”Ž|dQSSTT^o…І‚~vl^hmv~”˜•yyy‚„€zzwrp…•–“’’‘Œ†‹…ƒ‚„„‡„~vwqj\XT@ + + + + + + + + + + + + + %4Paq~Š“—šžŸ ¡¤¤¤££ ¤¥§¢¢¢¤¤¨ª§¢¢£¨£¨§¦¥ª¬ª¥¦¦ªª©¦«ªª¡¨©ª©©««©¬¬«¬©¬¬«¦¬¬«°®°®©¯®°«ª«««ª¬¬¨¬ª¤ ¥«®®¯¯®¯±«\[_a__`_`^``^]^^[^abba^__\\`a``___`aaa`aa`^\P=) 2FWemqsk^MJKXfrŠŒ‹lTB7;JVY]\VD+! "#"#$$$'&$(1<KHBCFIKF<98CIIJOSMFBN]jt¸ÇÈÉËÍÍËËÆ®Š]B3.3410-+(09DGFHKKKNQQNKPU\bimosy~‚~|„„‚€vaK;8=EINRV[ajw{xtu…—¤¬«¢‘|h\VOU[cea^VRPUfqkZHKLMKJQboy{}}€Œ—ª²˜jQQPPQOOQQPOONMNOQOMNMLMOQSUX[\[[_u‰‘“‹‹ŠŒŽ‡waVSTUV`t‡‘†~yqg]jv‰“›œœzz}ƒ†‚|wtpq‚’”“”••”’‘‡„†‰‹ˆƒ}{xrhYOL; + + + + + + + + + + + + + + + #3Mbv…”›ž ¡¡¢¢¤£Ÿ¢£¤¥¥¢£¥§¨¦¤¤£¦¨¨§¥¥¦§¨§©¦©ª¨¥©«ª©¨©¬ª««®«©¬¬¬ª®¯¯¯®¬¯¯¯®®®°®«ªª¬®®«©«®®¬®®®®®°°][`a`ab`_]]^_a`^]_aba```^]_``a`^`ab`a```ba]XI2# + +0CUclpsl\UPTXfq}‰ˆzbIDBOW[][VC+""!#$$%&'&$,?LSKAGLOOG:9<IJHIQSMCBSj}¦»ÆÉÈÍÏÎÎÌÄ£tN420661-..03;@ABCDGGIKLKLPX_elnpru|~~{€…„€yjT<98;@DCCCA?MYafiq€‘›¢ œ~m_]QVX`cba_\^hx…yh\TOLK@Rdr{||‚‚|{y|yƒ’„_OPKMOPPPPNLMKKKOLNMPNMLOQRMUY\[Zaw‰”˜“ŒŠŽŒƒrcUTQTR_w‰’…wvlf]o|…˜ ¡ ”~~„‡„}ulif{Ž•‘˜—˜˜—‘‘‹ŠŠŒˆ~}vtrgURL7 + + + + + + + + 3BXk}‹”›ŸžŸ¢¥ ¤¢¤¤¤£££¦§§Ÿ§¥¥¦¨§¥Ÿ¥¦§§§¦ªªª¦¨ªª©ª©©¨«¨®«©©¬®«®®®¯®©®®°¨¯¬¯¬¬««¬¯¯©¬°¬«©¬¬®¯±¯^^^_`ba_^^^]`a`^^`ab`^__]^__^``abbcca``_`_ZQ@+ + + +>P^impkc_[Y[en{†Š‰‚wgNNQTW]a^UA)# !"#%&&'&#%0JXWLGKQRPG;:KOLGKPRKBBPi‚š²ÁÈÊÍÎÎÍÌȼ•_<115770037;>??ABAAAA@DFHKRZ_gmprstwz|~ƒ‡„~o\E<:::>@@AA=73>HUYaoŽ•“‹~rnj_XW\]^ba^bn„…ufVMJHHUit{}€ƒ„ƒƒ€€z{xiTNNMKNONMMLMLKKMOPOQQONOQTRQRTVWYdyŠ’–”ŒŒ‘‰ŒmaTSQRS^z‹’Žƒ}wpjghuƒŠ’œ ¤¤›‡„‚„‡‚zqifgtˆ“˜˜™™™—–••“’ˆƒ{vpeSSL3 + + + + + + + + + + + + + + + + + + + + + + + + .HdyŠ“™ž£¥¦¦¤¤¤¤¤¤¥¦¨§¨§¨¨¨¨¨¦¦¦¦¦¥¨««ª««ª©§§©¬ªªª¬®¯«ª©ª®¯®¬¬¯¯®®¯®©¨¬¬¯°¯¬¬®¬¯²±°®¬¬¬°³±¯^]^^^``]]^]\_````aa__]]]^^___^`bbbbba``^^]UF4! "&4BN[ckjeggc]eku|reTLGHOSW^`ZO;&# "$&('&$#"1NXXLGPTSMG<EPSNLLMNG:<@Yu˜¸ÆÈËÏÎÍÍǯ‡O?/3576316:BFD>BCA?<6;?BELT[`glpqsrtux{…€tfOC==>=<A@CAA:76AKNP[j{‡‰ƒŽƒtdXXWY[ZVXdqzunaOLHHH[muz~„‚‚‚„|kdPJEKLLLMLNORTRJKMPOOPQMOORSRQPMNMXh|Œ‘““މ‘‰Š†yf]RPONHd€Œxligik|Š— ¥£‹†ƒ‚}uob`^p„•””–‘——˜˜—•‘‹Š†ƒyxqfTUM1 + + + + + + + + + + + + + + + + + + 'FXgv‡•¤¦¤¤ ¤ž¦§¦¤¨¨§¥¨¦¥¦¥¤¥¥¤¥©¨««¬®«¨¨¥ª¢¨¦ªª¯®¬¬¨¨¨®¬¤©ª¯¬ª¬®««§ª®°°®««ª«¬¯°¯¯®¬«¬±²±ª]]^^\^__\\]]_`aaaaa```__``\`a`abba^a`_]]\ZL8$ +%()2:HWdhgllgccfmrgS;:017EPZ^_UE0$"""##')($"""4O[YNMRUTMHDKTTPOLJHA76;Ef•¼ÈÈËÍÍÎÌǼ£ySE:646653:?EIFCDDA>756:>DMT[afkmnpqpoorx{xpaOA=@BAABDEFDC?==EILITcu}„‹˜¢ ’lXQQRRQMJSY\]^ZVRMJPaqv{}€‚…‰’šš–m^KAAHKJJKKRelhZMIJMMNPQRQQQPOPNLOPVj’ޑދ‰†€rbYRONMKk†‹}rhdbgm‘𢤥¥¥žŽ†…}zvm_^[k€“”•”•–™›™——“ŒŒ‹†|xhTWN/ + + + + + + + + + + + + + + + + + + + + + #A\uŠš¤§¥ ¤¦¦§¦£¦§¦¨¨§¨¨§¤§¨§¨¨©«¬¬®¬§«®ª¦¨«««®®¬¬ª©¬ª¨©¬¬®¬®®®°¯¬®®«¬¬¬¬«®®®^]^^^]__]]^``a``bccba```aaa`babcba`a``^[[TC* + ")+,-46JX\^aea^^[bbT6:<:777IW\\N7)!#%$%(+*&!""1M\aXMQTSKFDQXWSPKFB<68;F^˜¿ËÊËÉÍÎËŵ˜w]OC:36764=CFGEDKOJC</57=ENR[afhifjknmmhlomh^O>;@CBADEGHHGFBBBFGGJT^ht…¥¢’ƒpZOHJJJFKNRGWYY\\YZ\juwx}Ž ¬¢’€o_KA?HIIIJIf€Š†lHDCIJLNRQRPNOPOLKMMXnŽŽŽˆ‡‰}|nYVRRRQPsŽ”‘Šzo_^]dm†™£««¥©¨Ÿ“Œ†€yzun]\\h}Œ“–”—Žšš›•—˜—މˆ„€zkUWK+ + + + + + + + + + + + + + + + + -=a~—¦¦¡§¨¨¤¥¤¤ ¦§©ªªª¨¦©ª©©©§ª«¬ª©¨¬®«§¨«¬««©««¬¬¬«ªª®¬¬¯®¯¬¬¬®¯¯¨¯«°¯°°««®¬¬©¯°¯®«©¨¬a_^^___]\]_`aa__bdedbaa`\bccbaabaaa``a_]WJ5% + +"*03337?EFIOVWVVVVRA?BHGB;;CT[YF." "$%%'*+(###.J]g^NQTOGDLV]\YRIC<75:?Js¡ÃÌÏÎÎÍÌÈÂwhXG=9898;AFFDEKT[ZRF:55;HOR[adgfdehklib_cb_XL;9>BBBEEHJKJJJHFBABFJLM\w” ‚p]KEBEHJMPRPT^grwqieqyyz|~’§² ~paMB>GKKJGSw—¡›{N@@FJKNOPQROOPOLKNNZp‚ŽŽ‘’ŽŠˆ…€xiWURRSUX{–š•Šxl]\\brŒ «±¯«¨Ÿ•Œ…~zzypfcbg{‹’˜›™™šœ™—˜š™–‘ˆ…~{n[WH( + + + + + + + + + + + + + + + + + + + + + + + (Z‡¢¤¥§ª©ª©¦¥¦§©ª«ª©¨§¨©¦¨ª¨©ª¬¬¬«««¬«¨©ª«¨©ªªªª¬«¬¯¯¯®¯²±¯®®®¯®®±±°°²¯ª¬«¯°³²¯®«©©¯b`_^`a_^^^_^bba`cefeba_`accaaaa_```]_`]ZP>* )0589:<<827>DHJLKJFFMTTOG@FO\ZC$!"#$%%"')'##$2H]f^OOOI>FQ[b`]SIA777?B^…¬ÅÌÐÐÌÎÊú¦‡|n[F=79;<?DHGDGNYcb\PB94<JQT\_bddcdffge^\YTPOI;5:?ACEEGILMLHLID;=AEFGJn…•“‡yqcXJECNQ^dbZ^cp„yg_lsvzzz€ƒ›¬®š˜Š}paNC>FKLKQ_ƒ ¥¡UF>FHJHLLOOOLNOMKPN]oƒ‘“ŽŽ‘ŒŠŠˆufWTQPRU_€›Ÿ™wk\[[l|˜ª¯²£¨¥™ˆ†{puwsggcj{Œ’œžœ–—˜˜“››—”Œ…yn^WF% + + + + + + + + + + + + + + + + + + + + + + + + + 7| £¦¨¦ª¬«§¦§©¤©¨©¦¨¦¦¦¥¦ª¨¦¦¬ª«¨«¬«©¨¨©¨ª««©«©«¬®°®©²²°®«¬«¯±°°°«ªª¬«²²°¯®¨ª²baaaaaa_``__abbbceeeb_^_abcbacba`aa_^^\UE/ +$'+157753/,'.27=DFEJPW_c_SLIV_]?%!"&())'$$&%###6M^f\NJHB=GS^db\RE=67;BRm–´ÄÊÍÍÏÌǾ±ŸƒtXH<88:=BGIGFGMWce_UF<6=JRX\_]abaaab`^\VOFFIF;35:?CCDEHKNOOMJE?:>CFQ]l‚€xrod[RP[gu{xsqrzŠˆ|d_fqw}}}ƒ‹¤°©˜ˆ}rbOB>DGJMVb‹¤§¢„ZG?CGHIJKMLMLNNMORU`s…’”“””Ї‰‰ˆ€qaURPNPTa„¢Ÿ’kcbgz‘¤²´±ª¥£Ÿ“ƒ{tmnrsqjek{™ž¡™™š˜˜››˜–”…wibXD" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0wŸ¤¦©«ª¬«¨§ªªª¨©©©©¨§¥§¥©ª¨¨ª¬¯¬¬ªª¬«««««¬¬ª®®¬«§ª±±¯®®¬¬®°°¯±±¬«¬¯±°°±²±®§¯°´``a`aa````_\_]accccab`^^__bbaacbbaa__^WL9" + "$$"(+-.-,-++*-.27?AIRZeklcYX]c_F(%$(*+,( $""###8Sbg[IGF@:HQ\a]VM?94=ARc€£¼ÇÊÊÌËÊÀ·¢–…thYR@;8>DHFF@FFP[_\TG=4<EPW[___```^\VSROJC=DC9.24<@ABDEIIMNLHFCA?@CVk~Œ˜™‰otsk`^^r~•–••”’Œ|tbfkux{|„«³¥ˆ‚|qfXI=6@BDFU_ލ§ž[G:@CFIJLLIJMOMUY\`p|Š“”‘—˜‘…‰‹Š†€o^MRMMMWb‰¡¤¥’ƒopsŠž¬¶µ°ª¢£œ€{qndhfpsnejxœ¡¢Ÿ›››š˜›™˜“““Œƒ~wh\W> + + + + + + + + + + + + + + + + + + + + + + + + + + .tœ¥¤ª«©¥©§©¥¬¬¨¡©¥©¨¨¤¨¥©¨©¤©«¬®¬§ª¨«©««««ª«¬¬«¥«©¯±¯¬®¯°®«¨«¯®®±¬®¯¯¯°²²°©°¯X^``a`]`a```__`cbbaaaa__^aba`abc`_^``]R?) "#"!#&&)*-.-,+**+18?HQ\fnsl_[afbK,(())*-+(%#""#%;Ygh[KIE?EMTYZUOG<8:BTi}«¿ÈÈÌÌÌÇ»®™Ž‹„ty~viZKAHGFD@DEEOTUQG><>CLV[]^^^_^[VTNLID?<>?80139<>?ABEGHIGEDCA?@BVt£§£‘|uuqmnŽš£©«¬©£žš“‹†utz{…“¯²Ÿƒwo_VJ@77=BEHTr”ª¤—wTF:;BEHJKKJKLPUbt‚…‰”•‘‘•˜’Š‹ŒŠŠp]RPONNYj£§¨¥Ÿ—‹™¤®´±®¨¤£Žxnjgefmtqjiw’£¤¤ Ÿžœ™š˜•““Šƒ~wh_Q5 + + + + + + + + + + + + + + + + + + + + + 1s¦«ª©¦£¨ªª©ªª¨©¨¤ª«¨ªª¥¨¬«¦ª«ª«¬ª¨ª§ª©«ª¨®«ª©¬««««¬°°¯®¬¬°±±¬§ª®ª¬®ª¯¯¯¯¬®°²°°±±°¯\[_]^^]_`ab_a_acbabbbaabaab^abba__bb_YI2" + + + %&#!"$&)*+-0-,$)&'(17CNXbinkdcdhbL0--0100/,&$# $'C`ljXKIBDQWWXSMID;<>Un„™²ÀÄËÍÌÊ´¥’Ž„u~‘‘†wbLEBA@A=>BJPOHB?ACKPUYYX\]\WURLGD<:06:6,.169:;;;@BBBD???=:=ARn‹žšŠzpp{…𤬱´µ¶·ºº·³°®ª©¤–„v“ª”{phYL678<>GKi‰¢¬ž…hIB;:@EGHFLJLKS`ƒ¡®³µ³ª›“‰‘“‘Љƒ‡‰o\QQONJ\u‘¢¢¡¥£¡ŸŸ¡ª«©¨¥ŸŸœ~vmjdebmvsjny“£¦¨¦¡ Ÿž™™‘‘‘‰~xjVM- + + + + + + + + + + + + + + + + + + +8x¡¨«¨¦¦¤¨¦«ªª©§¦©¤««©««¥ª§¬¬«ª««ªª©¤ª«¬ª¬ª©©¬¬©¯¯®§®®°±®¬ªªª®¬«¬¬ª®°°«®®¯©°°°²°²®^_`__^]__bcbbbccbacca`acaabbbca`__bbZQ<( + +"&'%%'(*-00121.-,)'(+3<KT]bfjkkmi]G:7:<;:94.&$" &-LhqkTHFDJ[][WQLHC@>NkŽž ¶ÁÃÉÌÊÆ¼›’“‘ƒux‹›¦¤˜|WB><==:9=BIJEEJMOMLMTVVY\ZVSOJEB<7.-54,*-147889;=>?@@><978;C[q‚~vofv‰›¦¬±µ¹»¸º¼¿ÁÀ½º¶´·¶¬žŒ~z‰Ÿœ‰…~uhN269=@GYyœ±µŸ‚\E=:9<BFHJKMLLUm»ÇÎÑÌÀ®–ŒŽ‰}€ƒygZRPPOJ^}•¢¡ £¦¤¤¤£¡ §«ª¥£¡Ÿš‹{smhedcmvsmpz•¤¦ª¨§§¦¡™”ŽŒˆ„€yjXG( + + + + + + + + + + + + + + + + + + + + + + A|¤©¨¥¥§©¨««ªª©¥©©¨¨©¦©«¬¬®¨ª¬ªªª«ªª¨§©«¬ª©ª©ª¬¬®¯¯±°¯®®¬¬®¯°¯®««¬¯°°°¯®¯°°°®°°¯®±²²±²±¯^^`a____`aa_bccbbcda`^_`bbbbb`bb``a_UF1 + #$%$''),./011101/-+)+/@JTY_]imnmbQIEGIHFB?80)#!!*5VpsgRGE@R]\XSOPPONWb†¤°¨«´½ÃÇËɶ¤“Œ’‰yioz¤¤fN>:6;:99=ABCGMW[ZYVRQPRUTQOLHD@;6-,13.*(,.214689:9<>=;8444;@JUVUVZp…›«³µ¸¼½¿¿½¾Âþ¼¶°¹¶±¨™Š‚„‰Š}r~vfL37;?@K[t³¸¡„bE?654=DHKKIKGZ{¢¾ÆÐÖÔʸšŠƒsfv}r]XTQPOIb€–££¢£Ÿ¥¤¤ Ÿ¦«¬¨¤žž™ˆqlgfdd^jqocjx”¤¦ªªª¬«¦žž˜”ŽŠ‡ƒxhW@! + + + + + + + + + + + + + + + + + + + + + H¢§§¦¥¦¥¦¤ª¨©ª««©¦¨¥¥¤ª«¥¬¨§¥ª©¨¨©¦¨¥©¤¥§¨£©ªª¥®®°¯¯±©¯¬ª«®¬«®©«°²²°°¯°±±±³²ª«´®®®²¯aa``_`^``a^_abaa^ec``__`cdbb``aca`[\O:# + "$#%'))**++-..///.,))0ERV^`binleXJIMQSROKE>4+&"$.Gaup`QIFJU\YRJN[ehhoˆ¡´¾¿¸²³¼ÃÇż¬˜‹ˆzc\`l{Œ™¡˜|ZC98:;7667;@IT\`dc^XPKHMMKIGDA=83-,/11,(),-.0258889;;:7324678@BAD_~˜¨±¸»¾ÁÄÅÃÀ¿Ãý¼¹··´¯§›Ž}€}txƒqZF87;>?JUj‡¤§—}aD>8549AGIIHJM_‡¤¸ÁËÓÒʹžŠŠ‰za^kuj\WUQQOJe‚–£¤¤¤¡¤¦¢Ÿž£§ª©¥Ÿœ—‡qcaceecfjhbao ¥©¬¯®¬©¦£ ˜’ˆ†‚v_Q9 + + + + + + + + + + + + + + + + + + + + + + +M„£¤§§¥¥¤¤¤§¨¨©ª©¨¨¨©¨©©ªª«©¦¦¨ªª¨¨ª«ª««ªªª§¤©ªª¬¬®®¯°®«¬®®±²²±°±®°±±³°®®³²®±³baaaaaabbba`a`bbbcca_``abccb``bab`[TD- + #%'()))%'&)+,()*+,+*+3JZ^bddjmg[MCIPSUSRPKB7-*,0FXjrfQLGHLVZULOUgqtv… ´ÀÅÉÁ°©ª²¸³¨—…„ƒwdM;HScsƒ‘ކpRI9==:30*28GU]_eif`XNLHGEB>=;841-,*/0,&((+--./1338::874445899:;Sn’©±´¾ÃÃÂÈÉÆÂÄÇÈÆÅÃÀ½º´® ‘zrmrx„€ybB<49;<>HIW^o}wkWC>9618>DHJLNM]† ¬·ÄÌͲ™~ƒ‹„qZOah]NQPPQQNi‚• ¤£¤¤£›š™››¡£¤¥¢œœ’‹vk_acc^`dd\`h‡£¥«®«¥¨§¤¢¡–Œ†u_N4 + + + + + + + + + + + + + + + + + + + + +P†¤¨©©¤¤¤¤£¨©¨£¤¤¨¨©£¨¥¨§¥¥¦¦§§ª¨¨¨«¬¬©¬¬««ª¦ª¬«¦®®¬«¬«±¯«ªª®¯®¯°¬¯¯°²³²®¯«±®°¯°±¯¬¬¯¯b`abccadccbbaaccbccc`^___ccb`abba_WH3" + +!#%'))*+*'%(**(()''(()3M^^ehjlndT?@EQRQPNNLD9/.8P`lojWJC@@LSVRPUiquv|’±ÀÄÈÊö¥—•›“…xtrpaM701:DWizƒ†€ucN>@=5,+.4CS\_fkkgb\SPGA:753.211.+,,*&'(*,---//04887655458999MhŠ¢²º¾ÂÇÈÇÉÊÆÇÊÌËÈÇÅÃÁ½¸®ŸŠq`^cm|ˆ{gL876:;6<CHMQRPOPL@<9657;BFMTROZ‚›©©¸ÆÆ¹ª’{zƒ|gSOSUMEEFHKPXm…• ££¥¦ œš™™› ¢žžŸ ˜…wh_^\YY_`^^d†¡£§«©§¥¤¢ žœ—‘‘‰w`N1 + + + + + + + + + + + + + XЧª««©§¨¨©ª«ª¨©ª¨©©ª§¥¦§¦§©ª¨¨©ª«¨«¬«ª««ª©ª¬«ªª¬¯®ª©ª«¯¯®¬ª¬®¯®®°±°®¯°°²±±®¯°±±³²¯®«®°ba``aabcb`aaaacabcddba`^bcb```bb_\P;( ""##%%*53.&$')*))(%!$&+2L^chlnondRC>MWWVRHJIB722Ofqum]J:74ALPPPVhxwmrŸºÄÁÈÇľªˆ}sfYURSRI82*./7;O_o|‚ƒ|m^MJ:2,./CP]afiijhgd_UC@7534564/-,*(%(')++,./../167645159=@Rjˆ¡±ºÂÂÅÉÊÇÉÉÊÌÍÍÍÉÈÅÄÀÁ¼µ¥Žn^NNOaldQB6:<=<76@FJMMMMME8:9:7AEOPY][LZuŒšš¤³¶¯§jqzr`OD@<<<=777ETn‰—¢¢œ¡¤¡œ—šœ¡ Ÿšžš—’‡sgUXPVYYW]e†œŸœ¢¥¨¡ žŸž™’’’‰uaP1 + + + + + + + + + + + + + + + + + "_‘ªªª¬©©¦ªªªªª©©©©¢©§¨¢§¦©ªª§ª¦¦¦¦¥««¦««¬§«ª«¦«¯©¬ªªª®®¨¬©«¨¨ª®¬°®±°±°¯°«°¯¯¯®±¯¯¬®±³ab``aaaba```abbbbcbccbbccccbaabc_XG/ #%%%$$%,AC4'$%'()(&$"$%*1MailmqpndUHQ]efaWNHE?54F_uzyiQ;616ALLHFSqyom‡¨¿ÄÅÈÈÅÁ¬Šlg`O>==;62--/2137DUk{…Šˆ~scN7228EV_ddfhijkkh`TIB@@@>9621-+)(''())*-..,,/2554676=FYpŒ¢³½ÃÆÇËÍÊÉËÌÏÑÏÍÏÏÊÇÄÆÆÄ¾±–t\PHDCIJB97>AA>86>CEGHHIH@58:>EP\chjmf_\fy…‚…‘š£¦egphYG>968;:8526Ijˆ™¡œ–˜ž¢¢žœž¡¡¡Ÿž›šž›”ˆvf^WUUXY]k†˜››ž£¤£¡ žœ•ŽŒ’‡s`P1 + + + + + + + + + + + + + + + + + + + + + + + + +&f”ªª©«ª©¨©ª©¨ª©¨ª©§©ª©ªª«ªª©ªª«¨§¦¨¬¯¬©«¬®°®¯¬¬®°¯¯¯¯®°®¬«¨ª¬®¯±¯¬±²¯¯¯°±°°±²®¯¯°±°°²´bbbabbb`a_a`bcb\abcbcbbcccccbabaZN; + #$&&%(*9KH9(#%%&''$#"$&*.Mcknmnnkh^bkv{ui_QKA<3<Ohy{zhD;568>ED>@Ii€€w’´ÄÇÆÇÈý©Œ~ugSG<;32/..221.01CWkzƒŒo[GEER\acdefffcegbYLCEGFC<7310/-'(((%('+--*++0/55:>BGd{’¦³¾ÄÉËÍÏÍÍÎÏÐÓÓÓÓÓÏÍËÉÈËÊŸ jYVKI@E==>HHGE?7@@?@AAA?;3:8KZdnptuuqjeZhj`V\eŠ¢‹ccg`JF=:8?=;95135]}˜Œw„”Ÿ¤¡›¢¢¢œ–™šž Ÿ—–‘ƒwl_^Wchmt‰‘˜–ž ¤¤¡ Ÿ›–‹ƒo`L+ + + + + + + + + + + + + + + + + + + +,l•¤¨©©©©¤§§§©ª¨¨©©¦¬¨¨ª¬¬«§ª¥ª¨©¤¥¥®°§©®°«®ªª©®¯±ª°®¯ª¯««±°¯¯¯®«¯±±®ª²²°¯°¨±±°°°«abb``aaabcbcccca__`bbaacbaaaa`]^R@, + #$$'('+3BPI7($%%$%&&$#$%(,Kdkligjlkkpz†ˆ€vi]M@95@VlxzygN<89<>=:55>`{ƒ†’¨¼ÈÈÆÃǶ¢Œƒ|lYPG;521124631004DWk{ˆ“™—Œ}tolebaabegfc`_a^XJDDGFE?732230,()(''(),-++-/15;IV^p…™©¶¾ÃÈËÐÑÒÑÐÒÒÒÓÒÑ×ÔÎÎÎÌÉÎÍȾªŽskkk`VPOQW[^^VLFDB?@?;6754;DXlu{zz{zywne[PG>9Feˆ‡`\`YHFHMQKF=:61/0Ol‡yfh‡™¢¢£¦¨¤š•”–› ž˜—’Œ†yplmt|ƒŠ•˜› ¢£ œ›–Œ‹~h]H% + + + + + + + + + + + + + + + + + + + + + + + + +1p–¤§¦§©¨¤¦¥¥ªª©¨¨¨¬«¨©¬®¬«ª««¬ªªª«®®¯®®¬¬®¯©¯±³°¯®®®¯®®®°±²³±¯±®°°±±°®®¯°°°¯°¯°¯°®a\a__]abbbbcbccb_`_bb_`]```^_^]XI0$ "()((()-9HQD+'$$"""%%$"""(,Hchc`]_bdenz„‰‚zpcN445H[lqtvl^SGB??<6.16Up}‚–¯¿ÈÉÅÇÆ½™ƒwj]XQG:713378533332BSm€•—•‹‰}i`[`cghe^`_ZSG;ADDE?213453/-)*''((*.,--02=Eau†“ ¬´½ÂÅÈËÐÓÒÍÒÑÔÒÒÑÒÔÓÎÎÍÉÈÎÏɲ™{g€’–•ŒŒŽ‘’Œ„oTVYPHE:7321<H_rwyz{||{wriX@9-69YneXUWRIFH^omdZD;3.,CVgodL`~’Ÿ¤¨ª¦Ÿ›‘“Œ––›–“‘…{||„‰•š›œœœ™˜–—˜“‹‰‰‰…ybXD# + + + + + + + + + + + + + + + + + + + + + + +4s˜¥§¢¦¨ª¥ª§§¨ª§¨¨ª®¬£«¬¬ª¬ªªª«¬¯®¯®¬¤¬¬«¨¯±³²¬¯«¯°°®°®¬¬²°°¯±¦¯±±®°®®¯°®±°¯°¯®°«¯®aaaa__ab^^`bbccb__`bba_aaa``_^ZQ?* + %+*()().ENM>(&$#"!!%&$$##&)Eae_WSPSW[dr€†}tfM26DUdlonqpng\LB>:3,,0Jao~˜²ÁÆÆÇdzžˆ}pca^ZQG@9678974452-0@Yp‚“””™œ›ŽxYW^cfgeeb_XN=:AFED;00565541/-,+**,//..1@On…˜¤³·º¿ÂÅÈÊÍÏÏÐÑÒÓÓÒÑÑÑÐÎÌȼÂËÏËĸ¤‡–°¾À»µ±°±³±¥“dmuobQB<514=Lbuwwz}}ztmX<42=IU[WMJLJD@Ch‡Œ{iUA.-;GQTPFZw‹–›¡§©§¢›’‘“•™™•’’’ŒŽ‹•šœžž›˜•••”–‘‰„††‚saR>! + + + + + + + + + + + + + + + + + + + + + + + +8x›¦©¨§¨ªª©«ª§ª«¨¨«®¬¬¬¬«ª¬®¬¬¬«©¬®¬«®®®®«¨±±±²±°±¯¯°±¯®¯°¯¯®±±¬¯±±°®®®°®±±²³²®²²°±``cb`]_`]\accbba``abbbbbbb``^]TE4 )*)**++9KOG6&%$#"" $%$$$#$&A[_TMHHHJLYe|„€}rbK7EXfppqrprppl]G@83,--BXj{šµÁÄÆÆÂ¸¥†wkjgc`ZSLC?8::81120+,/DVn‰‘—œ ˜…hRY^bceedaWH<<DGD>7.167455410/.,,,/234H[z“¥¯µ¹¼¾¿ÁÂÁÈÇÉÅËÍÐÎÒÑÒÐÐÎËÆÆÂ¹»ÊÎʸ©—¢¼ÆÇ¹·®±°¤’r~Іy]FA;::@J_qutvx}{zzriW=:8IVZYTFEC@::;eŠ™š€kVC2=ACDDDXqŠ”œ¢¡ž™‘–™™—“––•‘••“Ž‘’˜—œ™—“—’“”‘‰ˆ†‡~qWM1 + + + + + + + + + + + + + + + + + + + + + + + + + + D§«©©©«¤¨¥«§«¬ª««¬¨¨©ª®®¬¬®¬¬¬¦«¬ª¬¯®¯¯¬¨°°±²¬°±°«¬«««¯±°¯°®±±¯©²²²®ª°±®®°¯®³´²®_`cc`_\\]`acdcbbcccbddccaa`_][M7# +$+,))*,2@NL?,%$##"""#$#$$#$&=TVLBAAABGRgw}{ym\HHVjuxwuuvtquvkZD94/.-9Og »ÄÆÆÃ»¬”ƒ{umppmge`ZUPKGD@85/--,.27BRjx‚Š’˜ Ÿ”s[NV\adffbTD=@EE?82/16655554320/../5<Qk‡ž°¹¼»ÁÃÂÁÂÂÂÇÈÈÉÉÉËÍÐÒÐÏÎÊÉÈÇ»ÁÉÌɸ¬¥ºÂÂÀ½º¸µ²©‘‰ˆ•”†fECA@@AEYlruuuxywwndTEAFR^^ZUJA:5349b‡›¢—‡t`L?>??>>CTgtz|‰Ž‘“‘‘—œ›™———˜——”Ž‘••——–—˜™™–‘ŽŒŠ‚oUG+ + + + + + + + + + + + + + + + + + + + + OƒŸ©©¨§ªª¨©«¬«¬¬«ª©ª¬ª¨©¬¬®¬«««¯«««§ª«©«®®®®¬¬¯®¯¯¯°°®®®®«¯°°¯°³²°°±²´³²²³±±±±°°²³±°²³±²``babb__acbbcdccddccddb`aa`^[TC( + + + +#)+*+,49HQJ8'""!"!"##$$%#%'>NL?:887=DTgnnmjbXWYgt{~{vvvtquyvlZ?910.6?a„¦¾ÈÊÇ¿°›…stotwvrldd]ZUURLGA:40/.2575DObp~Š“˜¡Ÿ‹m]MTU\``\N;<AB?91.*/045546872221/6>[u¥´½¿ÀÂÅÈÇÃÃÂÁÅÇÇÇÇÅÅÇËÌÌÌËÅÉÌÊÅÃÄÆÉǹ® ž®»¾¿¿º¶±©›‡Ž‘“Ž]AB@@AA9QahnnpqkjhdWRHJMUXZ[UH=43368Xy—Œ{bJA899;798HW\^`dfhnt|ƒ‡‹—œš›–˜——™˜ŽŽ‹Š“•””•™œœ˜“ˆŽ…nSD' + + + + + + + + + + + + + + + + + + + + + + + + + + + O‡¢£©©©©©¦«®©«¦¬«©¤©¨ª¤¬¬®©ª¤©¨§§©«¬««©®®¯®¯®ª¬°²¬¯¯°®¯°®®¯±°°¯²´´±µ´²°°¯²²´±°¯²®±±ababee`abcbb``bc`cddcbbaaaabZJ7" + + +!&)*.7@HNRG4$!"#"""###$$%$&2@HC843259FUbeb\XSV`jqw|}{z{yuty{ylYC9214>YÀÉËĶ¡Šzoquz~}xqmic^[ZXQJF>71114658?FK[l|‡’œ¢œŠp\OPRUUPC89>=83-+-..14559;943314@_}•¨´½ÂÂÂÄÆÉÊÆÂÁÀÁÂÃÃÀÃÂÇÉÉÉÊÇÆÇÊÈÃÃÃÁÄÄ»°¢––¤·ÄÆÀ¯¦œ…‰“•‘„xTHCA?A@?FS\cfjhfb_YSPMMQTUWZRC943457LfwvfJ6..156768:FNSVWSSNXbm{‰•œš˜™–˜šš›—ŽŽŒŠ‰‘—–’ŽŒ‘”˜››™“Ž…lO?" + + + + + + + + + + + + + + + + + + + + + + + + + + O‰£ªª¬ª¨¨¨ª«®¬¬ª©©¨©ª¬¬«®®¬«¨¨¨¬©¬«¬®®¬®ªª¯¯®®®¯¯®¯°°¯°±±°¯°²²²´´³±°°²¶´±²²²³±±abbddcbbb```__bcbaddccdbaa`_S?, + + + +#'*,8BKPRQD0$ """$$#"!$$%$):DF>130:>BHNTUSOLSWjsutz}~y||zxxy}}xoaKD>BHl˜µÄÇȽ©yrgpuy€{yvqjgb_YUMI?6/12335:@CCCUbs„’Ÿ¡›ŠufTSIHD>6:=93/*+-//14558:86327>\}—«µ¼À¾ÆÅÍÑÌÀÃÀÀ¾ÀÁÁÂÅÃÉÊÈÃļÁÂÁ¿¿ÀÁÂÁÀ»°¡–’š®ÀÆÂ²›š–x‚Œ‘‘‹„vh\KGDD=KU\c`^b\`WTSPKIHPSTTO>733069MW_e[G</.+-/133/6=JQTVRPNLKKfŽ™—•••••›˜˜ŒŠ”“‹‘–—–“ŒŽ‹hK9 + + + + + + + + + + + + + + + + + + + + + + + + + + VŒ¤©«©ª§¨£¨ª«ª¬¬¬©ªª©¦«¬¬©ª¬«®¯«¤«ª¬¨¬«¬©«¨«¬©¯¬¬¬¬®®°°°ª±²°«±®°²°°²³²²¯¨°°³²±¯³²±bccdbabcccbaa_abbbcc_bcc``^XH1 + + + + + &/6;CMQSRN?+%#!!"$%$#$%%$#,>EC<9:>GNKGBABDEMZitywvy~}}|zy|€€ypg`_f}¢»ÆÇÄ´šrljptx|}}~~ysold_[WL>2/./0/1:@B=>AJZq‡˜ š‘mVLB@<:>?;8.,,//02555677646?[y”¨µ¼ÀÂÄÅÆÈÑÖØÔÎÇÂÀ¿¿ÀÁÂÅÈÉÈÆÁÀ¼¼¸¸¼¼¾¾ÀÀ½·¬Ÿ“ˆŠ™¸½µ¨ ¦žz‚‹Ž‘†wjb[OKRclrkdcfd^RQMHCDLTWWNB8324:DNWZVE941/+,,,0133>FMRRPOMJ@@LtŠ•””“‘‘–š˜”ŽŽŽ‘’Ž”•“މˆŠ‹‡{dK5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [¤««©©©¨¨¨¨¨¨©ªª«ªª¨©©©¨ª¬®¬«®±®««¬ª«««¬¬««°®¬°°®®®®®¯°°²¯°±°°°°°²²±¯±±±®®®²²°®´µ²²bcccb`bdedd^a`a`baba_`bbb`YM;! + + + + + + + + + + +#*4<CJPRQPH8&%$""#$#"$%#"!,>C;>ADIPRI<98:<OXhsyzxy{{yz{||{~‚‚€~|{«ÀÈĽ§‡ujjlssqnquy|{wvrmga\P>3)))-,/7?DB>?9FVs‰”—œž™Žz^WE?:DJJC8-010-23325557;?Zw£¯¸¾ÂÂÀÇÇÌÔÜÜÙÕÎÄÁ¿¿¼ÀÁÄÆÆÄ¿»¸¶¶µ·»¼¼¾¾¼¸´«Ÿ„{~…𫵴°²™|w…Š’”’‡~{zursry}yuvxreRJLAECMT[_XPHA84;FS[YNC520.+,)*-018@GMOLMOOLHCYr˜”‘„ƒ‚ŠŽ’•”‘“ŽŽˆŽ’‘‘‡“•„ƒ~…‡uaL2 + + + + + + + + + + + + + + + + + + + + + + +a•¥ª«§ª¨©§¨¨¨¥©¥ª¨¨¨¨§¨§ª®©¤®®¯¬§«©©©®©«®°°¯¯¯¯¯°±°¯¯°«¯®®§¯¯±°±ª°°°±°°±®¬¯³¯®®´µ³°bb``acccdedcbba`bab`]`abb_SA- + + + + + + + +$+2:BIORTNC.(&&$"!""!!"###$,:@@AFJMONB878<K\lswzzxz{|}~~zxyyy{{{}‚Š‘›±ÂÈô™zjgjqtpmlklmuz|zzume]QC4,))++)2;B@>=:6CYr„‘™ ¥¦š‰ziQKMXWN>6320011.03207CYtŽ¡³º¾ÂÂÆÉÉÆÖÛÝÝÛÕÍÆ¾¾¾½½½¾¿½¸´°®«±·½½»½»´²°¬ €umpv£±´´°¢‚u€‰Œ“”ކŒ‘Ž‹…‚ƒ„yhSHNOOMNR`qwxmY;46HV[SG<30.-+*)(+-/4=DIMMMNNLNSauŽš•ŽŒˆ‚u~‰”•–”“’’“‘’”‡€‚|o^L1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + e˜¥©©¨¨©©©©«ª««ªª¨§¨§§ª«¬®¬ª¨§©¬¬¬ª©°¯®±®®®¯¯¯¯°²³²¯¯°®©¯°¯®¯¯±²°°°¯®°°°¯¯±®¯°²²°±³³±°ba``dddcbbdcbbbaabc`acb^`[K5% + + + + !#')/5?INROF;235.%"!"!! #$%%/9DEGIJIJDB;@BGRftwwzzywxz|||{zyxxz{{vˆ‘’ˆ™´ÃĽª‡c^]fqrommnhkovxzzxph]SI>0-*++++179<==::GNm‚– §¦£šxhehaUD45//010-.1/09Tp‰Ÿ¬µ¹»¿ÂÅÇÊÌÑ×ÛÝÞÝÚÔʽ»»º²±°´¶³²®©©·½¼»º´®ª«ª¢“†rg_gl†ª««¨™}€‚„†Œ‰…Œ’”•”ˆ{yx{|s_YL^gfZVSlƒ•ˆpS:CL]^M62/.-.+*))())+0<@HKKIJIJMUfyˆŒ’‰~n}ˆ••Š’‘‘’’’’’’‘‰…wiZI- + + + + + + + + + + + + + + + + + + + + gš§«©£¤¦ªª©¨«ª«¨ª¨¨©¨§«©ªª«©§¦¥¦¬¯®««ª¯®°©¯±¯¬¬®°¯°¯±±±°°°®ª°°²®²°°°¯®¯°°±«®°±°°°±®²´¬¯¯bccbddaccbcb_abcdddcdeca^UA+ + + #%%$%,6@FJLKGEFG>/$!"!"""$$$2ALTVYYTKHGGIJKSgtxww{{xx}~}yzzyxwxyyz‰‡ƒ”°¿ÀµoRLN]lnllrrokmsvvvwuk^WQI?71.,*(*.17;=<<?EVr‰’œ¥ª¨œˆqstjXF54/-//.,/0/2Ge„™¨±·º½ÀÂÃÅÉÎÕÛÜÝÞÝÜÚÐĵµ³®¦ª®±±°«¥¡¨µ»¹¹µ¯©¥¤¥¢–‰ra]`cgƒ–žœ«¨•}{ƒƒ‚€‚‡Œ‘””“‹|qqrqplhjr|{ukm|’ £•€fWUZbaH40.,-//-,*'%'*4;@ADDEEEBA:JXk}‹’––‘…xox‰–”‘‘‘‘‘””––‘ˆ†…‚{oaSC' + + + + + + + + + + + + + + + + !jœ§ª¨¤§ªª««¬ªª¨¨ªª©ªª§««ªª«¬ª©¨¨¨®¯ª¬¯°°¯°°®®°°®¯±°°±²±±°±°²´³¯¯¯¯°³²±²²±±±°°°¯°¯°³´³±¯cccbcbbcbbccbaaceecbccdbYJ6! + + +#%%$"%&+048AEHLORH8+"!!####%$8M[cgkjf]PONMLKQdrvx{}|zx|~|zwxxyuuuuw‡…vf}›¯¶¨Žb<;<Oajmpvxunmnpplqsm`\WRLC63-,(*(02:<>=CH^kml{‹–—ŠzkrxmVC53.--.+.01-AXy’¡²·¹½¿À¿ÁÈÌØÝÝÝÝÜÜÛØÏ¿©©¦¡¡£¤¦¨¥ž¢´»¸³³®©¤¢¤ž–‰s`[`bcmˆ”«°¦‹t|{{x|}…‹Ž‹…xhehmwy}ƒ„Šˆ‚}ŽŸ¥£}slljjiR51)+)//.)+)')6BFJFB?=CDC>71=Ho‡‘—–•‹~mfƒ”•’މ…€€ƒ‰‘”•……†ƒxjOM?$ + + + + + + + + + + + + + + + + + + + + %nŸ¥¦§¦¨«ª¥¬¬«¥¥¥«««¤ª§ªª«§¬¬«ª©§«®°®¬®«°¬®«¬ª¯°®°¯«®°±°¯¯²°±°°¬±³²¯¯±³²¯±®³´´³±®¯°²¬°±²´³²cdcbbbcc`dddcbaced_^`dc`R>&# + + + + + $$$$%&%#(+-1:AGMPK@1$ "$$!#$,@Zisvyxtle`XRLKP`osx{}|yvy{|{yvux{zyxx~ƒ|ra\c}’ž’xU78:BTalotxvomlkjlnomga]ZVNE:40-+,/6;>>AIYfi]X_qˆugdnymT?52.,,,-.12;QqŠœ¦³¸º¼»¾ÂÂÊÒÙÝÝÝÝÝÝÝÝÙ˶ž›˜•‘—–“¢²º¶´±§£¡ š“†p`abcacet‡®¾¶š„ywuvxyv~†‰…„|ob]bvƒ’•––¤©£‹tst{‚€u\<2+*,/0.,+*),BU`fbYJDA@A=5,*9dƒŽ””‘‰~ldz”„wlb\esƒŒ‘މˆˆ‚vePM?" + + + + + + + + + + + + + + + + + + + + + + + + + + +)w¡¨ªª¨ªª©©ª«©©©«¬«¬ª©¨©¬¬¬¬ªªª©ª«¬¯¯®¯±°®®®¯®®®«®®°±²³´±°¯°±°¯®°²´²°°²²²³´³²²±³²¯¯°²´´a`b`bbcccdddcbbacd`abb_XH0#" + + + + + + + !!"#%()+.,(/+05<BCA6%##$%%$)3Kboz}~|rsqh]OEEE\jqrxzyvvv{||ywsuw{zyu~€taWPSWnwjWE468:=NXblprokkfknmmnjfc`]YSI>911-6;@@AESahcR<BLcmja][htmUA31*+,-./5>Jh“ §«²¸¼¿¾½ÁÄÌÕÛÝÜÝÝÞÞÞÞÝ×Ȳ–‘‹†~~~‹¥´¶µ¯¬¨¢Ÿ˜•ƒmdadd_Ugr–¶Å¾©“†prosuuw}ztjb`y•››˜——•‹’Ÿ©§“wrmxƒ…~dE9-/-68632136Up}…~u`H?7993)+4`ŒŽŽ‹‚wlVsˆ‹„oRI654Nezˆ‰‡†„~scTQ@ + + + + + + + + + + + + + + + + + + + + + + +-z¤©©¬©©ª««ª¥©©ª¦®©©ª«¬©©©©¨§¦«¬¬¯²±ª¬©ª«¬«ª¯®ª°³´¯±®¯¯©ªª®²³´®²°±«°°²²³²µ³°°²¶¶´b`aabcccbbddbccccbaab`ZO=)! + + + *+'!#$(,6>CA;1*%')4:=4%$$#$$%.BUepz{{yttshYIBCH\koruvvvwy|~~yvuuxz{|}|oZOOPPRQKC5104446AO]fmookkmnllnlkgea`^TKD>:<AFFBDLYcaUC53:ENQRT[bnkZB1/,)+-.08Icy™Ÿ¥ª³»¿ÂÂÀÃÅÍ×ÛÜÜÝÝÝÝÞÞÞÝ×Ά}wqjfes‹«¸º¶±¬¦ œ™”Œ€pfhii`jyŠŸµ¾º¯©žŒuoptqquxttmcatŽ¥©©¨§¤¢£¡˜Ž†“£©œŠueiu€yfMC97<BHHHGKQYoŠš ›sQ>1-00-+7_~‰ŒŠ„xth_qrW>/*((*Dd|€yn_TM< + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 8¥§©¬¬«ªª©ª«ª©ª¬ª¬¬««®®¬¬¬¦ª¬¬¬«²²¯¬©ª«ªª¬¬¬ª°±®²²±°°°°®¬®°°¯±´µ´±±±°¯±°°³²´³°¯²¶·µbabcdbeccaccccb`b_`aa^RB0 + + + + + + + +-9951-04<ENVSMC1,&*,240&&$####9N[dipqrqomj]KC=DM`lprssuuyz}{€|yvty{|}}}nWONOOOJF?:2/,2132@G_nsspnokkgijjiibaaZRPJJIKMKDIR\_VD;222349>R^ekj[@1.,*)**2=[r‚™ž¥ª´»¾ÂÂÀÂÃÐØÜÜÜÜÜÜÜÝßßßÝÒÀ£‚wg`X^n–²»»¶²§¢œ—“‘Šu{„…Š–œŸ§ª´´¯°°¤Šikmkdkpqoh]u‹ž±²²³±¨¢—„™¤ŸnHNW^c`VRIMPTYZ\[_it…™¥¬§~ZG00*0,-<^xƒˆ…vl`SrsWD.,*(%(,Pky}|zrgZGD1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +E§©©©©ª«©§§©««¬¬««©«¨«¬¬«¬«¬¬ª¬§«ªªª¬°²±®§¬®®®©«©¯°¯¬¯²±°®±±°«°±´±²³µ±²´¯¯±¯³²±±±¯¯°²µcbdggeefecbcdebabcccaZI3! + + + + + + + + /=JOOLHGLPT[`^XOD:4-**,+*'%$" (CYaaadggfdb\QE<;EVdmqrrtwyyz}€~{wv|€~nYONNNMKFA>9/.02238BYnvvtppnkkjijljhda]YWVTRRONLO[_ZM<3112/./;Qbipk[>2/-*)+-5Nh{…”§¯´º¾¿¾ÀÂÈÒÚÛÜÝÝÝÜÜÞßßßÝÚÒ¼žydXSUsœ·¼¹²¯¬§£—–’ˆyv’œ¤µ¼»´°®¯¯±³–|dcb_ahljdb„¦«¯µ¶¸ºµ¬¤—‹ƒŠ™šŠd=7AMZ]_^__`cdhjihr‹—¡¨ª¢ˆcRA:73-0A\nx~{nbVVr}fE4+**(%'*5Wp|xslcVH>* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +O†§«ª©©©©¨¨ª«ª«ªª«¬«©ªªª¬««ª©««ª«ª¬«ª¬¬«¯±®®«ª®°°¯¯±°®²²±±±²²³´³´²±²³²±°°°²´µ´´²¯²²³µdcdfgdeffddcefdccccc^S?&"! + + + + + + + + + + + + + '@Q[_a]YXYZW`eb[UMKKD6.#()(&%!"-JacWVYXWVURNE989N^hmtttvxxyw}~€w}{yy}‚‚taXLLLKIFB@>942035:AXkswuqqponnmlkjjf\ZXZZZZWQQR[`\SE40.00/.3<P_hro_C20-*)+.4Rkz‚‰”œ¨®µºÀ¿¾¿ÅÊÔÚÚÜÝÝÝÝÜÞßßÞÝÛÙ̳eRETy¢¸º·²®¬§¡›š™“…rdr µÄÅÀ¼°¯®²µ·©žŒxaaSW]eehm’§ª©³´µ·º¶¥–‡~uz…ƒvV7;BS]aabddegfigjjlo}Œ•œœ…e]NRUK45CZbhkif^QTZmsZ:61-))&($.Fdwsgd^TI<& + + + + + + + + + + + + + + + + + + + + + + + + + + + +P‡¨«««ª¨¦§¨ª©©¢¥¥©©©«¬¥«¬«¤«ª«««¬¬ª©ª¦¯¬««¦©¨¬®¬¬±®«±®±±¯°±²±°®´´²®°¯±«±°°®³°²²³¯³´µ²edbdedceeddffedddcabYJ1%$)! + + + + + + + + + + + + + + + + + + +/HU]dfc`^\]`dhfaVPSZTE2(')))&##1NdcVLNNOONHB:34?Vgnsvvvw{|{}~~~~~|{y|z€~ztgWIKHHFCBBA?;669=J[ipuuusquxvsqoljf`^[Z[]_]Z[_baXM=2////.06;JXcpqdH0/,*)*-2Phv€‰”Ÿ©¯¶¼Á¾ÀÇÐÖÛÜÜÝÝÝÝÝÞßÞÞÝÜÛÔÛlKCS‚¥¸·´°°¯©œ›œ›‘j_`fmƒ”«ºÄÈÉÊÉÊËȽ§™Œ~n_MV\^e…Ÿ°±µ»¼¶µ³¯ª¡‘vkdonaA;@M[fffhjklkjheknnnqrt‡‹{djntxiS;F[e[VSQNOQWhiKDCE?7.*'&(;Ypng^WOG8! + + + + + + + + + + + + + + + + + + + + + + + + + Q‰©«¬©¦¨©©¨¨¨§¤¦¦ª«¦«¬ª©ª¬¬¬«©¬¯¯®«©¨§¨®¯°²±®¯¬±°¯°¯±°®¯¯°²³²µµµ²±²³²°²¯±³µ¶´µ´²dcddcacfeadfecdeeddb[L8&'1/# + + + + + + + + + + + + + + 0AGNZ[[\]Z_bdfd`VIR\XL:*)&,.,*/5ObaYMFEEFE?84.3E\msuuvtvy|}~~y}~~}|z~}z{|€ynaPMKIDCCEGF@ABNZejpowwusyxyuurqnldc^[Y^`_Z`dbYTL?1//00/059AJ\lndL1/*)(**4Kep€Š–¢¬³¹½ÁÂÂÃÌÒ×ÛÝÝÝÝÜÝÞÞßÞÝÝÜÜÕÆ rO>\‹¬µ¸°±°ª¡›œ›waQSX`gv›½ËÕØ××Õ˹Ÿ¡ ˜„qZ^`|—«·¹¼Á¹©¥£”†wp_^`^\RHNT^fijjklmliidjllmlkonprkfp{ƒ‰€oaThj\IE<BFKRfm^KQTPJ:+)&&(Pih]XND<1 + + + + + + + + + + + + + + + + + + + + + + + + + + Xªª©¬ª§¨©ª¤ªª©¥¨¨¬¨§¦«««¨««¬«¬ª«¨©©¯®¨§§¨ª¯±¯°°°ª®¯°°°±¯®±±±®µ·µµ³±³²³²±±²´¶¶´´´¯ddedbbcffddfdbdebdcc_TB5-7970(" + + + + + + + + + + + + .9@KPQPVZ\adb``^THQ\YTD:0.0;>>=@N\^XNA@?>=72/.2I`pstrrstv{~~}}}}}~}~~~{|}ƒ‡ˆƒxlYQMIEDHKMORW`josuy{}|{{{{yxz{ztoje^^^__`df_UQL@/./330//37DVfjbO<.+-/-+7Oes‹™¥°¹½ÀÁÀÂÉÑØÙÜÞÞÞÝÝÞÞÞÞÝÝÝÝÜÔÄŸuRAg–³¼¹µ³²¯ª¥¢Ÿ™‡oTC?HPYbnw…˜±ÉÖÙÙÚÕË¿´Á¿³˜ycn‡ž¬´¸¾Ã·£™•Ž…xri\R[ega^\^`djnooonomjijkkllmmmkhdckv‚‰ˆƒ{vsm\G>78:CNesmd`ccZG:5.*)IacZQE95* + + + + + + + + + + + + + + + + + + + + + + + +%a‘ª©©««©§ª¬¬¬¬¬«ªª®¬¬¬¬¬«««¬®¬¬¬«¬¬®°°¯®®°¯±²±®®°±±°°¯¯°³³²²µ¶´²²±²²°³´¶µ¶¶µ³³´µeeededeffeffecffcdddc_UJC9;98640( + + + + + + + + + + + + + + + + +",3>FHGEEIPY`a\[XRLX_baZRMIIKLKGCJSVWO@=4577/./<Mbomifeinrx}€~}z|}~|}€}z†Œˆƒyi^OKEJKOS^houwy}€|€~~}{|{‚ƒ~troi`]Y^`ff]MPNC//0463/./4?QbecVE8,01/-5NbsŒœªµ¼¿ÀÀ½ÃÍÕÚÛÜÞÞÞÞÞÞÞÝÜÝÝÝÝÜÓ¾œwTErŸ·½¸·¶²®§§¥ž•hL331<CQ\ben~µÑÙÚÜÛ×ÑÏÐÏɱ€}—ž¥®µ¼¾´¢—ˆ…ysld[V[pyqhg]demqqpplllighhorqmngdbbY`aq}ƒ…‚wrm]I?881=J`rtmhki^IDA410M`bXM<83( + + + + + + + + + + + + + + + + + + + + + + + + 'f”¨¨¨©¨ª©ªª®®ªª«««®¬¯°°¯©®®®¥¬«ª©®¯¯®°¬¬¬°°°±°¯±°°±±±®®²°±´´°´´³±°±³µµµµ±¶³±³´³fecdeffffefgfhigeefedea[SLA;9<<<6.$ + + + + + + + + + + + + + + + + + + + +#,3;AA<3./=KY]]WQMWaimmidb`\XWUQKFJNSOF;637977:CUcibYRPU_gow}~|z{zz||}€„…{~…‹’’Œ‚seXQMMO]ju|€„†‡ƒ€‚‚‚}€ƒ†ˆ„zxsme]^bebZSQPE8004641+*,8J]de]RB40///3EXk~ ®¶½¿¿¿ÀÆÐ×ÛÝÝÞÞÞÞÞÝÜÝÝÝÝÝÝÜÒ»–rUJ|§¹º´·´¯¬¨©§Ÿ‘}cD/-+,4@KSY`p§ÎØÙÙÙÙØ×ÖÖоˆ”˜™¡¤©³µ¢”†€wnf]VSXv€zumhilqvtqpklnlkklnorrqqnjgcZVYlzƒ‚}qj\J@=;86B[ptmglfYHJLIDESbd\K<84& + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + (i–©©ªªªªªªª««§«««©««¬¯°°¯¯«°²¯¬¬®¯¬¯¬¯°¯¯®®¯¯°°±®«¯°°°±³±¯°®°²²±³µ³³±²´µµ´´¶µ²°´´¶eddddeffecfgghhgededdgfa`^YRL=:9751-+( + + + + + + + + + + + + + %/5=B>0-)+,>NTVQFO^kqsspikicX_`]VL?ELOLE???BEEDP\abUEDBHO]bowxxwxww{z„…‚~ƒˆ‘”‘„{uni`fmw~…‰ŠŒ‹Š†„‚…†„}„‰Šˆ‡‚|zvm^`caYVUTRJ?6.23420,15JZbd_XJ93.0049IZw¡«³º¾½¼½ÅÐ×ÝßÞÞÞßßÞÝÛÜÝÞÞÝÜÛѶŒiQP‚©·¹¶µ±««¨©§Žv\?-,++*39<APh¡ÊÖ×רÚÙØØ×줙˜›š £ « “Œ‚yqg\WOW]swxqickjqrnjklpttusmoqrsvwvqkf\LNSp}„ƒzkaLIGC=9:Wmmca`YHCHOOHAN`b\L><5$ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +m˜§¬ª¦©©¨¢«ª«¬¬®¬©«ª¬®¯©®¬¬°²°¦¬®®«ª©°¯¯¬¬®®®®¯¬«¬®°°±°®±¯°¯±³¬³³³ª±¯µ´²²³³³³´µ¶¸fdeebdee`befdffededdeghgghfa[SJC88989:2( + + + + + + + + + + (1:ADD>3,*()2DKMFDRgsuuuqonjdaehfaR>9DKOMJJNPTWX\ac]J=9?FNW`hoqrtvsw|ƒƒ„„ˆŒ‘“‰„‚€~ƒˆŒŽŒ‰ˆˆˆˆ‰Š‡ƒƒˆ‹ŒŽŒ‡‚~zrkhd][X[ZWPH<./122257EV^^]ZULB:63357?NlŽ¢©¬·º¸¶¶ºÎØÜÞÞÞÞÞßßÞÜÝÝÝÜÜÛÛΰ{`OZ‡¨µ¹¶³°«©©¦¤™‡qV;--,*)*-/1:^˜ÂÑÕרÙ×ÖÔÏį¡Ÿ¡Ÿ¢¢¡¥«ª¤“‹€vng]TQT`mw~wmdjnpnjgdgkqwxxurqqprssqmhd\SFNi}…ˆ‚yjddcWF;6QeaUPNG>:?EF<9EV[VKA=5! + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /rš¬®ª¨©¨¨ª«¬®®¬¬¬¬ª¬¬®¯°®®®®¯°°¯¯®¬«¬¨°°°±²°®¯®¬®®±²±°±³³³²²´¶³±²µ³²²³´´³²³°²´´´¶ºgeeeecddccfgfeedeffffbgghihdca\WRIC9;<951+% + + + + + + + + + + + + + + $4CKNLID>820-5?DB?>Shrttsookfb]diifV?79AJMOSVY]`bded[K79:ENV\cigfpsux}€€ƒ…‚ƒ‚ƒ‡‹’’ކ„ƒ†‡‡‡‰ˆŽŽŒ‰ˆ‰‰Ž‹Ž‰ŠŒŽ‘Š‚~wsrogdedb_\UL>../0+26H]iiZNLKIHE@;587:=^ƒžª¬³¶µ³°¼ÎÙÜÝÞÞÞÞßßßÞÝÝÜÛÛÛÚÍ}XNc‹¦±·µ±±¯¬©¦ “€nT:,-)+&++--4S}¢³ÀÈÏÑÓÐËÁ¯§ £¦¥¥¦¢¨§¥™‹yda\UKXdmv{~vioswxvnoqttvxysqosnoppokgie`XRQi{ƒˆ†}}~oUJ8O\WEB9400/01/'9HNMB4:3 + + + + + + + + + + + + + + + + + + + 9z©ª«ª¨§©¦¯®¬¬¬«¯©¬°²±®¬¬¬¬°±±°°«®¯®©°°±²²³°®©¯°¯¯±±®®°±±´³±³°¶´±°³´³²³³³²³±´¯°±²±²µffededccdefhgeffgfefeeeghifghihfa[TK@<:;:950*% + + + + + + + ,ASYUOLJGC@><9>>;;GUcjmnnmkgb^]agihV;017@HPVZ\^adde`WLA>>EMT[_cbciotw~€~€‚†ƒ‚ƒƒ‚…‘ŽŒ‰‡†…†‡‰ŒŽŽŽŠˆ‰‘’“‘Ž“‘ˆvutnggpnfb_WM>,./002B\rvlVC@AEJJHB=9758Ks”¨±³³®¯ÀÒÚÝÝÝÞÞßßÞÞÞÞÝÝÝÛÚÚеUKiަ¯µµ³²°¨¡œŽ|iQ9/-,*,++,,0@Wo‚’¢°¸½½¸±ª¥¦©¬©¦¨©§¥›„}rc\TNQcty}}}slquy|zy{~~€~}yxuuvvuutrpnkga[UPcs}†††Œq]NOVO@92.+))))((.;AB955/ + + + + + + + + + + + + + + + + + + + + + + + + + + A~Ÿ¬¬¨«¬¬§©¬®ªª««®®¯®°±±®¬®®¯¯¯°°¯¯°±¯®±±²³²¯®®®°°°²²®¯±³´±¯¬±µµ³²±²²±°³³²³³²´´µ¸¶´±´geeeedddddeeefffgcdafefghhhfhkjggeb]XSM>;:;7652111) + + + + + + + + + + + + + + + + + + + + $4GWYSNKKJJJIHDA>9CNY_bekihf`XXX`bhfU71+.2@LTVWW\\\[]VMFECIMSWXXYZensw}€~y~€€~ƒ‚‚„Ž‰ŠŠ‰‡…‚†ˆ‘ŽŽˆŽ‘””””“’Ž’’ŽŠxrlfaiqohd^WL<,/011=On~tbK444?FIJGC?975CZ‚Ÿ²²°¯ÅÖÛÝÞÝÝÞàÞÝÞßÞÝÞÞÜÚÚÓ¾‘YYo“©°°´±®ª¦£Ÿ˜ˆqaL5.,)()++**/15;DN_p~‹’– £¤¤ªª©§¨¨¥~}vlbXOV\mz|~{ttswszxy{}{{{}wxrxutrtwurrpnhd[VQXap~~snl{ƒwfUQRH92+*)&%%$%%*.262,1* + + + + + + + + + + + + + + + + + + + + + + FŸ¬¬§ªª«§«««¯¦«««¬¯¬®®°®¯¬¬®®¯¬®¯¨®¬°¯±±°®¯®¯¯®°²®®®±³²±°¬²µµ³³±¯¯¯³±³°µ²¶´´´´µ¶µeffeeeegeeffcefeffdeghgghhhefllkjjiigd]UNI><=><=@@8,% + + + + + + + + + + + + + + )6FPPLKKKMNMOOI@?CJRZ_beiieaZQOU]deaR<5/*-7FOTTUXZXY\XIHHJMQRSRSTWajoty~}{wz|„„‡‹ŽŽŒ‹‹Šˆ†ˆŠ‹ŒŒ‹ŒŽ“–—–””•“ŽŽŽŒ‰tkb[`inmiebYM:100.3Dh|lT=2028=BFEC@=::=Nh¦¯«¬²ÉÙÝÝÞÞÝÞßÞÝÞßÞÝÝÝÜÛÚÒÁœraw—ª°²°¬¨¤£¢œ‘~iWE0,)'%')))+-//0/26;B^lŒ•¡¤©«¨¨¨§¡–…zvqeYQN]kv}~}wrtx|€}z|~{xwxvvvy{wsw}zwvsrmic\VIN_oofNRamom_OJIB2*(('&%%##%'*-.-+-# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + L† «¬ª¨©§ªª¬°¯¬ª§ª®««®¯°±¯¯®®¯¬¬®®®¯®¬®°¯¬®®®¬¯²±²²¯¯±±¯³¯¯®°²³²°°³¶µ´µ³°°°²³³´µµ¶·¶µ´´´µµddddeghgfcggeceeghgegggdhghchkllkkikkjie_ZUNH9=9<?<9752,% + + + + + + + + +"-3=A@?GLOPPNSQL9=ELNY]^afea\UIGFR[[VLB<3*)3<DIILRXZ[`\PLMORSRPOOQSZZdlqu{{|{}€„‡‰Š‰ˆ‡……‡‰‹Œ‹‰‰†„…†Ž’”•’ŽŽ‹‰ˆ‹Ž‹‰€qj\^alnkklkcT@01/19_|u^F?344757:;<<>>=?C[¡¨¥¢ªµÌÛÝÝÞÞÞÞßÞÝÞßÞÝÝÜÝÝÙÏÀ¡y€›ª«¬«¨£¢ž“…q\N=.*($#$(((*,..//.24F\•™š¡§ª¤£Ÿ¦¥œ‹uog[MORev{}zvrmst|||{{}}uvwwusqyzujuzzwwrtmkc`YL?OZ\ZJ<MORSH5>D<-)'&#&&%#$!%'(*,,+ + + + + + + + + + + + + + + + + + + + + + + + +\£«¬¬ª¨¨©ª¤©®ª«¨ª¬¯¦«©®®¯±¯ª®®®®®©¯°¯¯¯®¬¬«§¯²´²±®±³²°´®°¯¯´²°³µ·³¶µ²°±²´´´µµµ·¶·µ¶±²´eceecfgfeeghfcefgjgffefhhghiiikklkkklmnmjed`XOF@;>??@@@>90& + + + + + + + + + + + + + + + +*0249<>FPRRTVXYOA;GPV[^_aab]VNE=<AJMHDC>6+)/5886>HRYac]UUVWUSPKEMUYYVYimqwz}€}yz|€„†ƒ€~„……†…~{{z|‚‡ˆ‡ƒ€{zz~ƒŠ’–“ƒzmggmswuttsj[E6215OpˆmSGA=;<;6/559;?AA@AR†¤£¢¨²ÉÙÜÝÞÞßààßÞÞßÞÞÞÞÞÝÚϾ£†„Œžª©¦Ÿ¢Ÿ—ˆyiVF8,+(('())()+,-....:Nv’£¢ ¢¨§¢ŸŸ¡¡”„wldZQHLZo~}zqppuy{}}}|}{xxywtrpuwporuvvutsqldc`QA@ITVG8AFD@5/5?8)'%$$&&%$$$$$$&)-) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +"e–§¬«¬«¨©«««¬«©ª¬¬¯¯±®¬¬®°°ª¬¬¯®®«¯²±¯±°®¬®®©«°´²°°±³´³²´´±°±³´²³´´´´³²±²³µ¶³¶·¶¶¶¶¶·¶³´¶gdfecegfecffeddfhhgfgfghgghihgggkkkillmmljjieb]VPGC??>@B@<5/' + + + + + + + + +".2/248;DOSTX[]]TEGL^jnmlkklgSNA<7;?=;98<81*+---54?ER^a[WYZXXUPGHO_c_X_hjjsw{}xtqrtwywttuwxz}~}yrrqolqtsrpoppqrtmzŒ”—–‡|rswz}{susk`Q?>7L`u€ufUJFDCDB=;9;=>=BCC<a–µ½²¢§®Æ×ÛÜÞßáááààßÞÞßßàßÞÛÓ¿¥‰…ŒŸ¯®¬§¤¢‘ƒshRC60-,+*'**)(**,-.*<Lp §¦ ¡£¢Ÿ™–”…yk`WMKAQbs€}yukotwwy{|wyv{wxyxqtqpoqrsprutlrnmgfbU=<:HMD8@@C=4,6?6&%$##$$$#%#$"#(,' + + + + + + + + + + + + + + + + + + + + (i™§«¬¬¨«¬¬ª¬«©ª¬¨®®®¨®ª«¨¬¬®©°¬±´²¯±°¯¯®®®²³°ª°²³³²²³²²°¯±²²²³µ³²®²«²°¶·¶´¶³µ·¶²µ³µ±²³hgggegfefgffggffggfgffhhfghhhgghjjihjkllnnmllljfaZUND?<AA@?<6.# + + + + + + + + + + + + + + + +)212225:BMSV[_]\UIM^nz€ƒ…†…ziVD99:<=:45761)(*-4:=:<EVZYY]\XZZQCJ\hkd^aghhouy|xrmjinqnkmopoorutvqkgfehmstuvwvssuvutwy‡–•†xz|~{srphf\TQUapush^VOKIIJHDAABCA?ADFMr©ÆÌ½®¤©ÄØÝÝÞßáààààßßÞÞßàßÝÜÖÈ©Š†‹ž²°¬©¥Ÿ–„xgR<8320.*)*+*())*-.8PlŠ¢ª«©¦ŸžžšŽ‡‚{uk^TMJGEVjw}wpjp{{z|€|uxzyxxzwvtspoqtsqrtspppnlifWB:6;DA?@FFA4+6=4%##"#####$$$$$%(+% + + + + + + + + + + + + + + + + + + + + $j›¦«®«§©ªªªª©««¦©«¬®®¬«¬ª©®®°°¯°³±°°¯®¯¬®¯°²±°°°¯´µ´³´²°¯¯±³²´´²²³²²´·¶µ´µµ²²¶µ´µ·¶¶µ¶fffgggfdggghhggdgghhgghhghihggfijjhghhklmmljlmmlifb_[TMA?>>><94.( + + + + + + + + + + + + + + + + %/3354/48AGQVY[YXTLXgwƒ‡Š‘““‰ydM@58:981.22.'),4;CGA4>FRV[]\ZYZQBQcmnh`bed_msvwrkg`gppe`agihhmlmlg_[Vadopuxyzyuuvwvuuws‚Œ‘‰||z}~ztrokic_ciqvob]UUQONMMKHGGHHC=AFLSŒ¼ÐÏÄ·¦ÅÙßÞÞßààààßßßÞÝßàÞÝÜÚÍ®‹‡ˆš¨¯°ª¥›•‹ˆzhUH@=;852+++,()&*)7Eh†š¨®ª¥ ”‰vtjf\XMGDFDZoy}rnm~Œ„{|~vzyzuywxrollmrpurrrtmrnnhigZF?:@CGJOTPK9-58/%# !""!#$$##"##)," + + + + + + + + + + + + + + + + + + + + + + + + +jœ¨««¨«¨¨§©§®¬§ªª¬©ª©«ªª®¯¬ª°²°±¯°¯ª««©¨ª«®®³³±¬°µ¶«³³³±±®¯°²¯´²³°´²¶¶¶°°±µ³³µ´´¶·¸¸·´eecfeeefgffgffgggghigffefhijjigijjhhhhjliijjllkmljhhhd]UPJ@==@@>82-*'# + + + + + + + + + + + + + + + + + + *12365039@FNTVUUTRU\k{‡Œ’“——„q]E:7:96--/.+)*.8>IPG;;@OZ\\[[][QJXhnmica`Z`muspiea_fnmaRX^adgjjgcYQPXcmprvy{{xuvwz{|{vrs‹Š‚}y{zvvsolkhhn|}uf[WSUVUTVVSPONMKF>BIOm ËÖÒɾ¶¶ÈÙÞÞÞßßßßßßßßÞÝÞÞÞÝÝÜÔ·…–¢ª©¥Ÿ—“‹|h]QRVXRJ@<82.,,+,2B`~˜£©¯°ª¡žž›”…uneZXQH>=BE^s{zwx“¯²¨•‚„€}{|{{xvwsojlqtwwwtqstqplhgeXHMMIEKU`gbU>232+%$&)**(#$$$##"#%+! + + + + + + + + + + + + + + + + + +%m§©¨«««ª¨ª¯°©ª«®«©«®®¬¬°²¯±µ²°°¯ª¬¯®ª®¯®¯¯°®®±´²±²´´µ³´´´³²²±³µµµ´³µ·µµ´´³µµ´³³³³³´·¸¶µfefgfccdgfedffghhhijiffegijkkjihjjghijiijjiikiiikllkkkheb]WQJ=C@>;::85,! + + + + + + + + + +0013428<BGMPRSROPT]m|…ŒŽ‘’”‘‹}kWB?>>:511/.,,-6>LUL?<>O[\W[[^ZPI\mnjhea^Zdpurlic`\ab`^ZX]_eglnmd[LW_hpqrvx|xzuxy||{xrmnp†ŽŠ‚€zzruvslkijlzƒ|n`VUTUTVXYYURRPPNH@FLUz°ÑÖÔÌÁ¹¶ËÙÜÝÞÞÞÞÞÞÞÞÞÞÝÝÝÝÞÝÜØÂ˜ƒƒ“ ©¬©£¤£–‹|qkgdigfe_ZSI?63/6?`|’£§ª®®§Ÿ˜•“Ž‚wnbZRJ=62>Hasyzyv›¶ÉÍðž‡|}~v{xxtsntxwtvwtoqmkjkce`TEQUN@JWckcWA0/)'$'*-/-.*"##$"! '* + + + + + + + + + + + + + + + + + + + +,s¢§§«¨¬¨«¯§¯¯¯¬©ª©¯¯¬¬¯°¯¬°´³«°¯¯®®¯«°¬°®°±±¨¯²±³¯³¯·¯µ²´²²®µ·¶¶´³´¯´³µ³¶¶µ²²²³®²±µµ´µeegggfdefefgiihhhijjkigedijjjjiijifhjjihjkijjighjnnllnonmiea[TLH?@@A@>91& + + + + + !)..-.12;BFIJLNOLGFP]q€‰Š‰ŠŒ‹‘Žm[GDCCC?9674.,+2;NZQB==NZ\\]_\WOH]noifd`][hqvtqkida`_YZ[^cfilpwtg_^_clrsvwy|~}|{{zzvrleciŽ‹‰„zwwwrlklnyƒvfXYYWUTUXYXURPONMGAGM[Ž»Õ×Ô̸ºÎÚÞÞÞÞÞÞÝÞßßßÞÝÝÝÝÝÜÜÚÌ«ŽŸª«¦£¤£“ˆ|v‡†tmswvsmd[PFAANv’ ªª©¥Ÿ™Œ‰…|uk`SI>500;Nbpuzz—¶ÍÖÖÒÇ»ª’ˆƒ‚€€}}ztvwy|wrssqomkiihfaZOINVN?DR]aXK=.+%%$&(+,-/-)&##"""() + + + + + + + + + + + + + + + + + + + + + + + + + + + + -{¤¨¨ª®¯°¨ª««°®¬¯²°¯¯¯¬¯±®®®¬®¯¯³±®¯¯®¯¯¯°±°¬¯°¯±±°¯¯¯±±²³µµ···µ´°¬´¸¶´±³²¯´¶µ´µ¶´²²±´µ³²´´´¶deeghhgfecfijiifgghikigggfgghiiikjiijhhhikjkkjhgknmkmnnnnjiigc_[UIC?@=<95/( + + + + + + + + + + + + +#),-,++-7@EGGFGHD=@GYr‰‰……†‡…„xfSIBA@CFC=7880.,48KWOA?>P\][`_[RNFUdifa\\V]fmqw|zwocfghikorvxty}xjdaa_hnrvvw{||{xtrnofhZ_c}Œ‰†€zywrlqu{‚„~nZZ\\TUSSTTURLKHFEC@EHo¡ÇØ×Ð̸¾ÒÜßÞÝÝÝÝÝÞßààÞÜÝÞÝÝÜÜÜÓ·‰sŠ›§«©¦¤ ˜Ž…x•¡¢vxz}{wrj_UV\… ¥ª©¥ž•‡€|ung]RF77112EVennmŒ¯ÊÖÙÙØÕÐÁ¬†€ƒ}|zzuyzzvtrqmohgfedcb[PPNQVYDGKJG>.+)'$%#$$%$'(-.*$#"##(' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0{¦§¦ª«©ª©©©¬¯°¯®¬«±±±±°¬¬¬®¬¯±±©¯ª®°°¯°°¬®®®¯±±±®®³³³¯µ·¶¯°¬´¶µ²³´³¯´µ¶´´´²³³´³³±µ´¶¹eedfghigdddhfijihhijkihhhhegfgijjkiiiiihijjklkjklllnnonnmkkllmkjf`XOE@=??=:60( + + + + + + + + + + + "&),-,()/9@EFHHF=::DTn}„…„„†…lT<2/7<>BDB>8699426=IQJ>@IV__]bc]TMDGW_`ZZWT_efnz…‡‚}wrstwy|~€}zskeea\aiossuuvvurmikkjbWZat†ŒŒ‹Š…|vrqw~„‡vgZZ^][XWWWWUPKIGDBA?BK}³ÏØ×ÓÌĺÇÕÜÞÞÞÞÝÝÝÞßßßÞÝÝÝÝÝÝÝÝ×Á”z„•£©¬¬¥™‹‚x„ ¯³¦’zx€ˆ‹‹Šƒuh_oޤ¥¥ ˜‰„{tkcZRJA65668=N^iniyŸÃÕÙÚÚÛÚØÑŵ¢”…€|xzzz{yxwtqonmjfgdc`VSfrsurfROH9-&%%#"#$##$#$&+/-($#$$)& + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +7|¦ª¬¬¬¬«¬®®©«®®«°±±±²®««®®®°°±°®°°¬®°¯¯±±¯²³°°¯®±³±±´¶µ³²³µµ³²´µ³´µµ´¶¶¶³²µ¸µ²³´·¸¹»geeffgihhhghijjiiijjjikkiiihhhiihjiggijghijgjkkklllmnnnlllkkmmmmmlgb^YQDD:=>=:61) + + + + + + + + + + + + + + + + + + %',.-*.1?BLMLJFCCBPft|{y€„|lR2/'.2<?@A?=81;;427=GMG=FQ\ba`ee`XQHKNZZYRSUekhhy…Їƒ€~~~‚‚€|se\QTWZ\bglgmijjploillg_WOMK_s…‹‰‡…‚|uts{€†ƒvha\]^]ZYYYWYUSNJGB<<;BS¿ÒÔÖÓÌÇÆÎ×ÜÝßàÞÜÝÝÞÞÞÞÞÞÝÜÜÝÝÞÝÚÉŸnŽ›¤©«¤”Žˆ~o„Ÿ¬³¬ƒw…“ž¥£|z—™œ”‡vtqjbZSNCB;989:=ATdkmtˆµÑÚÛÛÜÜÛÚÙÕ;¬˜~}rwwzyzsxurjolkfec_YX\}Ž„tfS7-$%%#!"#$%$#"!(--*&"$%'& + + + + + + + + + + + + + + + + + + + + + + + + + + + + ?~¦ª«¬ª¬¯±«ª«ª©«¬¬¬¬«§®ª®±°¯°®®®¯¯¯®°°±µ´±³²°±¯®«±²±±µ²´³³´´±±³µ¯´¶¸¹¸¶µ¶¶´¸¹¶³¶¹µ¹·gfeefghhjkiihhfghihhijlkghhiijhgghhghjkkjljiiiklmmlmklmnmmmljllmnnnmljbZSJ??CCA?:3( + + + + + + + + + + + + + + + + + + + + + + !$),-.1:CQUTSPKHEAG^jqqqw{mT0+**/5>FHGC?::<:315;DGCDM]ejiiifb^WQQV[]VMKZnwuru€„‚}€ƒ„‚€€ƒ„~saNAFILRY`ffdhjlnmmoqmi`RDDAAHl}‡…„‚~wvz|€…ƒzg_]]]]\ZZ\\\[ZVQLF?:;=@^œÉÕ×ÖÓËÇÉÔÚÜÝÞÞÞÞÞÞÞÞÞÝÝÝÝÝÝÜÜÝÜÚϧsy‡’¤¨¥œ’ˆzs‚™¢§£™‰ µ¶´« —“‘‹†”|lfc_XPIHD??=;;<>@DXjnq{§Ç×ÛÛÛÛÛÛÚÚÚÖÐÄ´žstvxzyyxwsqnljgeaYUXw‘ Ÿœ›•‰{eK.'%$#"!$+-&"!$'**%"#%)$ + + + + + + + + + + + + + + + + + + + + + + + + + + + + H‚¦ªª¬«ª«¯°®¬ªªª«¬®ªªª©¯¯®¯¯°±°®°¯±°±±²±±³µ³±²²²³³³±°°°²³µµ²²³³²¯³¶µ´¶¹ºº¸µ´¶·¸¸·¶¶µµ¸¹¹·ffecggfgjkjhgfeeffgcfhkjhhhijjhdffgiihjkjijfjijkllmlkkmnnknmllmlljlmmljhe`YQN@=<><81( + + + + + + + + + + + + + + + + + + + !!!$&*.5@LW\]YUNDBAHU`ffdkn^>,((*5;GMJFA><;:42168ABKQ`koqolkhc`]XZ]acZJOax†…€{suurpy~€€}‚veQ<?BFEGJNQTW[`eilpqrmc`POOTZeqƒ„}{yz€ƒ„|lb\]]\Y\\ZZ\^]ZSLGB<2:?Mm©ÏÖÕÖÑ̼ÊÔÚÜÝÝÝÞàßÞÞÝÝÝÝÝÞßÝÛÛÜÛÚÒ®yyƒ–¡¦¨¢˜‰wdw†‰Š…€~|¤¯·¹ºµ°ª£œ‹ŒŠq_KLNLEC>@?>;;:==AG]oqq–¼ÓÚÛÛÛÛÚÚÚÚÛÚ×Õλœxyvvvutvqupomkfc\VWtŸ¦¡™š”‰y`A(%#""#%.2-"!!"!'($ "$&$ + + + + + + + + + + + + + + + + + + + + + + + Q‡¨ªª¬««¤©¨¯¯®¬««¬«¬¬®§©¨©ª®®¯¯°¯±®¬®±¬°¯±ª°±²¯®¬°®³±´²²±±±±´µ²²µ³³¯´°¶´·¸¹··´·¶·¸¸¶¶µ¶µµ´¸¶efeefgfgjjggfgehgegeijhhhhghjigghhhkjhikjiiijkkjfkmljklmmnnmnnmlkjjkknnopojd_YPI?CA@8/& + + + + + + + + + + + + + + !!!!$&,5=GQY][UOE@>@LTZ[\_`R6**,3>JQSJ@;:8864227;?JWeouwvsolhdbbacegh^RRb}Œ‹€ung^iouz}‚€{jS?<?CDDCBAA=@EO]lv|zwph`bhnu|„‡‡ƒ|z{}ƒ…„se^\\\ZX[\YZ[^\VK@:986:>P‚¶ÔØØÖÒËÉËÖÛÜÜÝÞÞßßÞÞÝÛÙØÙÜÞÝÛÜÜÛÛÕ´rŽ–¤§¤˜‡vioyx{yz~†‘¤µ·¸·µ·´¬¢š–†lXC?ADC?==?>::;;<?J`rs{§ÊÙÛÛÛÚÛÛÛÛÛÚÚÚÙ×̵ƒ{zxxvussttqomg_TMW€—£¦¡œ›š—’†pI*%""#$&+20+$"#$$$#! #& + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +W‹©®®¬¬¬®¬¬®©¦¬°¯¯¯±°¯±²°¯°±²°®°¯¯±±°¯¯¯¯°²²²´µ³³±°³³²³µ¶´µµ·¶´¶¸¶µ¶¸¶µ¶¸ºº¸¶·µ³µ·¶hhgfghhiihhgghhhhfihkkghhdgghijkkklkkgiikjiilllgjlmjkllkmonnnmmllilmnopoopnklic^XLE@@9421-& + + + + + + + + + + + + ! !"!!$'()08BKMNH@;8<AEIJKVZN64.9BOYZUH:75321.23;GPXgqtwxxurmeeddehiifaTYd|ŒŽˆ{mcX\ceguz€|q\?<<ADEBEDB?<9?@Vm{ƒ}vmfbn{ƒ‡‰ˆˆŠ‡ƒ|zuxz}~{rfZYW[ZYXZ]]^]ZYMA54355:>[—Â×ÙØÖÒÌÃÌÖÜÜÛÝÞßßßÞÝÜØÓÐÑÖÛÙØÙÜÜÛØ¼‹w|Œ–›žŸ“ƒvgq|‡“˜œŸ Ÿ«ª³´´´¸º¶°¦˜ƒfZHFAAA?:99:9:::8AL^ms‡´ÒÚÛÜÛÚÛÛÜÝÛÙÚÚÚÙѶ‰{wxtuknlqlppjaTFNUlŽ•‘‹Œ‹€mN-&! !%),,'!#$$"#!!$% + + + + + + + + + + + + + + + + + + + + + + + + + [Ž«¬®ª®¯¯£©¨¨¬¬®«¤±¯«®®±¯²³°©®°®¬¬¯«°¯°¯¯¯«®³±´µ´³³«³µµµµ´µ¶¶¶¶µµµ´µ··µ±¶¶º»º¸¸³¶¸¸³egggfhjjihehhhggijiijjhhiiiijllljkkkjjiiijjjkmlklmmklmkkmnonllmnnnnnnooononopqnnhaZREB<?>>6-% + + + + + + + + + + + + + + + + $"#"!!#"!"$#""(+39><70038>A@EKPLECDMXbf_QB61/-++,16>TcmquuvwxvsoligfgjlkkcV[g~ŒŠ€n^TTZa\`nzvbH99<AFGGFEA>;7:>Pgwyoeacqƒ‹‰‰ˆ…zrqttrk`UQPV[___aca``\UH9666558Ag¨ÌÙÙØÕÑÊÃË×ÜÜÝÝÞÞÞÞÞÚÕÐËÈÄËÍÊÇÍÓÖØ×Ùmu†’˜›”Œ‚uhq}’¤´·¸¸·¶´³³±³µ¸º·¬›c_WRLHDA>;9:89:97BN\gt“ÃÕÛÛÛÚÙÚÚÛÜÛÚÚÚÚÛÒ·‰zvuuphjmmnmmbUG>JR\dmvxoeikmg\I1'!""!!#&(&!#$$$##"'$ + + + + + + + + + + + + + + + + + + + ]‘¬«ª«ª«¯®®«««¬®©ª«««¯ª©°°®±±¯¬«¬¬¬¯°±²°¯°°®¯±²´´³³³´³±±²µµ´²²¶¶¶¶µ³³´µ··¸³³¶¸¸¹ºº·²·º¸³ffgghijihhiihhhfihhiijiijjkllmlhiijhhhkjigfgklllllljmmklklonnnnnpoomllnppponoqqpnkid]VPE?<<961*! + + + + + + + + + + + + + + + +",+($$!###"#$#""$&&),++,,/49>><=?CEHR[dfbT@9/-*)&'(5@RamssqpqsuusojjhgcjlljdV\k€‡wgNKIW^[Uix}|kQ@69;AFGEE@>88876DQakhc_^gn…‘’‰ŠŠŠ‡„|moome^MROVYaec_dd``_]UF:788539F€·ÒÙÙØÔÍÃ¿ÍØÜÝÞÞÞÞÞÞß×ʺ¾¾»¼¹«±ºÃÈËÎÀkf}‘šš’Œ€vfp{—®µ¸¿¾ÃÄ¿»°«©¨¦¨ªŸx`ba`^VIE>=:966698IS`cl•¾×ÚÚÛÙØÙÙÛÜÛÛÚÙÛÜÔ¸ˆxrskjihhmjicYE?;JM[_iigTH89;:96/'!""#! "#"!##$$##%(" + + + + + + + + + + + + + + + +$a“¬«ª«¨¬®®¬ª««®¨©¢©¨¬§¤°°°¯¯«©©©ª®°±±³²±²±¬¯°³µ´¯¯¯³®°³±´²°¯¶¶µ¶¶±¯°·´¸·¶·¹¶¹·º¹¸²·µµ´hgfghkjhdikkghjigegjgjjjjilnmlkihihgimlkjjiijklmlkmmmlklmnnmnolnlolmljnoonopmprqppoomhbYOI??@@:5.' + + + + + + + + + + + 084.*(%$##$$$#" ###$()'&&'-2665236>GPZ_YN>71,)('&(.=Tajpsqnmlmnonlkjihhlmlke[\o„ކxdMHHQYWVeuxp]F879:@DEDB?;778649AJTWXXcnx†–—•’‘‘އ„~uomicWUX]bghgfdca_]]\TJ<87754;R’Å×ÚÙ×Ðò´ÈØÜÝßÞÞÞÞÞßØÈµ´±¬«¦ ¡³³®·°–kaq‘Ÿ£ œ”‰ujn{•®¼ÂÃÅÅÅÅÃÀ»±¥‘‹ˆˆ…~kefikofZKA<86558;EZgibb‚®ÎÙÛÛÛÚÚÚÚÚÚÛÚÚÚÛÕºŒwrpomlkkkie_P@9=KU_gjibR6***$$&&$""###"""$####""!"&(! + + + + + + + + + + + + + + + + + + + + + + + +*h–¬©ª«¬¬¬¬«««¬¬¬®®ª©¨§¦©§ª®°°°±±°¯®«¯²²²²³²²°¬¯±³´³°®¯²®°³²²²±±³¶¹¹¹º¸´µ¶¸¸¶·¹º»ºº¹»¹¹¸·µ´ihhhhiihijlhgijhhdghihjiihlljjkkkfjgloniljkjjjkknmnmmlljoomilnonnoomljnonnopqqqorqpqqqmid`ZSLA=:9895," + + + + +;C<520&&#$$$%$##"" &**&%%%$&)+,.-.16;?B;53--((''&0;UfklppkiieefffgghhihlmkjeZ[t‰Š{jQK@KQQKbomaL56678:<ABA98752419<GIXagkxŸ˜—–”…ƒzvrlfedgjlmjgfed^]Y[VRNA44555?b£ÏÚÚ×ÓÄ©›–Á×ÜÝßÞÞÞÞßßÚͶ°š“‹‰˜œ™›ž˜v_u˜¬±®«¦ tqu…˜¯½ÃÄÃÂÄÄÃÀº± „†w}~}|{}~wl_JC5435:FVv„xc`a³ÌØÚÛÜÛÛÙØÙÚÛÛÚÙÖ¾vonnnjmnlhbVL@@BR]gmkgaR8&('#"#""##$%"$##$$$#!!!!(*" + + + + + + + + + + + + + + + + + + 3r›¬ª©©ª««¬¬¬¨§§«©®®«¬§§¦«¯±±±¯®°±°±±¯°¬¯°°«°¯²¯®¬°¯³²±«®®°ª²±²®±±·¶º¸¹¸¶µµµ¹´´´¹»º´¸´ººº¸·¶hiigffghijkigihgikihigijigklijkllkjjmnmmmlkjiljlnponlllnonlkknnmjoomlnooooopppnoqropqssrqoke]TJC:DFE=4+ + + + + + + + 4>??A>3)(&%$$$##"##'*)%%$##$%'*++,-///0/--,*('&&'8TiutsrodhhecdcbacehhiihhibY\z‘™“ˆwcPHFILS]d^O<434569;=@?=962/25;ELR[mnx‚“¢¦¢›—––“‰…~wqllmoppmifdeda]]\]ZSF63334Cv±ÔÚÙÕʯx¼ØÜÝÞßßÞÞÞßÜÖ̾—‘{‚‰’™™u| ¹ÂÂÁ¿»«“uou…˜«¶¿ÂÃÄÄÃÁ¼º¬—‡ˆ”˜œžœ—‘Š‚ueTD;56<Qn”“‚pc^cŒÆÏÖÛÛÛÚÚÚÚÛÛÛÛØÅuqonlklmie[RG?DKWblpkc`U:('&%$###$$$$"""#$&&$##$$$)+" + + + + + + + + + + + + + + + + + ;x««ªª«¬««®®«««¯±°¯¬¬¬¬¯²³°®«®®®¯®¯¯¯®°¯«°³²°¯±³±±°«®¯®²´³´²°°°µ¹···¶µ´´···µ¶¸¹´´¶·¸»¹¸¸¸ihigfehhhhihihgghhjjifiihgjljjjllijkmlkkmljfiklmmknnnllllmmllnnkiillmnnopnpooonppqqrrqsrrppolgaZRIFC@=95/( + + + + + + + + + + +%.6?A:40,*(&%###$$%&&$$#"&&%%()$())))*)))(&$$$(*A_p{{|zsokkghgdX^^beedbaff`W`}™¤ ™‰wdSMDLQSSK<5///2588:8<=920.25@LTXk|€€~~¡¨¦™†’“އ{vonloolie_cedddddea\P;412.M‰½×Ù×Ͷ–yt½ØÜÝÞßàßÞÞÞÞÜÙÓɽ±¢’†|zz‰‘’Žƒz{œ¸ÈÊÊÈÆ»¦†esx‡ŒŸ©±·»¿ÀÀ¹¹¯ ––ž¦§¨°²°¦›}mZO=?BZv‡Œtpmf_³ÈÖÛÛÛÛÛÚÛÛÜÜÚÄŠqonkihhgbVOA><CKXdnso`icI+(%%%$##"$""! $$*+)&*+'$*,! + + + + + + + + + + + + + + + + + + + + + + + + + + + + <{œ¦¬¬¬ªª©®°¬©®°²±°¯¯«¬®®®¯ªªª««¯®ª±±¯¯¯«±°³°°°±®¬±ª¯°µ¶µ±±°±®µµ·¶¶´´·¸µ²µ·¸³¶¶µ¶¹´··¹¶gijighijihggijeggijkgfhihhikjkkkkiijkmmljlkiikmnkillmmlkkmnponmkijloonlnmoppoooqpprrrrsrrqqstspke^WODCCD@<3* + + + + + + + + + + + +*1110332-&%####"#%%%##&'$$&&$$%%%%%$%&%#$$$*3Haq{~€|tmmnkic`ab_dca^cba\Yd‚œ¨©¦˜ƒqbXRONID73..0/.3799:;<92/-16BMT]q‡‰‚xyˆ›¥§—“’“’Œƒ{sqpqrnid`aeeeegijgcYI7344Z›ÆÙÙÒ½ €qp¾ØÜÝÞßßßßÞÞÞÝÝÜØÔÐÊÁ¶«¡”ŠŠ‰ˆ‚{y‘®ÄËÌËÈõ‘how}„Œ”Ÿª³»½·²ª ™œ«µµµ·»¼½¹·¬œˆwh]XXbw}ssz{gTXv“²ÇÕÙÚÚÚÚÚÚÛÛÚÄŒmlmljhebXNB;::?GTbowtsvrV1)$%&%$#"##"""#(+./.,-,(%,-! + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ={œ¨¯¬¬¯¯««®°«¯°±±°®®°¯®®¯®«®°°±²¯°²³±¯¯±³´³°°²°±±²±±¯¯±³µ´´³±±±´¸¶´´µ´µ¶·µµ´¸¸¶¶¶·¹¸´··¸ºhijihhiiihhijkkjjjjigghfhhiilllmlgjlllmmllmlkjnonjmjjjklmmnqqllmkkmooopoooqrpnoqqprrqmqrrrrsttrpnmic]WQHED=:73,! + + + + + + + + + %,573.,(%$!!!%%%#"%% ##$#" $$%%$#%$#$%%-7GZhsy}vnqtsqlhhgedc`aa^VUTi‰œ§ªªœˆte\XTPKE=41.1/0258:;<<951*/5>DFIg‚zqp€ŽŸ£“zŒ“““ŽŒ†~vvtsspje[beecdbhhfe`VE79=pÎÙÕǪ†ynq‹¼ØÜÝßÞÞßßßÞÞÞÝÝÜÜÜÛØÓÎǽ´£™‚€oowž»ÆÊÉÅĹ–mot{}ž£º¶³®± ¢µ¼¼»¸µ½´Àþ´£Œsmgksvwusxv`BN_z¥¸ÈÒÖÚÛÚÙÚÚÙÄ‘mikmlgaUNB;38766ETfvywc9-$$"&%$$$$##$&+.//-)'&$$+* + + + + + + + + + + + + + + + + + + + + + + + + C€ž©¯®«°°®®¯®¬«®±±¯«°°®©®«««®¯®®°°±²±±¬°²´³³³´³²³³°±²°°©±±³³´±±°³±µ³´®´¯µ´µµ´¸¸¶¶µ·²³³¸¸¹¹gikjehhhhiijkkkkkkhigiihehjkmlionmlmmlimmmnplloppponjjlnonnponoolknnnpppnnprpnnpqqrrnnorrqortsqqsusqmic\WPCCDD?6.% + + + + + + + + (--//.+)&#!$#"#"###$$"" !#$$$$####%&'/7DQ]hqy{zvsuwwvurpkgccb_\XSTUo𢍩‡tg\WTOKHD?<82..16:::;;972.,2789ATkpldn~œŸŽu”’‡‚~zxvtrnhb_bgihfeeebee`P>;K‡½ÕØÏ·Ž|snr‡ºØÜÝÞÞßßßÞÝÝÝÝÝÝÜÝÝÜÜÛÚÖÐȸ¦Žxckˆ¯½Âÿ´—qlnv~‚ƒ‚Šž¶ÄËÌËÈÆÀ½»ÄÅÄÂÂÂÂÃÄþ¶¨’ƒ|vppqsrrpiTCESepx¦»ÇÑרÙÚÛÙÂnhjmmh^QD<7479500@Vl{„ˆˆpF1##$')+,*&$#%(*--+)%"$$&*' + + + + + + + + + + + + + + + + + + + + + + + + + + Lˆ¢¨¬¯®¯°°®®¬®¯®¬°²´±®°°¯ª¯±®ª¯°°°¯±³¯°²±±²²²³³³²³µ´²²²±¯°±±±²²³±²²³´µ³´´´µµ·¶µ²¶¸¶µ¶¸¸¶¶·¹º»hhijjihhikjfklifklkjjjjjjkkkmlnpoooknnllmkmnlmoppooonlljnlmnmnonljooooppplnoomnoqqrpnoqrrqrrsrptwwurrrnmke^UPEE@<962) + + + "'*,,+&""""""!"#$%%# "$#"#####$%&)03;DPZclqsrosrqqqqomg`ba]VSQU\}’™”¤¦™„rcWOMIEDDCB=7..0599:;8996/02789:FMRW_n€“›ˆp€Ž’‰~|~|ytqolba^dhjigfffffhfYCB]›ÈØ×Ŧ†vsnr‚¹ØÝÝÞÞßßßÝÜÜÛÜÝÝÝÝÜÜÜÜÛÜÜÙÑĪŒwe…¢±¸º»·ªogco{„Š™ªÄÒØÙØÖÖÔÎÌÌËÊÉÇÇÅÄÁ¾½¾¶ †ƒ}uknffc`ZL<EHW`dg}‹¡³ÅÐÕÚÜØÀmdgjje]OD986<>;002HSm}†ŒxT7$&'(+,-*&#$'(((((#$$%')& + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Z§©¯¯°°°«ª®®®¯°°²®±±°«±®¬«¯±²²±³³±°±°²®¯±±®®¯°±´®²²±°°¯±²´´´²´³¶¶¶´µ´µ´¶¸·¶µ²¹···¸·¹·¶¶º½fgghjjiijlkjklhfjllkkkkjjnmkllmooonmnommmlllinmmnnlpqpmmmmmmknnmmopqpopqqponopoqrqpnloqrrrrrqqquxxuuutuuvsngaXLFBDEE<2( + + +$'('%%%%# ""$''%"%%#"##$$$$%).103;DMT^ekmnoonnnmlke`__ZTQORn‹›œ¡Ÿ‘€l[RQKA8>CCA?:2.1379::89;8554678:;=@MZp‚“œ—~y‹‰ƒ~}~~{xsppkgcabgijihffeillaRK{¬ÏÚÔ¹”uusosˆºØÝÞßßÞÞßÞÜÜÜÝÝÝÝÝÜÜÜÜÜÜÜÚØÒ¼˜‡†™§°²±¡†j`_et‹•ž²ÈÕÙÜÛÚÚÛÙ×ÕÓÐÊǾº¸¶·»´¢ŠˆƒztneZRLJECFGISY^chpŽ¥¸ÆÑÖÖÁŽledfc`XMC:;=CFD@?AEKTk{…z_=*('((**'$#$%&%$#((&'&&(*% + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +a–ª±¯¯¯°±°°±°¬¬°±°¯¯¯°±°±°¯¯®¬¯¯³´´±±±³³³³²²³±®¯±²³³´´´´³¯°²µ¶¶¶´µ¶·¶µ¶µµµ·º¹·¹»º¹·¶¶¶¸¹¹¶º¼ehijkkiijllkjjjhhgljjklllmmlljlonkmmllklllmlmnmkmnnoqponnnmlnnnmoppqooopqqqqpooprrqnoqqrsssrsrrrvvuuttuvuutsqle^UFFFB?:62+% + + + + + + "%')&#!#"'),-)&$#$$#$$#%&+24/04;?HOW^cffgkjkfda^[]ZXURO_|˜¥¢ ”nbVTOF89<EDBA@5102579989:9765533233;I`tˆ–˜“…y†Šˆ~x{}zxusnkifccejjjjihilooibp•»ÔØÍ¬}rssot¿ÚÜÞàßÝÞßÞÝÝÞÝÝÝÞÝÜÜÜÝÝÝÝÚÕÑ¿ŸŠ}‚„˜ ¡¡›xXTR]jx‡“¡®ÀÏÙÝÝÝÝÜÜÜÚØÕÏÇ»¢Ÿœš˜˜™˜‹ŽŠ„zpcIDAECJIHGORY`ht}‡®¼Æ¶Žj\_^]TOIB7<BGIIIIHJLPShsn]<)*&&"#$$!$%&%%%')(&'&&%)% + + + + + + + + + + + + + + + + + + + + + + + + d™«§°±°«¯¯¯°²±°®¬¯°®¬°¯¯©ª¬¯¯¯²´³°¨²°±²´³³²°®°°°¯µ¶µ¶·¸¶±°°µµµ²³®¶´¶¶·³¶µ¶¹¹·¸¸·µµµ¸¶·¸º¶¹¸dijjkkihijkkijlmjijkillmlkillklolijlkjhiknnmmnmkmnmnonmnnmmnnnnlppppnnnnooprpmmnosrqrsssrqrsssruuutsqtvvtutwxwsoh_WQFDDECA90& + + + + + + + +#&%%%'(+.65.%"#$$##%%&).562-/26<AGNTZ^cefda[[ZZ[ZVTSPg†œ£ ™n^TUSK=::CJLLLG>4/.25899:::8665320/07Oj€Ž•“Ž‹ŒŒŠ„~{vx||ywvtpligefjmnnomlkmpqno‚§ÅÓÓÂsppoms“ÂÛÞßßÞÝÞÞÝÜÜÝÜÜÝÞÝÜÝÝÜÜÜÜØÏ̼ž†}€„ˆŒ…h]ONQ]n›§³ÂÏÔØÛÛÜÜÜÜÜÙÕÍ»§““–‘‹–˜—“‡€viWOKNPMFDDJPWakmmk{Ÿ£‚f]\[XVMF=:<EKNONJHKPOOV`_T;/,)&##$"!#$%%&'(('$%%%()# + + + + + + + + + + + + + + + + + + + + + + + + + + + + ešª¯¬¬®°±®¯¯®¯²²²±¯±±¯®®¬¯²¯®¯®¯®¯±³³±²±°±²³³±²²²²²³³µ¶µ¶µ¶¶¶´³³µ²¯²µµ¶¶·¶¶¶¶¶···¸¹¸¸¹¹¸¸¹¹¸¶¸¸fgihihigfgkkjglljkklmmllljjkklmlkjkjklkgjjnmmmmmnnmnmmmnoonmnmmlpqnoommmnmpqpnoiprsstrrpqqrssqsuttsstuusttuvvwwvtpkfaZUHEDD@:5." + + + + +$(*-033,$#!$#"#&''*3:93-./136<AEIPVWUXYWWXXYVPMNOdŽ”„xdWKPUQC:8>GLOPOJC:1./3799:;:9764110/+C\x‰ŽŠ„ŽŒ‰xxtsuwwttqmjhhhknpooqpkmkmloo‚¥ÀÏȳŽkmmkes—ÅÝßßÞÞÝÝÞÝÛÜÜÜÛÜÝÝÝÝÝÜÛÛÜÖÍǺ‚{€€…†‡„‚€ynaSQPbrŠš¤±¸ÄÍÕÙÛÜÜÝÞÜÚÓÄ´¯µ¶µ·»»¸²¨—‘Œ‹…~utulbXNKHIJW`^\]V\fd___^ZYUK>:6CKNQROH=HNQNTTTE=0/.+%%$# ""%$&&&%$$$#&')! + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + !hœ«¯®¯¯°°¯¯±²²¯±¬¬¬¬¯¯®®²®¬«°²³®³²°¯±±²¬²±±³³³²°²³´®µ³´³³±²¯²³µ³µ²´³¶³´¶·¹º¹¸µºº¸¸¹·¸¶¹¹ffgiihijijkkjijkklllmmlkllkiglmllmkikoommnonmmmnmlmonmmnpqommonnpqnpqpopqqoqpppqqrrsrrrrrqppqstsstrsttttsrsttwxxxxvurmg^UNJIHHA:1) + + + + + + + + + &()**)&$###"#&(),5:81,,+-.0269<@EGHIMNOPQPNIFIL]oy{tk]NCIOUL?78BJMKLMJD<2./267789875420///8Pn€‰ˆˆ‡‹Œˆ„}wurpqstqnjggiiiloportrooooopq–®¾º¢}omlheržÇÝÞÝÜÝÝÝÝÜÜÜÛÜÜÝÝÝÝÝÝÜÛÛÛÕÈȼ¡z„††…„„…„~rf[VXdp}Š—¡©®»ÃÉÍÐÒÕר×ÑÅ´¸ÃÎÓÔÕÕÔÓÍõ§—š›œ›˜’‡zbZDEMTUUSMLLNQYba]YSG;8@JPQRROGDEMRUUTOIB=:71*'&$##$&&%$##$$&$'*( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + "l ¬®¬«®¬¬¬¯®®°±¯°°®¬¯±°¯±°±°®¯±²±²³°®±²±¯¯°±°³³°±°®°³³µ´´µ³³±´´´¶´³µ·¶¶·¸¹¹·¹º¹¶·¸···¸¹¹º»ºgfhjjgjkjjkkjjjkllljihkllhjkjlmmlmljkpoooopklklkllmnnnnopqpnmoooppopqpqqrrrqpmrrrnrpppqrssrqsttsssrqssssrqsuvvwxwvwvwvspke`VOJKFB>:61," + + + + "%&&%#%!$$&'*,042/.-,,,-/.22348::;<>?@ABA?FFQZ[[WTK?KTUQE579FKMLKKG?;0..12444431221-,+7DaxˆŠ…ƒ{yutrqnrqphigijiglmnoqrqooonopq{€”¢žxomhc`n¢ÊÝÞÜÛÜÝÜÜÜÜÛÛÜÝÝÝÝÝÜÜÜÛÛÚÓÇÉÁ§‚y€‡Š‹‰„‡†‡„{qcXUVamy„›¡ ¢¦²µ·¼Á¾¸¯¨¯ÂÒÛÞÝÝÝÝÚÔËÀ°ª¨¬¯®®®¯«¦œ‰nKMKKKJIIHGFWca[VHB6:FPTSSUQNHLNSVUURNKAA=6.,+)&%&&%$!""#$&&'*' + + + + + + + + + + + + + + + + + + + + + + + + + + + + #p£®¬ª¬§¬ªª««««¬®®®®¬¯²²±¯°®¯°¯®²±°°±²°®°±±±±±²²¬±³µµ·´·²±±¶´µ°µ°µ·¸¹¸¶¸º¹´¹¶·¯·³´µ¹¸¹·½¼ihjkkjijiihjjjkllkijegijjiikklmmjllklnoommppmlmlkmnmloppnpomnqponploooprrppppqrsrrssqqqqrtuusttsrsrqqutrqstvvutvwwxxyzyyxvqjc]SNLLJKIE:- + + + + + + + !$$%%%&'()*+-,..-,,,----,*+,-./146:<@ABCDFKMLHC<FWaZJ;37@GKLMKHC>:2.//00122210/.-,-AYq€„„ˆŒŒˆ€wutsstsstrolklliikmmmllnpomlnnpxƒ„{tpkcZ[k¢ËÝÞÝÜÝÞÝÜÜÝÝÝÝÝÝÝÝÜÜÜÛÛÛÚÓÆÊÄ«…y|‡‹ŒŠ‰ˆˆˆ‡}p`SNMM[iu€Œ–›”’’Ž‘’Ž–™³ÇÕÛÜÜÝÞÝÛØÓÊÃÁ¿»´´´¶·»¾±—xTIFFECCAADSb`YRE?8;FQVVUYXUSQPRUXYXWRMGB:963/-,+*)'$#""$&%$)% + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +u¦®®®¬®®®«¬ª«¬¯±°®¯®²²°¯¯°°±²°²°®¯±²³³³±®¯°°³±¯±´³®²µµµ¹º¶²²¶··¶¶µ´µ¶·º¸µ·¹¸´¸¹·····¸º¹¹¼¼»ihikkiihhfiijijlljlkjijfjjjijjmmkklklklmljooonoppoooonpqomnmnqqqooqrrqppqlooqqrrstuurrrqrsvvtqsttssstuuttttsuuvtxyyxxxxvz{xvtpia]RNLNMHB;2( + + + + + + + "$%%'')(*+,,-+-01100/-+)++*(/19<DEFDDEFEMKH:BL^fVA849@GMOMIEA><4.+././1320/,*',/>^w‡‹Š‰‰ŠŠ‡…wutvxxwwwutronmlhlnlehgmnoiklmowz{xtgpnh_UMd ÊÝÞÝÝÝÞÝÜÝÝÞßÞÝÝÜÜÜÜÛÛÛÛÙÒÉÈů‰v|„ˆƒ‰‡‰†Š‡vYOA@>DHWdp{˜™–‘‡‡{w‚–™¹ÎØÛÜÝÞÞÞÝÚÖÑÌÇÁ¹¯°£¬¯·¼±ŸVJ<:9:;<>S`^XQFA77<GMORUVTQMFHKQVWXVTOKFB>:3-241/+&$!"!&%')" + + + + + + + + + + + + + + + + + + + 6z¨®¬®°°±°°ª®ª¨¨ª«°°²¯°®®°±®¯±²®²³´µ´©®²³³³³±±°²´²®²´µ°³³³´¶¶µ®´¸·¶¶³¶±¶±¶µ·µ¶µ¹³¹»¹···¸¹»¸¹º¼ºhhfjiiiihijiiiikkkkklllkkkijkllkhjmnmkimopmmnoprrqpqponpolnonprroorusqppppoprrorrstusqpqssvvusqtuutusvuuuurttvvvvxzyxwvuxyzz{{vokh`YPOOLKF=3) + + + + + + + + + "&')*++++---133542/+**+)'/6?HJHIKKKKRYYRJJXbbP:69;?FMOKFB=><6-,,-+-010.,)&'+/;VpƒŒŽ‰„‚ƒ€|xtux{zyyywtusoononolihgmonnllnptvusonnkcYPM[ÉÜÝÝÞÞÞÝÜÜÝÞßÞÝÝÝÜÜÜÛÛÛÚÖÏÈÈŲŒx{…‰‰Š‹Œ‹…mN=;;;>AFR`qƒ’––’†‚}|ˆ”›œ¢°ÅÐÕØÚÛÜÝÜÛÙ×Îļ·±±¨§ªµ¸µ¤S97778:DXb^ZSKB813:@ADIKJHC?>@EHLNOPPNKEC<515873.'%"#%'')+! + + + + + + + + + + + + + + + + + + + + + + + + + + + + 8ªª¯°³³±¬®®®°±±°°°±²±¯®¯®¯±³³³´´¶´´±±²°²µ¶´±³³±±²³µµ³³³°°²³²µ¹¸··´¶¸¸··¸·µ¶¹ºººº¹·¶·¹»ºº»½»»ghikkihhjkjiiiijkkjflnmkkjjgkkjkllnonmmnpqonnjnqqqoppnoooloonprnmmqrqnomooolrrrrrprrrpopssuutstttruuwvuruvvuvwvqrtyzxuuuttxwyzwttuqkfa[MQLIC=71& + + + + + + + #&*+)*,/--.025541.,-+)(/8BJJEHMOQXbgg]T[dcWJ66:;:DLMHB;97<82--)+,./-*+'*-./8?Xlz„„€}{zyxxvvy{{z{xvswusrrooonkjglgknmhkmoqnkmnnf]PJA^ŸÊÛÝÞßÞÞÝÜÜÜÝÞÝÝÝÝÝÜÜÛÛÚ×ÒËÇÅŵ•{|‡ŒŽŒ‹…nE<8::<=@BQas„‹‘’Œ‚|†’¢ª¬¬¶¼ÅÎÓÕÖר××ØÔÆ´¢¦©ªª¨¢¢£¯´¬”lC=999ANfvre\RI92,0222688730234479:;?A@@=92.4631,'&#$%(&++ + + + + + + + + + + + + + + + + + + + + + 9‚ªª«¬®ª³³¯¬¯®¨¯®®®¯²³²¯¯®®®²³µ²´´³µ¯²³²®´·´±³±®´¶µ²²°°¯¯¬²®µ¸¸µ¹µ´¸¹·¹º·µ¹¼»¹º¹¹¶¹»¼º¸µ»¼¼¶hijkkihhlmhihijjlljhknmlkkklkjklllmnmooonoooooooponnmmnppoppopqrrrnnonoopoopqpqssrqpqpppsssuqsrtqtuvwxwvtvvuvvuttuvyyxsuwxxwwwvwy{{xsqke\XOMLJE@7/' + + + + + + + + + + +"%'),/110/126532//.+)-7@EECEILP[gmkecglfWH86878@IJD=97;=<95.+*+,,*)+0;DG>79?Q`qy|zzxvvvuut{z}|yuqwywutsqnmmlmjedlkhfgiigfiljdWLFBc§ÍÛÜÝÝÞÞÞÝÝÝÞßÞÝÝÝÝÝÜÛÛÛØÑÈÄÈǸ€‡Œ“’Œ‡sV>88789:<BOar|†‹ƒƒƒŽ¢®µµ·º»½ÈÏÑÒÎÊÇÃÁ¹«œ———˜œœœœž¢¨§˜{`TNJFGYu‡…€vhWD4./232..-+****+--,+,.//132/-..,*'''&'))(,+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + B„ª¬¬««¯±²®¬¯««°³³²±¯¯®®°±³µ²±±´³¯²´°®³µ³³³´´µµ·¶³³³´´³²²³´··¶·³±µ·¶»½µ·¼½¸¸¹¹¸¸º¼»¸·¹¼½¼½hhijjjihklkkkjjkkklhmmnnlikkliklllljmoomlnonooonmkkjmmqsrppqpnoprqnmnoooqrqorooossrpqqrqtuuvusrtuuvtvrwywvurutvvvvwxyxvuwxywxxyy{|{zzzxuolh]XKNLHC=5,! + + + + + + + + + + + $)/4765455100.-+)-19;<;;<@DNX\\[]bf_UF86772:BD<96:>A@?;4+)(+'''/<]|t_G8=>KVhtusutspsrw{}~}zwruqrsssqmlejkhafjiedaaaa]ceb[OAGIv²ÒÛÜÜÜÝÞÞÞÞßßàÞÝÝÞÝÝÜÛÛÛØÒÆÅÇÇ»¢‚‚‚ƒŽ““Š}kX@<467657;MZiv}€†‡‘¦±²³µ»»½ÄÊÍÍÁ½¦š…{Š’•Ž‘‚‚‚ƒ…‚‚…ykdb_\_d’“’‰~hNF>=<>?:3/&'%&&)**++'+-,*+--)(((&')(&(((&-+ + + + + + + + + + + + + + + + + + + + + + + + + I¬¬«©¨®¯¯©¬ª°¯¬¯®²²°°¯¬««¯°²³³®¯¯¯±±®¯¯´±µ®µ²³¶¶´µµµ¶¶°´³µ³¶´´³³²¶¶»¼¹¸¹¹¸´¹²¹´º»º¶¸º½½¼¸gghiiiijhiklkklllmnpoompnjmnmjlmmmljknookmonoomonjjmnpsupqrqoponoponopopqrrrrppqrsrqqrstuuuuttsuvuwyvtvyxwvvvuuwvvwwwwwvuwywyz{zzzzz|}}}yxwtkbYTQOLHA:4-" + + + + + + + + + + + +&.56655531/,-+)-03786678:>BGHHQUVRI@5565219=;9;@DEDDA82/-,*(*3FwœžyP;;:>GUiqtutrstux{}~~~{zvrppppmkiihgedfiigc^Y[]]^^XOD?H]‡½ÖÛÛÜÜÝÞÞÞÞÞÞßÞÝÝÞÝÝÜÜÜÛÙÓÌÇÆÅ½§Œƒ„…‡ŒŽ‹‰…}o^H>864437;KWglmkwƒ‹”¤¯·º¼½¾¾ÁÄÉÊÅ·¥„sv~““‡‚qvgimxtrmqrnns†—š›•ŠtUQMLLLLG>3'(((())+,**++*((,,++*))+,('(((',) + + + + + + + + + + + + + + + + + + + + + + + + + + + O“±®ª«¯¯®¯¯¯¯°°°®²²¬°°®°®®¯±³²¯±³±²µ³²³´³´³³²²±µ¶¶¶´´¶¶±µ¶¶¶¶³¶¸·µ´¶¹¹¸¸·¶¶¸¹¹¶·ºº¹·¸¸ºº¸µkiiijfiiihjllkkklmnopooomjmonkllmnlijlppnnnonlmoolopqqrrrqrqnoqmopqoqqpppoopqqposstpqqrsuqtrrsuwwuvxvtuuvwvuvutuvuvvutwvtsxvvxyyxuyx{z{||z{|xrmidXRMJGECA=5* + + + + + + + + +#)-15896//.-).+/11-,-./0257;??>;951334442999?EHHGGE?865530,7M{£¢‡Z?>;;<J]iqrssuusy{||}~ztplkigeegfcfehijibWRS[^\VLA<:MfÀÖÚÚÛÜÝÞÞÞÞÝÞßÞÝÝÝÝÝÝÝÜÛÙÓÌÅÂÄÁˆˆ‡…Š‹‡‡„†„€xnaXPMKIFJO\`\W\ew‚‰ª´¼¼¾½¶¿ÅÅŽ°‰…‚‹–˜™—‹†}sjv€ƒ†ˆŠ†wwx‹•˜˜“‰oSOLLKKKF>3)***(**+(,,++**+,,--++,02.)('*))( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + W‘¯®ª¯®¨¯±°¬¬¬®¯¯®¯¯¯°²²²²°®²¯¯±³³°³³²³µ´³³´³¯´²³²²³µ¶¶°³´¶²·¹¸··´¶¹¹³²³»¹¹¹¸¶¶·º·¶µ¸·¶··¶µ¶¸¶kkkkkjhiijimmljlllkmmonnmlmnolllmnkkjloponnppnnopqqqrrmopqqpmnqrqqqqrrnoppqqqqqqqqstsqlqsqtttuvwwuuvuttsrvvustsuwxxwvwwvuuvvvvwzyxwwyzz|{|{}}{zxrkd^UQQQQQKD;1# + + + + + + + + + + + + + + %+27756631.-+)')))+--./12320/.,-/2359;:9:AHIKLKHB<<>?>:6<Kxœ ŒeKB=;7;O_joqsvtux{‚ƒ‚ƒ‚|tpnkhffgijifhikjh\LDISZWOB95:Ql”ÄØÛÛÜÝÝÝÞÞÝÝÞßÞÝÝÞÝÝÝÝÛÚØÑÈÂÇÉÅ´™‰Œ‰…ˆ‰‡…‡‡ˆˆˆˆ…€yrnkhfgihdWRQZgpuy€‘£±¶¹º¶¼ÀÃŹ¥ŽŽ— £¥¢ ›—“‹‚}€Š•››œš–’’–—“”€cLFECCCB?81,,,,,--,+,-,+,--,02/./14751./153( + + + + + + + + + + + + + + + + + + #^‘®®®¬®°°«¨®±°®®®±³³²³³²²²²±¬°²³´³±²®²²³´¶¸µ°´²²±®±°¶µ´²²´²¶¹¸¶¶´¶¶¶¶¸º»º»ºº¹¸¹º¹¸¹¹¸·¸¹º¹¹»¼ijijkjjjjjkmlkllkjlmloonlkmonkklnlnnlloponnnoopppppprrpnpqrromqtsqrrstsrrrqrrqsrroqsusppqqtuvvvvuutssssttuutuutvxyzwxwwwvuvwxxyzzwwuxtz|}}~~}|{{zwtpkf`SQRPLKE<4+ + + + + + + + + + + &,0599751-%&''')+,,,,--0+,(,*.-37<?;3;EKLNNMJC;@AFFD>>Cm‘”rRE=;68>Q_hlswyzzz…ˆ‡…‚{srokhhhiglmmkjjg`P67:EMKF=64:OmœÉÛÛÛÜÝÝÜÝÞÝÜÞßÞÞÞÞÝÝÝÜÛÙ×ÑÃÄÉÌʺ¡‘Œ‹‡‰ˆ……ˆŠŠ‰‰‡‰ˆ†ƒ|zxxxtmaORTWX]bgn…• ¨²¶»¼½À¹£’ž«®¬ª¨ ¡¡—†Œ”¡ ¡£¤££¤¢š‘‡jS96223;<:20,++++./.*-.-+.//-352/12698436=A;) + + + + + + + + + + + + + + + + + + + + + + + + + + + $b”ª««««ªªª«¯¯¬©©¬®°³²³³²±²³±¬°°²±´³³°±®±±µµ´±µ±³²±²´µ´³±±µ³²³µ´³³¸·´´»»¹º»¹¸¹¹¹º¶º·¸¶¹¹º¹º»½½ijiijkllkklmjkklkjmmloonllmmlkkmnooonmnonnnnlppppnopppppqrrtrppttqqrrvvtstrqsusssqnrtvtsturttvutrtsrsttvutrstutwxxxwwwuwwvwxyyzzz{wuxzz}}}}~}{x|}}}|yungc_TRQQLIA9/$ + + + +"*157762,''&&&(()))*-//.,,-./27;=83:DLOPOMJDADFIKKFAAc„‡rYIA<638CS`kry~€€ƒ……‚}yvuvsomljgmprrojaTA0,29>?<8448Ig ÌÛÛÛÜÝÝÝÝÜÝÝÝÞÞÝÞÞÝÝÜÜÚÙ×ÒÊÄÈË˾¦“ŽŒ‰‡„ˆŠŠ‰‰Š‰‡ƒ…ƒ€~~{vlaWTSRXZ\dguŽ–Ÿ§°³µ¯œˆ„£³µ³²²±²²±¨š›ž ž¡£££¥¦¥Ÿ˜…kI7/-,/5;961,+***-..-/232021.564012687546>B:& + + + + + + + + + + + + + + + + + + + + + + + + &g–®¬¬«®¬¬««¬««¬¬¯±°±²²±¯²²±°°²³´µ·µ±±±°°¯¯²µ¶µ³³±²´³²´´µ¶µ³±¶··¸¸·µ¶ºº¹¹¸··¸¸¹»¼»¹¹»¹º¹º¼¾¾¾jkkjkjklllmmlijikkmmonnmllllllmmmnopnklmnnonnoompoonnnprrqsttrrssnoorsssttrnrttttsrssttpuwwutptssvuutqvvusrpuuuwxxwuvuvwyyyxwuxyzzxuyz{{{||z{{zy}}}z}{wttqlc_SOLMIE?8* + + + + + + +"(+/11.*)('&((('*-/11.-..-13753,6@GJNPNKGEHJKMMKHBVouo_QGB=7539AWit~ƒ‡‡„€}|{{zwqtswvtpmhppuurjY@7*--13201./0@_ŸÍÚÛÛÜÝÝÝÜÛÜÝÝÝÝÝÞÞÝÝÜÜÚÙØÔÍžÈËÀª•’‰‰‡…ƒ…†„„†ˆ‰†v}~|}|yvpiaWO\eghffrnu|ƒ‰‘“…s~‡ ±´³³³±¯´¶²¨žž™šž–”“˜ž›Ž}b>2))(19;84.-'+)((++/467652/674023444533681 + + + + + + + + + + + + + + + + + + + + + + + + + + + + .q™«¦¬«®¯®°°®¬®«¬¬®±¯®¯±°°°±±®®µµ³±²±±±²¬¬®³µ·¶´¯°°³²´µ¶µ·²µ²³µ¶²¸³¸ºº¹¹¸¶²¶¶·º¼½½·»½»µ¹·¾¾¾¸klmllkilmnnnliiikmlmnnnnnmnokmnmmmlnonnnmmnnnnlmpqqoppoqppsttttutrrsqqlpstrpprtustssrsssuwwutuvstvvutvwxttttwyywyzxwxywyzzyxwwxxwxyyyxy{z{zzz{{||{z||y}}zvphb[PRQRLE;3-& + + + + + + +!(--,--+*))((*,-.//--..02531.19>CHMMJJJLMMMLMKFFWXQBBBA<6522:Oeu€…ˆ†ƒ|vuwyzwtsswzxtpptwxxrhS:2..------//18W›ÌÚÛÜÝÝÝÝÜÜÝÞÝÜÞßÞÞÝÝÜÜÛÙØÕÐÈÄÇÊı™—“Šˆ††„‚ƒƒ‚ƒ†…ƒ~|||{}}|z||ysiZQ`iu}|xvphkfomiekoqy‡˜©¯³´²®±¶¸·±ª ––˜™š–“’—™˜’‹uT6))(,6:8521/+)())+/369753079403531231102* + + + + + + + + + + + + + + + + + + + + + + + + + 6v›«¬¬¬®¯°²³´³±¯¯±±°¯±°®¯±³´³±¯°¯±´´³¯±²³³²²±³µµ´µ¶´³²°²²µµ¶¸¹º¸¶´³´··³º½·¹º¹··¶´¶»½½½¼»½»ºº½¾¾½½jlnnllmmlmonljkilmmmmmmjnoppnlmmmmmlnookjklmnkmmpqrqqoqrppsssprrsstutpoorrttsstsrrutsstruuvrtvwtuutsuvxxvvvuvyyvyyxx{zzzzwxtyyytwxyxyz{wyxyvz{{||yyw~~|{~~~~|xtnh^\OSOJFC?7.% + + + + + + %)-/10.+)*))*+,-*,-/0321,0467@EGIJJMOONNNNJIFDBCCB@<77468G\o}‚€~|zsttz{yuurwxwtrsx|{wpdN81)..-+-,-+/19S™ËÙÛÞÝÝÝÜÜÜÝÞÝÜÞàßÞÞÝÝÜÛÚ×ÕÐÉÂÈËÆ¶¦›•ŒŠ†‡ƒ‚ƒ‚‚}z{z{w|y{|}zwn^R_gwƒ†‡ƒ~wsqqomjhuyƒ‰Œ¢¬°¯ª¨¯´¶¶³¦˜”Š‘‘‘•‘~_:)(%.4453231-"())(./320///8;51352.10/+11' + + + + + + + + + + + + + + + + + + + + + + + + @{«¬¬«¬°°±²´´²¬°°°®¬±®°®³³³¯®®±°³´³°´´¯µ±°°µ·¶³³³µ³µ±²²¶¶¶¶·¶·¶´±µ¶µ´¼½º¸¸¸¹ºº³·¹½¾¾ºº·»¶»·¼»½½hkmmllmmlnnmllmmmmkllmljmopomlmmlnnnoomjknponmnopqrrplorpprssrporstutqpqrrtutssrruvursuwvvvtvvwtvutsuvuvvwwttxxxwwy{{yxxwvxzzzyxwyyyz||zyxxyyzz{y{{~~|{}}}~{wske`\OORMJE;1* + + + + + + %*/242.,++++,---,..010-.235:>ADGILOPPPPOMHBABCCA>99:<<<=Pbt{~|{{|zz{{zywwwwssptx||zp_F71.----,,+,-19S˜ËÚÛÜÝÞÝÜÛÛÝßÞÞßàßÝÝÝÝÝÛÙØÔÎÈÂÇÊÆ¹ªž—ŽŒ‰…‚‚‚‚‚€||}|{zz{||zyscZ\dq}…ŠŒ‰|}}|yzˆŠŠŠŠ“ ¦ª§§«¯±³²°© ’†‚†ˆ‘}_>+((-3643211-(())-/110../19<82131.0/-,12% + + + + + + + + + + + + + + + + + + + K€¡¯¯®¬®®¯±²°°¯°¯®²²°±³²²±±±±±³³´³²²µ¶¶µ´´²³¶µ´¶¶¶¶¶·¶µµµµµµµ¶¶´µ¶¶··¹»º¹µ¶¸º»º¸¸º»¼»»»¹ºº»»º¼¼ijiikmmmmonjmmmmmllkmmmkmllllnnlnonnnlmlmppnnnnnorsqonoqoorsssqprstutrpsrorrqrsqstuvutvwwvwsuuttwwusuvvvvvvuwxyyzzzzywwvwxzz{yzwy{{z{{}|zxyxz{{{|||~~{|~~{~€€€}wwvsnha\PROJFC@:3* + + + + + + + +'-000..*-,/.,+,+.0/*/12159;=DGIMPRRPNMKEEDB@?<:7>ABCFFRbr{{{|~|x{z{zxyxwwtttvw{}r^D120-*+,,*-,-.7Q’ÈØÛÛÜÞÝÜÛÚÜßßßßßÞÜÝÝÞÞÜÙ×ÓÌÇÂÆÈĺ«Ÿ˜‘‘‡„‚‚ƒ€€~wz}|vwuz{zyyufZWYboz„‹Œ‰ƒ€}ƒƒ‚„‹Ž‹‹‰‰“˜™›ž¢¥¨¨¦ ˜Šxxnnoqu{}zxkQA/+)-2744-.-+()',/0210//04;>:33/.-/.+(10! + + + + + + + + + + + + + + + + + + + + + + + + + N…£°°©ªª¬¬ª¯®®¯®®¯®¯²²¬²±³ª°²²±±²³²²²¯¶·´²¶±´¶¶³¶¶µ±µ³µ²²´µ®¶·¶·¸¸¶µ¸¶¶¸»¹¶°·¹»µ¹¹¸¹¼»»¹º³¼¶½¹¹ºjkiijlmmmoolmmlklooommmlnmmkioppooknnmnnopqpoppplrrqpprrqqrrqroqrsttqsqtsqrsttuusstuuuvvuwwvuutuxwvtvvwwwvswxxxwyzywsvwxyy{zz{zwz|{z{}}|{{{zz||{|{y}}||}}}~~€}~~{xsmf]XQTTQPLD8-# + + + + + + + + + + + + %),/01011/,*))+...0221135=@BEHLPPPQPMJGEA@===>@BEFECAVhuvz|~{xwxxyyzzxz{yxyy{}r_D110-++++--,--5F¯ÉÕÚÜÞÜÛÛÚÜÝÝÞÞÞÞÝÝÝÝÝÛÚØÒÊÃÀ¿¾¼´¨™’“’Œˆ…ƒƒ}~|vx{yvuvvwwvsm`SLHJ\n}†ŠŠ†‚‚ƒƒ„‡Ž’‘Ž‹‹Š†~†ˆ‹‘““Šƒ{utqkea`_\YZZTI:,**.7;84.+())+,--/10../2;>:320/.,+*+0. + + + + + + + + + + + + + + + + + + + QФ®¯°°°°°®¯¯°°°±°¯±±±±²²³³³°²°¯¯°¯±±°³µ³°µ·¶··¶µ´³³³´³³´µµ¶µ¶³¸¹¹·µ··º½¼¹¶·¸º¹º»¼¼¾¾¼»º»¾¼½¼½¼»kkjjjkkjknolllklnnmlmnnmmmllmoppommnomnnnppoqqrppqpnoqqrssrrqrrrstsrrsuurorttrvwtousssvwwwwuvvuvvvvvvuwwwvswwvxvvxywvwwsvwwwyyywzzyy{}|y{}|||{}}|xz}~~~}|}~~}~~~€€€~zwqic][PSSROIB7' + + + + + + +#(-033/+(((*,--0110003;@?DAEHNOSSQNLIFA??@ABBB@DDHM^jsv{{ztsmvwzy{z|}}}|yz{rdQ620.,,,++,,,*29^¢½ÏÙÛÛÙÚÛÛÛÛÜÜÜÝÞÝÜÜÜÛÛØÏµ¬¬¬«ª¢š˜’’’‹ˆ‚y{|{uxxvsslppni`UL@<7<B[n|…‡†…†…€…†ŒŽŒ‰‹ˆ{{fqsqpnmf^jkutnc`^^^[Y^_YL=+--;B@;3*(()'((*+-.--..7;8101/(+'))0, + + + + + + + + + + + + + + + + + Zަ«¯±²²³®°±±±±®¬¬²²±³³±±®°±´²°¬±°¯¯±³³ª³µ³°¶¶·²··µ«±³µ±¶±¶µµ³²³··¶¯¶´µµ¼¾¼µ´´¹³º¸½º¹¸¾¼»µ»º»º½¾¾»ijklllllknnklmkkllijknnkmkjllmkoonmnonnonqpoqrqqqpnnopprsrrrrstsstrqqtuuqoorstwwutuvssuwwvuwwwuvvtvvwxxxvttwvxyyxyxxxxwusvwxyz{zyyxxz{{zz|||{~}{|~~~~}}}|{~~}~~~‚‚€~{vqi_XVXZXULD9.! + + + + + + + + + + + "(-020-,++......0//29>CEDCGLOQRQNMLHECEEBA@AACDFJVdmuxzxtrsuxyzzzy{}}zywrl^L<6111/+,-../07=Wm•°ÆÐÕרÚÛÜÜÜÜÜÝÞÝÜÜÜÛÚÔů £¤¤žš—‘‘Œ‹‰|{xyzzzxvssqomjaUH?565225B[n}ƒ„„‡…„…‡‡‰‰ˆ‡‡‡†‚wj`_adbbbbepwzskfdgjifgigbRB66AIHC8/,*(&&(')+,,--/465321/.+&).1, + + + + + + + + + + + + + + + + + + + ^“§®¯°°±°¯±³±±±¯¬²²²´´³±¯°²³²°²³±®±²´´³²³³´·º·µ¶·³¯°´¶¹··µµµ¶µ¶¶¶¶¶µ³µ·¹»º¸¶·¹»¹¹»¼º»½¿»¹»¾¾¾»¼½¼ihjmlmnnonnkmnljmmklnnnkmkkkmnmnponmopppqrqopqpqqqopqqpqroqrstuutsrpsttusqppruwruuuvutuuwwxxwvvuursvxxwwvuuwxyyzxxxwwxxxwvvuxz|}yvyyzz{w{{zz}~||}~~~}}}}{|z|}}|~~}|‚}{wqkfZ\TURNG?90# + + + + + + + + + +"'*-/121/.,(+,-/24;AEGHIIHLOOMMLKIGGFDB@BCCBB?R_knttwutsvwxxwsvuz~|wxqqojcWFA;:9878:<>ACGKZbƒ¸ÀÈÐØÛÜÜÜÜÜÝÝÝÜÛÛÔÆª†‚‡–š›—”ŽŽŒ‰Š‡‚zzxxvwyxsrqqpkaS>;33330.,7B[o{€~}~€‚‚|{{€€€€}viVY^fnrtuy}zsoknnnnnonneWM@MSPI@40*)&*++(+(*(,,253-110.+%)/2) + + + + + + + + + + + + + + + + + + d𬰰¯±®®«±®°±°®¯°¯²²±²²³²±°±±±²±±´²²³°·¹¸¶·´²°±²···¶µ²¶µ·µ³´··¶´¶···º²²³µ¶¹¹¹¸»¶¿»ºº½¼½¼½½½¼kjijlmmoppnnnonnmmloonmnnkmnmpnnnoonopqqqqnpqpnqqrprsqqqppqttuuuqsrprsttttsrrtuuuuutuvutuvvvtvwwwttwvuuvuuuwxyyyxyyxvxyzywxxyy||zxyz{{{{|}}}~~|{v|~~}}}}}}~~}~}|~€€€}|€}€‚„ƒztohcYYZVQMG>3( + + + + + + + + + + #(-010.-*()+/014<BGIJHFHJKKKLKHEDBCACFFD?;>Qainrvvuuwwwwxvrtvy{yxvtqqsrme\SQPOPQUXY\]\ZXX]t~‰“£´ÅÍÒÖÙÚÜÝÜÛ×ÓΧƒg`r|ˆ•—•‘‹‹Œ‹Š‰†‚~|zywuwvurqqofWB842110/-,/8EaqxsoquvwuqmnqvvvvwzymYPUcqy|{|}|xvrnhnqrrqoib^^]YQI?72/011//.,***,041,/0/.+&)05( + + + + + + + + + + + + j ¯³±°²³²±°¯°°²²±¯¯¯®®°²²´´³³³±°´³²²²³²®±³²³·¸···µ³²³µ¸¸³µ¶¸¶´µµ´³¶¶µµ¶·¹¼¹³³´¶¶¸º¸»»¼¾¼»½¼¼º¼¾¾¿Ámlklmlklmnnmnonmnnoponnnmknppoolnpqpnmqpppnnpqrrqqrtvsrqrrrstqutttrqrssttuussruuutspuuuuvuuutsvxwwwxwuuvxxvsxxyyxzzxy{{yyvy{{yz{{xz||}{z}}}}~~}{||~||}}}}}}}}}}}€|~~~ƒƒ€€~}zvphdSUPPMIC;0' + + + + + + + +%'+-,+))+++.0:AGHFBAACDGJJC?7<??BEFA:8<N]ejqvvswzzvxxxtttyywvusqmruvunheefhkmonpqmjfdecfkmnˆ–§²¼ÅÍÓÔÑËÁ³¦’scKZgrz„ŒŒˆˆ‰‰ˆ‰…‚~zywtstqqnmmcP@20-/,+,,-/4I[bgb]_aeifb_]_bdffgjjdXKATclopqwyxxwvsolkmprrpnmkgc\TPHC@@><:974.-+*'.11-//.*)',23& + + + + + + + + + + + + + $m¢¯®¬«°±²°±©±°²²²¬¬¬°®²´µ°¯¯±±µ´²²´°°°´´³²·µµ¶¶¯°°´´¸¸µ³¸º¹´³³³³´µ¶¹¹¶¸º¹±µ·¸µ»»¼½¼»¼»¾½¼½¾¾¾¿ÀÀmmllmlllimkkmmlkkoqqponmlmprmmnoppoqnopoopnnooqqqqruvvutssqqsutssupqprsttuuvuutttsrsttsuvuuvuuwwvvwwvuuvwyyyyywyyyyxz}~|yvy{||{{{{||||{{|}|}{|{|}}{}{|||y}~~{|€~€}~‚ƒƒ€€ƒ„†…ƒ~yrjd]RVVTNG>5+! + + + + + + + + + + + + + + +!%())*)***-5=CEC?>?ACDGGB<98;=>AA;3/7GT^gnstvy||xwvwyyyxxwvurpnntwyxuttvz||zz{{xtomllmmjjmtz„Ÿ¬µ¶±¦—‚se[QNS_hox……‚‚ƒ…‡‡„‚‚}yvusrqqpommcQ?6/,-+(()+.<M[_]UVWYY[[YWVPTVUWWTUWQ@;@NW]`dhkmnnomjfddilmlmnmic^XUSRSQOJFB?9520-+-1/.--,+**.40 + + + + + + + + + + + + + + &p£®²°®®¯±°°²²±°°²³²²±®¯²¶µ´²°²´µµµ¶´³³µµ³´´µµ·º¶²³¶µµ···¹¹¹····µ²µ·¸ºº¶¶¹¸µ¶ºº»¼½¼½¼»º¹¼»·½¿¿À¿ÀÀmlllkillmmljmnonnopookopppqrnmnppoopqopppoooonpoonoruwusrrstvvuqstsrppstutwvuuutsrqrttttttuuvvxxvttuvuwvwvzzzzzyyywwy{{{{wxz{{||zz|}|{{y{|||}}|{|}}}z{zy~}~€}}~‚€}€€€‚„†…††‚|}{xsj`ZURPMID=6-$ + + + + + + + + + + + +#%'))++4:?BA<<<AEECB@<::999983,/0;CP[cjklmllnqsuvvuurqqssroqqprxzzz{~~z{yyxwmrmquusolnnroyvz~}ocba^TRINWacmux{ywxz‚~x{xuppqplppolcTJ=3+,,+*)(/?P[]][ZZXYXY[\\WQWVWRPOPN?/58?EJOSVXZ]a`XRLSW\`__^^[YXTRQUUWVSPJC@7531/-,+*)))*+*04- + + + + + + + + + + + + + + )r£«±¯¯¯¯©°³³¯¬²¯±´³«ªª²·µ³±±±µµµ³´¯´´³²´´³¯¸º¶±³¶¶¶·¸¹¹º³µ¯·µ¶±µ¸º¶¶µ¶¸¸´·º»¹½¹»¹¼·º´½¸¹»¾¿À½½¿mlkljjkkkmlimppppolonmprrrqponmnpqpqrqqspnoopqqplnortttsrssuvuusssssorrsuvwwsstuutqqtutuuuuuvwwwvwwxzyxxwxyyyzz{{yvvwwsxxwx|{{|}{yz}}}|xwzy|||{{|~~}|{xxz{|}~€€~‚ƒ€€~€€„„„…†„ƒ‚ƒ…ƒ|unga]VVURKF=4( + + + + + + + +"%(-169??=;;BFDA?=:9876520-+-.05@KSYYWTOMYhsttsssrrqqutsrqruyz}|~{{{ywwvtstzzvtsssstsqljjgXVZ\[XSMIQ\admpuvvvxyz{{yxwvsononmnpolcYPE7/,**+++1@OWYZ[\ZXWY^cdc^[\]\[YWUN>0./37;>??@INQOKD@AFKNMMMNPPLIHJNSVWWUPGGD?:73,+*)'''()*/5+ + + + + + /v¥°¯®¯±¯®¯°±®¬°®³±«®±µ´³³µ³²³´³²²°µ´´²µµ±²¶·³±´··µ¶·¹¹¸¸µ¯µ¶µ²³·¹º¸···¸·¶¹»¼º¹¹¼»¹»¿¾¼ºº»¾½¼½¿mmmmkmmlllljlnpponnonmoqrlqqpmmlprrrrstspmooqrrpoorsqqutsqsuvvuttsstssrrvvvvtstxxvtsuqtuuvwuuuwwwxwtyxxxxwxtyxyzzyxwwvutvvz}~||{zyz|~~}xx{}}}y||}|}y{yxy||}}~€y€€‚€|€€~€‚ƒƒ…„ƒƒƒ„ƒ}xtpjc^STRPOI@7-# + + + + + + + + + + + + #*/5;?>==CDDA>8513320-++*,,-*34:>;952<B[monooqprrsuursntw|{}|~~}~}{yzzzyyyzywvvutrutrolg]UY[[[WQLM[_ejmosuvsvvuusttppnmkklnpnjc\VNB3/)++++4>LRRRVXYYWY^`deb``^``^XQG7),)*+-01179<=<:7/02=BIHGGLCF<;;GLTTUURHMNI=;5.*)(('(%*)26) + + + + + + + + + + + + + + + + + 7|©°«««««¨««©°¯±³²°®±²²´²³¯°°²¯¯°µµ³²¶¶²°´µ´³µ°·µ´µ¶´³´·±µµ¶®²³³²¸¶····¸¶½ººµ¼¼¼¸½ÀÀº»º¼½¼¼¿Álnnmlnomknmmmmnonnoonnlopqqppnmlnpqqrtsrppqrqpnppqsssuusrqqtuustsrruttrrvwvuttvyxvvuttvvtvwwvuvvwwwwutwyywxxxyxxwwyzyvvvvxz||||||{z|}~}{{}}}~~}|{{|{{}~~|}~|~€‚‚€€€€~~~}€ƒ‚‚‚ƒƒ„ƒƒ‚zunf\YX_\WOG;.! + + + + + + + + + + + + + %+28=>?ADC@;51.-.-+*))*,-,+++)+-,)+2:Pekmnoooprstuttsuzƒƒ~}€~}}{x|~~~€|zxvstuuwwrjaWXZ[\ZTKLYcfilnprsrssssssqonnmkkklnkgda]YM>1+++*+6BKQPOPSVXVX[^accba__`\UH<2++,+)+,.0245532.+),5EKMJKLMJFBBFPTTTVSQQTNE>60,**+++++.46) + + + + + + + + <«¯¯®¯¬§«¯¯««®±´³³³´²°²²¬°²±²³´µ´³²³µ¶´³µ¶³±²³µ¶µ··¸¶´·µµ¶·¸¶¶´³³µ´´µ¸¸··¶¸¼½¼»½½¼¼º½¿¿¿½¹½½¾¿¾Áoonmnoomnoolnoonnoonnmllpqqpnlnoonnoqqtsqqqrrpppqpqrsttrrsrostsrsrsttsttvwvtvvvwvuuutuwwwuuvvtuuvvvvutxyyvyyyuxvuuy{zxxvvwyzzx|{}|{}|{|z|}||}}z{y~}~|~~x~}{|}~€€€~~€€~€~~ƒ„ƒƒƒƒ‚‚~ztlf`aXZUPIB9.# + + + + + + + + (/49=?A=80.+*''')(**,,+))%()*)**/5K^fjllnnonrprttssx}‚€}{||}}}|{z}ƒ‚|{zyvstwxtnaQSW[][VOMXbfhkmnlnpqrqpstrnppollgghhbeda]TF6(*)+,7BILMMOPQRUV[[_]_a`^][WJ<//(*,,)*+./11210,,(),>KPNMLQUUPMLRXXSVVUPPRPGB61(*)./.+-.56' + + + + + + + + + + + + + + A…«®®¯®¨®±±±°¬®³´³®³²±±²³±±²±°±¶¶µ²³¯´´³²´´´®®¯°±³³¶¸¸´¸µ·¸¸¹¸°µ²·¶µ²²µ¸¸¸¸»¹¾µ»½»º»º¼¸½½¿¹¾¿¿¹¼¿oonnnolmoqpooponlooonnoppppomnppppppqqssoprssrpoppprotttuusrstsrqtuuutquvwwvvvvvutvvutuwwvruwxxywusuwxyxxxyyyyxxvxz{zyyxxxyyz|{z{||~}||}}}zy{}{x{€€||}~}{{~€€€‚€~}~~‚~€€‚ƒ„‚ƒ‚ƒ„…„†ˆˆ†ƒxrmha^YYUPJD?=:7-! + + + + + + + + + + #+17::5/+)'&&')***++))''''&'))+6FYbikjmppqqorrqqpsz~~|z{{{}~~~}|z}ƒ„ƒƒ„„ƒyssyzuo_MKSZ^[VPNT]cfhkkjloponoprtuutqnkgbefgedb`ZM;*,,,,8CFGHKNQRTWYZ[[ZX[\\[YPA1,+*(*++*,-.021/..+'/8FPSQNPUX\\YX[^][YWTPQSPMG?6/,-.0/..066% + + + + + + + + + QЬ®°¯¯°±°¯¯¯°²³µ²²²³¯°±±³²²±²¶¶´²³´µ´³µµ´´³³³²±³´µ¶¶·¹¸¸¸¹·¶µ¶¶¸¸¹¸·¶·¸¸»¼¼½¼ºº»¶¹»»»º»¼¾½¿À¿½¼½nmnnnloopooppmnlkmnooonponpomoqpppppsqqrqoqrsrqqrssrsrssuvstuttssuvtuuttuvvuvwwvuvwwvvvswvvvwyyyxvuvyzywxxyzyxzyyy{|{yyz{zxw{||yz}}~w{{}~}xz{{y{€€{|y~}}{}~€€€~€}|||}‚‚ƒ‚‚‚‚‚ƒ……„„†‡‡†††‚~{uidYWVWUUVURG9( + + + + + + + + +#*.-+)&''((*'*(+*)''''&&'((2<JX`giiijpoqnonmjlmx}|z{{{|}|{}}}{y„ƒ…ˆ‰‰„~zu}{taEJOW^[UPCNW]_eehikklhhiiiruwtpjhfffggedcaZN<,,,--8ADAEHLPTXZ[ZXWUUTUVWSK:0())((**,'-./11./,,(6BNUVVURWY][XW^a`^\XUQSQQPLE=110.,.-.-64" + + + + + + + + + + + + + + + + \¬¬«®±³®°ª®¬¬±²³¯´±´´³±¯°±±²®³¶¶²¯¬´´´³¶¶´¯°²´³³¶¶µ¶³¶¶¸´µµ¹¯¯°¹··µ¹····¸ºº»¼º¹º·¸¼¾¹»¹¹»¾¸Á¾¾¿¾ºoponmloppoopomlkjkorponolnpplppplpoprqqprqpqssqrstsqrqqqsvtttttupvwvuuvvtvrtuwtwtvxxvwwwwwuwwxwwyywvyzxxxxyzxz||zyy{zyvz{|vy{{{yz}~~}|||}~~z{||}€€|}|}~~€€~~~{|}~}}}€‚‚ƒ‚ƒƒƒ€‚ƒ€‚‚ƒƒ„……‚ƒ…††…††…„‡‡ƒ~vlda^^`abaXL:& + + + + + + + + ##%'*+++**+++)&&('&&((/8DMV]bdfhlorpnmkiijlv{€ƒ‚{~}zvx|~|z…‚‚ƒ‰‹‹‡~…yfPIKRYXTMCHPW\affghhgedeilnrtsooljlnmjedc`YM<-,,-/8?BCEHKLRWZZYWUTSRQTUTJ;/*)'&'()+,,.//00.*,/<LVZZZZZYY\[YX]aba^[WWWWUTOFA;861-,,,.51 + + + + + + + + + + %c”¬°±²°°±®®¯°²²³µµ´µ´±±±±±²³³´µ´¯«³¶´³µ¶³±³¶´²µ¸¶´¶¸µµ¶´µµ¹º·¸¸¸¶´¸··¶·ººº»½»¹¹º»¾Àºº¹º¼¿ÁÀÀ¿¿¿¿oponmknopppopnlkklprrmonkkpqqqppqpppooonpqqrrsrqqpplqrqrsutuuuuuuuvwvvwwxxvtuvwxxwwxyyyxxwxvwwwvyxwuwxyyxsxzz{||zxyzzxyy{||||}|wy||{~~}y{}~}z}~}~€€|€~}~~€z~~€€~}‚{ƒ‚€‚„…„‚‚ƒ„ƒ„ƒ‚ƒ„…†††„ƒ‚†ˆˆˆ„zupji\a_ZSI>4' + + + + + + + + + + + + + %)++*,*+*(%%&&'**18AIOS[\]_hlompnmhifgjsw€†‡‚€}xvu|}~}………‡‹‹‹‡€€ƒ†…~lSGDIMPPJCDJSZ]`dfjhgccbiijkprssokqonkgaeaYM<-+,.09>ABEGHILPTXWQROSQPQVWNB5,+&%%%%),,)//.,,*06FSYZ]_^\ZYZ[ZZ^`cdaYXW[[YTPIE==<6..+-/4/ + + + + + + + + + #b”«¬ª«¯®°¯²®°±±°±±µ´´³±¯²²±±´´³²´³°«´¶´°µµ´±´±µ³·¸¶µ¶µ¶²·µ·´»»»··¸·´º¸¸´¸µ¼¼¼¹¼¸»½½¾¾ººº»¼ÀÀÀ¿À»À¾npnmmkmmmppnooknnnnpqrpnkmopoqppqoonppppqrrsrrqrrsrqqqqrtuvvvuvwvuvwxwuwyyvutvxxvvuwxzyyxxxwxyyzzwwvwxyyxwxzz{zzyx{{yzzy{}}|}}|zx||}}}}{z|~|z€}}~}}€~|~€‚€‚}~€‚€ƒ‚€„ƒƒ„………„ƒƒ‚„ƒƒƒ„„††…„‚ƒ……ˆŠ‰‡†ƒ|vojeZWSPJC<4* + + + + + + + + $'+,,**'&$%%)-06>FLPRYZ\^eilooomjifflqt{„†€}{w{|||}„…†‰ŽŠˆ……ƒƒ……‚pRA@EIKJF@>EOW[_ejjjifcchkkmoqstqqpmlkihebZN;/+-/08>@BDFFFGJNRTSRSSQPPSUOD91.+****)*,--.,*+-4EPWYX^b`\[YZ]_aaaadd`^\\\ZWTOJGEA:30/044, + + + + + + + + + + + !b“©¯±°¯¯¯¯¯®±±²±±±µ´´³²²²³²³´´°±²±¯¯´µ²³µµ´³´´¶·¸¸¶µµ¶··¸¸¸ºº»¹¸µ¹»¼º¹·¸¹º»½º¹»¼½¿¾½»¼»»»½¾À¿ÀÀÁÁÀmlnkkmnmoppoooonnnonqqppqponoppooooopppqrqsutrqrrrssrrrsttvvtsuvwwvvxwvwxwvtttvvvuutxyyzxtxxyxy{{xwxxxxvxxyyzuwwwx}|z{|{||{y}||{{|}}|}~{|~~}}~}}|||}|||~€}‚€‚€|~~€‚‚‚‚‚ƒ„ƒ€€‚€„……„…‚€ƒ„ƒƒƒ‚††…„…†……‡‰ˆ‚†ˆˆ…‚|xpg_VTSPME;1! + + + + + + + + +"%()+++)')+./7>FLOQUY[\bgghnnnlkjjmrrz€€~}w~€€}zxzv~‚„…‰ŽŠŠŠ‹‰‡……„oOC@EHGBB;;:FPX`eijjjhgfjkjjlmpponmkjhihfaZP@1/...7;A@ABFFFCHJOPSTTPOMKKLD?:64552-*),****'-2ERWVWV^`_[[WZ\`cddbcga`_\VZYVRPMJC:32/332) + + + + + + + + + + + $e•©°±°«¯®¬°²²°¯´´´³²°²´³®²³°°±¯®®´µ³³³²³²³¶¶·¸³´±µ¸¸µ·¶¸¹¹·¹ºº»¼¹º°¶¹º¶¸¹ºµ¼¹»¸¿¾½½½»¼¹¾¼¼¾¾½ÁÂnnnlmoopooppopppnpqrqpmprrqpopqrqpppoooqpptvtsprqqrrrprtuuvuqrttvurssvwwvuwxvuuwwvvvwxxxwwwwttu{zwwyyxxyzyzzxwwxy{}|yz{|zz{}}{{{{||||~~}~||}~~}}|~}|{y{}}€ƒ€~ƒƒ‚ƒ„„‚‚ƒƒ‚‚ƒƒƒ„„ƒ‚ƒƒ‚ƒ…………„ƒ…‡††‡‡‡†…‰‰ˆ‡†‡†zqg`]][UOH@7-! + + + + + + + +!%'+,,.///6=DJMNSWY[_dfgmonppppprrx{|{{{~ƒ„|yz{{}€„‡‰‹‹‹ŒŒŠˆ„€jJBCEFDBA><:;FR]bfijilnnlliijmlkkjghhghie_YRD92.,08@DFDBDEDCFINPSVTQPMJIJIFDB@@>8.+)+*()**0@Q]][XW]`^[YZ[[Zaddegghfc]UWXVUSPKC9422450$ + + + + + + + )j—«°±¯®¯¯¯°¯¯²²±¯²´´¶´±±´²±²°±±°°±³¶¶´´³²²²¶¹»¹¶´µ·¸¶´·¸¸º¸¸»½¼»º¸¸¶¶¹¹¸¸¸¹º»½»»½¾½»¼½¾¾½¾¾½»¾ÀÂoonmoponmkopoprssrsrqpmoqorqppqqppppqrsrpnstsrssrnqppqqrtuuussutttssrwxwvtvwvvwxxyywvvyvwxxtuvxzzxzzzyyx{|{zxwyyz{||zy||~~}|{z{}}z}}|{}|~||}~|z}|~~}z{|~€}€€‚€~€€ƒ„ƒƒ„…„ƒ‚‚„…€„ƒ„‚‚ƒ†……ƒƒ„……††‡††‡‡‡†‡‡†‡ˆ‰†€|wpk[XVUSOH@9/ + + + + + + + + + + + $*-//056?FKOSRZW^_demqsutsuqrrxzxvyy~„„zyy{zv}|‚†‰Š‰‰‹Œ„y`B@BDCC?BA?=<:GRZ`eijlpqonmlllljhggff_cec[XULB8..18>ACB?@ACDHKQRPOOPRLKJKGJIIHEA8/-*,,**++;LW^_]ZY^][WXZ\[[]ccdfghhf^TUTYWVQOC:242680 + + + + + + + + + /p›«¯°±®±±±³²ª°±°°°°²²²´´±²°²°°´µ³¬®¨°³¸·µµ´µµ´º»º¸·¶¹·µ³·´¹°·³¼¼º···¹¶¸ººº¹¹º¹¼´»¹ºººµ¼º¾»½¾¿½¿¿¿ºlomoppnljknqpqrsssrqoomnpqqrqqonoqpqrsstrqrsqrrttussturpptuuuuvtrsrrsyxwuvvuvwxwyyywvwyxuwwvvxxzz{{z{{zz{|yyxyzyy||||}}}€|{zxx~}}|}zz{|~}{~€}z|}~~~~~€~~€‚ƒƒƒ€}}€‚„„‚‚„………„ƒ‚€…†……„„„ƒƒ…ˆ‡„†‡†††………†‡††‡ˆ……‡‰‰Š‰ˆ…zsmic`\[TNE<2) + + + + + + + + + + + %),1249AHNSWZ]]addmsvx{zwutuxzuvvw{‚‚yxyyxz{}€„†‡ˆ‰‹ŒƒqQ@?ABBBCCAA>=<?GOW^diloqponmljmnliffc_`a`[YVRLB701468:;;;>CFILQQLIKOTTPONLKLKJGA6/-+--,+-1DSXZ\\\]\ZXVWZ\]]_beffefge_ZZ\^_\[UH<9768:0 + + + + + + + 4vŸ¬®¯±³²±²´³²²´³±±³²±±±²³´´²²²³µ¶´²¯°´¹¹¶¶··¸·¶·º»¸·¹º¶³µ¶¶¸¸¹¹»¹¹ºº¹¶¹º»½¼»»º¼¾¼»»»»»¼½½¾¾¾¿¾¾¾½¾nnmnoonlllnoonpqroqqnmnopqrprsqnpqqqrrrssrsrqrstvvvtvvtssruuuuurrsttvvwwwvvuvvwwxxwwxxyxxxwwwwws{zyxyyyyz|{wz{zxy|}z{||||}}|{xz||||{{{{}~}}€€}{|}~€€€€~€~‚„ƒ€}~€„€‚„ƒƒ„„„„„…‡†…„…†…€„ˆ‰††„„‡…ƒ‡ˆ†„‡ˆ‡‡ˆŠˆ„ŠŠŠ…†„€}yun`]QPNIE=5* + + + + + %(,3<BIPW[^adeclpuw{|ywuvy{zuutz||}zuwx{~€~€‚‚†…|hK:=@@?BCCA@=<<=;@FQ[bimqqjkiiiknnjh``aa^`[[WWVOC:12-4388<?CCHMMMH@HOTVRQPMKFFFD=3+++,,,(.7IUTRUXXXYXVSWW\Y\]aeea_^^^]\]^ceghaPF=;989. + + + + + + >~£®¯°®±°±²³¯³¯µµ³°¯¯³³³µ¸¶µ´´²µ²¶³±¬¯¸¹··¸²¸´µ¶¸¹¹µ··¶µ³²³´¹·¸´»½½¹º·º¹¹ººº»»»»½·¼½¼»¾¾½¼¾½½½»¹¾¿nnkmonmmmnnnnnopqqpponnqoqrrqtsrqrrqprqqrrtsqrpqpvvuvvsutstvuttrstusquuvvuwxvusxyxvxxxzyxxwvwxxyzzxwuzzz{{{zz{{{z}|zzz{{z|y|{z{|z{zz}}z~}}}}~~~~|}€€€}}€€€‚ƒ‚€€„ƒ‚‚ƒ‚ƒ‚‚~€€‚„……ƒ„††„……‡‡†„‡‡†††„…†‡††ˆˆ‡††††ˆŠŠˆ‡ŠŒ‹‡Š‹Šˆ‡„}wof\ZZXSMB5% + + + + + '07?IRY]beebinqvyywvwwx}}{zyyy{}{xx|‚ƒƒƒ}|}|‚‚wfG9<>??@AA@?<8::88<EOYbjqpmkjgfiklljfdedc`_\Z[\XRF:468;=>>?AAHKJHD?FLQSRQOLJHGE@80+++,,,*/;IQQNNOPRTVSVWYZ[[\^aa^\[[[\\_`eiosnaOGB<77- + + + + + + + + G…¦±¯±°°°²²²±¯²³¶·´±±´´²²¶¸·µµ³²´µ´²¯¬±·¹¸¸¶¶¶´µ¶·¹º»¹¶·ºº¹·´¸·¹º½¿½ºº»º¸º¹»¼ÀÀ¾¼½½»½»¹¹¾½»¾ÀÁÁ¿½ÀÃnmmmnnmjopnmmoooqqpppppqrssrqrssroqrstsqsttsrsvuuvustsvwuttuussstuwuutttwtxxvvwwyyyyzzzywvutwxyzzwyyyz{wyzzyz{{z|||{{xzz|}}{|{|}}}}{}}~~~~z}}}|y~€€~||~€}‚„ƒ}€ƒƒ~‚„…„ƒ|‚ƒƒƒ‚€ƒƒ„…„}…„…†‡‡ˆˆ†……„‡‡……………†‡ˆˆ…†…†ˆ‰ˆˆ†‰‰Š‡‰‹Œˆˆˆ†…‚|tkfYVTRLD<3' + + $*8DMU\ab`ffnputtsuv{€€}}}z|}~z|~ƒ„†„~~x}€€€yiR;=<>?><<<<<;::789??KS_imnmlhbigghhhfdeab^^ZZ[ZWOD@>@CCBA@@AHHGEA?EIJKLLIHHED?8/.(*)+,,+1=EIIGHHHIQRVWWSYYZXXW][[Z[[[X_bbeqxtj]OL?=:, + + + + + + PŒ©±°±±¬°¯±«±¯´¯µµ´³µµ¯´µ¶³²³´²µ±´®ª¦ª¯··¸²µ²¶´µ²¶µ¼½»´µ²º¶µµ¸·»¼¼½¼µ»¸¸¸º¹º»ÀÀ½·½¾½½¼¶¹º»»¾¾¿ÀÀ½ÁÄonoppnonoqommoppoqpopoooqsrpprsrrppuuttstustsqrwtursssvxtsssuustsvxvvuuwy{ywvwxxxyyyzzyxxxxxwwz{xxzzwyzyxxyzyzzz|||~|{{{|~~{z|~|}~}|}~~~€}{z|€~|}~€€€€ƒ~„……‚‚‚„‡…€ƒ„‚ƒ…„„…ƒ…†……†‡„ƒƒ†ˆˆ‡†……„„…ˆˆ‡‡‡…‡ˆ‡‡‡‡‡ˆ‰Š‹Œ‹Š‰Š‹Œ‹„}woe`[^YSLE<1! + + + "/8AKV\aeilprssuuv……€~~|~€~~~€‚…„‚}}ƒ€€zn\L?>>>=<<<<<=><9:<>?CFN_fkmmkjigcijlkifeba`^\\ZXTPKHGJJIIHGHHHEB@@CIIHHHEDCB?91-,+))*,,,3:>ACEDGIJPQUWURVYXWVVWZ[\\\\\_bbeqxunfaWK@=- + + + + + Z’«±¯±°¯°®¯®¯±³µ´³±®²´´´´´´³´´µµµ´µ¶±©¨¯µ·¶µµ¶·¶´´µ¹¼½¹²³´·¹¹¹¹º½½¸½¼ºººººº¸º¹½¿¼»½½¾¾½¼º¸º»¾¾¾¾¾½ÀÂoooppnoppppooprqqqqqqmonpnpmqsspqpqstrtttsstsprtststtsuwurrsvvtsvxxsuuvwxyywvvxxz{ywwwvwy{zyxwyzxzzwxzzyyxyyyy{{|x|}}y|||~~|||~}{|~{}~~|~€€|}{~€}}~~€‚‚ƒƒ€ƒ„‚€€‚ƒ„‚€ƒ„ƒ„‚„††„…€„€…‡‡†‡‡‡‡ˆ†………ƒ†ˆ‰‡‡‡†‡ˆ‡††ˆ†ˆŠ‹Œ‹‹ŒŠŠ‹Ž‹‰†‚}xrgcXVSOIA9- + + + + !0<HRZchlqrrsux„‰†ƒ€|}}€~xwwy|~€~{|€‚ƒ€}tlbWHA:=>?>????=;=>>@A@HO\fhijillkjklljhec`cc`[[WVURNNONMLKJJJKIDCAFJHCFBB=<<<61++*)&)+,'1579>??@ILPRTRRQSUVVVOPSYZ\[\\^`a_pwsije_RK?* + + + + + + + + + c™«°±±±¯°¬«°°µ³²¯¯³²µ³´±´²µ·µ¶²´¬ª³²·¸¶·¸³²±·¸»¶¶±²²¸¶º¶¸º¼½¼¼¼»º·»º¹·ºº¾¾¾½¾¾½¾½º»¹º»½¾¿º½½ÀÀnpnoonoqppppmqprqqnrsrqpqnoqqsrqqpmqssrsssqtsrqqosstuutwwutuvuttwywtsuuuuuuxwvy{{{xvwxvwy{{zwwwwwyzzz{{yyz{zyxz{{z||}|{z{|y|}}~~~}x~~{|}}~~~~}|~€€}€€~~€€‚‚ƒƒƒ‚€€€ƒƒ‚€„„ƒ„„…†„ƒ……„„„†‡‡†‡…†††ƒ………†ˆˆˆ‡…„‡ˆˆ‡‡‰ˆˆŠŠŒ‹‹‰‡‹ŽŽ‹Š‰ƒ|tmc^[ZVRI@5+ *6DQ[djmoor€‰‹‡…€~~~‚‚{vrqvyzxww{ƒ„„‚~{vj[I@=@@@?@@@??>?>>??BEO`gjiimpnkhijjhddeffc_][YWTVUTSSQONNNKMMJHHJIEDA@><;840-+*('(++,/2348:<>GKNPQPOONPRTUSRTV[[Z[^`b`]ltqmkiaTL?' + + + + + + + + + + hž°³µ´²¯«¬®²µ´´³²²²²²³³´²´³³´·º¶®´¸µ¯§¬±´¶¸´¶·¸··¸º¹µ¶¶¶¸¹»¹´µ¹¼»ºº»¼»»º»¹¸º¼½¾¿À¾¼½¾½¼¾¼½½¿ÁÁÀ¿½¾¿npponkqqpmonpqssrqqrsrrpsqqqroqrrqqrtusqrsrrroqpruusuvvvvutuusttwvwvwwuuvtwyxwyz{uuuwyzyyz{zxvvvvwxxy{{xzzzyxxzu{z|{}{|{|}}|~}~~~}}zzz}}~{}|}~~~€€€€€‚‚ƒƒ}‚‚€€‚ƒ‚‚€„„ƒ„…†…‚‚ƒƒ…„„ƒƒ„„„…ƒ……††‡†…………‡ƒ„‡Š‰ˆ…ŠŠ‰…ŠŒ‹Š‰†ˆ‹ŽŠ‹‰ŒŒ‹ˆ„€{voa]ZXRMG>0( + + ",<GQY`fn‚Ї„‚€~‚ƒ„‚}wnqpqsrmqqx|‚ƒ„„‚~vndUKB@?=:>?@>>??>=>@@IVekiimlnkighedbddffc`_[YXYYXTUPTQPPOKNOMGHHJFFA@=<65/--,'((****-///47:=EIKMNJIHMHROXWTUY][XYZbc^ZellkljbUK=$ + + + + j ®µ´³²¯®¯³²²¯³²²³´´³³´µµ³²±·º¸®µµ·³¨ª±µ¶¶µ¶¶···¶µµµ·¸·³¹¹¹´µ·¹º¹º»¼½¼»º»¶¸¹¸·¾½¾¹ºº¾¾À½½½ÀÂÃÂÀ½¾¼mqppknppnoomprsurpprqpqrsttusqorrrrssvtqrsqqqqpqswwuuvvwvsrttuuvvvvwxxuuvwxyyyxyzzxvsyzzzz{{ywxyxxyxvz{{zzyyz{zzzz||}|||~~{|{}~}}€€~|||~~~~‚€€‚‚ƒ‚„„„€}€€‚„„„„‚}}ƒ††„‡‡…€†……ƒƒ‚„ƒ…„„„†‡ˆˆ††††††„†‰‰‰‰‰Š‡†ˆŠ‰Š‡ŠŠŠŠŒ‡‡ŠŒŒŒŒŽŒ‹‡ysm_]\[SJA8, + + ",<FP_s‚‰ŽŠ†ƒ‚„…‡„}xwupnnnnmmpy}ƒ…„~|wocWME=::=?@@AA><>??@M`kkjmolijjgcaacbccaa`]XZ[[YVUUTRRPOMNOMIHIJKHFB?=83.,,+**++++*+.--/47;AEHJLMLLNRTX\]UU[^[XYYbd][]befikdWJ:" + + + + + #n¡®±³¶µ³±¯¯±²±°²°¯±²´´´µ·µµ´²µ·¶µµ·¹¶«©²¹·µ´¶¶µ´µ´µµ´¸¸¶´¸¹¸·¶·¹º¸¹»»»½»¹¼¼»»º¸º½¿Á¿¿ÀÀÀ½½¼¾ÂÃÁ½½ÀÂnpqqooppooomnnpssnpqpppprststrprsmrstvurqoqsssrruwwutstuurrtuvvwvruvvwvuvvvwxyxvz{yuvxyzyy{zzwzwyyyyyyz{{zzxz{|wzz|||{z{|}}|{y|}}‚€~}}{~€€€€}‚‚ƒƒ~€~€€€‚‚ƒ„„‚~}„††††‡„ƒ‚„†…„†‡†††…‚…††ƒ‡‡††…„†…„†‡ˆˆˆ‰ˆˆˆ‰ˆ‰‹Œ‹‡ˆŠˆ‡‹Œ‹Š‹ŒŽŽ‹‰…|un`^WRNE;1' + + !&:HXgt…ˆ…‚ƒ…†…†}~{spnnmljqvxyƒ‚~~~{uoeQK?>=>?AA?9;=;6=H\hjjjjjejkgabbecb`a^a`^]\ZZWWTSSRQPPPIMIJGKLKFEB@:3+,,+*++,-,),-,*+-38;@EEKMOOSVY]`c_X^]YUYXab\PRVY]ekfXH5 + + + + + (u¦¯®²«´³²®¨³±°³³±®±±¶°µ³´±³±²³´²¹¹·µ®¤³¹¹²¸·´°µ¶¶¶¶µ´´µ´º¸¹µ¸º¹¶··¹·¹½½·ºº»º»··º¿ÀÀ¾¿¿Á¾¾¼½½ÀÁÀ½ÂÂppqqpppqpooonnkqrrpqqppqosuutqpqstssrstrnqrssrooqvvtssrrttrtuvvwvuuuuuvvuvvusyywyzywwvwxxyzz{|zyyzyxyzy|}}{{y{{{z||{z{zz~€€~{|||}~€~|}}}€|~€‚€€~€‚‚€~‚ƒ„ƒ€€‚ƒ…………ƒ…„…ƒ†‰‰†††††††††‡‡……‚………………††ˆ‰‰ˆ‰‹ŒŠ‹ŒŒŠ‰ˆŠŠ‰Š‹‰‰‰Šˆ€vke_\XQI@7,! + + + $4FZgqv|„ˆ‰‹‹…‚€wsqqokkqtsv{€~}}€wk]PD?<>>><858749IYcgjihiijjhceggfca_]`ca_^]ZXXYWVTRSTRPLKJGKNLHGGB:3/.,++*)+-,---+**).36;CHKOQSUX]djkhfc^XY]``_YQMSUX_ffXF/ 2{«±³±¯±´²±¯¯±±°®´¶³°±²µµ´´³³³´µ³µ¸¹¹µ´±¯´¹¸»º¶´±µ·¸¸ºµ¶¸º»»º¸·º»¸¶¶·¹µ¸¼»º¹¹¹¸¹¸·»½¾½½½¿ÁÃÀ½¼º»ÁÂÃÃÂoqqpoooppoqqpmnqqqnnqqqprtuusqqprqttqqsssttsspsttvwvtssqtttuttwxxwuvwwxxuwwvuwxvwyxwvvyz{{{z|z{y{|zwxyx|~}{||{zz{}|{{{z{~}z~{}}x}€€}{}}}}|€€€€~}}‚|€€€€~}~‚ƒƒ‚‚‚}~‚ƒƒ€€ƒƒƒ„„„„„†…ƒƒ„…‡„……†‚…†††‡ˆˆ†ˆ‡‡†…ƒƒ‚ƒ†‡†‰†……ŠŒ‹Š‰ˆŠ‰‰‹Œ‹Š‰‹ŒŒ‹‹ŒŠŽ‘ŽŠ…€}vlgZVSLF?6+! + + + &2?Q`p~‡‹†|ywtsonmqssu|€zyw|€|vmf_XOD?::76466CMZ]bdgjjhgeccgjihe]]]abcba_\WYVVUTNTVUSOGHHILKIGE@82..*++)%+*,-.-,++*-/47?FKNPRTVZgommlic_^bea]YUTSPLT\YTC, + + + + + + + + + + ;€®³´²°³®µ±²³°®®®³³´°²´³³³²³´µ´·³·¸·¸¶´µ¯³´¸»»¶´²²²¶µ¹³¶¹¼»½»¹¸¼·µµ·¶¶µ¸¹º»¼º»µº¼º»¾¹¹¹¾¿ÀÁÁ¼¾¿¿¾ÃÂÅÃoplooonpoopqonoqrqnoprqprttsqsssrsuuqrtttuvutsuutvwwuutsttuvttuwxvtvvwyxtwyyxxxvtxxxvxz{|}|||{{{{{zyzyv{{|z{}}yz|~{{{{{z{~||}}~}zz€~|{x}~}~~‚€||‚€€€~‚„„ƒƒƒ€ƒ„ƒ‚‚ƒ„‚ƒ„„………ˆ†ƒƒ„‡‡………†…ƒ††…‡ˆˆ‡‡ˆˆ‡„„‡†‚†‰ŠŠˆ†‡ˆŠ‹Œ‹‰‰‰‰‹ŒŒ‹‹ŒŒŒ‹ŠŠŠ‰‹ŒŽŒŒ‹ˆ‚zsjf[YTNF?6.! + + #9J_q€‰‰ˆ…|yzxtoooprruz|wuttyz{ywuurng]SK>;;>@ENW[^_`chhgb``aejiifcbabcccb`]\YWUUSSUYYVOKJHJKJIGC>9/++,+*))+,++-,-----/14;AEHJMQUWgqtnonk_^`b]WWXXVMKKSRL>) + + + :ƒ¯´±²³´µ´³µ·´²±±³³´±´µµµµ¶·¸¶´·¸·¶¶¸·¸¸µ©®µ¹¹¹¸·¶²´·¶¯´¹º»ºº»½¼·¹»¹¶µµ¶¸¹¼ººº»¾À¾¼½½½¾¿¿¾¾¾½ÀÀÀÂÄÆÄÁooooqpnnnmmoonopqqrrrsrqqpsrrstsrsuutsttuvwwuttttvvuututstuvvtttvuuvwwyxwwyyzzywxyyzzz{||{||}y|xyy||{{zz{|{v|}|z~~|{yzy{}}|}}~}|z}}}|}~€}}}|~€€~y‚‚€€€‚~~€‚ƒ„„ƒƒ‚€‚ƒƒ„ƒ……„‚ƒ…††……†‡†…†‡†„†…†‡†…‡†…††„„„†‡††‰ˆ†…ˆ‰‰„†‡‡„Š‹‹†ˆ‡ˆ‰‹Š‹‹Œ‹Š‹‡Š‰ŒŠŒŒŒ‹ŽŽŒŽ‰‡ƒ|tf_YVNLH?3( !+<Pcox~€}wtooopjstyx{xtirsqoonqrrsqmgb]WTSVW[^_`^]^`bdcb`_echhfec\b`bbbca]ZVUUVSXZYVRNMJMMKGFB?:3***,)))-,+)-,,*,,-,/19:;<BGKN\ktrnmppgXSPNMNOX]YPQQLC:$ + + + + 7‚®²¯°¯³²´²µ°³³´µµµ³¯³²µ±µ³º¹´³¶¶·µ³²··¹¶¯©²¶µ¸¸°²²·»¹®´´µ¶·´¹¼¼¸º¼¼··³´¶»µ´³¹»¿À¾¼»º»½¿¿½·º¼¼½»¼ÃÅ»opqqrqnnpqqqpoqqqooqssssrrssqssrqrruutrttwxxuurrsuttvwuurtuwvtstuuvuvvwxwwvyw{zyyz{{yz|}|{z|||{y{}}|{{||{}|zz|}}~~}|}|||}}|z~}|||}~~}}~~~~€€€~€€~}‚€~ƒƒ‚‚‚‚ƒ‚ƒƒ…††„„…†††ƒ‚……‡ˆˆ„ƒ†ˆ‡‡†‡‡‡„„††ƒƒ†‡††‡‰‰ˆ‡‡ˆˆ‰‹ŠŠŠ‹Œ‹‰‰‰ˆ‹Œ‹Œ‹Š‹‹Š‰ŒŒŒŒŒŽ’Œ†vod^\]UJ>5-# !.FWeqy{yvrnqstx{{{{yspprjiijkmnpsurpokggjllkigdb]\]bcbabeffgedaaaa__cdc^ZVVUUWXYWURPOPOMKHEA?<61..,+*+---..-,*,,,+169999<CIL_ptrnkopkbSMHGGJU^]YVQGC7 9¬°°°°²²³´³²³´µ·¶µ²®±²³´´µ·¶°±´¶´²²²¶¶·¶°°³³¶¶µ³²¹½º¶µ´¸·¶¶´º¼¸º¼½¼º¹¹¶º»¸¸º¾¿¾¾½»¼¿À¾¾¾¾ÀÃÿÀÁÀ¿Àonqqqnoopsspqopqqmoqrsttssrssstrsnrtuuuvvsvwvtsorstuvvuuutuvvqttuuutuvxxwwyzzzyyyyzzyx{||{yw{x{{||~|{x|{{||{{{||~~z~~~}~~|{|~~{~z}|}}~€{~~€€€~€~€€~{€€ƒ„ƒ€ƒƒ„„ƒ‚ƒ…†††…„†††ƒƒ……††…ƒƒ…‡ˆ‚ˆˆˆˆ‡…†‡…‚ˆ†ˆ‡ˆ‰‰ˆˆˆˆˆˆŠ‹‹‹‹‹ˆ‰ŠŠ‰‹‡‹‹ŒŠ‹ŠŠ‰‹ŽŽ‘Ž‹“‘Ž‹…€}xtidUPJD>7.$ + + + (3DVajnrstwy|}|yyxursrlfgfhgkmrponrqlmoorqnhhdb`acfgedgggfd^a_a[_^ddb]YUVONNVWTNNHOPNKKFGACA;431/+++-)-,,,,*,-,,5<=;84;<ILcsvrpkjjiibXOAEFOUWXWPJC5 + + + + <ˆ®°¯²°´³±±´³³¯µ²´²²±¯¯³´´´¶µ²±±²±°³³¸¹¸²°¯°°²µ¶³µ³»º¹¸¸µº¹¹¹º¼¼·º½¼¼»º»µ¹¶»»¼¾¿¾¾»¼½ÀÁ¿¹À¾ÃÅÄÂÁÁ¾½¾oooooponoqsspoorqpprsssstspqstuvtstuuuuvvvuuvtsttttvwuruuuuvvvutsuuvvwxzvww{zxvxwxzyyz{||{ywyy{||~}{||{yz|}}{z{}~~~{}~~{z|~}}~€€€}€€€€‚‚€€‚~€~€‚‚ƒ„‚„„„ƒ‚€~‚„„ƒ…‡ˆ‡…„††„„††…ƒƒƒ„…‡‡‡‰‰ƒˆ‡…†ˆ‡ˆŠŠˆˆ‰Šˆ†‡‰ŠŠˆˆŠŒ‹‹Šˆ†ˆŠ‰ŠŒŒ‹Š‹‰‹‰ŠŠŒŽ‹Ž‘‘‘‘ЋІ€xpf^TUNF=2' + + )7KWbjpv{}|xvvwvtutokjhggjpqolmoqonnpqqnhheecddhkjihfbeca`_`abdfd`[WUTRQQSUQNMNONNLLLJJIFC?;722111/.,+,,,,--29@@:89<AJVhvwuqjbbfkjf[OIHIKMPPNIB3 + Kް°±³³³³²±³³²³²²±²³´²¯²³µ¶¶µ¶²´´²±´¶¸»¹¸·µ²®³µ¶µ¶¸¸·¶¹»¼»»¸º»¼º·¸¼¼¼½¾º¸¸¹º½½¾»¼½»»¼½Á¿¹¿½ÁÅÃÀÀÂÂÂÀÂpoonnppmoostsrrrpoppqrqptqppsuvutstuuuuswwuswxvtvutvwwvuursswwvvvvvvvwxzyxyzzwxyxx{|||zx||{y{{||}€{|{||{z}}}wxy|{~~~}|{}~{v|}}|€€~}}€‚€€€‚ƒƒƒ€{€€€‚ƒƒ‚‚‚‚ƒƒƒƒ‚„…†‡ˆ‡ˆ„†………†‡‡ƒ„„„‚‡‡‡‡ˆˆ†‡ˆ…†‡ŠŠ‹ˆˆ‡ˆ††…‡‰Š‹‹Š‹‰‹ŠŠ‰‰ˆŠŠŠ‹ŽŒŠ‰‹Š‹ˆ‹‹Ž‰ŽŽŒŒŽ‘‘މ†€xobZRNJC;3,$ + ,9FS_ktxvsttxuyxurpkjelppplffgijjlmkhfgeddddinmmjeeed___abceec_YUSSTTPSOQLOQQNOLLLLKNNMJE>;89::871000/0146=A?987>CNZmxxvqd\T`hlni_YLK>=<DEEB1 + + + + + + + + + Z‘±±¯²²²°°°³²³´³±²´®³¯±²³´µµ·²´´´²¶´µ´¸º¹¶³¬±³´´·µ¸´¹º»¼¼¼»··¶¶µ¶·»½¾¶»·¹·¸¸¼¼»¹¾¹½½¾¿¿¹¿¼¾¿ÂÀÀ¿¾¼ÂÃnnnonopppqrttsrrpnnpqqpstsrrstsssrsttssuwvuuwzwsttsvwwvuutuwwwwxwvvwwvxxyywy{zzzzyz{||yzz{}}||}~~~|zy{}~~~~||~~}{{|~{{|{{|}|{~€€€~}€‚~€€‚ƒ„„€‚€‚ƒƒ„ƒ€‚„…ƒ€‚…†‰‰ˆ‡††…ƒ…†ˆ‡„„…‚†ˆˆ‡‡ˆ‡†ˆ‰‡‡‰‹Œ‹Š‰†ˆ‡…‰‰ˆ‰‹ŒŠ‰ŠŠŠŠ‹‹‹‹Š‰Š‰ŒŽŽŒŽŒŒŠ‹ŽŽŽ‘Ž‘‘‘†|tnf`\UME9- ,;L[glsxyz{|zyutrnmopqpkca`aefffeddffbdgiloonkgfec`^`abccbb^XSSVUTSSTQNQTQPOMMLLMQSVTOJHGFEECA>:8789;=>?A?989>DO^pyxxpbVRZdkprsk`RD<:;=BA. + #`•±±°²²±³³´´³´´³±±²´µ´µ´²´µ¶µ¶±µ¸·¸µµ¶··º¹¹µ±¯¯²´·º¹ºº»»º»½¼»¸·¸¸¸¸»½½»º»»»¹·¼»½¿¿¾¿ÀÀ¿¾º¾¿ÀÁÂÃÀÁÁÁÁÃpoqpoooopoqrspqqploqrrstuutttsqorssrtsuvvtuvwywsttuvwwuuuuwvwwwwxwxxwxwwwvxzzwzzzyxxz{|{zz|}{y~~}}~~}xz}~}}}}}}}}{z{}}}z}}}{|{||€}}}‚ƒ€{€€~}€ƒ‚€‚‚ƒ‚‚ƒ…ƒ€€„ƒƒ‚ƒ€ƒ‚„…‡‡†„†††ˆ‡‡‡………†‡‡†„‰ˆ†ˆ‰ˆˆ‰Š‹ŠŠŠ‡ˆˆˆŠ‰‡†‡Š‰ˆ†‰Š‹‹ŠŠ‰…‰‰ŒŒŒ‘ŽŒŒˆŒŽ‹‹‹ŒŠŒŽŒŠ‘“”“‰„~zth`XOF=6/( "-9KZgpuz|yxvvsrqqqqqlca^bbbb`\acfgeefhkkjhihheca`__]]^][YWUTXVURUUSLQSRMPOMGLNQTUTPNNMMIJJHFC@>??@@?>?>889;<L`r|yvn_UP\didmrrmcQH><8BA, + + + + #d˜²²¯³®°±³³´°°¯³²²³µµ¶³¶²´¶µ³²°´··´µ®¶¶¸²¹¹¸²¯¬¬µ¹º·¸º¼¸»·¾º¹¹»·¼º¼¼¾¼»»»»¼¸¿¼¾¾½¾¿¿¿¿¾º¹·ÁÄÃÂÁÂÁÀ¿¸rrqqppoopqpprrqqqrrrtttutttuutqqqrssstuuvvuvxxwwvvvvvvsuvwvuvxxwwyywwxuwxxx{yzzzxxxxyyzzz{y{{{}~||||}|}~~~}||}|{z}~~~~~}~~|{~€€€‚€‚ƒ€€€|~‚€‚„„‚ƒ‚‚€~‚„†„‚„„‚‚ƒ„†„‚„………„‡‡‡‰†…†……†‡ˆ†„†ˆˆˆ††ˆ‰‰‰…‰‡‡ˆŠŠˆ‰‹‹ˆ†‡ŠŠˆ…‰‹ŒŒ‰ˆˆŠŠ‹ŽŽŒ‘ŽŠ‹ŒŽŽŽ‹ŽŒ‹ŒŠŽŽ‘”–––”‘ˆ‚{si_VQIA91( + 4ET`kqvyz|}{urstrokihcddb\\_bbeddfiheddehhfd_^][ZYXXYWUVVZ[XXVTRNQSRQPPMJKNPQPMHJLMNOOLMKIFDBAA>=:=<6789:Ias|wri[PM\ef`^hoqnfYL@=DB* + + + + + $h›´³²²²°°°³³²°°²³´¶µ´³³´µ¶µµµ´´´¶¶¶µµ´·¶¶·¸¸¸·µ²°²µ··¶¸¼¾¾¿¾º¹º»½¾¾»º¼½º»»»¼¿À¾¾ÀÀÀ¿¾¿À¿ºº¸¿ÅÃÁÀÀ¿¿½»rrqpolonnqrrrrsrrstssttssrstuutqpputttusvvuuxyyywwwvvuuvwwuuwxxwxyywwwuwyyz{{{zywxwuxyxw{|zz}{|}{yz{||}~~~||{z{~€~|~~|{x€‚€‚€€‚ƒ‚~‚€ƒƒ‚ƒ‚ƒ‚ƒ„ƒ„ƒƒ„„‚ƒ„††„ˆ‡…„„„…„†ˆ‡„„ƒ††‰‰‡ˆ‡††‡ƒ†ˆŠ‰ˆ‡……‡‰ŠŠ‰‰ŒŠˆˆ‰‹‰†ŠŠŒŠ‡ˆŠ‹ŒŒ‰Œ‹ŒŒ‹ŒŽŠŠ‹Œ‹ŽŽ‘‘‘’”“””””“’‰xqg]TOHC>5$ + + $1?N\hs|ƒ€zwvwrskrqmigdb^__a`aafifaabceffd_]ZYYUQRSSRUVZZXUUQPNPRSMMNNLLLOQNEEDHGJLKKMMKGF>BCC><<:56569KaqvrhbTKHYcc\WUbknng]O?HB& + + + + + + *m³´¯¯¯²²°±´²±¯°°²´³²µ®´²¸µ¶¶¶¶µ²¶²··¸¹¸³·µ¸´¹¹·³³³µ¶´º¼¼½¼·¹ººº¾¿»³»¼º¹º¹¹»ÁÁ¾¿ÀÁ¿ºÀÀÀ»¼ºÀºÄÂÀ¼¾ÀÀ¾prnqnnonmortqpprqssrqsssststtvvtosvvxywvvuuvxxyyvwxyxuuvwvrxxwxxwyyxvvuxvzz{xxxxxzyvy{wy{||}}|x}|yy{zyz}|}~|||||}€~}~~~}||~‚‚€€‚‚‚‚~ƒ‚‚€ƒ‚‚‚‚„„‚‚ƒƒ„†„‚„†……‡ˆˆ…„††„†‡‡„ƒ†‡‰‰‰‡…ˆ‹Š‰†……‡‰Šˆ†„„‡‰ˆŠ‰‹‹‹‰‰ˆ‹ŠŠ‹Œ‹Šˆ‰ŒŒŠŠ‹ŒŠŒŒ‹ŠŠŽŽ‘‘Ž“‘’“””““”““•••”‘‹‡wnc^[WK?5-! "7FWhuzyxxyyyyywrlmlihhfebaafhd`^]_`cdb_[YYWQPPPQRTWYYWUSQMNOPRQNNPNNLOPMFEFFDEGHKLNLJGDDEEB>=:8776:Lcquoe\NCIW`_[PNTahnnhZLJ?" + + + + 0sŸ³³²°¯³´²²²²³µ´³´·¶···´²¶¶µ¶¶¶µµµ¶¶¶¹º¹º¹¹º»¹¹¸¶³³³³³´·¸¶¹¸µº½»¹½¾»ººº¹¸¼¼¼¿Â½½¾À¿»ÀÀÀ½¾¿ÁÂÂÃÀ¾¾ÀÂÄoqqrrpooooqrqpqrrrqprrrrtuttttuvttvuvvwvvuuvvvwxxxxyywuqvvwxxvxwxyyxwwwxz|{yxxxx|}|x{z{zz|}|}|||{zzzyzz||z~||}~}~~€|}~|~}}|~‚~€}~€}‚‚€}€|‚ƒ~~€ƒƒ‚‚„‚ƒ……„„‚…ƒ…‡‰……†‡„††‡…†ˆ‰ˆˆˆ‡„†ˆ‰‰†……‡ŠŒŠ††„ˆ‰ŠŠˆ‰ŠŠŠ‰ˆ†‹ŒŒŒ‹Œ‹‰ˆŒŽŒŠ‹Š‹ŒŽ‹‰ŽŒŒŽŽ’‘ޑޔ”“’‘“””–”“’‹†€zsg[RNG?7. %<GU_irz€€€|wrlppmklkifcafcdYYUVX]`^YWTVWTSSSTUTTZYXVUPPQPPQQMKOOLKLLKHIIGBE=GCJLJHFBCDEB@:;:;:<>PdqupdYEDMWX^[QBRU^_ddZLJ< + + + + + + + + + + 8|£²´³²³´³®®¯µµµ´¶·¶±¸¶³²²±²³µ±´´µµµµ·´º»ºººº¹µ¹¸´µµ°³¬¶¸·¸º¶¼½½¸½½»ºº¹º¹¿¾¾¾Â¾¾¾¿ÀÁ½À¾½¼¾ÀÀ¿Áº¾»À¾ÂÃqqqssqmopqpqpolrsrrprsrrtvutpoqxvtssrtuuvvuvutvwtxxyywtquuswxyyxyxvwwxvx{}zwvxwy{{|}{{{{z|||||zzz{zzyzz||}}{|~}~{{}~€€€}~~~€|€~~€ƒ‚€‚‚‚ƒ‚€„…†„‚ƒ„ƒ„„ƒ„ƒ†‡††‡‡„…„……‡‡†‡‡ˆˆˆƒƒ†‡‡…††ŠŠ…†‰‰‰Š‰…‡ˆˆˆ‰‰‰‹ŒŒ‹‹‹ŒŠ‹Ž‹ŠŒ‹ŽŽŽŒ‹Ž‘‹ŠŠŽ‘‘ŽŽ‘’‘’““”““‘‘’•––•••”’‰€wne^TOD:0( &;KYiu|}|wrkopnlmmljfghgc^XTSTX[YUTTUUTTUUY[[\\[[ZVPSVVUSPLLNOLHFIJIIJIHFGFEHIIGEA?ACBB@>>??@AUgpsndVBDOX^_]RLPXYXX[TJF7 + + >¥´´³²²³²±±²µ¶·´³¶·µ²´´°°´µ·¸¶µ´´µµµµ·´¸º¹¹¹¹¹¶¶¸´µ¶¸µµ¶·¸º»½¼½½½½¼»º¸¸º½¿ÁÀÀÂÂÀ¿¾¿ÁÃÁ¾¿¾ÁÅÄÃÀ¾¾½ÀÁÀÀrrqpssqqrrpqpoqrssqortrqsuutsstwvorrsuurvwwvutuvvxyxwvtqvtvwxyxyxwwxvwvvz{zwwyyyxxxxyy{{{||||{zz{|{z{}}}}}}{}|~€€~{|~}‚€€}€€€{€€~|}~ƒƒ„„„ƒƒƒƒ„ƒ}‚„…€ƒ…‚ƒ‚ƒ€„„„†‡ƒ‡ˆ†„…„„„‡‡††‡‡‡‡„„†‡ˆ……„‰ŠŠ…‡‰‰Š‹Š…ƒˆ‡ˆ‰‰‰ŠŠŒŒ‹ŠŠŒ‰‹ŽŽ‰‹ŽŽŠŽ‹ŽŽŒ‘‘ޑޑ‘Ž‘‘’’’“’“”””””–“•”“‹†~ul^TLHA;4- !(7HXbjnnlppojmjnnmljhd_ZOQPRTUNQRQNQSTTY[^_^\\YUQTXXYTKNMMJKGHHIJKJJLKGHFIJJHGB@?CCDDB@A=ADYjonldVAGPX\`_RFR\[WSMJGB+ + + + + + + + F…§²³²²²²±¯¯´¶·´²±´·µ¬³³±°µ´µµµ¶·¶·µµµ¹µ·¶¸´·¶¸´¸¹¸¸¹º¸·º·»¼½»ºº½½¼»¹µ¸¹¼¾¿¼¼¼ÁÂÁ¼À¿¿ÃÿÁºÀÃÅÁÿ¿¿¿À¿¿rqoprsrssrqrsrssrsqqsurstuttuvuttttsrwvuvvwwuvrvvwwwsuvvwxwwxwxxvwxytwyzyzyxxxzz{zxxyy{zy{|{{{{zz}{{|}}}}~}{~€}||}~~€~€€€€€€€€‚~€‚„†‚ƒ‚€‚‚ƒ…„ƒƒƒ‚‚„†‡‡ƒƒƒ„…„‰ˆ††‡„ƒ†…„„‡‡…††…†…„†ˆ‡ˆ‰‰‰‰‰ŠŠ‰‰ˆŠ‹Š‡†ˆˆŠŠ‰‰Š‰ŒŠ‹‹ŒŠ‹‹ŽŒŽŽŒŽŽŠŽŽŽŽŒŽ‘ŽŽ‘‘‘’”–”“’“•–“’”—•‘މ„|rh]XSMD:3.' &7HT\ciopnnopqonljfaZVSOPRSROMJKNQTSVZ\]]\YWURQWZZUONNLKMNJGILLKLNNMJJIKKKIGEDEDIKJHD=@EZjmljdVBIPVYa`QKU`\XPJGD>( + + NŒ©²³²±²³°¯±³¶µ³´²´¶¶µ´´´µ´³´µ·¸¹·¹¹·¸ºº¸¸···¸¸·¸»»»¼»¹·¼¿½½½½¼½¼»¼»ºº¼½¾¿¿½»¼¿À¾½¾½½ÁÂÃÁ¿¾¿ÃÅÿÀ¿ÂÀÁÁrrqprttsqqrrrstsrrrsuutuvvupuvurstutvvvsuuutwxwvwwwwxwxxwvwwvuuwxyyxwxz{{zzxytz||zyxxy{yy{{w{z{{}}}||w}€|~}}{{{|}}{}~~~~€}x€€€€€~€€€~{„„‚~}}€}ƒƒƒƒƒ‚‚‡‡‰ˆ„„‚„…‡‰ˆ……ƒƒ‚…ƒ„…‡…‡ˆ‡…††……ˆˆ‡†ˆˆ‡„‰‹‹Š‰‰‰‰‰ˆˆ‰Š‹Š‹‹ŠŒŒ‹ŠŽŽŒŒŒŒŽŽŒŽŠŒŽŒŽŒŽŽŒŽŽŽŒŽ’’‘“••“‘“”“’“•”‘’’“Šƒzmf]UOLIC9- %1=LYcilmqrolonkc`\XQRSTTQMKHNPQSSSXXXXVTTQSX[[VRQPOLNNLHMOMKLLMJLHIDHJIGGIHDJLOMF=?EXfjghfWAJRUWa_RK[daYQFDB<& + + Y•¬±´´´³±®±±³µµ¯´´´µµ²±±µ¶¶±µ¶¹¹¸¸¹¸¶¸º»º·¸·¸»º¶¹´¼¼¼·¶¶¼½¾µ»»»½¼¸ºº»¼½µ½¾¿¼»¶¾¼½¼¾¼¾¾ÂÁÁ¹¿¾Âÿ¿ÀÀÀ¿¾ssqpsutspqosqrpqqrstttsuwwvttvssuuvvwxwvvurtwxwwvxtxxxyzuvxyxwwxx{zwwxzzyyyzzzz||{zzy{{zy{{z{}||~~}|{{}}~}{|}|€~|}}}~~€€}|~~~€€}~€‚‚€€€}€€ƒ€€‚ƒƒ€‚ƒ‚„†‡ˆˆ†ƒ„„„ƒ„‡ˆ‡„„ƒƒ„…‚ƒ‡‡…‡‰‡†‡ˆ†ƒ„‡‡†ˆˆ‡†ŠŒŒ‹‰ˆ†‰†‡‰ŠŒ‹ŒŒŒŒŒ‹Š‹Œ‰ŽŽŒ‹Ž‹ŽŒ‹ŠŠŽŽŽŽŽ“‘’‘‘’‘‘’“““‘Ž“““’“”‘’•—˜˜—•Žˆyqg^]YPC8.% + %6GS[bhmnmpqmifa]YUSTTQNMLNQPOMORTTTSRRRTW[ZXVTTRPNMLLOQOKKKMOMJGFGHHGLNKGHKNMF>>EWdghkhVGLUW\_[TV`gd\TJ@C8 + + + + + c›®°³´´³±¯±±´¸¶´´´´²±°±²´¸··¸¸¹º·¸·¶¶¶¸º¹¸¹·¹»º·º»º¼¼»º¹º½»¶ºº¸¼»¹¹»¼½»¼¼»¼¼º¹»¿½½¿ÁÀÀÁÁ¿¿ÀÀ¿ÁÁ¿À¿ÂÄÃÁrrppsuuvtsstsqoostsqttsrvutssrtsuvvrxxxwwvuvyyxwwwvvvvz{zwyzzyxxz|{yyuyvvwzyz{zy{{z{|{{{||zx{|}||}}z|{}~}~~|{€}€€}~|€~}{~€€ƒ‚€}€€€€‚‚ƒƒ‚„„‚‚„‚…†…„††…„…†„†ˆ†ƒ„‚…†…„…ˆ‡ƒ††…‚ˆ‰‡†‰‰‡‡…††Š‹ŠŠ‡‰Šˆˆ‰ŠŒŒ‡‹‹ŒŠŠ‡‹ŒŒ‹‹ŒŽŽŽ‹‹ŽŒŽŽŽŽŒŽ’“’’‘’‘‘Ž”•”“““’—˜——˜•–”‘Žˆ‚zoj]VNF?8,$ )3?MX`fjnmjhf`\XTTPSONLPOMJMNNOSPTSSNUVZYXVVRTQOKLMSTQJJKONNIGCGDFHOQLEEFHG@6<FZegjjgUFQY^`^MOS`fc^WOJC4 + + + + hŸ¯°¯®¯¯¯³±´²¶¶´²µ°¯¯³¯±²·¶¸¶·¹·¸·µµ²¹º¹¸º²··¹¸¼»¹¸»º¸·º·¶·»·¼¼»µ¶·¼º¼½¾ºº½¼¶º¸¼¹ÀÀÁ¿À¾½½¾ÀÁ¾À¿¾ÀÄÆÅÄqqoqsuvxvstuqqpsuvrqsutttrqssuutuwvvvwvxwvvyzzxvtvvwwwx|{yxyzyz{||{{{vyxxz{yv{zyz{y{{yz{{zyzzz{{xz|~}}|}}}}~||€~~|€‚|~€€~€‚ƒƒ‚€‚‚ƒ„…„ƒƒ„‚„„ƒƒ„„ƒ„……„……„„„††ƒ„†‡†ƒ†ˆˆ†„……†‡‡ˆ‡†‡ŠŠˆ††††‰Œ‰ŠŠŠŠ‹‰ŠŠŒŽŒ‹ŒŒ‹‹‹ŒŒŒŒŽŽŒŒŽŽŽŽ‘‘’Ž‘’‘‘’’‘‘‘‘’”•“‘Ž‘“‘Œ‘“”“‘‘”—™••—˜——•——•އ€yoeZXQI?6-" + ':EOX`ejjhb\YWWXVUTRQPKJKMOQSTVXXWWYZYXXVUTTRRUXYXUQNMOROLHGEDDHNPJC>??<86;N`jgjibSIMW^b\LGO]d`\VPID2 + + + + + + !k¡°²°°²²°²´³³°´¶´°´¶µµµµµ¶¶·´²´¶¶··¶´·»¼¸¹ºº¸·¹º¸¸·¸¸··¸º»¹º¹¶¾Á½¹¹»½½½¾¾¾¾½¼»¼½»¸¿ÂÁÁÀ¾¾½½¾ÁÃÂÀÀÃÅÆÇÇqrrqrrsuurstsqrtvuqssrtuurrstuusuvvvustuwvwyzwvvwxwvwvyzyyyzzt{|{vxzzvxyyy{yy{|y||{zzwz{zxyz{{{xz{|~~}}~~~}||y~€y}}~€z€€€~}€€€€€‚‚‚‚ƒ„„ƒ‚€€€~}ƒƒƒ…†…ƒ‚„„…†‚€‚‚……‚„ƒ„„„………†‡†…‡ˆ………‡‡‰‰‡………‡‡‰ˆ…‚ˆ†ŠŒŒ‰ˆˆŠŒŒ‰‰Š‹ˆŒŒŽŽŒ‹ŒŽŽŒŒ‰‹ŒŽ‹‹‹ŽŽ’’’ŽŽ‘’“’Ž‘’‘”•”’“•”’’“’’“”‘––””–˜––—˜˜™—•’އ€wjeURNG?8-# %2?KW_c`ZZW[[YXWUTSPFKJPOSSWXZYXWXUUVVTTTUWY\\[XSRKOPNFECBADGHHE<:650.-@Vfomjf\J6AFT]XMILY`]WTJID/ + + + + + + + + #o¤±²²³´°®¯¶µ´°±±´±³³·³µ¶·¸·²²¯±²³´····¼¼¹³º¸¹¶¹´··¸·¶·ºº¹¸¹¹º´¿Â¾¸»½¿À¿¹¾º¼¼¾ºÁ¼¹¹¿ÂÀ¼Á¿À¸¾¿ÃÄÄÀÁÃÄÃÃÃnrrrqposqrstsppssrqssqquvuttqvvusttwustwwwwxyxvxz{yvvxyxuxy{zy{|vvvzzwvzzz{zyz|~}}|{{z{}{zzz|}{z{|{}~|y€€}||}~~}}|}}~€€~}~€€€€‚ƒ‚‚………‚}€€€€‚ƒƒ‚„„ƒƒ„……†…‚‚‚‚……„ƒ„„………†‡‡†ˆˆ†‡‡†‡‡†‰‰‰ˆ†‡ˆ††ˆ‡…†ˆŠŠŠ‰‡††ŠŒŒ‹‰Š‹ŒŒŒ‹ŒŽŽ‹‰ŒŽŽŒ‹Œ‘’’‘ޑޑ‘“’’’“”••”’‘’”•“’’“”–“‘‘“•••”•˜——˜š™—™›™˜–•ކ}vlb\WPH>4+! '9EOSVXZ\][YXWWUUSONNQSTTUVXVUVVUVUSTUVVWYZ\ZXUSPNKHD@@ADEEDA;61.,,,DZksojaTA68<FUSKHIT[ZWQKKE- %r¦±²³´³³±²´¶´´´´´±²³´³´µ·º¸±´¶·´´´µ¶·¸»¼º¹¸·¸º¹¹¹¹¹¸¸¹ºº¹·¸¼¼¼¾À¾¼¼¾¾¿¿¿¿¿¾¼¾ÀÁÃÀ¿¿À¾ºÀÃÂÂÂÃÃÄÄÃÂÃÃÃÃÅprqqqqrsrssrrrrsrnopqqsuutuvxwuutstutruwwwxxxxyzzxytxyzzyuyyyyzzwxyz{yxxzy|xyu}~}|||||}~}}}{~~}||z|~}|~€€{~~~€}€z}|~}~~~~}€€„†€€~€€€€€ƒ‚ƒ‚„ƒ„…††„‚‚‚ƒ††‚„‡‡…………‡ˆ…‡‡‡ˆ††‡ˆ‰‰‰‰‡‡ˆ‡‡‡††‡‰ˆˆˆŠ‹‰‡‰ŠŒŒ‹ŒŒŒ‹‹‹ŒŒ‹ŽŽŽŒŠŠ‹ŒŒŠŽŽŽŠŽŒ‘‘ŽŽ’’’’‘‘’“‘‘“”“’””“”’““•”–“““–““•–—™˜˜”™š˜–‘†~wib\TMGA:2( '1;EMTWWTTUUUWVQLKJMOOMMNPTVVTTTPRQRQPOPQVWUTOHIGFA@ADBA??:4,+&+-E^mrma\L?47:HQL>CCHMPQK?KF+ + + + + + (u©²²µµ´³³®´³³±¶µ´°±¬³³³³´´·±µ¶¶µ¶·¶²²²»¹¹º¹···¹¹»¹¹µ¸¹¹¹ºµº¿¾»¾¼¾¼»·¸¸¿ÀÀ¿À½¾¾ÂÀÂÀ¿¼»»¿ÁÁÁÃÂÁÁÂÂÁ¼ÀÂÃÄrqprsstuqsssststsrpoorstssuwyxusqrouvsuvxxxwwxxyzzwvxyy{zxxxy{zzwz{zxzyzzz||zz||{{|}}}}~y€~|}}{|{{}€~~~}€‚€€~}€€€€€~~}}}~}}}~~~~€€‚„„ƒ€‚ƒƒƒ‚‚ƒ‚‚ƒ„„‡‡‡„‚„„„…………ˆˆ†‚…†‡…††……†…‚ƒ†‰Š‰ŠŠ‡‡‡‰‰†‡‡ŠŠ‰‰ˆ‹‹ˆ‰‰ŠŒ‹ŒŒŒŒŒŒŒŽŽŽŽŽŒ‹‹ŒŽŽŽŽŽ‘‘‘‘’‘‘‘‘‘“”“‘‘““”•‘‘’”•––––•”“”••–˜—˜˜˜—˜›››š™–“Žˆ€wme[YSJ?4( '4>EIMPQPSUUQJHGFHJIHGKOQQPPQPNLLJFFHJNQQOLFGGGFDEEB@=:61,*)*-F`mpicXI?98=KQKC@?>>?IE<IE' + + +x«³µµ´¶´´´´²²²¶·³±°±³´³³´µ´°´³´´·¸µ³´µ¹·´¸¹¸·¶¸¹º¸¹·¸¹ºº»»¼¿½»½¿½»º¼¾¿¿ÁÁÀÀÀ»¿ÀÁÁÁ¿½¿¾¾ÀÀÁÁ½ÁÁÂÁÄÅÃsrrstsvwvsssttrrtssqrrssssttxwutsstvxvtuwuwwxzyxyvwwyvxxyzyuz||zz{zzzyxyzz{{|z{z{zz||w~~~}y||}{{{}~}~~€}~~‚€€~{{{}z~~~|~€€€€}‚„„ƒƒƒ„…ƒ€ƒƒ„†‡ƒ„ƒ„†…ƒƒ…‡‰‡…„†††…†‡„ƒƒ„„„„‰ŠŠŠŠ‡‡ˆŠ‰ŠŠ‹‹Š‰ŠˆŠŠ‰‰ŠŠ‰‰‰‡Œ‹‹‹Œ‰ŒŒŒŒŽŽŽŽŒ‰Ž‹ŽŽŽ’’Œ‘ŽŽŽŽ’’‘“–•“’’’“”””””––••—””””””–˜˜——˜•–—œš™–™š™—’‡€wlfYSLD<4( "+7@EJQSRRJHADEE??>CEEEEGHGFEEDCBA@BCEEEEDEHIJIFB>64-,()(*/JcmpgbWF?<>CQVMF@=<9AGE;HA# .|«²´´³·¶¶¶¶´³¬¶´³°±°´´³³µ°°±µ³´´¶³²±µ··µµ¶¹·¸´·¸¹¸¹·¹º¹¹»ººº½º½¾¼»¼¾À¿¾¼ÂÁÁÂÁ¿½¼¿¼Á¿¿¿ÀÁÁ¶ÄÄÄÂÁÀÄÆÅÅÆÄsqqtutuwwuprttrstuttssuvutuvwwtuuvvvxxvvvtvyyzzxyxwwxxvwy{ywy}{yyzyyzzxyyzyy{}|zz{z{|}~€~|{{|{~|}~}z~~~}}~€‚‚€}~~~{}|~€€|€~€}€€‚€„ƒ……„„…„ƒ„„ƒ„……„„„†…„‚ƒ‡ˆ‡„‚†‡…‚…‡†……‡‰‡†‡‰‰‰ˆ‡‡ŠŠ‰‹‹Š‰ˆˆ‰ˆ‡‡ˆˆŠŠ‹ˆ‰‰‰‹Œ‹‹ŒŽ‹‹ŽŽ‘ŽŠ’‘’’ŽŽ‹““’’‘‘“•••”“””•••–••••—–“““’’”˜š˜˜™–—˜™˜–—™œ›™˜—”…}tkc\WNE;3( '19DJPROIDCEB;;<;>@@@ABA@@AA?><;>@@?@AACFHHHF@:4/+*((''3OfoofaUB>=?GTTKD@><=BFEDF= + ;€²³³µ¶·´¸¸¸´²´²³²µµ´´´³´·¶·¸µµµµµ²´·¹¹··º¹¹¹¶¸¹º¸¸¹¹»»»ººº¼¾½¼½¼¼½¿¿½¼»ÁÃÃÄ¿¾¿¿¿ÁÃÁÀÁÁÁÃÅÆÁÀÂÃÅÇÆÄÆÃsqqrsmswwtqqrostttttsptuurvuvvvuutvvwvvuttvyyyxuyzwwwwxuxzzyxxzxyyxwywwwyxyw}|wwy|}}|~~|x{|}|}|}~}|~}y{|~|€€}~€}€~€}€‚‚€€}€ƒ„„„…„‚„ƒ„„ƒƒƒ„…‚………ƒ‚†ˆ‡„†ˆ…ƒ…‡‡†„ˆ†ˆ†‡‰ˆ„ˆŠŠ‹Œˆ‰‹Šˆˆˆˆˆˆ‰‹‹ŠŠ‰‡ŠŠŠ‡‹ŽŒ‹ŽŒ‹‹ŽŽŒŒŽ‘ŒŽŽ‘’’’’Š‘‘‘‘••”““••”••‘•”–—–”“““’•˜™™™——“”‘–•›œ™—›™˜–‘‡wi`VSMH?5' $2<CFEDFGD>=<;;<<<9=><:=<<655:=<9:::<>?@C@<5.,+*))(,7Ukrog`T>909GJJA7<?AAEGFAE5 + Jˆ¯³±´¯¶·¶¶¶µ´³²²²²´²±³®³µº»¹µ´´¶´µ¶¸»»¹¸º¹±»·¶´º¸¸±¸¶¼¼º·¼½¾¾»µ½¾¾½¾¾½»ÂÁÄÃÁ¼¿ÀÀ¾ÁÀÀÀÁÀ¿¿ÅÄÀ¿ÃÂÅÃÅÃÅÂsrqqrrtvusqqqsuvttutrrsuttvwuuvvvvvwttvutsuz{yxvzzwvtwxwvyzzwxzyzyvxzzyyyz|}}~}y{z{~}{}|zy{}}|z}}{{}||€|yw|~~}}€€€~€€‚‚‚ƒ‚€‚‚‚‚‚‚‚‚„…ƒ……„ƒ„„ƒƒ…†……„„„……………†‡‡…ƒ†‡†ƒƒ‡Š‰‡†ˆˆ‡‰‹Š‹‹Š‹Œ‹‰ˆˆ‰‰‹ŒŽŽŠ‰‰Š‹ŠŠ‰‰Ž‹ŠŠŒŒ‹Ž‘ŽŒ‘ŽŽŽŽŽ““’’‘”“’‘‘’“““”•“’‘“”•‘”––”“•—–”’“’”••–—˜——˜˜—˜››››šš›œžœ˜”Œ…{qgebZPE<3' *26;@EDDA>;;<=<:;<;;:;96448:988889;;==:40.,+****/@\prnicS=403EJC948BIKIFCFB/ + T±µ¶¶¶µ¶µ³³³µµ´³³´³²²²²³³µº½¹µ¹º¶³¶¸¹»»¹¸º¹ººº¸¹º»¸¶·»»¼»¼¼½¿À¼»¾À½½½½¾ÁÂÃÃÄÀ¼¿¿ÁÂÁÀ¿½ÂÁ¿ÁÂÃÀ¿ÂÄÄÄÃÂÅÆrqrprsuutttrrsuwvuurtuvuutvxwsuvxxyxttvuuuuz{wxuyyyvvxyxxy{{yyyy{zzy{|{{z{|x|||z{{z{|{}|{{~|{y{yyz{{~~~~€€~|~~€}~€€‚€‚‚ƒ„„„ƒƒƒ‚‚‚‚‚‚‚‚ƒ„…†…†…„ƒ„…‡‡†…ƒ†‡‡‡ˆ‡‡‡ˆ„„„„……ƒƒƒ‡†‰ˆ‡„‡ˆ‰ŠŠ‰Œ‹‹Š‰‰‰†Š‰‹ŒŒ‰‡ŠŒŒ‹‹Š‹ŽŒ‹Š‰ˆ‹Œ‰ŠŠŒŽŽŽŽ‹Ž‰ŽŽ“”“‘”‘’“’‘‘“‘‘‘’’”•”“‘’“’’”••“”“––•”–—–••’“•˜——˜š™š™š—–•™›œ›››š™–”‰†€wmcZUNG@9,! -38;;<>@@><::;;46697436795867566774---,+*+++4JbsqlgbQ<209FI>5-5CMOG?AE?+ Z‘³µ´¸´´²²±±±µ´µ¯µ¶¶´µ±²±²µ¹·¸¶¸¹¶°·¶¹¹¹¸ººº¸º»¹¹¹µ¹²¹º¼µºº¼¶¾¾¼¼À»¸·¼¸¿ÂÁ¾Á»¾¼¾¿Á¿¿¾À½ÂÂÁÁ¾½¼ÂÅļÂÃÅÅrttsqsuuttttsspwvsttuwwvvwvwwwuvwyyxuuvvvvvyyyyxvyywxyzyw{{{zxwy|{{y{~}|yz{{zzxy{zyy{}}|y|~€€}}|{{yw|~€€€€€~€€€€~|‚‚‚€‚ƒ‚‚‚‚‚„„„…„„ƒ‚‚€~‚‚ƒƒ‚‚ƒ„„……„„…†‡‡‡‡†‡‡ˆˆ‰ˆˆ‰‡………††…„…‡‰‰ˆ‰ˆ‡†ˆˆ‰‡‡ŠŒ†††ˆ‰Š‹ŒŠ‹‹Š‰‰ŒŒŒŒ‹ŒŽŽ‹Œ‰‰ŒŒŒŠŒŒ‹ŽŽŠ‹ŒŒŒŽ’‘’••‘‘“•”””“‘’‘‘‘‘’‘“•–‘“““’’•––••–•—–•–™—••”–˜™™˜—˜˜˜™™™˜˜™›š—”ššš™šš›š˜—–†}ukf_ZSJ?4' ")-39@A?::;<:64476434689998655431-,-,*)*+,9Odonjc\M711;GF92-3BLMD<<B;% "^“²´³¶³µ¶¶··µ´´´µµµ·¹¶±²±³´¶¸·¶´¶·¹¹¶¸¸·¹¹»º¸ºº·¸¸·¹¼ºº»ºº»¼¾½»¼ÁÂÁ¾¼½ÀÀÀ¿À¿¾¾¿¿¿ÁÂÂÂÂÃÂÂÁÀ¿½¿½ÁÄÃÁÀÆÇÆttttttuutrrquuttuqstvvwwvuuuvwvtvvutuvwxxuwyz{{zxxxwxvyzz{{{zyyy{||y|~~}|||zyyyy{zzv{||zzz~~~€}~z{|~~~~}€€‚‚€€‚€€~ƒƒ‚€€‚‚„„ƒ‚‚‚~€€‚„ƒ‚‚ƒ‚ƒ„……………‚††‡†‡‡‡†‡„‡„‡…†‡†…„†‡ˆŠŠ‰‡Šˆ†‡ˆ„‡„ŠŠˆ‡†…†‡ŒŒŒ‰‰ŠŠŠŒŒŽŒŠ‰‹ŒŽŒŽŽ‘Š‹ŒŽ‘’’‘‘•–“““”““’Ž’‘““‘“’“’•—–””“”‘•–—••–•––Ž•––•–”—˜š™™–—”˜™™˜™˜™–™•–—–•˜˜™›œšž œ•”‘Šwkc]XPF;1# + +(179:;<>=96555615699;::7521//..-+&)**,<Q[abaYPI32-=ID53.1=FHA8:@5 + + $a–³´³²²·µµ¶·´µ±³´³³¸¸¶°°±µ´µ±³´´¶¶µº·¸µ´´¹¸¹¸»¹ºº¹¶»»º¶¼ºº·¼¾¿º¾ÀÀÀÀ¼¼¾À¸½»À¾½½¿»ÂÂÀ¾À¿ÂÀÀ¾½¾½½½¾ÅÄÅÈÇÃusptvvvvtsqtvwurtrutwvuvtsqssuuvwwwtuvxxxxwwx{zyvvvvxyyzzzzyy{yy{{{|~€z}~}zxxz{{{zzz{{zz{|}~~~‚€~}{{|}|~~~~~€‚}€€€€‚ƒ‚€‚ƒ~€€€€‚„ƒ‚‚€€„„‚‚‚ƒƒƒ…‡†„„†‡†††‡‡††……††ˆˆ‡„„ƒˆ‰ˆŠ‰‰‹Š‡†‡‰‰‰ŠŠ‰‡††„‰ŒŒŒ‹ˆ‰Š‹ŠŒŽŒ‹‹Œ‹Ž‘‹ŽŒŽ‘‘‘‘‘‘Ž‘“•“‘““““’“’•”““”•••”•—–”•–”“’––•”””––”•———–•—ššš™˜—”˜›šš™˜˜–˜˜š›˜˜˜—˜šžŸ¢¢¡¡¢œ“Œ†wni]TJB8.! #*/47:<=??=:99:<<<;;:9620.///,+**+,-=OWYXUOLG?75@JC31/09AD>69>1 &ešµµ¶µ²µ´´³µ¸¶··²µ¶··¶´³´µ·´°¯²´¶¶µ¹¹¸¶·¹º¼¼¼»¹»»ººººº¼¼¼¼½¼¼½¾½½¹¼½»¸¼¾¼½¿ÁÃÁ¾¾ÀÁÂÀ¾¾½ÀÂÂþÀÀÁÄÆÅÆÇÆÂtrqsvvvvuuuuuuutsrtuvvustuttvwwwwywuutuvwwwtyzxvvwxvxxz{zxzx{{{xwwy|~~}|{{zz{||y|||||xy{{{}|{{€~~{{{}}}~€€€€€|€€€€€€‚‚‚ƒƒƒ‚‚ƒ„„ƒ„‚‚€|ƒƒƒ‚„ƒƒ…†…„ƒ‡‡…ƒ‡†‡„…‚ƒ„†‡ˆ‡……‡ˆ‰ˆ‰ˆ‰ŠŠ„†‰ŠŠŠ‹Š‰‰…‰‡‹ŠŠˆŠŠ‹ˆŒŽ‹Š„‰‹Œ‹Œ‹‹Œ‘ŽŠŠŽŠŒŽŽŽ‘‘‘‘Ž’’‘“’”Ž’””“‘‘“•”‘”•””––•“•““‘‘’”––••—––˜——˜—––”˜šš—–”””—œ›šš—˜—˜”›žœš›œœšœžž£¤¤¡ ˜—”‰‚wf`[SIA8/# %-39@DC@>=@A@<=7:7531---.++)+*-->NPRQIHFJKD8BH@1/.17>@?7??/ + + 0pŸµµ¶¶³²²²±´³¶·¸²···¶·´µ´¶·¶±³µµ²¶·¹µ·¸··»¼ººº¸»»¹¸ºº»»¼¼¾¿½¸¼¼º·¸º¾¸»¾¾º¿ÁÃÄÁ»¿¿ÀÁ½½¼Á¾ÃžÄÄÄÄÄÂÃÁÅÃrpptuuvvvwwvttsvursttvusvxuwwxwvwywuvuuvxvvwyywusxyzzz|}zz{|{|{ywvxzz{{|}zz{w{{{{|}}}||{{{|z{{}}~zy|y{|}~~€€{€‚‚€€~ƒ„ƒ‚€‚ƒ„„„ƒƒ„ƒƒ‚„ƒ‚ƒ„……ƒƒ………„„……††††††…ƒ„„………†…†ˆ‰ƒˆ‡‰ˆ‹‹ˆ‡ŠŠŠŠŠ‹‹‰Š‹ŒŠ‰Š‹‰‰‰ŠŒŒ‹ŠŠ‰ŒŒ‹‹‹ŽŽŠ‹‘‘ŒŽŽ‘““‹ŒŽ‘‘‘““””•“Ž’•”’’’”•”””“’’•––••“””““”••–•˜˜—™˜—˜”“”•—™˜˜˜——–—š››œœœœ™™™›š™˜œœœžŸœ¢¤¤£¢¡žœš˜…|tha[SKC<4% "+4;>@AADEC@><;9740.---,+**+,.@MONKE@BIPLDBB;/./16<@@AC@- :z£³´µµ¶´³´´´µµ··¸·¶µ·¶¶¶¶¶¸¸¸··¶²·»¹¸¸¹µ¸º¹·¸º¼¼»¹¶ººº»¼¼¾¿¼¹º½½»½ÀÀ¾¾¾¼¹¿ÃÂÂÀÀÀÀÁÃÂÁÀ¼ÀÂÄÅÄÆÇÆÅÅÃÁÂÃÅÆrpqturuvvvwvuttvvsssuuttwwxxwwvuxxxvwwvvzzxvxyyuwxyz{{||{{||{{{yxxzzzyy{{{}|yyyx{{|}|{{z|}}{|}~~}|~y|}yx||}~€€€€€~€‚‚‚‚~€€€‚€€€‚……€ƒƒ„ƒƒƒƒ„…††„~…„„‚ƒ„„‚………†ƒ‚‚†……„…‡…‡ˆˆ‰‰‰‰‰‹‹‰‰‰‰‰Š‰ŠŠŠŠŒŒŠ‰†Š‰‰‡‰‹ŒŒŒ‡ŠŒŽ‹ŠŒŠŒŒ‘‘Ž‘‘‘‘““Š’’‘’‘“•”“Ž“‘’““‘’’””“‘”–—–”•““••’““–˜™˜™˜˜—•–—””•˜˜™™š“––šœšš™š”š™™–––ŸœŸ¢£ ¡ Ÿœœœ ¡ž™”ކzqf_YWSKB9) +27;BHF??:<<83/*-,--,*+),.@LLIGB>:AHKIE=6.-+279:><E?) + ?¦´µ±´´´°µ´µµ¶··´·¬µ³¶··¶¶·¹¸·´µµ¹·¹¸¸¹¹¹»¸º»¼½¼»ºµ»¼¼»¼»¼¾½µ¶¸¿¿¿¿¾»¾¹¸¸¾¼ÁÁÂÂÀ¿ÁÀÀ¿Á¼ÁÀÆÄÄÂÈÈÆÁÄÃÄÅÅÅrsqsuuuvwvwvvusvwvuttttvwvxxwvwvxxxwyxvw{}{yyz{zzyz||{{|||||{z{|{{zywyy{||}}{x{{||{}}{z|~~~~€€|}~z|~~}~z~}€~€€€€‚‚ƒƒ‚‚€‚‚ƒƒ‚€‚………‚‚ƒ„ƒƒ‚€‚ƒ„„ƒ……………„‚ƒ„…„„„…†‡†††ˆ‡†‡‡†‡‡†‡‰‰‰‰ŠŠ‰†‡†ˆˆˆ‡Š‹ŒŒŠ‰Š‹Šˆ‰Š‰Œ‹‹ŒŒŒŠŒŽŽŽ‘‘’’ŽŽ‘‘‘‘‘‘’’“’’”“’‘“’’””””•”“’’“““‘••”••”“–••””–˜šš™™™˜–˜˜—————™›šš——š›™›œ˜™™™›ž›š›žŸœ›ž¡¢£¡ Ÿž ¡¢¢¡ Ÿ™’‹wplid[QG;0(" $+6?A@?>><82.*,-.--+,,,1@HHGC?;89>DHD=3.-.2898::C=# + D†¨µµ´³²²°µ·¶´·¹¸¸¶µ¶·µ¶¸µ³´·¹··º¼¹¹º»»º¹»½¾½½»»»»º¹»¾¼»»»·»¼½¼¾¿Á¿¼»º½½½¿¿ÀÁÂÄÃÂÁÂÃÂÃÂÁÂÄÄÄÃÂÇÈÈÇÆÅÂÅÅÅtsstuuuuvvwvvusuwvvuuruvvuwwvuuvxywwyywvyz{zzx{|{w{|}||z~}|{|||{{xzyyz{|}zz|{y}}}{{}~||}~~|€~€€|}~€€~~~€€{€‚‚„ƒ„„ƒ‚‚|€‚ƒƒƒƒ~ƒ‚ƒ„„„ƒ„…„„ƒ‚‚ƒ‡‡…††‡†…ˆ„‡‡ˆƒ‡†…„††‡ˆ‰ƒˆŠ‹Šˆ„‰‰‰‰‰‰‹‹ŒŒŽŒŠŒ‹ˆ‹Œ‹‹ŒŒŠŒŽŽŽŽŽŽŽŽŽ‘‘Ž‘‘‘’’’Ž‘’’’““’“Ž’•–•”““Ž““•••’””““•”••––•“––™˜˜–˜˜––—’˜˜–•˜™™˜™—š™™—˜™š››•œžž›žžŸš ¡ Ÿž™Ÿ ¢ŸŸ Ÿ ž›—“މ~uc^[TLF@6) $+159::820+,----+,,,3@HFA@<9443:<<;5.//599779A;! + JŠª¶¶¯µ³³¯µ¸·µ¸º¸¸·³¹¸·³¹´´¯·´¸·º»¹¹¼¿½¶º¼½»¼ºº²½¼»·»¼½¶½¼¼»¹¹¾º¼¼½¹»»¿À¿¼ÂÁÁÂÂÀÁÂÄÄÄÄÄÂû¾ÂÁÅÇÈÊÉÆÇÈÆÀutstuuquvvwxwvttvwvvwxxvvuvvvtsvyzwwzzyxxxvy{zy{{z{|{|}~}~|z|||{y{{z{||}|yz||z~~||}~~~}z}€€€}~€~€‚~}‚€€ƒ€‚‚€~~‚ƒ‚„€€€ƒ…„„ƒƒ„…ƒ„„ƒƒ……„ƒ„‚‚„‡ˆ…†††‡‡‡†…ˆŠ‰ˆ†‡„„…ˆ‰‡ˆ‹‹ŠŠ‹ŒŒŠ‰‰Š‹Œ‹‹ŒŒŠ‰‹‹‰‰‹Œ‹‹‹ŽŽŽŽ‘‘‘ŒŒŒŒ’Ž‘‘‘ŒŽ‘“’’’‘““’Ž“—–•‘’““’”•––““’‘‘”•””’•••–—————™™––———˜—–—–—˜š›š™™™š›œœ›œœœœœœœžœž¢¢¡¡¡Ÿ £¢ž£¢ œ–Œ„{rgc^YPG=4+" +.232221--..,,,,4@FC?=;710/4898630/7;:9:>A9 RŽ«µµ¶µµ´´¶¸·¶¹¸¶¶µ´·º¹º¸·¶¶¶³·¸¹º¹¹»½½»»¼»¸º»¹¹»½¼»¼¾¼»½¿À¿½¼½½¼¼½¾¾¾¾ÀÀÀÀÁÀÀ¾½¾ÂÃÃÃÃÃÃÁ¿ÁÄÃÃÃÃÆÊÊÊÊÈÈÇusrquutuuquuuuuquruvxzyxwvwwwvuuyzxxz{zvyxww{|yyzzz{||}zzy{z{{|}~~|{||{{zy|~}z~€z}|~~||~€€~}z}~~|€€€€}€}~}€}‚‚‚€€€‚ƒƒ‚€ƒ„„„„„„„‚„„ƒƒƒ††„„ƒƒƒ‚‡‡††…‡†ƒ‡„ƒ„Љˆ‡ˆ‡…ƒ†ŠŠ…‰‰‹‡Š‰ˆˆˆ‡ˆˆ‹ŽŒŠ‹ŒŒŒŠŠŠ‰‹…ˆ‡ŒŒŒ‹ŒŽŽŽŽ‹’‘‹‹‹ŽŒ‘ŒŒŽ‘’‘‘‘‘’’’““’•–”“’’”“‘‘””–”••“’“”““’•••–’–––—˜˜—–™—™–———––—˜š››š™šœœš››œœš˜™™žšž™ ž ¡¤¢¢£¥¤¢ š•Ž…yoe^YVRMF>0$ &+032/./.--./5?BA<;:6/..369:863/8>=9:>B5 Z’«²µ¶¶²¶µ¸¹·¶¸²·¸µ°·¶¶¶·±·µ³³¶³´´¹¸ºº¹¹ºµ¸·¹¶ºº»·¹¸¸¹½¼½·¿ÁÀ½¾¾¿¿¿»¿½¾¹ÁÀ¿¼À¸¿¿ÁÁÁ¿À¿ÄÀÄÃÄÅÅ¿ÃÈÈÃÈÆÇÈqssstuvvrrssttvwvuuvuyzzyyxxxxruvxxyz{|{zxwx{|zywyzz||{yyzzzzzz~}|||zz}}|}|}~€~z}~~~}}~~~~{||}}~~~€‚€€€€€€€€€‚€€€‚ƒƒ‚€‚ƒ‚ƒ‚‚ƒƒ†‡…„‚„…†‡†……………†‡††‡‡††‰‰ˆˆ‡†Œ‹‰ˆŠŠ‡‰Šˆˆˆ‰ˆ‡ŒŽŒ‹‹‹Šˆ‰‹ŒŒŠ‰ŒŽŽŽ‹‹ŽŽŽŽŽ‘’‘ŽŽŽ’‘‘‘ŽŒ‘‘‘’’“”•“’’””“”––”“““••”‘‘“”•––——””–—•”””––––•“———˜—˜šššš››™—–“˜šœš˜š›œœ›˜š›š››™›žžžŸžœœžžžŸŸ ¢££¢¢¥££¤¤£Ÿš“‹‚zqkie_WNC:1& !'*+,.00/007>@?=<:61..036:973/9=<;:AA2 ^•¬²µ······¸·¶¶¶·¹µµ¶¶µµ¶µµ¶µ´´´¹¹¹¹¸¹¸··µ¹·¹º»½¼º¹¸º½½¾¼¸¼¾¿¾½¿ÁÁ¿½½½½À¿ÀÀÀÀÂÄÄÁÁÁ¿ÁÄÆÇÄÃÃÆÇÅÁÅÄÁÅÃÇÉsrtvutvutssorsvuvwvvvwy{zvwxyyyxxvvvz|{{zvvuy{zvww{z|yzz|}}}|z{}~}}|||{z|||}y}~~~€}{~~~}{}}|~}}€€€~€‚ƒƒ€€~~}|‚‚‚‚‚~‚€€‚„„€€‚‚ƒƒƒƒƒ…„†‚ƒ‚ƒ€„„……„„„„…†††ˆˆ†…‡‰ˆ††‡ˆ‹ŠŠ‹‹ˆˆ‰ˆ†ˆˆ‰ˆ‹ŒŒŒŒ‡‰Š‹ŒŒŒŒŒ‹ˆŒŽ‹‹ŒŽŽŒŽŒŽŽ‘‘‘ŽŽ‹’’’‘’’Ž“””””•“”•“’’’”••”’‘’–••——“”˜˜•“‘•—˜•—’–˜™˜—–•–š•™›œšš™˜˜™š™˜™™™™˜˜™™™—›š›œ›žžžžœžžžžŸŸ ¡ ¡¡¡¤¥¢¢£¡žœ˜’Œ†|rgb`[TOIB9+ !%+04269=???>;62/(++14542/7897=D@. + dž®±µ¸¸¶····¸³³²·¹·¶¸±µ´´²µ²¶µµµº¼ººº¶·¶µ¶»¹»º»¼¼·¸¸»¼¼½¾¹»½¾¾ÀÀÁÁ¿¹¾º¿ÂÂÁÁÁ¿ÂÃÅÄÂÁÁ¾ÂÅÇÀÃ½ÅÆÉÇÅÄÃÀÂÃÉÊtsvwvwvttutpqttsuvvvvwxyxuvxz{{zzvuvz{vxxuvvxyyxx{{{zz{}{~~}|||}}}|{{{{}}||}€€{€}}}}~}|{~€€}~€€~€€‚„ƒƒ€‚€€‚ƒƒ„„ƒ€ƒ„€€€‚„ƒƒ‚‚‚ƒƒ„†…††††‡†ƒ…………„……„ƒ‚ƒ…ˆˆ†ˆ‰‰‡‡ˆ‡‡ˆˆ‡ŠŒ‹‹‰†‰‰‡ˆ‰‰‰‹ŒŒŽŠŠ‹Š‹ŒŒˆŒŒŒŽŽŽŒŒŒŽŽŽŽ‘‘ŽŽ’““‘‘’‘‘‘’“””‘’’’””“”–—“‘’••”˜—”•——•••–˜™š˜——˜š›™——˜™˜˜šššš™™˜˜™™™™š™˜š˜™›š›œšššœžŸ›œŸ ŸžžŸžžŸž ¡¤¤¡£¥£¢¤¤¡Ÿ˜†wjfda[SE9-$ &+/27<@BA>;72/,,-///1225887@G@+ j¤´µ·¹¸º¸¶¸··¸·¶·¸·¹¸¹¹¹¸¹·¶¸¸·¶»¾¼¼»º¹··¸»»»»¸»»º¹ºº¹·¼¾¿À¿ÀÁÂÁ¿½¼½¿ÀÁÃÀÀÁÂÀÀÁÂÅÄÂÀÁ½ÀÄÆÆÅÄÆÊÈÈÈÇÄÁÅÇÉÉtrvvuuuqsvtprsttttwxxxvuwuwyzzzzzwvuyxwxxwxxxvy{|{zxyv|}}}|yxx~~}||wyx{|||}x{}€€€€€}{{{~}€~||€€€~€‚‚ƒ€‚}~‚ƒƒ„„‚ƒ…„ƒ„€€ƒƒ‚‚‚‚‚‚€„…†‡‡†††‡‡‡††………‡‡…„ƒ†‰‰†‡‰‰ˆ‡‡†‰ŠŠ‰‡ŒŒ†‡‡ˆ‰‹ŠŠŠ‰ˆŠŒŽˆŒ‹Š‰‰ˆŽ‹‹Ž‹Œ‹ŽŽŽŒŒ‰Ž‘’’‘’’‹“’”‘’’’’‘‘‘’’’‘“”’”’–—•’‘•–™š—””•–––”——˜˜™—˜—™›š˜—˜˜™™˜—–——––˜™œ–ššš››š™—˜˜šš™›œŸžžžžŸž˜ŸŸžšš›Ÿ ¡ ¤¢¥¦£Ÿ¤¥££¥¤¡—‘‰{pgb^YSPI?-" #*2:?A=770//120../114588CJ?' + n§³µ·¸¹¹¸¶¸¯··¸¶µµ¸¹º¹¹¸¸¹ºµ»»¹¸¼½¼¹»¸»µººº´»¼¹»»¸¸¸¹º»»¿ÁÁ¾¾À¿¼ºº»ÁÀÁ¿¿¸Â¿¾½ÀÁÂÁÁÀ¿¾¿ÁÆÅÇ¿ÇÄÆÆÇÆÆÂÇÇÈÂsttupttsrutsttvvutwzzxvuwxwywwwwxwwwyxvvwxyyxxy{{yz{z{||}||{x{}~{{||{z{||||yz}€€€€€€~~~}|~~‚€€ƒ‚‚‚ƒ€‚€€€‚„…„‚‚‚„ƒ‚ƒƒƒ‚††‚€ƒ‚ƒ…‡ˆ‡…„…†‡…†††„„†‡†………†ˆˆ‡‡ˆ‹Š‡…†ˆ‹‹Šˆ‰‰Š‹‰ˆ‡‰ŒŽŒ‹ŠŠŠŒŽŽ‹ŒŒ‹ŠˆŽŒŒŽŽŽŽ‘“Ž‘’’‘’’’“’“”–““””•”“’‘‘‘““’‘’–•““•”““’••™™—”””•––—˜˜—–˜™˜—š››š˜˜™™™››™˜˜—˜›œœœ›šœ›››œœœš›œœžŸž £ ™œŸ žžŸ ¡£¢¢£¢¤¦¤¡¡£££¥§§¦¥£Ÿ˜Ž„xmggebYNB8/$ )1655558<>:40//115899EK># + $q¨µµ´·¸¸···¸¶¶··µ¶¹»ºº¹·¹»»»»ºº»¼¼»»»»»¼½¾º¸º¼º¼º»»»¼¾¾½ÀÁÀ¼·½ÁÄÁÁÁÃÂÁ¿À¿ÀÁÂÂÃÂÂÀÀÀÀÀ¿ÃÅÅÃÄÄÅÅÆÇÅÃÆÊÉÈÇÇrrtvvttrrttssuvvvtwzyxwvyyyyxuwxwxxwwwuvvvvwwuz|yw{|{||||}~~||{|{z{||}}}}z}z|}€~}}{~€€€}~~~~~€€€‚ƒ‚~€ƒƒ‚‚‚‚€€ƒƒ‚‚‚‚ƒƒ„ƒ…ƒ‡†‚‚‚‚ƒ€‚ƒ…‡…„ƒƒƒ…††…†‡‡…‡†††††††…†‡‡Š‹‰‚……‰Š‰‡‡ˆŠ‹ŒŒˆŠ‹ˆ‹‡ˆˆ‰ŠŽŽŽŽŒ‹‰ŽŒŒŽŽ‹ŽŒ“‘‘’“’’’’‹’•”’”––•““’’’“““’“•–•”•–•”’–•–”“”–——˜™˜˜•—•˜˜˜–—™œœ™—˜–˜›šš››šœœœ›šš›—™•ž›™œœ›œž œœ˜ ¢ šŸ ¡ ŸŸ¢¢£¢¢¢££¤£¢¢£££¦¦¢¥¦§¥ ›–ˆyufdc[UNG>2& "(,3=FIE9111129;;:FJ: )u«·¸·¸¹³¶¸¹¹¶µ¶²³³ºº¸´º·¸»¼»º¶»¼»º»¼½º»º¾¾º¹º»»»»¼¼½¾¿¾¼¿½Á»¹·¾¿Ã¿ÄÁÂÀ¿¹À¾ÁÀÄÁĽ¿¼¼½¿¼ÄÃÂÃÆÃÄÆÆÅÅÄÆÊÊÅÇÇrttuutsrotutvvvwwvxyxwwwz{yyxxxxxxyxwvvxxwwxww{|yz{{|}}|{}}~}|{|{yw|}}|}€~~|€€~~}{}~}€€€~€€€€}ƒƒ‚‚ƒ„ƒƒ‚ƒƒ„ƒƒ‚‚‚‚ƒ‚€„…ƒ…††…ƒ„……„‚ƒ„‚……ƒ‚„„…†††…„ˆˆ‡‡‡††ˆ‡†……†ˆˆ‰ˆ†‡ˆ‡ˆˆ†‰‰Š‹ŽŽŠŠ‰…‰‹‹‰‹ŽŽŽŒŒ‹ŽŽŽŽŽŒ’‘‘““•‘‘‘“‘‘••–••••””••––•––––•“—•””–•••“”•—ššš™˜˜™™™—–—™™›œ™–———™š›œœœœœ›š™™˜˜™ž™™˜›žŸœžœŸŸœ›ž ŸšžŸ ¢¡›¡¢Ÿ¤¤£¢£££¤¤¢¡¢£¥¥£¨©¨§¦¦¤Ÿ—†~tlje`ZUH7% (3>DC<88889<@@@HI6 .{·¹·¸¸·³¸¹¹¶´´µ·¹¹¸¸º¹¸µ¸»¼¹¹º»¹¸º½½¾¼º¼¼·ºººººº»»ºº¾¾¾½¾À¿¼¼¼¿ÀÂÁÂÁ¿¿ÁÁÂÂÁÁÁÁÂÀ¿¾À¿»ÂÆÇÉÈÈÇÈÈÅÇÆÆÈÈÈÅÃuquusrtsttvsvvvwxvxuwxxyzzxvxxxwyzyxxxzzzuxzzy{|{z{{|}~~}z{}||||yy{|{|€€~}~{€€~}|~~~€€€}~€}€‚‚€€‚‚ƒ‚€‚„€€‚ƒ…„‚€‚‚~ƒ„€‚„…„……„ƒ†††…„ƒ„„‚„ƒ„……‚†………‡ˆˆ†ˆˆ‡‡‰‡†…ƒ…‡‰‡†‡‡ˆ‰‰‰ˆ‡‰Š‹Œ‹ˆŠˆ…‹Œ‹ŽŠŽŒŒŒŽŽŽŠŽ‘‘””“’’‘‘‘““’”•”“”““’”••“•”•’˜–’•”‘•“••–•–—˜šš™˜–˜šš™—–™šš™››š–——™™™š›œœœœ›š™™™››œœš›ŸŸ›œžŸžžŸœŸžžœœž £¢œ¢¢¢¤¤¡ £££ ¢ ¡£¤¤£¨¨¡¦¥§©¨£¡œ—‰~wgffaVI;3* !(027=A@<ADC@LK4 3‚°³³´±·¸¶³¶¶´³µ¶¶µ´¶¹¹¸·¶´»»¹¹¼¶ºº¼¹½¹¾»º»»¹¸¸»½¼ºº»¼¹¿¹½¼Ãº¿¼¼¼Á¿¿Á¾ÁÂÁ¿ÀÀ¿ÀÂÂÁÃÅĽþÆÈÉÆÈÇÈÅÉÈÆÅÇÂÂÂutttrrrvtuvvwvsxwyywwwz|xyyxxwxyzz{ywz{{yyz||{{}{z{{z|~}z}~~|yz{}z|€}|~~~€€~~€€€~|{{}~ƒƒ€‚‚‚€|€‚ƒ„„ƒ‚ƒ„„ƒ‚ƒ‚‚ƒ„„ƒ„††ƒƒ„†‡‰‡„ƒƒ‚…†„ƒ„†‡…„†‡ˆ‰ˆ‡††ˆ‰ˆ‰ŠŠˆ…ƒ†‡‰ˆ‡ˆˆ‰Š‹Š…‰‰‰‹Œˆ‡‡ˆˆŠŒŒŒŽŒŽŽŽŽŽ‹‘‘ŽŽŽ‘‘’‘’“‘’’’’““’““”’’““‘”“’’“”––•’•““””’”•––—˜™˜–––˜™˜–—™››™˜šœ›š—™š™™™šš–™›œ››—˜šœœœž Ÿ›šžž¡¡¡Ÿžž›œž¡£¢ ¡¡¢££¢¡¡¡¢¡£¢¡¢¤¢¢¢¥¥£¢£§ª¬ª¥¦¤Ÿ˜…{vrnbXSMB7* *3:=?BEHMTN3 ;‰³µ±²±·º·¶·µ´¶¹º·´´¶¹º¸¶µ·º»¹º¼¾½½»¼¼½¾½¹º¼¼¼¹¾¾¼º¾¾¾¾¿¿¿¿ÃÂÀ½ÁÄÁ¾¼ÁÂÁÁÂÁÁÂÃÄÅ¿ÁÃÄÄÇÅÃÂ¿ÄÆÈÉÈÆÇÅÉËÉÅÆÇÇÅusurstuvuuvwxuvwxyxvvwz{zyxxwwwwz{{yyy{wxz{xyz||{w{{yz|~}z~~~}~~}y{|}|}}~}}}||~€~{||{zxyz€€€€€~~€‚‚‚ƒƒƒƒ‚‚ƒ‚‚‚‚„„„ƒ†„‚€†…†ˆ‡ƒƒ„…ˆˆ†……††„„†‡ˆˆˆ„…††ƒ†‡ˆ‰ˆ‰ˆ‡‡†‡‡ˆ‰‰Š‹‰‰ŠŠ‹‹‹Šˆ‡ˆ‰ŒŒŠŠŠŽŽŽ‹‹ŒŽŒŽŽ‹ŠŠ‘‘‘‘‘’‘‘‘‘“”““’”“’ŽŽ’””“”“”•“’““”’‘”–—–—–•”–”–‘–””““”•–˜™šš™™™—™˜›œ››››™šš˜—“™™™š™—›œœœž ¡ ŸŸžžŸž›˜ž¡¡žŸœ ŸžŸžŸ ¡¡¡¡£ ¡£¢Ÿ ¢¢¢¤£¢¢ ¤£¡¡¦¨«¬ª¥§¨§¥¡™“Œ}rhda]WNC9& $,4=GR[S1 DŒ´µ±±²¹¹¸¶¸´¶¹ºµ¸·¶µ¹¶º··ºº´¸¶»¼½¶´´ºº½½¼¼½½¼»À½¹¸½¾¿¸ÀÀÀ¿ÂÁÀ½ÂÂÀ¾¾¾ÁÁÁ¾Â¾ÃÂÄÆÄÃŹÂúÂÀÄÁÆÆÈÆÅÅÇÊÊÆÅÇÉÃtttsrwvuuttwwxxwwxuuvxwyxxtxvvuuy{zyyzzxy|{xwy{}{yz{yz{}}|}}||z~}y|}~}{{|€€€~|}€{{|}~~zz|~‚‚‚}€€‚€€‚ƒ€~‚ƒ„„………ƒ‚……„ƒ††ƒƒ„†‡‡…€„„ƒƒ…‡ˆ‡†‡†††……„…†ˆˆ‹Šˆƒ†ˆ‡ˆŠˆ‰†‰‰ŠŒŒ†‰‰‰‡‡‰ŒŒŒ‰ŽŽŒŽŒ‹Œ‹ŒŒŒŽ’’‘‘‘Ž’‘’’’“”“‘‘“••”’‘“–••–•”•”“”••–”“•———˜˜˜—˜š˜—•“””•——–”™™šš˜™š˜•˜››››™šš›™™˜˜™››š›œœ›œžŸžœŸ¡ œ›œŸ ŸžŸ¡¡¡ž Ÿ Ÿ¢¥¢Ÿ ££¢žœŸ¡¡ ¢¤¥¤¤¥¤¢ £¥§©ª§¥§¨¨¨ª«©¦¡šˆxqme\TK=0% *6CUH. J¶¶µ´·¸¸¹¹º¹¸¹¹ºº»·³¸¼»»»¼º·¸¸¹¾¼µµ·º»»¼¼½¾¿¿¾¿½¼»»¼½¾¾¾¾½ÀÁÀÀÂþ¾¿¿ÀÀÀÁÁ¿ÂÀÁÄÅÅÅÃÁÂÂÃÄÅÃÀÆÅÈÈÅÄÅÈÊÉÊËÊÉsrvuuuuqututvxxvxxwwwxyxwyzzxxwuwzywzz{x{|{yxy}~|zyvz{||}{{{|z}}}z~~~||}~€~~~}|~€~}|€€}|~~‚€~~~‚€€‚‚‚€€€€€~„„ƒƒ‚‚„„††…ƒ„…„‚„†…‚‚„„‚ƒƒƒƒƒ„…‡ˆ‡††‡‡‡†……†‡ˆˆ‰Š„‡Š‹‡‰ŠŠ‰‰ˆˆ‰Œ‹‰‰‰ˆˆˆŒŠŽŠ‘ŒŽŒŒ‰ŒŽ‹ŠŠŒ‘‘’‘‘‘‘‘’‘’“’’’‘‘‘”•”’‘‘‘’’”•”‘”•““•”•“••••–••”–––”˜˜™–—’–—˜™™˜—––•š™˜˜™˜—˜ššœ™—™›š™˜–šœ›š›–›š™œ››š ¡ ›ž œž¡£¡žŸŸ ¡ ›¡¡ šŸ¡¤Ÿžž¡¤¢ £¦¦¥¤¥¥£ ¤¥£§©§¢¦§§§«¬«ª¨£ž™“‰xnfc_XOH>4# %* Q“¹¸´¶²¸¶¸ºº¹·²º¹»¶·´º¼½°¼º¹¶ºº»¾»´´¶º¶º¸½¼¿À¿¿¿¾¾µ¼º½½¾»»¼À¿À¼ÄÅÁ¾¿À¿»À¾Á¿Á¿¿ÀÂÃÃÂÂÁÆÇÇÆÄÁÉÇÊÄÅÀÇÇÌÊÌËÌÌstvvutstuvvvvvvvwzuxxxxyyzzzyzxwsxxwz|{|||{yx|~}z{yuz{yzz{z||{{|~€}{|{y|‚‚€~~}}{|~}}€€€€€€ƒ‚‚€€‚‚€‚„„…†…‚‚„…‡†…„…„ƒ……‚‚‚ƒƒƒƒƒƒ„„„…†‡†……„†††ˆ‰‰ˆˆˆˆˆ‰‰ŠŒ‰‰ˆˆŠˆ‡ˆŠŠŠˆ‹‰†Š‰‹ŒŒŒŽŒŽ‘‘‹ŒŒ‹ŒŽŽŒ‹ŽŽŽ’’’’‘’‘‘‘Ž‘’‘’’’““‘“”””“’‘”“•”““““””•—™™˜—•””—˜˜™˜—˜™™™™š˜”•”™›˜–™œ›™˜šž›™˜™˜——™›œœœœœ››œ››œ›š› ¢ žŸŸ››šž £¡œžŸ Ÿ ¡¢ žŸ¡¡ ¡¥¤¡¤§¦¥¤££¢¡¥¥¢¤¦¥¡¤§©«¬«¬¬©«ª¨¨¦Ÿ–‹‚toliaYPH</ \—¹¸¶¶¹¸¶´·¸¸¸¹¹¹»»·¶º¾¼¼»¼º·º¼¼¼º¸º¹º¹º¹¾½ÀÁ¾¿¿¾½¼½¾¾¾¿À¿¼¾¿ÁÁÂľÁÄÁ»¿ÂÁÂÁ¿½¾ÂÅÃÆÇÈÇÇÆÅÅÆÉËÉÉÉÊËËËÌËÌÌËtuvuuttuwvvwuutuxyyxxwxzyyxx{wwxxxyy{{{}~}zwy}~|{zyu{{yyz|~~|wzz}|{z{y{|~€€€{||}~€~}|~€€€€‚€€€~€€€{‚ƒ‚ƒƒƒ„†„ƒ„……„ƒƒƒ‚ƒ„„„„……ƒ„„…‚‚‚ƒƒ…†‡†ˆ‡„…††ˆˆ‹ŠŠˆˆ‡ŠŠ‹Œ‹‰‰†ˆ‰‰ƒˆŠŠ‡ŠŒŠ…‹ˆ‰‡‹ŽŽŒŽŒŒŒ‹ŠŽŒŽŽŠŠ‹’“‘‘Ž‘‘‘Ž‘‘‘‘‘”“’”•••‘‘‘”•—–”’’‘‘’““–˜šš˜•••˜™˜˜˜˜™š˜“—˜˜•–“š™˜’—š›š™—œ™œœ›š˜–™šš›žžž›œ›››žŸŸžžŸŸžžžž ¢¢¡ž¡¡žŸŸ ¢¢Ÿžž¢¡¡¢¢¢¡Ÿ¢¤¤¦¥¡ ¤¥¥¡¤¤¢¡¥§¨ª«§«¬«§§¦«ª§¥ ›”ކ{tba^VLB3) #bš¸·±µµ¶µµµµ¶¸¹·µºº¶¶ºº¼»º¹¼·¼·½º»»¾»¼»½»»¼ÀÁ¾½¿½½½¿½ÀÁ¿¼¾¹ÁÀ¿¾À¾ÂÄüÁÁÂÂÁ½¿¿ÃÆÈÈÇÅÄÀÅÄÇÇÉÂÈÊËÉÊÈÅÄÄÄÊÊtvwurutvwvtuuvuvxzwwwxxxxxz|{yyxv{z{{z{}}}zy|~z||{{{|{zzy€€}yy|}|{|{{|~}}z€~~~~~€€~}}€€‚‚~}~~~€‚ƒ‚‚ƒƒ„„„‚ƒƒ‚ƒƒ€„……„‚‚ƒ‚‚‚„……„†‡‡………†„‚‚„‡ˆ‡ˆ‡ƒ…†‡ˆŠŠ‹ŠŠ‰†‰Šˆ‹Š‰Š‰‰‹Š‰ˆ‰Š‹ŒŒ‹Š‡ˆ‰‹ŽŽŽŽŽŽŽŒ‹ŽŒŽŒŒŽŽ‘‘‘‘‘’‘’“‘‘‘‘Ž”•““””––••–•––•“‘’–—”•––——™—”–˜˜™™˜——˜™—•–˜——˜™™š˜“–˜šš™š›™››š™™™š›œœœžžžŸŸœ›šžŸŸ žžžŸŸž Ÿ¡¢¡¡ ¡¡ ž ¡¡ ¢¢££¢ Ÿ¡¡££¥¤¢ ¢¥¦¥¥¥£¡¤¥¦¦¨©©ª¬ª¨©«©¥©««©¥ž—Œ‚zqie[QH>1$ )j¶·¶µ¶·µ¶µ´¸»¼¹¶¸¹¸·¸¹ºº·¸¼¾¾¿¾¾¾½¾¾½¾½¼»»½½½½¾¾½¼¾ÀÁ¿¾¾¿¿¿¼»½¾ÁÃÂÃÁÂÁÁÁÁÁÃÄÆÇÇÅÅÅÆÇÈÈÇÇÈÇÉÉÉÈÅÀÅÆÃÉÌuyxuuvtvwvttvwwxyyxvvuvwxvz||xwxzzzz|zzw|||z}}{y}{{{|x|}~~}zz}~~~}z||~~€}~}}}~€‚}~€€~}~€}€€‚‚‚‚„…„ƒƒ‚ƒ€‚€‚ƒ…„ƒ~‚ƒ‚…„„…‚„…‡‡†„…‚„ƒƒ€ƒ…‡ˆ‡††††…Š‹‰‚ˆ„†‡ˆˆ‰‹‹‰‹ŠŠ‹‹‹Š„‰ŒŒ‰ˆ‡ˆ‰ŒŽ‹ˆŽŽŽ‹ŒŽŒŽŒŽŽŽŽŒ‘‘‘“’’““‘’“’’“”“•’•••–—–——•’•““”™˜“•˜™˜––•“————˜•••—““•––˜’š™˜—˜–™™›š™™™˜˜——˜˜˜š˜œœ™Ÿ žœ™›ŸŸž˜›žžž Ÿ¢¡¢¡¡ ŸŸ¡Ÿ ž¡ ¢žœ££¢¢£¡¤¢¡¡¤¥¥¥¥¤¤¥¥¥§¨¨©ªª««©¨¨¨¦¨¬¬®¬¨¥ š•‡xo]ZXOGB8-" /q¡¶¹·¸ººµ¹´¸º¹º¹³¸¹·¶¶·»º¸¸»»½½½¿¿»¼½½½¼»»º¹¹½¹¾»½»½¶ÀÀÀ¿¾¿¿¾À½»¹¾¿À½Á¿Á¿À¿ÂÂÂÂÄÁÄÄÃÂÅÈÈÄÄÃÆÁÈÉÅÃÇÅÆÈÈÄÉÉwzxtuwuwxwtuvwxywyxwutvywvy}zxyzzzy|}|yy{|||{}{{{{{}}|}~}|y||{{|{~€€~}{€}~~}}~€‚€ƒƒ‚€~€€€‚~€ƒ€‚‚‚‚„ƒ€‚‚ƒ‚‚ƒ……†ƒ‚ƒƒ…„ƒ„‚…ˆ‡†††……„„‚„†‡‡‡‡‡‡ˆŠŠˆ†…ˆˆ‰ŠŠ‹‹Š‰‰‹‹Š‰ŠŠ‹‹‹‰ˆ‰‰ŒŠŠŒŽ‰ŒŽŒŒ‰ŒŽ‹ŽŽŽŽŽ“”’‘’“”““’”••””•–’•––•–•””“””•—–•–˜™™•–––˜˜˜–——–——•’•˜——˜™™˜—™œ›™šš™˜˜˜™˜™šš™šœœ›œŸš››ššŸ¡œœœœžŸŸž›› £¡ž¢££¢ žŸ ŸŸ ¢¢ ¢¢¡¢££¢¢¢¡£££¥¥£Ÿ¢¤¦¤£¤¤¦§§§§¦¤«ª©©¨§¨ª«¬®¬©§¦¥ž”‰€xphe_XK?2( 4y¦¹º»»½¼»»»»¼¸¸¹¸¸ººº¹¶»¾»º¹¹º»¼¾½¹º¼¼¾½¾¾¾¼º¼º¼½»¼»»¿ÂÀÀÀ¿½¿ÁÂÁÀ¿¾¾¾ÁÂÁÀ¿ÀÁÂÂÃÂÂÃÄÃÃÄÆÅÅÄÄÆÇÉÉÁÅÈÉÈÈÉÉÈÉvxwtvxxwwwvvvvwwyxwwwrvxyx{|yv{|{zz|}}z|{{|}}}|||x{|}}|||{{{{zz|}~~€€~|}€|€€~€‚€‚€€€‚‚€ƒƒ€‚€€‚‚€‚ƒƒ~„„„„ƒ„„€ƒ‚€„…†††ƒ‚ƒƒ€‚„ƒ……†„…†…„„ƒ‚‚ƒ„…†‡…†‡ˆŠŠ‡ˆ‡…‚ˆˆ‰‹‹‡‡‡‰ŠŒŒ‰ŠŠƒˆ‹Œ‰‰Š‹ˆ‹ŠŠ‰Ž‘Ž‹‰ŽŽŽŒŒŒŒ‹‹Ž‘ŽŒ‘‘’““’’’””“”””•••’––•“’“•””’••–˜˜———˜——˜—–•““”˜–••˜•—˜™™š–˜››˜™”™™™—ššš™šššœœ›œš™™›œ›šŸ¡ŸžžžŸœ¡¢¡Ÿ¡ž¢¢ ŸŸžž›Ÿœ ¢¤¡££¢žŸ ¢¢¢ £¡¦¥¦¢ £¢¦¥¥¤¥¤§¤¦¤¦©ª«ª¨¨©ª§«®®¬«§¨¨©¦ œ—‡~vg_WQJA1' + <€«¼¼º¼»½½½¾½¸·µ¼¹¹º¼½¼¸¹»»º¹¸¹¸¹º»·»º»¹½¼¿Á¿º¾º¼µ¹¹º¹¾¹¿½¼º¾¿ÁÀÀ¿¿¾¾¿ÂÃÃÃÁÀÁ¿Á»ÁÀÃÂÄÀÁÁÃÃÃÃÄÄÉÉÈÉËÊÉÆÇÈÇÃuwuuwxvvwxxvvuuxyxuvwwvwyzzzvx{}|zz{||{~|z~}|{z{y{|}}|{}~~|x|{}}~~}~~~€€‚‚€~~€€€‚‚€€‚ƒ„ƒ}~€‚ƒ‚ƒƒƒ„…††„„„‚‚ƒƒ…††…ƒƒƒ„„‚‚„„ƒ„…„ƒ‚ƒƒ……ƒ…„„‡‡…„‡†‰‰‰‰ˆ…†ˆˆ†ŒŽ‹‡ˆŠŠ‰ŠŠ‰Š‰‰ˆŒŒŠŠ‹ŒŠˆˆ‹Œ‰‹Ž‘Ž‹‰ŠŽŽŽŽŽŒŽ‘‘“‘Ž‘’‘’‘“”’’‘‘’–•”““••”•”””’’”•””“”””™”•–˜—–•——–”’•—˜˜—•—––™—™š——›š™™˜—™™˜šœ›š™š›œœžŸšœœœž ¡¡ŸŸžžŸŸŸ ¢¢ ¢¢ ¢¡¡ŸŸŸ žŸ¢¤¤¢£¡ ¡¢¢¢£¤§§¦¦¦¤¡¤§§¨¤¤¥§§§¨§¥¥§ª©ªª««¨¬¬¨¨ªªª©¬¬¬ª¦¡šƒtmifYM@4( C‡®¼¼»»¼»½½¾½»º»¼º¹¹»½¾À¼¸»¼¹¹¹¸¹ºº¹»¼¼½¼»½ÁÀÀ¾¾¼»º¼½»¾ÀÀÁ¿¾ÀÂÁÂÁÀÀ¿ÁÂÃÄÄÄÃÂÂÄÃÁÀÂÃÅÅÅÄÄÆÅÂÃÅÄÆÈÈÊÊÊÉÇÅÇÆÃvvuvxwvuvxxwvtvyywurwyzyyuywyyzy{{|zz{z}|z~€}yzxzwz{}z||}~~|}}}}~~~~}~~€~}€|||‚ƒ€€{€~€€~‚‚~~|€ƒƒƒƒ„„„„ƒ‚…„„ƒ„‚†…„ƒ‚‚……„„ƒƒ……††…ƒ…‡…„…ƒ…ˆˆ…††††ˆˆˆ‡‡‡ˆˆŠŒŠ‹‡‰ŠŠ„ЋІЋ‰Œ‹‹Œ‹ˆ‡Œ‹ŒŒ‹‹ŽˆŠŒŽŽŽŒŽ‘‘‘’’’‘‘‘’’‘”“‘‘’”“‘‘’••“””•”’‘’”“”””••••‘–™˜——˜––——˜˜—•—–˜˜š–™™šš—™™–š›š™›™——™™œž—™œ›–›žž›˜œœ›šŸ ¡¡ŸžŸ ŸŸ¡ž ¡¡žŸœ¡£¢¢¡¡¢¢¡ŸŸ¢¤¤¡£Ÿ£¢¢¢¤§¤¥¤¥§§£¥§¦§¦¥¦¤¨¢©§¤¦£§¦ªªª§«©¦¤¦©«©©ªª«¬¬ª¤œ–‡wi^WPG>6' + HŒ®¹»¼¼µ¼»¼¹»º»¸¸ºº´º¶½¿¼¸»µ·¸¸¶µ¶¸¸¼º»¾¿¹½¼¾¾¾¼¾»½½¾»ÀÁûÂÁÁÀÃÃÂÀÁ¾ÂÃÃÅľÄÁÂÅÈÀÂÂÃÅÇÇÆÆÇÆÄÃÆÄÄÅÊÇÆÇËÊÈÈÆÃvvuwxwsvvwvxuuwyxvtuwzzyyxxyyzzxyz{ywyz{zz|~}|z{zvy{~~}|}}y}}~|}~}~}~~~~€}~€€€€‚€}}€~}€‚€€€‚‚‚‚€‚~ƒƒ„ƒƒƒ„……………†…„ƒ‚€‚ƒ…†„ƒ‚…ˆ‰ˆ†…„†‡‡‡†…‡‰‡††††…††„…‡ˆˆ‰‰‹‹‹Š†‰‰ˆ‰Š‹‹Š‹‹‰ŠŠŠŒ‹Œ‰ŠŽ‰ŠŒŒŽŒŒŽ‡‘‘‘‘‘‘“’‘‘‘’‘’“““”““‘‘““’‘‘“””••––••“’“”••”””•––”•—˜———”–—™˜˜™™˜———›œ››››˜˜—˜šš–™šœ™˜š›Ÿž›šœœœœžžœš››œ›œžžŸ ¡ŸŸ Ÿ ŸŸžŸžžŸ£££¡¢¢¢¢¡¢¡Ÿ¤¤¤¤¥¥£¡ £¦¦¥££¤¨¦¥¥¥¤¥¥¤¦¨©«©§¥¥¥¥¦§¨©ªª¨§¥¥¨««©©«ª©©¬®¯ªª¨¢™si`[PE91-& M¸·º»¼¼½»¹¹¹º¸¸¹ºº»»¼¼¹»»¶·»º¸¶¶¼¾¾½¸¼¾¿¾½¼½½½¿Á½»½¾¾ÀÀÁÂýÂÄÅÃÁÀÀÂÄÅÇÅÃÄÄÃÅÇÆÄÄÇÆÈÇÄÆÇÆÅÂÆÉÈÊÊÊÉÊËËÉÇÅÄutvwxxwvvvwwvvxxxvwwy{zyxxzyyyzyxvzyyxxxwy{||{||}x|{}~|{~}}~}}~~~~€€€€€€‚}€€€~}}~€}ƒ‚}€€|€ƒ€€€€‚ƒƒ‚‚‚ƒƒ„ƒ…‡ƒ†ˆ…ƒƒ€€‚ƒ„†„„‚‚„…ˆˆ†……‚††ˆ‰ˆ††‡†…††‡†…„……ˆˆˆ‡††‰‡Œ‡‰‡‡ˆ‰‰ŒŒ‰‡†ˆŠŒŠŒŒŒŠŽŽ‹‹‹Œ‹ŽŽŒŒŒŽ‘“’ŽŽ’’’‘Ž’‘’’‘‘“““““’’Ž’””––”•–”“”““”•”““”–•““”——–“•–—˜™–˜˜˜–—–˜™›šš™š™—–™›š™œž›—›šœŸž˜™››šœŸ›œœ›œŸ Ÿ–œ››Ÿ¡¡œœ›ž Ÿ›Ÿ ¡¢ œ ¡¤££¤¤££¤¤ ¢Ÿ¥§¥¥¥¤¦¥¥œ¥¤£¥¦¥¥¦©§§¦¦¦¥£¦¦¦§ª«¨§§§©¬«£ª¦«©¨©«¬¯±¯¬¥Ÿ—Ž‚qf[QIEA6+# \–´µ·º¶»¾¼º¸µ¶µ·¹»¼¼¹»¼»»»¹¹º»¸¸¸½¾¿¿½¸½½¾¾¼»¾¹À¿¿¼¾¼½¼¼¼ÁÂÁÃÅÁÃÂÁ¿ÃÀÄÅÅÅÄÁÂÃÄÅÅÅÆÆÈÈÇÅÅÄÃÂÆÈÈÈÈÉÊÃÊËÈÅÆ¿vwwvwxuvvxwwvwwxvwxwz{zyyzzyx{|{yyz{|{vttx{}~{{|}|||{z|}~}~€€}y|}~~~€€€€‚‚~{~z€}€€‚ƒ‚‚‚|„‚€€ƒ„„ƒ‚~„„ƒ‚†‡††‡„ƒ„„‚„†‡‡……†‡ƒ…‡†ƒ„††…†‰Šˆ„ƒ††…„…‡‰ˆˆ‰‡ˆˆ‡†††Š‹‰ˆ†‡Š‹ŒŒŒŠ‰ˆŠŒŽ‰ŒŒŽŽ‹Œ‹‰ŒŽ‘”’‘‘’’‘’“‘‘‘’‘“’’’‘’“’““••“’””“––’’””‘”’–•””•––—˜˜˜˜—˜˜–––—˜˜™š™˜˜™›š•–—ššŸ›››˜›žœ™š›š™š››šœšš›ž Ÿ Ÿ›› žŸ¡¡ž™ ¡Ÿ ¡Ÿž¡¢žŸ¡£¤¤¤¦££¤¥¤££¤¦§¤¤¤¤¤¤¤¤£¤¥§¤¥¦¦¦¦¤¥¦§¦¤¦¦¦§ª¬¨§¨¨¨¬«¨©®¯¬«©ª¬¯±°°¯¯¬¨Ÿ–Š~ogc^TL@5-$ fœ°µ···´µ¾»ºº¹·¶¶·»½º·¸¼»¹¹¼»¹¼½¼½¼»º¾¿À½¼½½»º¼¿¾¾¿¿À½¿Á¿»¾ÀÁÂÁÃÃÄÂÁÂÂÂÁÀÄÅÄÄÆÁÃÃÆÇÈÇÈÆÄÆÆÄÃÆÈÉÊÊÉÉÈÈÊÉÉÈÈwxwuxyxvwwvqvvwyywxwxzzzzzzvz||{zy{||{xvwx|}}{{y|}}|{u{||}}y~}~zyz{|}}~~€€€€ƒ‚€€€~€€€~ƒ„‚‚‚€‚€}‚‚€‚ƒ„„€€‚††„ƒ‚„…†‡‡…ƒƒ‚„†‡„ƒƒˆ‰‡†††ƒ†‡†…ˆˆ‡ƒ„†‡ƒƒ‚‡‰Š‰‰†‡‡‰‰ˆ†ŠŒŠ†‡†Š‹ŒŽŽ‹‰‹‹‰‰ŒŽ‹‹ŒŽŽŽŽŒŽŒŠŠŽ‘“Ž“‘“’ŽŽ’’’Ž’“’Œ‘‘’“””““’“”“““–—”•–––—˜———–”••–˜™˜˜˜™—–”•—˜˜˜——–˜˜™šš˜œ›—›œ›œ˜šœœšš—š˜š›š›œžž›žž ££žžž¡¡ ŸŸž ¡ œ¡ ¡¢¡¡¢££¤£¤¤££¤¥¦£££¦¥£¡¤£¥¡¤£¡ ¥§¥¤¦£§§§¥§¤¥¥¦¥££ª«¦§¤©©©¨©«¬¬¬«¨¨¨¬®¯®¯°®ª¢›”Œ€tj`ZRJA:3+" k¡¯´µµ·¶¸»ºººº¹´¸¸»´¸·¹¼»´º½½·½¿½´¼¸¼½¼¼½¼»¸»¶½½½º¾½À¾¿ÁÀ¼¾¼½¾ÁÂÃÂÁ¿Á¾ÂÀÁÃÅÅÆÈÇÅÅÅÆÇÆÁÄÄÇÈÆÄÇÇÈÊÊÊËÉÈÅËÌÌÇsvvuwxxwuwsuwxyzzyyxwyyzyxxy{|{{{z{|}{yy{{}}zz{|z{{|{y{}z~~~~~}{y||{|~~~}ƒ€€€ƒƒ„„‚‚‚ƒƒ‚‚ƒ‚ƒƒƒ‚‚†‡ƒ‚ƒ†††…ƒ€‚‚‚††„ƒ…‡ˆ‡†††…„„†‡†‡‡‡†…††‡‡‡‡ˆˆ‰‡†‡ˆ‰ˆ‡‡Š‹ˆ‰‹ŒŠŠŽ‹Š‹‹‡ŠŒŒŒŽŽ‘ޑޑ‘‘‘’’’’“’““’’“”‘‘‘’’’““’’“”•“•”’—–——™™™˜——˜˜——–••–——˜———˜˜———˜˜˜˜™™›››œš˜š›ššœšššš™—™›œžž™™ŸŸŸ ž››˜œŸ¡£¢ ¡¢¢¡ ¡žŸ ¡¢Ÿ¡¢£££¤¦¤¡¢£££¥¦¤¢¤¤¡¡¥§¦¥¥£¡¢¥§§¨§¨¨¨§§¦¦¦¤¥¦¦§ªª¦¦©©««©§«®¯«ª§ª®°¯®¯±²±®¬ª¦ ˜Žƒvoa\VPIC:. o¤²´´µ¸º»º¸¹¹¹·´¹»¹¸¹ººººº»½¾½¼½º¹¼¼¼¾½ºº½»¹»¾¿Á¿¿¾¼¿¿À¿¿À¿ÁÂÃÂÀÂÁÀ¿ÂÃÂÀÁÄÄÄÅÇÇÇÅÄÂÄÄÀÃÅÄÈÇÇÈÇÈÉÇËÍÉÈÉËÍÌÌvuusvuwwvxzxz{zxzxxxxy{|{||||zyzzzz}~zyz||||yx{{||{|{z{}~}€|€~}{|}~€‚‚€€€‚€‚‚‚‚‚~€‚ƒ‚€}‚……ƒ„…„ƒ‚„„ƒ‚„…„ƒ‚€ƒ„„‡†ƒ€…‚ƒ…„‚…††„……†‡‡ƒƒ…‡†††‡‡ˆ‡…†ˆ‰‡†ˆ„ˆ‡‡ˆˆ‡‰ŠŠ‰‰ˆ‹‡‰‰ŽŽ‹‡‹‹ŒŒŒ‹ŽŠŒŽ‘‘ŽŽ‹ŽŽŽŒŒŽŽ‘’“’“‘“‘“‘“’““’Ž‘””“‘“““••“–•—˜˜”–˜˜–”’—™™˜—”•–•”–’–”—˜——™šš•š™™šœ›››š“𙙙𛛙𕙛œžš™›œ›ŸŸœ™›œžŸ Ÿ ¢¢ž¡ŸŸžŸž¡ž¡ž¡ ¡ ¤¢£¥¥ £¡¡ ¤¦¤Ÿ¥¦£¢£¤¦¦§¥¥¥§ªª¨¨¦©¦§¡¥§¦¤£¤§¦©¨©¢§©©¤¬©§«¯¯®ª©¨ª®©®°¯ª®¯¬¯¯®¨¦ š’‡zq_YURE8& !r¨³µ´²º¼¼»¹µ¹µ´µº¸¹µ»¼»µ¹¹»¹¾º»¹º¹¼¶¼¾½¸·¹»µ½ÀÁºÁÀ¿¼¾¿Á¾¿¿À½ÃÃÂÁÃþÃÀÃÀÀÀÁÁÄÂÃÄÆÆÆÂÂÂÆÆÇÇÆÇÆÆÆÇÉËÌÇÇÈÉÇÌÍwvwwutwxxz{{||xyzxuyy{||{~}}|zx{{{y{}}yz{|yyy{|{|}{||{z|€€~}€~|}~€ƒƒ}ƒ‚}€‚‚‚‚€‚€‚ƒ€}~ƒ‚„…„†‡„„…„„„„†„‚~‚‚ƒƒ…‡…„……„…ƒ„††ƒƒ~‚†‰‡ƒƒ…„……†‡ˆ‡†……ˆ‹‰ˆˆˆ‰Šˆ‡ˆŠŠ‹Š‰‡ˆ‰‹Œ‹ŠŠŒŒŽŽŽ‹ŒŒ‘‘Œ‹ŽŽ‘ŽŽ‘‘‘’“‘“•”“”•––”‘’”””“•”““–––•––——”•–•“’–™š˜““•˜˜—–––––––—™››š››™šœœœ›š›š—™›šš››››š™™›œœœœ››œœŸ œžžŸŸ ¢¡ ŸŸ ¢¢¢¢£¢ ¡¡¤¥¥¤£¤¥¥¤¤£¡£¤¤¥§¨¦¥¥§§§§¦¦¦§ª«ª©¦¨ª¨¨§§¦¤¦§¨©©¨¨¨©ª©©ª¨§¬®®¬ª«ª¬¯®¬°°¯®¬««¯¯¯¯°°°®«¥’‡znd`UI<0" )w¬¶¸·¸¹¹¹º¸··¸¹º¹¹¹¹º¼¼¸¸º»½¼¹º»º¸¹ºº¾½»º»»¼¾À¿¿¿ÃÁ»½¾ÁÃÁÀÀÂÀ¿ÁÂÃÅÄÃÃÅÄ¿¿ÀÀÃÅÃÅÃÅÇÉÊÇÇÇÈÈÆÅÇÈÈÅÆÉËÊÈÇÈÉÆÊÎwvwwwtyxyzz{||zzyxwz|||xz{{xzzz{|||z|}}{{{{zy}}|||{{{y{}€€z€€‚€€€‚‚€‚‚ƒƒ‚‚…„}‚„††„„„…„ƒ‚……€€~‚‚€„…€ƒ…ƒ}…‡†„„…‡†…„€}…‡…„ƒ‚††‡ƒ‡‡‡‡‰‹Š„ˆ†ŠŠˆ„‡ˆˆ†Š‹‹‹Š‹‹‹Œ‹ŒŽŽŽŽŽŽŠŽŽŽŽŽŽŽŽ‘“’‘‘‘Žˆ’’’’‘””“’“”•–•“‘”’”“”””•˜–•––’—•––•’”•”•˜˜–”–—š™—”•–—’•–—˜š›››š™š•œš››œ—™™š›œ›–™šš˜žœšž žžŸžžŸ ¡ ž¡¡ŸŸ¡££ ž£¤£¢£¤¥£¤¥¥¤¤¥¤£¤¥¦¦¦§¦¥¨©©¦¨¦¥¥¥¥©©¨¦¦£§¨¨¨§¥¨¦ªªª¦¦§©©ª¨§§ª¬ª¬ªª«¬®®¨®¯°°«¬©¬««®ª±¯®¯²±«¥”‹|saWNC:2# 3~¯¸»»º¹µµ¶º¹º»»¹¹´º¸¸º¹··¸¹²º¹¹»»´¹¸»º½»¼¾½½¿»¾¿¾»À¼¾·¾ÁÁ¿À¾¾»¾¾ÁÁÂÂÃÅÇÂÁ»ÀÆÈÃÂÃÆ¿ÉÈÆÅÅÆÈÆÆÅÉÆÇÂÌÊÊÉÇÇÉÆÇÉxxwxxzzzwzzzzzzzywvy{||zyyzzxyz{z}}|{|||{{zxx}|||||{yxz}}€€~|}€‚‚€€€}€€‚‚€€‚~ƒ„„‚€……‚~€„†…ƒƒ„„„ƒ~ƒ…‚‚ƒƒ‚‚‚††‚€€„‡†…„†…………ƒ‚„…„…„„‚†‡††‡ˆ‡‡ˆŠˆ„‡‰‰‰ˆˆ‡ˆ‡†ŠŒŒ‹Œ‰‰Š‹ŽŽŽŽŽŽŽŽ‘“’‘‘’““’“‘’“‘‘‘”•““‘’“”“’‘’”“‘“”““”–˜–“–••–———•“—š™—–——˜—•šš™˜˜™˜–“’“—™š˜šš™™››œœ›™žžœ™˜šœ›žžŸ žŸŸŸŸ ¢žžžŸ¢¡¡Ÿœœœ ¡Ÿ¡£¢Ÿ› ££¢ ¢£¢¥¥¥¤¢¢¡¥¦§¨¦¦¤¤¤§¨©©¨§¦¦¤£¦¨¨¨¤¥¦¥£§§¥§¨©«ª§¦¨§¦¨¨§¦¨ª®¬©««ª«¬®¬«¯¯¯¬««¬«¯®®®³¶¶´°¦Ÿ“†wmbZOD8/& ;‡²¹»»º¹·º¼¼¼»º¸¸¸ºººº»¹·º»·¶¸¹·»º¹¹ºº¹º¹º½¾À¾»¾¿½½¾½¾¾½¾ÀÁ¿¾½½ÁÂÁÁÃÃÅÆÇü¿ÅÈÉÇÆÅÆÇÈÇÆÄÆÇÈÆÃÈÇÉÌËÈÌÍÊÆÉÉÈÊwwwwz{zyxyyxww{zxxwt{||uvx{{zyyz|||x{{|{{{{y{}{|}}}{{xz{|€}|~€‚€‚€€‚€€€‚‚€|‚…„„ƒ€‚ƒ„ƒ„…„„…ƒ‚‚„‚„„ƒƒ‚……ƒ‚‚‚ƒ„„………„„………†…††………†‡ˆ†„………„‡‡‡„ˆ‡‡†‰Šˆˆˆ†Š‹Œ‹Œ‹‡ŒŠŽŒŒŠŽ‹ŽŽ‹ŒŽŽŽ‘‘‘“‘‘‘‘‘’‘“–•”’‘’””““–•“”‘‘‘‘——–”•”•’–—˜”—š™˜™™˜š—•˜šš™™–™˜——˜–š•˜˜™™™—›šœ™›œœ™žžššš›œœœœ›ž Ÿžž ŸŸ ¢¤Ÿž›ž žžœœŸ Ÿ ŸŸžŸŸ¢¤¢¡¢¢¤¥¥¤¢¡£¤§©¨¤¦£¤£¤¦¨§§§§§¦¢§¦¨©©¨§§§¦¦¦¦¦¨¨¨¨¨¨§£§¨¨¦¥¥ª«ªª«¬««¬«¬¨«§¬¬¬¬«¯¬«ªª¬®²³²®±¯©¢›•Šzp^VNG@8/& @ˆ³¸µ¹·¹¶»¹¼¼º´¹ººº»¼»·¶·»¾º·¸¹¹µº·ºµº¹¸¶¹»¾º¾¼¾¾½½½½¾¿¿¾¿¼À¼À½ÂÀÂÃÅÃÇÆÇÂĽ½¼ÈÊÉÅÅÄÆÆÇÂÆÈÊÈÆÂÈÈÈÉËÈËÌËÈËÆÉÇwvw{{zyxwxzzyxxxyzyzz|zwvxy|{zzz{}{{{{||{|~~}||z|~~z{{y€~€‚‚€‚€€€‚‚€€€‚‚€€€ƒƒƒ„……„ƒƒ„…‡…„……„„„„ƒƒƒƒ€€ƒ„ƒƒƒ„…„ƒ‚†……†…‚…„„……ƒ‡†„‚ˆ‰‡„ƒ„„„„†…†Š‰‡‡ˆŠ‹‡‰ŠŠŠŒŒ‹‰ŠŽŒ‹‰‹ŒŒŽ‘ŽŽŒŽ‘‘’”’Ž‘‘‘‘‘’‘‘‘‘’–•”“’’’““””•——–“’”’–˜–“––•’”–˜—˜˜–—˜˜—𙕗™™˜˜™šššš™™šš˜–™›š—™˜šš—›œ›žžš›œœ›žž›œŸœžŸ¡¤¥¡ŸŸ žœœž Ÿ¡¢¡ ¡¡ ¢¢ ¡£¦¤¢¡¢£¤¤¤¤¥£££ª¨¦¥¤££¤¥¦¥¦¦£§¨¨¦¦¥¨¨¨ª¬ª§¥¥§¦¨©ªªª«©¦§¨©¨§§¨§§©«®®¬ª©¨ª««¬®®®ª°¯ª¬¬¬¯±²²³´³±°¨ž‘†ymf^UMC8( MŒ´·¸¹¸»¼¼»»º¸¸º¼º¹»»º¹¹¶º¾¼¸»ººº»½»»º¼»º»½¾¿¿½¿½ÁÂÀ»¼Á¾À¾ÁÁÁÂÃÃÅÇÇÇÈÈÇÇÅÅÃÄÆÉÈÇÅÄÇÉÉÈÈÉÊÉÈÈÉÈÇÈËËÊÉÉÌÍÌÊÊxyzzzzyvyyz{zwvvyyyxyyzyxyzzz{{wzw|~}z{{|~€~~~{{|}{}~€€€€€|‚|€€€‚‚‚€€€|€‚ƒƒ„ƒ‚‚‚……ƒ„„„‚ƒ„…‚„‚…†…ƒƒƒ„ƒ‚ƒ††…€„…„‚„†‡‡ˆ…ƒƒ‚‚†„…††……‡‡ƒ‚‚ƒƒ„…ˆ‡ˆ‹Š‡‡‰‹Š‡Š‹Š‹ˆ‹‹‹Œ‹Š‰ŒŽ‰ŠŒŒ‹ŒŒŽŽŽŒŽ‘‘”“Ž‘‘“”“’““”•”“”““‘““••—–“•–”‘–”–“˜™•‘•˜˜˜—––—˜˜—˜—–—˜™˜™™š›š•—š›™™–šœ›™˜—™››œœœžŸš›žœœšœžŸŸž ŸŸ˜ž £¤£ Ÿ¡¢žœ Ÿ ££¢¡££ £¡¡¢¢¢¥£¢ £¢¤Ÿ¤¥££§¨§¤¥£¤¤¤¤¥¥¦¥¤¥¨§¦¦¥¤¤¡ª«©§£¤¦©ª«ª©ªª¨©¬«¦¨©©¢¦¦ª¨¬«ªª«©¬«¬ªª¬®«©±²¯®««®®°±±±²±´µ±¯ª¤›’Š{naZMB7.% + Z”·¸¸¼º½½½»¹¶¶¶·µ·´µ´º»»·»¶¼¹¹¹¹º¾µ¼ººº»»¼º¾¿¿¼¾½ÁÁÁº¾ÃþÀ½Á¿ÁÀÃÄÆÃÆÅÇÃÇÄÅÀÅÃÅÅÉÇÆÃÈÉÉÉÈÈÈÅÉÉËÇÉÊÌÇÊÇÊÍÏËËÈxzzxyzxyzzxzzyxwvxyxxxy{yxxyzzyzzz{~}|{z|}~~~{{|~{z{€€|€~ƒ‚€€}€€€€€€€€}~€‚ƒƒƒ‚€„„ƒ‚ƒ‚………ƒ‚……„ƒƒ…ƒ€„…‰‡………„ƒ„…„ƒ„†‚‡‡…‚„…†……„…‡‡‡†……††ˆˆ…ˆˆ‰‹Šˆˆ‰ŠŠ‰‹‹‹Š‰Š‹‹ŒŒŒŒŒŒ‹‹Š‹‹‰‹ŒŒ‹‹ŽŽ‘‘‘‘‘’Ž‘•”“’“•—•“’’“”’‘’’’”•—–•“•—–—–••–˜™•’–˜˜——–˜™™˜˜˜˜˜˜—”—˜™™š—“•š››™–šœ›š˜™ššœœœŸ™—žžœ››ž ¢ Ÿ ŸŸ ¡¢¢ £¢¡ ¡ Ÿ ¢£¡Ÿ££££¤¤¢Ÿ¡¤¦¦¦£ £¤¤¤¤¤§§£¤¥¦¦¥¥¥¦¥¥¥¥¥¦¥¤¥¦¥£¢©¬ª©¨©ªªª«ª¦¨©¨«¬«ª¨©ª¨§¨©§¨§ª«®®®¯¯¯°¯®®°°®®««¬®®®¯±³´²¶·±¬§ “…uj^UKA70( #a™¹»¼½¿»»¼¾º··¶¶¸¸¸¸º»½¼ºº»»¼º¹»¼½½»ºº»¼¼»º½À¿»¾¿¿Á¿¾ÂÃÁ¿ÀÁÁÀ¿ÂÇÆÄÂÂÃÅÅÅÃÃÄÆÇÈÈÇÇÈÈÇÆÉÊÉÇÄÇÉÊËËÌËËËÌÌÌÎÎÌËxyxvyzxwwxxxyyyxxwxxyzzzywyzzyyy{|{z}||xz{|}}}||}}~}{|€~~~€}~}€{€|~~€€€}€€€€ƒƒ€„……„‚ƒ…†„ƒƒ…ƒ„„‡ˆ…‚†‡…‚………†‡…‚„„…„……„……ƒ„…‡‡†††„ˆ‰‰„„„ˆ‰‹Œ‹ˆ‰‰‰‰ŠŒ‹‰‹‹‹ŒŒ‰ŠŠŠ‰‰†ŠŒŒŒŒŒŒŒ‰ŽŽŽŽ‘Ž‘’’’•’••“’”“’’““•“——–’•—˜™˜“•”—˜—“”––•—”—˜—•˜™˜˜˜””•–————”—™›œš–šœœœ›•šœ›˜›žœœ Ÿž››™žŸ Ÿ Ÿ Ÿ› ¡¡Ÿ¡¢¡ ŸŸŸ¡¢¡ ¢¡£¥¤¢ £¤¦¦¥£ ¢¤¤¤¤¤¦¥£¡¦¦§¤¥¦¦¥¥¥¦¥¥¥¥¥¦¢¥¤¨©¬ªªª©ª©§¨¨ª©¨§¬ª©¨©««©©©©§¨§ªª¬®®¯°°°°®°®¯®¬¬¬¨¦§¨©®¯®¬°³³¶·µ¯²²¬¤œ”ˆ{lTMGA:2% +gš¶»¹»¸»·º·¹¸ººº¹º¹º½¿¾¼¹º¼¼¼»·½¼¿»¼¶¶·ºº»¼¾¿¿»¿ÀÁÁÄ¿¿Â¾À½Ã¾Á¿ÁÅĽ¿ÃÁÄľÅÇÆÅÆÅÇÇÈÃÈÌÌÈÇÆÄÄÊÍÎÆÈÈËËÌÆÎÌËÉxywwz{wvqwxwvyyyyyyyy{zzzyz{{{xzz}||}~~|x{zz|~~|y}|~~}{~€€}~}€€€~}zz€€€ƒ‚€‚€€€ƒ„‚€‚ƒ„…€‚„†…„ƒ„†ˆ†………ƒƒ††‚„…†ƒˆ†…€ƒ„††…………„………†‡ˆ…‡‡†ˆ‰‰„„„‡ˆŠŒŒ‹‰ˆ…‡‰ŒŒ‹‰ŠŠŒ‹‹‹‹ŒŒŠ‰‹ŒŒŠ‰Œ‘‘‹ŽŽ‘ŽŽŽ‘‘‘‘‘Œ‘‘‘’“•–“’–•”“””“•˜——–”•–˜˜——••–™˜—––˜™˜—––––˜™———––˜˜——™˜˜™›œœ›ššš›œ›šœœœœžžžžžžŸ ›œœŸ¢¢Ÿ ¡Ÿž ŸŸ¡ ¡¢¡ŸŸŸŸ ŸŸž ¢¡¡¡¡¢£¢¡¡¤¤¤¥¥¤¡¡¢£¢¦¦¥¤¢¤¤¦¥¤¤¦§¦§ªª©¦¦¦¥¦¦¥¥§¨ª©¨¨§¨©§§ª«ªªª¬ª¨©«¬«ª««««ª««««¬®®®¯¬¬±´²®«¬®«®¬¬¯±°¯¯®°°±³³³´µ·¶³²®§ž‘…uh]VMD8, 4nž·ºº¹ºº¹¹º¸º»½¼º¼»»¾¾½»»º½¼¼¼¸½¿¾½¼¼¹¹¼¾½½¾¿¿¿¾ÁÂÃÃÃÀÃÁ¼¾ÀÂÃÂÃÁÁÂÂÂÄÃÂÀþÄÅÅÅÅÄÄÆÇÈËÌÌÉÇÉÈÅÈÍÍÊÈÉÊËËÇÍÍËÉxyxuz{wvwwxyyyzzyxyyz|}}zzzwz|{yz}}|}{~}{x{}~}||~~{}~|}}~~~~}}~|~€€|}~‚€~„„€€‚‚€~‚ƒ‚‚‚„„ƒ‚‚‚‡ˆ‡‚…„……†‡‡†…†‡ˆ‡……„ƒ„†††„ƒƒ…„…†…ˆ‡†‡ˆ‡„„„……†‡Š„‰ˆ‡ƒ‡‰ŒŒŠ†ˆŠ‹ŒŒŒŒŽŒŒŒŠ‘ŽŠŽŒŽŒŽ‘‘’‘‘‘‘‘’‘•–’”––””–•‘“•—––••“–”–•–’––™˜–•™™˜˜—•—————––“˜˜˜——˜™šš˜›œœœš—›œœ›œš›œœ›œœ–ŸŸ›ž˜Ÿ¢¡ Ÿ›žŸŸžŸ £¢ŸœŸŸžŸ ž Ÿ¡ ¡ ¢££ ¡¡¢£££¤£¡œ¢ ¥¦¥£¥¥£ž¥£¤¥¦¥¨¨ª©§¦¨¥¦¤¦¦§§§§¦¥¦¤©¨¦ª«¦«¬©¦¨¨ª¬©¬¬¬ª¬«ªª¬¬©²³±®®®¬¯°®®¬²±°±±±°°¯®²³³¯´³³®²¯ª¤œ“‡tfZQG;3+# 3s£º»»º¹»¸¼¼¼»»¶»¹½¼¼¼¼¹»º¼½½¼½¸½¾¾¸¾¾»»½¿¾»¾¾ÀÀÀÁÄÂÄÀÀÁÁ½½½ÂÂÁ½¿ÀÂÀÁÁÁÂÂÃľÄÂÁÁÈÆÅÅÇÈÊÈÇÈÊÉÇÇÈÊËÌËÊÊÇÇÇÌÌËÉuwwvz{wyxxxyzzwyxz{zz{||z|{yz|{y{|}}}~€{zz}~~|~}~~~}~~||~€~~~€~€‚~€~~„„€‚€€€€‚€‚ƒ„„‚‚ƒ…†‡†…„…………†‡‡„…‡ˆ„……„‚„††…„„„…ƒ‚„……‰ˆ……†‡…‡†…‰‰ŠŠ‹Š‰ˆ……ŠŠŠ‰ˆ†Š‰‹ŒŒŒŽŽŽŽŽŽŽ‹Ž‘‘ŒŠŠŽ‘‘‘“‘’““’”““••‘’”–••’–•‘’•–•––””•––—––—˜™˜””˜™˜™˜———•””••”—˜˜–™š››™™›œœœ™›Ÿœœ›œœ›™œ›ššž šŸžž Ÿžžž¡Ÿž¡¡ ¢¢ žŸ¢¢Ÿž¡¡ ¡¢£¢¡ ¢¥¥¤ Ÿ ¢¢¡£¥£¢¡£¤¥¤¥§¥¢£¤¤£¦§¨¨©©¨¨ª§¦§¦§¦¤¨ª¨¨¦§©©¨§¨©ª©©ª©¦§©¬¬¬««¬«ª«¬®®¯¯«¬°±²±°°±¯®®¯®°±°±²°¯®®°±°±³µ´µµµ´´²®¤™ƒqgURI@4) 2w¦»ºº¹·º¾½¾¾¼»»ºº»½½»»¼»¼¼½¼½¾¼»½½¾¿¾»¾ÁÀ¾¼¿¿¾ÀÁÂÄÃÃÄÃÂÁ¿¾¾ÃÃÁ¿ÁÁÁ¿½ÁÃÃÅÇÆÅÅÃÄÅÇÇÆÆÅÇÇÆÇÉÊËÊËÉÈÍÐÎÍÌÉÉÌÍÌËÊtvwwyyyxyxy{{{{yy||{zwzxx{|zz{zy|}}~}~~||||}~}~}}~~~~€€~€~€€~}}|~~€€€€}||€~‚„……ƒ‚‚‚{}€ƒƒ‚ƒ„‚‚…ƒƒƒƒƒ…„ƒƒ…††ƒ††…„…‚‚ƒ…†……†††…†„……‡ˆ‡„„†‡†ˆˆˆŠ‹‹‹‰‹ŠŠ†ŠŠˆˆŠˆ‰‹‹‹Œ†ŒŽŠŽ‘Ž‘‘’ŽŽŽ‘’’“Ž’”””””‘””“”””•—–“’’”•–•–’’’•–•‘••—™š˜––™—˜˜˜•˜˜—–––—”˜”™——–š™™š›™™™œžžžœœ›žŸœ™œšš› Ÿ›šœžž›Ÿžž žŸ¡£ ¡¡¡Ÿ¤¦£ ¡££ ¡££¢¡›£ ¤¥¤¢¡Ÿ¢¡£¥¥¤££¦¢¨©¨¥£¡¢£¥¥¥§¨©ª¦§§¨¨¦¤§§§ª«ª¨¨ª©§§§ª«ª§ª£©©©©®®«¬«¨¬¬¬¯¬®¬§¯¯¯¯«±±¯®®«®¯°¯±«¯²²¯°¬°®°¨±°µ¶µ³¶¶µ²¶²¯«§¢›ƒreYOE?82,'" 0w§¸¸µº¸¼¾½·½»¼¼º¹»½¾»½½¾½»»»¼¼»ºµ½¸¾¹¼½¾»¾¿Â¼½ÀÁÁÂÀÀ¿Åľ¿ÂÃÂÁÂÄÃÁÀ¿¼ÄÃÆÆÇÇÅÁÅÈÉÁÈÆÅÃÅÃÄÄÊËÌÌÊÇÉÊÍÌÍÌËÌÏÎÌÇuwyywyxxxxyyz|}|z|}|yzzxuzzzz|{{|}}}}}}}|{|||}~~|}|y}{{}€€€€}€}}}}~~~~~~‚€~€€~‚„„„…„ƒ‚‚ƒ|~~}‚„„‚‚‚ƒƒƒƒ„…„‚‚‚ƒ…………„ƒ…††……†††…ƒ„……ƒ„†‡‡ˆ‡†††€‡††ˆˆˆ‡‡†‡‰‰ˆ‡‰‹Œ‹‹Œ‹†ˆŠŒŒŒ‹ŒŽŒ‹‹ŒŒŽŽŽ’Œ‘ŒŽ’’’””“‘’””“’‘’““•”’”—•”•———•–•“‘“•••–”“•˜™™™š›™———™™™˜˜˜˜—–—™™˜––™ššœ›™™˜œžœš››œž œ˜œž›ŸšœœŸ¡¡žœŸŸ ¡£¤£ ¡¢¥¦¦¤¡¢¤¥¥£¢Ÿ¡¢¤¢¢¢¢¡¡¡ž¢£¥¥¦¥££¦©ª©¨§£¢£¦¦¤¤§¨©«©¤¦©ª¥¢¦©©«ª¨¨¨ª©¨¨¨«¬«©¬¬ªª¨«®®«®®«¬¬¬¬¬®¯®®°°°¯®¯°±±²±¯¯°°±±³³²±°°´´³´³µ´µ··´³´µ´²¤šƒsdYWQLE?7-# .w¦º¸¹»½½¾ºµº»¼¾½»»½¿½¾¿¾¼»»¼»¼¼¼»»¼»¹»¼»¼¿Â¿º½¿À¿ÀÀÀÂÃÄÃÂÄÇÄÁÁÃÄÄÃÁÀÀÃÆÅÄÅÇÅÀÇÉÇÇÈÈÇÆÇÉÈÃÈÉÈÉÉÊËÊËËÍÎÌËÍÍÌÎxvy{{yzxxxyyyy||zz{||||zyzzy{}|zzxzz|x}~}y{z}~~~~~|}~}z~€€€~€~}|~~{€€€ƒ‚€}~‚ƒ‚€„„ƒ‚‚}‚‚„„ƒƒ‚€ƒƒ„„„„„ƒƒ……†‡‡†ƒƒ†‚ƒƒ…‡‡…„„……„„†ƒ†‡‡ƒ†‡‡‡ˆˆŠˆ‰†††††…„‡‰Š‡‹ŒŒ‹‰‡‹ŒŽ‹ŽŽŽ‹‹ŠŒŽŒŽŒŽŽ‰ŽŽ‘ŒŽŽ‘Œ‘‘’“”““’’“”‘””’‘‘“–•‘”“’”—˜™˜–––••“”•–••’‘‘–•—™š™˜’—˜™™˜˜™˜—•˜˜™———›œšš—šš›œ›››š›žš›™žœŸ žžžžšœžžžŸ ŸŸž¢Ÿ¤¤ Ÿ¢¢¥£¢Ÿ ž¦§¥£¡œ£¥¤££¢¡¡ œ¢ ¦¥¤¤£ §ª©¥§§§¦¦¨¦¢¤¥§¤¨¨§§¨¨§¤§¦©¨¨¨©««ª©¤©¨«ª«§®®«¨«®°«®¯®¯¬«ª®ª¬¬¯¬®°±²®¯°²°®±°°®¬¯±±¯´¯¯®®¯³¯°³±®´·¶³³´´´´´°®¨£š‘‡yo]WSTPKC:) ;€©¶µµ»¸½¼¹µ»½¼º¾¼¼¸À¾¿»½¹¹º»º½¾½»»ºº¹½¿¾½Á»¹¸¼¾¿¾¿½ÂÄÄÃÅÂÆÇûÃÃļÄÃÁÀÂÃüÂÇÅÀÆÆÅÇÉÊÉÉÉÉÈÃÈÇÈÂÊÌÌÉÈÆÊÌÌÌÌÊÏÏyuy}{zyxwwxyzy|{wzz{{{zzzzzyz|yyyxz{zz|}}{{|}~€€}}€~~€€€‚‚€~€€~€€€‚‚‚‚ƒƒ‚€‚ƒƒ‚‚‚‚‚‚ƒƒ„„‚……„„ƒƒƒƒ„„„……†‡‡‡†„ƒ…††„…††…ƒƒ…………†††††‡‡ˆ‰‰…‰Š‹Šˆˆ‰†…‡‰‰‰‰‰‹Œ‹Œ‹ˆŠŒŒŽŽŽŽŽŒŒ‰ŠŒŽŽŽŽŽŽ’‘’‘’”’’‘’‘“”’“•–‘‘––•””“””–—–“––––•”••–•“””•–”˜™šš˜˜˜™™˜˜˜———˜˜˜™˜™œž˜˜™™›œœ›šœ›ššœ›œž žŸžŸžœŸ £¢¡ŸœŸ¡¢¢ŸŸ¡£££ ¢¤¥¥££¡¡¥¥¤¤¥¢¡¡¢¤¦¥¦¤¥¥¦§¨§¦¦¨§¦§§¦¢¥¦¦¥¥¥¦§¥¥§ª««ª¨©©«««©¨ª¬©ª«®¬¬¬®¯®«¯®®®°°®¬¯°±°°°®«®®®±²¯®±³¯¯²´±®¯«¯±¯®²²°±±±¯¯±®°³¶µ²³´³³²²³´´³²°©Ÿ’†zqlkg`VK8'I‹®·´·¼¾½º¸¶»½½¾½½½¾¾¿¿¼¼»º¹½½»¼¼½½»º»½ÁÀ¿ÀÀ½¼½ÁÁÂÁÁÃÅÇÈÆÅÅÆÃÂÃÅÄÄÅÇÅÅÅÂÂÁÃÇÆÄÅÅÅÇÉËËÌËÉÈÈÉÊÉÌÍÎÌÌÌÌÊÉËÍÎÐÑÏzvyxyyxvxvyzzxzzyzz{{{{{zv{{|zz{zx{||z}|{{|}}}€|€~}~~€€‚‚ƒ€‚}€}ƒ‚€~€€ƒ„ƒ‚‚‚ƒƒƒ‚€€„………††…‚‚„……„„…††‡…„„…ƒ†ˆ‡ƒ„††…„†‡…„††…„„†‰…‰ŠŠ‰ŠŠŠˆˆŠˆ…‰Š‹‹‰‰‹Œ‹‹‹Š‰‰Œ‰ŒŽŽ‹ŒŒ‰ŒŽŽŽŽŽŽ‘‘‘‘Ž’’‘‘“”’‘“””•’•––‘‘”•“”“’’’“•”•”“””•••–•””“–—˜˜™š›š™——˜šš™–•–˜–˜˜™šœš–™™œœœ››™š™˜™ŸŸ›—Ÿ›Ÿœ›žœœ—Ÿ ¡¢¡ žŸ ¡ŸŸ ž Ÿ ¡£¢£¦£ ¡£ ¡£¢¡¤¦¦¦¥¥¥§§¥§¥¤¥¦¦¥¤¥¥¥£¦¦¦¦¥¦¦¦¥£§¬¬ª«««ªª¨©¨ª¬®®«©ª§ª¬®ª®°®©®«°°®®¯°°¯°®®¬ª¯°®¬°¯±±°®¬°±±®±±°±²±°°±²²±³µµ±´°´µ´±³µ´³··µ±¬§¢š‘…}hd_RD9+& Y™µ¼º¹¾¿½¹¸·º¶½¾½»¾»½º¿¼¼¹¹º¾¸¸·»½¿¸ºµ½À¿»¾ÀÁÀ¿ºÂ¿ÄÃÂ½ÆÆÅÁÅÄùÃÂÂÁÅÇÇ¿ÈÅÃÁÃÆÆÅÄÃÆÃÈÆÊÈÊÈÈÉÌÊÊÏÏÈËÍÎÍËÉËÊÎÐÐÏz{yxz{zzzzzzyyxzzxw{}|{{zz{||}~|xy{|}~z{|||~}}€~~~~|{|‚‚‚~~~~}„‚€~€‚ƒ}~ƒ‚‚„„‚‚ƒ‚‚„„………††„„„…†ƒ…………†„ƒ†‡‡‰†‚‚‡†‡†„†‡„„ƒ„…„ƒ†‰‰ˆŠŒ‹…Šˆ††‹‰ˆ‰Š‹Œ‹‹Œ‹‰ˆ‰ŒŒŒŒŽŒ‹Œ‹ŽŒ‹Ž‘‘‘Œ‘’‘“”“’”•–••–•”‘“”“’”““’“•—•”““”••“’––•‘“—˜˜™˜™šš™–š›››š˜—–˜™™™™™šœœ››œ››œ››ž šœœœ›››œ›œŸ ž¡¢¢¡ ŸŸŸžŸ Ÿ ŸŸ¤¥¥¥¢Ÿ¡¡ ž¢¢£¤¦¦¤ ¤¦¦§¨¨¦¢¥§¥¤¤¤¥§¨¦§¨¨¨¨©ª©¦¨©¥¦ª¬©ª¨©ª«¬«©«ª©«®®®°³±¯«¬¬¯®®°®¯°°®¬®°±±¯®®¯®®¯°¯®°±±°¯²²±³²°±³´±±²´µµµ´´·´±µµ¶´¶¶¶¶·¹¸¶¯¨›†{mbVK>5+#+h¡¹¾¼¼½¾½ºº·º½½½½¿½¼½À¿¾¼¸¼¿½¶»¾¾¿¿½¼½½¿¿¿ÀÃÄÂÀÀÂÅÄÄÂÁÄÇÄÃÄÅÃÂÁÅÅÅÃÃÅÇÉÈÅÃÄÅÇÇÈÄÇÈÉÊÉÇÈÈÇÉËÊÉÎÌÇÌÎÎËËÌÍÎÍÎÎÍyyyw{{{{|{zwyzy{{uwz||yxz}~||~{z{||~~}~~~~~~€‚€}}~~€€~€€€€€€€‚€€‚€€‚‚ƒ‚‚ƒ‚‚‚„…ƒƒ„ƒ‚ƒ„ƒ„„„„„…‚ƒ„ƒƒ…†‚…‚„„…‡ˆ‡……‡‡†‡‡„†ˆ†……†‡…ƒ‰Š‰‡ŠŠ‰‰Šˆ‰‹Š‰ŠŠ‹ŒŒŒ‹‹Š‡‹ŒŒŽ‹‹Œ‹Š‹ˆŒŽ‹Œ‘‘‘’‘‰’‘Ž“•”’’“”“––••”’”••––––””’”‘—™–““•––“•–˜˜•”—˜™™™—™š˜–ššš—œššš™™ššš—›œœœœšžžžžžžžš™˜›››œ›žž Ÿ ¡¢ ž Ÿ œŸ žž£§¦¤£ž ¡¡¢¤¤£¥¦¤£¢¥¦¥¥¦¤¨§¢¢¨£¥¦¥¥¨©ªª¨¥§©ª««§¨¤¦¥¬¬«¨©©©ª©©«ª©«¨«©ª§¬¯±±®¬¯ª¯¯«¯²²®¯¬®¬¬¬²²±±±¯®°²°«²³²°²´³±³²±³µµ³±±±¶´µ´´¶´±³´µµµµ·°·¸º´¸·²¦ž•…x`XQIA8,% $8r¤¹»º¹º¼¼¹º·»½½»½¿¾¹½¼¾¾¼¸¼»½¸¾½¿ÀÀ½¿¸¾¾ÂÂÃÃÂÁÁÁÁÂÁÀÃÃÃÁÀ¿ÀÂÅÅÄÆÇÆÃ»ÅÇÈÆÇÆÄÃÈÇÆÅÇÅÌÍÊÇÉÉÈÆËÉÊÉËÉËËÊÊÌÌÌÍÎÎÎÎyzz{zz||{zyxz|zzzzyz{{yxw}~|z}|||}|{{}~~z~€‚€}|~€€}}}~‚‚€€~}~}€ƒƒ„…‚€}‚ƒ‚‚‚ƒ„„„‚‚‚~‚ƒ‚„†‚‚ƒƒ‚„‚ƒƒƒ„…ƒ‚ƒƒ‚ƒ……†††„ƒ„††‚‡ˆ‡……††ˆˆ‡††‡‰‰ˆˆˆˆ‰†‡ˆˆ‰Š‹‰‰Š‰ˆŠŠŒ‹ˆ‹ŒŒŒŒŒ‹ŽŒŠ‹Œ‹Œ‹‹ŒŽŽŽ‹‘‘Ž‘““’’’“’’”–”’‘’““––“””“••–˜˜——••—•“–™—“”————”—™™˜–•—˜˜˜˜——š™˜•—šœœšœžœ˜™™šœœžžžž›œœœŸŸžŸžœœ›šœœŸ ¢¡ŸŸ žžŸ¢¥¢ŸŸ¡¡ ¢¢¡¥¨¥£¢ ¤¥§¦¤¦¦¤¢¤§§¤¥¦¨¨¦¢¦¨§§¨¨§§¨««§¤¤¨¨«ª©ª©¨««¬¬¬«¬¬«¬¬ªª®¬©«©¨ª¬®®®¬¯¬®¯®ª®°²²¯®®®°²±²²±°®°°°²²±²²²±±²²²³±²³µ´´²²³µ¶µ³²µ´´´³··¶¶¸¸¶¶¸¹·¸ºº·´°ªœŒ€ti`UKB;2.,%+<S{¦¹½º¹º»»ºº»¼½½ºº¿¾¼»¹»½¼¼½¾¿¿¾¾¿ÁÂÀÀÂÁÃÄÄÃÂÀÀÁÄÅÄÀÀÃÂÁÀÀÀÂÂÆÅÄÆÈÇÃÂÅÈÈÈÈÆÇÃÆÈÉÊÈÈËÌÈÇËËÊÇÊËÉÉÉÌÎÎÌÍÎÍËÌÎÏÏÐz||{zy{}|{zzz||y||zzzyzyz}}y||{{|}{uy|~~}}€y{|~€€~€}~‚‚€}~‚ƒ„„€‚ƒƒ‚‚‚‚……„ƒƒ‚‚‚…„ƒƒ‚ƒ‚‚‚„…ƒ‚‚€ƒ„………†…‚ƒ„…†ˆ†………†‡ˆ†††‡†ˆˆˆˆˆ‡ˆˆˆˆˆ†‰††…ˆ†‰‹‰„Š‹‰†ŠŠŒŒŒ‹ŒŒŒ‹ŽŽŒ‡ŠŽŽ‹‰ŒŽŽ‹‹‹’‘Œ’“‘’“Œ‘”“Ž‘“•”“’’“”‘‘‘““”’”•—–••——––˜—”–šš—–“˜˜™™—–––˜“˜——™š™™™šš›•œš–——˜š›œœ›œœœœ—œ›š››ž››žŸœŸž››šžž Ÿœžž ¡Ÿ›¡£¢¡ ¡¡ ¢£Ÿ¥£¥¥¤¡¢ ¤¤¦¥¤¥¦¥¤¥¨££¤§§¨¨§¦¨¦§§¨©©¥ª«©£¥§©©©¨¬ª©¥«««ª«®«¬¬ª¬¬¬©¨¨¬¬®®¯®«¯®®¨¯®«¬°±±®±±±±°²³²®³²°°±®±²´±±±²²´«²³´®µ²³µ´°µ´·¶¶·¶µ¶³·¶´µ¸±·µ¸¸²ª£ž–Šzc\VPKIGD>4%6LZaº¼»µ»ººººµ½½»º»¼¾³»¹»·¼¹¾½ÀÀ¾¼¾ÀÃÂÁ½ÀÁÃÃÃÃÁÀÁÂÅÅÄÀÀ¿¿¿ÂÂÁÂÆÁÅÈÉÃÅÅÆÇÇÇÈÄÄÃÃÃÉÇÉÆÇÉÈÆËÌËÇÇÈÇÅËËÍÌËÍÎÌËÉÎÉÎÍ|}|{yz{||{zyy{}~}z{zyzz|}||}|zzz~|zy{~~}||~~~|{{€€€€}|~~ƒ‚~€‚ƒƒ„„‚ƒ„…‡‡…„„„‚„†……‚~€ƒ…†…‚ƒƒƒƒ„‡ˆ‰‡„ƒ…†‡‡††‡‡†‡††‡ˆˆ‡‡†‡‡ˆ†‰‰ˆ†‡‡‡ˆŠ‰ˆ†‡‡‡ˆŠŠŠŠŒŠ‰ŠŠŒŽ‹ŠŠ‹ŒŽŽŠŠŽŽŽŒ‹ŒŽŽŒŽŽŽŽŽ‘‘‘‘Œ““‘”“’‘“””•”’’’”•”“’“’‘””––“”••••–—”•–™™—••˜šš™˜˜™™˜˜˜˜™™—›š›š™™›œ›™˜š™•ššœœ™››š™š›š˜š›žœ›žŸŸžžŸ ¡ šŸžœžœšž ¡¡¢ šžŸ›Ÿ ¢¢ ¡££ ££¤¥¥¦¦¦£¢££ ¥¥¥¥¦§¨§¨¦¥¦¨§¦§§¤¦¦ªª¨¨©¨§¦§¨¨¨«¬«ª«««©ª¬ª¬¬«ª««ª¬««©ª«¬®¯¯°®®¯°°¯®®®¯°¯®±³±±±°¯±°¬±´²±²³±°¯¯®°²´²´´µ´³±±²±²´´´µ²¯´´µµµ¶¶¶¶¸¶µ²¶µ±·¹¹»º¶¶¶´Ÿ‘„xmf`_[XRF6)/Ois´º»¼½¼ºººº»¼½¼¼¾½½½»º¼¼¼½¾¿ÁÁ¼»½¿ÂÂÀ»½¾¾ÁÄÅÃÀÃÃÃÃÄÂÁ¾ÁÁÃÃÁ¿ÆÄÆÉÈÄÅÇÆÄÄÅÅÅÆÇÄÄÈÇÈÆÇÈÈÇÉÊËÊÉÉËÌËËËÉÇËÍÌÌÎÍÍÍÎzxyyz{|yyyz{||}~~~}|zyz{|{{{|z{{~~|{{~~}}}{}~}|}}~~~~€|‚‚~~~~€~€€‚ƒ‚‚ƒƒƒƒ„…†„„„„„ƒƒ„ƒƒƒ‚‚‚†ˆ…‚ƒ„‚‚„„ˆ‡‡†………„†††‡ˆ‰ˆ†…†‡‡†„…ƒ‡ˆˆˆˆ‡‡‡‡‡‰‰‹‹Š‰ˆ‰‰ˆ‹‰Š…ˆˆ‹ˆ‹Š‹ŠŠˆ‰ŠŒŽŽŒŽŽŽŽŽ‹ŽŽŒŽŽŒ‘‘‘ˆ‘‘’“”‘‘‘’“’‘“Ž“““‘‘’––•”“‘‘”–•”””’““••–——–˜””•™™››™•™š™”—˜™˜™™šœš••—›œ››œœ››˜œš›››–›šš›œœ™ž›Ÿžœœ¡££¡œš››œž¡›œžžž¢¤¡šŸžœ £¢¢££Ÿ¡¡¤¡¤¦§¥£¡¢£¥¦¥¥¦£§©©§¦¦¦¨¨¦¦¨¨§¦©©§©¨©¦§¤©©ªª««¬¬¬«¬ª¥¬¬ª§ªªª©¥ª««ª¬®«®¨«¬°°²°°«¬±¯²®°¬²²°±°®®²±¬°±²±²°±¯¬®®®®°²µ··µ´²²¯±±µ²³³±°´²´°´µµ³·¶¹¸¸·¶³¹º¸··µ·¸»»´§ ˜‰~ga\`YNE>6*3Lew€…¨º¼¾¾½½¹ºº¾¿½¼¼½¾¾¾»½¹¾¼¼¸ÁÁÂÁ½¸¼½¾ÀÁ»»ºº»ÂÃÂÁÃÁÁÂÂÁÁ¿ÂÁÁ¼Á¾ÆÆÇÄÄÅÇ¿ÅÁ¿¾ÂÀÇÈÆÆÇÇÉÆÇÈÇÇÈÇÍÍÊÃËÎÍÇËÇÈÊËËÎÎÎÎÌÉxwxyw|{xxz{||||~~|{zz{y{|}||z{}~~~}}}}}{{|}~~~€}|}~€{}‚‚€€€€€€€‚ƒ‚€‚ƒƒ…„‚€‚ƒƒ„„€‚‚ƒ‚‚ƒ„ƒƒ…†ƒ‚„„‚€†ˆ‡‡‡†„„††…ƒ…‡††ˆˆ†„„ƒ…††ˆ‡†…‡ˆ‰ˆ‹Šˆ‰Š‡Š‹ŠŠ‹‹‹‰‡†Š‹Œ‹ŠŠ‰‹Š‰ŠŒŽŽŽŽŒŽŽ‹ŒŒ‘‘’‘‘‘‘‘‘“”“’Œ’““‘“““‘‘‘’’”–•”’’‘‘˜—“••““••”“—˜—––•–™™™›œ™–—š™”—™™˜˜˜š›š™–šœ›œœœ›š›œœ˜››œ›››žžžžžžŸŸŸ¢¢ ››œ›š¡¢¡ Ÿ¡¢ Ÿ Ÿ¡¡¡¡¢¢¢¢£¢ ¡¡¡¢£¢¤¡¢¤¤¦¦¦§¥£¨©¥¦§§§§§¦§©©§¦¦¨¨ª«ªª§¦§ªªª¨ª¬¬«ª«¬¬ª¬¬¬¬«¬«©©©ªª««¬¬¬®®¬ªª¯±²´±¯®°±²´´´´²¯°²°¬®²²±°±±²±²³´¯®¯±°®°²´¶µµ´³²²²³´¶µ´µ¶µ´´¶µ´´¶·¹º»¸¶·¹º¹µ·¸¸·¹¼½»º¹¹³¬ “‡|mf_]VN?02Lex‡‰œ±¾¿¿¾¼¼»»½¿À¾¼»½¾½½¼½¾¾¼¼½ÀÂÁ¿½¼¼½¿ÂÂÁ¾½¼¿ÁÃÄÄÂÀÂÃÃÁÁÃÄÃÁÀÁÅÇÊÇÅÅÄÅÇÆÅÁ¿ÀÃÆÆÇÈÈÈÉÉÉÇÆÇÊÌÍÍÉÈËÎÌÌËÈËÌÊÈÍÎÌÏÍÈyyyyz{{zy{{z}~}w|}~{{zzzz|}}|x}~~{|}~}|}z|{|}€€|~}€{|{}~~{~€‚€}€|ƒ„ƒƒƒ‚€€‚ƒƒ‚‚‚ƒƒƒ‚ƒ‚‚„ƒƒƒ„„…ƒ€†„„†ˆˆ†„ƒƒ…‡‡†ƒ‚…………‰ˆ‡ƒ„„‡…†‡ˆ‡†‡‰‹‹‹‹…‰‡ˆ‹Œ‡Œ‹Œ‰‰ˆŠŠŒŠ‰‰‰ŒŒ†ŒŽŽŽŽŽ‹‹ŒŽ‘’’’”“‘‘‘””“‘“““•”•“Ž’‘“•••““”’’’”˜—“•–””˜–•“—™˜•˜—™™š™™˜˜˜˜™˜•š›š–™š››šœ›–™˜››š™™››››šš›œž•›Ÿž›œŸ Ÿ œž¡¡Ÿž›› ¡žŸ¡ œ›ž ¢Ÿ¢£¢ž¡¢¡ž¤¡ ™¢ž¡£¤¥¤Ÿ¥¡¢£¦¨§£¦¨¦£§§¦¤¤¤§©¨¤¨¨§§ªªªª©¢¦¦«¬«««©¨¨©ªªª¬«ª§©ª®ªª§©¬«¥©««¦¬®¯®«¨°°°¯°©®¯¯°²³²±±±±±®ª¯²²²²²±±³´´³²±ª±°±³³¬±²±°¯¯³³´··¶¶¶¶±µ¶·²¶¸¸¸¹´¶³¸ºº·¶µ·¸·¶¹ºº³¹¶¹¹µ°¨¡™‚i`XNGB?IUco†™§²»Á¿¿¾¼»¹¹º½¼½½½½¼¹½½¿¾À¹ºº¿ÁÀ¾¿½¿ÀÀ½Â¿À»»¼ÁÁ½ÂÁÃÂÃÃÃÁÄÆÅÀÀÁÇÄÈÅÅÄÃÃÇÄþÄÄÆÅÆÆÇÈÊÇÈÈÉÉÊÊÌÌÈÈÊÌÍÃÍÉÎÍËÇÍÊÍÏÐËy{zz{|{{y||yz}|z{}~~}|{{y~~}|{|~~~}}{{~~~}||}€€€€|}|}{~€‚€€}~€‚ƒ„€ƒƒƒƒƒ‚‚‚„„……ƒ„………€‚„„‚‚ƒ„……„~…‡††††‡ƒ„„……ˆƒ„„„………†‡‡‡†‡‰ˆ††‡‰‰‰†‡ŠŠ‹‹Œ‹‹‰Š‹Œ‹‹Š‰ŠŠ‰ˆŒ‹ŠŽŽŒŒŒ‹‹ŒŽŽŽŒŽŽ’””“‘””“’‹‘‘‘“’””“””””’•”••’’“”––••••––••––——–˜ššš™˜–•–››™—•™›šš™˜™˜™š™–™˜š›™™›œšš˜˜š›ž›™™šœ›œžŸ ¡¡¡ŸœŸ¡ žœŸžœ ŸŸŸžŸ¡¤£¢¢¡¡Ÿ ¡£¤¤¢££¥¦§¦§¦¥¤¥§¨¨¨§¤¤¥¦§¦¦¤¥¤¤¦§§¦¨«©¨©«««ª¨¨ª«««««§ª««©«««¬ª¨ª¯©©«®°ª¨¬¬¯¯¬®±°¯®®¯¬¬¬®¬¯³³±¬¯³³²µ´±²µ²±³´±±±²³³³±±³±®°²´´·¶µ¶·µ³´µ·¸¸¸¶¶µµµ¶·¹¸·¶¶···¸ºº¸¸¸¸¹¹º»º¹´®¤—‹nd]^dmqv’¬¹ÁÂÁ¿¿¾¼»º¹¹¼½½½¾½»½¾¾ÀÀÀ¿½¹¾Â¿¼¾ÀÁÁ¿½ÀÁÀÁÀÁÁ¾¿ÁÁÃÃÃÄÅÄÂ¿ÆÆÆÃÃÆÇÅÆÆÅÄÅÇÇÅÆÇÉÈÈÇÅÈÉÈÆÇÈËÌÉÉÊËÉÇÈÌÌÌÌÎÎÍÍÎÎÎÎÏÑÐvvzz{|{{zzzyyzzz|||{||z|~~~}|zz|||{}~~~~{{|}€€€~€~~€‚ƒ‚‚‚ƒ„‚‚~ƒƒ‚€ƒ„………„ƒ„…‡†‚‚ƒ…‚ƒƒ‚„…ƒƒ…†„††„ƒƒ…†††‡‡††……‚…ƒ†„†…ˆˆˆ†„„ˆŠŠ‰‡‡‰‰ŠŒŒ‹‹„ˆŠ‰‹Šˆ‰‰‡ˆŠŒ‹Š‰Œ‰Œ‹ŒŒŒŽŽŽ‰ŽŽŒŽ’”’Œ‘“’‘Ž‘‘‘‘“”‘’‘’’”–——–”’‘‘‘•••”•••“–—–•••—”™›š—”“–šœ—˜”™—šš˜”•–—™˜•›œ›šššœœš˜˜›œ››–˜—œ›š›š˜œžžž ŸœŸŸŸœœžžž› ¡ ž ¤¦¥£¡¡¡£¤¤ ¥£¥£¥¦§¨§¢¦¦¨¨§¤¤¤¦¦§¨§¥¥¤¤£¤¥¥¥©ªª¨©©ª«¬§««¬¬ª©©§«¬©¬¬¬ª®¬ª¬®¯¯¬¬¯®¨°°°«¬§©¬¬«¬ª®«¯²²°®©®²²±³´±³¶³ª³®°°±±²´´²³³³±±±³±µµ´®µ¶¶´´´·¶µ±°°·µ¸¶¸³·´¶¶·¶·¹¹¸¹·ººº¸¸·¹º¹¹¶²¬¦ž•‰smgz}¡¸¿ÁÂÀÀ¿½º»»º¸¼½¼¸¾½¿Á¿½½½ÂÀÁ»½¹¿½ÁºÀ¿½¼¾½¿ÀÀÁÀ¾¿ÀÂÃÂÀÄÆÆÄÄÅÇÆÄ¿ÈÆÄÁÅÄÅÆÈÅÄÅÉÉÉÂÇÇÇÃÇÅÇÅËÌÊÅÊÄÌÊÈËÊÉÊÊËËÏÍÍÌÎÍÐÐyxyyx|{zyyyyvwxy{{{{||yz|~|}z|}~~}|}~}{~}|}~}€~‚€€€ƒƒƒƒ‚€€€~ƒ‚‚ƒƒƒƒ€~ƒ……„‚€ƒ„„ƒ‡ƒƒ……ƒƒƒƒ‚‚„€‚„„„……ƒƒ‚††‡††‡‡†„…†…†††ˆ‡†…‡‰ˆ†‡‰‰‹‰†…‰‰Š‹‹Šˆ†ŠŒ‹Š‡ˆ‰Š‹ŒŠ‰‰ŠŒ‹ŒŽŠŽŽŽŽŽŽŽ‘‘ŽŽŽ’“’‘‘‘‘‘ŠŽ‘””“”“‘‘‘’”––•–—”‘‘”•–•”“”•–˜—–”–——™ššš˜–—˜›œ™——˜™š—•”–—™™™œžžœœ›šš˜˜œžœž›™š››šš˜™šœœœœŸŸžŸ¡ žŸŸŸ ŸŸ ¡¡ŸŸ¢¥¥£¡¡£¤£££¤¤¤¤¥£¤¦§¥¢¥¦¤£Ÿ¤¤¦§¨©¨¦¦¥¤¤¥¨ª¨¨©ªª«©§§ª¬««ª¨¨©ª«ª¬¯®¬«¬¬©ª®¬¬¬®®¯±±°¬¬ª«®±°°¯¯¯¯°°±²°°³µ³³²®°²³²³¶µ´²´µµ´µ´´´³²®´¶·¸¶µµ´²´µ¶¶¹º¸··¶·¶¶¶¶¶¸¸¸º»ºººº¹··¶¶¹¼½¼¼º´« •‘–¢²ÀÁ¿¿À¿½»¹¹»»¸¼¼¼¾¾½À¿º½ÁÂÂÿ¿ÀÁÂÁÀÁ¿ÀÀ¿½»¼ÁÀ¼ÁÃÃÂÁÂÄÈÇÆÆÆÇÆÄÆÇÆÄÅÅÄÅÇÇÇÆÆÈÉÇÁÆÉÇÄÈÈÈÇÉÍËÆÊÌËÊÉËÌÎÍÉÍÐÏÏÌËËÌÏÑzy{xz{|{{z{zxwxy{|{z||{z}~|{|~~|~€}|~~~~}}~}|{ƒ„‚€€‚‚ƒ~‚‚€€€‚ƒ„‚€„…ƒ}ƒ„‚…††‡ˆ†‚ƒ„…„„…„ƒƒ€ƒ‚ƒ‚„…†‡…ƒ††‡………†‡ˆˆ††‰‰†ƒ‡Š‰…‡ˆŠŠŠ„…‰‰ˆ‹Š‰ˆŠ‹ŒŒ‹Šˆ‡‡ˆ‹‹‰Œ‰Œ‹ŽŠ‹ŽŽ‹ŽŽŽŽ‘‘Ž’‘‘‘’’‘‘••”“–—”‘‘””’’’”•••”’”––’‘”•–“——––—•—™™™˜˜™™››šš™”š›˜•–˜™™™™›œžž—˜˜™™˜›œœžŸ›œ™™˜›œ›œœ™žŸŸŸ ¢ œžžŸŸŸ š›œ¢Ÿ¡ŸŸ ¡œ££¤¡££¤££ ¥¥¤¤¥£¢¡£¤£¢¤¥§©§¦§§¥¤§£§©¬¬©¦©§§§©¨¦§ª«©¦¦§§§©©ª§¬««®®¨§¦¬ªª«¬®¯¨¬¬««¯±°°±°³ª°¯ª«©°°°¬¬®¯«®°«°¯°°³´·´¯²´´³³³µ±³µµ²¶¶´²³´²¯³´¶··¯´²²µ¶´´·»¸¸····´µ¶¶¶·¸º»¸¶¶¶¸¸¸µµ´¼½¾½¼¹¹³²²¶º¾ÂÀ»»º»»»¹ºº»¹»·¾Á¿º¿¿½º»¼ÀÁÂÃÁ¾ÁÁÃÀÁºÀ½¾ÀÁºÀýÂÄÄÁ¿¿ÃÆÆÅÇÃÇÇÄÅÆÆÆÇÈÂÆÇÇÀÇÆÅÄÆÀÇÊÈÄÉÊÉÇÊËÍÈÊÌÊÆÌÎÍÌÌÈÏÏÐÐÍÇÍÇÐÏvz|}{{|}|{{{yz{{z{{}}|||}||~~}}~}|€~~{|~€€|}}}ƒ„‚€|‚€‚ƒ€}€‚‚‚ƒ‚~~}}~ƒ„ƒ€€ƒ……‚„„€…†††ˆ†ƒ„…ƒ…†…„„ƒ„…„„„†‡……†ˆ‰†ƒ†††‰‰‡†‰Š‡‡‰‹‰‡‡ˆŠ‰Š‰ŠŒ‹‰Š‰‰ŠŠ‹‹‹ŠŠˆ‡„‡ŒŽ‹‹‹‹‹ŽŽŒŒŒŒŒ‹ŒŒŒŽŽ‘’’’’““““’““““““–˜•’“–•’’’“’˜—”’•••””••–––—–––””—™™—˜˜š™˜™œš•šš•˜œ›™™š›œ›››˜——š›™šœ›šœž žŸ›œžžŸ ŸŸŸŸ Ÿ¡œœžžœž¡¡ŸžŸ¡£¤£¡ ŸŸ¡£¥£¡¡¢¡¡Ÿ£¥¥¥¥¥£¡¡£¥¥£¥¥©ª¨¥¤§¤¦©©ª«¨ª©©©§¨¨¨©¦¥¦§¦¨©ªª©©©ª«¬«©«¬¬«¬¬¬¬¯¯¯«ª«¬¬±³²±±³²°¬®°°¯®¯°±°¯«®¯®®¯¯¯¯±²±±°³·¶±³´´³²³²°³µ³³µ¶³±´´³°±±³¶´¯±²²³µµµ·¹º¸·¶¶·µ¶¸·µ´¸º¹·µ¶´·¹¹¹µ´º¼¼¼º¼»º½ÂÃÃÃÁ¿º¶º»¼¼¼¼½¼¸º¼¿À¾¼¾¼º»¼½¿¿¿ÂÁÀÁÃÄÄÁÁÀÀ¿ÀÂÅÄÄÄÄÀÂÃÁÄÿÃÄÆÅÄÆÇÃÃÆÈÅÆÈÅÅÆÅÅÆÆÅÅÆÆÈËÊÈÉÉÉÈÊËÌÊÈÉÊÈÌÎÌËÌÌÎÐÐÏÍÏÏÑÏÍxz~||{{||zz{zzz{zz|~~}zyz{|}~~}|}{~}}~~~~}{‚€~}}}~|‚€€€‚~‚‚‚‚~~€‚……ƒ€‚…†‚‚ƒ„ƒ…„„„„……ƒ‚ƒ††„„…„ƒ††…†††„†‡ˆ††…„ƒˆˆˆ‰Š‰‰‡‰‰‡ƒ…†‰‰‰ˆŒ‹‹ˆˆˆŠŠŠ‰ˆ‡‰Šˆ‡‡‡ˆˆ‹Š‹ŒŒ‡ŒŠŠ‹ŽŽŒŒŒ‘ŽŽ’Ž’’’””’’’’‘’Ž’””“••”“‘“”•—˜—••––——”—–—––——”–”–•˜š™—–—˜•šš•››–›œœ›š™œœš•—™™™œœš—š™˜—žŸ›œžžŸŸŸž ›ŸŸŸ žŸ¡ž ¡¡Ÿ¢¢££¤¤£ ¢¤¥¤£Ÿžž ££¤¥¥¦¥¥¤¥¦¥¡¥¥¦¦§¨§¤¤¥§¨¨¨©«ª©©©©§ª«ª©§¥§¨ª««ª«¦©¦¨«¬¨¨©ªª¬«««¬®°¯«©ª¨®«°²¯²±°¯°®°¯±±°°®¬°¬¬¬®¯±²²³±²³³±´³µ°±²°³²²²³´³²±°²¯²«²³°°¯±±³¶·°¸¹·µµ±¹·µ··¶¶¸º¹·´´µ¶·¸¸¶µºµ¹ºº»»·½¿¾½Á¾¿¸º»»¸»¼½¿½·º»Àº½½¿»»»½¹ÀÀ¿¿ÀÀÀÁÅľÃÂÀ¾ÀÂÄÄÅÄÂÂÂÀÄÄÀÁÂÂŽÄÂÁÁÁÁÅÂÄÅÅÆÆÃÇÃÄÄÆÈÉÊËÌÊÅÇÈÊÈÌÌÊÅÌÊÉÊÍÍÍÍÎÎÐÎÐÏÎÍÎÌ{}}}||{{z{{{zzz{|}{}yxxz{|z~z{}~}|}~~~~}}~~€}~~}~~~~€€€~‚|€€€„…ƒ…†ƒ„†„‚ƒ……ƒƒƒ„„†‚††…‚„………†††……………†ƒ…†……„†‡ˆˆŠŒŠ‡‡ˆ†„…†ˆ‹‰ˆŒŒŠŠŠ‰‰‰ŠŠˆ‰‹Œ‹ŠŠŠ‹‹‹Š‰‹‹ŒŽŽŽŒ‹ŽŒ‹‘‘‘ŽŽŽ‘““‘‘‘’’‘’’’’”•‘““’‘“”•”•”‘“”•–––—––•–—˜˜˜–––—˜˜—•–”—š™—“–—˜š›š˜™›š››œœœ›œœœ›šš›œœœ›™™›››Ÿžš›œœ™žŸžœŸŸžŸŸŸ¡¡ ŸŸ ¡¡¢£Ÿ¡¡££¤¥§¥¢ ¢¡Ÿ¢¦¦¤¤¦§§¥¤§©§¥¥§¦¥¥¥¦§¦¦¦¦¥©««ªª©¨§ª«ªª©¥§§©«ªª«©¦¦©ªª©§ª¬«¨¨«®«¯®®«©«¯°°®ª¯±«¬¬°±²³²®¯°±±°°¯±°¯°±¯¯°°°²²²³±³´´´µ´²²²±³µ··´´µµµ²°°¯²±±³±°±³³²²¶·¸·¶²µ´¶¹¸µ´´µ·¸¸·¶µ·¶´··µµµ¹·¸º¹»º·»½¼¾¾¾¼¼»»¹¹¹¼¾¿½»»½¿¿½¿¿¾½¼¾¿ÀÁ¾½¿ÁÁÁÁÁÀ¿ÃÂÀ¿¿¿ÂÄÅÄÿÀÂÁÁÀÁÃÄÄÄÅÄÀÂÃÄÃÅÅÆÇÇÇÇÇÇÅÇÈÇÆÉÌÉÄÈËÉÊËÌÊÊÍÍÌÌÍÍÎÎÍÎÏÏÏÍÊÌÎÍ|~}wz{{wwx}zz{|}~}||{x|||}|{{|}|~}~€€|||~~~}~€€€}‚€‚‚‚‚‚‚‚‚€€€‚‚‚‚„‚‚‚‚ƒ…ƒ„……ƒƒ„……ƒƒƒ„†„ƒ„ƒ……‚†‡†ƒ‡ˆ‡…„…††„ƒ‡‡…„„…‡‡‡‰‹…‡‡‡††ˆ‰†‰‰‹‡‰‰‰ŠŠ…‹‹‰‰‹‹Š…‹ŒŒŒ‹‹ŠŠ‹ŽŒŽŒŒŠ‰Ž‘ŒŽŽ“Ž‘’’’’‘‘”“‘Ž‘’”‘‘’’””””““’’’“’–—–‘‘•––—˜˜——™™˜–—•••™™™˜—–™™›—˜™œš›˜šœœžœ™›œ›››™šœ››žš›™žžŸ œœœ™žŸŸ¡ žŸ¡¡¡¢££¢¡£œ¥¤¡Ÿ¢¤££¥§¦¤¤¥¦¦¤¡¦¦¨§¦¥¥¤££¤¦§§§£§ª«ª©¥§©©§«ª©¦¨¥¨£©¬«¦©¨©¦§©ªªª¦«®®©©ª®«¯°©¬¯²®¬ª¯¯¬«ªª°¬±³²®¯¯°±±«°²²°°¯°®°²³²²«±±²²´µ´´´´³²²¶¹¹²²´´³´±±®²°¯°±°³´µ°³µµ´¶³µ¶µ¶·µ¶¶µ¸µ·¶·¶¸¶µ··µ´´¸¸º¼¼¼¹µ¹¼»½½¶¼»½¹¸¸¼¼¿¸¼¶¼¾À½½¾À»¼¼¿À¿½½¼¿½ÁÀÀ½¾¾Ã¿¾¼ÁÂÃÂÃÃÃÀ¾¿ÁÂÁ½ÁÄÃÂÅÆÅÀÃÃÃÂÀ¿ÆÇÇÇÇÅÅÆÈÄÄÃÄÆÉÅÊÈÉÇËÇÉÊÍÍËÌËËÎÍÌÌÎÏÏÇÌÍÎÍy}}{wz{zy{|yz|}~{€~~}}|||||}}||}~~}~€{|}€‚‚€}}}~~€|‚‚‚‚~€‚‚‚‚‚€ƒ‚€€€€ƒ‚ƒ„ƒƒ„‚……„„„…†„ƒƒ………†‚„†…†…„……„†ˆ‡‡†‡†„ƒ„…†††‡ˆ‡††„†‡‡‡Š‰ˆˆˆˆˆ‹ŠˆŠŒ‹†‡‡ˆ‹Šˆ‹‹‹‹‹‹ˆŠ‹ŒŠ‰‹‹‰‰ŒŽŽŽŽŽŒŒŒ‘‘ޑޑ““‘’’‘‘‘’’’Ž‹“––––•”””’’’’“’“•••–•““’“•——˜””–——˜˜—–—™››™˜——™œœœœ›šš›˜›œœ˜œžšš››š™››œš›œœœœŸžŸŸž žžžŸŸžŸ¡¡ ŸŸ ¢ ¢££¤£¢¢¡££ ¢££¥¥¦¤£¤¥¦¦§¥¤¤¥¦¨¥£¥¤¥¤¤£¥¨§¨¨©¨§§¦¤¨©©©©¨§¨¨¨¨¨ªªª©ª©©¨««««ª«®«©¬®«¯±±¯«¬°²¯«¯¯ª¯¯¯°¯°°±¯®¯±±°±²²±±²°®°³³³³´²±°°²´³³³³²²²²¶¹¸²±³´´³³³³²¯±²±°³¶µ´´´´²´¶·¹¸¶´³µ·¶µ¶¸··¸º¹¶²·¸µ··¶·º½¾¾ºµ¸¹¹ºº¶¼ÀÀ¾»º½À¿½»¼¼¾¾¿¿¿¾º»¾¿¿¾»½¾¾¿¿ÀÀÀÂÄľ¾ÁÄÄÄÁÀÁÁ¿¿ÁÂÁÀÃÆÄÄÄÄÄÂÅÃÅÃÂÂÄÅÆÇÈÅÇÈÈÇÇÈÈÊÊËÊÊÊÌËÊÉËÌËËÎÍÌÍÍËÊÌÏÏÍÌÍÐÑzz|zxx{{z{{{||}}}{~~}z}}}z{~~||||~~~~}}||~~}~~€€€€‚‚‚‚‚€€‚‚€‚‚„ƒ‚‚ƒƒ„~ƒ„…††…„„„ƒ„‚ƒ„„†„„…„ƒƒ……„„ƒ„…†‡‡…€…ƒ‡…†ˆˆ‡ˆ……ƒ††‡ˆˆˆˆˆŠ‹Š‰‹ŒŠ†‡‡ˆ‰ŠˆŒŒ‹Œ‹‹ˆ‰Š‰ˆ‹Ž‹ŒŒŽŽ‘Ž‘’‘‘“””’Ž‘’‘Œ’“Ž’“““’‹‘•–––•‘“’“”•”–•Ž•–”“‘‘•——”•’“’–———–—˜˜™™™’˜–œšššš”˜šœ›šš››œšš›œš›œ›–š˜œŸœŸŸžŸ žžžžŸ¡¡žžŸ¡›¡Ÿ¡¢£ ¡¡ ¢¡ Ÿ¤£¢££££££ž£¤¦¢¦§¦¡£¢¥¦¦¥¦¦¨¤¦¦§¤©¦¦§¦¤§§¥¤¨¥¨§§§ª§©¨©ª©§§¤©©¬¬¬¬¬¬¯ª©¨¬«®±²¬¯ªªª¯°®«®¯¯¯¯±±®¯°©«¯±²°²±¬±³±®±²³®´µµ°¯°±²¯±°°²³±´µµ±²µµ±¯¯²±²°³´´³µ±±±´µ´²³´¸¸·²³±¶··²´¶µµ·¶¹¸·¶¶µ·¸·°»¾¾½»·¸¸¸·¸µ½À¿¼¼·½¸Á½½¸¼»¿»¿¼½¹»¸ÁÀ¾»¿½¿½¿ÂÁ¿ÃÄÅžÁ¿Ä¿À»ÀÀÁÂÂÁÄÅÅÁÁÁÂÂÅÄÃÂÅÆÆÀÇÄÅÆÉÄËÈÉÉËÇÌËÊÆËÂËÆÉÊËÊÍÏÏËÎÌÊÇÌÐÐÊÊÍÒÒ{|{yx{{z{||{}}|~}}}}|||}||y€|z{}~~}{{|}~~~}€~}~€~€‚ƒ„~~~~€‚‚„„„ƒ€ƒƒƒ„ƒƒ„…†…ƒƒ‚ƒ€ƒƒ…„…‡…„„„ƒ„„„„…ƒ€„„„‡‰‡†††ˆˆ‰ŠŠŠ‰‡„„…†‡‡…ˆ‡‡‰ŠŠŠŒŒ‡†‡ˆ†‰‹Œ‹ŒŒŒ‹Ž‰‰Š‹Š‡†ŒŽŽŽŽ‘‘ŽŽ‘‘‘““”””’‘’’‘’’‘‘“”””’Œ‘””“”•”““”””––••””••”“‘•–––”•——–•˜—–’—••˜›š˜˜—›œ›š™–™œžœ›šššššš›œœœœ˜™›ž—œœžŸŸ›œžŸ ¢ Ÿ Ÿ ¡¡ ¢££ ¡¡¡¢¢¢¡¤¦¥¤¤££¢¡¡£¥¨¦¦§¦¥¥¥¤¥¥¥¨©§©¨§§§§¨¨¦¦§§§¥¥¨¨¤§ª©¨ªª¨ª«ª¨¦¤©¬®©«®®¯®«ª«¯°°¯®®¬ª©«¬®¯°°°°±°¯¯°¯®°³±«°²°¯±´²¯²³²²´¶³±±°±²±°¯¯´¶³²²²³³³¶µ³±°°°²µ´´´µ´´³³³µ´³µ·¸··¶µ´¸¸·µµ¸µ³´´¸¹¸µµµµ¸¹º»¾¾½»··¸¹¹¹»½¿½ºº¼½¿¿À¾¼½»¾À¿¾½¹¼ÀÁÁ¾¿ÀÀ¾½ÀÄÁÀÀÃÆÈÆÄÿÃÅÄÃÁÁÂÃÃÂÄÃÄÃÅÆÅÁÃÁÄÅÃÂÆÈÈÈÆÇÊÌËÌÌÍÌÌÌÍËÊÈÊÌÍÊÉËÍÌÌÎÏÏÏÎÏÎÎÍÏÎÏÏÑÑÒz{{xzzyz}~{zz{|~||{||{||}~~xz{~}}}}}~~~}{€€~€€€€‚ƒƒ€~‚€……ƒ‚„ƒƒ……„ƒ‚‚‚„„„‚€ƒ‚„…†††…†…„ƒ††…††ƒ„…ƒ€ˆŠ‡‡‡†‰Š‹‹‰ˆˆ…„…‡ˆ‰‰ˆˆ‡‡ˆ‡ˆŠŒ‹‰††‡ˆŠŒŒŠŠ‹‡‹‹Œ‡‰ŽŠ‹ŒŒŽ‹‘‘‘Œ’”’‘‘’“‘‘‘Ž‘’“’‘’“““•“••““”“–””””——”•”•–—“”“•–™™™™˜–’—˜—™›š•••™ž™››šš››š››œ››››˜›™š›žŸ››œ™ššžŸŸœœœ›šŸŸ Ÿ¡ ŸŸ¡ž¡ ¢ž¡££Ÿ¢¢¡¤¦§¥££¢££¤¦¥¦¥¨¦¨©¨¥§¢¥§¨§¦¥§¦¦¢§¨¦¤§©§¡¦©ª¤¨©«£««©«ª«ª©¦¬¬«©ª«¨¬®§«ª««®¬®®®¨«¬±²±¬±®±±®®°²°°¯°¯±´³°³®²²´¯®¯¯®²³³±¯´¶²°®±±²³³±´²±¯³²²µµ´°²±³²´¶±¸¹¹¸¶´º»¹¶¶¸·²µµ··¶³´´¶¸¹¶¹¸»¼¹µ¸¹»»º¹½¿¾µº¼½½½¾½½¾º¹º¾¾¾º¾ÁÀÀ¿¿ÁÁ¿½ÁÃÁ¼ÁÃÆ¾ÄÆÄ¾ÄÄÄÃÃÃÃÃÃÃÂÃÄÃÄÆÇÂÆÂÆÆÈÆÈÃÉÄÈÈÊÌËÊÍËËÆÍÎÍÆÉÈÍÎÌÊÍÍÌËÍÌÌÌÎÇÌËÍÇÎÑÓÏÏÏxzzy{yyz~{zyz|}z{z{w{|~~}{{|~~}}|~~~~~~~~‚€~}~~‚ƒ|€‚‚‚ƒ„…„ƒƒ‚…ƒƒ‚€ƒƒƒ„„„ƒƒ„‚€‚†††€…‡‡†††‡†‡…ƒ…†……ˆˆ„‡†…ˆŠ‹Š…………ƒ‡ŠŠŠŠˆˆˆ‰‰‡‡‰ŠŠŠˆ…‡ˆŠŒ‹Š‰‹ŒŒŒ‹‹‹‹Œ‹Š‹ˆŒ’Ž‹ŒŽ‘‘’‘‘“‘‘‘““’’“’“’Ž“““““•––•““”•———––˜—––––—™˜“‘”–—™šš˜—“™œœšš—“”–˜žž›˜›œ›š›œš›››ž›šš›žžžž›šž Ÿœ™›žŸŸ ¡¡ ¢¢¡¢¢¡¡££¢¢¡ £¦§¥£¢¢¢££¤¥£¥¦¦§©¬©¦¦§¦¥§©§¦§©¦ ¦¨ª©¨©§¦¨«ª¨§§ª¬«¬«ª«¬««¬¬¬«©©ª©©ª¬«ªª«ªª««¬«ª¬¯¯°®±±±°®¯°±²±±±²³±®°²±±±°±²±²²±°±°®±³³³²²²³±¯¯¯°±±³³³´³±µ´±°±µ¸µ³µ·µ±²µ¶·¸º¸·µ²¹»¹¹¸¶¸º¸¶µ´²²µ·µ··¸¸¶·¹··»¾¼»¹¹»¼¼¼¼¼¹ººº¸¼½¼»»½¿¿º½À¿¾¿¾ÁÁ¾¿ÁÂÀÁÃÅÃÁÂÅÅÅÅÇÆÅÅÅÅÂÃÂÃÁÃÆÆÈÈÈÈÈÈÉÉÈÇÈÇÄÉÊÊËÌÍÌÍÊÈÊÍÌÌÊÈËËÌÎÍÌÌÊËÌÌÎÌÌÌÍÌËÍÑÒÒÒÒzxxy{xyz|~}||z|}||}{zz{|||}}||~~~€{{{~~‚‚}|}€€}}}~ƒƒ€}|‚‚ƒ„„…~‚‚ƒ‡‡ƒ€ƒ‚ƒ‚‚‚ƒƒ„‚ƒ‚„„††…„…ƒ†…†……‚ƒ„†………††ˆ‡†……‡ˆˆ‡‡‡‡ˆ‰ŠŠ‰ˆˆˆŠ†‰‰Š‰ˆ‡Š‹Š‰ˆ‡ŠŠŠ‰ŒŒŒŒ‹ˆ‹ŠŒ‹‹‹ŽŽ‘‘‘‘’’“‘Ž“““”““’’‘‘‘’““’“’•••“”•–••–––—•—”———˜™–“”••–™š˜˜™››—š”˜•˜šœšŸžœ™—ž›—›››™™šž›››šœŸŸœŸžšœžœœŸ ž ¡£¢¢¢¢¢££¢££ ¡£¤¥¤¤¤¡¡ ¢Ÿ¥¢¥¢¤¥©©¨§§§§¦§¨§¡¥¥§¡§¨¬ª¨©©©§©ª¨¤«¬¨«ª«®¬ªª«¦ª¨««ª©ª«««¬¬¬¬®©©©«°±±±¯°°±¯¬¬¯±²±±¯²³°«¯¯¯°¯®³´²±±°²³´´²°°°°¯°³³®³µµ´µ³³¶¶²³´·¶µ´µ¶¶µ¶¶µµ¸´¶±´±¶·¸²¸¸¹º¹²µµ¶²¸»¹²·ººµ¶µµµ¼¼»³¹ºº¹¸º¼¼º¸»¼»¹½¾¾¼¾¿¿¹¼½¿½¾¿ÀÀ¾ºÀ¼ÀÀÁÀ½ÂÄÆÆÇÆÆÇÆÅÄÀÃÀÄÃÃÅÇÇÆÇÆÅÈÄÉÇÆ¿ÆÄÊÊÇÅÊÅÌÇÊÇÉËÊÊËÇÊÊÍÏÎÌËÊÍÍÎÌËËÏÑÐÉÎÍÏÐÐÐzz{{{zyzz|~}|zw}||||{{z||||}|{z€~y€{|}}~}~€‚‚ƒ‚‚~~~€ƒ„ƒ‚€‚‚„„…„‚‚ƒ‡‰„ƒƒƒƒ„€~}„ƒ‚„†………‡…ƒƒ„„ƒ…„„…†‡†„…†…ˆˆ……†‡‡‡‡ˆˆˆ‰Šˆˆˆ†‡Š‹Š‰‰ŠŠ‰‰‹‹Š‹Š‰‰‰‰‹ŒŒŒŒ‰Š‹ŒŽŽŠŽŒŠŽŒ’’Ž’’‘‘‘‘‘Ž’‘“”’’“““’“‘‘“’““”“”•–˜—•”“’”—˜——˜˜–––”““””••–˜—™››š–˜™™šššœž›™œœš˜œž›œœœ›™™šœœš›œœ› žžœœœ™ŸœžŸž¢ ŸŸž ¡¢ Ÿ¡¡¢¢¢££¢¡ ¢£¢ ¢£¢¡¢¢¤£¡£¤¤¦§§§§¦§¨¥¤¥¥¦¦¦¥¡¨¬©§¨ª¨¨©«ªª¬¯ªªªª«¬«©ª©ªª¨«¯®«««¬¬¬¯°¬®±³´®¯°±¯°°®¯¯®®®°¯¯±±±°°²²®°±²³´µ¶²²³²°´µ´³±³³±¯±¶¶µµ¸··¶´´¶¶¶¶¸¶µ³²´¶··¶·¶µµ´´¶´±µ¶·±¸º¸····¸¹º»½º³¸»»º¸º¹¹º»¹·¸»¼¼º¸¹»¼»¼¿¼·¼¾¿À¾½½½¼¼¾¾¾¿¾¾½½¾ÀÁÄÃÂÁÂÂÃÅÅÃÄÆÇÆÅÃÂÂÄÅÄÄÇÇÆÅÄÄÄÆÇÈÈÅÄÇÆÊÉÆÅÈËÊÊÉÈÈËÌËÌËÈÊÌÎÎÏÎÍÍÎÏÌÌÌÏÑÑÏÎÎÍÍÏÐyz{z{|z{{z}}|z|~|{{|z}~~}}{|}}}}|}}€€~yƒƒ‚‚ƒƒƒ‚‚‚ƒ……ƒ~‚‚‚€‚ƒ„ƒ‚‚‚…‡†…„ƒ…ƒ€ƒ„……„‚ƒ‚„ƒ…„„€ƒ„„ƒ†‡‡‡‡‡†…†…‡†…ƒ‡†‡††…„ƒ‡‰‰†ˆ†Š‹Š‰ŠˆŠ‹Š‰‹ŠŠ‡Œˆˆ‰ˆ‹Œ‰ŠŠŠ‹Š‹ŽŽŽŽŽŽŽ”–’ŽŽŽ‘‘’’‘‘’‘’’‘’”’‘’’“”‘””••””•”“•˜™™™˜––””“”–––——––˜š›˜———˜›››š›™™™—›œ›š›œŸŸœž›˜›ššœ™œž ž›››Ÿ¡ ŸŸ ¢£¢žŸ Ÿ Ÿ ¢£££¤£ ¡žžŸ££¡ž¢¢¢¡¤¢¡¢£¡¥¦§§¦¥¦¡©¥¥¡¥§¨§¤Ÿ§ª«¨¨¥©©©ª«¬¬ª«®«ªªª¥«©ªª©ª¬©«©«¬®®®¯¯¯¯¯¯¯²±¯¬°²±°¯°±¯®¯¬¬°±±±²³´±²±²´³´´´´´´´´³³µ³µ®²²³µ¶±·µ¸¹¶²³²¶¶¶±µ³²³··µ¶±²±´¯µµ·³¶´¸±¸¶·³·¸»ºº¶¼½ºµº¹»µ¹¹¹·¸¸¸··¸¼¼»µ¶·º¼¼½¼·½¼¿¼»ºº¼¾¼½¸¾¾¼¹½ºÀÀÃÃþÂÀÃÁÄÄÃÀÆÆÆÄûÃÅÅÄÇÉÈÄÅÄÅÃÄÅÇÉÇÄÆÈÌÈÈÆÉÉÉÉÊÉÊËÎÌÍÌÉÇÌÌÎÎÏÍËÊÎÌËÊÏÎÏÏÎÊËÌÌËxz|z|}{|yzz{|~~~}~~}|{|}~~}|~~~|{}~€~~~€‚‚€~‚ƒƒ„„ƒƒ„…ƒ‚~‚ƒƒ‚„…‚‚}ƒ……„„…„ƒƒ„…ƒ…„ƒ„„ƒ„„…„†…‚„…„…†ˆ‡……††‡‡‡…„…‡‡‡‡ˆ†„ƒƒ†‰‰‡‡‡ŠŠˆˆ‰‰Š‹‰Š‹ŠŠ‹‹ˆ‰‰‹ŒŠ‡ŠŠ‹‹ŠŒŽŽŒŒŠŒŽŒŒŒŒŒ‰Ž’••‘ŽŽŽ‘‘’‘’‘“‘’“’’’’•–•’““””•”“””•––”“–—˜˜˜—–––•”—–—————˜™ššš™˜™™››š›š˜™œ—š›š›ž¡¡¡ Ÿœ›œ›ššœžœœžŸŸšœžŸžŸ ¡¡ž¡¢£¢ ¡¢¢ ¢¢£¤¥¦¦£ ¡¢žžŸ¤£ ¢££¤¤¥¥¥¡£¤¥§§¥¤¥§¨©§¦¦¨¨¥£¤§¨©ªªªªª«ª«¬«ª©®®®¬«ª©¬ª©¬¬©ª««ª¬¬«®¯°°¯¯°¯®®®°±±³³±¯±±®®¯°°®®¯¯°²±²´´µ´´¶¶´±´²³µ´µ¶µ±³µ´µ´´´±´´µ´´µ·¶²µ¶¶·¶´³´´³³·¶µµ¶·¹¶´µ¸¸¸·¸¸¸·¶¶µµ¶º¼»»»º¸¸»¼»¹¸¸¸·º¼¹¼»º¹ºº·¸¹¹»»»¼¾¾¿¾¾¾¾½¾¾¾¾¾¾¾½º½ÀÁÁÁ¿ÁÁÃÄÂÃÂÂÄÆÄÄÄÄÅÅÅÄÆÉÈÅÅÅÅÅÅÇÅÉÉÈÈËÌËÊÊÈÇÇÊËÉÊÍÏÎÍÌÊÉÊÍÎÎÎÍÌÊÍËÎÏÎÎÎÏÏÐÏÑÑÐzz{zzyz}|yyy{}}z~~||{|{~}~€{~€|x€€€~~€‚‚}€‚‚‚ƒƒ„„‚‚‚‚ƒƒ‚‚€€„„‚€€€„ƒ‚‚‚„…†……„ƒƒƒ‚…††……†‡‡…ƒ†‡†……‡††…‚…†‡‡…‚†‡‡‡‡‡‡„…ƒ†ˆ‰‡ˆ†‰‰ˆˆ‰‰Š‹‰ˆ‹Œ‹Œ‹‹‹‹Œ‹‹ŠˆŒ‹ŒŒŠŒŒ‹‡ŽŠŒ‹ŽŒ’‘“‘‘‘’“’’’““’’““’’“•–•““”•‘•”“•—”””–•••–•—”•–—•——™–—˜˜˜˜™™——š™–š˜™™™•™™›œ—šš™™ž Ÿžžšœ™œ•ššœœœžŸ ¡¡Ÿ›Ÿ ¡ ¡Ÿ ¡¤£¡¢£¢ž¢¥¦¤¤ž£¤¤£¤¦¥¡ ¡¥¤¤¥¤¤¤¤¤¤¨§¤¤¤¥§¡©¥¨©©¥¤£¨§ª¬ªª«ªª¬««ª«¬®®ª«¨¬¬¬«ªª¨©©¬¬©©ª¬®®ª®°°¯®°±¯±±²°¯²±®¬±°¯¯°°²¯²´µ±´µ¶µ²±±°³®´´µ´°±²²´´´±²³´²±±±´´±µ¶¶´¶®µ²¶¶¶·¶³¶¶¶·¸²¶³··¸¶·²³µµ³µµ¹¼º¹¹···ººº¹¶µ·¸¹¼½½»¸¸¸º·¸¸¸·¾¼½½¿¼¾»ÀÀ¿¸¾»¾¿¾¿¾¼¿ÁÁ½Á¾¿¿¿¾ÂÁÁ¾ÃÁÁÂÄ¿ÄÃÄÄÅÄÅÆÈÅÇÅÆÁÅÇÊÊÉÉÈÉËÇÉÆÇÆÈÊÉÉËÎÏÍÌÉÈÈÈÈÉÇÌÍÍÊÊÉÏÏÍÈÍÐÑÐÐÈÒÎ{zyyxwy~~}|{{z{~}~~}|||}€€~~€€~|{}}}~€€~€‚‚‚ƒƒƒ‚‚‚ƒ„ƒ‚€ƒ‚‚ƒƒ‚ƒ„‚‚‚‚ƒ…†…„ƒƒ‚‚‚‚†‡…ƒ†ˆˆ„†ˆŠ‡……†„†…‚ƒ†‡††‡ˆ‡†††‡‡…††ˆˆ†ˆˆˆŠ‰…‡ˆŠ‹‹‡‡‹ŒŒ‹ŠŒ‹ŒŒ‹ˆ‹ŒŒŒŒŒŒŽŽ’‘““’‘Ž’’‘‘“““”“““’’““’’“””””•••••–”’“–—–•••——––––—“•—™šš™–—˜™™˜˜”•–š˜—˜˜˜™˜—™›ž›››™™œžššœœœž›™šœžœžŸŸŸŸ ¡žŸ Ÿ Ÿ Ÿ ££¢¢£¡žŸ¤¥¥¥¦¥¥¥¥¦§¥£¢££¤¤¤¡£¥¦£¤¦§¥¥¦¨¨ª¨§§©ª§¦¦¨ª««ª«ª©ª¬«««ª«¬¬¬¬«§¬®¬©©«©©©©¬¬¨ª¬ª«¬¬¬®°°¯¬±°®±²±¯¯°±³±®«±²¯¯²³²¯¯±²³²³³²±±±¯±´´´³²°¯±±²´³±²´µ³³´µ´¶¶¶·µ³´µ¶·¶¶µ¶¸¸·µµ¶·¶¶¶·¹¸·µ°µ¶¶¶¶¶¸»º¸¹¶·¸¸··¹·´··¶º½»¹···¹ººº»¾¾¾¿½½½¿ÁÁÀ¾½¾¿¾¾¿À¾½¾À¿¾Â¾¼À½ÀÂÀÀÂÅÅÅþÂÄÅÇÇÇÆÅÈÈÇÆÇÈÇÉÊÊÉÉÇÇÉÉÉÉÉÊËÉÌÎÎÏÍËËÉÊÈÊÊÉÊËÍÍÍËÌÎÏÍÌÍÐÐÐÏÏÑÓ|{y{zz|~z}|}~~||{~~}}|{|~€€~}}}~~~€€€€€~€|€€‚‚‚ƒ„ƒƒƒƒ……‚ƒ‚‚„„ƒƒƒ€‚‚‚ƒ‚„‚ƒ‚‚‚„ƒ†‡………†‡…†‡ˆ……‡‡†……‚„††ƒ†ˆˆ…„„‡ˆ‰‡†„‰ˆˆ‰‰ˆˆ‡‰‰‰Š‹‰ˆˆ‹ŒŒ‹ŽŽŠ‹‹ŒŠŒ‰‹Š‹‹ŽŒŠŽŽŒ‘’‘““’Ž’‘‘’’““’’“‘’“’’’’“““““”“––”‘‘‘–—–””•–––”–—”–——™™—”—™š›š˜–•˜š˜—˜˜™™™˜˜š›œ›ššžš™™›š™œžžœ›šœžž˜š››Ÿ žžŸ ¢¢¢¡ £¡Ÿ›¢¡¢Ÿ £¤¥¦£¥¥¥ ¦¥¤¡££¤£¢Ÿ¤¦¨¨¦££¢¦¢¦§¨§©¢¦¦§§¨¥¨©«©««ª©ªªª¨¦¦«¬«©¬«¤¨®ª¥§¨«¬¬«¬¬©®®¬®¯®¨°¯®°±°³³±°¯°±³°®ª±³±¯²³³««¬¬¬²³²¯°²±¯°²³¯°°¯¯²³´¯³²³´·µ¶¹¸µ´µ·µ³±²³·¸µ¯µµ¸¸¸µµµ¶²¶´µ¶¸·µ²µ··¸¹²·¸¹¶º¶¶¶¶¶·¸¹¶¸´´·¼¼¼º¸¶¹¼¼¹¼º¾¾¿¼»º¿À¿À¿¿½¾º¿ÂÁ¼½¸¾½ÁÁ¾¹Á¾¿À½ÄÅÄÄÅ¿¾¿ÆÇÇÈÈÄÅÆÆÂÇÅÇÄÅÅÇÈÇÈÈÉÉÈËÎÍÉÍÐÏÌÊÉÊÈÉÉÌÆÊÉÎÌÍËÊÊÏÎÏËÍËÏÍÐÌÑÑ~|z|}|}~~}~~|}|{z|}}~~}v€€~~|{~€€‚ƒ‚€‚„ƒ‚‚ƒ„„……„„ƒ„„……ƒ‚ƒ‚‚ƒƒƒ‚€ƒƒƒƒƒƒƒƒ……„„ƒ†‡†„…„„…††ƒ„†‡‡†„„…‡†ƒ„‡…†‡‡‰‹Š‰‡‡ˆˆˆŠ‰ˆ†‡‰Š‡Š‰ˆ‰Š‰‹‹‹‹ŽŽŽŽŒŽŒ‰Š‹ŒŒŒŽ‹‘”‘Ž‘’’’‘‹‘’’‘‘’“’’’‘’’’““’““‘’‘’““’“•––“’‘’–˜–•””””•””–”—––—˜–“–™››š™—”˜™–˜˜™™˜—˜˜˜™™˜›™—œš™˜›œ››œ›œžžžžžžžžœž¡¢¢Ÿšž¡¢¢ ¡¡Ÿ ¡¡¡ž¡¡£¤¥¥¥¤¥¥¥¥¥¤Ÿ£¤££ ž¤§©¨§§¦¥¥¦¤¥¥¦¨§§¨¨©©¨§¨ª««ªªª©§¦¦¦¤ª«ª«¬ªª®®¬©¨©¬¬¬¬¬«¯±¯®®°®¯©°°°°°²±¯°²¯¬°±²±°°±³±¯²µ²¬±³®®±³±¯³¶´¯ª¯±±±±¬®³´¶µµ¶´³¶·¹¹¸´µµ´´²²³´µ·µ³´µ´µ·¸·¶µ³´´¶·¸¹·¶·¸¹º¸·¹º¹ºº··¹¸ººº»»¹¸¹»»»¼¼»¹¼½¼º¼¾¾½¼¼»½¾½»¾ÂÂÁ¿¿¿¿ÁÂÀ¿¾¼¼ÀÁ½ÀÃÁ¿¿ÂÂÃÄÅÆÅÄÁÂÃÅÃÇÇÃÃÃÅÅÅÄÄÃÆÄÄÅÇÊÉÉÈÆËÎÌÉÌÍÍÌËÊÈÉÊÌÍÍÍÏÐÏÍÌÎÐÐÏÎÌËÍÏÏÏÏÐÐ|zx}~{||~||~€€}|{z|}}€~~~}€~}|€€€€ƒ‚‚‚„„‚ƒ„„„………ƒƒƒ„‚ƒ‚€‚ƒƒƒ‚‚„„ƒ„…„„ƒƒ„……‡…„ƒƒ………†‡„„…„ƒƒƒ†ˆ‡……††………‡ˆ‰‰‡‰†Š‰ˆˆˆ„‰‹‰…ˆ‰ˆƒŠ‹‹ŠŠŠ‰ˆŒŒŽŽŒ‹ŒŽŽŒŒŒŒ…ŒŽŽŽ‘’“‘’’Œ‘’’‘‘‘Ž’’’‘’’‘””“““‘““•••–——”“’’––•––””“”“–——–—–˜™–“–˜››˜˜™•˜˜˜˜™•™™˜“™˜˜˜—›š“šœœ›š›š˜˜˜œžžžžžŸ›žž¢¡Ÿšš›Ÿ¡žœž›Ÿ ŸŸŸŸ¡¡¢¥£¥¥¦£¦¦¥¥¤ ¥¥¥¢ ¡¡©ª¨¦¦¥¥¤¤¤¤¤§§¨¨¨©«©¨§ªªª©ª«©¢¨§¨¥ª§§¦ªªª©«¬¯«¬¬¬««ª«ª©©ª«®ª®«®ª®¬©±±²²°©ª©°²°®¯®®²²±°¬¯²±´´²°°°±°´·µ±®®°±±°®©³´¶·µ³´°¶¶µ²¶³³²±²µ¶¶±³¶·¶´²³´´°··¶±±³·¸º¹·µ··¹¸¸µº¹¸¹¸¶º»»¼¼»»»ººº¹¼¹»¸ºº¼½½·½º½¹º·¾¿À½¼¸ÁÁÁ½¿½¾½Á¿À¿¿»ÂÀÁÃÅ»À¾ÃÄÄÃÄÅÄÃÁ½Â¿ÃÄÄÄÄÄÄÄÅÃÅÃÄÄÄÄÈËËÊÆÅËÌÊÊÍËÊÉÍÈÈÈÈÈÏËÏÐÐÍËÊÐÎÓËÎÍÍÎÎÏÏÍÐÐwwx}~}}||zy~€~}{||~~{€}~~€€€€€€€€€€€€€‚‚ƒ€€‚„„ƒ‚‚„ƒƒ„„‚ƒ„ƒ„„ƒ„…„„†…ƒ‚„ƒƒ…‡††…„ƒ…††‡‡†…„‚€…‡‰ˆ‡‡†„††ˆŠ‹‰ˆ‡‡ˆ‰ˆ‰ˆ‡‰‹Š†‰‹ˆ‰Š‹‹‰ˆŠ‹‹‹‹ŒŽŒŠŒŒŒŽŽŽŽŽŒŒ‰ŽŒ‘‘’”“’‘‘‘“’““”“““”’“’““’–––•”–”’‘‘“””•–•””••–˜™–——™š—”–—™™’—™ššš™š™™š›™š™šš™˜œœšš›œ››ž™˜š›œœžŸœœœžŸ ŸŸŸŸž¡Ÿ› ž žŸžŸ¡¡¢£¤¥¥¥¥¥¦£¥¤¤¥¤¤¤£¤¦§©«¨¥¤¤¢¢¦¨¨¨¨§©©¨©ªª§ª¬¬©¨©ªªª©ªªªªª©ªªªªª¬¯¯¯¯ªª«©©ª«¬®®¯ª«©¬«®°°°°°¯°°°±³²²°¬°²³´±¯®¬°°²³µ³±®°²²³µµ²¯®°²³°¯´´´µ³²²³µ¸¶´²²²³µµ¶·¶´³³·¶´³³µ³¯µ·µ´µ¸¸¹¹¸····¸··¹·µ¶»¹¶¸º¹»½½ºº¹¸¸¸»»¹¹º¼¾¾¾¿½½¼¼ºº½ÁÁÁ¾ºÁÁÀÀ½»½ÀÀÀÀÀÁÂÁÁÂÄÄÄÂÂÃÅÅÅÅÅÄÃÀ¿Á¾ÃÆÇÆÆÅÃÇÇÆÆÈÈÈÈÈÉËÌËÇÈËÍÌÌÎÎÊÌÍÌÊÊÊËÍÎÎÏÍÍÌÍÏÒÑÑÎÍÎÏÏÎÍÌÐÐy{}}~~}z{{|}~||{{||||}{~}||}|~~~€€€‚‚€‚‚‚ƒ‚‚ƒ‚‚‚€…ƒ€‚ƒ„„‚‚€…………„ƒ‚…………„†ˆ‡†…„ˆˆ‡‡†ƒ…„ƒ„„†ˆ‰ˆ‡ˆ‡‡ˆˆˆ‰‰ˆ„‡ƒ†ˆ‰ˆˆ…‰‰Š…ˆ‹‹Š‹‰ŠˆˆŠŒŒŠˆ‹ŠŒŒŒˆ‹ŽŽˆŒŽŽŽŒŽˆ‰‹ŽŽ‘‘‘””’’““‘’‘’““”•‘“’’’’’“’”••‘’”•‘‘’’‘‘’’”“––˜™˜–—–™——•–––———™™š—››š˜š™››ššœ—™œœœ›šœ›œœœš™›››˜žœœ›œ››œŸ ¡¡¡¡¡ ŸŸ Ÿ¡¡¡¡ ž¡ ¡£¤¤¤¤£ ££¥¤£ž¤¤¤¢¡¢¨¨¨¤¦£¦¥¤£§©©¨ª©ª¦§§¨§¨«¬§©©«««¨ª««¨«¥ª««¨¨©®®®ª««ªª¥ª«®¯®««©ª¨¬®®®¬ª®°³²°±³²³®±°´³°®¬±´²³³³¯¯°²²³²µ²±¯®¬µµ²«´³±¯²±³³´µµ±³®µ³¶¶·µ¸·µ±¶µµµ¶·µ±¶´¶µ¶··³´´¶···¸¸º³°¯¸»¸²³µ¹º¼¾¼¶¶µ¸·ºº¹º¼»»»½½¾½½¾¼¸¼¾¿Á¿¼ÂÂÀÁÀ¸¿¿½»¿¿À¾¾¾ÃÃÄÁÅÂÄÀÆÅÅÂÄÄÄÁÿÆÈÈÆÅÄÇÉÈÆÆÆÈÊËÆÊÈËËÈÈÊËÌÍÏÏÍÌÌÌÊÊËÊÌÉÎÌÍÎÎÍÍÆÎÎÍËÐÐÏÍËÌÑÑz{|}|~}z{~~}|}{{{{~~|{|~|~€|~€€}~~€€€€‚‚ƒƒ‚„‚‚ƒƒ„€‚ƒƒ‚„……„„„ƒ‚†††…„…ˆˆ††‡ˆ‰…††………†‡…‡ˆ‡†‡ˆŠˆˆˆ††‡ˆ‡††„†ˆˆ‡‡ˆˆŠˆ‡‰‹‰‹Œ‹Š‰‰‹‹†‰ŠŠ‡‰ˆŠŒŽŽ‹ŠŽŒ‹ŒŒ‹‹‰Œ‘‘’“””’”•’Ž’““”“““”–”‘’’‘’’’‘‘“–—””––’“•–•“”••”˜š™—–––•—–••–––•——”™™—š›——šœœ›š›œœšš››š››œœš˜™›šš›œœžžŸŸŸœ›Ÿ¢¡¢ Ÿ žŸ£¢ Ÿž ¢¡¡ŸŸ¢¥¤£¤£¡¢¢¢£¥¦¤¢£¤¦¥£¥§§¦¥§§§¦¦§¨§ª¤¦¨©©¨¨¨§¦§«¬©¨¨ª««¬¬¬«««ª©«®®®¯¬«ª«¬¬¬«©©¯©«««®®¬¯¯¯¯®¬±²®°²±³´²°³³°®«²¶´²±°²´±±±²³µ²²³´´µµ¶²°³´²±²´³²±³´´µ¸··¶·¸¹¸·µµ¶¶µµ·¹·¶¶´µµµ·µ¯³µµ¶¶¶·º¹¸´µ¹º¶¶·¸¹º»½»¸¹¹¸¸º»»½¼»¼¼»»¾¾¼¿¾·¹¼¾À¾¼ÂÁÀÁÀ¿¿¿»º¾À¿À¿¿ÃÅÅÂÃÃÃÆÆÆÄÃÂÃÅÆÅÆÇÇÇÆÅÈÉÇÄÆÅÅÈÊÊËÊÉÉÊÈÈÊÊÊÌÎÏÍÌÊÊËÌÍÌÌÍÎÎÎÎÍÌÌÍÍÎÍÎÏÐÏÍÎÏÏÑzy{{}~~{|~}~~~||}}}}|}~}~~€€|~€€€~€‚‚}‚‚‚ƒ„ƒ‚‚€‚‚ƒ~„…„‚ƒƒ‚ƒ„„„ƒ‚‚ƒ…†…………††††…†ˆ‡†…ƒ†…†‡‰‰‡†‡‡‡ŠŠˆˆ……††…‡ˆ†ƒ†‡‡†‡‡‰‰ˆˆ‰‰Š‹‹ŠŠˆ‰‰‡‰‹ŒŒŒŒ‹Œ‹‹ŽŽŒ‰ŠŠ‹‹ŽŒˆŽ‘ˆŽŽ’‘’“’’“““–—–””—”“”’’‘’‘“––•”•——””–––”““”“˜š™’“–•“–“““––˜—š–—™™˜™š˜“˜œœš™–š›š–˜š™˜›œœ›œš—šœ›”œœž Ÿœ›ŸŸ ŸžžŸ ž¡¤¤ ž¡ ¡žžŸ¤¦¤ £¡¡¡¡¡¡¥¦¢¡¢¥¥¥¤¨§¨£¦¦§¨§¦©ªª¨¦¥§©§¤¦¨¨¨ªª«ª©¥¥¥ªªª«ª¬ª¨¯°®®¯¯®¬¬¨¬¬®¬©®©©©®¯¯¯®¯°¯ª¯°°±²±²²²®±²²°¬°±±°¯°°±°¬±°²²°«³±´±µ³³¯´³³³´µ´¯¯±²²µ³¸¸·µµµ¶¶µ³·°¸¶¸·¶³¸·¶°µ¶·¯µ·¶³´µ¶···µµ¹¹¸¹»¹¸¶¹¸º·º¸¸¸ºººº¼º¼¹»º»¼»º¼µµ¶¾¿¾¼ÂÁÀ¿¿¹À¾½¼½»¿ÀÀ¿ÄÅÅÁ»ÅÅÇÇÅÆÇÆÆÆÇÈÇÅÅÃÈÉÉÅÆÇÇÇÈÃÉÉËÉÊÆÇÉÌÊÊÉÎÌÍÇÇÇËÍÎÌËËÏÉÌËÌÉÏÐÏËÏÎÎÏÏÍÏËÏÉ}{|}{~}{|}}~~|}|y}~}{{{~€€€€}€€€€~~€ƒ‚}‚ƒ‚‚‚‚‚‚ƒ‚‚ƒƒ‚„ƒ‚ƒ†…„ƒ„‚€€„ƒƒƒ††…†††††„…†‡†„‡‡†††ˆ‰„…‡‡ˆˆ‰‰‰‡‡‡ˆ†‡‰‡†††ƒ†‡‡‡‡‡‡‰Š‰ŠŠŠ‹‰ˆ‰‡ŠŒ‹ŒŒ‹ŠŽŒŠ‹ŽŒ‹‹‹Œ‹‹‰ˆ‘ŽŽŽŒŠ’’’ŽŽŽ‘’‘’”–•””–”‘“”’’”•“‘’““•••–—––•”–”“’“‘•———˜—–”–—•–˜™™™›š———˜—˜˜——™š™˜˜š›š™›žœœœ™››˜žž›šœœœžŸ¡ ŸœœŸžžŸžŸ ¡ ¡¤¤£¡¢¢¢¡žŸ¡¦¦£¡¤¤£¤¡ £¤¤¡£¦¥¥¤§§§¦¥£¥¨¨¨¨©§¥¤¥¦¨¥¤¥§©ª©¨§©ª«©¥¨««¬«©«ª©«®®®®®®®®®®®«««¬®¯¯°¯®¯²±®®¯®°°°°°±°¯¯±´³®°±®®°°±°°°±²²°²¯«°²²´´³²³²°±´µµ³±²²³²´¶·¹¸µ²´µ·µµµ¶····¶µ¸¹·¶·¹¸¶·º¶·¹¸µ¶··¸¸·¹º¼»¹¹¸¹·¹»»¸»º»ºº¼¼½½¾¼»¼¾¼»»¼»¾¾¾¾¿ÀÀ¿¼¾ÁÀÀÁ¾½¹½¾¿ÃÃÄÄÄÂÂÄÅÅÆÅÇÉÈÆÆÅÈÈÅÄÅÈÊÈÆÇÈÇÈÉÉÈÉÊËÊÉËÎÌËËÌÎÌÌÍËÇÊËÌÌÏÏÍÌÌÍÍÏÏÐÐÐÏÍÍÎÎÌÐÒÏÏ}{}~~~}w||}}~{{{}{{|{}€~€€€€€€€€€‚€€‚}€€€|‚„~€ƒƒ€ƒƒ‚ƒ……~€€€ƒ„„ƒ‚‚„‡‡††††„……„ƒ„……†‡‡‡†……‡‡ƒƒ‡ˆˆ‡†‡‰ˆ‡‡ˆ†‡ˆ‡‡‡‡†‡ˆˆ‡„…‡‰ˆ‰‡Š‹‹ˆˆ‰‰ŠŒŒ‹Œ‹ŠŒ‹‡Š‹‹‹ŒŽˆŒŽŽŒ‰Œ‘’’ŽŽ‘‘‘Š‘ŽŽŽ”“”“”‘“Ž’‘•–“‘‘’““”•––—•”••“‘“‘—šš——–—˜——™š™šš˜˜”—”––˜———™™šœœœ›”œžžžžœ››œœœ™Ÿžœœžž› žœžžž ¡¡Ÿ ŸŸ¡£¢£¤¤¢ ž ¢¥¤£ ¤¤¤£¢¢¢£¥¥£¤¥£££¤¥¦¦¤¢£¥©¢§¦§¦¤¢¥§¦£¢¢©©¨§¨©©¬ª¦©¤«¬«¨¨©©©ª«¬¬¬«¨¬¬«ª¯¯®®©©ª®¯¯¯°®ª°²±¬¬¯®¯®®ª¯¯±°®¯µ´²±²¯±²²¯±°±²³´²±±±«´¯µ²±°±°²³´´³³³²³³³¶µ¸¶µµµ±µ³²²··¶µ¶µ·¸¶´º»¹¸»½º¹¸·¶µ¸¸¸ºº¶¹¹º¸º»¹¶¹º½¸¹º½¾¼¹¿¾¿½½º¾ÀÀ¿¾¼¾»¿½½¸½¿¿½¿¾ÀÁÁ¾½º¾ºÁÂÀ¾ÄÅÄÂÆÁÄ¿ÄÁÆÆÅÅÅÆÇÁÅÅÇÊÉÅÉÁÆÇÉÉÉÈÉÈÌÉÌËËÅÌÍÌÄÍÏÍÇÈÈÉËÑÎÌÌÌÌÍÍÏÌÎÎÏÌËÉÎÌÒÎÍÎ|}}~~~}}~~€€|}~€}~~x|€€~}}~€€€ƒƒ€~€‚€‚ƒ~€‚‚€}ƒƒ€„„‚~€ƒƒƒ„„„„ƒ‚„ˆˆ‡†††…ƒƒ„‚}ƒ‚‡‡‡ƒ‡……„……„†‰ˆ†‡ˆ‰‰„‡Š‹ˆ†‡ˆ„‡‰Š‹‰†…†‡‰‰‰Š‹‹‹Š‰ŒŒŠŠŠŠŒŒŒŽ‹Š‹ŒŠ‰ˆŽŽŽ‘‹ŒŽ‘’”“Ž‘‹‘’‘‘’‘’“’‘‘’•–”””•“Ž‘“”•“““‘“––””””••–——””•”’’˜™™–”——–••˜™š™—–˜š˜–—™˜–˜››šœœ››œœœž››œœ›œŸœžž›žŸŸŸžžŸ ¡Ÿžœ¢¢¢¢¤¥¤žŸ¢¤¤£¢¢£¤£¢££¤¤¦¨¥¤£¢¤¤¤¥¦§¦¥¥¥¨©¨©©¨¨£¦¦¦¦¥¦¨ªª©©©ª«¬«ªªª¬ª¨¨©¨«¬ªªªª¬¬¨¬¬¬«¯¯¯¯®¬¬¯¯¯®®®«¯°¯°®¯®°®®®¯±³²®°³³³³±±²³²²²³²°³µ³°±³³´´´´³±¯¶º·´°³µ¶´²²²²²´µ¶·µµ¶µµµ²°´¸¸·¶µ···¸º»·¸¼½»¹·¶¶··¸·ºº¹ººº»¼»º¸º½¼º¹º½¿½¾½¾¾¾»»½ÁÁÀ¾¾¾¾¾¿½»¼¾¾½¾ÀÀÀÀ¿¿¿ÀÀÂÿ½ÃÆÉÊÇÆÄÄÃÄÄÄÄÅÄÄÆÇÇÅÈÉÉÉÈÉÇÈÅÇÉÉÈÉËÌÌËÊÈËÎÊÈËÏÍËÊÈÉÌÐÎÍÎÍÍÏÒÑÎÌËÌÐÏÏÎÐÑÏÏÎ}}}z~~~~~€~|}y~|}~~}}~€€€~|~€€€€|€~~€‚‚ƒƒƒ‚‚€‚ƒ~€‚€€‚€ƒƒ„ƒ‚ƒ‚ƒ……„„„‡ˆ‡†…„†€ƒƒƒ…†‡‡‡‡ˆ‡‡††‡‡‡‰Šˆ…†‡‰ŠŠ‰‹Šˆ†‡ˆ‡‡Š‹‹‰‰‰‰†ˆ‰Š‹Š‡Š‹‹ŒŒ‹‹‡‹ƒŒŽŒŒ’‘މމ‘‘’“’“‘Œ‹’’’’’’““’’’“•”“’”–”“““’”””’•˜—’”•’‘’˜—–——••“™›š™˜–—””“—šš˜—–—™š–˜™—•™šœœœš™—›œ››šœœœ—œžžšš™žŸŸŸž Ÿž¡¡ œž ¡ž¡£¢¡¢¢¤¤¢¡¤¤¡Ÿ¢¡¢£¤¢¤¤£¢¥§¥¡¢¢¥¦¥¤¦Ÿ§¤§¦ª¨ª©ª©¨¤¥¦§§¨§¨¥§¨©¥ª«¬¬«¨©©¨¨«¬¬¬««¬¬¨¬ªªª«ª®¯®¯®®¯¯®«®«¬¬¯°¯®®®®°²´³°¬±±³³²«²±´µµ°²±³°³±±²µµµ±¶µ´°·ºº·³°¶·µ²´´´´¶¶··¶´¸³·´³°°±¹¶¶µ··¸¸¸···º·¸··´¸µ···¶¹¹»¼¼º½»»¸»¸¼·¶µº¹¼»¹¹½¹¹º¾¼À·¿¾¾½¿Á¿»½¹¾½ÁÁÁÁÁ¿ÁÂÁ¿ÂÄÁ½ÄÂÅÇÈÈÇÂŽÆÄÄÀÃÄÅÇÈÇÇÇÉÃÉÃÆÇÉÆÇÇÆÈÊÉÌËËÈËËËÈÌÊÍÊËÈÊÍÎÊÎÎÏÇÏÐÒÏÌÊÎÑÑÑÑÏÑÐÎÊ}}|}~~~€€||||y~}|}~~~€€~~~~~~€€€€€}}z~}€‚„ƒƒ‚‚€€ƒƒ‚‚ƒ„€€€…„‚‚‚‚„…„„„††„…„†††‡ˆ†ˆˆ‡‡†‡‡†€„†‡ˆŠŠŠˆ„‚†‰‹‹‹ˆˆ‡†‡Š‹ŠŠŠˆ‰ŠŠ‰†‡ˆŠŒŠˆŠŒŒŒŠ‹‹‹‹ŒŒŒ‹ŒŽŽ‘’‘ŒŒŽŽŽ‘‘ŽŽ‘””‘ŒŽ‘‘ŽŽ“““‘‘‘’“‘”””•••••”“’–—–””––•––—“———–—™››œ›™˜••—˜ššš–™šš˜˜˜˜–—™šœž›™™šœœ›š››œžžžž¡ŸžžžŸžŸ ¡¢££ œž ¡¢£¢ ¡¡¢£¤££ ¢¤£¡¤¥¥¤¤¡£¥¦£¢£¤¥¦¦¦¦¨§©¨¨¨«ª©©ª¨£¦§§§¨¨§§¦¦¨©ªª««ªªªª¨§¬®¬¬¬¬®°¯«ª¬®«©¯®¬§®°¯¯°¯®«®°°¬®¯¯±±¯¬¬®¯²²²°°±±¯³±°²´´µµ´²´µ¶´²³µµµµ´¶¸·µ¶···´°µ·¶¶µ´²¶¸¸¶¸·µ¸º·¶µ´³µ·¶··¸¶·¸··¸¹·¶¶¶¶¶¸¹¸¸··¹»»»»½¾½¼¼»½º¸µº¼½½ºº»¼½½À¾¿¿¾¾¾¿¾ÀÂÁÁ¿¾¿ÂÃÃÂÂÁÀÁÂÂÁÁÂÄÄÃÂÄÆÆÈÈÉÆÆÇÇÆÄÄÅÄÃÇÉÈÇÈÊÊÊÇÆÊÌÈÅÆÈÉÊËÌËÌËÊÌÌÌÍËÊËÈÊÌÌÍÏÐÎÈÐÓÑÏÏÌÏÐÑÒÒÐÒÑÎÌ~~|}~~€~€}~{}~~~}|}}~x~€‚€~€€€€|}~€‚‚€‚‚‚‚ƒ}‚ƒ„……„‚ƒƒƒ€‚‚„…„„ƒ‚‚„„„ƒ‚‚…†††††††‡††ˆˆ††…„…„ƒ†ˆ‰ˆˆ„†„…ˆ‰ŠŠŠˆ†‡ˆ‰‹‹‹ŠŠ‰‰†ˆ†ˆ‰ŠŠ‰ˆŠ‹ŒŒŒŒ‹Š‹ˆˆ‰ŠŠŽŽŽ‹Ž’‘ŽŠŽ•“‘‘Š‹“”“’’““‘””–—–•–”“’•–•••”–•”•–——”–——”—™››š“™“•—ššššš››”˜™š™˜™™–šœœ›š™œœ—šœœšžŸžœŸ¢¡ ŸŸŸ˜œšŸ¡¢£¡¡ŸœŸž ¢¢œ¡ ££¢£¤¥¥¥¥¥¥¥¤££¤¥¤¡ £¥¦§¨¥¨§§¦©¢§¨§¥¦£¨¥§¨¨ª©¦¦¨©£¨¨©©©¦ªªªª©¥¬©©«¬¨®°¯«ªª«««©®®®©ª¯¬¯²±®«¯¯±²³¬±¯°²±°ª¯°°¯®®¯°®°´³¯³±±²²²²¯·µ´±³µµ±²³³µ·´³±µ´´²´¬´¶·²´´·´¶µµ¶·¸··¹·µ´¶¶·´´³³³²±»º¹´¸¸¸·¹·¸¸¹µ»ºº³¹¶½½º´»º¹º¼¿À¿¾¹»¸º»À½¿¾À¼½½¾¾À¿ÂÁÁ½¿ÂÃÂÁ¿ÃºÂÃÿÀÂÃÄÆ½ÆÅÄÀÅÆÇÃÉÆÇÆÆÆÇÇÆÇÇÉÊÊËÍÊÁËÍÊÆÉËËÆÊÇÊÌËËÌÆÎËÊÊÌÈËÌÌÌÐÐÎÉÑÒÑÎÑÌÎÍÍÎÏÎÒÒÐÎ}|~~}€€€~~|~~~€‚‚‚€€‚‚~~€€~ƒ„ƒƒ‚‚‚‚ƒƒƒ…†ƒ‚‚„„„„‚ƒ„…†…„„ƒƒ„„ƒ‚‚†‡‡ˆ‡‡„………†‡‡ˆ‡†……††ˆˆˆ‹‰„……†ˆˆ‰‰‰ˆˆ‰ˆ‰‰ŠŠ‰‹ŠŠ‰Šˆ…‡‰‰ˆŠŠ‰ŠŠŒŽŒ‹‹‹Š‰Š‹ŒŒ‹Ž’‘ŽŽ‘‘Ž‹’“’‘‘‘ŽŽŒ‹‘’’‘“““““’‘””•–––•”““““”•–”””’“—˜—–˜–•–˜˜˜—˜—•”–•™™ššš™˜˜›››šœš—˜œ›œžš™žžŸ£¡¡¡¡Ÿ žžŸŸŸ¡¡ žœžŸŸŸ ¡¡ ŸŸ ¢¡ŸŸ¡£¤¢¥¥££¤¦¦¤¤¥£ž¡£§§§§¨©¨§§§¨¦¥¤¥¤¢¨ª¨§©«ª¨¨ªª©§©©¨©¨¨ª¨ªª©ªª¨¬¬¨¬®¬®®«ª©«¬««¬«±²¯¯¯°°±±²³²±²²³±±¯®¯°°±±°¯¯¬¯³´´³±±±°°²µ¶¶´±´µµ´°²´µ¶¶³±³µµ¶´°°¶¸¹¶´¶·µ²¶¶¶¸¹¹¸¸¶´¶¸·¶¶···µ±¸º¸¸¹ºººº¹¸¹ººº»¹¹¹ºº¼¹¸ººº½¿¿Á¿¼»»¼¼¾¿¿¾¿¿¾¾À¿¾ÀÁÂÀ½¾ÁÃÄÂÂÃÅÂÂÀ½ÀÄÄÅÄÅÅÅÁ¾ÂÄÄÆÇÇÆÆÅÆÇÉÆÅÇÊÈÆÉÌÌÉÊËÊÌÍÌËÊÉÈÊËÉÉËÎÏÎÊÌÎÎÍÎÏÐÏÏÍÎÐÐÎÑÐÍÎÏÐÐÐÑÒÓÓÓ}~|€z~~~~~€€~~ƒƒ~~€‚ƒ€€€€{€}‚ƒƒ‚‚‚‚‚ƒ„€‚‚€ƒ…„ƒ‚€ƒ„…†…ƒ†…ƒ‚…‚ƒ‡ˆ†„†„……„…‡…†‡‡†…ƒ†‡ˆ…‡‰Š…†††‰‰‰‰ˆ‰ˆ‰‡ˆˆˆˆ‰‹‰†ŠŠŠ‡‡…‰ˆ‹ŠŠ‹ŒŒ‘ˆŒŠŽŽŒŒŽŽŽŒŠŽ‘ŽŽ‹‘’‘‘‘ŒŽŽŽŽ’””’“‘‘’’’”•••””””““”“‘‘’“”••—˜˜˜–””•–••••”•–—˜˜™™•š••–š›œ™œœ››žœ›šš››œ››œžž £¡œ žžžž¡¡žž¢œžœ ¡¡ ¢£¡¡Ÿ¡ ¡ž Ÿ Ÿ ¢¥¥ žž¦¦¥¥¥¢¡¡¤¦¦¢¥§©©ªª©©¨¥¥¦¥¢©©§¤¥¦©¤ªªª©ª««©«ª¨©©¬«¥©ª¬¬¨«®¯¯««ªª¨«¬®«¬©«³°±±±¬«°±±°³´³°±±¯®¯°±«°¯°®¯µ¶´³²±°¯±²´µ´²µ³¶´²°¶´¶±±±±°³·¶±°µ·¸µ¯¶¶¶³³³·¹¹³¶¸¸´¸¸¸¶¶·¸¶¶³³²¶´·¸¹¸ºº¸¶»º»¶¹ºººº·¹»»»½ÀÀ½½¼¿¼»»»¸½¾¿½¾¾¿½½¿¿¸Ã¾À½¿Àý¼»Äý½¾ÁÁÂÂÀÀÇľÄÅÃÃÆÆÇÅÈÈÆÃÇÇÇÉÉÄÊÊÌÉÊÆÆÇÍËÌÆËËËÊÊÅËÍÏÏÎÍÏÏÍÇÎÐÏÇÌÍÏÐÏÐÑÈÐÑÐÐÑÒÓÐÕÖ}|{~}€~}~ƒ}||€€€€}}‚ƒƒ{~‚ƒ€€€€€€‚‚‚ƒ„ƒ„„ƒ‚‚‚ƒƒ‚ƒ…†††‡‡„†…‚„†ˆˆ†…†‡…„†ˆ‡…„‡‚………†‡ˆ‡‡‡ˆ…ˆ‰‡‰ŠŠŠŠ‰‡ˆˆ‰‰‰‰‰Š‰‰‰ŠŒŒŠ‰‰‰ŒŒŒ‘ŽŒŒŽŽŽŒŽŽŽ‘’‘’’’””‘‹Ž‘‘’“’‘’“’‘’””“”””•••”“’‘””—––˜™˜–”•“•••––––˜˜šš˜™›š™™™—š›œœžžœ››œ›œœœ›œœœŸŸ ¢¢¡Ÿž™Ÿ¡¢ Ÿ¡£¢Ÿž ¢¢¢¢¡ŸŸ¢¢¢¡£¢ £¤¤¤£¥¦££¤¤£§¦¤¤¤¥¦¦¦¤¥¨©ª¬¬ª¨¤¨¦¦§§¨§©ªª©«ªª©ª«¬««¨©ª¬«¨¨ª«¬«««¬ª«¬©¬¬¯¯®¯°²´´²±°®®®°°°±²±²²´³²±¯°¬¯°¯°²´´³²²±³²²²±³³´µµ¶¶¶´µ´µµµ²±®±³¶¶³°´µ´³´¶·¹·¶µ¶·¶¶¶¸¸·¹º¶·¶··µµ··¶¶¶¸¹¸µ¸¹µ¸»½»¹ººººº¹¹½¾¼¿ÁÀ¿¼º¼¼¿¿¼»¾ÀÁÁ¿¾½¼¾ÂÀ¿ÂÄÀ¿ÁÅÃÀÀÃÄÃÂÂÂÁÂÀÀÁÁÁÅÆÃ¿ÅÆÁÂÅÈÈÉÉÉÆÂÇÇÄÈÉÊÊËÌÍÌËÊËËÊËÍËÌËÊÊÉÊËÍÎÎÍÎÑÍÉÌÏÏÏÍÌÏÎÎÏÑÐÑÑÏÎÎÑÑÑÓÔ~z}}{~~€€€z~€€€€}€€~‚~~{ƒ‚ƒƒƒ€}€€‚‚€‚‚ƒƒ……„‚ƒƒƒƒ‚‚‚‚‚‚„„ƒ‚ƒ…‡‡ˆ‡††„…ˆ‰‰ˆˆ‡…†……†††‡‡†…„…††‡ˆˆ††…ˆŠˆ‡Š‹Šˆ‰ˆˆˆ‰‰ŠŠŠ‹Šˆˆ‰ŒŒ‹‹‹ŠŒŽŒŠ‹ŽŽŽ‰‡‹ŒŒŠŒŽŒ‘’‘‘ŒŽ‘’’””“ŒŒ““’’’‘’”””““’‘””““”–••–––•––“–“—˜˜–™š—““”•••’–“”–š››—™š›˜šœš——–œ›žš˜š›šš›œœœŸ Ÿžžžžœ¡¢ œž ¢¢££££¢Ÿ¡¡¡ ¡ž ¢££¢¥¤¢¢¢¤¤£¤¤¤§¦£¢§©©¨§£¦¦¦¥¥¥§¨§¤¬«§¢¨¨©¤¤¤©«¬¨««¬«©ªªª««¬ªª¨ª©««««¬©®««©°°ª¬«¯¯¯±°¯²³²ª¯°°¯¯±²¬®¯°±²´´³²®®±°¯°²²³°±³³³®´±³³³°µµ¶±µ³³®¶³´´´´´´µµ´³³´·¸·µ¹¸¶µ¶µ´µ··¹¸¹¹¸µ¶µ·°¶¶¸µ¹¹¹º¹·º¶¸¹»¸»¹¼½»¶ºº¼¿À¼¾»º¹¹¸½½ÀÀ¼»¾ÁÂÀ¾º½½¿Â¿½ÀÃýÄÃÿÂÂÃÁÀÂÂÂÅÃÃÃÃÃÆÂÂÁÄÇÆÂÅÈÉÈÊÊÇÃÅÅÆÈÇÆÊËËËÌËÊÉËÄÌËÊÉÊÊÉÄÉÉÍËÍÇÎÑÎÉÌÌÐÑÐÍÎÌÎÐÓÌÐÐÏÌÍÏÒËÒÏ~}~}|~~~~‚~~}ƒƒ€~~€|€€~‚ƒƒ€ƒ‚‚‚€‚‚ƒƒ„„„„€€‚…‡†…‚„ƒƒ…†‡‡…„ƒ‡ˆˆ†…„ƒ„‰‰‰‰‰‰ˆ†††…ƒ‡ˆˆˆ†„…††ƒ‡‡†‡ˆ‰Šˆ‡Š‹‰ˆ‰ˆ‰ˆ‰ŠŠ‹‹ŒŠ‡†‰Š‰‡‹‹ˆˆ‹Ž‹Š‹ŽŒŒŒŽ‹ŠŠ‹ŠŠŽŒ‹ŒŽŽŽ’’’‘‘‘‘‘““”’‘’“”’’”””––••”““‘‘““’‘•—–––””•—™š—”–™™™™›˜••——™˜——–—››™šœš˜™›™šœœœ›››šššœ›œžŸ¡¢ ŸŸœžžŸ¡ŸœžŸ¢¢¢¢ š ŸžŸ Ÿ ¢¡ ¤¦¤£¤¤£¤£££¥¥¥¤¦¦££¨ªª©¨§¦¥¥¦¦§¦§§¨ªª¨¦©©ªª¨¨¨ª«¬¬«ªªª©©ª«««««««ª¬¬¬®¯®®¬±°®®°°¯®®®±¯®®±²²¯³´²¯°¯¯±³³²±±²³³±°¯±³°²³´³µµµ´´´´µ³´¶µ´³²°´³´µ´´µ³²·¶´¶¹¹¹·¶¶¶µ·¹º¸¶·¸¹º¹¹¸µ·¸¸¹·¹¸º»º¹¹º¸»¾¼¹º¼¼¼¾¾»ºº»½¿¾½¼¼¹¶¼¿¾¿¿¿½»¿ÂÀ¿½½¾À¾À¼¼¾ÁÄÆÄÁÂÂÁÂÁÂÂÂÃÂÅÄÅÃÄÆÇÇÅÆÆÆÆÂÅÆÆÇÉÊÇÆÇÆÉÈÉÊÊÊÈÈÊÌÌÌÊËÌÌÊÊÊÉÉÉÊÉÌËÌÍÍÏÎËËÏÐÏÏÎÐÐÑÒÒÑÐÐÐÏÏÐÐÑÒÔ~}€~~€€ƒ€‚‚ƒ‚‚€€€~~}}ƒƒ‚~‚‚‚‚ƒ|ƒƒ„ƒƒ€‚„†‡†„„……†‰‹Š‰ˆ‡†„…‡‰ˆ‡…„„†ˆˆƒˆ‡‡‡……‡…†‡‡‰‰‰ˆ‡‡‡††…„‡‰Šˆ‡‡ŠŠŠ…‡‡‰ˆ‰‹Œ‹ŒŒŒŠ‰‰ˆ„ˆŠ‰‡ˆ‡ŒŒ‹Š‰’Œ‹ŽˆŠ‹ŒŒŽŒ‹‹Œ‰Ž‘‘‘‘Ž’’‘ŽŽŽ“–•’“””“‘•––’’’’“”“““’‘’——˜˜——–•™›˜‘—™š™™•–•——™š›š˜˜šœžœ–™šœš›œ››œ››ššššœžœœ¡¢¡žŸŸž˜žŸ Ÿ›œœž¡ ŸŸ¡¡¡ ŸžŸ¡£££¥¦¦¥¥¥¤£¦¥¢Ÿ¥¦§¥¥¥¤£¦§§¨§¥¦£¦¦¨¥§©ª¨©©©ª««¬ª«¨§©«§««¬¬ª¨©¥ª§¨ª«¬«««¬¬®¯®¨¬®®®¯°°¬°¯®®¯¬®«®±²³±µ¶³°°®«¯®³²³±²³´µ³¬®°±³¶·µ¶¶µ¶¶µ±´¶µµµµ´³²³²²³´µµ³µ¶·¶¹º¹¸·¶·¯´±¹¸¸´¶·¹»º¹¹¸»º¹¶º°¹»¼»º¹¸·»½½¹¼¼¼¼½¶»º¼¼½¸½»»»¼¹¼¾¿½¿¼½¼¼½¿¼ÀÀÂÂÀÀÀ»¾¾ÆÀÃÀÁÁÀÀÃÄÄÁÃÿÅÅÅÆÇÂÃÂÅÅÃÃÆÆÇÆÆÄÈÇÊÌÌËÈÆÊÍÏÈÊÊÌÉÊÇÉÉËÌËÈÈÊÌÌÍÍÏÊÎÐÏÎÎÍÏÐÐÌÑÑÑÑÒÎÐÍÍÍÒÔ \ No newline at end of file diff --git a/tutorial/tracking/template-tracker/tutorial-template-tracker.cpp b/tutorial/tracking/template-tracker/tutorial-template-tracker.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4f00ddfe78a73647ef34f95a7e4578126761f786 --- /dev/null +++ b/tutorial/tracking/template-tracker/tutorial-template-tracker.cpp @@ -0,0 +1,51 @@ +/*! \example tutorial-template-tracker.cpp */ +#include <visp/vpDisplayGDI.h> +#include <visp/vpDisplayX.h> +#include <visp/vpImageIo.h> +#include <visp/vpTemplateTrackerSSDInverseCompositional.h> +#include <visp/vpTemplateTrackerWarpHomography.h> + +int main() +{ +#if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) + vpImage<unsigned char> I; + + vpImageIo::readPGM(I, "pattern-template-tracker.pgm"); + +#ifdef VISP_HAVE_X11 + vpDisplayX display; +#else + vpDisplayGDI display; +#endif + + display.init(I, 100, 100, "Template tracker"); + vpDisplay::display(I); + vpDisplay::flush(I); + + vpTemplateTrackerWarpHomography warp; + + vpTemplateTrackerSSDInverseCompositional tracker(&warp); + + tracker.setSampling(2,2); + tracker.setLambda(0.001); + tracker.setIterationMax(200); + tracker.setPyramidal(2, 1); + + tracker.initClick(I); + + while(1){ + vpDisplay::display(I); + tracker.track(I); + + vpColVector p = tracker.getp(); + + tracker.display(I, vpColor::red); + + if (vpDisplay::getClick(I, false)) + break; + + vpDisplay::flush(I); + vpTime::wait(40); + } +#endif +} diff --git a/tutorial/visual-servo/ibvs/CMakeLists.txt b/tutorial/visual-servo/ibvs/CMakeLists.txt index a7134b807801bd7d1f2f1eed83a653a7f2191c7c..42a4bd98a8b16d204cf8aced8fbf1bff6efda6e7 100644 --- a/tutorial/visual-servo/ibvs/CMakeLists.txt +++ b/tutorial/visual-servo/ibvs/CMakeLists.txt @@ -3,31 +3,31 @@ project(tutorial-visual-servo-ibvs) cmake_minimum_required(VERSION 2.6) find_package(VISP REQUIRED) -if(VISP_FOUND) - include(${VISP_USE_FILE}) -endif(VISP_FOUND) -# build the examples -add_executable(tutorial-ibvs-4pts tutorial-ibvs-4pts.cpp) -add_executable(tutorial-ibvs-4pts-display tutorial-ibvs-4pts-display.cpp) -add_executable(tutorial-ibvs-4pts-image-tracking tutorial-ibvs-4pts-image-tracking.cpp) -add_executable(tutorial-ibvs-4pts-ogre tutorial-ibvs-4pts-ogre.cpp) -add_executable(tutorial-ibvs-4pts-ogre-tracking tutorial-ibvs-4pts-ogre-tracking.cpp) -add_executable(tutorial-ibvs-4pts-plotter tutorial-ibvs-4pts-plotter.cpp) -add_executable(tutorial-ibvs-4pts-wireframe-camera tutorial-ibvs-4pts-wireframe-camera.cpp) -add_executable(tutorial-ibvs-4pts-wireframe-robot-afma6 tutorial-ibvs-4pts-wireframe-robot-afma6.cpp) -add_executable(tutorial-ibvs-4pts-wireframe-robot-viper tutorial-ibvs-4pts-wireframe-robot-viper.cpp) +# set the list of source files +set(tutorial_cpp + tutorial-ibvs-4pts.cpp + tutorial-ibvs-4pts-display.cpp + tutorial-ibvs-4pts-image-tracking.cpp + tutorial-ibvs-4pts-ogre.cpp + tutorial-ibvs-4pts-ogre-tracking.cpp + tutorial-ibvs-4pts-plotter.cpp + tutorial-ibvs-4pts-plotter-gain-adaptive.cpp + tutorial-ibvs-4pts-plotter-continuous-gain-adaptive.cpp + tutorial-ibvs-4pts-wireframe-camera.cpp + tutorial-ibvs-4pts-wireframe-robot-afma6.cpp + tutorial-ibvs-4pts-wireframe-robot-viper.cpp +) -# copy the Ogre3D data -get_target_property(target_location tutorial-ibvs-4pts-ogre LOCATION) -get_filename_component(target_location "${target_location}" PATH) -list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/sphere/Sphere.mesh" ) -list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/sphere/Sphere.material" ) -list(APPEND data2copy "${CMAKE_CURRENT_SOURCE_DIR}/target_square.pgm" ) -foreach(data ${data2copy}) - add_custom_command( - TARGET tutorial-ibvs-4pts-ogre - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy "${data}" "${target_location}" - ) +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/sphere/Sphere.mesh" ) +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/sphere/Sphere.material" ) +list(APPEND tutorial_data "${CMAKE_CURRENT_SOURCE_DIR}/target_square.pgm" ) + +foreach(cpp ${tutorial_cpp}) + visp_add_target(${cpp}) +endforeach() + +# Copy the data files to the same location than the target +foreach(data ${tutorial_data}) + visp_copy_data(tutorial-ibvs-4pts-ogre.cpp ${data}) endforeach() diff --git a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-display.cpp b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-display.cpp index e46daed8a484246240fb37dc797840e327c2df58..29aae8c5eb7ae94d4ec789338b93c4a096374846 100644 --- a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-display.cpp +++ b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-display.cpp @@ -7,6 +7,9 @@ #include <visp/vpProjectionDisplay.h> #include <visp/vpServoDisplay.h> +void display_trajectory(const vpImage<unsigned char> &I, std::vector<vpPoint> &point, + const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam); + void display_trajectory(const vpImage<unsigned char> &I, std::vector<vpPoint> &point, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam) { @@ -27,83 +30,88 @@ void display_trajectory(const vpImage<unsigned char> &I, std::vector<vpPoint> &p int main() { - vpHomogeneousMatrix cdMo(0, 0, 0.75, 0, 0, 0); - vpHomogeneousMatrix cMo(0.15, -0.1, 1., - vpMath::rad(10), vpMath::rad(-10), vpMath::rad(50)); + try { + vpHomogeneousMatrix cdMo(0, 0, 0.75, 0, 0, 0); + vpHomogeneousMatrix cMo(0.15, -0.1, 1., + vpMath::rad(10), vpMath::rad(-10), vpMath::rad(50)); - std::vector<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); + std::vector<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); - vpServo task ; - task.setServo(vpServo::EYEINHAND_CAMERA); - task.setInteractionMatrixType(vpServo::CURRENT); - task.setLambda(0.5); + vpServo task ; + task.setServo(vpServo::EYEINHAND_CAMERA); + task.setInteractionMatrixType(vpServo::CURRENT); + task.setLambda(0.5); - vpFeaturePoint p[4], pd[4] ; - for (int i = 0 ; i < 4 ; i++) { - point[i].track(cdMo); - vpFeatureBuilder::create(pd[i], point[i]); - point[i].track(cMo); - vpFeatureBuilder::create(p[i], point[i]); - task.addFeature(p[i], pd[i]); - } + vpFeaturePoint p[4], pd[4] ; + for (unsigned int i = 0 ; i < 4 ; i++) { + point[i].track(cdMo); + vpFeatureBuilder::create(pd[i], point[i]); + point[i].track(cMo); + vpFeatureBuilder::create(p[i], point[i]); + task.addFeature(p[i], pd[i]); + } - vpHomogeneousMatrix wMc, wMo; - vpSimulatorCamera robot; - robot.setSamplingTime(0.040); - robot.getPosition(wMc); - wMo = wMc * cMo; + vpHomogeneousMatrix wMc, wMo; + vpSimulatorCamera robot; + robot.setSamplingTime(0.040); + robot.getPosition(wMc); + wMo = wMc * cMo; - vpImage<unsigned char> Iint(480, 640, 255) ; - vpImage<unsigned char> Iext(480, 640, 255) ; + vpImage<unsigned char> Iint(480, 640, 255) ; + vpImage<unsigned char> Iext(480, 640, 255) ; #if defined(VISP_HAVE_X11) - vpDisplayX displayInt(Iint, 0, 0, "Internal view"); - vpDisplayX displayExt(Iext, 670, 0, "External view"); + vpDisplayX displayInt(Iint, 0, 0, "Internal view"); + vpDisplayX displayExt(Iext, 670, 0, "External view"); #elif defined(VISP_HAVE_GDI) - vpDisplayGDI displayInt(Iint, 0, 0, "Internal view"); - vpDisplayGDI displayExt(Iext, 670, 0, "External view"); + vpDisplayGDI displayInt(Iint, 0, 0, "Internal view"); + vpDisplayGDI displayExt(Iext, 670, 0, "External view"); #else - std::cout << "No image viewer is available..." << std::endl; + std::cout << "No image viewer is available..." << std::endl; #endif #if defined(VISP_HAVE_DISPLAY) - vpProjectionDisplay externalview; - for (int i = 0 ; i < 4 ; i++) - externalview.insert(point[i]) ; + vpProjectionDisplay externalview; + for (unsigned int i = 0 ; i < 4 ; i++) + externalview.insert(point[i]) ; #endif - vpCameraParameters cam(840, 840, Iint.getWidth()/2, Iint.getHeight()/2); - vpHomogeneousMatrix cextMo(0,0,3, 0,0,0); + vpCameraParameters cam(840, 840, Iint.getWidth()/2, Iint.getHeight()/2); + vpHomogeneousMatrix cextMo(0,0,3, 0,0,0); - while(1) { - robot.getPosition(wMc); - cMo = wMc.inverse() * wMo; - for (int i = 0 ; i < 4 ; i++) { - point[i].track(cMo); - vpFeatureBuilder::create(p[i], point[i]); - } - vpColVector v = task.computeControlLaw(); - robot.setVelocity(vpRobot::CAMERA_FRAME, v); + while(1) { + robot.getPosition(wMc); + cMo = wMc.inverse() * wMo; + for (unsigned int i = 0 ; i < 4 ; i++) { + point[i].track(cMo); + vpFeatureBuilder::create(p[i], point[i]); + } + vpColVector v = task.computeControlLaw(); + robot.setVelocity(vpRobot::CAMERA_FRAME, v); - vpDisplay::display(Iint) ; - vpDisplay::display(Iext) ; - display_trajectory(Iint, point, cMo, cam); + vpDisplay::display(Iint) ; + vpDisplay::display(Iext) ; + display_trajectory(Iint, point, cMo, cam); - vpServoDisplay::display(task, cam, Iint, vpColor::green, vpColor::red); + vpServoDisplay::display(task, cam, Iint, vpColor::green, vpColor::red); #if defined(VISP_HAVE_DISPLAY) - externalview.display(Iext, cextMo, cMo, cam, vpColor::red, true); + externalview.display(Iext, cextMo, cMo, cam, vpColor::red, true); #endif - vpDisplay::flush(Iint); - vpDisplay::flush(Iext); + vpDisplay::flush(Iint); + vpDisplay::flush(Iext); - // A click to exit - if (vpDisplay::getClick(Iint, false) || vpDisplay::getClick(Iext, false)) - break; + // A click to exit + if (vpDisplay::getClick(Iint, false) || vpDisplay::getClick(Iext, false)) + break; - vpTime::wait( robot.getSamplingTime() * 1000); + vpTime::wait( robot.getSamplingTime() * 1000); + } + task.kill(); + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; } - task.kill(); } diff --git a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-image-tracking.cpp b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-image-tracking.cpp index a0c9d8a859771397ca32965d06cb9656ebc5dfe0..6d225b9c630768d6bda1e18c137439f49cceb883 100644 --- a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-image-tracking.cpp +++ b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-image-tracking.cpp @@ -8,6 +8,8 @@ #include <visp/vpServoDisplay.h> #include <visp/vpSimulatorCamera.h> +void display_trajectory(const vpImage<unsigned char> &I, const std::vector<vpDot2> &dot); + /*! Given an image of a target, this class provided virtual framegrabbing capabilities in order to retrieve an image of a @@ -79,91 +81,96 @@ void display_trajectory(const vpImage<unsigned char> &I, const std::vector<vpDot int main() { #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) - vpHomogeneousMatrix cdMo(0, 0, 0.75, 0, 0, 0); - vpHomogeneousMatrix cMo(0.15, -0.1, 1., vpMath::rad(10), vpMath::rad(-10), vpMath::rad(50)); + try { + vpHomogeneousMatrix cdMo(0, 0, 0.75, 0, 0, 0); + vpHomogeneousMatrix cMo(0.15, -0.1, 1., vpMath::rad(10), vpMath::rad(-10), vpMath::rad(50)); - vpImage<unsigned char> I(480, 640, 255); - vpCameraParameters cam(840, 840, I.getWidth()/2, I.getHeight()/2); + vpImage<unsigned char> I(480, 640, 255); + vpCameraParameters cam(840, 840, I.getWidth()/2, I.getHeight()/2); - std::vector<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); + std::vector<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); - vpServo task ; - task.setServo(vpServo::EYEINHAND_CAMERA); - task.setInteractionMatrixType(vpServo::CURRENT); - task.setLambda(0.5); + vpServo task ; + task.setServo(vpServo::EYEINHAND_CAMERA); + task.setInteractionMatrixType(vpServo::CURRENT); + task.setLambda(0.5); - vpVirtualGrabber g("./target_square.pgm", cam); - g.acquire(I, cMo); + vpVirtualGrabber g("./target_square.pgm", cam); + g.acquire(I, cMo); #if defined(VISP_HAVE_X11) - vpDisplayX d(I, 0, 0, "Current camera view"); + vpDisplayX d(I, 0, 0, "Current camera view"); #elif defined(VISP_HAVE_GDI) - vpDisplayGDI d(I, 0, 0, "Current camera view"); + vpDisplayGDI d(I, 0, 0, "Current camera view"); #else - std::cout << "No image viewer is available..." << std::endl; + std::cout << "No image viewer is available..." << std::endl; #endif - vpDisplay::display(I); - vpDisplay::displayCharString(I, 10, 10, - "Click in the 4 dots to initialise the tracking and start the servo", - vpColor::red); - vpDisplay::flush(I); + vpDisplay::display(I); + vpDisplay::displayCharString(I, 10, 10, + "Click in the 4 dots to initialise the tracking and start the servo", + vpColor::red); + vpDisplay::flush(I); - vpFeaturePoint p[4], pd[4]; - std::vector<vpDot2> dot(4); + vpFeaturePoint p[4], pd[4]; + std::vector<vpDot2> dot(4); - for (int i = 0 ; i < 4 ; i++) { - point[i].track(cdMo); - vpFeatureBuilder::create(pd[i], point[i]); + for (unsigned int i = 0 ; i < 4 ; i++) { + point[i].track(cdMo); + vpFeatureBuilder::create(pd[i], point[i]); - dot[i].setGraphics(true); - dot[i].initTracking(I); - vpDisplay::flush(I); - vpFeatureBuilder::create(p[i], cam, dot[i].getCog()); - - task.addFeature(p[i], pd[i]); - } + dot[i].setGraphics(true); + dot[i].initTracking(I); + vpDisplay::flush(I); + vpFeatureBuilder::create(p[i], cam, dot[i].getCog()); - vpHomogeneousMatrix wMc, wMo; - vpSimulatorCamera robot; - robot.setSamplingTime(0.040); - robot.getPosition(wMc); - wMo = wMc * cMo; + task.addFeature(p[i], pd[i]); + } - for (; ; ) { + vpHomogeneousMatrix wMc, wMo; + vpSimulatorCamera robot; + robot.setSamplingTime(0.040); robot.getPosition(wMc); - cMo = wMc.inverse() * wMo; + wMo = wMc * cMo; - g.acquire(I, cMo); + for (; ; ) { + robot.getPosition(wMc); + cMo = wMc.inverse() * wMo; - vpDisplay::display(I); + g.acquire(I, cMo); - for (int i = 0 ; i < 4 ; i++) { - dot[i].track(I); - vpFeatureBuilder::create(p[i], cam, dot[i].getCog()); + vpDisplay::display(I); - vpColVector cP; - point[i].changeFrame(cMo, cP) ; - p[i].set_Z(cP[2]); - } + for (unsigned int i = 0 ; i < 4 ; i++) { + dot[i].track(I); + vpFeatureBuilder::create(p[i], cam, dot[i].getCog()); - vpColVector v = task.computeControlLaw(); + vpColVector cP; + point[i].changeFrame(cMo, cP) ; + p[i].set_Z(cP[2]); + } - display_trajectory(I, dot); - vpServoDisplay::display(task, cam, I, vpColor::green, vpColor::red) ; - robot.setVelocity(vpRobot::CAMERA_FRAME, v); + vpColVector v = task.computeControlLaw(); - vpDisplay::flush(I); - if (vpDisplay::getClick(I, false)) - break; + display_trajectory(I, dot); + vpServoDisplay::display(task, cam, I, vpColor::green, vpColor::red) ; + robot.setVelocity(vpRobot::CAMERA_FRAME, v); + + vpDisplay::flush(I); + if (vpDisplay::getClick(I, false)) + break; - vpTime::wait( robot.getSamplingTime() * 1000); + vpTime::wait( robot.getSamplingTime() * 1000); + } + task.kill(); + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; } - task.kill(); #endif } diff --git a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-ogre-tracking.cpp b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-ogre-tracking.cpp index 183aa06999a8214d30fa4d9c58994ed82cbe24cd..912adffbdf2eaaf4c74db09cfb5d12e10351d45b 100644 --- a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-ogre-tracking.cpp +++ b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-ogre-tracking.cpp @@ -8,6 +8,12 @@ #include <visp/vpServoDisplay.h> #include <visp/vpSimulatorCamera.h> +void display_trajectory(const vpImage<unsigned char> &I, const std::vector<vpDot2> &dot, unsigned int thickness); +#if defined(VISP_HAVE_OGRE) +void ogre_get_render_image(vpAROgre &ogre, const vpImage<unsigned char> &background, + const vpHomogeneousMatrix &cMo, vpImage<unsigned char> &I); +#endif + void display_trajectory(const vpImage<unsigned char> &I, const std::vector<vpDot2> &dot, unsigned int thickness) { static std::vector<vpImagePoint> traj[4]; @@ -23,10 +29,7 @@ void display_trajectory(const vpImage<unsigned char> &I, const std::vector<vpDot #if defined(VISP_HAVE_OGRE) void ogre_get_render_image(vpAROgre &ogre, const vpImage<unsigned char> &background, - #if VISP_VERSION_INT > VP_VERSION_INT(2,7,0) - const - #endif - vpHomogeneousMatrix &cMo, vpImage<unsigned char> &I) + const vpHomogeneousMatrix &cMo, vpImage<unsigned char> &I) { static vpImage<vpRGBa> Irender; // Image from ogre scene rendering ogre.display(background, cMo); @@ -41,139 +44,110 @@ void ogre_get_render_image(vpAROgre &ogre, const vpImage<unsigned char> &backgro int main() { #if defined(VISP_HAVE_OGRE) && (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI)) - unsigned int thickness = 3; - - vpHomogeneousMatrix cdMo(0, 0, 0.75, 0, 0, 0); - vpHomogeneousMatrix cMo(0.15, -0.1, 1., vpMath::rad(10), vpMath::rad(-10), vpMath::rad(50)); - - // Color image used as background texture. - vpImage<unsigned char> background(480, 640, 255); - - // Parameters of our camera - vpCameraParameters cam(840, 840, background.getWidth()/2, background.getHeight()/2); - - // Define the target as 4 points - std::vector<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); - - // Our object - // A simulator with the camera parameters defined above, - // and the background image size - vpAROgre ogre; - ogre.setCameraParameters(cam); - ogre.setShowConfigDialog(false); - ogre.addResource("./"); // Add the path to the Sphere.mesh resource - ogre.init(background, false, true); - //ogre.setWindowPosition(680, 400); - - // Create the scene that contains 4 spheres - // Sphere.mesh contains a sphere with 1 meter radius - std::vector<std::string> name(4); - for (int i=0; i<4; i++) { - std::ostringstream s; s << "Sphere" << i; name[i] = s.str(); - ogre.load(name[i], "Sphere.mesh"); - ogre.setScale(name[i], 0.02f, 0.02f, 0.02f); // Rescale the sphere to 2 cm radius - // Set the position of each sphere in the object frame - ogre.setPosition(name[i], vpTranslationVector(point[i].get_oX(), point[i].get_oY(), point[i].get_oZ())); - ogre.setRotation(name[i], vpRotationMatrix(M_PI/2, 0, 0)); - } + try { + unsigned int thickness = 3; + + vpHomogeneousMatrix cdMo(0, 0, 0.75, 0, 0, 0); + vpHomogeneousMatrix cMo(0.15, -0.1, 1., vpMath::rad(10), vpMath::rad(-10), vpMath::rad(50)); + + // Color image used as background texture. + vpImage<unsigned char> background(480, 640, 255); + + // Parameters of our camera + vpCameraParameters cam(840, 840, background.getWidth()/2, background.getHeight()/2); + + // Define the target as 4 points + std::vector<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); + + // Our object + // A simulator with the camera parameters defined above, + // and the background image size + vpAROgre ogre; + ogre.setCameraParameters(cam); + ogre.setShowConfigDialog(false); + ogre.addResource("./"); // Add the path to the Sphere.mesh resource + ogre.init(background, false, true); + //ogre.setWindowPosition(680, 400); + + // Create the scene that contains 4 spheres + // Sphere.mesh contains a sphere with 1 meter radius + std::vector<std::string> name(4); + for (int i=0; i<4; i++) { + std::ostringstream s; s << "Sphere" << i; name[i] = s.str(); + ogre.load(name[i], "Sphere.mesh"); + ogre.setScale(name[i], 0.02f, 0.02f, 0.02f); // Rescale the sphere to 2 cm radius + // Set the position of each sphere in the object frame + ogre.setPosition(name[i], vpTranslationVector(point[i].get_oX(), point[i].get_oY(), point[i].get_oZ())); + ogre.setRotation(name[i], vpRotationMatrix(M_PI/2, 0, 0)); + } - // Add an optional point light source - Ogre::Light * light = ogre.getSceneManager()->createLight(); - light->setDiffuseColour(1, 1, 1); // scaled RGB values - light->setSpecularColour(1, 1, 1); // scaled RGB values - light->setPosition((Ogre::Real)cdMo[0][3], (Ogre::Real)cdMo[1][3], (Ogre::Real)(-cdMo[2][3])); - light->setType(Ogre::Light::LT_POINT); + // Add an optional point light source + Ogre::Light * light = ogre.getSceneManager()->createLight(); + light->setDiffuseColour(1, 1, 1); // scaled RGB values + light->setSpecularColour(1, 1, 1); // scaled RGB values + light->setPosition((Ogre::Real)cdMo[0][3], (Ogre::Real)cdMo[1][3], (Ogre::Real)(-cdMo[2][3])); + light->setType(Ogre::Light::LT_POINT); - vpServo task ; - task.setServo(vpServo::EYEINHAND_CAMERA); - task.setInteractionMatrixType(vpServo::CURRENT); - task.setLambda(0.5); + vpServo task ; + task.setServo(vpServo::EYEINHAND_CAMERA); + task.setInteractionMatrixType(vpServo::CURRENT); + task.setLambda(0.5); - // Image used for the image processing - vpImage<unsigned char> I; + // Image used for the image processing + vpImage<unsigned char> I; - // Render the scene at the desired position - ogre_get_render_image(ogre, background, cdMo, I); + // Render the scene at the desired position + ogre_get_render_image(ogre, background, cdMo, I); - // Display the image in which we will do the tracking + // Display the image in which we will do the tracking #if defined(VISP_HAVE_X11) - vpDisplayX d(I, 0, 0, "Camera view at desired position"); + vpDisplayX d(I, 0, 0, "Camera view at desired position"); #elif defined(VISP_HAVE_GDI) - vpDisplayGDI d(I, 0, 0, "Camera view at desired position"); + vpDisplayGDI d(I, 0, 0, "Camera view at desired position"); #else - std::cout << "No image viewer is available..." << std::endl; + std::cout << "No image viewer is available..." << std::endl; #endif - vpDisplay::display(I); - vpDisplay::displayCharString(I, 10, 10, "Click in the 4 dots to learn their positions", vpColor::red); - vpDisplay::flush(I); - - std::vector<vpDot2> dot(4); - vpFeaturePoint p[4], pd[4]; - - for (int i = 0 ; i < 4 ; i++) { - // Compute the desired feature at the desired position - dot[i].setGraphics(true); - dot[i].setGraphicsThickness(thickness); - dot[i].initTracking(I); - vpDisplay::flush(I); - vpFeatureBuilder::create(pd[i], cam, dot[i].getCog()); - } - - // Render the scene at the initial position - ogre_get_render_image(ogre, background, cMo, I); - - vpDisplay::display(I); - vpDisplay::setTitle(I, "Current camera view"); - vpDisplay::displayCharString(I, 10, 10, "Click in the 4 dots to initialise the tracking and start the servo", vpColor::red); - vpDisplay::flush(I); - - for (int i = 0 ; i < 4 ; i++) { - // We notice that if we project the scene at a given pose, the pose estimated from - // the rendered image differs a little. That's why we cannot simply compute the desired - // feature from the desired pose using the next two lines. We will rather compute the - // desired position of the features from a learning stage. - // point[i].project(cdMo); - // vpFeatureBuilder::create(pd[i], point[i]); - - // Compute the current feature at the initial position - dot[i].setGraphics(true); - dot[i].initTracking(I); + vpDisplay::display(I); + vpDisplay::displayCharString(I, 10, 10, "Click in the 4 dots to learn their positions", vpColor::red); vpDisplay::flush(I); - vpFeatureBuilder::create(p[i], cam, dot[i].getCog()); - } - - for (int i = 0 ; i < 4 ; i++) { - // Set the feature Z coordinate from the pose - vpColVector cP; - point[i].changeFrame(cMo, cP) ; - p[i].set_Z(cP[2]); - - task.addFeature(p[i], pd[i]); - } - vpHomogeneousMatrix wMc, wMo; - vpSimulatorCamera robot; - robot.setSamplingTime(0.040); - robot.getPosition(wMc); - wMo = wMc * cMo; + std::vector<vpDot2> dot(4); + vpFeaturePoint p[4], pd[4]; - for (; ; ) { - // From the camera position in the world frame we retrieve the object position - robot.getPosition(wMc); - cMo = wMc.inverse() * wMo; + for (int i = 0 ; i < 4 ; i++) { + // Compute the desired feature at the desired position + dot[i].setGraphics(true); + dot[i].setGraphicsThickness(thickness); + dot[i].initTracking(I); + vpDisplay::flush(I); + vpFeatureBuilder::create(pd[i], cam, dot[i].getCog()); + } - // Update the scene from the new camera position + // Render the scene at the initial position ogre_get_render_image(ogre, background, cMo, I); vpDisplay::display(I); + vpDisplay::setTitle(I, "Current camera view"); + vpDisplay::displayCharString(I, 10, 10, "Click in the 4 dots to initialise the tracking and start the servo", vpColor::red); + vpDisplay::flush(I); for (int i = 0 ; i < 4 ; i++) { - dot[i].track(I); + // We notice that if we project the scene at a given pose, the pose estimated from + // the rendered image differs a little. That's why we cannot simply compute the desired + // feature from the desired pose using the next two lines. We will rather compute the + // desired position of the features from a learning stage. + // point[i].project(cdMo); + // vpFeatureBuilder::create(pd[i], point[i]); + + // Compute the current feature at the initial position + dot[i].setGraphics(true); + dot[i].initTracking(I); + vpDisplay::flush(I); vpFeatureBuilder::create(p[i], cam, dot[i].getCog()); } @@ -182,21 +156,59 @@ int main() vpColVector cP; point[i].changeFrame(cMo, cP) ; p[i].set_Z(cP[2]); + + task.addFeature(p[i], pd[i]); } - vpColVector v = task.computeControlLaw(); + vpHomogeneousMatrix wMc, wMo; + vpSimulatorCamera robot; + robot.setSamplingTime(0.040); + robot.getPosition(wMc); + wMo = wMc * cMo; + + for (; ; ) { + // From the camera position in the world frame we retrieve the object position + robot.getPosition(wMc); + cMo = wMc.inverse() * wMo; - display_trajectory(I, dot, thickness); - vpServoDisplay::display(task, cam, I, vpColor::green, vpColor::red, thickness+2) ; - robot.setVelocity(vpRobot::CAMERA_FRAME, v); + // Update the scene from the new camera position + ogre_get_render_image(ogre, background, cMo, I); - vpDisplay::flush(I); - if (vpDisplay::getClick(I, false)) - break; + vpDisplay::display(I); - vpTime::wait( robot.getSamplingTime() * 1000); + for (int i = 0 ; i < 4 ; i++) { + dot[i].track(I); + vpFeatureBuilder::create(p[i], cam, dot[i].getCog()); + } + + for (int i = 0 ; i < 4 ; i++) { + // Set the feature Z coordinate from the pose + vpColVector cP; + point[i].changeFrame(cMo, cP) ; + p[i].set_Z(cP[2]); + } + + vpColVector v = task.computeControlLaw(); + + display_trajectory(I, dot, thickness); + vpServoDisplay::display(task, cam, I, vpColor::green, vpColor::red, thickness+2) ; + robot.setVelocity(vpRobot::CAMERA_FRAME, v); + + vpDisplay::flush(I); + if (vpDisplay::getClick(I, false)) + break; + + vpTime::wait( robot.getSamplingTime() * 1000); + } + task.kill(); + } + catch(vpException e) { + std::cout << "Catch a ViSP exception: " << e << std::endl; + } + catch(...) { + std::cout << "Catch an exception " << std::endl; + return 1; } - task.kill(); #endif } diff --git a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-ogre.cpp b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-ogre.cpp index 742eb1ceb054f90a06171c29379e250e3300072c..0328d7aea020de3b551b8fa3c4d102dcfe8c17ab 100644 --- a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-ogre.cpp +++ b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-ogre.cpp @@ -1,4 +1,5 @@ /*! \example tutorial-ibvs-4pts-ogre.cpp */ + #include <visp/vpAROgre.h> #include <visp/vpFeatureBuilder.h> #include <visp/vpServo.h> @@ -6,86 +7,94 @@ int main() { - vpHomogeneousMatrix cdMo(0, 0, 0.75, 0, 0, 0); - vpHomogeneousMatrix cMo(0.15, -0.1, 1., vpMath::rad(10), vpMath::rad(-10), vpMath::rad(50)); + try { + vpHomogeneousMatrix cdMo(0, 0, 0.75, 0, 0, 0); + vpHomogeneousMatrix cMo(0.15, -0.1, 1., vpMath::rad(10), vpMath::rad(-10), vpMath::rad(50)); - // Define the target as 4 points - 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); + // Define the target as 4 points + 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); #if defined(VISP_HAVE_OGRE) - // Color image used as background texture. - vpImage<unsigned char> background(480, 640, 255); + // Color image used as background texture. + vpImage<unsigned char> background(480, 640, 255); - // Parameters of our camera - vpCameraParameters cam(840, 840, background.getWidth()/2, background.getHeight()/2); + // Parameters of our camera + vpCameraParameters cam(840, 840, background.getWidth()/2, background.getHeight()/2); - // Our object - // A simulator with the camera parameters defined above, - // and the background image size - vpAROgre ogre; - ogre.setShowConfigDialog(false); - ogre.setCameraParameters(cam); - ogre.addResource("./"); // Add the path to the Sphere.mesh resource - ogre.init(background, false, true); + // Our object + // A simulator with the camera parameters defined above, + // and the background image size + vpAROgre ogre; + ogre.setShowConfigDialog(false); + ogre.setCameraParameters(cam); + ogre.addResource("./"); // Add the path to the Sphere.mesh resource + ogre.init(background, false, true); - // Create the scene that contains 4 spheres - // Sphere.mesh contains a sphere with 1 meter radius - std::vector<std::string> name(4); - for (int i=0; i<4; i++) { - std::ostringstream s; s << "Sphere" << i; name[i] = s.str(); - ogre.load(name[i], "Sphere.mesh"); - ogre.setScale(name[i], 0.02f, 0.02f, 0.02f); // Rescale the sphere to 2 cm radius - // Set the position of each sphere in the object frame - ogre.setPosition(name[i], vpTranslationVector(point[i].get_oX(), point[i].get_oY(), point[i].get_oZ())); - } + // Create the scene that contains 4 spheres + // Sphere.mesh contains a sphere with 1 meter radius + std::vector<std::string> name(4); + for (int i=0; i<4; i++) { + std::ostringstream s; s << "Sphere" << i; name[i] = s.str(); + ogre.load(name[i], "Sphere.mesh"); + ogre.setScale(name[i], 0.02f, 0.02f, 0.02f); // Rescale the sphere to 2 cm radius + // Set the position of each sphere in the object frame + ogre.setPosition(name[i], vpTranslationVector(point[i].get_oX(), point[i].get_oY(), point[i].get_oZ())); + } - // Add an optional point light source - Ogre::Light * light = ogre.getSceneManager()->createLight(); - light->setDiffuseColour(1, 1, 1); // scaled RGB values - light->setSpecularColour(1, 1, 1); // scaled RGB values - light->setPosition((Ogre::Real)cdMo[0][3], (Ogre::Real)cdMo[1][3], (Ogre::Real)(-cdMo[2][3])); - light->setType(Ogre::Light::LT_POINT); + // Add an optional point light source + Ogre::Light * light = ogre.getSceneManager()->createLight(); + light->setDiffuseColour(1, 1, 1); // scaled RGB values + light->setSpecularColour(1, 1, 1); // scaled RGB values + light->setPosition((Ogre::Real)cdMo[0][3], (Ogre::Real)cdMo[1][3], (Ogre::Real)(-cdMo[2][3])); + light->setType(Ogre::Light::LT_POINT); #endif - vpServo task ; - task.setServo(vpServo::EYEINHAND_CAMERA); - task.setInteractionMatrixType(vpServo::CURRENT); - task.setLambda(0.5); + vpServo task ; + task.setServo(vpServo::EYEINHAND_CAMERA); + task.setInteractionMatrixType(vpServo::CURRENT); + task.setLambda(0.5); - vpFeaturePoint p[4], pd[4] ; - for (int i = 0 ; i < 4 ; i++) { - point[i].track(cdMo); - vpFeatureBuilder::create(pd[i], point[i]); - point[i].track(cMo); - vpFeatureBuilder::create(p[i], point[i]); - task.addFeature(p[i], pd[i]); - } - - vpHomogeneousMatrix wMc, wMo; - vpSimulatorCamera robot; - robot.setSamplingTime(0.040); - robot.getPosition(wMc); - wMo = wMc * cMo; - - for (unsigned int iter=0; iter < 150; iter ++) { - robot.getPosition(wMc); - cMo = wMc.inverse() * wMo; + vpFeaturePoint p[4], pd[4] ; for (int i = 0 ; i < 4 ; i++) { + point[i].track(cdMo); + vpFeatureBuilder::create(pd[i], point[i]); point[i].track(cMo); vpFeatureBuilder::create(p[i], point[i]); + task.addFeature(p[i], pd[i]); } + + vpHomogeneousMatrix wMc, wMo; + vpSimulatorCamera robot; + robot.setSamplingTime(0.040); + robot.getPosition(wMc); + wMo = wMc * cMo; + + for (unsigned int iter=0; iter < 150; iter ++) { + robot.getPosition(wMc); + cMo = wMc.inverse() * wMo; + for (int i = 0 ; i < 4 ; i++) { + point[i].track(cMo); + vpFeatureBuilder::create(p[i], point[i]); + } #if defined(VISP_HAVE_OGRE) - // Update the scene from the new camera position - ogre.display(background, cMo); + // Update the scene from the new camera position + ogre.display(background, cMo); #endif - vpColVector v = task.computeControlLaw(); - robot.setVelocity(vpRobot::CAMERA_FRAME, v); - vpTime::wait( robot.getSamplingTime() * 1000); + vpColVector v = task.computeControlLaw(); + robot.setVelocity(vpRobot::CAMERA_FRAME, v); + vpTime::wait( robot.getSamplingTime() * 1000); + } + task.kill(); + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + } + catch(...) { + std::cout << "Catch an exception " << std::endl; } - task.kill(); } diff --git a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-plotter-continuous-gain-adaptive.cpp b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-plotter-continuous-gain-adaptive.cpp new file mode 100644 index 0000000000000000000000000000000000000000..beef4d088ad28ce69a86b86c58d41949dd9b50ae --- /dev/null +++ b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-plotter-continuous-gain-adaptive.cpp @@ -0,0 +1,102 @@ +/*! \example tutorial-ibvs-4pts-plotter-continuous-gain-adaptive.cpp */ +#include <visp/vpFeatureBuilder.h> +#include <visp/vpServo.h> +#include <visp/vpSimulatorCamera.h> +#include <visp/vpPlot.h> + +int main() +{ + try { + vpHomogeneousMatrix cdMo(0, 0, 0.75, 0, 0, 0); + vpHomogeneousMatrix cMo(0.15, -0.1, 1., vpMath::rad(10), vpMath::rad(-10), vpMath::rad(50)); + + 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); + + vpServo task ; + task.setServo(vpServo::EYEINHAND_CAMERA); + task.setInteractionMatrixType(vpServo::CURRENT); + + vpAdaptiveGain lambda(4, 0.4, 30); + task.setLambda(lambda); + + vpFeaturePoint p[4], pd[4] ; + for (unsigned int i = 0 ; i < 4 ; i++) { + point[i].track(cdMo); + vpFeatureBuilder::create(pd[i], point[i]); + point[i].track(cMo); + vpFeatureBuilder::create(p[i], point[i]); + task.addFeature(p[i], pd[i]); + } + + vpHomogeneousMatrix wMc, wMo; + vpSimulatorCamera robot; + robot.setSamplingTime(0.040); + robot.getPosition(wMc); + wMo = wMc * cMo; + +#ifdef VISP_HAVE_DISPLAY + vpPlot plotter(2, 250*2, 500, 100, 200, "Real time curves plotter"); + plotter.setTitle(0, "Visual features error"); + plotter.setTitle(1, "Camera velocities"); + + plotter.initGraph(0, 8); + plotter.initGraph(1, 6); + + plotter.setLegend(0, 0, "x1"); + plotter.setLegend(0, 1, "y1"); + plotter.setLegend(0, 2, "x2"); + plotter.setLegend(0, 3, "y2"); + plotter.setLegend(0, 4, "x3"); + plotter.setLegend(0, 5, "y3"); + plotter.setLegend(0, 6, "x4"); + plotter.setLegend(0, 7, "y4"); + + plotter.setLegend(1, 0, "v_x"); + plotter.setLegend(1, 1, "v_y"); + plotter.setLegend(1, 2, "v_z"); + plotter.setLegend(1, 3, "w_x"); + plotter.setLegend(1, 4, "w_y"); + plotter.setLegend(1, 5, "w_z"); +#endif + + unsigned int iter = 0; + while(1) { + robot.getPosition(wMc); + cMo = wMc.inverse() * wMo; + for (unsigned int i = 0 ; i < 4 ; i++) { + point[i].track(cMo); + vpFeatureBuilder::create(p[i], point[i]); + } + vpColVector v = task.computeControlLaw(iter*robot.getSamplingTime()); + robot.setVelocity(vpRobot::CAMERA_FRAME, v); + +#ifdef VISP_HAVE_DISPLAY + plotter.plot(0, iter, task.getError()); + plotter.plot(1, iter, v); +#endif + if (( task.getError() ).sumSquare() < 0.0001) + break; + + iter++; + } + std::cout << "Convergence in " << iter << " iterations" << std::endl; + + task.kill(); + +#ifdef VISP_HAVE_DISPLAY + plotter.saveData(0, "error.dat"); + plotter.saveData(1, "vc.dat"); + + vpDisplay::getClick(plotter.I); +#endif + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + } +} + + diff --git a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-plotter-gain-adaptive.cpp b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-plotter-gain-adaptive.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d3d0a7b806d3a7bd27eb004c93c48eed4a1cfd2a --- /dev/null +++ b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-plotter-gain-adaptive.cpp @@ -0,0 +1,102 @@ +/*! \example tutorial-ibvs-4pts-plotter-gain-adaptive.cpp */ +#include <visp/vpFeatureBuilder.h> +#include <visp/vpServo.h> +#include <visp/vpSimulatorCamera.h> +#include <visp/vpPlot.h> + +int main() +{ + try { + vpHomogeneousMatrix cdMo(0, 0, 0.75, 0, 0, 0); + vpHomogeneousMatrix cMo(0.15, -0.1, 1., vpMath::rad(10), vpMath::rad(-10), vpMath::rad(50)); + + 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); + + vpServo task ; + task.setServo(vpServo::EYEINHAND_CAMERA); + task.setInteractionMatrixType(vpServo::CURRENT); + + vpAdaptiveGain lambda(4, 0.4, 30); + task.setLambda(lambda); + + vpFeaturePoint p[4], pd[4] ; + for (unsigned int i = 0 ; i < 4 ; i++) { + point[i].track(cdMo); + vpFeatureBuilder::create(pd[i], point[i]); + point[i].track(cMo); + vpFeatureBuilder::create(p[i], point[i]); + task.addFeature(p[i], pd[i]); + } + + vpHomogeneousMatrix wMc, wMo; + vpSimulatorCamera robot; + robot.setSamplingTime(0.040); + robot.getPosition(wMc); + wMo = wMc * cMo; + +#ifdef VISP_HAVE_DISPLAY + vpPlot plotter(2, 250*2, 500, 100, 200, "Real time curves plotter"); + plotter.setTitle(0, "Visual features error"); + plotter.setTitle(1, "Camera velocities"); + + plotter.initGraph(0, 8); + plotter.initGraph(1, 6); + + plotter.setLegend(0, 0, "x1"); + plotter.setLegend(0, 1, "y1"); + plotter.setLegend(0, 2, "x2"); + plotter.setLegend(0, 3, "y2"); + plotter.setLegend(0, 4, "x3"); + plotter.setLegend(0, 5, "y3"); + plotter.setLegend(0, 6, "x4"); + plotter.setLegend(0, 7, "y4"); + + plotter.setLegend(1, 0, "v_x"); + plotter.setLegend(1, 1, "v_y"); + plotter.setLegend(1, 2, "v_z"); + plotter.setLegend(1, 3, "w_x"); + plotter.setLegend(1, 4, "w_y"); + plotter.setLegend(1, 5, "w_z"); +#endif + + unsigned int iter = 0; + while(1) { + robot.getPosition(wMc); + cMo = wMc.inverse() * wMo; + for (unsigned int i = 0 ; i < 4 ; i++) { + point[i].track(cMo); + vpFeatureBuilder::create(p[i], point[i]); + } + vpColVector v = task.computeControlLaw(); + robot.setVelocity(vpRobot::CAMERA_FRAME, v); + +#ifdef VISP_HAVE_DISPLAY + plotter.plot(0, iter, task.getError()); + plotter.plot(1, iter, v); +#endif + if (( task.getError() ).sumSquare() < 0.0001) + break; + + iter++; + } + std::cout << "Convergence in " << iter << " iterations" << std::endl; + + task.kill(); + +#ifdef VISP_HAVE_DISPLAY + plotter.saveData(0, "error.dat"); + plotter.saveData(1, "vc.dat"); + + vpDisplay::getClick(plotter.I); +#endif + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + } +} + + diff --git a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-plotter.cpp b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-plotter.cpp index 54afccf712faf7ed74bfa523cd5ef3336f6fc46b..df01839ddb190d6b5ed8da353f9d496460a97792 100644 --- a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-plotter.cpp +++ b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-plotter.cpp @@ -6,84 +6,95 @@ int main() { - vpHomogeneousMatrix cdMo(0, 0, 0.75, 0, 0, 0); - vpHomogeneousMatrix cMo(0.15, -0.1, 1., vpMath::rad(10), vpMath::rad(-10), vpMath::rad(50)); - - 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); - - vpServo task ; - task.setServo(vpServo::EYEINHAND_CAMERA); - task.setInteractionMatrixType(vpServo::CURRENT); - task.setLambda(0.5); - - vpFeaturePoint p[4], pd[4] ; - for (int i = 0 ; i < 4 ; i++) { - point[i].track(cdMo); - vpFeatureBuilder::create(pd[i], point[i]); - point[i].track(cMo); - vpFeatureBuilder::create(p[i], point[i]); - task.addFeature(p[i], pd[i]); - } + try { + vpHomogeneousMatrix cdMo(0, 0, 0.75, 0, 0, 0); + vpHomogeneousMatrix cMo(0.15, -0.1, 1., vpMath::rad(10), vpMath::rad(-10), vpMath::rad(50)); + + 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); + + vpServo task ; + task.setServo(vpServo::EYEINHAND_CAMERA); + task.setInteractionMatrixType(vpServo::CURRENT); + task.setLambda(0.5); + + vpFeaturePoint p[4], pd[4] ; + for (unsigned int i = 0 ; i < 4 ; i++) { + point[i].track(cdMo); + vpFeatureBuilder::create(pd[i], point[i]); + point[i].track(cMo); + vpFeatureBuilder::create(p[i], point[i]); + task.addFeature(p[i], pd[i]); + } - vpHomogeneousMatrix wMc, wMo; - vpSimulatorCamera robot; - robot.setSamplingTime(0.040); - robot.getPosition(wMc); - wMo = wMc * cMo; + vpHomogeneousMatrix wMc, wMo; + vpSimulatorCamera robot; + robot.setSamplingTime(0.040); + robot.getPosition(wMc); + wMo = wMc * cMo; #ifdef VISP_HAVE_DISPLAY - vpPlot plotter(2, 250*2, 500, 100, 200, "Real time curves plotter"); - plotter.setTitle(0, "Visual features error"); - plotter.setTitle(1, "Camera velocities"); - - plotter.initGraph(0, 8); - plotter.initGraph(1, 6); - - plotter.setLegend(0, 0, "x1"); - plotter.setLegend(0, 1, "y1"); - plotter.setLegend(0, 2, "x2"); - plotter.setLegend(0, 3, "y2"); - plotter.setLegend(0, 4, "x3"); - plotter.setLegend(0, 5, "y3"); - plotter.setLegend(0, 6, "x4"); - plotter.setLegend(0, 7, "y4"); - - plotter.setLegend(1, 0, "v_x"); - plotter.setLegend(1, 1, "v_y"); - plotter.setLegend(1, 2, "v_z"); - plotter.setLegend(1, 3, "w_x"); - plotter.setLegend(1, 4, "w_y"); - plotter.setLegend(1, 5, "w_z"); + vpPlot plotter(2, 250*2, 500, 100, 200, "Real time curves plotter"); + plotter.setTitle(0, "Visual features error"); + plotter.setTitle(1, "Camera velocities"); + + plotter.initGraph(0, 8); + plotter.initGraph(1, 6); + + plotter.setLegend(0, 0, "x1"); + plotter.setLegend(0, 1, "y1"); + plotter.setLegend(0, 2, "x2"); + plotter.setLegend(0, 3, "y2"); + plotter.setLegend(0, 4, "x3"); + plotter.setLegend(0, 5, "y3"); + plotter.setLegend(0, 6, "x4"); + plotter.setLegend(0, 7, "y4"); + + plotter.setLegend(1, 0, "v_x"); + plotter.setLegend(1, 1, "v_y"); + plotter.setLegend(1, 2, "v_z"); + plotter.setLegend(1, 3, "w_x"); + plotter.setLegend(1, 4, "w_y"); + plotter.setLegend(1, 5, "w_z"); #endif - for (unsigned int iter=0; iter < 150; iter ++) { - robot.getPosition(wMc); - cMo = wMc.inverse() * wMo; - for (int i = 0 ; i < 4 ; i++) { - point[i].track(cMo); - vpFeatureBuilder::create(p[i], point[i]); - } - vpColVector v = task.computeControlLaw(); - robot.setVelocity(vpRobot::CAMERA_FRAME, v); + unsigned int iter = 0; + while(1) { + robot.getPosition(wMc); + cMo = wMc.inverse() * wMo; + for (unsigned int i = 0 ; i < 4 ; i++) { + point[i].track(cMo); + vpFeatureBuilder::create(p[i], point[i]); + } + vpColVector v = task.computeControlLaw(); + robot.setVelocity(vpRobot::CAMERA_FRAME, v); #ifdef VISP_HAVE_DISPLAY - plotter.plot(0, iter, task.getError()); - plotter.plot(1, iter, v); + plotter.plot(0, iter, task.getError()); + plotter.plot(1, iter, v); #endif - } + if (( task.getError() ).sumSquare() < 0.0001) + break; - task.kill(); + iter++; + } + std::cout << "Convergence in " << iter << " iterations" << std::endl; + + task.kill(); #ifdef VISP_HAVE_DISPLAY - plotter.saveData(0, "error.dat"); - plotter.saveData(1, "vc.dat"); + plotter.saveData(0, "error.dat"); + plotter.saveData(1, "vc.dat"); - vpDisplay::getClick(plotter.I); + vpDisplay::getClick(plotter.I); #endif + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + } } diff --git a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-wireframe-camera.cpp b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-wireframe-camera.cpp index e9e96e4257791e284f208e0926d37d9943f9e3e2..af310734bdaabfb76e9fbdcd9c8485c89eead9da 100644 --- a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-wireframe-camera.cpp +++ b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-wireframe-camera.cpp @@ -8,6 +8,9 @@ #include <visp/vpServoDisplay.h> #include <visp/vpWireFrameSimulator.h> +void display_trajectory(const vpImage<unsigned char> &I, std::vector<vpPoint> &point, + const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam); + void display_trajectory(const vpImage<unsigned char> &I, std::vector<vpPoint> &point, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam) { @@ -28,85 +31,90 @@ void display_trajectory(const vpImage<unsigned char> &I, std::vector<vpPoint> &p int main() { - vpHomogeneousMatrix cdMo(0, 0, 0.75, 0, 0, 0); - vpHomogeneousMatrix cMo(0.15, -0.1, 1., vpMath::rad(10), vpMath::rad(-10), vpMath::rad(50)); - - std::vector<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); - - vpServo task ; - task.setServo(vpServo::EYEINHAND_CAMERA); - task.setInteractionMatrixType(vpServo::CURRENT); - task.setLambda(0.5); - - vpFeaturePoint p[4], pd[4] ; - for (int i = 0 ; i < 4 ; i++) { - point[i].track(cdMo); - vpFeatureBuilder::create(pd[i], point[i]); - point[i].track(cMo); - vpFeatureBuilder::create(p[i], point[i]); - task.addFeature(p[i], pd[i]); - } + try { + vpHomogeneousMatrix cdMo(0, 0, 0.75, 0, 0, 0); + vpHomogeneousMatrix cMo(0.15, -0.1, 1., vpMath::rad(10), vpMath::rad(-10), vpMath::rad(50)); + + std::vector<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); + + vpServo task ; + task.setServo(vpServo::EYEINHAND_CAMERA); + task.setInteractionMatrixType(vpServo::CURRENT); + task.setLambda(0.5); + + vpFeaturePoint p[4], pd[4] ; + for (unsigned int i = 0 ; i < 4 ; i++) { + point[i].track(cdMo); + vpFeatureBuilder::create(pd[i], point[i]); + point[i].track(cMo); + vpFeatureBuilder::create(p[i], point[i]); + task.addFeature(p[i], pd[i]); + } - vpHomogeneousMatrix wMc, wMo; - vpSimulatorCamera robot; - robot.setSamplingTime(0.040); - robot.getPosition(wMc); - wMo = wMc * cMo; + vpHomogeneousMatrix wMc, wMo; + vpSimulatorCamera robot; + robot.setSamplingTime(0.040); + robot.getPosition(wMc); + wMo = wMc * cMo; - vpImage<unsigned char> Iint(480, 640, 0) ; - vpImage<unsigned char> Iext(480, 640, 0) ; + vpImage<unsigned char> Iint(480, 640, 0) ; + vpImage<unsigned char> Iext(480, 640, 0) ; #if defined VISP_HAVE_X11 - vpDisplayX displayInt(Iint, 0, 0, "Internal view"); - vpDisplayX displayExt(Iext, 670, 0, "External view"); + vpDisplayX displayInt(Iint, 0, 0, "Internal view"); + vpDisplayX displayExt(Iext, 670, 0, "External view"); #elif defined VISP_HAVE_GDI - vpDisplayGDI displayInt(Iint, 0, 0, "Internal view"); - vpDisplayGDI displayExt(Iext, 670, 0, "External view"); + vpDisplayGDI displayInt(Iint, 0, 0, "Internal view"); + vpDisplayGDI displayExt(Iext, 670, 0, "External view"); #else - std::cout << "No image viewer is available..." << std::endl; + std::cout << "No image viewer is available..." << std::endl; #endif - vpCameraParameters cam(840, 840, Iint.getWidth()/2, Iint.getHeight()/2); - vpHomogeneousMatrix cextMo(0,0,3, 0,0,0); - - vpWireFrameSimulator sim; - sim.initScene(vpWireFrameSimulator::PLATE, vpWireFrameSimulator::D_STANDARD); - sim.setCameraPositionRelObj(cMo); - sim.setDesiredCameraPosition(cdMo); - sim.setExternalCameraPosition(cextMo); - sim.setInternalCameraParameters(cam); - sim.setExternalCameraParameters(cam); - - while(1) { - robot.getPosition(wMc); - cMo = wMc.inverse() * wMo; - for (int i = 0 ; i < 4 ; i++) { - point[i].track(cMo); - vpFeatureBuilder::create(p[i], point[i]); - } - vpColVector v = task.computeControlLaw(); - robot.setVelocity(vpRobot::CAMERA_FRAME, v); + vpCameraParameters cam(840, 840, Iint.getWidth()/2, Iint.getHeight()/2); + vpHomogeneousMatrix cextMo(0,0,3, 0,0,0); + vpWireFrameSimulator sim; + sim.initScene(vpWireFrameSimulator::PLATE, vpWireFrameSimulator::D_STANDARD); sim.setCameraPositionRelObj(cMo); - - vpDisplay::display(Iint) ; - vpDisplay::display(Iext) ; - - sim.getInternalImage(Iint); - sim.getExternalImage(Iext); - - display_trajectory(Iint, point, cMo, cam); - vpDisplay::flush(Iint); - vpDisplay::flush(Iext); - - // A click in the internal view to exit - if (vpDisplay::getClick(Iint, false)) - break; - vpTime::wait(1000*robot.getSamplingTime()); + sim.setDesiredCameraPosition(cdMo); + sim.setExternalCameraPosition(cextMo); + sim.setInternalCameraParameters(cam); + sim.setExternalCameraParameters(cam); + + while(1) { + robot.getPosition(wMc); + cMo = wMc.inverse() * wMo; + for (unsigned int i = 0 ; i < 4 ; i++) { + point[i].track(cMo); + vpFeatureBuilder::create(p[i], point[i]); + } + vpColVector v = task.computeControlLaw(); + robot.setVelocity(vpRobot::CAMERA_FRAME, v); + + sim.setCameraPositionRelObj(cMo); + + vpDisplay::display(Iint) ; + vpDisplay::display(Iext) ; + + sim.getInternalImage(Iint); + sim.getExternalImage(Iext); + + display_trajectory(Iint, point, cMo, cam); + vpDisplay::flush(Iint); + vpDisplay::flush(Iext); + + // A click in the internal view to exit + if (vpDisplay::getClick(Iint, false)) + break; + vpTime::wait(1000*robot.getSamplingTime()); + } + task.kill(); + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; } - task.kill(); } diff --git a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-wireframe-robot-afma6.cpp b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-wireframe-robot-afma6.cpp index 590aa30998b6a5d54a80a154ace304c3adc36ed2..ab10745d13c35b77544ee467cb44bcd0913c72c3 100644 --- a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-wireframe-robot-afma6.cpp +++ b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-wireframe-robot-afma6.cpp @@ -5,10 +5,13 @@ #include <visp/vpServo.h> #include <visp/vpSimulatorAfma6.h> +void display_trajectory(const vpImage<unsigned char> &I, std::vector<vpPoint> &point, + const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam); + void display_trajectory(const vpImage<unsigned char> &I, std::vector<vpPoint> &point, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam) { - int thickness = 3; + unsigned int thickness = 3; static std::vector<vpImagePoint> traj[4]; vpImagePoint cog; for (unsigned int i=0; i<4; i++) { @@ -27,10 +30,11 @@ void display_trajectory(const vpImage<unsigned char> &I, std::vector<vpPoint> &p int main() { #if defined(VISP_HAVE_PTHREAD) - vpHomogeneousMatrix cdMo(0, 0, 0.75, 0, 0, 0); - vpHomogeneousMatrix cMo(-0.15, 0.1, 1., vpMath::rad(-10), vpMath::rad(10), vpMath::rad(50)); + try { + vpHomogeneousMatrix cdMo(0, 0, 0.75, 0, 0, 0); + vpHomogeneousMatrix cMo(-0.15, 0.1, 1., vpMath::rad(-10), vpMath::rad(10), vpMath::rad(50)); - /* + /* Top view of the world frame, the camera frame and the object frame world, also robot base frame : @@ -53,102 +57,106 @@ int main() c_x <-- */ - vpHomogeneousMatrix wMo(0, 0, 1., 0, 0, 0); - - std::vector<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); - - vpServo task ; - task.setServo(vpServo::EYEINHAND_CAMERA); - task.setInteractionMatrixType(vpServo::CURRENT); - task.setLambda(0.5); - - vpFeaturePoint p[4], pd[4] ; - for (int i = 0 ; i < 4 ; i++) { - point[i].track(cdMo); - vpFeatureBuilder::create(pd[i], point[i]); - point[i].track(cMo); - vpFeatureBuilder::create(p[i], point[i]); - task.addFeature(p[i], pd[i]); - } + vpHomogeneousMatrix wMo(0, 0, 1., 0, 0, 0); + + std::vector<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); + + vpServo task ; + task.setServo(vpServo::EYEINHAND_CAMERA); + task.setInteractionMatrixType(vpServo::CURRENT); + task.setLambda(0.5); + + vpFeaturePoint p[4], pd[4] ; + for (unsigned int i = 0 ; i < 4 ; i++) { + point[i].track(cdMo); + vpFeatureBuilder::create(pd[i], point[i]); + point[i].track(cMo); + vpFeatureBuilder::create(p[i], point[i]); + task.addFeature(p[i], pd[i]); + } - vpSimulatorAfma6 robot(true); - robot.setVerbose(true); + vpSimulatorAfma6 robot(true); + robot.setVerbose(true); - // Get the default joint limits - vpColVector qmin = robot.getJointMin(); - vpColVector qmax = robot.getJointMax(); + // Get the default joint limits + vpColVector qmin = robot.getJointMin(); + vpColVector qmax = robot.getJointMax(); - std::cout << "Robot joint limits: " << std::endl; - for (unsigned int i=0; i< 3; i ++) - std::cout << "Joint " << i << ": min " << qmin[i] << " max " << qmax[i] << " (m)" << std::endl; - for (unsigned int i=3; i< qmin.size(); i ++) - std::cout << "Joint " << i << ": min " << vpMath::deg(qmin[i]) << " max " << vpMath::deg(qmax[i]) << " (deg)" << std::endl; + std::cout << "Robot joint limits: " << std::endl; + for (unsigned int i=0; i< 3; i ++) + std::cout << "Joint " << i << ": min " << qmin[i] << " max " << qmax[i] << " (m)" << std::endl; + for (unsigned int i=3; i< qmin.size(); i ++) + std::cout << "Joint " << i << ": min " << vpMath::deg(qmin[i]) << " max " << vpMath::deg(qmax[i]) << " (deg)" << std::endl; - robot.init(vpAfma6::TOOL_CCMOP, vpCameraParameters::perspectiveProjWithoutDistortion); - robot.setRobotState(vpRobot::STATE_VELOCITY_CONTROL); - robot.initScene(vpWireFrameSimulator::PLATE, vpWireFrameSimulator::D_STANDARD); - robot.set_fMo(wMo); - bool ret = true; + robot.init(vpAfma6::TOOL_CCMOP, vpCameraParameters::perspectiveProjWithoutDistortion); + robot.setRobotState(vpRobot::STATE_VELOCITY_CONTROL); + robot.initScene(vpWireFrameSimulator::PLATE, vpWireFrameSimulator::D_STANDARD); + robot.set_fMo(wMo); + bool ret = true; #if VISP_VERSION_INT > VP_VERSION_INT(2,7,0) - ret = -#endif - robot.initialiseCameraRelativeToObject(cMo); - if (ret == false) - return 0; // Not able to set the position - robot.setDesiredCameraPosition(cdMo); - - vpImage<unsigned char> Iint(480, 640, 255); + ret = + #endif + robot.initialiseCameraRelativeToObject(cMo); + if (ret == false) + return 0; // Not able to set the position + robot.setDesiredCameraPosition(cdMo); + + vpImage<unsigned char> Iint(480, 640, 255); #if defined(VISP_HAVE_X11) - vpDisplayX displayInt(Iint, 700, 0, "Internal view"); + vpDisplayX displayInt(Iint, 700, 0, "Internal view"); #elif defined(VISP_HAVE_GDI) - vpDisplayGDI displayInt(Iint, 700, 0, "Internal view"); + vpDisplayGDI displayInt(Iint, 700, 0, "Internal view"); #else - std::cout << "No image viewer is available..." << std::endl; + std::cout << "No image viewer is available..." << std::endl; #endif - vpCameraParameters cam(840, 840, Iint.getWidth()/2, Iint.getHeight()/2); - robot.setCameraParameters(cam); - - bool start = true; - for ( ; ; ) - { - cMo = robot.get_cMo(); - - for (int i = 0 ; i < 4 ; i++) { - point[i].track(cMo); - vpFeatureBuilder::create(p[i], point[i]); - } + vpCameraParameters cam(840, 840, Iint.getWidth()/2, Iint.getHeight()/2); + robot.setCameraParameters(cam); + + bool start = true; + for ( ; ; ) + { + cMo = robot.get_cMo(); + + for (unsigned int i = 0 ; i < 4 ; i++) { + point[i].track(cMo); + vpFeatureBuilder::create(p[i], point[i]); + } + + vpDisplay::display(Iint); + robot.getInternalView(Iint); + if (!start) { + display_trajectory(Iint, point, cMo, cam); + vpDisplay::displayCharString(Iint, 40, 120, "Click to stop the servo...", vpColor::red); + } + vpDisplay::flush(Iint); - vpDisplay::display(Iint); - robot.getInternalView(Iint); - if (!start) { - display_trajectory(Iint, point, cMo, cam); - vpDisplay::displayCharString(Iint, 40, 120, "Click to stop the servo...", vpColor::red); - } - vpDisplay::flush(Iint); + vpColVector v = task.computeControlLaw(); + robot.setVelocity(vpRobot::CAMERA_FRAME, v); - vpColVector v = task.computeControlLaw(); - robot.setVelocity(vpRobot::CAMERA_FRAME, v); + // A click to exit + if (vpDisplay::getClick(Iint, false)) + break; - // A click to exit - if (vpDisplay::getClick(Iint, false)) - break; + if (start) { + start = false; + v = 0; + robot.setVelocity(vpRobot::CAMERA_FRAME, v); + vpDisplay::displayCharString(Iint, 40, 120, "Click to start the servo...", vpColor::blue); + vpDisplay::flush(Iint); + vpDisplay::getClick(Iint); + } - if (start) { - start = false; - v = 0; - robot.setVelocity(vpRobot::CAMERA_FRAME, v); - vpDisplay::displayCharString(Iint, 40, 120, "Click to start the servo...", vpColor::blue); - vpDisplay::flush(Iint); - vpDisplay::getClick(Iint); + vpTime::wait(1000*robot.getSamplingTime()); } - - vpTime::wait(1000*robot.getSamplingTime()); + task.kill(); + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; } - task.kill(); #endif } diff --git a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-wireframe-robot-viper.cpp b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-wireframe-robot-viper.cpp index f0a3b377998d1c9c4f1e8ae37a54ee7e4614d29d..3ad1147583827ddf2e3aaf0e24d4832a337bb6da 100644 --- a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-wireframe-robot-viper.cpp +++ b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-wireframe-robot-viper.cpp @@ -5,10 +5,13 @@ #include <visp/vpServo.h> #include <visp/vpSimulatorViper850.h> +void display_trajectory(const vpImage<unsigned char> &I, std::vector<vpPoint> &point, + const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam); + void display_trajectory(const vpImage<unsigned char> &I, std::vector<vpPoint> &point, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam) { - int thickness = 3; + unsigned int thickness = 3; static std::vector<vpImagePoint> traj[4]; vpImagePoint cog; for (unsigned int i=0; i<4; i++) { @@ -27,11 +30,11 @@ void display_trajectory(const vpImage<unsigned char> &I, std::vector<vpPoint> &p int main() { #if defined(VISP_HAVE_PTHREAD) + try { + vpHomogeneousMatrix cdMo(0, 0, 0.75, 0, 0, 0); + vpHomogeneousMatrix cMo(0.15, -0.1, 1., vpMath::rad(10), vpMath::rad(-10), vpMath::rad(50)); - vpHomogeneousMatrix cdMo(0, 0, 0.75, 0, 0, 0); - vpHomogeneousMatrix cMo(0.15, -0.1, 1., vpMath::rad(10), vpMath::rad(-10), vpMath::rad(50)); - - /* + /* Top view of the world frame, the camera frame and the object frame world, also robot base frame : --> w_y @@ -53,114 +56,118 @@ int main() c_x <-- */ - vpHomogeneousMatrix wMo(vpTranslationVector(0.40, 0, -0.15), - vpRotationMatrix(vpRxyzVector(-M_PI, 0, M_PI/2.))); - - std::vector<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); - - vpServo task ; - task.setServo(vpServo::EYEINHAND_CAMERA); - task.setInteractionMatrixType(vpServo::CURRENT); - task.setLambda(0.5); - - vpFeaturePoint p[4], pd[4] ; - for (int i = 0 ; i < 4 ; i++) { - point[i].track(cdMo); - vpFeatureBuilder::create(pd[i], point[i]); - point[i].track(cMo); - vpFeatureBuilder::create(p[i], point[i]); - task.addFeature(p[i], pd[i]); - } + vpHomogeneousMatrix wMo(vpTranslationVector(0.40, 0, -0.15), + vpRotationMatrix(vpRxyzVector(-M_PI, 0, M_PI/2.))); + + std::vector<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); + + vpServo task ; + task.setServo(vpServo::EYEINHAND_CAMERA); + task.setInteractionMatrixType(vpServo::CURRENT); + task.setLambda(0.5); + + vpFeaturePoint p[4], pd[4] ; + for (unsigned int i = 0 ; i < 4 ; i++) { + point[i].track(cdMo); + vpFeatureBuilder::create(pd[i], point[i]); + point[i].track(cMo); + vpFeatureBuilder::create(p[i], point[i]); + task.addFeature(p[i], pd[i]); + } - vpSimulatorViper850 robot(true); - robot.setVerbose(true); - - // Enlarge the default joint limits - vpColVector qmin = robot.getJointMin(); - vpColVector qmax = robot.getJointMax(); - qmin[0] = -vpMath::rad(180); - qmax[0] = vpMath::rad(180); - qmax[1] = vpMath::rad(0); - qmax[2] = vpMath::rad(270); - qmin[4] = -vpMath::rad(180); - qmax[4] = vpMath::rad(180); - - robot.setJointLimit(qmin, qmax); - - std::cout << "Robot joint limits: " << std::endl; - for (unsigned int i=0; i< qmin.size(); i ++) - std::cout << "Joint " << i << ": min " << vpMath::deg(qmin[i]) << " max " << vpMath::deg(qmax[i]) << " (deg)" << std::endl; - - robot.init(vpViper850::TOOL_PTGREY_FLEA2_CAMERA, vpCameraParameters::perspectiveProjWithoutDistortion); - robot.setRobotState(vpRobot::STATE_VELOCITY_CONTROL); - robot.initScene(vpWireFrameSimulator::PLATE, vpWireFrameSimulator::D_STANDARD); - robot.set_fMo(wMo); - bool ret = true; + vpSimulatorViper850 robot(true); + robot.setVerbose(true); + + // Enlarge the default joint limits + vpColVector qmin = robot.getJointMin(); + vpColVector qmax = robot.getJointMax(); + qmin[0] = -vpMath::rad(180); + qmax[0] = vpMath::rad(180); + qmax[1] = vpMath::rad(0); + qmax[2] = vpMath::rad(270); + qmin[4] = -vpMath::rad(180); + qmax[4] = vpMath::rad(180); + + robot.setJointLimit(qmin, qmax); + + std::cout << "Robot joint limits: " << std::endl; + for (unsigned int i=0; i< qmin.size(); i ++) + std::cout << "Joint " << i << ": min " << vpMath::deg(qmin[i]) << " max " << vpMath::deg(qmax[i]) << " (deg)" << std::endl; + + robot.init(vpViper850::TOOL_PTGREY_FLEA2_CAMERA, vpCameraParameters::perspectiveProjWithoutDistortion); + robot.setRobotState(vpRobot::STATE_VELOCITY_CONTROL); + robot.initScene(vpWireFrameSimulator::PLATE, vpWireFrameSimulator::D_STANDARD); + robot.set_fMo(wMo); + bool ret = true; #if VISP_VERSION_INT > VP_VERSION_INT(2,7,0) - ret = -#endif - robot.initialiseCameraRelativeToObject(cMo); - if (ret == false) - return 0; // Not able to set the position - robot.setDesiredCameraPosition(cdMo); - // We modify the default external camera position - robot.setExternalCameraPosition(vpHomogeneousMatrix(vpTranslationVector(-0.4, 0.4, 2), - vpRotationMatrix(vpRxyzVector(M_PI/2,0,0)))); - - vpImage<unsigned char> Iint(480, 640, 255); + ret = + #endif + robot.initialiseCameraRelativeToObject(cMo); + if (ret == false) + return 0; // Not able to set the position + robot.setDesiredCameraPosition(cdMo); + // We modify the default external camera position + robot.setExternalCameraPosition(vpHomogeneousMatrix(vpTranslationVector(-0.4, 0.4, 2), + vpRotationMatrix(vpRxyzVector(M_PI/2,0,0)))); + + vpImage<unsigned char> Iint(480, 640, 255); #if defined(VISP_HAVE_X11) - vpDisplayX displayInt(Iint, 700, 0, "Internal view"); + vpDisplayX displayInt(Iint, 700, 0, "Internal view"); #elif defined(VISP_HAVE_GDI) - vpDisplayGDI displayInt(Iint, 700, 0, "Internal view"); + vpDisplayGDI displayInt(Iint, 700, 0, "Internal view"); #else - std::cout << "No image viewer is available..." << std::endl; + std::cout << "No image viewer is available..." << std::endl; #endif - vpCameraParameters cam(840, 840, Iint.getWidth()/2, Iint.getHeight()/2); - // Modify the camera parameters to match those used in the other simulations - robot.setCameraParameters(cam); - - bool start = true; - //for ( ; ; ) - for (int iter =0; iter < 275; iter ++) - { - cMo = robot.get_cMo(); - - for (int i = 0 ; i < 4 ; i++) { - point[i].track(cMo); - vpFeatureBuilder::create(p[i], point[i]); - } + vpCameraParameters cam(840, 840, Iint.getWidth()/2, Iint.getHeight()/2); + // Modify the camera parameters to match those used in the other simulations + robot.setCameraParameters(cam); + + bool start = true; + //for ( ; ; ) + for (int iter =0; iter < 275; iter ++) + { + cMo = robot.get_cMo(); + + for (unsigned int i = 0 ; i < 4 ; i++) { + point[i].track(cMo); + vpFeatureBuilder::create(p[i], point[i]); + } + + vpDisplay::display(Iint); + robot.getInternalView(Iint); + if (!start) { + display_trajectory(Iint, point, cMo, cam); + vpDisplay::displayCharString(Iint, 40, 120, "Click to stop the servo...", vpColor::red); + } + vpDisplay::flush(Iint); - vpDisplay::display(Iint); - robot.getInternalView(Iint); - if (!start) { - display_trajectory(Iint, point, cMo, cam); - vpDisplay::displayCharString(Iint, 40, 120, "Click to stop the servo...", vpColor::red); - } - vpDisplay::flush(Iint); + vpColVector v = task.computeControlLaw(); + robot.setVelocity(vpRobot::CAMERA_FRAME, v); - vpColVector v = task.computeControlLaw(); - robot.setVelocity(vpRobot::CAMERA_FRAME, v); + // A click to exit + if (vpDisplay::getClick(Iint, false)) + break; - // A click to exit - if (vpDisplay::getClick(Iint, false)) - break; + if (start) { + start = false; + v = 0; + robot.setVelocity(vpRobot::CAMERA_FRAME, v); + vpDisplay::displayCharString(Iint, 40, 120, "Click to start the servo...", vpColor::blue); + vpDisplay::flush(Iint); + //vpDisplay::getClick(Iint); + } - if (start) { - start = false; - v = 0; - robot.setVelocity(vpRobot::CAMERA_FRAME, v); - vpDisplay::displayCharString(Iint, 40, 120, "Click to start the servo...", vpColor::blue); - vpDisplay::flush(Iint); - //vpDisplay::getClick(Iint); + vpTime::wait(1000*robot.getSamplingTime()); } - - vpTime::wait(1000*robot.getSamplingTime()); + task.kill(); + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; } - task.kill(); #endif } diff --git a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts.cpp b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts.cpp index 0ecad7c9739c3be692dd9c3251483a136f9c4139..1d676a727b8daced0d6740b3a4a1a129eb1d3a5f 100644 --- a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts.cpp +++ b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts.cpp @@ -5,47 +5,52 @@ int main() { - vpHomogeneousMatrix cdMo(0, 0, 0.75, 0, 0, 0); - vpHomogeneousMatrix cMo(0.15, -0.1, 1., - vpMath::rad(10), vpMath::rad(-10), vpMath::rad(50)); - - 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); - - vpServo task ; - task.setServo(vpServo::EYEINHAND_CAMERA); - task.setInteractionMatrixType(vpServo::CURRENT); - task.setLambda(0.5); - - vpFeaturePoint p[4], pd[4] ; - for (int i = 0 ; i < 4 ; i++) { - point[i].track(cdMo); - vpFeatureBuilder::create(pd[i], point[i]); - point[i].track(cMo); - vpFeatureBuilder::create(p[i], point[i]); - task.addFeature(p[i], pd[i]); - } - - vpHomogeneousMatrix wMc, wMo; - vpSimulatorCamera robot; - robot.setSamplingTime(0.040); - robot.getPosition(wMc); - wMo = wMc * cMo; - - for (unsigned int iter=0; iter < 150; iter ++) { - robot.getPosition(wMc); - cMo = wMc.inverse() * wMo; - for (int i = 0 ; i < 4 ; i++) { + try { + vpHomogeneousMatrix cdMo(0, 0, 0.75, 0, 0, 0); + vpHomogeneousMatrix cMo(0.15, -0.1, 1., + vpMath::rad(10), vpMath::rad(-10), vpMath::rad(50)); + + 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); + + vpServo task ; + task.setServo(vpServo::EYEINHAND_CAMERA); + task.setInteractionMatrixType(vpServo::CURRENT); + task.setLambda(0.5); + + vpFeaturePoint p[4], pd[4] ; + for (unsigned int i = 0 ; i < 4 ; i++) { + point[i].track(cdMo); + vpFeatureBuilder::create(pd[i], point[i]); point[i].track(cMo); vpFeatureBuilder::create(p[i], point[i]); + task.addFeature(p[i], pd[i]); } - vpColVector v = task.computeControlLaw(); - robot.setVelocity(vpRobot::CAMERA_FRAME, v); - } - task.kill(); + vpHomogeneousMatrix wMc, wMo; + vpSimulatorCamera robot; + robot.setSamplingTime(0.040); + robot.getPosition(wMc); + wMo = wMc * cMo; + + for (unsigned int iter=0; iter < 150; iter ++) { + robot.getPosition(wMc); + cMo = wMc.inverse() * wMo; + for (unsigned int i = 0 ; i < 4 ; i++) { + point[i].track(cMo); + vpFeatureBuilder::create(p[i], point[i]); + } + vpColVector v = task.computeControlLaw(); + robot.setVelocity(vpRobot::CAMERA_FRAME, v); + } + + task.kill(); + } + catch(vpException e) { + std::cout << "Catch an exception: " << e << std::endl; + } }