计算机视觉中的目标检测与形状识别
在计算机视觉领域,目标检测和形状识别是非常重要的任务。下面我们将详细探讨基于颜色的目标检测以及图像中形状识别的相关内容。
基于颜色的目标检测
我们首先来介绍一个简单的目标检测程序,它仅利用颜色信息进行目标检测。严格来说,这更像是一个颜色边界检查程序,因为其中并未涉及机器学习。该程序的目的是解决找到红色球的大致位置,并控制一个简单的轮式机器人去拦截它的问题。
简单颜色目标检测器代码实现
以下是实现该功能的代码:
// Program to display a video from attached default camera device and detect colored blobs using simple
// R G and B thresholding
// Author: Samarth Manoj Brahmbhatt, University of Pennsylvania
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
using namespace cv;
using namespace std;
Mat frame, frame_thresholded;
int rgb_slider = 0, low_slider = 30, high_slider = 100;
int low_r = 30, low_g = 30,