mirror of
https://github.com/introlab/rtabmap.git
synced 2026-10-06 10:07:47 +08:00
OpenCV 5 support (#1732)
* OpenCV 5 support * RTABMapConfig.cmake, guard from including stereoRectifyFisheye.h * unified opencv components at the same place * fixing android build * Confirmed stereo calibration with fisheye works. Fix camera start/top progress dialog not drawn. Opencv >=4.7 using new opencv's ArucoDetector class. * pinning opencv for downstream apps * Avoid changing object/image points between fisheye calibration * Fixed stereo calib diverging when recalibrating same data * removed not needed opencv c api * fixing depthai build on opencv5 * bumped version * Adding ci opencv5 with homebrew * fixed ci script * Fixed OptimizerCeres build with opencv5
This commit is contained in:
@@ -32,7 +32,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <rtabmap/utilite/UEventsManager.h>
|
||||
#include <rtabmap/utilite/UConversion.h>
|
||||
#include <rtabmap/utilite/UFile.h>
|
||||
|
||||
#if CV_MAJOR_VERSION < 5
|
||||
#include <opencv2/calib3d/calib3d.hpp>
|
||||
#else
|
||||
#include <opencv2/geometry.hpp>
|
||||
#endif
|
||||
|
||||
namespace rtabmap {
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <rtabmap/utilite/UThread.h>
|
||||
#include <rtabmap/utilite/UTimer.h>
|
||||
#include <rtabmap/core/util2d.h>
|
||||
#include <opencv2/imgproc/types_c.h>
|
||||
|
||||
#ifdef RTABMAP_FREENECT
|
||||
#include <libfreenect.h>
|
||||
@@ -183,7 +182,7 @@ private:
|
||||
|
||||
if(color_)
|
||||
{
|
||||
cv::cvtColor(rgbIrBuffer_, rgbIrLastFrame_, CV_RGB2BGR);
|
||||
cv::cvtColor(rgbIrBuffer_, rgbIrLastFrame_, cv::COLOR_RGB2BGR);
|
||||
}
|
||||
else // IrDepth
|
||||
{
|
||||
|
||||
@@ -29,7 +29,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <rtabmap/utilite/UMath.h>
|
||||
#include <rtabmap/utilite/UTimer.h>
|
||||
#include <rtabmap/core/util2d.h>
|
||||
#include <opencv2/imgproc/types_c.h>
|
||||
|
||||
#ifdef RTABMAP_FREENECT2
|
||||
#include <libfreenect2/libfreenect2.hpp>
|
||||
@@ -430,11 +429,11 @@ SensorData CameraFreenect2::captureImage(SensorCaptureInfo * info)
|
||||
cv::Mat rgbMat; // rtabmap uses 3 channels RGB
|
||||
#ifdef LIBFREENECT2_WITH_TEGRAJPEG_SUPPORT
|
||||
|
||||
cv::cvtColor(rgbMatC4, rgbMat, CV_RGBA2BGR);
|
||||
cv::cvtColor(rgbMatC4, rgbMat, cv::COLOR_RGBA2BGR);
|
||||
|
||||
#else
|
||||
|
||||
cv::cvtColor(rgbMatC4, rgbMat, CV_BGRA2BGR);
|
||||
cv::cvtColor(rgbMatC4, rgbMat, cv::COLOR_BGRA2BGR);
|
||||
|
||||
#endif
|
||||
cv::flip(rgbMat, rgb, 1);
|
||||
@@ -490,11 +489,11 @@ SensorData CameraFreenect2::captureImage(SensorCaptureInfo * info)
|
||||
cv::Mat rgbMat; // rtabmap uses 3 channels RGB
|
||||
#ifdef LIBFREENECT2_WITH_TEGRAJPEG_SUPPORT
|
||||
|
||||
cv::cvtColor(rgbMatC4, rgbMat, CV_RGB2BGR);
|
||||
cv::cvtColor(rgbMatC4, rgbMat, cv::COLOR_RGB2BGR);
|
||||
|
||||
#else
|
||||
|
||||
cv::cvtColor(rgbMatC4, rgbMat, CV_BGRA2BGR);
|
||||
cv::cvtColor(rgbMatC4, rgbMat, cv::COLOR_BGRA2BGR);
|
||||
|
||||
#endif
|
||||
cv::flip(rgbMat, rgb, 1);
|
||||
@@ -607,11 +606,11 @@ SensorData CameraFreenect2::captureImage(SensorCaptureInfo * info)
|
||||
// rtabmap uses 3 channels RGB
|
||||
#ifdef LIBFREENECT2_WITH_TEGRAJPEG_SUPPORT
|
||||
|
||||
cv::cvtColor(rgbMatBGRA, rgb, CV_RGBA2BGR);
|
||||
cv::cvtColor(rgbMatBGRA, rgb, cv::COLOR_RGBA2BGR);
|
||||
|
||||
#else
|
||||
|
||||
cv::cvtColor(rgbMatBGRA, rgb, CV_BGRA2BGR);
|
||||
cv::cvtColor(rgbMatBGRA, rgb, cv::COLOR_BGRA2BGR);
|
||||
|
||||
#endif
|
||||
cv::flip(rgb, rgb, 1);
|
||||
@@ -629,11 +628,11 @@ SensorData CameraFreenect2::captureImage(SensorCaptureInfo * info)
|
||||
// rtabmap uses 3 channels RGB
|
||||
#ifdef LIBFREENECT2_WITH_TEGRAJPEG_SUPPORT
|
||||
|
||||
cv::cvtColor(rgbMatBGRA, rgb, CV_RGBA2BGR);
|
||||
cv::cvtColor(rgbMatBGRA, rgb, cv::COLOR_RGBA2BGR);
|
||||
|
||||
#else
|
||||
|
||||
cv::cvtColor(rgbMatBGRA, rgb, CV_BGRA2BGR);
|
||||
cv::cvtColor(rgbMatBGRA, rgb, cv::COLOR_BGRA2BGR);
|
||||
|
||||
#endif
|
||||
cv::flip(rgb, rgb, 1);
|
||||
|
||||
@@ -34,7 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <rtabmap/core/util3d.h>
|
||||
#include <rtabmap/core/util3d_filtering.h>
|
||||
#include <rtabmap/core/Graph.h>
|
||||
#include <opencv2/imgproc/types_c.h>
|
||||
#include <opencv2/imgproc.hpp>
|
||||
#include <fstream>
|
||||
|
||||
namespace rtabmap
|
||||
@@ -1111,7 +1111,7 @@ SensorData CameraImages::captureImage(SensorCaptureInfo * info)
|
||||
{
|
||||
UWARN("Conversion from 4 channels to 3 channels (file=%s)", imageFilePath.c_str());
|
||||
cv::Mat out;
|
||||
cv::cvtColor(img, out, CV_BGRA2BGR);
|
||||
cv::cvtColor(img, out, cv::COLOR_BGRA2BGR);
|
||||
img = out;
|
||||
}
|
||||
else if(!img.empty() && _bayerMode >= 0 && _bayerMode <=3)
|
||||
@@ -1119,7 +1119,7 @@ SensorData CameraImages::captureImage(SensorCaptureInfo * info)
|
||||
cv::Mat debayeredImg;
|
||||
try
|
||||
{
|
||||
cv::cvtColor(img, debayeredImg, CV_BayerBG2BGR + _bayerMode);
|
||||
cv::cvtColor(img, debayeredImg, cv::COLOR_BayerBG2BGR + _bayerMode);
|
||||
img = debayeredImg;
|
||||
}
|
||||
catch(const cv::Exception & e)
|
||||
|
||||
@@ -29,7 +29,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <rtabmap/utilite/UThreadC.h>
|
||||
#include <rtabmap/core/util2d.h>
|
||||
#include <rtabmap/core/Compression.h>
|
||||
#include <opencv2/imgproc/types_c.h>
|
||||
|
||||
#ifdef RTABMAP_K4A
|
||||
#include <k4a/k4a.h>
|
||||
@@ -508,7 +507,7 @@ SensorData CameraK4A::captureImage(SensorCaptureInfo * info)
|
||||
CV_8UC4,
|
||||
(void*)k4a_image_get_buffer(rgb_image_));
|
||||
|
||||
cv::cvtColor(bgra, bgrCV, CV_BGRA2BGR);
|
||||
cv::cvtColor(bgra, bgrCV, cv::COLOR_BGRA2BGR);
|
||||
}
|
||||
bgrCV = model_.rectifyImage(bgrCV);
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <rtabmap/utilite/UTimer.h>
|
||||
#include <rtabmap/utilite/UThreadC.h>
|
||||
#include <rtabmap/core/util2d.h>
|
||||
#include <opencv2/imgproc/types_c.h>
|
||||
|
||||
#ifdef RTABMAP_K4W2
|
||||
#include <Kinect.h>
|
||||
@@ -486,11 +485,11 @@ SensorData CameraK4W2::captureImage(SensorCaptureInfo * info)
|
||||
{
|
||||
cv::Mat tmp;
|
||||
cv::resize(cv::Mat(nColorHeight, nColorWidth, CV_8UC4, pColorBuffer), tmp, cv::Size(), 0.5, 0.5, cv::INTER_AREA);
|
||||
cv::cvtColor(tmp, imageColor, CV_BGRA2BGR);
|
||||
cv::cvtColor(tmp, imageColor, cv::COLOR_BGRA2BGR);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::cvtColor(cv::Mat(nColorHeight, nColorWidth, CV_8UC4, pColorBuffer), imageColor, CV_BGRA2BGR);
|
||||
cv::cvtColor(cv::Mat(nColorHeight, nColorWidth, CV_8UC4, pColorBuffer), imageColor, cv::COLOR_BGRA2BGR);
|
||||
}
|
||||
// loop over output pixels
|
||||
for (int depthIndex = 0; depthIndex < (nDepthWidth*nDepthHeight); ++depthIndex)
|
||||
|
||||
@@ -29,7 +29,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <rtabmap/utilite/UFile.h>
|
||||
#include <rtabmap/utilite/UThreadC.h>
|
||||
#include <rtabmap/core/util2d.h>
|
||||
#include <opencv2/imgproc/types_c.h>
|
||||
|
||||
#ifdef RTABMAP_OPENNI2
|
||||
#include <OniVersion.h>
|
||||
@@ -514,7 +513,7 @@ SensorData CameraOpenNI2::captureImage(SensorCaptureInfo * info)
|
||||
cv::Mat tmp(h, w, CV_8UC3, (void *)colorFrame.getData());
|
||||
if(_type==kTypeColorDepth)
|
||||
{
|
||||
cv::cvtColor(tmp, rgb, CV_RGB2BGR);
|
||||
cv::cvtColor(tmp, rgb, cv::COLOR_RGB2BGR);
|
||||
}
|
||||
else // IR
|
||||
{
|
||||
|
||||
@@ -26,9 +26,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <rtabmap/core/camera/CameraOpenNICV.h>
|
||||
#include <rtabmap/utilite/UTimer.h>
|
||||
#if CV_MAJOR_VERSION > 3
|
||||
#include <opencv2/videoio/videoio_c.h>
|
||||
#endif
|
||||
#include <opencv2/videoio.hpp>
|
||||
|
||||
namespace rtabmap
|
||||
{
|
||||
@@ -59,30 +57,34 @@ bool CameraOpenNICV::init(const std::string & calibrationFolder, const std::stri
|
||||
}
|
||||
|
||||
ULOGGER_DEBUG("Camera::init()");
|
||||
_capture.open( _asus?CV_CAP_OPENNI_ASUS:CV_CAP_OPENNI );
|
||||
#if CV_MAJOR_VERSION < 5
|
||||
_capture.open( _asus?cv::CAP_OPENNI_ASUS:cv::CAP_OPENNI );
|
||||
#else
|
||||
_capture.open( _asus?cv::CAP_OPENNI2_ASUS:cv::CAP_OPENNI2 );
|
||||
#endif
|
||||
if(_capture.isOpened())
|
||||
{
|
||||
_capture.set( CV_CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE, CV_CAP_OPENNI_VGA_30HZ );
|
||||
_depthFocal = _capture.get( CV_CAP_OPENNI_DEPTH_GENERATOR_FOCAL_LENGTH );
|
||||
_capture.set( cv::CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE, cv::CAP_OPENNI_VGA_30HZ );
|
||||
_depthFocal = _capture.get( cv::CAP_OPENNI_DEPTH_GENERATOR_FOCAL_LENGTH );
|
||||
// Print some avalible device settings.
|
||||
UINFO("Depth generator output mode:");
|
||||
UINFO("FRAME_WIDTH %f", _capture.get( CV_CAP_PROP_FRAME_WIDTH ));
|
||||
UINFO("FRAME_HEIGHT %f", _capture.get( CV_CAP_PROP_FRAME_HEIGHT ));
|
||||
UINFO("FRAME_MAX_DEPTH %f mm", _capture.get( CV_CAP_PROP_OPENNI_FRAME_MAX_DEPTH ));
|
||||
UINFO("BASELINE %f mm", _capture.get( CV_CAP_PROP_OPENNI_BASELINE ));
|
||||
UINFO("FPS %f", _capture.get( CV_CAP_PROP_FPS ));
|
||||
UINFO("Focal %f", _capture.get( CV_CAP_OPENNI_DEPTH_GENERATOR_FOCAL_LENGTH ));
|
||||
UINFO("REGISTRATION %f", _capture.get( CV_CAP_PROP_OPENNI_REGISTRATION ));
|
||||
if(_capture.get( CV_CAP_PROP_OPENNI_REGISTRATION ) == 0.0)
|
||||
UINFO("FRAME_WIDTH %f", _capture.get( cv::CAP_PROP_FRAME_WIDTH ));
|
||||
UINFO("FRAME_HEIGHT %f", _capture.get( cv::CAP_PROP_FRAME_HEIGHT ));
|
||||
UINFO("FRAME_MAX_DEPTH %f mm", _capture.get( cv::CAP_PROP_OPENNI_FRAME_MAX_DEPTH ));
|
||||
UINFO("BASELINE %f mm", _capture.get( cv::CAP_PROP_OPENNI_BASELINE ));
|
||||
UINFO("FPS %f", _capture.get( cv::CAP_PROP_FPS ));
|
||||
UINFO("Focal %f", _capture.get( cv::CAP_OPENNI_DEPTH_GENERATOR_FOCAL_LENGTH ));
|
||||
UINFO("REGISTRATION %f", _capture.get( cv::CAP_PROP_OPENNI_REGISTRATION ));
|
||||
if(_capture.get( cv::CAP_PROP_OPENNI_REGISTRATION ) == 0.0)
|
||||
{
|
||||
UERROR("Depth registration is not activated on this device!");
|
||||
}
|
||||
if( _capture.get( CV_CAP_OPENNI_IMAGE_GENERATOR_PRESENT ) )
|
||||
if( _capture.get( cv::CAP_OPENNI_IMAGE_GENERATOR_PRESENT ) )
|
||||
{
|
||||
UINFO("Image generator output mode:");
|
||||
UINFO("FRAME_WIDTH %f", _capture.get( CV_CAP_OPENNI_IMAGE_GENERATOR+CV_CAP_PROP_FRAME_WIDTH ));
|
||||
UINFO("FRAME_HEIGHT %f", _capture.get( CV_CAP_OPENNI_IMAGE_GENERATOR+CV_CAP_PROP_FRAME_HEIGHT ));
|
||||
UINFO("FPS %f", _capture.get( CV_CAP_OPENNI_IMAGE_GENERATOR+CV_CAP_PROP_FPS ));
|
||||
UINFO("FRAME_WIDTH %f", _capture.get( cv::CAP_OPENNI_IMAGE_GENERATOR+cv::CAP_PROP_FRAME_WIDTH ));
|
||||
UINFO("FRAME_HEIGHT %f", _capture.get( cv::CAP_OPENNI_IMAGE_GENERATOR+cv::CAP_PROP_FRAME_HEIGHT ));
|
||||
UINFO("FPS %f", _capture.get( cv::CAP_OPENNI_IMAGE_GENERATOR+cv::CAP_PROP_FPS ));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -112,8 +114,8 @@ SensorData CameraOpenNICV::captureImage(SensorCaptureInfo * info)
|
||||
{
|
||||
_capture.grab();
|
||||
cv::Mat depth, rgb;
|
||||
_capture.retrieve(depth, CV_CAP_OPENNI_DEPTH_MAP );
|
||||
_capture.retrieve(rgb, CV_CAP_OPENNI_BGR_IMAGE );
|
||||
_capture.retrieve(depth, cv::CAP_OPENNI_DEPTH_MAP );
|
||||
_capture.retrieve(rgb, cv::CAP_OPENNI_BGR_IMAGE );
|
||||
|
||||
depth = depth.clone();
|
||||
rgb = rgb.clone();
|
||||
|
||||
@@ -28,7 +28,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <rtabmap/utilite/UFile.h>
|
||||
#include <rtabmap/utilite/UThreadC.h>
|
||||
#include <rtabmap/utilite/UTimer.h>
|
||||
#include <opencv2/imgproc/types_c.h>
|
||||
|
||||
#ifdef RTABMAP_OPENNI
|
||||
#include <pcl/io/openni_grabber.h>
|
||||
@@ -94,7 +93,7 @@ void CameraOpenni::image_cb (
|
||||
|
||||
cv::Mat rgbFrame(rgb->getHeight(), rgb->getWidth(), CV_8UC3);
|
||||
rgb->fillRGB(rgb->getWidth(), rgb->getHeight(), rgbFrame.data);
|
||||
cv::cvtColor(rgbFrame, rgb_, CV_RGB2BGR);
|
||||
cv::cvtColor(rgbFrame, rgb_, cv::COLOR_RGB2BGR);
|
||||
|
||||
depth_ = cv::Mat(rgb->getHeight(), rgb->getWidth(), CV_16UC1);
|
||||
depth->fillDepthImageRaw(rgb->getWidth(), rgb->getHeight(), (unsigned short*)depth_.data);
|
||||
|
||||
@@ -29,7 +29,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <rtabmap/utilite/UMath.h>
|
||||
#include <rtabmap/utilite/UThreadC.h>
|
||||
#include <rtabmap/core/util2d.h>
|
||||
#include <opencv2/imgproc/types_c.h>
|
||||
|
||||
#ifdef RTABMAP_REALSENSE
|
||||
#include <librealsense/rs.hpp>
|
||||
@@ -938,7 +937,7 @@ SensorData CameraRealSense::captureImage(SensorCaptureInfo * info)
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::cvtColor(rgb, bgr, CV_RGB2BGR);
|
||||
cv::cvtColor(rgb, bgr, cv::COLOR_RGB2BGR);
|
||||
}
|
||||
|
||||
bool rectified = false;
|
||||
|
||||
@@ -31,7 +31,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <rtabmap/utilite/UConversion.h>
|
||||
#include <rtabmap/utilite/UStl.h>
|
||||
#include <rtabmap/utilite/UDirectory.h>
|
||||
#include <opencv2/imgproc/types_c.h>
|
||||
|
||||
#ifdef RTABMAP_REALSENSE2
|
||||
#include <librealsense2/rsutil.h>
|
||||
@@ -1440,7 +1439,7 @@ SensorData CameraRealSense2::captureImage(SensorCaptureInfo * info)
|
||||
cv::Mat bgr;
|
||||
if(rgb.channels() == 3)
|
||||
{
|
||||
cv::cvtColor(rgb, bgr, CV_RGB2BGR);
|
||||
cv::cvtColor(rgb, bgr, cv::COLOR_RGB2BGR);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -28,7 +28,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <rtabmap/core/camera/CameraStereoDC1394.h>
|
||||
#include <rtabmap/utilite/UTimer.h>
|
||||
#include <rtabmap/utilite/UConversion.h>
|
||||
#include <opencv2/imgproc/types_c.h>
|
||||
|
||||
#ifdef RTABMAP_DC1394
|
||||
#include <dc1394/dc1394.h>
|
||||
@@ -295,8 +294,8 @@ public:
|
||||
|
||||
//DC1394_COLOR_CODING_RAW16:
|
||||
//DC1394_COLOR_FILTER_BGGR
|
||||
cv::cvtColor(cv::Mat(frame->size[1], frame->size[0], CV_8UC1, capture_buffer), left, CV_BayerRG2BGR);
|
||||
cv::cvtColor(cv::Mat(frame->size[1], frame->size[0], CV_8UC1, capture_buffer+image.total()), right, CV_BayerRG2GRAY);
|
||||
cv::cvtColor(cv::Mat(frame->size[1], frame->size[0], CV_8UC1, capture_buffer), left, cv::COLOR_BayerRG2BGR);
|
||||
cv::cvtColor(cv::Mat(frame->size[1], frame->size[0], CV_8UC1, capture_buffer+image.total()), right, cv::COLOR_BayerRG2GRAY);
|
||||
|
||||
dc1394_capture_enqueue(camera_, frame);
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <rtabmap/utilite/UStl.h>
|
||||
#include <rtabmap/utilite/UFile.h>
|
||||
#include <rtabmap/utilite/UConversion.h>
|
||||
#include <opencv2/imgproc/types_c.h>
|
||||
|
||||
namespace rtabmap
|
||||
{
|
||||
@@ -339,7 +338,7 @@ SensorData CameraStereoImages::captureImage(SensorCaptureInfo * info)
|
||||
if(rightImage.type() != CV_8UC1 && rightGrayScale_)
|
||||
{
|
||||
cv::Mat tmp;
|
||||
cv::cvtColor(rightImage, tmp, CV_BGR2GRAY);
|
||||
cv::cvtColor(rightImage, tmp, cv::COLOR_BGR2GRAY);
|
||||
rightImage = tmp;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,9 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <rtabmap/utilite/UTimer.h>
|
||||
#include <rtabmap/utilite/UThreadC.h>
|
||||
#include <rtabmap/utilite/UConversion.h>
|
||||
#if CV_MAJOR_VERSION > 3
|
||||
#include <opencv2/videoio/videoio_c.h>
|
||||
#endif
|
||||
#include <opencv2/videoio.hpp>
|
||||
|
||||
namespace rtabmap
|
||||
{
|
||||
@@ -81,18 +79,18 @@ bool CameraStereoTara::init(const std::string & calibrationFolder, const std::st
|
||||
|
||||
capture_.open(usbDevice_);
|
||||
|
||||
capture_.set(CV_CAP_PROP_FOURCC, CV_FOURCC('Y', '1', '6', ' '));
|
||||
capture_.set(CV_CAP_PROP_FPS, 60);
|
||||
capture_.set(CV_CAP_PROP_FRAME_WIDTH, 752);
|
||||
capture_.set(CV_CAP_PROP_FRAME_HEIGHT, 480);
|
||||
capture_.set(CV_CAP_PROP_CONVERT_RGB,false);
|
||||
capture_.set(cv::CAP_PROP_FOURCC, cv::VideoWriter::fourcc('Y', '1', '6', ' '));
|
||||
capture_.set(cv::CAP_PROP_FPS, 60);
|
||||
capture_.set(cv::CAP_PROP_FRAME_WIDTH, 752);
|
||||
capture_.set(cv::CAP_PROP_FRAME_HEIGHT, 480);
|
||||
capture_.set(cv::CAP_PROP_CONVERT_RGB,false);
|
||||
|
||||
ULOGGER_DEBUG("CameraStereoTara: Usb device initialization on device %d", usbDevice_);
|
||||
|
||||
|
||||
if (cameraName_.empty())
|
||||
{
|
||||
unsigned int guid = (unsigned int)capture_.get(CV_CAP_PROP_GUID);
|
||||
unsigned int guid = (unsigned int)capture_.get(cv::CAP_PROP_GUID);
|
||||
if (guid != 0 && guid != 0xffffffff)
|
||||
{
|
||||
cameraName_ = uFormat("%08x", guid);
|
||||
|
||||
@@ -28,13 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <rtabmap/core/camera/CameraStereoVideo.h>
|
||||
#include <rtabmap/utilite/UTimer.h>
|
||||
#include <rtabmap/utilite/UConversion.h>
|
||||
#include <opencv2/imgproc/types_c.h>
|
||||
#if CV_MAJOR_VERSION > 3
|
||||
#include <opencv2/videoio/videoio_c.h>
|
||||
#if CV_MAJOR_VERSION > 4
|
||||
#include <opencv2/videoio/legacy/constants_c.h>
|
||||
#endif
|
||||
#endif
|
||||
#include <opencv2/videoio.hpp>
|
||||
|
||||
namespace rtabmap
|
||||
{
|
||||
@@ -172,7 +166,7 @@ bool CameraStereoVideo::init(const std::string & calibrationFolder, const std::s
|
||||
|
||||
if (cameraName_.empty())
|
||||
{
|
||||
unsigned int guid = (unsigned int)capture_.get(CV_CAP_PROP_GUID);
|
||||
unsigned int guid = (unsigned int)capture_.get(cv::CAP_PROP_GUID);
|
||||
if (guid != 0 && guid != 0xffffffff)
|
||||
{
|
||||
cameraName_ = uFormat("%08x", guid);
|
||||
@@ -214,17 +208,17 @@ bool CameraStereoVideo::init(const std::string & calibrationFolder, const std::s
|
||||
if(capture_.isOpened())
|
||||
{
|
||||
bool resolutionSet = false;
|
||||
resolutionSet = capture_.set(CV_CAP_PROP_FRAME_WIDTH, stereoModel_.left().imageWidth()*(capture2_.isOpened()?1:2));
|
||||
resolutionSet = resolutionSet && capture_.set(CV_CAP_PROP_FRAME_HEIGHT, stereoModel_.left().imageHeight());
|
||||
resolutionSet = capture_.set(cv::CAP_PROP_FRAME_WIDTH, stereoModel_.left().imageWidth()*(capture2_.isOpened()?1:2));
|
||||
resolutionSet = resolutionSet && capture_.set(cv::CAP_PROP_FRAME_HEIGHT, stereoModel_.left().imageHeight());
|
||||
if(capture2_.isOpened())
|
||||
{
|
||||
resolutionSet = resolutionSet && capture2_.set(CV_CAP_PROP_FRAME_WIDTH, stereoModel_.right().imageWidth());
|
||||
resolutionSet = resolutionSet && capture2_.set(CV_CAP_PROP_FRAME_HEIGHT, stereoModel_.right().imageHeight());
|
||||
resolutionSet = resolutionSet && capture2_.set(cv::CAP_PROP_FRAME_WIDTH, stereoModel_.right().imageWidth());
|
||||
resolutionSet = resolutionSet && capture2_.set(cv::CAP_PROP_FRAME_HEIGHT, stereoModel_.right().imageHeight());
|
||||
}
|
||||
|
||||
// Check if the resolution was set successfully
|
||||
int actualWidth = int(capture_.get(CV_CAP_PROP_FRAME_WIDTH));
|
||||
int actualHeight = int(capture_.get(CV_CAP_PROP_FRAME_HEIGHT));
|
||||
int actualWidth = int(capture_.get(cv::CAP_PROP_FRAME_WIDTH));
|
||||
int actualHeight = int(capture_.get(cv::CAP_PROP_FRAME_HEIGHT));
|
||||
if(!resolutionSet ||
|
||||
actualWidth != stereoModel_.left().imageWidth()*(capture2_.isOpened()?1:2) ||
|
||||
actualHeight != stereoModel_.left().imageHeight())
|
||||
@@ -244,17 +238,17 @@ bool CameraStereoVideo::init(const std::string & calibrationFolder, const std::s
|
||||
if(capture_.isOpened())
|
||||
{
|
||||
bool resolutionSet = false;
|
||||
resolutionSet = capture_.set(CV_CAP_PROP_FRAME_WIDTH, _width*(capture2_.isOpened()?1:2));
|
||||
resolutionSet = resolutionSet && capture_.set(CV_CAP_PROP_FRAME_HEIGHT, _height);
|
||||
resolutionSet = capture_.set(cv::CAP_PROP_FRAME_WIDTH, _width*(capture2_.isOpened()?1:2));
|
||||
resolutionSet = resolutionSet && capture_.set(cv::CAP_PROP_FRAME_HEIGHT, _height);
|
||||
if(capture2_.isOpened())
|
||||
{
|
||||
resolutionSet = resolutionSet && capture2_.set(CV_CAP_PROP_FRAME_WIDTH, _width);
|
||||
resolutionSet = resolutionSet && capture2_.set(CV_CAP_PROP_FRAME_HEIGHT, _height);
|
||||
resolutionSet = resolutionSet && capture2_.set(cv::CAP_PROP_FRAME_WIDTH, _width);
|
||||
resolutionSet = resolutionSet && capture2_.set(cv::CAP_PROP_FRAME_HEIGHT, _height);
|
||||
}
|
||||
|
||||
// Check if the resolution was set successfully
|
||||
int actualWidth = int(capture_.get(CV_CAP_PROP_FRAME_WIDTH));
|
||||
int actualHeight = int(capture_.get(CV_CAP_PROP_FRAME_HEIGHT));
|
||||
int actualWidth = int(capture_.get(cv::CAP_PROP_FRAME_WIDTH));
|
||||
int actualHeight = int(capture_.get(cv::CAP_PROP_FRAME_HEIGHT));
|
||||
if(!resolutionSet ||
|
||||
actualWidth != _width*(capture2_.isOpened()?1:2) ||
|
||||
actualHeight != _height)
|
||||
@@ -273,10 +267,10 @@ bool CameraStereoVideo::init(const std::string & calibrationFolder, const std::s
|
||||
if (this->getFrameRate() > 0)
|
||||
{
|
||||
bool fpsSupported = false;
|
||||
fpsSupported = capture_.set(CV_CAP_PROP_FPS, this->getFrameRate());
|
||||
fpsSupported = capture_.set(cv::CAP_PROP_FPS, this->getFrameRate());
|
||||
if (capture2_.isOpened())
|
||||
{
|
||||
fpsSupported = fpsSupported && capture2_.set(CV_CAP_PROP_FPS, this->getFrameRate());
|
||||
fpsSupported = fpsSupported && capture2_.set(cv::CAP_PROP_FPS, this->getFrameRate());
|
||||
}
|
||||
if(fpsSupported)
|
||||
{
|
||||
@@ -310,14 +304,14 @@ bool CameraStereoVideo::init(const std::string & calibrationFolder, const std::s
|
||||
std::string fourccUpperCase = uToUpperCase(_fourcc);
|
||||
int fourcc = cv::VideoWriter::fourcc(fourccUpperCase.at(0), fourccUpperCase.at(1), fourccUpperCase.at(2), fourccUpperCase.at(3));
|
||||
bool fourccSupported = false;
|
||||
fourccSupported = capture_.set(CV_CAP_PROP_FOURCC, fourcc);
|
||||
fourccSupported = capture_.set(cv::CAP_PROP_FOURCC, fourcc);
|
||||
if (capture2_.isOpened())
|
||||
{
|
||||
fourccSupported = fourccSupported && capture2_.set(CV_CAP_PROP_FOURCC, fourcc);
|
||||
fourccSupported = fourccSupported && capture2_.set(cv::CAP_PROP_FOURCC, fourcc);
|
||||
}
|
||||
|
||||
// Check if the FOURCC was set successfully
|
||||
int actualFourcc = int(capture_.get(CV_CAP_PROP_FOURCC));
|
||||
int actualFourcc = int(capture_.get(cv::CAP_PROP_FOURCC));
|
||||
|
||||
if(!fourccSupported || actualFourcc != fourcc)
|
||||
{
|
||||
@@ -386,7 +380,7 @@ SensorData CameraStereoVideo::captureImage(SensorCaptureInfo * info)
|
||||
if(rightImage.type() != CV_8UC1 && rightGrayScale_)
|
||||
{
|
||||
cv::Mat tmp;
|
||||
cv::cvtColor(rightImage, tmp, CV_BGR2GRAY);
|
||||
cv::cvtColor(rightImage, tmp, cv::COLOR_BGR2GRAY);
|
||||
rightImage = tmp;
|
||||
rightCvt = true;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <zed-open-capture/sensorcapture.hpp>
|
||||
#include "SimpleIni.h"
|
||||
|
||||
#if CV_MAJOR_VERSION >= 5
|
||||
#include <opencv2/geometry.hpp>
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2018, STEREOLABS.
|
||||
|
||||
@@ -28,12 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <rtabmap/core/camera/CameraVideo.h>
|
||||
#include <rtabmap/utilite/UTimer.h>
|
||||
#include <rtabmap/utilite/UConversion.h>
|
||||
#if CV_MAJOR_VERSION > 3
|
||||
#include <opencv2/videoio/videoio_c.h>
|
||||
#if CV_MAJOR_VERSION > 4
|
||||
#include <opencv2/videoio/legacy/constants_c.h>
|
||||
#endif
|
||||
#endif
|
||||
#include <opencv2/videoio.hpp>
|
||||
|
||||
namespace rtabmap
|
||||
{
|
||||
@@ -105,7 +100,7 @@ bool CameraVideo::init(const std::string & calibrationFolder, const std::string
|
||||
{
|
||||
if (_guid.empty())
|
||||
{
|
||||
unsigned int guid = (unsigned int)_capture.get(CV_CAP_PROP_GUID);
|
||||
unsigned int guid = (unsigned int)_capture.get(cv::CAP_PROP_GUID);
|
||||
if (guid != 0 && guid != 0xffffffff)
|
||||
{
|
||||
_guid = uFormat("%08x", guid);
|
||||
@@ -143,12 +138,12 @@ bool CameraVideo::init(const std::string & calibrationFolder, const std::string
|
||||
}
|
||||
|
||||
bool resolutionSet = false;
|
||||
resolutionSet = _capture.set(CV_CAP_PROP_FRAME_WIDTH, _model.imageWidth());
|
||||
resolutionSet = resolutionSet && _capture.set(CV_CAP_PROP_FRAME_HEIGHT, _model.imageHeight());
|
||||
resolutionSet = _capture.set(cv::CAP_PROP_FRAME_WIDTH, _model.imageWidth());
|
||||
resolutionSet = resolutionSet && _capture.set(cv::CAP_PROP_FRAME_HEIGHT, _model.imageHeight());
|
||||
|
||||
// Check if the resolution was set successfully
|
||||
int actualWidth = int(_capture.get(CV_CAP_PROP_FRAME_WIDTH));
|
||||
int actualHeight = int(_capture.get(CV_CAP_PROP_FRAME_HEIGHT));
|
||||
int actualWidth = int(_capture.get(cv::CAP_PROP_FRAME_WIDTH));
|
||||
int actualHeight = int(_capture.get(cv::CAP_PROP_FRAME_HEIGHT));
|
||||
if(!resolutionSet ||
|
||||
actualWidth != _model.imageWidth() ||
|
||||
actualHeight != _model.imageHeight())
|
||||
@@ -165,12 +160,12 @@ bool CameraVideo::init(const std::string & calibrationFolder, const std::string
|
||||
else if(_width > 0 && _height > 0)
|
||||
{
|
||||
int resolutionSet = false;
|
||||
resolutionSet = _capture.set(CV_CAP_PROP_FRAME_WIDTH, _width);
|
||||
resolutionSet = resolutionSet && _capture.set(CV_CAP_PROP_FRAME_HEIGHT, _height);
|
||||
resolutionSet = _capture.set(cv::CAP_PROP_FRAME_WIDTH, _width);
|
||||
resolutionSet = resolutionSet && _capture.set(cv::CAP_PROP_FRAME_HEIGHT, _height);
|
||||
|
||||
// Check if the resolution was set successfully
|
||||
int actualWidth = int(_capture.get(CV_CAP_PROP_FRAME_WIDTH));
|
||||
int actualHeight = int(_capture.get(CV_CAP_PROP_FRAME_HEIGHT));
|
||||
int actualWidth = int(_capture.get(cv::CAP_PROP_FRAME_WIDTH));
|
||||
int actualHeight = int(_capture.get(cv::CAP_PROP_FRAME_HEIGHT));
|
||||
if(!resolutionSet || actualWidth != _width || actualHeight != _height)
|
||||
{
|
||||
UWARN("Desired resolution (%dx%d) cannot be set to camera driver, "
|
||||
@@ -182,7 +177,7 @@ bool CameraVideo::init(const std::string & calibrationFolder, const std::string
|
||||
}
|
||||
|
||||
// Set FPS
|
||||
if (this->getFrameRate() > 0 && _capture.set(CV_CAP_PROP_FPS, this->getFrameRate()))
|
||||
if (this->getFrameRate() > 0 && _capture.set(cv::CAP_PROP_FPS, this->getFrameRate()))
|
||||
{
|
||||
// Check if the FPS was set successfully
|
||||
double actualFPS = _capture.get(cv::CAP_PROP_FPS);
|
||||
@@ -213,10 +208,10 @@ bool CameraVideo::init(const std::string & calibrationFolder, const std::string
|
||||
std::string fourccUpperCase = uToUpperCase(_fourcc);
|
||||
int fourcc = cv::VideoWriter::fourcc(fourccUpperCase.at(0), fourccUpperCase.at(1), fourccUpperCase.at(2), fourccUpperCase.at(3));
|
||||
|
||||
bool fourccSupported = _capture.set(CV_CAP_PROP_FOURCC, fourcc);
|
||||
bool fourccSupported = _capture.set(cv::CAP_PROP_FOURCC, fourcc);
|
||||
|
||||
// Check if the FOURCC was set successfully
|
||||
int actualFourcc = int(_capture.get(CV_CAP_PROP_FOURCC));
|
||||
int actualFourcc = int(_capture.get(cv::CAP_PROP_FOURCC));
|
||||
|
||||
if(!fourccSupported || actualFourcc != fourcc)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user