Last active
March 31, 2021 15:51
-
-
Save berak/1c676b2f9c0ec0f40e70e5fbfe4f62df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "opencv2/opencv.hpp" | |
using namespace cv; | |
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
int IMAGE_SIZE = 513; | |
cv::Mat faceImg= cv::imread("C:/data/persons/unsorted/139539.png"); | |
cv::dnn::Net net = cv::dnn::readNetFromTensorflow("c:/data/dnn/HumanSegm.pb"); | |
cv::Mat blob; | |
cv::Scalar scMean(-123.68/255, -116.779/255, -103.939/255); | |
cv::dnn::blobFromImage(faceImg, blob, 1.0/255.0, cv::Size(IMAGE_SIZE, IMAGE_SIZE), scMean, true); | |
net.setInput(blob); | |
cv::Mat response = net.forward(); | |
Mat ch1(IMAGE_SIZE,IMAGE_SIZE,CV_32F,response.ptr<float>(0,0)); | |
Mat ch2(IMAGE_SIZE,IMAGE_SIZE,CV_32F,response.ptr<float>(0,1)); | |
Mat res; | |
cv::compare(ch1,ch2,res,cv::CMP_LT); | |
imshow("F",faceImg); | |
imshow("C1",ch1); | |
imshow("C2",ch2); | |
imshow("R",res); | |
waitKey(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment