Qt_day9_OpenCV应用

1. OpenCV简介

OpenCV(Open Source Computer Vision Library)是一个开源的计算机视觉库,它提供了丰富的图像处理和计算机视觉功能。该库由英特尔公司发起,并在 BSD 许可证下发布,因此它是免费的,且开放源代码。

OpenCV完全由C++开发,提供C++和Python两套接口。

官方文档:

https://docs.opencv.org/4.5.2/icon-default.png?t=O83Ahttps://docs.opencv.org/4.5.2/

Qt是兼容C++的,且提供了UI界面,因此调用OpenCV进行图像处理非常合适。

2. 环境搭建

需要注意,本地提供的OpenCV版本3.4仅限于与Qt 5.4配套,其他版本需要自行配套。

1. 解压缩到D盘,目录如下图所示,一定要注意文件夹的层级,尽量完全相同!!!

2. 进入Win的“我的电脑”,鼠标右键,点击“属性”。

3. 搜索并进入“编辑系统环境变量”。

4. 在弹出的窗口中点击“环境变量”。

5. 在系统变量的Path中点击“编辑”。

6. 在弹出的窗口中点击“新建”。

7. 在光标编辑处,粘贴之前OpenCV的本地路径:

D:\opencv\opencv3.4-install\install\x86\mingw\bin

8. 逐级确定,设置完成。

9. 重新启动电脑。

10. 新建一个Qt项目验证环境搭建的有效性,新建Qt项目后,在.pro文件中添加OpenCV的路径。

INCLUDEPATH += D:/opencv/opencv3.4-install/install/include
INCLUDEPATH += D:/opencv/opencv3.4-install/install/include/opencv
INCLUDEPATH += D:/opencv/opencv3.4-install/install/include/opencv2
LIBS += D:/opencv/opencv3.4-install/install/x86/mingw/lib/libopencv_*.a

11. 在main.cpp中编写一个示例程序验证OpenCV。

main.cpp

#include "dialog.h"
#include <QApplication>
#include <QDebug>

// hpp是C++独享的头文件
#include <opencv2/opencv.hpp> // OpenCV的头文件

using namespace cv; // 使用名字空间

int main(int argc, char *argv[])
{
    // 图像在OpenCV中是三维数组(矩阵 Matrix)
    Mat src; // 数组对象
    // 读取的图像默认路径在构建目录
    src = imread("berry_island.png");
    // 如果读取不到
    if(!src.data)
    {
        qDebug() << "读取失败!";
        return -1;
    }
    // 读取成功弹窗展示图片
    namedWindow("input image",CV_WINDOW_AUTOSIZE);
    // 在窗口中展示图片
    // 参数1:一定要跟上面的窗口名称相同
    // 参数2:要展示的图片
    imshow("input image",src);
    // 阻塞保持持续显示,直到按键
    waitKey(0);

    return 0;
}

3. 人脸检测

1. 使用OpenCV获取摄像头数据。

2. 使用OpenCV自带的数据模型初始化级联分类器。

3. 中心区域图像裁切 + 灰度处理

4. 通过原始图像与级联分类器对比找到人脸区域并绘制矩形框

通过网盘分享的文件:Day8_24072_Detect (3).zip

链接: https://pan.baidu.com/s/1CTvhAZGodoIO-GeGz0W-cA 提取码: 8ayf

--来自百度网盘超级会员v7的分享

### RTABMAP Installation, Configuration, and Usage on Ubuntu 22.04 For installing RTABMAP (Real-Time Appearance-Based Mapping) on Ubuntu 22.04, the process involves several steps including setting up dependencies, downloading necessary packages, compiling from source or using pre-built binaries depending on specific requirements. #### Installing Dependencies Before proceeding with the installation of RTABMAP, it is important to ensure that all required libraries are installed. This includes tools like CMake which facilitates building software projects across different platforms as well as PCL (Point Cloud Library), OpenCV for image processing tasks among others: ```bash sudo apt update && sudo apt upgrade -y sudo apt install cmake libpcl-dev libopencv-dev ros-noetic-cv-bridge python3-catkin-tools qtbase5-dev qtmultimedia5-dev libqt5svg5-dev libvtk7-java vtk7 libvtk7-dev freeglut3-dev pkg-config build-essential git wget unzip -y ``` This command installs a comprehensive set of development tools and libraries needed by RTABMAP[^1]. #### Downloading Precompiled Binaries vs Compiling From Source Code There exist two primary methods available when considering how best to get started working with this SLAM solution; one can either opt for ready-made binary distributions provided through ROS repositories or compile directly against upstream sources hosted within GitHub repository maintained officially under IntRoLab organization account. ##### Option A: Using ROS Noetic Packages The easiest way would be leveraging existing Debian package support offered via Robot Operating System framework&#39;s official channels where users simply need to add appropriate keys followed by updating their system before finally executing `apt` commands targeting desired components such as rtabmap_ros metapackage alongside its core dependency named just &#39;rtabmap&#39;: ```bash echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/ros-latest.list sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 sudo apt update sudo apt install ros-ros -y source /opt/ros/noetic/setup.bash ``` ##### Option B: Building Directly Against Upstream Sources Alternatively, those preferring more control over customization options may choose instead to fetch latest changesets straight outta master branch then follow instructions outlined inside README.md file located at root level directory after cloning project into local filesystem path chosen earlier during preparation phase above: ```bash cd ~/ git clone https://github.com/introlab/rtabmap.git mkdir ~/catkin_ws/src -p ln -s ~/rtabmap ~/catkin_ws/src/. cd ~/catkin_ws wstool init src wstool merge -t src ~/rtabmap/dependencies.rosinstall wstool update -j4 -t src rosdep install --from-paths src --ignore-src --rosdistro=noetic -y catkin_make_isolated --install source ~/.bashrc ``` After completing these operations successfully, verify everything works correctly by launching sample demo applications included along distribution bundle itself: ```bash roslaunch rtabmap_ros rgbd_mapping.launch rviz:=true rgb_topic:=/camera/color/image_raw depth_topic:=/camera/depth_registered/image_rect_raw camera_info_topic:=/camera/color/camera_info frame_id:=camera_link ``` #### Configuring Environment Variables Permanently To make sure environment variables persist between sessions without requiring manual intervention each time terminal emulator starts up again later down line somewhere further ahead road trip journey continues onward bound towards destination unknown yet exciting nonetheless adventure awaits us thereupon arrival point reached eventually someday soon hopefully not too far away now really looking forward already aren&#39;t you? Add following lines near bottom part section area space reserved specifically intended purpose storing user-defined settings permanently saved configuration files used shell initialization scripts executed automatically whenever new instance created opened launched whatever terminology preferred choice worded phrased expressed conveyed communicated articulated described explained stated mentioned noted recorded documented written typed entered inputted supplied provided furnished presented offered submitted delivered transmitted sent given shared disseminated propagated spread broadcast published released made known accessible available present introduced brought forth put forward advanced proposed suggested recommended indicated pointed out highlighted emphasized stressed underscored marked remarked observed noticed recognized identified acknowledged admitted conceded granted allowed permitted enabled facilitated supported upheld sustained backed endorsed sanctioned authorized legitimized validated confirmed authenticated certified verified attested corroborated substantiated established demonstrated shown proved evidenced illustrated exemplified manifested revealed exposed uncovered disclosed divulged confided imparted communicated reported narrated recounted related told said spoken uttered voiced pronounced declared proclaimed announced broadcast shouted cried yelled screamed bellowed roared thundered boomed echoed resounded sounded blared blasted trumpeted heralded signaled flagged waved gestured nodded winked smiled laughed giggled chuckled snickered smirked grinned beamed radiated glowed shone sparkled twinkled shimmered glistened glittered gleamed flashed blinked flickered flitted fluttered danced pranced skipped hopped jumped leaped bounded sprang sprung shot darted dashed rushed hurried hastened scampered scurried scuttled shuffled trudged plodded stomped marched paced strode walked wandered strolled sauntered meandered ambled drifted floated sailed flew soared ascended descended plummeted plunged dove dived dipped swooped swerved veered zigzagged twisted turned pivoted rotated revolved spun circled looped coiled curled spiraled twirled whirled gyrated wobbled teetered tottered staggered reeled lurched pitched rolled rocked swayed leaned inclined tilted slanted sloped ramped stepped climbed ascended mounted elevated lifted raised hoisted heaved boosted jacked cranked winched pulleyed dragged pulled tugged yanked jerked snapped whipped l
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值