Zufällige Bilderausgabe und binäres Bild(verbesserbar)
This commit is contained in:
+13
-7
@@ -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;
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
Reference in New Issue
Block a user