Fix option errors and add dummy module

This commit is contained in:
jfmcarreira committed 2021-10-24 22:18:25 +01:00
1 parent acc9d8ea98
commit 90a5c32bb6
11 files changed
+336 -71

No files matched your search

+6 -10
View File
@@ -13,7 +13,9 @@ SET(Calyp_Mod_SRCS CalypModulesFactory.cpp)
#
# Modules List
#
# SET( MODULE_LOCATION "")
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
ADD_MODULE_USE_OPENCV(DummyOpencvModule "DummyOpencvModule" VERSION 3.1.0 MODULES core)
ENDIF()
ADD_MODULE(FilterComponentLuma "FilterComponent")
ADD_MODULE(FilterComponentChromaU "FilterComponent")
@@ -34,6 +36,8 @@ ADD_MODULE(WeightedPSNR "WeightedPSNR")
ADD_MODULE(HEVCIntraPrediction "HEVCIntraPrediction")
ADD_MODULE(OptimiseDisplay "OptimiseDisplay")
ADD_MODULE_USE_OPENCV(ShapeDetection "ShapeDetection" VERSION 3.1.0 MODULES core)
ADD_MODULE_USE_OPENCV(
MeasureOpticalFlowDualTVL1
"MeasureOpticalFlowDualTVL1"
@@ -85,15 +89,7 @@ ADD_MODULE_USE_OPENCV(
imgproc
photo
)
# ADD_MODULE_USE_OPENCV(
# ThreeSixtyDynamicDownsampling
# "ThreeSixtyDynamicDownsampling"
# VERSION
# 3.1.0
# MODULES
# core
# imgproc
# )
# ADD_MODULE_USE_OPENCV( ThreeSixtyDynamicDownsampling "ThreeSixtyDynamicDownsampling" VERSION 3.1.0 MODULES core imgproc )
ADD_MODULE_USE_OPENCV(
ThreeSixtyNxN
"ThreeSixtyNxN"
+60
View File
@@ -0,0 +1,60 @@
/* This file is a part of Calyp project
* Copyright (C) 2014-2021 by Joao Carreira (jfmcarreira@gmail.com)
* Luis Lucas (luisfrlucas@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/**
* \file DummyOpencvModule.cpp
*/
#include "DummyOpencvModule.h"
#include <cstdlib>
//#include <opencv2/video/video.hpp>
using cv::Mat;
using cv::Ptr;
using namespace cv::saliency;
DummyOpencvModule::DummyOpencvModule()
{
/* Module Definition */
m_iModuleAPI = CLP_MODULE_API_2;
m_iModuleType = ClpModuleType::FrameProcessing;
m_pchModuleCategory = "Dummy";
m_pchModuleName = "DummyOpencvModule";
m_pchModuleLongName = "Shape detection";
m_pchModuleTooltip = "Detect shapes in images";
m_uiNumberOfFrames = 1;
m_uiModuleRequirements = ClpModuleFeature::NewWindow | ClpModuleFeature::Options;
m_bConvertToGray = false;
m_cModuleOptions.addOptions()( "Convert to Gray", m_bConvertToGray, "Measure a binary saliency map [false]" );
}
cv::Mat* DummyOpencvModule::create_using_opencv( const std::vector<Mat>& apcMatList )
{
m_resultImage = std::make_unique<Mat>( apcMatList[0].rows, apcMatList[0].cols, CV_8UC1 );
return m_resultImage.get();
}
Mat* DummyOpencvModule::process_using_opencv( const std::vector<Mat>& apcMatList )
{
apcMatList[0].copyTo( *m_resultImage );
return m_resultImage.get();
}
+50
View File
@@ -0,0 +1,50 @@
/* This file is a part of Calyp project
* Copyright (C) 2014-2021 by Joao Carreira (jfmcarreira@gmail.com)
* Luis Lucas (luisfrlucas@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/**
* \file DummyOpencvModule.h
* \brief Modules to detect curves shape
*/
#ifndef __DUMMYOPENCVMODULE_H__
#define __DUMMYOPENCVMODULE_H__
// CalypLib
#include "lib/CalypModuleIf.h"
// OpenCV
#include <opencv2/core/core.hpp>
#include <opencv2/saliency.hpp>
class DummyOpencvModule : public CalypOpenCVModuleIf,
public CalypModuleInstace<DummyOpencvModule>
{
using Mat = cv::Mat;
private:
std::unique_ptr<Mat> m_resultImage;
public:
DummyOpencvModule();
virtual ~DummyOpencvModule() = default;
Mat* create_using_opencv( const std::vector<Mat>& apcMatList ) override;
Mat* process_using_opencv( const std::vector<Mat>& apcMatList ) override;
};
#endif // __DUMMYOPENCVMODULE_H__
+78
View File
@@ -0,0 +1,78 @@
/* This file is a part of Calyp project
* Copyright (C) 2014-2021 by Joao Carreira (jfmcarreira@gmail.com)
* Luis Lucas (luisfrlucas@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/**
* \file ShapeDetection.cpp
*/
#include "ShapeDetection.h"
#include <cstdlib>
//#include <opencv2/video/video.hpp>
using cv::Mat;
using cv::Ptr;
using namespace cv::saliency;
ShapeDetection::ShapeDetection()
: m_rng( 12345 )
{
/* Module Definition */
m_iModuleAPI = CLP_MODULE_API_2;
m_iModuleType = ClpModuleType::FrameProcessing;
m_pchModuleCategory = "Utilities";
m_uiNumberOfFrames = 1;
m_uiModuleRequirements = ClpModuleFeature::NewWindow;
m_bConvertToGray = false;
/* Module Definition */
m_pchModuleName = "ShapeDetection";
m_pchModuleLongName = "Shape detection";
m_pchModuleTooltip = "Detect shapes in images";
}
cv::Mat* ShapeDetection::create_using_opencv( const std::vector<Mat>& apcMatList )
{
m_resultImage = std::make_unique<Mat>( apcMatList[0].rows, apcMatList[0].cols, CV_8UC1 );
return m_resultImage.get();
}
Mat* ShapeDetection::process_using_opencv( const std::vector<Mat>& apcMatList )
{
Mat canny_output;
cv::Canny( apcMatList[0], canny_output, 30, 100 );
std::vector<std::vector<cv::Point> > contours;
findContours( canny_output, contours, cv::RETR_TREE, cv::CHAIN_APPROX_SIMPLE );
std::vector<std::vector<cv::Point> > hull( contours.size() );
for( size_t i = 0; i < contours.size(); i++ )
{
cv::convexHull( contours[i], hull[i] );
}
for( size_t i = 0; i < contours.size(); i++ )
{
cv::Scalar color = cv::Scalar( m_rng.uniform( 0, 256 ), m_rng.uniform( 0, 256 ), m_rng.uniform( 0, 256 ) );
cv::drawContours( *m_resultImage, contours, (int)i, color );
cv::drawContours( *m_resultImage, hull, (int)i, color );
}
return m_resultImage.get();
}
+52
View File
@@ -0,0 +1,52 @@
/* This file is a part of Calyp project
* Copyright (C) 2014-2021 by Joao Carreira (jfmcarreira@gmail.com)
* Luis Lucas (luisfrlucas@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/**
* \file ShapeDetection.h
* \brief Modules to detect curves shape
*/
#ifndef __SHAPEDETECTION_H__
#define __SHAPEDETECTION_H__
// CalypLib
#include "lib/CalypModuleIf.h"
// OpenCV
#include <opencv2/core/core.hpp>
#include <opencv2/saliency.hpp>
class ShapeDetection : public CalypOpenCVModuleIf,
public CalypModuleInstace<ShapeDetection>
{
using Mat = cv::Mat;
private:
bool m_bBinaryMap;
std::unique_ptr<Mat> m_resultImage;
cv::RNG m_rng;
public:
ShapeDetection();
virtual ~ShapeDetection() = default;
Mat* create_using_opencv( const std::vector<Mat>& apcMatList ) override;
Mat* process_using_opencv( const std::vector<Mat>& apcMatList ) override;
};
#endif // __SHAPEDETECTION_H__