vec2d
namespace :
cv::vec2d;
void src2ipm(cv::Mat &srcimage, cv::Mat& uvgrid, cv::Mat& outimage, cv::Mat& coord, cv::Size& sz, double ht, double roll, double pitch, double* camera_param_KK)
{ int height = (int)(ht*1000); //unit-mm.
double fx = camera_param_KK[0];
double fy = camera_param_KK[4];
double cx = camera_param_KK[2];
double cy = camera_param_KK[5]; double c1 = cos(pitch*PI / 180);
double s1 = sin(pitch*PI / 180);
double c2 = cos(roll*PI / 180);
double s2 = sin(roll*PI / 180); double means = cv::mean(srcimage).val[0]; outimage = cv::Mat::zeros(sz.height, sz.width, CV_64FC1);
coord = cv::Mat::zeros(sz.height, sz.width, CV_64FC2);// for (int i = 0; i < sz.height; i++)
{
for (int j = 0; j < sz.width; j++)
{
float ui = uvgrid.at<double>(0, i*sz.width + j);
float vi = uvgrid.at<double>(1, i*sz.width + j);
//cout << "vi: " << vi << endl;
if (ui<0 || ui>1278)
outimage.at<double>(i, j) = means / 255;
else
{
int x1 = (int)ui, x2 = (int)(ui + 1);
int y1 = (int)vi, y2 = (int)(vi + 1);
float x = ui - (float)x1;
float y = vi - (float)y1; double val = srcimage.at<uchar>(y1, x1)*(1 - x)*(1 - y) +
srcimage.at<uchar>(y1, x2)*x*(1 - y) +
srcimage.at<uchar>(y2, x1)*(1 - x)*y +
srcimage.at<uchar>(y1, x1)* x* y;
outimage.at<double>(i, j) = val/255;
//
coord.at<cv::Vec2d>(i, j)[1] =
height*(fy*s1 + cy*c1 - y1*c1) / (fy*c1 - cy*s1 + y1*s1)*(1 - y) +
height*(fy*s1 + cy*c1 - y2*c1) / (fy*c1 - cy*s1 + y2*s1)*y;
double y_w = coord.at<cv::Vec2d>(i, j)[1];
coord.at<cv::Vec2d>(i, j)[0] = (s1*y_w + height*c1)*(cx - x1) / fx; //Vec2d
}
}
}
outimage = outimage*255;
//cout << "coordinate.rows: " << coordinate_.rows << "--- coordinate.cols: " << coordinate_.cols << endl; //imshow("ipm", outimage);
//cv::waitKey(0);
//imwrite("./ipm.png", outimage);
}
cv::Mat temp = cv::Mat::ones(3, uv.cols, CV_64FC1);
void xyp2ipmp(cv::Mat& xyp, cv::Mat& ipmp, cv::Mat& xylim, Size sz){
//xylimist_[0]-latteral/xylimist_[1]-longitudinal...
//ipmp-row0-cols-latteral/ipmp-row1-rows-longitudinal...
std::cout << "start probp2ipmp: " << std::endl;
double xmin = 0, xmax = 0, ymin = 0, ymax = 0;
minMaxLoc(xylim.row(0), &xmin, &xmax);
minMaxLoc(xylim.row(1), &ymin, &ymax);
double stepcol = (xmax - xmin) / sz.width;
double steprow = (ymax - ymin) / sz.height;
cv::Mat tempx = cv::Mat::ones(1, xyp.cols, CV_64FC1) * xmin;
cv::Mat tempy = cv::Mat::ones(1, xyp.cols, CV_64FC1) * ymax;
ipmp = cv::Mat::zeros(2, xyp.cols, CV_8UC1);
ipmp.rowRange(0, 1) = ( xyp.rowRange(0, 1) - tempx ) / stepcol;
ipmp.rowRange(1, 2) = ( tempy - xyp.rowRange(1, 2) ) / steprow;
}
save image:
char output_path[100];
sprintf(output_path,"./ipmp/00000%05d.png",cnt);
cv::imwrite(output_path, ipm3);
vec2d的更多相关文章
- [LeetCode] Flatten 2D Vector 压平二维向量
Implement an iterator to flatten a 2d vector. For example,Given 2d vector = [ [1,2], [3], [4,5,6] ] ...
- Package gp in the OpenCASCADE
Package gp in the OpenCASCADE eryar@163.com China 一.简介 Introduction to Package gp gp是几何处理程序包(Geometr ...
- C++ STL,list vector区别
顺序性容器: 向量 vector : 是一个线性顺序结构.相当于数组,但其大小可以不预先指定,并且自动扩展.它可以像数组一样被操作,由于它的特性我们完全可以将vector 看作动态数组.在创建一个 ...
- Flatten 2D Vector
Implement an iterator to flatten a 2d vector. For example, Given 2d vector = [ [1,2], [3], [4,5,6] ] ...
- LeetCode Flatten 2D Vector
原题链接在这里:https://leetcode.com/problems/flatten-2d-vector/ 题目: Implement an iterator to flatten a 2d v ...
- opencv基本的数据结构(转)
DataType : 将C++数据类型转换为对应的opencv数据类型 enum { CV_8U=0, CV_8S=1, CV_16U=2, CV_16S=3, CV_32S=4, CV_32F=5, ...
- c++容器(vector、list、deque)
vector ,deque 和 list 顺序性容器: 向量 vector : 是一个线性顺序结构.相当于数组,但其大小可以不预先指定,并且自动扩展.它可以像数组一样被操作,由于它的特性我们完全可 ...
- 边工作边刷题:70天一遍leetcode: day 84
Flatten 2D Vector 要点: 这题是2d的iterator,一般对于1d的情况,hasNext()是不需要做移动的.而2d不同,core iterator是j向的,而i向要在hasNex ...
- opencv3中的机器学习算法之:EM算法
不同于其它的机器学习模型,EM算法是一种非监督的学习算法,它的输入数据事先不需要进行标注.相反,该算法从给定的样本集中,能计算出高斯混和参数的最大似然估计.也能得到每个样本对应的标注值,类似于kmea ...
随机推荐
- [ios]安装CocoaPods及使用详解
最新 macOS Sierra 10.12.3 安装CocoaPods及使用详解 http://www.jianshu.com/p/b64b4fd08d3c CocoaPods的安装以及遇到的坑 ht ...
- java数组声明和变式--record1
java声明数组方式: String[] namelist; int numlist[];//此声明为动态声明,不能指定长度,numlist[10] 静态声明的方式: int a[]={1,2,3 ...
- 【Golang 接口自动化07】struct转map的三种方式
背景 我们在前面介绍过怎么使用net/http发送json或者map数据,那么它能不能直接发送结构体数据呢?我们今天一起来学习结构体struct转map的三种方法,为后续做铺垫. struct转map ...
- Codeforces 913C - Party Lemonade
913C - Party Lemonade 思路:对于第i个话费cost[i],取min(cost[i],2*cost[i-1]),从前往后更新,这样就可以保证第n个的话费的性价比最高,那么从最高位开 ...
- 雷林鹏分享:C# 索引器(Indexer)
C# 索引器(Indexer) 索引器(Indexer) 允许一个对象可以像数组一样被索引.当您为类定义一个索引器时,该类的行为就会像一个 虚拟数组(virtual array) 一样.您可以使用数组 ...
- Android之省市区三级联动
最近项目要做一个电商APP,选择收货地址的三级联动滚动选择组件, 控件用起来非常简单 ,下面是它的运行效果: 布局 <LinearLayout xmlns:android="http: ...
- 在 Confluence 6 中连接一个 LDAP 目录
希望将 Confluence 连接到一个 LDAP 目录: 在屏幕的右上角单击 控制台按钮 ,然后选择 General Configuration 链接. 在左侧的面板中单击 用户目录(User Di ...
- Garlands CodeForces - 707E (离线树状数组)
大意: 给定n*m矩阵, k条链, 链上每个点有权值, 每次操作可以关闭或打开一条链或询问一个子矩阵内未关闭的权值和. 关键询问操作比较少, 可以枚举每条链, 暴力算出该条链对每个询问的贡献. 最后再 ...
- HDU-4849 Wow! Such City! (单源最短路)
Problem Description Doge, tired of being a popular image on internet, is considering moving to anoth ...
- POJ-1129 Channel Allocation (DFS)
Description When a radio station is broadcasting over a very large area, repeaters are used to retra ...