|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #include "input.h"
-
- Input::Input(/* args */)
- {
- }
-
- Input::~Input()
- {
- }
-
- Mat Input::readFile(String filePath)
- {
- 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
- }
-
- return image;
- }
-
- Mat Input::readWebcam()
- {
- const int VID_HEIGHT = 240;
- const int VID_WIDTH = 320;
- Mat image;
- VideoCapture cap(0);
-
- cap.set(CAP_PROP_FRAME_HEIGHT, VID_HEIGHT);
- cap.set(CAP_PROP_FRAME_WIDTH, VID_WIDTH);
-
- if(!cap.isOpened()) {
- cout << "Fehler";
- return Mat();
- }
-
- cap.read(image);
-
- return image;
- }
|