Zufällige Bilderausgabe und binäres Bild(verbesserbar)

This commit is contained in:
Baran Yasar 2022-11-01 16:34:51 +01:00
parent 403aaf0cdd
commit 20c961550b
33 changed files with 32 additions and 13 deletions

View File

@ -1,6 +1,5 @@
#include "input.h"
Input::Input(/* args */)
{
}
@ -11,15 +10,24 @@ Input::~Input()
Mat Input::readFile(String filePath)
{
Mat image = imread(filePath, IMREAD_COLOR);
std::srand(std::time(0));
// Read all .jpg files from the specified folder
std::string folder = filePath;
std::vector<std::string> filenames;
cv::glob(folder, filenames);
// Random shuffle
std::random_shuffle(filenames.begin(), filenames.end());
Mat image = imread(filenames[0], IMREAD_COLOR);
if(image.empty())
{
std::cout << "Could not read the image: " << filePath << std::endl;
return Mat();
//To do:Exception handeling
}
imshow("Display window", image);
waitKey(0);
return image;
}
@ -39,8 +47,6 @@ Mat Input::readWebcam()
}
cap.read(image);
imshow("Display window", image);
waitKey(0);
return image;
}

View File

@ -1,4 +1,7 @@
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <opencv2/opencv.hpp>
using namespace std;

View File

@ -8,8 +8,10 @@ Processing::~Processing()
{
}
Mat Processing::calculate_binaray(const Mat& inputPicture)
Mat Processing::calculate_binaray(Mat& inputPicture, int thresholdValue)
{
//cvtColor(inputPicture, inputPicture, COLOR_RGB2GRAY);
return Mat();
//Mat &outputPicture;
cvtColor(inputPicture, inputPicture, COLOR_BGR2GRAY);
threshold(inputPicture, inputPicture, thresholdValue, 255, THRESH_BINARY);
return inputPicture;
}

View File

@ -16,5 +16,5 @@ public:
// End und Anfangspunkt analysieren und Winkel und Ausrichtung der Linie extrahieren (Abstand des untersten Punktes von der Mitte)
~Processing();
Mat calculate_binaray(const Mat& inputPicture);
Mat calculate_binaray(Mat& inputPicture, int thresholdValue);
};

View File

Before

Width:  |  Height:  |  Size: 253 KiB

After

Width:  |  Height:  |  Size: 253 KiB

View File

Before

Width:  |  Height:  |  Size: 301 KiB

After

Width:  |  Height:  |  Size: 301 KiB

View File

Before

Width:  |  Height:  |  Size: 268 KiB

After

Width:  |  Height:  |  Size: 268 KiB

View File

Before

Width:  |  Height:  |  Size: 296 KiB

After

Width:  |  Height:  |  Size: 296 KiB

View File

Before

Width:  |  Height:  |  Size: 311 KiB

After

Width:  |  Height:  |  Size: 311 KiB

View File

Before

Width:  |  Height:  |  Size: 254 KiB

After

Width:  |  Height:  |  Size: 254 KiB

View File

Before

Width:  |  Height:  |  Size: 252 KiB

After

Width:  |  Height:  |  Size: 252 KiB

View File

Before

Width:  |  Height:  |  Size: 265 KiB

After

Width:  |  Height:  |  Size: 265 KiB

View File

Before

Width:  |  Height:  |  Size: 245 KiB

After

Width:  |  Height:  |  Size: 245 KiB

View File

Before

Width:  |  Height:  |  Size: 327 KiB

After

Width:  |  Height:  |  Size: 327 KiB

View File

Before

Width:  |  Height:  |  Size: 282 KiB

After

Width:  |  Height:  |  Size: 282 KiB

View File

Before

Width:  |  Height:  |  Size: 229 KiB

After

Width:  |  Height:  |  Size: 229 KiB

View File

Before

Width:  |  Height:  |  Size: 328 KiB

After

Width:  |  Height:  |  Size: 328 KiB

View File

Before

Width:  |  Height:  |  Size: 276 KiB

After

Width:  |  Height:  |  Size: 276 KiB

View File

Before

Width:  |  Height:  |  Size: 310 KiB

After

Width:  |  Height:  |  Size: 310 KiB

View File

Before

Width:  |  Height:  |  Size: 299 KiB

After

Width:  |  Height:  |  Size: 299 KiB

View File

Before

Width:  |  Height:  |  Size: 248 KiB

After

Width:  |  Height:  |  Size: 248 KiB

View File

Before

Width:  |  Height:  |  Size: 328 KiB

After

Width:  |  Height:  |  Size: 328 KiB

View File

Before

Width:  |  Height:  |  Size: 316 KiB

After

Width:  |  Height:  |  Size: 316 KiB

View File

Before

Width:  |  Height:  |  Size: 329 KiB

After

Width:  |  Height:  |  Size: 329 KiB

View File

Before

Width:  |  Height:  |  Size: 295 KiB

After

Width:  |  Height:  |  Size: 295 KiB

View File

Before

Width:  |  Height:  |  Size: 279 KiB

After

Width:  |  Height:  |  Size: 279 KiB

View File

Before

Width:  |  Height:  |  Size: 266 KiB

After

Width:  |  Height:  |  Size: 266 KiB

View File

Before

Width:  |  Height:  |  Size: 251 KiB

After

Width:  |  Height:  |  Size: 251 KiB

View File

Before

Width:  |  Height:  |  Size: 269 KiB

After

Width:  |  Height:  |  Size: 269 KiB

View File

Before

Width:  |  Height:  |  Size: 277 KiB

After

Width:  |  Height:  |  Size: 277 KiB

View File

Before

Width:  |  Height:  |  Size: 262 KiB

After

Width:  |  Height:  |  Size: 262 KiB

View File

Before

Width:  |  Height:  |  Size: 249 KiB

After

Width:  |  Height:  |  Size: 249 KiB

12
lfr.cpp
View File

@ -5,10 +5,18 @@
using namespace cv;
const int threshold_binary = 110;
int main(void)
{
std::cout<<"Hello world";
Input test;
// Mat image1 = test.readFile("C:\\Line-Following-Robot\\Test_data\\WhatsApp Image 2022-10-26 at 09.54.14.jpeg");
Mat image2 = test.readWebcam();
Processing test1;
Mat image1 = test.readFile("C:\\Line-Following-Robot\\Test_data\\*.jpeg");
//Mat image2 = test.readWebcam();
test1.calculate_binaray(image1, threshold_binary);
imshow("Display window", image1);
waitKey(0);
}