Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <opencv2/dnn.hpp>
- #include <opencv2/imgproc.hpp>
- #include <opencv2/highgui.hpp>
- using namespace cv;
- using namespace cv::dnn;
- using namespace std;
- void extractDescriptor(Mat img) {
- Net net = readNetFromTensorflow("model-descriptor.pb");
- for(string s : net.getLayerNames())
- cout << s << " " << net.getLayerId(s) << endl;
- Mat inputBlob = blobFromImage(img);
- inputBlob /= 255.0;
- net.setInput(inputBlob);
- Mat result = net.forward("MatMul");
- for(int i=0; i < result.dims; i++)
- cout << result.size[i] << " ";
- cout << endl;
- }
- int main(int argc, char **argv) {
- Mat test = imread(argv[1], IMREAD_GRAYSCALE);
- extractDescriptor(test);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement