请教怎么实现从图像中分析出一条线?并对这条线进行处理。比如用摄像头给黑板拍照然后从图像中找出黑板上的线条?如果要动态的不停分析处理用什么样的摄像头比较好
请问如何实现从图像中分析出一条线?并对这条线进行处理。比如用摄像头给黑板拍照然后从图像中找出黑板上的线条?如果要动态的不停分析处理用什么样的摄像头比较好?
请问如何实现从图像中分析出一条线?并对这条线进行处理。比如用摄像头给黑板拍照然后从图像中找出黑板上的线条?如果要动态的不停分析处理用什么样的摄像头比较好?方便程序处理
谢谢
------解决方案--------------------
通用的摄像头肯定是没有你想要的功能的。 除非你让厂家为你定制。
一般来说就是你自己写好图像处理算法。 采集一帧处理一帧. 当然你需要提高处理速度, 尽量达到30帧以上处理速度.
------解决方案--------------------
先对图像灰度化,再用调整算法二值化,就出来了线条,剩下的就是图像识别了。
------解决方案--------------------

请问如何实现从图像中分析出一条线?并对这条线进行处理。比如用摄像头给黑板拍照然后从图像中找出黑板上的线条?如果要动态的不停分析处理用什么样的摄像头比较好?方便程序处理
谢谢
------解决方案--------------------
通用的摄像头肯定是没有你想要的功能的。 除非你让厂家为你定制。
一般来说就是你自己写好图像处理算法。 采集一帧处理一帧. 当然你需要提高处理速度, 尽量达到30帧以上处理速度.
------解决方案--------------------
先对图像灰度化,再用调整算法二值化,就出来了线条,剩下的就是图像识别了。
------解决方案--------------------
/*------------------------------------------------------------------------------------------*\
This file contains material supporting chapter 7 of the cookbook:
Computer Vision Programming using the OpenCV Library.
by Robert Laganiere, Packt Publishing, 2011.
This program is free software; permission is hereby granted to use, copy, modify,
and distribute this source code, or portions thereof, for any purpose, without fee,
subject to the restriction that the copyright notice may not be removed
or altered from any source or altered source distribution.
The software is released on an as-is basis and without any warranties of any kind.
In particular, the software is not guaranteed to be fault-tolerant or free from failure.
The author disclaims all warranties with regard to this software, any use,
and any consequent failure, is purely the responsibility of the user.
Copyright (C) 2010-2011 Robert Laganiere, www.laganiere.name
\*------------------------------------------------------------------------------------------*/
#if !defined LINEF
#define LINEF
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#define PI 3.1415926
class LineFinder {
private:
// original image
cv::Mat img;
// vector containing the end points
// of the detected lines
std::vector<cv::Vec4i> lines;
// accumulator resolution parameters
double deltaRho;
double deltaTheta;
// minimum number of votes that a line
// must receive before being considered
int minVote;
// min length for a line
double minLength;
// max allowed gap along the line
double maxGap;
public:
// Default accumulator resolution is 1 pixel by 1 degree
// no gap, no mimimum length
LineFinder() : deltaRho(1), deltaTheta(PI/180), minVote(10), minLength(0.), maxGap(0.) {}
// Set the resolution of the accumulator
void setAccResolution(double dRho, double dTheta) {
deltaRho= dRho;
deltaTheta= dTheta;
}
// Set the minimum number of votes
void setMinVote(int minv) {
minVote= minv;
}
// Set line length and gap
void setLineLengthAndGap(double length, double gap) {
minLength= length;
maxGap= gap;
}
// Apply probabilistic Hough Transform
std::vector<cv::Vec4i> findLines(cv::Mat& binary) {
lines.clear();
cv::HoughLinesP(binary,lines,deltaRho,deltaTheta,minVote, minLength, maxGap);
return lines;
}
// Draw the detected lines on an image
void drawDetectedLines(cv::Mat &image, cv::Scalar color=cv::Scalar(255,255,255)) {
// Draw the lines
std::vector<cv::Vec4i>::const_iterator it2= lines.begin();
while (it2!=lines.end()) {
cv::Point pt1((*it2)[0],(*it2)[1]);
cv::Point pt2((*it2)[2],(*it2)[3]);
cv::line( image, pt1, pt2, color);