Browse Source

Choose between showing img and saving it

pull/1/head
Tim Zeuner 2 years ago
parent
commit
01f29ca9cd
3 changed files with 25 additions and 6 deletions
  1. 2
    0
      AutonomousMode/autonomous_mode_main.cpp
  2. 17
    6
      AutonomousMode/lfr.cpp
  3. 6
    0
      AutonomousMode/lfr.h

+ 2
- 0
AutonomousMode/autonomous_mode_main.cpp View File

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.outputFileName = "/home/pi/Line-Following-Robot/AutonomousMode/tmp/test.jpg";
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;

+ 17
- 6
AutonomousMode/lfr.cpp View File

this->thresholdCanny1 = thresholdCanny1; this->thresholdCanny1 = thresholdCanny1;
this->thresholdCanny2 = thresholdCanny2; this->thresholdCanny2 = thresholdCanny2;
this->apertureSizeCanny = apertureSizeCanny; this->apertureSizeCanny = apertureSizeCanny;

this->videoFlag = false;
this->saveOutputFlag = false;
this->outputFileName = "";
} }


LFR::~LFR() LFR::~LFR()


void LFR::loop() void LFR::loop()
{ {
namedWindow("Display window");
if(this->videoFlag) {namedWindow("Display window");}
while(iAmLooping) while(iAmLooping)
{ {
Mat image = input.readWebcam(); Mat image = input.readWebcam();
{ {
line( image, Point(lines[i][0], lines[i][1]), line( image, Point(lines[i][0], lines[i][1]),
Point( lines[i][2], lines[i][3]), (0,0,255), 1, 8 ); Point( lines[i][2], lines[i][3]), (0,0,255), 1, 8 );
}
imshow("Display window", image);
char c = (char)waitKey(1);
}
if(this->videoFlag)
{
imshow("Display window", image);
char c = (char)waitKey(1);
}
if (this->saveOutputFlag && !(this->outputFileName.empty()))
{
imwrite(this->outputFileName, image);
}
} }
destroyWindow("Display window");
if(this->videoFlag) {destroyWindow("Display window");}
input.freeWebcam(); input.freeWebcam();
} }


iAmLooping = false; iAmLooping = false;
this->loopThread.join(); this->loopThread.join();
return; return;
}
}

+ 6
- 0
AutonomousMode/lfr.h View File



void startLoop(); void startLoop();
void endLoop(); void endLoop();

bool videoFlag;
bool saveOutputFlag;

std::string outputFileName;
}; };

Loading…
Cancel
Save