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

Commit 47d3e45

Browse files
committed
Remove cnn segmentation component processing for Android platform (not supported)
1 parent a6454db commit 47d3e45

5 files changed

+37
-17
lines changed

SolARModuleOpenCV.pri

+6-14
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ HEADERS += $$PWD/interfaces/SolAR2D3DcorrespondencesFinderOpencv.h \
1919
$$PWD/interfaces/SolARDescriptorsExtractorSIFTOpencv.h \
2020
$$PWD/interfaces/SolARDescriptorsExtractorFromImageOpencv.h \
2121
$$PWD/interfaces/SolARDeviceDataLoader.h \
22+
$$PWD/interfaces/SolARFCNSegmentationOpencv.h \
2223
$$PWD/interfaces/SolARFiducialMarkerLoaderOpencv.h \
2324
$$PWD/interfaces/SolARQRCodeLoaderOpencv.h \
2425
$$PWD/interfaces/SolARQRCodePoseEstimatorOpencv.h \
@@ -43,6 +44,7 @@ HEADERS += $$PWD/interfaces/SolAR2D3DcorrespondencesFinderOpencv.h \
4344
$$PWD/interfaces/SolARKeypointDetectorRegionOpencv.h \
4445
$$PWD/interfaces/SolARMapFusionOpencv.h \
4546
$$PWD/interfaces/SolARImageMarkerLoaderOpencv.h \
47+
$$PWD/interfaces/SolARMaskOverlayOpencv.h \
4648
$$PWD/interfaces/SolARMatchesOverlayOpencv.h \
4749
$$PWD/interfaces/SolARModuleOpencv_traits.h \
4850
$$PWD/interfaces/SolAROpencvAPI.h \
@@ -63,7 +65,7 @@ HEADERS += $$PWD/interfaces/SolAR2D3DcorrespondencesFinderOpencv.h \
6365
$$PWD/interfaces/SolARUnprojectPlanarPointsOpencv.h \
6466
$$PWD/interfaces/SolARSVDTriangulationOpencv.h \
6567
$$PWD/interfaces/SolARVideoAsCameraOpencv.h \
66-
$$PWD/interfaces/SolARMaskOverlayOpencv.h \
68+
$$PWD/interfaces/SolARYOLACTSegmentationOpencv.h \
6769
$$PWD/interfaces/features2d_akaze2.hpp \
6870
$$PWD/src/AKAZE2/AKAZEConfig.h \
6971
$$PWD/src/AKAZE2/AKAZEFeatures.h \
@@ -98,6 +100,7 @@ SOURCES += $$PWD/src/AKAZE2/akaze.cpp \
98100
$$PWD/src/SolARDescriptorsExtractorSIFTOpencv.cpp \
99101
$$PWD/src/SolARDescriptorsExtractorFromImageOpencv.cpp \
100102
$$PWD/src/SolARDeviceDataLoader.cpp \
103+
$$PWD/src/SolARFCNSegmentationOpencv.cpp \
101104
$$PWD/src/SolARFiducialMarkerLoaderOpencv.cpp \
102105
$$PWD/src/SolARQRCodeLoaderOpencv.cpp \
103106
$$PWD/src/SolARQRCodePoseEstimatorOpencv.cpp \
@@ -121,6 +124,7 @@ SOURCES += $$PWD/src/AKAZE2/akaze.cpp \
121124
$$PWD/src/SolARKeypointDetectorOpencv.cpp \
122125
$$PWD/src/SolARKeypointDetectorRegionOpencv.cpp \
123126
$$PWD/src/SolARMapFusionOpencv.cpp \
127+
$$PWD/src/SolARMaskOverlayOpencv.cpp \
124128
$$PWD/src/SolARMatchesOverlayOpencv.cpp \
125129
$$PWD/src/SolARModuleOpencv.cpp \
126130
$$PWD/src/SolAROpenCVHelper.cpp \
@@ -140,18 +144,6 @@ SOURCES += $$PWD/src/AKAZE2/akaze.cpp \
140144
$$PWD/src/SolARUndistortPointsOpencv.cpp \
141145
$$PWD/src/SolARUnprojectplanarPointsOpencv.cpp \
142146
$$PWD/src/SolARVideoAsCameraOpencv.cpp \
143-
$$PWD/src/SolARMaskOverlayOpencv.cpp
144-
145-
!android {
146-
147-
HEADERS += \
148-
$$PWD/interfaces/SolARYOLACTSegmentationOpencv.h \
149-
$$PWD/interfaces/SolARFCNSegmentationOpencv.h
150-
151-
SOURCES += \
152-
$$PWD/src/SolARYOLACTSegmentationOpencv.cpp \
153-
$$PWD/src/SolARFCNSegmentationOpencv.cpp
154-
155-
}
147+
$$PWD/src/SolARYOLACTSegmentationOpencv.cpp
156148

157149

interfaces/SolARFCNSegmentationOpencv.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
#include "SolAROpencvAPI.h"
2222
#include "api/segm/ISemanticSegmentation.h"
2323
#include <opencv2/opencv.hpp>
24+
#ifndef __ANDROID__
2425
#include <opencv2/dnn.hpp>
2526
#include <opencv2/dnn/shape_utils.hpp>
27+
#endif
2628

2729
namespace SolAR {
2830
namespace MODULES {
@@ -63,8 +65,10 @@ class SOLAROPENCV_EXPORT_API SolARFCNSegmentationOpencv : public org::bcom::xpcf
6365
private:
6466
std::string m_modelFile = "";
6567
std::string m_modelConfig = "";
66-
cv::dnn::Net m_net;
67-
float m_scale;
68+
#ifndef __ANDROID__
69+
cv::dnn::Net m_net;
70+
#endif
71+
float m_scale;
6872
cv::Scalar m_mean;
6973
cv::Size m_inputSize;
7074
std::vector<std::string> m_outputLayerNames;

interfaces/SolARYOLACTSegmentationOpencv.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
#include "SolAROpencvAPI.h"
2222
#include "api/segm/IInstanceSegmentation.h"
2323
#include <opencv2/opencv.hpp>
24+
#ifndef __ANDROID__
2425
#include <opencv2/dnn.hpp>
2526
#include <opencv2/dnn/shape_utils.hpp>
27+
#endif
2628

2729
namespace SolAR {
2830
namespace MODULES {
@@ -78,7 +80,9 @@ class SOLAROPENCV_EXPORT_API SolARYOLACTSegmentationOpencv : public org::bcom::x
7880
float m_maskThresh = 0.f;
7981
std::string m_modelFile = "";
8082
std::string m_modelConfig = "";
81-
cv::dnn::Net m_net;
83+
#ifndef __ANDROID__
84+
cv::dnn::Net m_net;
85+
#endif
8286
float m_scale;
8387
cv::Scalar m_mean;
8488
cv::Size m_inputSize;

src/SolARFCNSegmentationOpencv.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ SolARFCNSegmentationOpencv::~SolARFCNSegmentationOpencv()
4444

4545
xpcf::XPCFErrorCode SolARFCNSegmentationOpencv::onConfigured()
4646
{
47+
#ifndef __ANDROID__
4748
LOG_DEBUG(" SolARFCNSegmentationOpencv onConfigured");
4849
// read and initialize network
4950
m_net = cv::dnn::readNet(m_modelFile, m_modelConfig);
@@ -62,11 +63,16 @@ xpcf::XPCFErrorCode SolARFCNSegmentationOpencv::onConfigured()
6263
m_inputSize = cv::Size(500, 500);
6364
m_outputLayerNames = { "output" };
6465
return xpcf::XPCFErrorCode::_SUCCESS;
66+
#else
67+
LOG_ERROR ("SolARYOLACTSegemntationOpencv is not avialble for Android");
68+
return xpcf::XPCFErrorCode::_FAIL;
69+
#endif
6570
}
6671

6772
FrameworkReturnCode SolARFCNSegmentationOpencv::segment(const SRef<SolAR::datastructure::Image> image,
6873
SRef<SolAR::datastructure::Image> &mask)
6974
{
75+
#ifndef __ANDROID__
7076
/// convert to opencv image
7177
cv::Mat imageCV;
7278
SolAROpenCVHelper::mapToOpenCV(image, imageCV);
@@ -108,6 +114,10 @@ FrameworkReturnCode SolARFCNSegmentationOpencv::segment(const SRef<SolAR::datast
108114
cv::resize(maxClass, maskCV, imageCV.size(), 0.0, 0.0, cv::INTER_NEAREST);
109115
SolAROpenCVHelper::convertToSolar(maskCV, mask);
110116
return FrameworkReturnCode::_SUCCESS;
117+
#else
118+
LOG_ERROR ("SolARYOLACTSegemntationOpencv is not avialble for Android");
119+
return FrameworkReturnCode::_ERROR_;
120+
#endif
111121
}
112122

113123
}

src/SolARYOLACTSegmentationOpencv.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ SolARYOLACTSegmentationOpencv::~SolARYOLACTSegmentationOpencv()
4646

4747
xpcf::XPCFErrorCode SolARYOLACTSegmentationOpencv::onConfigured()
4848
{
49+
#ifndef __ANDROID__
4950
LOG_DEBUG(" SolARYOLACTSegmentationOpencv onConfigured");
5051
// read and initialize network
5152
m_net = cv::dnn::readNet(m_modelFile, m_modelConfig);
@@ -66,6 +67,10 @@ xpcf::XPCFErrorCode SolARYOLACTSegmentationOpencv::onConfigured()
6667
m_nbChannels = 32;
6768
m_outputLayerNames = { "conf", "mask", "proto", "boxes" };
6869
return xpcf::XPCFErrorCode::_SUCCESS;
70+
#else
71+
LOG_ERROR ("SolARYOLACTSegemntationOpencv is not avialble for Android");
72+
return xpcf::XPCFErrorCode::_FAIL;
73+
#endif
6974
}
7075

7176
bool checkJaccard(const Rectanglei& box, const uint32_t& id, const std::vector<Rectanglei>& boxes, const std::vector<uint32_t> &ids)
@@ -93,6 +98,7 @@ FrameworkReturnCode SolARYOLACTSegmentationOpencv::segment(const SRef<SolAR::dat
9398
std::vector<uint32_t> &classIds,
9499
std::vector<float> &scores)
95100
{
101+
#ifndef __ANDROID__
96102
boxes.clear();
97103
masks.clear();
98104
classIds.clear();
@@ -177,6 +183,10 @@ FrameworkReturnCode SolARYOLACTSegmentationOpencv::segment(const SRef<SolAR::dat
177183
}
178184
LOG_DEBUG("Number of output detections: {}", boxes.size());
179185
return FrameworkReturnCode::_SUCCESS;
186+
#else
187+
LOG_ERROR ("SolARYOLACTSegemntationOpencv is not avialble for Android");
188+
return FrameworkReturnCode::_ERROR_;
189+
#endif
180190
}
181191

182192
}

0 commit comments

Comments
 (0)