c_cpp 在openFrameworks中找到单应性

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp 在openFrameworks中找到单应性相关的知识,希望对你有一定的参考价值。

#pragma once
#include "ofxCv.h"

class Homography {
public:
	ofMatrix4x4 getHomography(cv::vector<cv::Point2f> cvSrcPos, cv::vector<cv::Point2f> cvDstPos) {
		ofMatrix4x4 homographyMat;
		cv::Mat homography = cv::findHomography(cvSrcPos, cvDstPos);
		homographyMat.getPtr()[0] = homography.at<double>(0, 0);
		homographyMat.getPtr()[4] = homography.at<double>(0, 1);
		homographyMat.getPtr()[12] = homography.at<double>(0, 2);

		homographyMat.getPtr()[1] = homography.at<double>(1, 0);
		homographyMat.getPtr()[5] = homography.at<double>(1, 1);
		homographyMat.getPtr()[13] = homography.at<double>(1, 2);

		homographyMat.getPtr()[3] = homography.at<double>(2, 0);
		homographyMat.getPtr()[7] = homography.at<double>(2, 1);
		homographyMat.getPtr()[15] = homography.at<double>(2, 2);
		return homographyMat;
	}

	ofMatrix4x4 getHomography(vector<ofVec2f> srcPos, vector<ofVec2f> dstPos) {
		cv::vector<cv::Point2f> cvSrcPos, cvDstPos;
		for (auto p : srcPos) {
			cvSrcPos.push_back(cv::Point2f(p.x, p.y));
		}
		for (auto p : dstPos) {
			cvDstPos.push_back(cv::Point2f(p.x, p.y));
		}
		return getHomography(cvSrcPos, cvDstPos);
	}
};

以上是关于c_cpp 在openFrameworks中找到单应性的主要内容,如果未能解决你的问题,请参考以下文章

c_cpp openFrameworks ofxPBR ofApp文件

c_cpp openFrameworks - 使用ofFmodSoundPlayer从audioPlayer获取原始音频帧

c_cpp openFrameworks内联着色器模板(仅限vert和frag)

c_cpp openFrameworks现代main.cpp(Open GL 4.1)

c_cpp 矢量函数(openFrameworks的Vec2f / 3f / 4f端口)

准备尝试openFrameworks