Browse Source

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

pull/1/head
Baran Yasar 1 year ago
parent
commit
20c961550b

+ 13
- 7
Input/input.cpp 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;
}

+ 3
- 0
Input/input.h View File

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

using namespace std;

+ 5
- 3
Processing/processing.cpp 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;
}

+ 1
- 1
Processing/processing.h 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);
};

Test_data/WhatsApp Image 2022-10-26 at 09.54.14.jpeg → Test_data/image1.jpeg View File


Test_data/WhatsApp Image 2022-10-26 at 09.54.20 (1).jpeg → Test_data/image10.jpeg View File


Test_data/WhatsApp Image 2022-10-26 at 09.54.20.jpeg → Test_data/image11.jpeg View File


Test_data/WhatsApp Image 2022-10-26 at 09.54.21 (1).jpeg → Test_data/image12.jpeg View File


Test_data/WhatsApp Image 2022-10-26 at 09.54.21.jpeg → Test_data/image13.jpeg View File


Test_data/WhatsApp Image 2022-10-26 at 09.54.22 (1).jpeg → Test_data/image14.jpeg View File


Test_data/WhatsApp Image 2022-10-26 at 09.54.22.jpeg → Test_data/image15.jpeg View File


Test_data/WhatsApp Image 2022-10-26 at 09.54.23 (1).jpeg → Test_data/image16.jpeg View File


Test_data/WhatsApp Image 2022-10-26 at 09.54.23.jpeg → Test_data/image17.jpeg View File


Test_data/WhatsApp Image 2022-10-26 at 09.54.24 (1).jpeg → Test_data/image18.jpeg View File


Test_data/WhatsApp Image 2022-10-26 at 09.54.24 (2).jpeg → Test_data/image19.jpeg View File


Test_data/WhatsApp Image 2022-10-26 at 09.54.15.jpeg → Test_data/image2.jpeg View File


Test_data/WhatsApp Image 2022-10-26 at 09.54.24.jpeg → Test_data/image20.jpeg View File


Test_data/WhatsApp Image 2022-10-26 at 09.54.25 (1).jpeg → Test_data/image21.jpeg View File


Test_data/WhatsApp Image 2022-10-26 at 09.54.25.jpeg → Test_data/image22.jpeg View File


Test_data/WhatsApp Image 2022-10-26 at 09.54.26 (1).jpeg → Test_data/image23.jpeg View File


Test_data/WhatsApp Image 2022-10-26 at 09.54.26.jpeg → Test_data/image24.jpeg View File


Test_data/WhatsApp Image 2022-10-26 at 09.54.27 (1).jpeg → Test_data/image25.jpeg View File


Test_data/WhatsApp Image 2022-10-26 at 09.54.27.jpeg → Test_data/image26.jpeg View File


Test_data/WhatsApp Image 2022-10-26 at 09.54.28 (1).jpeg → Test_data/image27.jpeg View File


Test_data/WhatsApp Image 2022-10-26 at 09.54.28.jpeg → Test_data/image28.jpeg View File


Test_data/WhatsApp Image 2022-10-26 at 09.54.16 (1).jpeg → Test_data/image3.jpeg View File


Test_data/WhatsApp Image 2022-10-26 at 09.54.16.jpeg → Test_data/image4.jpeg View File


Test_data/WhatsApp Image 2022-10-26 at 09.54.17.jpeg → Test_data/image5.jpeg View File


Test_data/WhatsApp Image 2022-10-26 at 09.54.18 (1).jpeg → Test_data/image6.jpeg View File


Test_data/WhatsApp Image 2022-10-26 at 09.54.18.jpeg → Test_data/image7.jpeg View File


Test_data/WhatsApp Image 2022-10-26 at 09.54.19 (1).jpeg → Test_data/image8.jpeg View File


Test_data/WhatsApp Image 2022-10-26 at 09.54.19.jpeg → Test_data/image9.jpeg View File


+ 10
- 2
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);

}

Loading…
Cancel
Save