写一个opencv dnn handpose的c++代码
时间: 2023-03-07 14:10:21 浏览: 89
我可以提供一个简单的OpenCV DNN Handpose C代码示例:
#include <opencv2/dnn.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>using namespace cv;
using namespace cv::dnn;int main( int argc, char** argv )
{
// Load the network
Net net = readNetFromCaffe("handpose_iter_10000.caffemodel", "handpose_deploy.prototxt");
// Read the image
Mat frame = imread("hand.jpg");
// Prepare the blob
Mat blob;
dnn::blobFromImage(frame, blob);
// Set the input
net.setInput(blob);
// Run the forward pass
Mat output = net.forward();
// Get the heatmap
Mat heatmap = output.reshape(1, frame.rows);
// Normalize the heatmap
normalize(heatmap, heatmap, 0, 255, NORM_MINMAX, CV_8U);
// Show the heatmap
imshow("Heatmap", heatmap);
waitKey(0);
return 0;
}