Advertisement
Guest User

Untitled

a guest
Nov 16th, 2017
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <opencv2/dnn.hpp>
  3. #include <opencv2/imgproc.hpp>
  4. #include <opencv2/highgui.hpp>
  5.  
  6. using namespace cv;
  7. using namespace cv::dnn;
  8. using namespace std;
  9.  
  10. void extractDescriptor(Mat img) {
  11.     Net net = readNetFromTensorflow("model-descriptor.pb");
  12.  
  13.     for(string s : net.getLayerNames())
  14.         cout << s << " " << net.getLayerId(s) << endl;
  15.  
  16.     Mat inputBlob = blobFromImage(img);
  17.     inputBlob /= 255.0;
  18.     net.setInput(inputBlob);
  19.     Mat result = net.forward("MatMul");
  20.  
  21.     for(int i=0; i < result.dims; i++)
  22.         cout << result.size[i] << " ";
  23.     cout << endl;
  24. }
  25.  
  26. int main(int argc, char **argv) {
  27.     Mat test = imread(argv[1], IMREAD_GRAYSCALE);
  28.  
  29.     extractDescriptor(test);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement