Enable OpenCV4 compability
This commit is contained in:
@@ -29,6 +29,9 @@
|
||||
|
||||
#include <cstdio>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#if CV_MAJOR_VERSION >= 4
|
||||
#include <opencv2/videoio.hpp>
|
||||
#endif
|
||||
|
||||
using cv::Mat;
|
||||
using cv::VideoCapture;
|
||||
@@ -78,8 +81,13 @@ bool StreamHandlerOpenCV::openHandler( ClpString strFilename, bool bInput )
|
||||
m_strFormatName = "DEV";
|
||||
m_strCodecName = "Raw Video";
|
||||
pcVideoCapture = new VideoCapture( iDeviceId );
|
||||
#if CV_MAJOR_VERSION >= 4
|
||||
m_uiWidth = pcVideoCapture->get( cv::CAP_PROP_FRAME_WIDTH );
|
||||
m_uiHeight = pcVideoCapture->get( cv::CAP_PROP_FRAME_HEIGHT );
|
||||
#else
|
||||
m_uiWidth = pcVideoCapture->get( CV_CAP_PROP_FRAME_WIDTH );
|
||||
m_uiHeight = pcVideoCapture->get( CV_CAP_PROP_FRAME_HEIGHT );
|
||||
#endif
|
||||
m_dFrameRate = 25;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -58,7 +58,7 @@ bool DisparityStereoSGBM::create( std::vector<CalypFrame*> apcFrameList )
|
||||
}
|
||||
m_uiNumberOfDisparities = ( ( apcFrameList[0]->getWidth() / 8 ) + 15 ) & -16;
|
||||
int cn = apcFrameList[0]->getNumberChannels();
|
||||
#if( CV_MAJOR_VERSION == 3 )
|
||||
#if( CV_MAJOR_VERSION >= 3 )
|
||||
m_cStereoMatch = cv::StereoSGBM::create( 0, 16, m_uiBlockSize );
|
||||
m_cStereoMatch->setPreFilterCap( 63 );
|
||||
|
||||
@@ -99,7 +99,7 @@ CalypFrame* DisparityStereoSGBM::process( std::vector<CalypFrame*> apcFrameList
|
||||
return m_pcDisparityFrame;
|
||||
}
|
||||
cv::Mat disparityImage, disparityImage8;
|
||||
#if( CV_MAJOR_VERSION == 3 )
|
||||
#if( CV_MAJOR_VERSION >= 3 )
|
||||
m_cStereoMatch->compute( leftImage, rightImage, disparityImage );
|
||||
#else
|
||||
m_cStereoMatch( leftImage, rightImage, disparityImage );
|
||||
|
||||
@@ -60,7 +60,7 @@ private:
|
||||
bool m_bUseHH;
|
||||
int m_uiNumberOfDisparities;
|
||||
unsigned int m_uiBlockSize;
|
||||
#if( CV_MAJOR_VERSION == 3 )
|
||||
#if( CV_MAJOR_VERSION >= 3 )
|
||||
cv::Ptr<cv::StereoSGBM> m_cStereoMatch;
|
||||
#else
|
||||
cv::StereoSGBM m_cStereoMatch;
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
*/
|
||||
|
||||
#include "MeasureOpticalFlowDualTVL1.h"
|
||||
#if CV_MAJOR_VERSION >= 4
|
||||
#include <opencv2/optflow.hpp>
|
||||
#endif
|
||||
|
||||
using cv::Mat;
|
||||
using cv::Mat_;
|
||||
@@ -61,7 +64,11 @@ bool MeasureOpticalFlowDualTVL1::create( std::vector<CalypFrame*> apcFrameList )
|
||||
return false;
|
||||
|
||||
m_iStep = 16;
|
||||
#if CV_MAJOR_VERSION >= 4
|
||||
m_cTvl1 = cv::optflow::createOptFlow_DualTVL1();
|
||||
#else
|
||||
m_cTvl1 = cv::createOptFlow_DualTVL1();
|
||||
#endif
|
||||
m_pcOutputFrame = new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), CLP_GRAY );
|
||||
|
||||
return true;
|
||||
|
||||
@@ -166,7 +166,11 @@ bool OpticalFlowDualTVL1::create( std::vector<CalypFrame*> apcFrameList )
|
||||
bool bRet = commonCreate( apcFrameList );
|
||||
if( !bRet )
|
||||
return bRet;
|
||||
#if CV_MAJOR_VERSION >= 4
|
||||
m_cOpticalFlow = cv::optflow::createOptFlow_DualTVL1();
|
||||
#else
|
||||
m_cOpticalFlow = cv::createOptFlow_DualTVL1();
|
||||
#endif
|
||||
return bRet;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user