Skip to content
This repository was archived by the owner on Jul 20, 2023. It is now read-only.

Commit c6a55e6

Browse files
author
BCOM\nduong
committed
fix: check image is grey before applying the wallis filter
1 parent 935c7b2 commit c6a55e6

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

interfaces/SolARImageFilterWallisOpencv.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#ifndef INTERFACESSolARImageFilterWallisOpencv_H
1818
#define INTERFACESSolARImageFilterWallisOpencv_H
1919
#include <xpcf/component/ConfigurableBase.h>
20-
20+
#include "interfaces/SolARImageConvertorOpencv.h"
2121
#include "api/image/IImageFilter.h"
2222

2323

@@ -84,8 +84,7 @@ class SolARImageFilterWallisOpencv : public org::bcom::xpcf::ConfigurableBase, v
8484
float m_B = 0.7f;
8585
uint32_t m_windowWidth = 14;
8686
std::string m_denoisingMethod = "None";
87-
88-
87+
SolARImageConvertorOpencv m_convertor;
8988
};
9089

9190

src/SolARImageFilterWallisOpencv.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616

1717
#include "interfaces/SolARImageFilterWallisOpencv.h"
18-
#include "interfaces/SolARImageConvertorOpencv.h"
1918
#include "SolAROpenCVHelper.h"
2019
#include "opencv2/imgproc.hpp"
2120
#include "opencv2/photo.hpp"
@@ -67,10 +66,11 @@ xpcf::XPCFErrorCode SolARImageFilterWallisOpencv::onConfigured()
6766

6867
FrameworkReturnCode SolARImageFilterWallisOpencv::filter(const SRef<SolAR::datastructure::Image> input, SRef<SolAR::datastructure::Image> & output)
6968
{
70-
7169
SRef<datastructure::Image> imageGrey;
72-
SolARImageConvertorOpencv convertor;
73-
convertor.convert(input, imageGrey, datastructure::Image::ImageLayout::LAYOUT_GREY);
70+
if (input->getImageLayout() != datastructure::Image::ImageLayout::LAYOUT_GREY)
71+
m_convertor.convert(input, imageGrey, datastructure::Image::ImageLayout::LAYOUT_GREY);
72+
else
73+
imageGrey = input;
7474

7575
cv::Mat cvImgGrey8U, cvImgFiltered, cvImgSmooth8U, cvImgSmooth64F, cvImgUniform64F, cvImgSum64F, cvImgCount64F, cvImgLocalMean64F, cvImgTemp64F, cvImgTemp2_64F, cvImgS_64F, cvKernel64F;
7676
SolAROpenCVHelper::mapToOpenCV(imageGrey,cvImgGrey8U);

0 commit comments

Comments
 (0)