Show calculated boxes like tested in spielwiese
This commit is contained in:
parent
633b75176c
commit
44a266629f
@ -15,8 +15,8 @@ int main(void)
|
|||||||
const int apertureSizeCanny = 3;
|
const int apertureSizeCanny = 3;
|
||||||
|
|
||||||
LFR lfr(videoHeight, videoWidth, thresholdBinary, gaussKernelSize, thresholdCanny1, thresholdCanny2, apertureSizeCanny);
|
LFR lfr(videoHeight, videoWidth, thresholdBinary, gaussKernelSize, thresholdCanny1, thresholdCanny2, apertureSizeCanny);
|
||||||
lfr.saveOutputFlag = true;
|
lfr.saveOutputFlag = false;
|
||||||
lfr.outputFileName = "/home/pi/Line-Following-Robot/AutonomousMode/tmp/test.jpg";
|
lfr.videoFlag = true;
|
||||||
lfr.startLoop();
|
lfr.startLoop();
|
||||||
//To end the video stream, write any char in the console.
|
//To end the video stream, write any char in the console.
|
||||||
char a;
|
char a;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
|
|
||||||
LFR::LFR(int videoHeight, int videoWidth, int thresholdBinary, int gaussKernelSize, int thresholdCanny1, int thresholdCanny2, int apertureSizeCanny)
|
LFR::LFR(int videoHeight, int videoWidth, int thresholdBinary, int gaussKernelSize, int thresholdCanny1, int thresholdCanny2, int apertureSizeCanny)
|
||||||
: iAmLooping(false), input(videoHeight, videoWidth), processing(), controlModule(), interpreter(), intersectionHandler(), roi()
|
: iAmLooping(false), input(videoHeight, videoWidth), processing(), controlModule(), interpreter(), intersectionHandler()
|
||||||
{
|
{
|
||||||
this->iAmLooping = false;
|
this->iAmLooping = false;
|
||||||
this->thresholdBinary = thresholdBinary;
|
this->thresholdBinary = thresholdBinary;
|
||||||
@ -14,10 +14,6 @@ LFR::LFR(int videoHeight, int videoWidth, int thresholdBinary, int gaussKernelSi
|
|||||||
this->videoFlag = false;
|
this->videoFlag = false;
|
||||||
this->saveOutputFlag = false;
|
this->saveOutputFlag = false;
|
||||||
this->outputFileName = "";
|
this->outputFileName = "";
|
||||||
|
|
||||||
cv::Point roiOrigin(0, videoHeight*(7.5/12.0));
|
|
||||||
roi = Rect(roiOrigin.x, roiOrigin.y, videoWidth, videoHeight/12);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LFR::~LFR()
|
LFR::~LFR()
|
||||||
@ -34,10 +30,14 @@ void LFR::loop()
|
|||||||
while(iAmLooping)
|
while(iAmLooping)
|
||||||
{
|
{
|
||||||
Mat originalImage = input.readWebcam();
|
Mat originalImage = input.readWebcam();
|
||||||
Mat processedImage = originalImage;
|
|
||||||
|
Point roiOrigin(0, int(originalImage.rows*(7.5/12.0)));
|
||||||
|
Rect roi(roiOrigin.x, roiOrigin.y, originalImage.cols, originalImage.rows/12);
|
||||||
|
Mat processedImage = originalImage(roi);
|
||||||
|
|
||||||
processing.processImage(processedImage, this->thresholdBinary, this->gaussKernelSize, this->thresholdCanny1, thresholdCanny2, this->apertureSizeCanny);
|
processing.processImage(processedImage, this->thresholdBinary, this->gaussKernelSize, this->thresholdCanny1, thresholdCanny2, this->apertureSizeCanny);
|
||||||
FrameData data = processing.calculateLineSegments(processedImage, this->roi);
|
FrameData data = processing.calculateLineSegments(processedImage, roi);
|
||||||
this->provideOutput(processedImage);
|
this->provideOutput(originalImage, data, roi);
|
||||||
}
|
}
|
||||||
if(this->videoFlag) {destroyWindow("Display window");}
|
if(this->videoFlag) {destroyWindow("Display window");}
|
||||||
input.freeWebcam();
|
input.freeWebcam();
|
||||||
@ -56,15 +56,25 @@ void LFR::endLoop()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LFR::provideOutput(const Mat& image)
|
void LFR::provideOutput(Mat image, const FrameData& frameData, const Rect& roi)
|
||||||
{
|
{
|
||||||
|
for(int i = 0; i < frameData.contours.size(); i++)
|
||||||
|
{
|
||||||
|
drawContours(image, frameData.contours, i, Scalar(0,255,255), 1, 8, noArray(), 0, Point(roi.x, roi.y));
|
||||||
|
|
||||||
|
rectangle(image, frameData.boundingBoxes[i], Scalar(0,255,0));
|
||||||
|
Rect center(Point(frameData.middlePoints[i].x-2, frameData.middlePoints[i].y-2), Point(frameData.middlePoints[i].x+2, frameData.middlePoints[i].y+2));
|
||||||
|
rectangle(image, center, Scalar(0,0,255));
|
||||||
|
Rect leftRect(Point(frameData.leftEdges[i].x-2, frameData.leftEdges[i].y-2), Point(frameData.leftEdges[i].x+2, frameData.leftEdges[i].y+2));
|
||||||
|
rectangle(image, leftRect, Scalar(0,0,255));
|
||||||
|
}
|
||||||
if(this->videoFlag)
|
if(this->videoFlag)
|
||||||
{
|
{
|
||||||
imshow("Display window", image);
|
imshow("Display window", image);
|
||||||
char c = (char)waitKey(1);
|
char c = (char)waitKey(25);
|
||||||
}
|
}
|
||||||
if (this->saveOutputFlag && !(this->outputFileName.empty()))
|
if (this->saveOutputFlag && !(this->outputFileName.empty()))
|
||||||
{
|
{
|
||||||
imwrite(this->outputFileName, image);
|
imwrite(this->outputFileName, image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,9 +30,8 @@ class LFR
|
|||||||
int thresholdCanny1;
|
int thresholdCanny1;
|
||||||
int thresholdCanny2;
|
int thresholdCanny2;
|
||||||
int apertureSizeCanny;
|
int apertureSizeCanny;
|
||||||
cv::Rect roi;
|
|
||||||
|
|
||||||
void provideOutput(const Mat& image);
|
void provideOutput(Mat image,const FrameData& frameData, const Rect& roi);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user