|
|
@ -5,12 +5,11 @@ |
|
|
|
#include "precomp.hpp" |
|
|
|
#include "precomp.hpp" |
|
|
|
#include "opencv2/imgproc.hpp" |
|
|
|
#include "opencv2/imgproc.hpp" |
|
|
|
#include "opencv2/core.hpp" |
|
|
|
#include "opencv2/core.hpp" |
|
|
|
|
|
|
|
#include "opencv2/dnn.hpp" |
|
|
|
|
|
|
|
|
|
|
|
#include <fstream> |
|
|
|
#include <fstream> |
|
|
|
#include <algorithm> |
|
|
|
#include <algorithm> |
|
|
|
|
|
|
|
|
|
|
|
#include "opencv2/dnn.hpp" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using namespace cv::dnn; |
|
|
|
using namespace cv::dnn; |
|
|
|
|
|
|
|
|
|
|
|
namespace cv |
|
|
|
namespace cv |
|
|
@ -75,20 +74,22 @@ public: |
|
|
|
void detect(InputArray inputImage_, std::vector<Rect>& Bbox, std::vector<float>& confidence) |
|
|
|
void detect(InputArray inputImage_, std::vector<Rect>& Bbox, std::vector<float>& confidence) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CV_Assert(inputImage_.channels() == inputChannelCount_); |
|
|
|
CV_Assert(inputImage_.channels() == inputChannelCount_); |
|
|
|
Mat inputImage = inputImage_.getMat().clone(); |
|
|
|
Size inputSize = inputImage_.getMat().size(); |
|
|
|
Bbox.resize(0); |
|
|
|
Bbox.resize(0); |
|
|
|
confidence.resize(0); |
|
|
|
confidence.resize(0); |
|
|
|
|
|
|
|
|
|
|
|
for(size_t i = 0; i < sizes_.size(); i++) |
|
|
|
for(size_t i = 0; i < sizes_.size(); i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Size inputGeometry = sizes_[i]; |
|
|
|
Size inputGeometry = sizes_[i]; |
|
|
|
|
|
|
|
Mat inputImage = inputImage_.getMat().clone(); |
|
|
|
|
|
|
|
resize(inputImage, inputImage, inputGeometry); |
|
|
|
net_.setInput(blobFromImage(inputImage, 1, inputGeometry, Scalar(123, 117, 104)), "data"); |
|
|
|
net_.setInput(blobFromImage(inputImage, 1, inputGeometry, Scalar(123, 117, 104)), "data"); |
|
|
|
Mat outputNet = net_.forward(); |
|
|
|
Mat outputNet = net_.forward(); |
|
|
|
int nbrTextBoxes = outputNet.size[2]; |
|
|
|
int nbrTextBoxes = outputNet.size[2]; |
|
|
|
int nCol = outputNet.size[3]; |
|
|
|
int nCol = outputNet.size[3]; |
|
|
|
int outputChannelCount = outputNet.size[1]; |
|
|
|
int outputChannelCount = outputNet.size[1]; |
|
|
|
CV_Assert(outputChannelCount == 1); |
|
|
|
CV_Assert(outputChannelCount == 1); |
|
|
|
getOutputs((float*)(outputNet.data), nbrTextBoxes, nCol, Bbox, confidence, inputImage.size()); |
|
|
|
getOutputs((float*)(outputNet.data), nbrTextBoxes, nCol, Bbox, confidence, inputSize); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|