As a C++ beginner, I am currently facing a problem I somehow can't solve, even if the code is pretty simple. I've been searching for answers all over the Internet, but none was applicable for my problem.
I am currently coding basic SVMs with C++, under VS2013, using OpenCV 2.4.8. I was able to work on images of same size, specifying fixed height, width at the beginning of my code.
Now, I'm trying to : open images of different sizes, resize them to a certain lower size, and apply the previous code to the now-resized dataset. Simple as that.
Here's the beginning of my code :
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/ml/ml.hpp>
#include <iostream>
#include <math.h>
#include <fstream>
#include <string>
#include <sstream>
#include <windows.h>
using namespace cv;
using namespace std;
int main(){
Input parameters are :
int Nb_Data_Class_1 = 10;
int Nb_Data_Class_0 = 5;
int Height_Zone = 200;
int Width_Zone = 200;
so I will resize all my files to 200x200 format.
string Path = "C:\\Users\\....";
string Format = ".jpg";
int Nb_Files = Nb_Data_Class_1 + Nb_Data_Class_0;
Mat TrainingMat(Nb_Files, Zone_Image, CV_32FC1);
Mat TrainingLabels(Nb_Files, 1, CV_32FC1);
For every file of the class labelled {1} - they are all named Tree01, Tree02, etc. - I open, and resize.
for (int i = 0; i < Nb_Data_Class_1; ++i)
{
stringstream ss;
ss << Path << "\\Tree0" << i + 1 << Format;
Mat Image = cv::imread(ss.str(), 0);
resize(Image, Image, Size(Width_Zone, Height_Zone));}
Things worked perfectly without the last line. I had a Mat array, filled with 0-t0-255 numbers. Now, I get the following error :
OpenCV Error: Assertion failed <ssize.area<> >0> in cv::resize,
file C:\builds\2-4-PackSlave-win32-vc12-shared\opencv\modules\imgproc\serc\imgwarp.cpp, line 1824
What could be the problem ? I thought that maybe OpenCV wasn't properly opening the files ; but, in that case, how everything could have been previously working ? Still wondering.
Any help would be much appreciated ! Thanks in advance.