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