opencv hand openpose

这篇具有很好参考价值的文章主要介绍了opencv hand openpose。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

使用opencv c++ 来调用caffemodel

使用opencv 得dnn 模块调用 caffemodel得程序,图片自己输入就行,不做过多得解释,看代码清单。
opencv hand openpose,c++,opencv和AI,opencv,人工智能,计算机视觉

opencv hand openpose,c++,opencv和AI,opencv,人工智能,计算机视觉

定义手指关节点

const int POSE_PAIRS[20][2] =
{
{0,1}, {1,2}, {2,3}, {3,4}, // thumb
{0,5}, {5,6}, {6,7}, {7,8}, // index
{0,9}, {9,10}, {10,11}, {11,12}, // middle
{0,13}, {13,14}, {14,15}, {15,16}, // ring
{0,17}, {17,18}, {18,19}, {19,20} // small
};

string protoFile = “hand/pose_deploy.prototxt”;
string weightsFile = “hand/pose_iter_102000.caffemodel”;

int nPoints = 22;文章来源地址https://www.toymoban.com/news/detail-615350.html

代码清单

#include <opencv2/dnn.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>

using namespace std;
using namespace cv;
using namespace cv::dnn;
#ifdef _DEBUG
#pragma comment(lib,"opencv_world455d.lib")
#else
#pragma comment(lib,"opencv_world455.lib")
#endif

const int POSE_PAIRS[20][2] =
{
	{0,1}, {1,2}, {2,3}, {3,4},         // thumb
	{0,5}, {5,6}, {6,7}, {7,8},         // index
	{0,9}, {9,10}, {10,11}, {11,12},    // middle
	{0,13}, {13,14}, {14,15}, {15,16},  // ring
	{0,17}, {17,18}, {18,19}, {19,20}   // small
};

string protoFile = "hand/pose_deploy.prototxt";
string weightsFile = "hand/pose_iter_102000.caffemodel";

int nPoints = 22;

int main(int argc, char **argv)
{
	string imageFile = "qianbo2.jpg";
	// Take arguments from commmand line
	if (argc == 2)
	{
		imageFile = argv[1];
	}

	float thresh = 0.01;

	Mat frame = imread(imageFile);
	Mat frameCopy = frame.clone();
	int frameWidth = frame.cols;
	int frameHeight = frame.rows;

	float aspect_ratio = frameWidth / (float)frameHeight;
	int inHeight = 368;
	int inWidth = (int(aspect_ratio*inHeight) * 8) / 8;

	cout << "inWidth = " << inWidth << " ; inHeight = " << inHeight << endl;

	double t = (double)cv::getTickCount();
	Net net = readNetFromCaffe(protoFile, weightsFile);

	Mat inpBlob = blobFromImage(frame, 1.0 / 255, Size(inWidth, inHeight), Scalar(0, 0, 0), false, false);

	net.setInput(inpBlob);

	Mat output = net.forward();

	int H = output.size[2];
	int W = output.size[3];

	// find the position of the body parts
	vector<Point> points(nPoints);
	for (int n = 0; n < nPoints; n++)
	{
		// Probability map of corresponding body's part.
		Mat probMap(H, W, CV_32F, output.ptr(0, n));
		resize(probMap, probMap, Size(frameWidth, frameHeight));

		Point maxLoc;
		double prob;
		minMaxLoc(probMap, 0, &prob, 0, &maxLoc);
		if (prob > thresh)
		{
			circle(frameCopy, cv::Point((int)maxLoc.x, (int)maxLoc.y), 8, Scalar(0, 255, 255), -1);
			cv::putText(frameCopy, cv::format("%d", n), cv::Point((int)maxLoc.x, (int)maxLoc.y), cv::FONT_HERSHEY_COMPLEX, 1, cv::Scalar(0, 0, 255), 2);

		}
		points[n] = maxLoc;
	}

	int nPairs = sizeof(POSE_PAIRS) / sizeof(POSE_PAIRS[0]);

	for (int n = 0; n < nPairs; n++)
	{
		// lookup 2 connected body/hand parts
		Point2f partA = points[POSE_PAIRS[n][0]];
		Point2f partB = points[POSE_PAIRS[n][1]];

		if (partA.x <= 0 || partA.y <= 0 || partB.x <= 0 || partB.y <= 0)
			continue;

		line(frame, partA, partB, Scalar(0, 255, 255), 8);
		circle(frame, partA, 8, Scalar(0, 0, 255), -1);
		circle(frame, partB, 8, Scalar(0, 0, 255), -1);
	}

	t = ((double)cv::getTickCount() - t) / cv::getTickFrequency();
	cout << "Time Taken = " << t << endl;
	imshow("Keypoints", frameCopy);
	imshow("Skeleton", frame);
	imwrite("out.jpg", frame);

	waitKey();

	return 0;
}

到了这里,关于opencv hand openpose的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包赞助服务器费用

相关文章

  • AI人工智能开发的5种最佳人工智能编程语言

    今天的AI程序员应该掌握多种语言,因为他们在跨学科的环境中工作,而不是在孤岛中工作。 虽然当前这一代人更喜欢Python,R,Java,Lisp,Prolog,Julia等 ,但前端开发人员必须了解JavaScript,Python和R的机器学习应用程序。一家知名组织的流程自动化首席开发人员了解R,Java,

    2023年04月16日
    浏览(10)
  • 【人工智能】Responsible AI 负责任的人工智能:人工智能安全和隐私的未来 The Future of AI Security and Privacy

    【人工智能】Responsible AI 负责任的人工智能:人工智能安全和隐私的未来 The Future of AI Security and Privacy

      While AI development was mostly in the realm of research, practices such as sharing open datasets, publishing models publicly, and using any compute resources available all helped drive forward the state of the art. AI is now increasingly deployed in production environments in the commercial, healthcare, government, and defense sectors and Intel provides

    2023年04月09日
    浏览(10)
  • 人工智能ai写作系统,ai智能写作机器人

    人工智能ai写作系统,ai智能写作机器人

     人工智能AI大数据深度:基于伪原创算法,采用神经网络算法,在超过1535000篇文章中进行自动学习、聚合算法进行人工智能的创建,内容语义不变,媒体阿里、腾讯、百度均于日前在百家号内容创作者盛典上推出人工智能创作支撑平台创作大脑。 智能助手可以为人类创作者

    2024年02月10日
    浏览(16)
  • 【AI人工智能】从技术角度看,我们离超级人工智能还有多远?

    目录 前言 超级人工智能是什么? 一、计算能力 二、算法支持 三

    2024年02月06日
    浏览(23)
  • AI人工智能简史

    AI人工智能简史

    最近学习AI,顺便整理了一份AI人工智能简史,大家参考: 1951年 第一台神经网络机,称为SNARC; 1956年 达特茅斯学院会议,正式确立了人工智能的研究领域; 1966年 MIT发明ELIZA人机心理治疗对话程序,通过和数据库实现心理咨询; 1980年 CMU为DEC设计的XCON专家系统获得巨

    2023年04月17日
    浏览(11)
  • 人工智能AI简史

    人工智能AI简史

    最近学习AI,顺便整理了一份AI人工智能简史,大家参考: 1951年 第一台神经网络机,称为SNARC; 1956年 达特茅斯学院会议,正式确立了人工智能的研究领域; 1966年 MIT发明ELIZA人机心理治疗对话程序,通过和数据库实现心理咨询; 1980年 CMU为DEC设计的XCON专家系统获得巨

    2023年04月18日
    浏览(24)
  • 【人工智能】AI 人工智能:会给人类未来的工作带来怎样的转变?

    0. 前言 人工智能(AI)将对人类未来的工作产生深刻的影响,这些转变具体可以分为以下几点: 自动化与智能优化 : 人工智能可以实现自动化,从而提高工作效率。许多脑力和体力密集型的任务将不再需要人工完成,劳动力可用于更高级别的任务。 生产力增长 : 随着AI的广泛

    2024年02月08日
    浏览(88)
  • 【人工智能 AI】什么是人工智能? What is Artificial Intelligence

    【人工智能 AI】什么是人工智能? What is Artificial Intelligence

      目录 Introduction to Artificial Intelligence人工智能概论 What is Artificial Intelligence? 什么是人工智能?

    2024年02月10日
    浏览(16)
  • 【大数据&AI人工智能】变革人类社会的第四次工业革命——AI人工智能革命已到来

    【大数据&AI人工智能】变革人类社会的第四次工业革命——AI人工智能革命已到来

    霍金曾留下几句话: 在我的一生中,我见证了很多社会深刻的变化。其中最深刻,同时也是对人类影响与日俱增的变化就是人工智能的崛起。 人工智能的真正风险不是它的恶意,而是它的能力。一个超智能的人工智能在完成目标方面非常出色,如果这些目标与我们的目标不

    2023年04月22日
    浏览(11)
  • 人工智能-OpenCV+Python实现人脸识别(人脸检测)

    在OpenCV中使用Haar特征检测人脸,那么需要使用OpenCV提供的xml文件(级联表)在haarcascades目录下。这张级联表有一个训练好的AdaBoost训练集。首先要采用样本的Haar特征训练分类器,从而得到一个级联的AdaBoost分类器。Haar特征值反映了图像的灰度变化情况。例如:脸部的一些特征

    2024年02月06日
    浏览(50)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包