From e8d2a9752b7f6671386c10cf3af0006951b23dfc Mon Sep 17 00:00:00 2001 From: Vladimir Bystricky Date: Fri, 13 Dec 2013 17:25:16 +0400 Subject: [PATCH 1/9] Add support Creative Senz3D camera by Intel Perceptual Computing SDK --- CMakeLists.txt | 7 +- cmake/OpenCVFindIntelPerCSDK.cmake | 51 ++ cmake/OpenCVFindLibsVideo.cmake | 6 + cmake/templates/cvconfig.h.in | 3 + modules/highgui/CMakeLists.txt | 6 + .../include/opencv2/highgui/highgui_c.h | 25 +- modules/highgui/src/cap.cpp | 12 + modules/highgui/src/cap_intelperc.cpp | 699 ++++++++++++++++++ modules/highgui/src/precomp.hpp | 1 + modules/highgui/test/test_precomp.hpp | 1 + samples/cpp/intelperc_capture.cpp | 379 ++++++++++ 11 files changed, 1188 insertions(+), 2 deletions(-) create mode 100644 cmake/OpenCVFindIntelPerCSDK.cmake create mode 100644 modules/highgui/src/cap_intelperc.cpp create mode 100644 samples/cpp/intelperc_capture.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index ebaf45e56a..229b0689af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -163,7 +163,7 @@ OCV_OPTION(WITH_XINE "Include Xine support (GPL)" OFF OCV_OPTION(WITH_OPENCL "Include OpenCL Runtime support" ON IF (NOT IOS) ) OCV_OPTION(WITH_OPENCLAMDFFT "Include AMD OpenCL FFT library support" ON IF (NOT ANDROID AND NOT IOS) ) OCV_OPTION(WITH_OPENCLAMDBLAS "Include AMD OpenCL BLAS library support" ON IF (NOT ANDROID AND NOT IOS) ) - +OCV_OPTION(WITH_INTELPERC "Include Intel Perceptual Computing support" OFF IF WIN32 ) # OpenCV build components # =================================================== @@ -829,6 +829,11 @@ if(DEFINED WITH_XINE) status(" Xine:" HAVE_XINE THEN "YES (ver ${ALIASOF_libxine_VERSION})" ELSE NO) endif(DEFINED WITH_XINE) +if(DEFINED WITH_INTELPERC) + status(" Intel PerC:" HAVE_INTELPERC THEN "YES" ELSE NO) +endif(DEFINED WITH_INTELPERC) + + # ========================== Other third-party libraries ========================== status("") status(" Other third-party libraries:") diff --git a/cmake/OpenCVFindIntelPerCSDK.cmake b/cmake/OpenCVFindIntelPerCSDK.cmake new file mode 100644 index 0000000000..2d45c6e227 --- /dev/null +++ b/cmake/OpenCVFindIntelPerCSDK.cmake @@ -0,0 +1,51 @@ +# Main variables: +# INTELPERC_LIBRARY and INTELPERC_INCLUDES to link Intel Perceptial Computing SDK modules +# HAVE_INTELPERC for conditional compilation OpenCV with/without Intel Perceptial Computing SDK + +if(NOT "${INTELPERC_LIB_DIR}" STREQUAL "${INTELPERC_LIB_DIR_INTERNAL}") + unset(INTELPERC_LIBRARY CACHE) + unset(INTELPERC_LIB_DIR CACHE) +endif() + +if(NOT "${INTELPERC_INCLUDE_DIR}" STREQUAL "${INTELPERC_INCLUDE_DIR_INTERNAL}") + unset(INTELPERC_INCLUDES CACHE) + unset(INTELPERC_INCLUDE_DIR CACHE) +endif() + +if(WIN32) + if(NOT (MSVC64 OR MINGW64)) + find_file(INTELPERC_INCLUDES "pxcsession.h" PATHS "$ENV{PCSDK_DIR}include" DOC "Intel Perceptual Computing SDK interface header") + find_library(INTELPERC_LIBRARY "libpxc.lib" PATHS "$ENV{PCSDK_DIR}lib/Win32" DOC "Intel Perceptual Computing SDK library") + else() + find_file(INTELPERC_INCLUDES "pxcsession.h" PATHS "$ENV{PCSDK_DIR}include" DOC "Intel Perceptual Computing SDK interface header") + find_library(INTELPERC_LIBRARY "libpxc.lib" PATHS "$ENV{PCSDK_DIR}/lib/x64" DOC "Intel Perceptual Computing SDK library") + endif() +endif() + +if(INTELPERC_LIBRARY AND INTELPERC_INCLUDES) + set(HAVE_INTELPERC TRUE) +endif() #if(INTELPERC_LIBRARY AND INTELPERC_INCLUDES) + +get_filename_component(INTELPERC_LIB_DIR "${INTELPERC_LIBRARY}" PATH) +get_filename_component(INTELPERC_INCLUDE_DIR "${INTELPERC_INCLUDES}" PATH) + +if(HAVE_INTELPERC) + set(INTELPERC_LIB_DIR "${INTELPERC_LIB_DIR}" CACHE PATH "Path to Intel Perceptual Computing SDK interface libraries" FORCE) + set(INTELPERC_INCLUDE_DIR "${INTELPERC_INCLUDE_DIR}" CACHE PATH "Path to Intel Perceptual Computing SDK interface headers" FORCE) +endif() + +if(INTELPERC_LIBRARY) + set(INTELPERC_LIB_DIR_INTERNAL "${INTELPERC_LIB_DIR}" CACHE INTERNAL "This is the value of the last time INTELPERC_LIB_DIR was set successfully." FORCE) +else() + message( WARNING, " Intel Perceptual Computing SDK library directory (set by INTELPERC_LIB_DIR variable) is not found or does not have Intel Perceptual Computing SDK libraries." ) +endif() + +if(INTELPERC_INCLUDES) + set(INTELPERC_INCLUDE_DIR_INTERNAL "${INTELPERC_INCLUDE_DIR}" CACHE INTERNAL "This is the value of the last time INTELPERC_INCLUDE_DIR was set successfully." FORCE) +else() + message( WARNING, " Intel Perceptual Computing SDK include directory (set by INTELPERC_INCLUDE_DIR variable) is not found or does not have Intel Perceptual Computing SDK include files." ) +endif() + +mark_as_advanced(FORCE INTELPERC_LIBRARY) +mark_as_advanced(FORCE INTELPERC_INCLUDES) + diff --git a/cmake/OpenCVFindLibsVideo.cmake b/cmake/OpenCVFindLibsVideo.cmake index 00ed56ad31..22b58f5ef1 100644 --- a/cmake/OpenCVFindLibsVideo.cmake +++ b/cmake/OpenCVFindLibsVideo.cmake @@ -250,3 +250,9 @@ if (NOT IOS) set(HAVE_QTKIT YES) endif() endif() + +# --- Intel Perceptual Computing SSDK --- +ocv_clear_vars(HAVE_INTELPERC) +if(WITH_INTELPERC) + include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindIntelPerCSDK.cmake") +endif(WITH_INTELPERC) diff --git a/cmake/templates/cvconfig.h.in b/cmake/templates/cvconfig.h.in index 88c307dd98..f52c5e457c 100644 --- a/cmake/templates/cvconfig.h.in +++ b/cmake/templates/cvconfig.h.in @@ -158,6 +158,9 @@ /* Xine video library */ #cmakedefine HAVE_XINE +/* Intel Perceptual Computing SDK library */ +#cmakedefine HAVE_INTELPERC + /* Define to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel and VAX). */ #cmakedefine WORDS_BIGENDIAN diff --git a/modules/highgui/CMakeLists.txt b/modules/highgui/CMakeLists.txt index c3ad7ca740..5c86a2fcd1 100644 --- a/modules/highgui/CMakeLists.txt +++ b/modules/highgui/CMakeLists.txt @@ -218,6 +218,12 @@ elseif(HAVE_QTKIT) list(APPEND HIGHGUI_LIBRARIES "-framework QTKit" "-framework QuartzCore" "-framework AppKit") endif() +if(HAVE_INTELPERC) + list(APPEND highgui_srcs src/cap_intelperc.cpp) + ocv_include_directories(${INTELPERC_INCLUDE_DIR}) + list(APPEND HIGHGUI_LIBRARIES ${INTELPERC_LIBRARY}) +endif(HAVE_INTELPERC) + if(IOS) add_definitions(-DHAVE_IOS=1) list(APPEND highgui_srcs src/ios_conversions.mm src/cap_ios_abstract_camera.mm src/cap_ios_photo_camera.mm src/cap_ios_video_camera.mm) diff --git a/modules/highgui/include/opencv2/highgui/highgui_c.h b/modules/highgui/include/opencv2/highgui/highgui_c.h index 9204ee81f4..99f453385d 100644 --- a/modules/highgui/include/opencv2/highgui/highgui_c.h +++ b/modules/highgui/include/opencv2/highgui/highgui_c.h @@ -312,7 +312,9 @@ enum CV_CAP_AVFOUNDATION = 1200, // AVFoundation framework for iOS (OS X Lion will have the same API) - CV_CAP_GIGANETIX = 1300 // Smartek Giganetix GigEVisionSDK + CV_CAP_GIGANETIX = 1300, // Smartek Giganetix GigEVisionSDK + + CV_CAP_INTELPERC = 1500 // Intel Perceptual Computing SDK }; /* start capturing frames from camera: index = camera_index + domain_offset (CV_CAP_*) */ @@ -468,6 +470,19 @@ enum CV_CAP_PROP_GIGA_FRAME_HEIGH_MAX = 10004, CV_CAP_PROP_GIGA_FRAME_SENS_WIDTH = 10005, CV_CAP_PROP_GIGA_FRAME_SENS_HEIGH = 10006 + + ,CV_CAP_PROP_INTELPERC_PROFILE_COUNT = 11001, + CV_CAP_PROP_INTELPERC_PROFILE_IDX = 11002, + CV_CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE = 11003, + CV_CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE = 11004, + CV_CAP_PROP_INTELPERC_DEPTH_CONFIDENCE_THRESHOLD = 11005, + CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_HORZ = 11006, + CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_VERT = 11007, + + // Intel PerC streams + CV_CAP_INTELPERC_DEPTH_STREAM = 1 << 31, + CV_CAP_INTELPERC_IMAGE_STREAM = 1 << 30, + CV_CAP_INTELPERC_STREAMS_MASK = CV_CAP_INTELPERC_DEPTH_STREAM + CV_CAP_INTELPERC_IMAGE_STREAM, }; enum @@ -548,6 +563,14 @@ enum CV_CAP_ANDROID_ANTIBANDING_OFF }; +enum +{ + CV_CAP_INTELPERC_DEPTH_MAP = 0, // Each pixel is a 16-bit integer. The value indicates the distance from an object to the camera's XY plane or the Cartesian depth. + CV_CAP_INTELPERC_UVDEPTH_MAP = 1, // Each pixel contains two 32-bit floating point values in the range of 0-1, representing the mapping of depth coordinates to the color coordinates. + CV_CAP_INTELPERC_IR_MAP = 2, // Each pixel is a 16-bit integer. The value indicates the intensity of the reflected laser beam. + CV_CAP_INTELPERC_IMAGE = 3, +}; + /* retrieve or set capture properties */ CVAPI(double) cvGetCaptureProperty( CvCapture* capture, int property_id ); CVAPI(int) cvSetCaptureProperty( CvCapture* capture, int property_id, double value ); diff --git a/modules/highgui/src/cap.cpp b/modules/highgui/src/cap.cpp index bbfcc85964..f3dc8b9787 100644 --- a/modules/highgui/src/cap.cpp +++ b/modules/highgui/src/cap.cpp @@ -155,6 +155,9 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index) #endif #ifdef HAVE_GIGE_API CV_CAP_GIGANETIX, +#endif +#ifdef HAVE_INTELPERC + CV_CAP_INTELPERC, #endif -1 }; @@ -193,6 +196,7 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index) defined(HAVE_AVFOUNDATION) || \ defined(HAVE_ANDROID_NATIVE_CAMERA) || \ defined(HAVE_GIGE_API) || \ + defined(HAVE_INTELPERC) || \ (0) // local variable to memorize the captured device CvCapture *capture; @@ -341,6 +345,14 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index) return capture; break; // CV_CAP_GIGANETIX #endif + +#ifdef HAVE_INTELPERC + case CV_CAP_INTELPERC: + capture = cvCreateCameraCapture_IntelPerC(index); + if (capture) + return capture; + break; // CV_CAP_INTEL_PERC +#endif } } diff --git a/modules/highgui/src/cap_intelperc.cpp b/modules/highgui/src/cap_intelperc.cpp new file mode 100644 index 0000000000..d562dc0c8e --- /dev/null +++ b/modules/highgui/src/cap_intelperc.cpp @@ -0,0 +1,699 @@ +#include "precomp.hpp" + +#ifdef HAVE_INTELPERC + +#if defined TBB_INTERFACE_VERSION && TBB_INTERFACE_VERSION < 5000 +# undef HAVE_TBB +#endif + +#include "pxcsession.h" +#include "pxcsmartptr.h" +#include "pxccapture.h" + +class CvIntelPerCStreamBase +{ +protected: + struct FrameInternal + { + IplImage* retrieveFrame() + { + if (m_mat.empty()) + return NULL; + m_iplHeader = IplImage(m_mat); + return &m_iplHeader; + } + cv::Mat m_mat; + private: + IplImage m_iplHeader; + }; +public: + CvIntelPerCStreamBase() + : m_profileIdx(-1) + , m_frameIdx(0) + , m_timeStampStartNS(0) + { + } + virtual ~CvIntelPerCStreamBase() + { + } + + bool isValid() + { + return (m_device.IsValid() && m_stream.IsValid()); + } + bool grabFrame() + { + if (!m_stream.IsValid()) + return false; + if (-1 == m_profileIdx) + { + if (!setProperty(CV_CAP_PROP_INTELPERC_PROFILE_IDX, 0)) + return false; + } + PXCSmartPtr pxcImage; PXCSmartSP sp; + if (PXC_STATUS_NO_ERROR > m_stream->ReadStreamAsync(&pxcImage, &sp)) + return false; + if (PXC_STATUS_NO_ERROR > sp->Synchronize()) + return false; + if (0 == m_timeStampStartNS) + m_timeStampStartNS = pxcImage->QueryTimeStamp(); + m_timeStamp = (double)((pxcImage->QueryTimeStamp() - m_timeStampStartNS) / 10000); + m_frameIdx++; + return prepareIplImage(pxcImage); + } + int getProfileIDX() const + { + return m_profileIdx; + } +public: + virtual bool initStream(PXCSession *session) = 0; + virtual double getProperty(int propIdx) + { + double ret = 0.0; + switch (propIdx) + { + case CV_CAP_PROP_INTELPERC_PROFILE_COUNT: + ret = (double)m_profiles.size(); + break; + case CV_CAP_PROP_FRAME_WIDTH : + if ((0 <= m_profileIdx) && (m_profileIdx < m_profiles.size())) + ret = (double)m_profiles[m_profileIdx].imageInfo.width; + break; + case CV_CAP_PROP_FRAME_HEIGHT : + if ((0 <= m_profileIdx) && (m_profileIdx < m_profiles.size())) + ret = (double)m_profiles[m_profileIdx].imageInfo.height; + break; + case CV_CAP_PROP_FPS : + if ((0 <= m_profileIdx) && (m_profileIdx < m_profiles.size())) + { + ret = ((double)m_profiles[m_profileIdx].frameRateMin.numerator / (double)m_profiles[m_profileIdx].frameRateMin.denominator + + (double)m_profiles[m_profileIdx].frameRateMax.numerator / (double)m_profiles[m_profileIdx].frameRateMax.denominator) / 2.0; + } + break; + case CV_CAP_PROP_POS_FRAMES: + ret = (double)m_frameIdx; + break; + case CV_CAP_PROP_POS_MSEC: + ret = m_timeStamp; + break; + }; + return ret; + } + virtual bool setProperty(int propIdx, double propVal) + { + bool isSet = false; + switch (propIdx) + { + case CV_CAP_PROP_INTELPERC_PROFILE_IDX: + { + int propValInt = (int)propVal; + if ((0 <= propValInt) && (propValInt < m_profiles.size())) + { + if (m_profileIdx != propValInt) + { + m_profileIdx = propValInt; + if (m_stream.IsValid()) + m_stream->SetProfile(&m_profiles[m_profileIdx]); + m_frameIdx = 0; + m_timeStampStartNS = 0; + } + isSet = true; + } + } + break; + }; + return isSet; + } +protected: + PXCSmartPtr m_device; + bool initDevice(PXCSession *session) + { + if (NULL == session) + return false; + + pxcStatus sts = PXC_STATUS_NO_ERROR; + PXCSession::ImplDesc templat; + memset(&templat,0,sizeof(templat)); + templat.group = PXCSession::IMPL_GROUP_SENSOR; + templat.subgroup= PXCSession::IMPL_SUBGROUP_VIDEO_CAPTURE; + + for (int modidx = 0; PXC_STATUS_NO_ERROR <= sts; modidx++) + { + PXCSession::ImplDesc desc; + sts = session->QueryImpl(&templat, modidx, &desc); + if (PXC_STATUS_NO_ERROR > sts) + break; + + PXCSmartPtr capture; + sts = session->CreateImpl(&desc, &capture); + if (!capture.IsValid()) + continue; + + /* enumerate devices */ + for (int devidx = 0; PXC_STATUS_NO_ERROR <= sts; devidx++) + { + PXCSmartPtr device; + sts = capture->CreateDevice(devidx, &device); + if (PXC_STATUS_NO_ERROR <= sts) + { + m_device = device.ReleasePtr(); + return true; + } + } + } + return false; + } + + PXCSmartPtr m_stream; + void initStreamImpl(PXCImage::ImageType type) + { + if (!m_device.IsValid()) + return; + + pxcStatus sts = PXC_STATUS_NO_ERROR; + /* enumerate streams */ + for (int streamidx = 0; PXC_STATUS_NO_ERROR <= sts; streamidx++) + { + PXCCapture::Device::StreamInfo sinfo; + sts = m_device->QueryStream(streamidx, &sinfo); + if (PXC_STATUS_NO_ERROR > sts) + break; + if (PXCCapture::VideoStream::CUID != sinfo.cuid) + continue; + if (type != sinfo.imageType) + continue; + + sts = m_device->CreateStream(streamidx, &m_stream); + if (PXC_STATUS_NO_ERROR == sts) + break; + m_stream.ReleaseRef(); + } + } +protected: + std::vector m_profiles; + int m_profileIdx; + int m_frameIdx; + pxcU64 m_timeStampStartNS; + double m_timeStamp; + void enumProfiles() + { + m_profiles.clear(); + if (!m_stream.IsValid()) + return; + pxcStatus sts = PXC_STATUS_NO_ERROR; + for (int profidx = 0; PXC_STATUS_NO_ERROR <= sts; profidx++) + { + PXCCapture::VideoStream::ProfileInfo pinfo; + sts = m_stream->QueryProfile(profidx, &pinfo); + if (PXC_STATUS_NO_ERROR > sts) + break; + m_profiles.push_back(pinfo); + } + } + virtual bool prepareIplImage(PXCImage *pxcImage) = 0; +}; + +class CvIntelPerCStreamImage + : public CvIntelPerCStreamBase +{ +public: + CvIntelPerCStreamImage() + { + } + virtual ~CvIntelPerCStreamImage() + { + } + + virtual bool initStream(PXCSession *session) + { + if (!initDevice(session)) + return false; + initStreamImpl(PXCImage::IMAGE_TYPE_COLOR); + if (!m_stream.IsValid()) + return false; + enumProfiles(); + return true; + } + virtual double getProperty(int propIdx) + { + switch (propIdx) + { + case CV_CAP_PROP_BRIGHTNESS: + { + if (!m_device.IsValid()) + return 0.0; + float fret = 0.0f; + if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_COLOR_BRIGHTNESS, &fret)) + return (double)fret; + return 0.0; + } + break; + case CV_CAP_PROP_CONTRAST: + { + if (!m_device.IsValid()) + return 0.0; + float fret = 0.0f; + if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_COLOR_CONTRAST, &fret)) + return (double)fret; + return 0.0; + } + break; + case CV_CAP_PROP_SATURATION: + { + if (!m_device.IsValid()) + return 0.0; + float fret = 0.0f; + if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_COLOR_SATURATION, &fret)) + return (double)fret; + return 0.0; + } + break; + case CV_CAP_PROP_HUE: + { + if (!m_device.IsValid()) + return 0.0; + float fret = 0.0f; + if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_COLOR_HUE, &fret)) + return (double)fret; + return 0.0; + } + break; + case CV_CAP_PROP_GAMMA: + { + if (!m_device.IsValid()) + return 0.0; + float fret = 0.0f; + if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_COLOR_GAMMA, &fret)) + return (double)fret; + return 0.0; + } + break; + case CV_CAP_PROP_SHARPNESS: + { + if (!m_device.IsValid()) + return 0.0; + float fret = 0.0f; + if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_COLOR_SHARPNESS, &fret)) + return (double)fret; + return 0.0; + } + break; + case CV_CAP_PROP_GAIN: + { + if (!m_device.IsValid()) + return 0.0; + float fret = 0.0f; + if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_COLOR_GAIN, &fret)) + return (double)fret; + return 0.0; + } + break; + case CV_CAP_PROP_BACKLIGHT: + { + if (!m_device.IsValid()) + return 0.0; + float fret = 0.0f; + if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_COLOR_BACK_LIGHT_COMPENSATION, &fret)) + return (double)fret; + return 0.0; + } + break; + case CV_CAP_PROP_EXPOSURE: + { + if (!m_device.IsValid()) + return 0.0; + float fret = 0.0f; + if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_COLOR_EXPOSURE, &fret)) + return (double)fret; + return 0.0; + } + break; + //Add image stream specific properties + } + return CvIntelPerCStreamBase::getProperty(propIdx); + } + virtual bool setProperty(int propIdx, double propVal) + { + switch (propIdx) + { + case CV_CAP_PROP_BRIGHTNESS: + { + if (!m_device.IsValid()) + return false; + return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_COLOR_BRIGHTNESS, (float)propVal)); + } + break; + case CV_CAP_PROP_CONTRAST: + { + if (!m_device.IsValid()) + return false; + return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_COLOR_CONTRAST, (float)propVal)); + } + break; + case CV_CAP_PROP_SATURATION: + { + if (!m_device.IsValid()) + return false; + return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_COLOR_SATURATION, (float)propVal)); + } + break; + case CV_CAP_PROP_HUE: + { + if (!m_device.IsValid()) + return false; + return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_COLOR_HUE, (float)propVal)); + } + break; + case CV_CAP_PROP_GAMMA: + { + if (!m_device.IsValid()) + return false; + return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_COLOR_GAMMA, (float)propVal)); + } + break; + case CV_CAP_PROP_SHARPNESS: + { + if (!m_device.IsValid()) + return false; + return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_COLOR_SHARPNESS, (float)propVal)); + } + break; + case CV_CAP_PROP_GAIN: + { + if (!m_device.IsValid()) + return false; + return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_COLOR_GAIN, (float)propVal)); + } + break; + case CV_CAP_PROP_BACKLIGHT: + { + if (!m_device.IsValid()) + return false; + return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_COLOR_BACK_LIGHT_COMPENSATION, (float)propVal)); + } + break; + case CV_CAP_PROP_EXPOSURE: + { + if (!m_device.IsValid()) + return false; + return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_COLOR_EXPOSURE, (float)propVal)); + } + break; + //Add image stream specific properties + } + return CvIntelPerCStreamBase::setProperty(propIdx, propVal); + } +public: + IplImage* retrieveFrame() + { + return m_frame.retrieveFrame(); + } +protected: + FrameInternal m_frame; + bool prepareIplImage(PXCImage *pxcImage) + { + if (NULL == pxcImage) + return false; + PXCImage::ImageInfo info; + pxcImage->QueryInfo(&info); + + PXCImage::ImageData data; + pxcImage->AcquireAccess(PXCImage::ACCESS_READ, PXCImage::COLOR_FORMAT_RGB24, &data); + + if (PXCImage::SURFACE_TYPE_SYSTEM_MEMORY != data.type) + return false; + + cv::Mat temp(info.height, info.width, CV_8UC3, data.planes[0], data.pitches[0]); + temp.copyTo(m_frame.m_mat); + + pxcImage->ReleaseAccess(&data); + return true; + } +}; + +class CvIntelPerCStreamDepth + : public CvIntelPerCStreamBase +{ +public: + CvIntelPerCStreamDepth() + { + } + virtual ~CvIntelPerCStreamDepth() + { + } + + virtual bool initStream(PXCSession *session) + { + if (!initDevice(session)) + return false; + initStreamImpl(PXCImage::IMAGE_TYPE_DEPTH); + if (!m_stream.IsValid()) + return false; + enumProfiles(); + return true; + } + virtual double getProperty(int propIdx) + { + switch (propIdx) + { + case CV_CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE: + { + if (!m_device.IsValid()) + return 0.0; + float fret = 0.0f; + if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_DEPTH_LOW_CONFIDENCE_VALUE, &fret)) + return (double)fret; + return 0.0; + } + break; + case CV_CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE: + { + if (!m_device.IsValid()) + return 0.0; + float fret = 0.0f; + if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_DEPTH_SATURATION_VALUE, &fret)) + return (double)fret; + return 0.0; + } + break; + case CV_CAP_PROP_INTELPERC_DEPTH_CONFIDENCE_THRESHOLD: + { + if (!m_device.IsValid()) + return 0.0; + float fret = 0.0f; + if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_DEPTH_CONFIDENCE_THRESHOLD, &fret)) + return (double)fret; + return 0.0; + } + break; + case CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_HORZ: + { + if (!m_device.IsValid()) + return 0.0f; + PXCPointF32 ptf; + if (PXC_STATUS_NO_ERROR == m_device->QueryPropertyAsPoint(PXCCapture::Device::PROPERTY_DEPTH_FOCAL_LENGTH, &ptf)) + return (double)ptf.x; + return 0.0; + } + break; + case CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_VERT: + { + if (!m_device.IsValid()) + return 0.0f; + PXCPointF32 ptf; + if (PXC_STATUS_NO_ERROR == m_device->QueryPropertyAsPoint(PXCCapture::Device::PROPERTY_DEPTH_FOCAL_LENGTH, &ptf)) + return (double)ptf.y; + return 0.0; + } + break; + //Add depth stream sepcific properties + } + return CvIntelPerCStreamBase::getProperty(propIdx); + } + virtual bool setProperty(int propIdx, double propVal) + { + switch (propIdx) + { + case CV_CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE: + { + if (!m_device.IsValid()) + return false; + return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_DEPTH_LOW_CONFIDENCE_VALUE, (float)propVal)); + } + break; + case CV_CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE: + { + if (!m_device.IsValid()) + return false; + return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_DEPTH_SATURATION_VALUE, (float)propVal)); + } + break; + case CV_CAP_PROP_INTELPERC_DEPTH_CONFIDENCE_THRESHOLD: + { + if (!m_device.IsValid()) + return false; + return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_DEPTH_CONFIDENCE_THRESHOLD, (float)propVal)); + } + break; + //Add depth stream sepcific properties + } + return CvIntelPerCStreamBase::setProperty(propIdx, propVal); + } +public: + IplImage* retrieveDepthFrame() + { + return m_frameDepth.retrieveFrame(); + } + IplImage* retrieveIRFrame() + { + return m_frameIR.retrieveFrame(); + } + IplImage* retrieveUVFrame() + { + return m_frameUV.retrieveFrame(); + } +protected: + FrameInternal m_frameDepth; + FrameInternal m_frameIR; + FrameInternal m_frameUV; + + bool prepareIplImage(PXCImage *pxcImage) + { + if (NULL == pxcImage) + return false; + PXCImage::ImageInfo info; + pxcImage->QueryInfo(&info); + + PXCImage::ImageData data; + pxcImage->AcquireAccess(PXCImage::ACCESS_READ, &data); + + if (PXCImage::SURFACE_TYPE_SYSTEM_MEMORY != data.type) + return false; + + if (PXCImage::COLOR_FORMAT_DEPTH != data.format) + return false; + + { + cv::Mat temp(info.height, info.width, CV_16SC1, data.planes[0], data.pitches[0]); + temp.copyTo(m_frameDepth.m_mat); + } + { + cv::Mat temp(info.height, info.width, CV_16SC1, data.planes[1], data.pitches[1]); + temp.copyTo(m_frameIR.m_mat); + } + { + cv::Mat temp(info.height, info.width, CV_32FC2, data.planes[2], data.pitches[2]); + temp.copyTo(m_frameUV.m_mat); + } + + pxcImage->ReleaseAccess(&data); + return true; + } +}; + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +class CvCapture_IntelPerC : public CvCapture +{ +public: + CvCapture_IntelPerC(int /*index*/) + : m_contextOpened(false) + { + pxcStatus sts = PXCSession_Create(&m_session); + if (PXC_STATUS_NO_ERROR > sts) + return; + m_contextOpened = m_imageStream.initStream(m_session); + m_contextOpened &= m_depthStream.initStream(m_session); + } + virtual ~CvCapture_IntelPerC(){} + + virtual double getProperty(int propIdx) + { + double propValue = 0; + int purePropIdx = propIdx & ~CV_CAP_INTELPERC_STREAMS_MASK; + if (CV_CAP_INTELPERC_IMAGE_STREAM == (propIdx & CV_CAP_INTELPERC_STREAMS_MASK)) + { + propValue = m_imageStream.getProperty(purePropIdx); + } + else if (CV_CAP_INTELPERC_DEPTH_STREAM == (propIdx & CV_CAP_INTELPERC_STREAMS_MASK)) + { + propValue = m_depthStream.getProperty(purePropIdx); + } + return propValue; + } + virtual bool setProperty(int propIdx, double propVal) + { + bool isSet = false; + int purePropIdx = propIdx & ~CV_CAP_INTELPERC_STREAMS_MASK; + if (CV_CAP_INTELPERC_IMAGE_STREAM == (propIdx & CV_CAP_INTELPERC_STREAMS_MASK)) + { + isSet = m_imageStream.setProperty(purePropIdx, propVal); + } + else if (CV_CAP_INTELPERC_DEPTH_STREAM == (propIdx & CV_CAP_INTELPERC_STREAMS_MASK)) + { + isSet = m_depthStream.setProperty(purePropIdx, propVal); + } + return isSet; + } + + bool grabFrame() + { + if (!isOpened()) + return false; + + bool isGrabbed = false; + if (m_depthStream.isValid()) + isGrabbed = m_depthStream.grabFrame(); + if ((m_imageStream.isValid()) && (-1 != m_imageStream.getProfileIDX())) + isGrabbed &= m_imageStream.grabFrame(); + + return isGrabbed; + } + + virtual IplImage* retrieveFrame(int outputType) + { + IplImage* image = 0; + switch (outputType) + { + case CV_CAP_INTELPERC_DEPTH_MAP: + image = m_depthStream.retrieveDepthFrame(); + break; + case CV_CAP_INTELPERC_UVDEPTH_MAP: + image = m_depthStream.retrieveUVFrame(); + break; + case CV_CAP_INTELPERC_IR_MAP: + image = m_depthStream.retrieveIRFrame(); + break; + case CV_CAP_INTELPERC_IMAGE: + image = m_imageStream.retrieveFrame(); + break; + } + CV_Assert(NULL != image); + return image; + } + + bool isOpened() const + { + return m_contextOpened; + } +protected: + bool m_contextOpened; + + PXCSmartPtr m_session; + CvIntelPerCStreamImage m_imageStream; + CvIntelPerCStreamDepth m_depthStream; +}; + + +CvCapture* cvCreateCameraCapture_IntelPerC(int index) +{ + CvCapture_IntelPerC* capture = new CvCapture_IntelPerC(index); + + if( capture->isOpened() ) + return capture; + + delete capture; + return 0; +} + + +#endif //HAVE_INTELPERC diff --git a/modules/highgui/src/precomp.hpp b/modules/highgui/src/precomp.hpp index dcd4afdc01..88ba8e4b20 100644 --- a/modules/highgui/src/precomp.hpp +++ b/modules/highgui/src/precomp.hpp @@ -127,6 +127,7 @@ CvCapture* cvCreateFileCapture_OpenNI( const char* filename ); CvCapture* cvCreateCameraCapture_Android( int index ); CvCapture* cvCreateCameraCapture_XIMEA( int index ); CvCapture* cvCreateCameraCapture_AVFoundation(int index); +CvCapture* cvCreateCameraCapture_IntelPerC(int index); CVAPI(int) cvHaveImageReader(const char* filename); diff --git a/modules/highgui/test/test_precomp.hpp b/modules/highgui/test/test_precomp.hpp index 7e9f4c63af..e166d9d80c 100644 --- a/modules/highgui/test/test_precomp.hpp +++ b/modules/highgui/test/test_precomp.hpp @@ -34,6 +34,7 @@ defined(HAVE_XIMEA) || \ defined(HAVE_AVFOUNDATION) || \ defined(HAVE_GIGE_API) || \ + defined(HAVE_INTELPERC) || \ (0) //defined(HAVE_ANDROID_NATIVE_CAMERA) || - enable after #1193 # define BUILD_WITH_CAMERA_SUPPORT 1 diff --git a/samples/cpp/intelperc_capture.cpp b/samples/cpp/intelperc_capture.cpp new file mode 100644 index 0000000000..7744377c5a --- /dev/null +++ b/samples/cpp/intelperc_capture.cpp @@ -0,0 +1,379 @@ +// testOpenCVCam.cpp : Defines the entry point for the console application. +// + +#include +#include "opencv2/highgui/highgui.hpp" +//#include "opencv2/imgproc/imgproc.hpp" + +#include + +using namespace cv; +using namespace std; + +static bool g_printStreamSetting = false; +static int g_imageStreamProfileIdx = -1; +static int g_depthStreamProfileIdx = -1; +static bool g_irStreamShow = false; +static double g_imageBrightness = -DBL_MAX; +static double g_imageContrast = -DBL_MAX; +static bool g_printTiming = false; +static bool g_showClosedPoint = false; + + +static int g_closedDepthPoint[2]; + +static void printUsage(char *arg0) +{ + char *filename = arg0; + while (*filename) + filename++; + while ((arg0 <= filename) && ('\\' != *filename) && ('//' != *filename)) + filename--; + filename++; + + cout << "This program demonstrates usage of camera supported\nby Intel Perceptual computing SDK." << endl << endl; + cout << "usage: " << filename << "[-ps] [-isp IDX] [-dsp IDX]\n [-ir] [-imb VAL] [-imc VAL]" << endl << endl; + cout << " -ps, print streams setting and profiles" << endl; + cout << " -isp IDX, set profile index of the image stream" << endl; + cout << " -dsp IDX, set profile index of the depth stream" << endl; + cout << " -ir, show data from IR stream" << endl; + cout << " -imb VAL, set brighness value for a image stream" << endl; + cout << " -imc VAL, set contrast value for a image stream" << endl; + cout << " -pts, print frame index and frame time" << endl; + cout << " --show-closed, print frame index and frame time" << endl; + cout << endl; +} + +static void parseCMDLine(int argc, char* argv[]) +{ + if( argc == 1 ) + { + printUsage(argv[0]); + } + else + { + for( int i = 1; i < argc; i++ ) + { + if ((0 == strcmp(argv[i], "--help")) || (0 == strcmp( argv[i], "-h"))) + { + printUsage(argv[0]); + exit(0); + } + else if ((0 == strcmp( argv[i], "--print-streams")) || (0 == strcmp( argv[i], "-ps"))) + { + g_printStreamSetting = true; + } + else if ((0 == strcmp( argv[i], "--image-stream-prof")) || (0 == strcmp( argv[i], "-isp"))) + { + g_imageStreamProfileIdx = atoi(argv[++i]); + } + else if ((0 == strcmp( argv[i], "--depth-stream-prof")) || (0 == strcmp( argv[i], "-dsp"))) + { + g_depthStreamProfileIdx = atoi(argv[++i]); + } + else if (0 == strcmp( argv[i], "-ir")) + { + g_irStreamShow = true; + } + else if (0 == strcmp( argv[i], "-imb")) + { + g_imageBrightness = atof(argv[++i]); + } + else if (0 == strcmp( argv[i], "-imc")) + { + g_imageContrast = atof(argv[++i]); + } + else if (0 == strcmp(argv[i], "-pts")) + { + g_printTiming = true; + } + else if (0 == strcmp(argv[i], "--show-closed")) + { + g_showClosedPoint = true; + } + else + { + cout << "Unsupported command line argument: " << argv[i] << "." << endl; + exit(-1); + } + } + if (g_closedDepthPoint && (-1 == g_depthStreamProfileIdx)) + { + cerr << "For --show-closed depth profile has be selected" << endl; + exit(-1); + } + } +} + +static void printStreamProperties(VideoCapture &capture) +{ + size_t profilesCount = (size_t)capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_INTELPERC_PROFILE_COUNT); + cout << "Image stream." << endl; + cout << " Brightness = " << capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_BRIGHTNESS) << endl; + cout << " Contrast = " << capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_CONTRAST) << endl; + cout << " Saturation = " << capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_SATURATION) << endl; + cout << " Hue = " << capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_HUE) << endl; + cout << " Gamma = " << capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_GAMMA) << endl; + cout << " Sharpness = " << capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_SHARPNESS) << endl; + cout << " Gain = " << capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_GAIN) << endl; + cout << " Backligh = " << capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_BACKLIGHT) << endl; + cout << "Image streams profiles:" << endl; + for (size_t i = 0; i < profilesCount; i++) + { + capture.set(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_INTELPERC_PROFILE_IDX, (double)i); + cout << " Profile[" << i << "]: "; + cout << "width = " << + (int)capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_FRAME_WIDTH); + cout << ", height = " << + (int)capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_FRAME_HEIGHT); + cout << ", fps = " << + capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_FPS); + cout << endl; + } + + profilesCount = (size_t)capture.get(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_INTELPERC_PROFILE_COUNT); + cout << "Depth stream." << endl; + cout << " Low confidence value = " << capture.get(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE) << endl; + cout << " Saturation value = " << capture.get(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE) << endl; + cout << " Confidence threshold = " << capture.get(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_INTELPERC_DEPTH_CONFIDENCE_THRESHOLD) << endl; + cout << " Focal length = (" << capture.get(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_HORZ) << ", " + << capture.get(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_VERT) << ")" << endl; + cout << "Depth streams profiles:" << endl; + for (size_t i = 0; i < profilesCount; i++) + { + capture.set(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_INTELPERC_PROFILE_IDX, (double)i); + cout << " Profile[" << i << "]: "; + cout << "width = " << + (int)capture.get(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_FRAME_WIDTH); + cout << ", height = " << + (int)capture.get(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_FRAME_HEIGHT); + cout << ", fps = " << + capture.get(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_FPS); + cout << endl; + } +} + +static void imshowImage(const char *winname, Mat &image, VideoCapture &capture) +{ + if (g_closedDepthPoint) + { + Mat uvMap; + if (capture.retrieve(uvMap, CV_CAP_INTELPERC_UVDEPTH_MAP)) + { + float *uvmap = (float *)uvMap.ptr() + 2 * (g_closedDepthPoint[0] * uvMap.cols + g_closedDepthPoint[1]); + int x = (int)((*uvmap) * image.cols); uvmap++; + int y = (int)((*uvmap) * image.rows); + + if ((0 <= x) && (0 <= y)) + { + static const int pointSize = 4; + for (int row = y; row < min(y + pointSize, image.rows); row++) + { + uchar* ptrDst = image.ptr(row) + x * 3 + 2;//+2 -> Red + for (int col = 0; col < min(pointSize, image.cols - x); col++, ptrDst+=3) + { + *ptrDst = 255; + } + } + } + } + } + imshow(winname, image); +} +static void imshowIR(const char *winname, Mat &ir) +{ + Mat image; + if (g_showClosedPoint) + { + image.create(ir.rows, ir.cols, CV_8UC3); + for (int row = 0; row < ir.rows; row++) + { + uchar* ptrDst = image.ptr(row); + short* ptrSrc = (short*)ir.ptr(row); + for (int col = 0; col < ir.cols; col++, ptrSrc++) + { + uchar val = (uchar) ((*ptrSrc) >> 2); + *ptrDst = val; ptrDst++; + *ptrDst = val; ptrDst++; + *ptrDst = val; ptrDst++; + } + } + + static const int pointSize = 4; + for (int row = g_closedDepthPoint[0]; row < min(g_closedDepthPoint[0] + pointSize, image.rows); row++) + { + uchar* ptrDst = image.ptr(row) + g_closedDepthPoint[1] * 3 + 2;//+2 -> Red + for (int col = 0; col < min(pointSize, image.cols - g_closedDepthPoint[1]); col++, ptrDst+=3) + { + *ptrDst = 255; + } + } + } + else + { + image.create(ir.rows, ir.cols, CV_8UC1); + for (int row = 0; row < ir.rows; row++) + { + uchar* ptrDst = image.ptr(row); + short* ptrSrc = (short*)ir.ptr(row); + for (int col = 0; col < ir.cols; col++, ptrSrc++, ptrDst++) + { + *ptrDst = (uchar) ((*ptrSrc) >> 2); + } + } + } + + imshow(winname, image); +} +static void imshowDepth(const char *winname, Mat &depth, VideoCapture &capture) +{ + short lowValue = (short)capture.get(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE); + short saturationValue = (short)capture.get(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE); + + Mat image; + if (g_showClosedPoint) + { + image.create(depth.rows, depth.cols, CV_8UC3); + for (int row = 0; row < depth.rows; row++) + { + uchar* ptrDst = image.ptr(row); + short* ptrSrc = (short*)depth.ptr(row); + for (int col = 0; col < depth.cols; col++, ptrSrc++) + { + if ((lowValue == (*ptrSrc)) || (saturationValue == (*ptrSrc))) + { + *ptrDst = 0; ptrDst++; + *ptrDst = 0; ptrDst++; + *ptrDst = 0; ptrDst++; + } + else + { + uchar val = (uchar) ((*ptrSrc) >> 2); + *ptrDst = val; ptrDst++; + *ptrDst = val; ptrDst++; + *ptrDst = val; ptrDst++; + } + } + } + + static const int pointSize = 4; + for (int row = g_closedDepthPoint[0]; row < min(g_closedDepthPoint[0] + pointSize, image.rows); row++) + { + uchar* ptrDst = image.ptr(row) + g_closedDepthPoint[1] * 3 + 2;//+2 -> Red + for (int col = 0; col < min(pointSize, image.cols - g_closedDepthPoint[1]); col++, ptrDst+=3) + { + *ptrDst = 255; + } + } + } + else + { + image.create(depth.rows, depth.cols, CV_8UC1); + for (int row = 0; row < depth.rows; row++) + { + uchar* ptrDst = image.ptr(row); + short* ptrSrc = (short*)depth.ptr(row); + for (int col = 0; col < depth.cols; col++, ptrSrc++, ptrDst++) + { + if ((lowValue == (*ptrSrc)) || (saturationValue == (*ptrSrc))) + *ptrDst = 0; + else + *ptrDst = (uchar) ((*ptrSrc) >> 2); + } + } + } + imshow(winname, image); +} + +int _tmain(int argc, char* argv[]) +{ + parseCMDLine(argc, argv); + + VideoCapture capture; + capture.open(CV_CAP_INTELPERC); + if (!capture.isOpened()) + { + cerr << "Can not open a capture object." << endl; + return -1; + } + + if (g_printStreamSetting) + printStreamProperties(capture); + + if (-1 != g_imageStreamProfileIdx) + { + if (!capture.set(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_INTELPERC_PROFILE_IDX, (double)g_imageStreamProfileIdx)) + { + cerr << "Can not setup a image stream." << endl; + return -1; + } + } + if (-1 != g_depthStreamProfileIdx) + { + if (!capture.set(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_INTELPERC_PROFILE_IDX, (double)g_depthStreamProfileIdx)) + { + cerr << "Can not setup a depth stream." << endl; + return -1; + } + } + else if (g_irStreamShow) + { + if (!capture.set(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_INTELPERC_PROFILE_IDX, 0.0)) + { + cerr << "Can not setup a IR stream." << endl; + return -1; + } + } + else + { + cout << "Streams not selected" << endl; + return 0; + } + + //Setup additional properies only after set profile of the stream + if ( (-10000.0 < g_imageBrightness) && (g_imageBrightness < 10000.0)) + capture.set(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_BRIGHTNESS, g_imageBrightness); + if ( (0 < g_imageContrast) && (g_imageContrast < 10000.0)) + capture.set(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_BRIGHTNESS, g_imageContrast); + + int frame = 0; + for(;;frame++) + { + Mat bgrImage; + Mat depthImage; + Mat irImage; + + if (!capture.grab()) + { + cout << "Can not grab images." << endl; + return -1; + } + + if ((-1 != g_depthStreamProfileIdx) && (capture.retrieve(depthImage, CV_CAP_INTELPERC_DEPTH_MAP))) + { + if (g_closedDepthPoint) + { + double minVal = 0.0; double maxVal = 0.0; + minMaxIdx(depthImage, &minVal, &maxVal, g_closedDepthPoint); + } + imshowDepth("depth image", depthImage, capture); + } + if ((g_irStreamShow) && (capture.retrieve(irImage, CV_CAP_INTELPERC_IR_MAP))) + imshowIR("ir image", irImage); + if ((-1 != g_imageStreamProfileIdx) && (capture.retrieve(bgrImage, CV_CAP_INTELPERC_IMAGE))) + imshowImage("color image", bgrImage, capture); + + if (g_printTiming) + { + cout << "Image frame: " << capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_POS_FRAMES) + << ", Depth(IR) frame: " << capture.get(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_POS_FRAMES) << endl; + cout << "Image frame: " << capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_POS_MSEC) + << ", Depth(IR) frame: " << capture.get(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_POS_MSEC) << endl; + } + if( waitKey(30) >= 0 ) + break; + } + + return 0; +} + From 4088013251e9e30fe43b57d41a63bce08f967030 Mon Sep 17 00:00:00 2001 From: Vladimir Bystricky Date: Tue, 17 Dec 2013 12:00:40 +0400 Subject: [PATCH 2/9] Add set/get depth generator properties by default. Add documentation --- doc/user_guide/ug_intelperc.rst | 80 +++++++++++++++++++ doc/user_guide/user_guide.rst | 1 + .../include/opencv2/highgui/highgui_c.h | 6 +- modules/highgui/src/cap_intelperc.cpp | 33 ++++++-- samples/cpp/intelperc_capture.cpp | 68 ++++++++-------- 5 files changed, 144 insertions(+), 44 deletions(-) create mode 100644 doc/user_guide/ug_intelperc.rst diff --git a/doc/user_guide/ug_intelperc.rst b/doc/user_guide/ug_intelperc.rst new file mode 100644 index 0000000000..d00a2f9009 --- /dev/null +++ b/doc/user_guide/ug_intelperc.rst @@ -0,0 +1,80 @@ +******* +HighGUI +******* + +.. highlight:: cpp + +Using Creative Senz3D and other Intel Perceptual Computing SDK compatible depth sensors +====================================================== + +Depth sensors compatible with Intel Perceptual Computing SDK are supported through ``VideoCapture`` class. Depth map, RGB image and some other formats of output can be retrieved by using familiar interface of ``VideoCapture``. + +In order to use depth sensor with OpenCV you should do the following preliminary steps: + +#. + Install Intel Perceptual Computing SDK (from here http://www.intel.com/software/perceptual). + +#. + Configure OpenCV with Intel Perceptual Computing SDK support by setting ``WITH_INTELPERC`` flag in CMake. If Intel Perceptual Computing SDK is found in install folders OpenCV will be built with Intel Perceptual Computing SDK library (see a status ``INTELPERC`` in CMake log). If CMake process doesn't find Intel Perceptual Computing SDK installation folder automatically, the user should change corresponding CMake variables ``INTELPERC_LIB_DIR`` and ``INTELPERC_INCLUDE_DIR`` to the proper value. + +#. + Build OpenCV. + +VideoCapture can retrieve the following data: + +#. + data given from depth generator: + * ``CV_CAP_INTELPERC_DEPTH_MAP`` - each pixel is a 16-bit integer. The value indicates the distance from an object to the camera's XY plane or the Cartesian depth. (CV_16UC1) + * ``CV_CAP_INTELPERC_UVDEPTH_MAP`` - each pixel contains two 32-bit floating point values in the range of 0-1, representing the mapping of depth coordinates to the color coordinates. (CV_32FC2) + * ``CV_CAP_INTELPERC_IR_MAP`` - each pixel is a 16-bit integer. The value indicates the intensity of the reflected laser beam. (CV_16UC1) +#. + data given from RGB image generator: + * ``CV_CAP_INTELPERC_IMAGE`` - color image. (CV_8UC3) + +In order to get depth map from depth sensor use ``VideoCapture::operator >>``, e. g. :: + + VideoCapture capture( CV_CAP_INTELPERC ); + for(;;) + { + Mat depthMap; + capture >> depthMap; + + if( waitKey( 30 ) >= 0 ) + break; + } + +For getting several data maps use ``VideoCapture::grab`` and ``VideoCapture::retrieve``, e.g. :: + + VideoCapture capture(CV_CAP_INTELPERC); + for(;;) + { + Mat depthMap; + Mat image; + Mat irImage; + + capture.grab(); + + capture.retrieve( depthMap, CV_CAP_INTELPERC_DEPTH_MAP ); + capture.retrieve( image, CV_CAP_INTELPERC_IMAGE ); + capture.retrieve( irImage, CV_CAP_INTELPERC_IR_MAP); + + if( waitKey( 30 ) >= 0 ) + break; + } + +For setting and getting some property of sensor` data generators use ``VideoCapture::set`` and ``VideoCapture::get`` methods respectively, e.g. :: + + VideoCapture capture( CV_CAP_INTELPERC ); + capture.set( CV_CAP_INTELPERC_DEPTH_GENERATOR | CV_CAP_PROP_INTELPERC_PROFILE_IDX, 0 ); + cout << "FPS " << capture.get( CV_CAP_INTELPERC_DEPTH_GENERATOR+CV_CAP_PROP_FPS ) << endl; + +Since two types of sensor's data generators are supported (image generator and depth generator), there are two flags that should be used to set/get property of the needed generator: + +* CV_CAP_INTELPERC_IMAGE_GENERATOR -- a flag for access to the image generator properties. + +* CV_CAP_INTELPERC_DEPTH_GENERATOR -- a flag for access to the depth generator properties. This flag value is assumed by default if neither of the two possible values of the property is set. + +For more information please refer to the example of usage intelperc_capture.cpp_ in ``opencv/samples/cpp`` folder. + +.. _intelperc_capture.cpp: https://github.com/Itseez/opencv/tree/master/samples/cpp/intelperc_capture.cpp + diff --git a/doc/user_guide/user_guide.rst b/doc/user_guide/user_guide.rst index de9edcb683..76cf756f85 100644 --- a/doc/user_guide/user_guide.rst +++ b/doc/user_guide/user_guide.rst @@ -9,3 +9,4 @@ OpenCV User Guide ug_features2d.rst ug_highgui.rst ug_traincascade.rst + ug_intelperc.rst diff --git a/modules/highgui/include/opencv2/highgui/highgui_c.h b/modules/highgui/include/opencv2/highgui/highgui_c.h index 99f453385d..862fa053a6 100644 --- a/modules/highgui/include/opencv2/highgui/highgui_c.h +++ b/modules/highgui/include/opencv2/highgui/highgui_c.h @@ -480,9 +480,9 @@ enum CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_VERT = 11007, // Intel PerC streams - CV_CAP_INTELPERC_DEPTH_STREAM = 1 << 31, - CV_CAP_INTELPERC_IMAGE_STREAM = 1 << 30, - CV_CAP_INTELPERC_STREAMS_MASK = CV_CAP_INTELPERC_DEPTH_STREAM + CV_CAP_INTELPERC_IMAGE_STREAM, + CV_CAP_INTELPERC_DEPTH_GENERATOR = 1 << 31, + CV_CAP_INTELPERC_IMAGE_GENERATOR = 1 << 30, + CV_CAP_INTELPERC_GENERATORS_MASK = CV_CAP_INTELPERC_DEPTH_GENERATOR + CV_CAP_INTELPERC_IMAGE_GENERATOR, }; enum diff --git a/modules/highgui/src/cap_intelperc.cpp b/modules/highgui/src/cap_intelperc.cpp index d562dc0c8e..910a6f748a 100644 --- a/modules/highgui/src/cap_intelperc.cpp +++ b/modules/highgui/src/cap_intelperc.cpp @@ -195,6 +195,11 @@ protected: int m_frameIdx; pxcU64 m_timeStampStartNS; double m_timeStamp; + + virtual bool validProfile(const PXCCapture::VideoStream::ProfileInfo& /*pinfo*/) + { + return true; + } void enumProfiles() { m_profiles.clear(); @@ -207,7 +212,8 @@ protected: sts = m_stream->QueryProfile(profidx, &pinfo); if (PXC_STATUS_NO_ERROR > sts) break; - m_profiles.push_back(pinfo); + if (validProfile(pinfo)) + m_profiles.push_back(pinfo); } } virtual bool prepareIplImage(PXCImage *pxcImage) = 0; @@ -552,6 +558,11 @@ public: { return m_frameUV.retrieveFrame(); } +protected: + virtual bool validProfile(const PXCCapture::VideoStream::ProfileInfo& pinfo) + { + return (PXCImage::COLOR_FORMAT_DEPTH == pinfo.imageInfo.format); + } protected: FrameInternal m_frameDepth; FrameInternal m_frameIR; @@ -609,12 +620,16 @@ public: virtual double getProperty(int propIdx) { double propValue = 0; - int purePropIdx = propIdx & ~CV_CAP_INTELPERC_STREAMS_MASK; - if (CV_CAP_INTELPERC_IMAGE_STREAM == (propIdx & CV_CAP_INTELPERC_STREAMS_MASK)) + int purePropIdx = propIdx & ~CV_CAP_INTELPERC_GENERATORS_MASK; + if (CV_CAP_INTELPERC_IMAGE_GENERATOR == (propIdx & CV_CAP_INTELPERC_GENERATORS_MASK)) { propValue = m_imageStream.getProperty(purePropIdx); } - else if (CV_CAP_INTELPERC_DEPTH_STREAM == (propIdx & CV_CAP_INTELPERC_STREAMS_MASK)) + else if (CV_CAP_INTELPERC_DEPTH_GENERATOR == (propIdx & CV_CAP_INTELPERC_GENERATORS_MASK)) + { + propValue = m_depthStream.getProperty(purePropIdx); + } + else { propValue = m_depthStream.getProperty(purePropIdx); } @@ -623,12 +638,16 @@ public: virtual bool setProperty(int propIdx, double propVal) { bool isSet = false; - int purePropIdx = propIdx & ~CV_CAP_INTELPERC_STREAMS_MASK; - if (CV_CAP_INTELPERC_IMAGE_STREAM == (propIdx & CV_CAP_INTELPERC_STREAMS_MASK)) + int purePropIdx = propIdx & ~CV_CAP_INTELPERC_GENERATORS_MASK; + if (CV_CAP_INTELPERC_IMAGE_GENERATOR == (propIdx & CV_CAP_INTELPERC_GENERATORS_MASK)) { isSet = m_imageStream.setProperty(purePropIdx, propVal); } - else if (CV_CAP_INTELPERC_DEPTH_STREAM == (propIdx & CV_CAP_INTELPERC_STREAMS_MASK)) + else if (CV_CAP_INTELPERC_DEPTH_GENERATOR == (propIdx & CV_CAP_INTELPERC_GENERATORS_MASK)) + { + isSet = m_depthStream.setProperty(purePropIdx, propVal); + } + else { isSet = m_depthStream.setProperty(purePropIdx, propVal); } diff --git a/samples/cpp/intelperc_capture.cpp b/samples/cpp/intelperc_capture.cpp index 7744377c5a..30471c3471 100644 --- a/samples/cpp/intelperc_capture.cpp +++ b/samples/cpp/intelperc_capture.cpp @@ -107,48 +107,48 @@ static void parseCMDLine(int argc, char* argv[]) static void printStreamProperties(VideoCapture &capture) { - size_t profilesCount = (size_t)capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_INTELPERC_PROFILE_COUNT); + size_t profilesCount = (size_t)capture.get(CV_CAP_INTELPERC_IMAGE_GENERATOR | CV_CAP_PROP_INTELPERC_PROFILE_COUNT); cout << "Image stream." << endl; - cout << " Brightness = " << capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_BRIGHTNESS) << endl; - cout << " Contrast = " << capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_CONTRAST) << endl; - cout << " Saturation = " << capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_SATURATION) << endl; - cout << " Hue = " << capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_HUE) << endl; - cout << " Gamma = " << capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_GAMMA) << endl; - cout << " Sharpness = " << capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_SHARPNESS) << endl; - cout << " Gain = " << capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_GAIN) << endl; - cout << " Backligh = " << capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_BACKLIGHT) << endl; + cout << " Brightness = " << capture.get(CV_CAP_INTELPERC_IMAGE_GENERATOR | CV_CAP_PROP_BRIGHTNESS) << endl; + cout << " Contrast = " << capture.get(CV_CAP_INTELPERC_IMAGE_GENERATOR | CV_CAP_PROP_CONTRAST) << endl; + cout << " Saturation = " << capture.get(CV_CAP_INTELPERC_IMAGE_GENERATOR | CV_CAP_PROP_SATURATION) << endl; + cout << " Hue = " << capture.get(CV_CAP_INTELPERC_IMAGE_GENERATOR | CV_CAP_PROP_HUE) << endl; + cout << " Gamma = " << capture.get(CV_CAP_INTELPERC_IMAGE_GENERATOR | CV_CAP_PROP_GAMMA) << endl; + cout << " Sharpness = " << capture.get(CV_CAP_INTELPERC_IMAGE_GENERATOR | CV_CAP_PROP_SHARPNESS) << endl; + cout << " Gain = " << capture.get(CV_CAP_INTELPERC_IMAGE_GENERATOR | CV_CAP_PROP_GAIN) << endl; + cout << " Backligh = " << capture.get(CV_CAP_INTELPERC_IMAGE_GENERATOR | CV_CAP_PROP_BACKLIGHT) << endl; cout << "Image streams profiles:" << endl; for (size_t i = 0; i < profilesCount; i++) { - capture.set(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_INTELPERC_PROFILE_IDX, (double)i); + capture.set(CV_CAP_INTELPERC_IMAGE_GENERATOR | CV_CAP_PROP_INTELPERC_PROFILE_IDX, (double)i); cout << " Profile[" << i << "]: "; cout << "width = " << - (int)capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_FRAME_WIDTH); + (int)capture.get(CV_CAP_INTELPERC_IMAGE_GENERATOR | CV_CAP_PROP_FRAME_WIDTH); cout << ", height = " << - (int)capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_FRAME_HEIGHT); + (int)capture.get(CV_CAP_INTELPERC_IMAGE_GENERATOR | CV_CAP_PROP_FRAME_HEIGHT); cout << ", fps = " << - capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_FPS); + capture.get(CV_CAP_INTELPERC_IMAGE_GENERATOR | CV_CAP_PROP_FPS); cout << endl; } - profilesCount = (size_t)capture.get(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_INTELPERC_PROFILE_COUNT); + profilesCount = (size_t)capture.get(CV_CAP_INTELPERC_DEPTH_GENERATOR | CV_CAP_PROP_INTELPERC_PROFILE_COUNT); cout << "Depth stream." << endl; - cout << " Low confidence value = " << capture.get(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE) << endl; - cout << " Saturation value = " << capture.get(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE) << endl; - cout << " Confidence threshold = " << capture.get(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_INTELPERC_DEPTH_CONFIDENCE_THRESHOLD) << endl; - cout << " Focal length = (" << capture.get(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_HORZ) << ", " - << capture.get(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_VERT) << ")" << endl; + cout << " Low confidence value = " << capture.get(CV_CAP_INTELPERC_DEPTH_GENERATOR | CV_CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE) << endl; + cout << " Saturation value = " << capture.get(CV_CAP_INTELPERC_DEPTH_GENERATOR | CV_CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE) << endl; + cout << " Confidence threshold = " << capture.get(CV_CAP_INTELPERC_DEPTH_GENERATOR | CV_CAP_PROP_INTELPERC_DEPTH_CONFIDENCE_THRESHOLD) << endl; + cout << " Focal length = (" << capture.get(CV_CAP_INTELPERC_DEPTH_GENERATOR | CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_HORZ) << ", " + << capture.get(CV_CAP_INTELPERC_DEPTH_GENERATOR | CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_VERT) << ")" << endl; cout << "Depth streams profiles:" << endl; for (size_t i = 0; i < profilesCount; i++) { - capture.set(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_INTELPERC_PROFILE_IDX, (double)i); + capture.set(CV_CAP_INTELPERC_DEPTH_GENERATOR | CV_CAP_PROP_INTELPERC_PROFILE_IDX, (double)i); cout << " Profile[" << i << "]: "; cout << "width = " << - (int)capture.get(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_FRAME_WIDTH); + (int)capture.get(CV_CAP_INTELPERC_DEPTH_GENERATOR | CV_CAP_PROP_FRAME_WIDTH); cout << ", height = " << - (int)capture.get(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_FRAME_HEIGHT); + (int)capture.get(CV_CAP_INTELPERC_DEPTH_GENERATOR | CV_CAP_PROP_FRAME_HEIGHT); cout << ", fps = " << - capture.get(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_FPS); + capture.get(CV_CAP_INTELPERC_DEPTH_GENERATOR | CV_CAP_PROP_FPS); cout << endl; } } @@ -227,8 +227,8 @@ static void imshowIR(const char *winname, Mat &ir) } static void imshowDepth(const char *winname, Mat &depth, VideoCapture &capture) { - short lowValue = (short)capture.get(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE); - short saturationValue = (short)capture.get(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE); + short lowValue = (short)capture.get(CV_CAP_INTELPERC_DEPTH_GENERATOR | CV_CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE); + short saturationValue = (short)capture.get(CV_CAP_INTELPERC_DEPTH_GENERATOR | CV_CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE); Mat image; if (g_showClosedPoint) @@ -302,7 +302,7 @@ int _tmain(int argc, char* argv[]) if (-1 != g_imageStreamProfileIdx) { - if (!capture.set(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_INTELPERC_PROFILE_IDX, (double)g_imageStreamProfileIdx)) + if (!capture.set(CV_CAP_INTELPERC_IMAGE_GENERATOR | CV_CAP_PROP_INTELPERC_PROFILE_IDX, (double)g_imageStreamProfileIdx)) { cerr << "Can not setup a image stream." << endl; return -1; @@ -310,7 +310,7 @@ int _tmain(int argc, char* argv[]) } if (-1 != g_depthStreamProfileIdx) { - if (!capture.set(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_INTELPERC_PROFILE_IDX, (double)g_depthStreamProfileIdx)) + if (!capture.set(CV_CAP_INTELPERC_DEPTH_GENERATOR | CV_CAP_PROP_INTELPERC_PROFILE_IDX, (double)g_depthStreamProfileIdx)) { cerr << "Can not setup a depth stream." << endl; return -1; @@ -318,7 +318,7 @@ int _tmain(int argc, char* argv[]) } else if (g_irStreamShow) { - if (!capture.set(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_INTELPERC_PROFILE_IDX, 0.0)) + if (!capture.set(CV_CAP_INTELPERC_DEPTH_GENERATOR | CV_CAP_PROP_INTELPERC_PROFILE_IDX, 0.0)) { cerr << "Can not setup a IR stream." << endl; return -1; @@ -332,9 +332,9 @@ int _tmain(int argc, char* argv[]) //Setup additional properies only after set profile of the stream if ( (-10000.0 < g_imageBrightness) && (g_imageBrightness < 10000.0)) - capture.set(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_BRIGHTNESS, g_imageBrightness); + capture.set(CV_CAP_INTELPERC_IMAGE_GENERATOR | CV_CAP_PROP_BRIGHTNESS, g_imageBrightness); if ( (0 < g_imageContrast) && (g_imageContrast < 10000.0)) - capture.set(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_BRIGHTNESS, g_imageContrast); + capture.set(CV_CAP_INTELPERC_IMAGE_GENERATOR | CV_CAP_PROP_BRIGHTNESS, g_imageContrast); int frame = 0; for(;;frame++) @@ -365,10 +365,10 @@ int _tmain(int argc, char* argv[]) if (g_printTiming) { - cout << "Image frame: " << capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_POS_FRAMES) - << ", Depth(IR) frame: " << capture.get(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_POS_FRAMES) << endl; - cout << "Image frame: " << capture.get(CV_CAP_INTELPERC_IMAGE_STREAM | CV_CAP_PROP_POS_MSEC) - << ", Depth(IR) frame: " << capture.get(CV_CAP_INTELPERC_DEPTH_STREAM | CV_CAP_PROP_POS_MSEC) << endl; + cout << "Image frame: " << capture.get(CV_CAP_INTELPERC_IMAGE_GENERATOR | CV_CAP_PROP_POS_FRAMES) + << ", Depth(IR) frame: " << capture.get(CV_CAP_INTELPERC_DEPTH_GENERATOR | CV_CAP_PROP_POS_FRAMES) << endl; + cout << "Image frame: " << capture.get(CV_CAP_INTELPERC_IMAGE_GENERATOR | CV_CAP_PROP_POS_MSEC) + << ", Depth(IR) frame: " << capture.get(CV_CAP_INTELPERC_DEPTH_GENERATOR | CV_CAP_PROP_POS_MSEC) << endl; } if( waitKey(30) >= 0 ) break; From cc08e00876b91ad626b60d88bee5aa3441ed546b Mon Sep 17 00:00:00 2001 From: Vladimir Bystricky Date: Tue, 17 Dec 2013 16:13:55 +0400 Subject: [PATCH 3/9] Fix notes about cmake files. Fix build warning. --- cmake/OpenCVFindIntelPerCSDK.cmake | 55 ++++--------------- cmake/OpenCVFindLibsVideo.cmake | 1 - cmake/templates/cvconfig.h.in | 6 +- doc/user_guide/ug_intelperc.rst | 7 +-- modules/highgui/CMakeLists.txt | 2 +- .../include/opencv2/highgui/highgui_c.h | 10 ++-- modules/highgui/src/cap_intelperc.cpp | 44 +++++++-------- samples/cpp/intelperc_capture.cpp | 18 +++--- 8 files changed, 54 insertions(+), 89 deletions(-) diff --git a/cmake/OpenCVFindIntelPerCSDK.cmake b/cmake/OpenCVFindIntelPerCSDK.cmake index 2d45c6e227..7243105601 100644 --- a/cmake/OpenCVFindIntelPerCSDK.cmake +++ b/cmake/OpenCVFindIntelPerCSDK.cmake @@ -1,51 +1,20 @@ # Main variables: -# INTELPERC_LIBRARY and INTELPERC_INCLUDES to link Intel Perceptial Computing SDK modules +# INTELPERC_LIBRARIES and INTELPERC_INCLUDE to link Intel Perceptial Computing SDK modules # HAVE_INTELPERC for conditional compilation OpenCV with/without Intel Perceptial Computing SDK -if(NOT "${INTELPERC_LIB_DIR}" STREQUAL "${INTELPERC_LIB_DIR_INTERNAL}") - unset(INTELPERC_LIBRARY CACHE) - unset(INTELPERC_LIB_DIR CACHE) -endif() - -if(NOT "${INTELPERC_INCLUDE_DIR}" STREQUAL "${INTELPERC_INCLUDE_DIR_INTERNAL}") - unset(INTELPERC_INCLUDES CACHE) - unset(INTELPERC_INCLUDE_DIR CACHE) -endif() - -if(WIN32) - if(NOT (MSVC64 OR MINGW64)) - find_file(INTELPERC_INCLUDES "pxcsession.h" PATHS "$ENV{PCSDK_DIR}include" DOC "Intel Perceptual Computing SDK interface header") - find_library(INTELPERC_LIBRARY "libpxc.lib" PATHS "$ENV{PCSDK_DIR}lib/Win32" DOC "Intel Perceptual Computing SDK library") - else() - find_file(INTELPERC_INCLUDES "pxcsession.h" PATHS "$ENV{PCSDK_DIR}include" DOC "Intel Perceptual Computing SDK interface header") - find_library(INTELPERC_LIBRARY "libpxc.lib" PATHS "$ENV{PCSDK_DIR}/lib/x64" DOC "Intel Perceptual Computing SDK library") - endif() -endif() - -if(INTELPERC_LIBRARY AND INTELPERC_INCLUDES) - set(HAVE_INTELPERC TRUE) -endif() #if(INTELPERC_LIBRARY AND INTELPERC_INCLUDES) - -get_filename_component(INTELPERC_LIB_DIR "${INTELPERC_LIBRARY}" PATH) -get_filename_component(INTELPERC_INCLUDE_DIR "${INTELPERC_INCLUDES}" PATH) - -if(HAVE_INTELPERC) - set(INTELPERC_LIB_DIR "${INTELPERC_LIB_DIR}" CACHE PATH "Path to Intel Perceptual Computing SDK interface libraries" FORCE) - set(INTELPERC_INCLUDE_DIR "${INTELPERC_INCLUDE_DIR}" CACHE PATH "Path to Intel Perceptual Computing SDK interface headers" FORCE) -endif() - -if(INTELPERC_LIBRARY) - set(INTELPERC_LIB_DIR_INTERNAL "${INTELPERC_LIB_DIR}" CACHE INTERNAL "This is the value of the last time INTELPERC_LIB_DIR was set successfully." FORCE) +if(X86_64) + find_path(INTELPERC_INCLUDE_DIR "pxcsession.h" PATHS "$ENV{PCSDK_DIR}include" DOC "Path to Intel Perceptual Computing SDK interface headers") + find_file(INTELPERC_LIBRARIES "libpxc.lib" PATHS "$ENV{PCSDK_DIR}lib/x64" DOC "Path to Intel Perceptual Computing SDK interface libraries") else() - message( WARNING, " Intel Perceptual Computing SDK library directory (set by INTELPERC_LIB_DIR variable) is not found or does not have Intel Perceptual Computing SDK libraries." ) + find_path(INTELPERC_INCLUDE_DIR "pxcsession.h" PATHS "$ENV{PCSDK_DIR}include" DOC "Path to Intel Perceptual Computing SDK interface headers") + find_file(INTELPERC_LIBRARIES "libpxc.lib" PATHS "$ENV{PCSDK_DIR}lib/Win32" DOC "Path to Intel Perceptual Computing SDK interface libraries") endif() -if(INTELPERC_INCLUDES) - set(INTELPERC_INCLUDE_DIR_INTERNAL "${INTELPERC_INCLUDE_DIR}" CACHE INTERNAL "This is the value of the last time INTELPERC_INCLUDE_DIR was set successfully." FORCE) +if(INTELPERC_INCLUDE_DIR AND INTELPERC_LIBRARIES) + set(HAVE_INTELPERC TRUE) else() - message( WARNING, " Intel Perceptual Computing SDK include directory (set by INTELPERC_INCLUDE_DIR variable) is not found or does not have Intel Perceptual Computing SDK include files." ) -endif() - -mark_as_advanced(FORCE INTELPERC_LIBRARY) -mark_as_advanced(FORCE INTELPERC_INCLUDES) + set(HAVE_INTELPERC FALSE) + message(WARNING "Intel Perceptual Computing SDK library directory (set by INTELPERC_LIB_DIR variable) is not found or does not have Intel Perceptual Computing SDK libraries.") +endif() #if(INTELPERC_INCLUDE_DIR AND INTELPERC_LIBRARIES) +mark_as_advanced(FORCE INTELPERC_LIBRARIES INTELPERC_INCLUDE_DIR) \ No newline at end of file diff --git a/cmake/OpenCVFindLibsVideo.cmake b/cmake/OpenCVFindLibsVideo.cmake index 22b58f5ef1..a5075b57f7 100644 --- a/cmake/OpenCVFindLibsVideo.cmake +++ b/cmake/OpenCVFindLibsVideo.cmake @@ -252,7 +252,6 @@ if (NOT IOS) endif() # --- Intel Perceptual Computing SSDK --- -ocv_clear_vars(HAVE_INTELPERC) if(WITH_INTELPERC) include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindIntelPerCSDK.cmake") endif(WITH_INTELPERC) diff --git a/cmake/templates/cvconfig.h.in b/cmake/templates/cvconfig.h.in index f52c5e457c..a6cee63684 100644 --- a/cmake/templates/cvconfig.h.in +++ b/cmake/templates/cvconfig.h.in @@ -85,6 +85,9 @@ /* Apple ImageIO Framework */ #cmakedefine HAVE_IMAGEIO +/* Intel Perceptual Computing SDK library */ +#cmakedefine HAVE_INTELPERC + /* Intel Integrated Performance Primitives */ #cmakedefine HAVE_IPP @@ -158,9 +161,6 @@ /* Xine video library */ #cmakedefine HAVE_XINE -/* Intel Perceptual Computing SDK library */ -#cmakedefine HAVE_INTELPERC - /* Define to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel and VAX). */ #cmakedefine WORDS_BIGENDIAN diff --git a/doc/user_guide/ug_intelperc.rst b/doc/user_guide/ug_intelperc.rst index d00a2f9009..71a7c5d90e 100644 --- a/doc/user_guide/ug_intelperc.rst +++ b/doc/user_guide/ug_intelperc.rst @@ -12,7 +12,7 @@ Depth sensors compatible with Intel Perceptual Computing SDK are supported throu In order to use depth sensor with OpenCV you should do the following preliminary steps: #. - Install Intel Perceptual Computing SDK (from here http://www.intel.com/software/perceptual). + Install Intel Perceptual Computing SDK (from here http://www.intel.com/software/perceptual). #. Configure OpenCV with Intel Perceptual Computing SDK support by setting ``WITH_INTELPERC`` flag in CMake. If Intel Perceptual Computing SDK is found in install folders OpenCV will be built with Intel Perceptual Computing SDK library (see a status ``INTELPERC`` in CMake log). If CMake process doesn't find Intel Perceptual Computing SDK installation folder automatically, the user should change corresponding CMake variables ``INTELPERC_LIB_DIR`` and ``INTELPERC_INCLUDE_DIR`` to the proper value. @@ -56,7 +56,7 @@ For getting several data maps use ``VideoCapture::grab`` and ``VideoCapture::ret capture.retrieve( depthMap, CV_CAP_INTELPERC_DEPTH_MAP ); capture.retrieve( image, CV_CAP_INTELPERC_IMAGE ); - capture.retrieve( irImage, CV_CAP_INTELPERC_IR_MAP); + capture.retrieve( irImage, CV_CAP_INTELPERC_IR_MAP); if( waitKey( 30 ) >= 0 ) break; @@ -76,5 +76,4 @@ Since two types of sensor's data generators are supported (image generator and d For more information please refer to the example of usage intelperc_capture.cpp_ in ``opencv/samples/cpp`` folder. -.. _intelperc_capture.cpp: https://github.com/Itseez/opencv/tree/master/samples/cpp/intelperc_capture.cpp - +.. _intelperc_capture.cpp: https://github.com/Itseez/opencv/tree/master/samples/cpp/intelperc_capture.cpp \ No newline at end of file diff --git a/modules/highgui/CMakeLists.txt b/modules/highgui/CMakeLists.txt index 5c86a2fcd1..fd2eec6a1e 100644 --- a/modules/highgui/CMakeLists.txt +++ b/modules/highgui/CMakeLists.txt @@ -221,7 +221,7 @@ endif() if(HAVE_INTELPERC) list(APPEND highgui_srcs src/cap_intelperc.cpp) ocv_include_directories(${INTELPERC_INCLUDE_DIR}) - list(APPEND HIGHGUI_LIBRARIES ${INTELPERC_LIBRARY}) + list(APPEND HIGHGUI_LIBRARIES ${INTELPERC_LIBRARIES}) endif(HAVE_INTELPERC) if(IOS) diff --git a/modules/highgui/include/opencv2/highgui/highgui_c.h b/modules/highgui/include/opencv2/highgui/highgui_c.h index 862fa053a6..8a59197594 100644 --- a/modules/highgui/include/opencv2/highgui/highgui_c.h +++ b/modules/highgui/include/opencv2/highgui/highgui_c.h @@ -469,10 +469,10 @@ enum CV_CAP_PROP_GIGA_FRAME_WIDTH_MAX = 10003, CV_CAP_PROP_GIGA_FRAME_HEIGH_MAX = 10004, CV_CAP_PROP_GIGA_FRAME_SENS_WIDTH = 10005, - CV_CAP_PROP_GIGA_FRAME_SENS_HEIGH = 10006 + CV_CAP_PROP_GIGA_FRAME_SENS_HEIGH = 10006, - ,CV_CAP_PROP_INTELPERC_PROFILE_COUNT = 11001, - CV_CAP_PROP_INTELPERC_PROFILE_IDX = 11002, + CV_CAP_PROP_INTELPERC_PROFILE_COUNT = 11001, + CV_CAP_PROP_INTELPERC_PROFILE_IDX = 11002, CV_CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE = 11003, CV_CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE = 11004, CV_CAP_PROP_INTELPERC_DEPTH_CONFIDENCE_THRESHOLD = 11005, @@ -480,8 +480,8 @@ enum CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_VERT = 11007, // Intel PerC streams - CV_CAP_INTELPERC_DEPTH_GENERATOR = 1 << 31, - CV_CAP_INTELPERC_IMAGE_GENERATOR = 1 << 30, + CV_CAP_INTELPERC_DEPTH_GENERATOR = 1 << 29, + CV_CAP_INTELPERC_IMAGE_GENERATOR = 1 << 28, CV_CAP_INTELPERC_GENERATORS_MASK = CV_CAP_INTELPERC_DEPTH_GENERATOR + CV_CAP_INTELPERC_IMAGE_GENERATOR, }; diff --git a/modules/highgui/src/cap_intelperc.cpp b/modules/highgui/src/cap_intelperc.cpp index 910a6f748a..18b3b9d0c0 100644 --- a/modules/highgui/src/cap_intelperc.cpp +++ b/modules/highgui/src/cap_intelperc.cpp @@ -63,7 +63,7 @@ public: } int getProfileIDX() const { - return m_profileIdx; + return m_profileIdx; } public: virtual bool initStream(PXCSession *session) = 0; @@ -132,29 +132,29 @@ protected: return false; pxcStatus sts = PXC_STATUS_NO_ERROR; - PXCSession::ImplDesc templat; - memset(&templat,0,sizeof(templat)); - templat.group = PXCSession::IMPL_GROUP_SENSOR; - templat.subgroup= PXCSession::IMPL_SUBGROUP_VIDEO_CAPTURE; + PXCSession::ImplDesc templat; + memset(&templat,0,sizeof(templat)); + templat.group = PXCSession::IMPL_GROUP_SENSOR; + templat.subgroup= PXCSession::IMPL_SUBGROUP_VIDEO_CAPTURE; - for (int modidx = 0; PXC_STATUS_NO_ERROR <= sts; modidx++) + for (int modidx = 0; PXC_STATUS_NO_ERROR <= sts; modidx++) { PXCSession::ImplDesc desc; sts = session->QueryImpl(&templat, modidx, &desc); - if (PXC_STATUS_NO_ERROR > sts) + if (PXC_STATUS_NO_ERROR > sts) break; - + PXCSmartPtr capture; sts = session->CreateImpl(&desc, &capture); - if (!capture.IsValid()) + if (!capture.IsValid()) continue; - + /* enumerate devices */ - for (int devidx = 0; PXC_STATUS_NO_ERROR <= sts; devidx++) + for (int devidx = 0; PXC_STATUS_NO_ERROR <= sts; devidx++) { PXCSmartPtr device; sts = capture->CreateDevice(devidx, &device); - if (PXC_STATUS_NO_ERROR <= sts) + if (PXC_STATUS_NO_ERROR <= sts) { m_device = device.ReleasePtr(); return true; @@ -172,19 +172,19 @@ protected: pxcStatus sts = PXC_STATUS_NO_ERROR; /* enumerate streams */ - for (int streamidx = 0; PXC_STATUS_NO_ERROR <= sts; streamidx++) + for (int streamidx = 0; PXC_STATUS_NO_ERROR <= sts; streamidx++) { PXCCapture::Device::StreamInfo sinfo; sts = m_device->QueryStream(streamidx, &sinfo); - if (PXC_STATUS_NO_ERROR > sts) + if (PXC_STATUS_NO_ERROR > sts) break; - if (PXCCapture::VideoStream::CUID != sinfo.cuid) + if (PXCCapture::VideoStream::CUID != sinfo.cuid) continue; - if (type != sinfo.imageType) + if (type != sinfo.imageType) continue; - + sts = m_device->CreateStream(streamidx, &m_stream); - if (PXC_STATUS_NO_ERROR == sts) + if (PXC_STATUS_NO_ERROR == sts) break; m_stream.ReleaseRef(); } @@ -206,7 +206,7 @@ protected: if (!m_stream.IsValid()) return; pxcStatus sts = PXC_STATUS_NO_ERROR; - for (int profidx = 0; PXC_STATUS_NO_ERROR <= sts; profidx++) + for (int profidx = 0; PXC_STATUS_NO_ERROR <= sts; profidx++) { PXCCapture::VideoStream::ProfileInfo pinfo; sts = m_stream->QueryProfile(profidx, &pinfo); @@ -422,7 +422,7 @@ protected: return false; PXCImage::ImageInfo info; pxcImage->QueryInfo(&info); - + PXCImage::ImageData data; pxcImage->AcquireAccess(PXCImage::ACCESS_READ, PXCImage::COLOR_FORMAT_RGB24, &data); @@ -574,7 +574,7 @@ protected: return false; PXCImage::ImageInfo info; pxcImage->QueryInfo(&info); - + PXCImage::ImageData data; pxcImage->AcquireAccess(PXCImage::ACCESS_READ, &data); @@ -610,7 +610,7 @@ public: : m_contextOpened(false) { pxcStatus sts = PXCSession_Create(&m_session); - if (PXC_STATUS_NO_ERROR > sts) + if (PXC_STATUS_NO_ERROR > sts) return; m_contextOpened = m_imageStream.initStream(m_session); m_contextOpened &= m_depthStream.initStream(m_session); diff --git a/samples/cpp/intelperc_capture.cpp b/samples/cpp/intelperc_capture.cpp index 30471c3471..be032dead9 100644 --- a/samples/cpp/intelperc_capture.cpp +++ b/samples/cpp/intelperc_capture.cpp @@ -3,7 +3,6 @@ #include #include "opencv2/highgui/highgui.hpp" -//#include "opencv2/imgproc/imgproc.hpp" #include @@ -122,11 +121,11 @@ static void printStreamProperties(VideoCapture &capture) { capture.set(CV_CAP_INTELPERC_IMAGE_GENERATOR | CV_CAP_PROP_INTELPERC_PROFILE_IDX, (double)i); cout << " Profile[" << i << "]: "; - cout << "width = " << + cout << "width = " << (int)capture.get(CV_CAP_INTELPERC_IMAGE_GENERATOR | CV_CAP_PROP_FRAME_WIDTH); - cout << ", height = " << + cout << ", height = " << (int)capture.get(CV_CAP_INTELPERC_IMAGE_GENERATOR | CV_CAP_PROP_FRAME_HEIGHT); - cout << ", fps = " << + cout << ", fps = " << capture.get(CV_CAP_INTELPERC_IMAGE_GENERATOR | CV_CAP_PROP_FPS); cout << endl; } @@ -143,11 +142,11 @@ static void printStreamProperties(VideoCapture &capture) { capture.set(CV_CAP_INTELPERC_DEPTH_GENERATOR | CV_CAP_PROP_INTELPERC_PROFILE_IDX, (double)i); cout << " Profile[" << i << "]: "; - cout << "width = " << + cout << "width = " << (int)capture.get(CV_CAP_INTELPERC_DEPTH_GENERATOR | CV_CAP_PROP_FRAME_WIDTH); - cout << ", height = " << + cout << ", height = " << (int)capture.get(CV_CAP_INTELPERC_DEPTH_GENERATOR | CV_CAP_PROP_FRAME_HEIGHT); - cout << ", fps = " << + cout << ", fps = " << capture.get(CV_CAP_INTELPERC_DEPTH_GENERATOR | CV_CAP_PROP_FPS); cout << endl; } @@ -353,7 +352,7 @@ int _tmain(int argc, char* argv[]) { if (g_closedDepthPoint) { - double minVal = 0.0; double maxVal = 0.0; + double minVal = 0.0; double maxVal = 0.0; minMaxIdx(depthImage, &minVal, &maxVal, g_closedDepthPoint); } imshowDepth("depth image", depthImage, capture); @@ -375,5 +374,4 @@ int _tmain(int argc, char* argv[]) } return 0; -} - +} \ No newline at end of file From 63ae0eeba592e8855dd602ae9b1b406e48374645 Mon Sep 17 00:00:00 2001 From: Vladimir Bystricky Date: Tue, 17 Dec 2013 18:39:52 +0400 Subject: [PATCH 4/9] Fix build errors --- doc/user_guide/ug_intelperc.rst | 2 +- samples/cpp/intelperc_capture.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/user_guide/ug_intelperc.rst b/doc/user_guide/ug_intelperc.rst index 71a7c5d90e..bae5f70146 100644 --- a/doc/user_guide/ug_intelperc.rst +++ b/doc/user_guide/ug_intelperc.rst @@ -5,7 +5,7 @@ HighGUI .. highlight:: cpp Using Creative Senz3D and other Intel Perceptual Computing SDK compatible depth sensors -====================================================== +======================================================================================= Depth sensors compatible with Intel Perceptual Computing SDK are supported through ``VideoCapture`` class. Depth map, RGB image and some other formats of output can be retrieved by using familiar interface of ``VideoCapture``. diff --git a/samples/cpp/intelperc_capture.cpp b/samples/cpp/intelperc_capture.cpp index be032dead9..24ab0170eb 100644 --- a/samples/cpp/intelperc_capture.cpp +++ b/samples/cpp/intelperc_capture.cpp @@ -1,7 +1,6 @@ // testOpenCVCam.cpp : Defines the entry point for the console application. // -#include #include "opencv2/highgui/highgui.hpp" #include From dd71bef6f599b1a6130eb9bdfb9ba4a707ca65d4 Mon Sep 17 00:00:00 2001 From: Vladimir Bystricky Date: Wed, 18 Dec 2013 09:59:24 +0400 Subject: [PATCH 5/9] Fix errors in example (samples/cpp/intelperc_capture.cpp) --- samples/cpp/intelperc_capture.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/samples/cpp/intelperc_capture.cpp b/samples/cpp/intelperc_capture.cpp index 24ab0170eb..b81a278cfe 100644 --- a/samples/cpp/intelperc_capture.cpp +++ b/samples/cpp/intelperc_capture.cpp @@ -20,12 +20,12 @@ static bool g_showClosedPoint = false; static int g_closedDepthPoint[2]; -static void printUsage(char *arg0) +static void printUsage(const char *arg0) { - char *filename = arg0; + const char *filename = arg0; while (*filename) filename++; - while ((arg0 <= filename) && ('\\' != *filename) && ('//' != *filename)) + while ((arg0 <= filename) && ('\\' != *filename) && ('/' != *filename)) filename--; filename++; @@ -95,7 +95,7 @@ static void parseCMDLine(int argc, char* argv[]) exit(-1); } } - if (g_closedDepthPoint && (-1 == g_depthStreamProfileIdx)) + if (g_showClosedPoint && (-1 == g_depthStreamProfileIdx)) { cerr << "For --show-closed depth profile has be selected" << endl; exit(-1); @@ -153,7 +153,7 @@ static void printStreamProperties(VideoCapture &capture) static void imshowImage(const char *winname, Mat &image, VideoCapture &capture) { - if (g_closedDepthPoint) + if (g_showClosedPoint) { Mat uvMap; if (capture.retrieve(uvMap, CV_CAP_INTELPERC_UVDEPTH_MAP)) @@ -283,7 +283,7 @@ static void imshowDepth(const char *winname, Mat &depth, VideoCapture &capture) imshow(winname, image); } -int _tmain(int argc, char* argv[]) +int main(int argc, char* argv[]) { parseCMDLine(argc, argv); @@ -349,7 +349,7 @@ int _tmain(int argc, char* argv[]) if ((-1 != g_depthStreamProfileIdx) && (capture.retrieve(depthImage, CV_CAP_INTELPERC_DEPTH_MAP))) { - if (g_closedDepthPoint) + if (g_showClosedPoint) { double minVal = 0.0; double maxVal = 0.0; minMaxIdx(depthImage, &minVal, &maxVal, g_closedDepthPoint); From 66145ea06c68e427b19d3d0c2ae0103c96c333fe Mon Sep 17 00:00:00 2001 From: Vladimir Bystricky Date: Wed, 18 Dec 2013 10:55:09 +0400 Subject: [PATCH 6/9] Add CV_CAP_INTELPERC and CV_CAP_PROP_INTELPERC_ prefixes to const_ignore_list --- modules/java/generator/gen_java.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/java/generator/gen_java.py b/modules/java/generator/gen_java.py index 123daf70b8..c0aaed1918 100755 --- a/modules/java/generator/gen_java.py +++ b/modules/java/generator/gen_java.py @@ -18,6 +18,8 @@ class_ignore_list = ( const_ignore_list = ( "CV_CAP_OPENNI", "CV_CAP_PROP_OPENNI_", + "CV_CAP_INTELPERC", + "CV_CAP_PROP_INTELPERC_" "WINDOW_AUTOSIZE", "CV_WND_PROP_", "CV_WINDOW_", From 80d0593dbd62f9a2349a15f488f2b17547521534 Mon Sep 17 00:00:00 2001 From: Vladimir Bystricky Date: Wed, 18 Dec 2013 11:46:52 +0400 Subject: [PATCH 7/9] Delete end comma in enumerations --- modules/highgui/include/opencv2/highgui/highgui_c.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/highgui/include/opencv2/highgui/highgui_c.h b/modules/highgui/include/opencv2/highgui/highgui_c.h index 8a59197594..4f743ffec8 100644 --- a/modules/highgui/include/opencv2/highgui/highgui_c.h +++ b/modules/highgui/include/opencv2/highgui/highgui_c.h @@ -460,11 +460,11 @@ enum CV_CAP_PROP_IOS_DEVICE_EXPOSURE = 9002, CV_CAP_PROP_IOS_DEVICE_FLASH = 9003, CV_CAP_PROP_IOS_DEVICE_WHITEBALANCE = 9004, - CV_CAP_PROP_IOS_DEVICE_TORCH = 9005 + CV_CAP_PROP_IOS_DEVICE_TORCH = 9005, // Properties of cameras available through Smartek Giganetix Ethernet Vision interface /* --- Vladimir Litvinenko (litvinenko.vladimir@gmail.com) --- */ - ,CV_CAP_PROP_GIGA_FRAME_OFFSET_X = 10001, + CV_CAP_PROP_GIGA_FRAME_OFFSET_X = 10001, CV_CAP_PROP_GIGA_FRAME_OFFSET_Y = 10002, CV_CAP_PROP_GIGA_FRAME_WIDTH_MAX = 10003, CV_CAP_PROP_GIGA_FRAME_HEIGH_MAX = 10004, @@ -482,7 +482,7 @@ enum // Intel PerC streams CV_CAP_INTELPERC_DEPTH_GENERATOR = 1 << 29, CV_CAP_INTELPERC_IMAGE_GENERATOR = 1 << 28, - CV_CAP_INTELPERC_GENERATORS_MASK = CV_CAP_INTELPERC_DEPTH_GENERATOR + CV_CAP_INTELPERC_IMAGE_GENERATOR, + CV_CAP_INTELPERC_GENERATORS_MASK = CV_CAP_INTELPERC_DEPTH_GENERATOR + CV_CAP_INTELPERC_IMAGE_GENERATOR }; enum @@ -568,7 +568,7 @@ enum CV_CAP_INTELPERC_DEPTH_MAP = 0, // Each pixel is a 16-bit integer. The value indicates the distance from an object to the camera's XY plane or the Cartesian depth. CV_CAP_INTELPERC_UVDEPTH_MAP = 1, // Each pixel contains two 32-bit floating point values in the range of 0-1, representing the mapping of depth coordinates to the color coordinates. CV_CAP_INTELPERC_IR_MAP = 2, // Each pixel is a 16-bit integer. The value indicates the intensity of the reflected laser beam. - CV_CAP_INTELPERC_IMAGE = 3, + CV_CAP_INTELPERC_IMAGE = 3 }; /* retrieve or set capture properties */ From d449ba104a068c92a931a68d782245bbcb92af6c Mon Sep 17 00:00:00 2001 From: Vladimir Bystricky Date: Thu, 19 Dec 2013 10:29:19 +0400 Subject: [PATCH 8/9] Fix comment in the cmake file from SSDK to SDK --- cmake/OpenCVFindLibsVideo.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/OpenCVFindLibsVideo.cmake b/cmake/OpenCVFindLibsVideo.cmake index a5075b57f7..a797f04169 100644 --- a/cmake/OpenCVFindLibsVideo.cmake +++ b/cmake/OpenCVFindLibsVideo.cmake @@ -251,7 +251,7 @@ if (NOT IOS) endif() endif() -# --- Intel Perceptual Computing SSDK --- +# --- Intel Perceptual Computing SDK --- if(WITH_INTELPERC) include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindIntelPerCSDK.cmake") endif(WITH_INTELPERC) From d6a7e8f84fd5ac745af2589a573b011b82a69345 Mon Sep 17 00:00:00 2001 From: Vladimir Bystricky Date: Fri, 20 Dec 2013 12:33:39 +0400 Subject: [PATCH 9/9] Remove TBB ifdef form code --- modules/highgui/src/cap_intelperc.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/modules/highgui/src/cap_intelperc.cpp b/modules/highgui/src/cap_intelperc.cpp index 18b3b9d0c0..368f4fd2c5 100644 --- a/modules/highgui/src/cap_intelperc.cpp +++ b/modules/highgui/src/cap_intelperc.cpp @@ -2,10 +2,6 @@ #ifdef HAVE_INTELPERC -#if defined TBB_INTERFACE_VERSION && TBB_INTERFACE_VERSION < 5000 -# undef HAVE_TBB -#endif - #include "pxcsession.h" #include "pxcsmartptr.h" #include "pxccapture.h"