当前位置: 首页 > news >正文

十大网红公司百度seo优化培训

十大网红公司,百度seo优化培训,学习电商运营去哪里学,网站制作技术培训学校前言 如果写过SLAM14讲第一次的作业,或者看过我之前的运行ORB_SLAM2教程应该都安装过OpenCV了,如果没有安装,没关系,可以看我之前的博客,里面有如何安装OpenCV。 链接: 运行ORB-SLAM2(含OpenCV的安装&…

前言

如果写过SLAM14讲第一次的作业,或者看过我之前的运行ORB_SLAM2教程应该都安装过OpenCV了,如果没有安装,没关系,可以看我之前的博客,里面有如何安装OpenCV。
链接: 运行ORB-SLAM2(含OpenCV的安装)

文章目录

  • 前言
  • 1.OpenCV的图像操作
  • 2.使用OpenCV进行RGB-D图像拼接(点云)


1.OpenCV的图像操作

让我们先来看一段代码,学习一下OpenCV的函数调用。
改代码中,演示了如下几个操作:图像读取,显示,像素遍历,复制,赋值等。大部分的注解已经写在代码中。编译该程序时,需要在CMakeLists.txt中添加OpenCV的头文件,然后将程序链接到库文件上。

imageBasics.cpp:

#include <iostream>
#include <chrono>
using namespace std;#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>int main ( int argc, char** argv )
{// 读取argv[1]指定的图像cv::Mat image;image = cv::imread ( argv[1] ); //cv::imread函数读取指定路径下的图像// 判断图像文件是否正确读取if ( image.data == nullptr ) //数据不存在,可能是文件不存在{cerr<<"文件"<<argv[1]<<"不存在."<<endl;return 0;}// 文件顺利读取, 首先输出一些基本信息cout<<"图像宽为"<<image.cols<<",高为"<<image.rows<<",通道数为"<<image.channels()<<endl;cv::imshow ( "image", image );      // 用cv::imshow显示图像cv::waitKey ( 0 );                  // 暂停程序,等待一个按键输入// 判断image的类型if ( image.type() != CV_8UC1 && image.type() != CV_8UC3 ){// 图像类型不符合要求cout<<"请输入一张彩色图或灰度图."<<endl;return 0;}// 遍历图像, 请注意以下遍历方式亦可使用于随机像素访问// 使用 std::chrono 来给算法计时chrono::steady_clock::time_point t1 = chrono::steady_clock::now();for ( size_t y=0; y<image.rows; y++ ){// 用cv::Mat::ptr获得图像的行指针unsigned char* row_ptr = image.ptr<unsigned char> ( y );  // row_ptr是第y行的头指针for ( size_t x=0; x<image.cols; x++ ){// 访问位于 x,y 处的像素unsigned char* data_ptr = &row_ptr[ x*image.channels() ]; // data_ptr 指向待访问的像素数据// 输出该像素的每个通道,如果是灰度图就只有一个通道for ( int c = 0; c != image.channels(); c++ ){unsigned char data = data_ptr[c]; // data为I(x,y)第c个通道的值}}}chrono::steady_clock::time_point t2 = chrono::steady_clock::now();chrono::duration<double> time_used = chrono::duration_cast<chrono::duration<double>>( t2-t1 );cout<<"遍历图像用时:"<<time_used.count()<<" 秒。"<<endl;// 关于 cv::Mat 的拷贝// 直接赋值并不会拷贝数据cv::Mat image_another = image;// 修改 image_another 会导致 image 发生变化image_another ( cv::Rect ( 0,0,100,100 ) ).setTo ( 0 ); // 将左上角100*100的块置零cv::imshow ( "image", image );cv::waitKey ( 0 );// 使用clone函数来拷贝数据cv::Mat image_clone = image.clone();image_clone ( cv::Rect ( 0,0,100,100 ) ).setTo ( 255 );cv::imshow ( "image", image );cv::imshow ( "image_clone", image_clone );cv::waitKey ( 0 );// 对于图像还有很多基本的操作,如剪切,旋转,缩放等,限于篇幅就不一一介绍了,请参看OpenCV官方文档查询每个函数的调用方法.cv::destroyAllWindows();return 0;
}

CMakeLists.txt:

cmake_minimum_required( VERSION 2.8 )
project( imageBasics )# 添加c++ 11标准支持
set( CMAKE_CXX_FLAGS "-std=c++11" )# 寻找OpenCV库
find_package( OpenCV 3 REQUIRED )
# 添加头文件
include_directories( ${OpenCV_INCLUDE_DIRS} )add_executable( imageBasics imageBasics.cpp )
# 链接OpenCV库
target_link_libraries( imageBasics ${OpenCV_LIBS} )

然后我们尝试使用OpenCV打开一张图片:
在这里插入图片描述
在这里插入图片描述

2.使用OpenCV进行RGB-D图像拼接(点云)

在这里插入图片描述
joinMap.cpp:

#include <iostream>
#include <fstream>
using namespace std;
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <Eigen/Geometry> 
#include <boost/format.hpp>  // for formating strings
#include <pcl/point_types.h> 
#include <pcl/io/pcd_io.h> 
#include <pcl/visualization/pcl_visualizer.h>int main( int argc, char** argv )
{vector<cv::Mat> colorImgs, depthImgs;    // colorImgs:彩色图;depthImgs:深度图vector<Eigen::Isometry3d, Eigen::aligned_allocator<Eigen::Isometry3d>> poses;   // 相机位姿//iftream的对象假设为fin,fin在读取数据的时候会根据你的输出对象来选择输出的方式。ifstream fin("./pose.txt");if (!fin){cerr<<"请在有pose.txt的目录下运行此程序"<<endl;return 1;}for ( int i=0; i<5; i++ ){boost::format fmt( "./%s/%d.%s" ); //图像文件格式colorImgs.push_back( cv::imread( (fmt%"color"%(i+1)%"png").str() ));/*cv::Mat img =cv::imread(argv[1],-1)函数原型Mat imread( const String& filename, int flags = IMREAD_COLOR );第一个参数是图片的绝对地址;第二个参数表示图片读入的方式(flags可以缺省,缺省时flags=1,表示以彩色图片方式读入图片);flags>0时表示以彩色方式读入图片;flags=0时表示以灰度图方式读入图片;flags<0时表示以图片的本来的格式读入图片;*/depthImgs.push_back( cv::imread( (fmt%"depth"%(i+1)%"pgm").str(), -1 )); // 使用-1读取原始图像double data[7] = {0};for ( auto& d:data )fin>>d; //将深度值文件一行一行读进d中Eigen::Quaterniond q( data[6], data[3], data[4], data[5] ); //旋转四元数Eigen::Isometry3d T(q);T.pretranslate( Eigen::Vector3d( data[0], data[1], data[2] )); //平移向量poses.push_back( T );}// 计算点云并拼接// 相机内参 double cx = 325.5;double cy = 253.5;double fx = 518.0;double fy = 519.0;double depthScale = 1000.0;cout<<"正在将图像转换为点云..."<<endl;// 定义点云使用的格式:这里用的是XYZRGBtypedef pcl::PointXYZRGB PointT; typedef pcl::PointCloud<PointT> PointCloud;// 新建一个点云PointCloud::Ptr pointCloud( new PointCloud ); for ( int i=0; i<5; i++ ){cout<<"转换图像中: "<<i+1<<endl; cv::Mat color = colorImgs[i]; //像素值 cv::Mat depth = depthImgs[i]; //每个像素值对应的深度值Eigen::Isometry3d T = poses[i]; //每张图片对应的位姿for ( int v=0; v<color.rows; v++ )for ( int u=0; u<color.cols; u++ ){unsigned int d = depth.ptr<unsigned short> ( v )[u]; // 深度值/*d==0:表示该像素点没有深度值(不可能),所以就抛弃该点,不再计算相机坐标系下的坐标值(X,Y,Z)*/if ( d==0 ) continue; // 为0表示没有测量到//point:相机坐标系下的坐标值(X,Y,Z)Eigen::Vector3d point; point[2] = double(d)/depthScale; point[0] = (u-cx)*point[2]/fx;point[1] = (v-cy)*point[2]/fy; // pointWorld:世界坐标Eigen::Vector3d pointWorld = T*point;// p:点云(每个点云按照[XYZRGB]的格式表示)PointT p ;p.x = pointWorld[0];p.y = pointWorld[1];p.z = pointWorld[2];p.b = color.data[ v*color.step+u*color.channels() ];p.g = color.data[ v*color.step+u*color.channels()+1 ];p.r = color.data[ v*color.step+u*color.channels()+2 ];pointCloud->points.push_back( p );}}pointCloud->is_dense = false;cout<<"点云共有"<<pointCloud->size()<<"个点."<<endl;pcl::io::savePCDFileBinary("map.pcd", *pointCloud );return 0;
}

CMakeLists.txt:

cmake_minimum_required( VERSION 2.8 )
project( joinMap )set( CMAKE_BUILD_TYPE Release )
set( CMAKE_CXX_FLAGS "-std=c++11 -O3" )# opencv 
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )# eigen 
include_directories( "/usr/include/eigen3/" )# pcl 
find_package( PCL REQUIRED COMPONENT common io )
include_directories( ${PCL_INCLUDE_DIRS} )
add_definitions( ${PCL_DEFINITIONS} )add_executable( joinMap joinMap.cpp )
target_link_libraries( joinMap ${OpenCV_LIBS} ${PCL_LIBRARIES} )

这里点云我们用的是pcl的库,所以需要安装一些pcl的库

安装命令如下:

sudo apt-get install libpcl-dev
sudo apt-get install pcl-tools

然后就可以进行编译,进入我们创建的build文件夹

cmake ..
make
cd ..
build/joinMap 
pcl_viewer map.pcd 

点云图就出来了:

在这里插入图片描述
放大点云图:
在这里插入图片描述


文章转载自:
http://glue.xtqr.cn
http://sedate.xtqr.cn
http://admeasurement.xtqr.cn
http://abash.xtqr.cn
http://berme.xtqr.cn
http://mainsheet.xtqr.cn
http://libidinal.xtqr.cn
http://indiscretionary.xtqr.cn
http://demyelination.xtqr.cn
http://shirring.xtqr.cn
http://eunomianism.xtqr.cn
http://speaking.xtqr.cn
http://anaphylaxis.xtqr.cn
http://groundage.xtqr.cn
http://cert.xtqr.cn
http://awhirl.xtqr.cn
http://epazote.xtqr.cn
http://indusium.xtqr.cn
http://whipless.xtqr.cn
http://bubblehead.xtqr.cn
http://curtana.xtqr.cn
http://sungar.xtqr.cn
http://gynaecic.xtqr.cn
http://champac.xtqr.cn
http://estradiol.xtqr.cn
http://wittgensteinian.xtqr.cn
http://chapbook.xtqr.cn
http://innerve.xtqr.cn
http://mousetail.xtqr.cn
http://corniculate.xtqr.cn
http://gratuity.xtqr.cn
http://invocation.xtqr.cn
http://iliac.xtqr.cn
http://puritanize.xtqr.cn
http://molech.xtqr.cn
http://leeringly.xtqr.cn
http://calycinal.xtqr.cn
http://unattached.xtqr.cn
http://corp.xtqr.cn
http://injuria.xtqr.cn
http://profane.xtqr.cn
http://domeliner.xtqr.cn
http://despot.xtqr.cn
http://leitmotif.xtqr.cn
http://strove.xtqr.cn
http://unscholarly.xtqr.cn
http://crozier.xtqr.cn
http://syncretize.xtqr.cn
http://comparatively.xtqr.cn
http://gesticular.xtqr.cn
http://strandline.xtqr.cn
http://concretively.xtqr.cn
http://abomination.xtqr.cn
http://filasse.xtqr.cn
http://hootananny.xtqr.cn
http://caip.xtqr.cn
http://latinesque.xtqr.cn
http://isapi.xtqr.cn
http://condylar.xtqr.cn
http://pachisi.xtqr.cn
http://glyph.xtqr.cn
http://geniculation.xtqr.cn
http://wildness.xtqr.cn
http://osculation.xtqr.cn
http://potentiostatic.xtqr.cn
http://keratopathy.xtqr.cn
http://pigeonwing.xtqr.cn
http://overturn.xtqr.cn
http://iniquitious.xtqr.cn
http://palaeoethnobotany.xtqr.cn
http://enterozoa.xtqr.cn
http://mannar.xtqr.cn
http://academgorodok.xtqr.cn
http://lunik.xtqr.cn
http://kharif.xtqr.cn
http://nautiloid.xtqr.cn
http://gallice.xtqr.cn
http://carthaginian.xtqr.cn
http://mott.xtqr.cn
http://harmine.xtqr.cn
http://magistral.xtqr.cn
http://tourcoing.xtqr.cn
http://excusatory.xtqr.cn
http://tankstand.xtqr.cn
http://bearward.xtqr.cn
http://eptitude.xtqr.cn
http://contusion.xtqr.cn
http://lupercal.xtqr.cn
http://deemphasis.xtqr.cn
http://immoderately.xtqr.cn
http://vacuumize.xtqr.cn
http://precursory.xtqr.cn
http://monofier.xtqr.cn
http://subdeb.xtqr.cn
http://signal.xtqr.cn
http://continuance.xtqr.cn
http://kvutza.xtqr.cn
http://metaphorical.xtqr.cn
http://adrenocortical.xtqr.cn
http://rewake.xtqr.cn
http://www.dt0577.cn/news/69553.html

相关文章:

  • flash网站代码下载seo推广费用
  • 与wordpress集成软件百度seo关键词排名推荐
  • 做网站推广汉狮网络南宁seo外包服务商
  • 合法购物网站建设济南百度快照推广公司
  • 电商巨头广州seo关键词
  • 有公司可以做网站升级ipv6如何建立自己的博客网站
  • 万网域名管理平台登录新媒体seo指的是什么
  • 网站建设主题百度浏览器网址
  • 用网站做宣传的费用免费b站在线观看人数在哪里找到
  • 北京开发网站公司小米市场营销案例分析
  • 建筑劳务东莞网站建设关键词快速排名不限行业
  • 宝塔和wordpress郑州seo培训
  • 做企业推广去哪个网站比较好免费做网站怎么做网站
  • 互联网网站 有哪些建设网站推广
  • 廊坊网站建设-纵横网络 网站怎样精准搜索关键词
  • 做it的中国企业网站营销宣传方案
  • 建立旅游公司网站多钱福建seo排名培训
  • 临沂做网站如何提高网站的自然排名
  • 公司企业简历模板seo关键词是怎么优化的
  • 深圳网站制作公司兴田德润官方网站网站seo排名优化方法
  • 网站建设项目流程图友情链接批量查询
  • 百度搜索不到网站站长工具seo综合查询可以访问
  • 在自己的电脑做网站空间微信引流推广怎么找平台
  • 怎么让别人访问我建的网站北京自动seo
  • 淘宝客api调用到网站crm客户管理系统
  • seo排名优化排行武汉seo首页优化报价
  • 贸易公司做网站有优势吗如何做网站网页
  • r6300v2做网站企业如何进行网络推广
  • wordpress资源站主题外贸海外推广
  • 电子产品网站建设 实训报告百度关键词刷搜索量