程序一编译就有问题,吧里大佬帮忙看下~(是一个hsv阈值化程序)
opencv吧
全部回复
仅看楼主
level 2
NARUTONPX 楼主
#include"opencv2/opencv.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
#include <ctype.h>
using namespace cv;
using namespace std;
Mat HSV, thresholded;
int iLowH = 0;
int iHighH = 180;
int iLowS = 0;
int iHighS = 255;
int iLowV = 0;
int iHighV = 255;
void on_Trackbar(int, void*);
int main()
{
Mat frame;
VideoCapture cap(1);
cap.set(CV_CAP_PROP_FRAME_WIDTH, 1920); //1920 1080
cap.set(CV_CAP_PROP_FRAME_HEIGHT, 1080);
cap.set(CV_CAP_PROP_EXPOSURE, -6.5);//设置曝光时间
namedWindow("video", CV_WINDOW_NORMAL);
namedWindow("adjust", CV_WINDOW_NORMAL);
createTrackbar("LowH", "adjust", &iLowH, 180, on_Trackbar);
createTrackbar("HighH", "adjust", &iHighH, 180, on_Trackbar);
createTrackbar("LowS", "adjust", &iLowS, 255, on_Trackbar);
createTrackbar("HighS", "adjust", &iHighS, 255, on_Trackbar);
createTrackbar("LowV", "adjust", &iLowV, 255, on_Trackbar);
createTrackbar("HighV", "adjust", &iHighV, 255, on_Trackbar);
while (1)
{
cap >> frame;
if (frame.empty())
{
cout << "There is no images." << endl;
return false;
}
imshow("video", frame);
waitKey(1);
vector<Mat> hsvSplit;
cvtColor(frame, HSV, COLOR_BGR2HSV);
split(HSV, hsvSplit);
equalizeHist(hsvSplit[2], hsvSplit[2]);
merge(hsvSplit, HSV);
on_Trackbar(0, 0);
waitKey(1);
imshow("adjust", thresholded);
waitKey(1);
}
return 0;
}
void on_Trackbar(int,void*)
{
inRange(HSV, Scalar(iLowH, iLowS, iLowV), Scalar(iHighH, iHighS, iHighV), thresholded);
Mat element = getStructuringElement(MORPH_RECT, Size(5, 5));
morphologyEx(thresholded, thresholded, CV_MOP_OPEN, element);
morphologyEx(thresholded, thresholded, CV_MOP_CLOSE, element);
}
2017年08月30日 07点08分 1
1