使用openCV的QT中的图像处理 [英] Image Processing in QT using openCV
问题描述
我使用opencv2.3.1在QT中检测圆。
i am using opencv2.3.1 in QT for detecting circle.
我的Open CV目录是D:\OpenCV
my Open CV Directory is D:\OpenCV
这里是我的代码:
项目文件:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = ImgProcessing
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h \
FORMS += mainwindow.ui
INCLUDEPATH +=D:\\opencv\\build\\include
LIBS += -LD:\\opencv\\build\\x86\\vc10\\lib \
-lopencv_calib3d231d \
-lopencv_contrib231d \
-lopencv_core231d \
-lopencv_features2d231d \
-lopencv_flann231d \
-lopencv_gpu231d \
-lopencv_haartraining_engined \
-lopencv_highgui231d \
-lopencv_imgproc231d \
-lopencv_legacy231d \
-lopencv_ml231d \
-lopencv_objdetect231d \
-lopencv_ts231d \
-lopencv_video231d
主窗口我把QPushButton对Click事件我尝试做图像处理
and in the main window i put QPushButton on the Click event i am try to do the image processing
void MainWindow::on_pushButton_clicked()
{
cv::Mat matOrg=cv::imread("D:\\temp\\Test_mar26-5-1.bmp");
cv::Mat matProcessed;
std::vector<cv::Vec3f> vecCircles;
std::vector<cv::Vec3f>::iterator itrCircles;
cv::inRange(matOrg,cv::Scalar(0,0,175),cv::Scalar(100,100,256),matProcessed);
cv::GaussianBlur(matProcessed,matProcessed,cv::Size(9,9),1.5);
cv::HoughCircles(matProcessed,vecCircles,CV_HOUGH_GRADIENT,2,matProcessed.rows/4,100,50,10,400);
for(itrCircles =vecCircles.begin();itrCircles !=vecCircles.end();itrCircles++)
{
ui->plainTextEdit->appendPlainText(QString("X: ")+ QString::number((*itrCircles)[0]));
ui->plainTextEdit->appendPlainText(QString("Y: ")+ QString::number((*itrCircles)[1]));
ui->plainTextEdit->appendPlainText(QString("Radius: ")+ QString::number((*itrCircles)[2]));
}
}
但是问题是当我试图运行程序,我得到以下错误
the project building with out any issue. but the problem is when i try to run the program i am getting following error
开始
Starting
D:\ ImgProcessing-build-Desktop_Qt_5_0_0_MSVC2010_32bit_SDK\debug\ImgProcessing.exe ...
D:\ImgProcessing-build-Desktop_Qt_5_0_0_MSVC2010_32bit_SDK\debug\ImgProcessing.exe...
程序意外完成。
D:\ImgProcessing-build-Desktop_Qt_5_0_0_MSVC2010_32bit_SDK\debug\ImgProcessing.exe
退出代码-1073741515
D:\ImgProcessing-build-Desktop_Qt_5_0_0_MSVC2010_32bit_SDK\debug\ImgProcessing.exe exited with code -1073741515
我没有得到为什么它不运行?并且如果尝试评论整个块它正在运行(没有图像处理代码)。当我启用cv :: mat变量时,我得到运行时错误。
I am not getting why it's not running? and if try to comment the whole block it's running.(no image processing code). when i enable the cv::mat variable that time onwards i am getting the runtime error.
请帮助我解决这个问题。
我尝试处理的图片低于
please help me to fix the issue. the image i am trying to process is below
推荐答案
代码对我很好,没有错误。但是 vecCircles.size()
在此处显示为零。请在调试模式基础上建立断点(继续按F10)。
The code worked fine for me, no error at all. But vecCircles.size()
shows zero here. Please build on debug mode and find breakpoints (keep pressing F10).
这篇关于使用openCV的QT中的图像处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!