资源简介
matlab2015(2016可用)利用mex编译opencv249中的warpPerspective函数,简化和加速roi的提取。http://blog.csdn.net/sunflower_boy/article/details/51137605
代码片段和文件信息
#include “mex.h“
#include “matrix.h“
#include “math.h“
#include “opencv2/opencv.hpp“
using namespace cv;
void mexFunction(int nlhs mxArray *plhs[] int nrhs const mxArray *prhs[])
{
int N = mxGetN(prhs[0]);//number of cols
int M = mxGetM(prhs[0]);//number of rows
char* srcPtr = (char*)mxGetData(prhs[0]);
double* pointPtr = mxGetPr(prhs[1]);
double dstSizeW = 0;
double dstSizeH = 0;
double x1 = *(pointPtr+0);
double x2 = *(pointPtr+1);
double x3 = *(pointPtr+2);
double x4 = *(pointPtr+3);
double y1 = *(pointPtr+4);
double y2 = *(pointPtr+5);
double y3 = *(pointPtr+6);
double y4 = *(pointPtr+7);
Point2f src_vertices[4];//Point2f(xy)
src_vertices[0] = Point2f(x1y1);
src_vertices[1] = Point2f(x2y2);
src_vertices[2] = Point2f(x3y3);
src_vertices[3] = Point2f(x4y4);
mexPrintf(“src_Vertice: xy\n“);
mexPrintf(“%f%f;\n“src_vertices[0].xsrc_vertices[0].y);
mexPrintf(“%f%f;\n“src_vertices[1].xsrc_vertices[1].y);
mexPrintf(“%f%f;\n“src_vertices[2].xsrc_vertices[2].y);
mexPrintf(“%f%f;\n“src_vertices[3].xsrc_vertices[3].y);
Point2f dst_vertices[4];
if(nrhs==3)
{
double* dstPointPtr = mxGetPr(prhs[2]);
dst_vertices[0] = Point2f(*(dstPointPtr+0)*(dstPointPtr+4));
dst_vertices[1] = Point2f(*(dstPointPtr+1)*(dstPointPtr+5));
dst_vertices[2] = Point2f(*(dstPointPtr+2)*(dstPointPtr+6));
dst_vertices[3] = Point2f(*(dstPointPtr+3)*(dstPointPtr+7));
}
else
{
mexPrintf(“Auto Dst Point:\n“);
double dstSize1 = sqrt(pow((x2-x1)2)+pow((y2-y1)2));
double dstSize2 = sqrt(pow((x3-x2)2)+pow((y3-y2)2));
if(dstSize1 > dstSize2)
{
dstSizeW = dstSize1;
dstSizeH = dstSize2;
dst_vertices[0] = Point2f(dstSizeW0);
dst_vertices[1] = Point2f(00);
dst_vertices[2] = Point2f(0dstSizeH);
dst_vertices[3] = Point2f(dstSizeWdstSizeH);
}
else
{
dstSizeW = dstSize2;
dstSizeH = dstSize1;
dst_vertices[0] = Point2f(00);
dst_vertices[1] = Point2f(0dstSizeH);
dst_vertices[2] = Point2f(dstSizeWdstSizeH);
dst_vertices[3] = Point2f(dstSizeW0);
}
mexPrintf(“dstSizeWdstSizeH:%f%f\n“dstSizeWdstSizeH);
mexPrintf(“dst_Vertice: xy\n“);
mexPrintf(“%f%f;\n“dst_vertices[0].xdst_vertices[0].y);
mexPrintf(“%f%f;\n“dst_vertices[1].xdst_vertices[1].y);
mexPrintf(“%f%f;\n“dst_vertices[2].xdst_vertices[2].y);
mexPrintf(“%f%f;\n“dst_vertices[3].xdst_vertices[3].y);
}
//Acturally it should be Mat(rowscols...);
//but Matlab Array is store by cols
Mat src = Mat(NMCV_8UC1srcPtr);
//transposition because Matlab Array store by col
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3536 2016-04-12 21:50 cv_rotateRect.cpp
文件 12800 2016-04-12 21:50 cv_rotateRect.mexw64
----------- --------- ---------- ----- ----
16336 2
- 上一篇:JPEG编解码程序
- 下一篇:Matlab-PDE工具箱有限元法求解偏微分方程
相关资源
- matlab和c程序混编提示找不到mex.h
- MATLAB R2017a 支持Microsoft Visual Studio 2
- MATLAB不识别VS缺失的配置文件支持的最
- 64位MATLAB添加VS2017支持mbuild -setup未找
- VIBE-MEX--
- matlab中jpeg tool box(tbx)编译好的mex
- MatConvNet CPU版 编译文件
- Matlab2015a未找到支持的编译器或 SDK
- 随机森林工具包RF_MexStandalone-v0.02-pr
- MATLAB mexopts配置文件.zip
- matlab2011b找不到编译器vs2012的问题
-
msvc2017.xm
l和msvcpp2017 - 随机森林工具包randomforest-matlab(基于
- matlab2013(a) mex -setup 找不到visual s
- RF_MexStandalone-v0[1].02
- Windows-Precompiled-RF_MexStandalone-v0.02-随机
- SLIC超像素风格slicmex.c修改后的文件,
- nvmex_tool.zip
评论
共有 条评论