全景影像转点云——只有鱼才能看见的真实
2017-08-22 15:12
204 查看
子非鱼,安知鱼之乐。呵呵呵呵呵呵.....
最近做车载影像贴图,看到PTGui有个很炫的全景影像浏览功能,客户仿佛置身其中一样。
于是想做一个一样的出来。
当然啦,就是普通的全景影像。
不过每天用这样的眼睛看世界,没过多久就崩溃了吧。
所以说做鱼也不容易啊。
吾非鱼,安知鱼之乐,这种话也说不出来了吧。。。
好了进入主题,公式如下:
上代码:
上结果:
将视角分别移动到里面和外面,效果都很绝佳。
说两句:
观察这只水鸟很久了,不知道它为何孤身一只。
景色很美,它飞起来的时候翅膀也很大,希望没人杀掉它。
希望它多吃点,变成仙鹤。池塘里还有这么多鱼呢。
最近做车载影像贴图,看到PTGui有个很炫的全景影像浏览功能,客户仿佛置身其中一样。
于是想做一个一样的出来。
当然啦,就是普通的全景影像。
不过每天用这样的眼睛看世界,没过多久就崩溃了吧。
所以说做鱼也不容易啊。
吾非鱼,安知鱼之乐,这种话也说不出来了吧。。。
好了进入主题,公式如下:
上代码:
//将全景影像用球面投影尝试进行弄成三维球形 void IMG2BallCloud(std::string in_IMGFileName, std::string out_OutClouFileName, bool ifDownSample) { cout << "2Dimage to 3DBallCloud..."; cv::Mat PanoramaIMG = imread(in_IMGFileName); if (PanoramaIMG.empty()) { cout << "open IMG Fail!" << endl; return; } int nr = PanoramaIMG.rows; // number of rows int nc = PanoramaIMG.cols; // number of columns double R = (double)nc / (2 * CV_PI);//利用“R*theta=周长”这一公式反算半径 cout << "R Active:" << R << endl; ofstream outFile(out_OutClouFileName); int PtNum = nr*nc; cout << "Origion Point Cloud Num:" << PtNum << endl; PtNum = 0; for (int r = 0; r < nr; r++) { //进行1/4采样, if (ifDownSample) { if (r % 2 == 1)continue; } for (int c = 0; c < nc; c++) { if (ifDownSample) { if (c % 2 == 1)continue; } double x = (double)c; double y = (double)r; double theta = x / R; double phi = y / R; double X = R*sin(phi)*sin(theta); double Y = R*sin(phi)*cos(theta); double Z = R*cos(phi); int color_b = PanoramaIMG.at<cv::Vec3b>(r, c)[0]; int color_g = PanoramaIMG.at<cv::Vec3b>(r, c)[1]; int color_r = PanoramaIMG.at<cv::Vec3b>(r, c)[2]; //if (color_b == 0)continue;//图像的黑色部分不要 if (abs(theta) <= 0.2 || abs(phi) <= 0.2) { color_b = 0; color_g = 255; color_r = 0; } PtNum++; outFile << X << " " << Y << " " << Z << " " << color_r << " " << color_g << " " << color_b << endl; } } cout << "done! last point cloud num:" << PtNum << endl; outFile.close(); } void PanoramaIMG_toBallCloud() { //std::string PanoramaIMGFile = std::string(".\\Data\\picture\\PanoramaIMG.jpg");//拍摄而得全景 std::string PanoramaIMGFile = std::string(".\\Output\\SphericalMapping.jpg");//黑色采样全景 std::string OutCloudFile = std::string(".\\Output\\PanoramaIMG_toBallCloud.txt"); IMG2BallCloud(PanoramaIMGFile, OutCloudFile); }
上结果:
将视角分别移动到里面和外面,效果都很绝佳。
说两句:
观察这只水鸟很久了,不知道它为何孤身一只。
景色很美,它飞起来的时候翅膀也很大,希望没人杀掉它。
希望它多吃点,变成仙鹤。池塘里还有这么多鱼呢。
相关文章推荐
- 在WORD中之前放进去的图片现在打不开了 不能显示出来了 只有边框 预览时才能看见
- 怎么查看真实项目的http 请求的请求报文和响应报文,即request和response?只有这样,才能完全彻底明白一个http 请求整个过程,发送和接收的是什么东西。
- 只有打开这个界面,我才能回到真实的自我
- 只有改变才能看见未来
- IT人只有关注未来,才能持续发展
- 12个球一个天平,现知道只有一个和其它的重量不同,问怎样称才能用三次就找到那个球
- 只有有价值的工作才能体现出程序员的价值!
- 安卓游戏 h5游戏 安卓activity+webview+h5=2048程序员版 只有程序员才能玩的懂的2048升级版html离线小游戏 2048安卓程序员版 android2048
- 谁说只有理财规划师才能做好理财的?
- 据说只有山东人才能看懂的笑话
- 只有标注了desc的任务才能在rake -T上显示
- 切记:只有肯吃苦才能赚大钱!
- 只有与众不同才能生存 推荐
- PL_SQL(oracle数据库)导入数据出现“经由常规路径 EXPORT:V11.02.00 -64bit ”只有DBA才能导入由其他DBA导出的文件
- 只有成功才能使生活变得更加美好
- 蓦然认知:只有做得重一些,我们才能活下来
- 只有数学学得好的人才能写程序?
- 只有偏执狂才能生存!
- 25个据说只有程序员才能看懂的笑话
- 管理神话之二:只有专家才能做这事