#include
<opencv\cv.h>
#include
<string>
#include
<vector>
#include
<io.h>
#include
<iostream>
#include
<fstream>
#include
<opencv2\highgui\highgui.hpp>
#include
<opencv2\core\core.hpp>
#include
<opencv2\imgproc\imgproc.hpp>
//#include <opencv2\imgcodecs.hpp>
//#include <opencv2\core\base.hpp>
using
namespace
std;
using
namespace
cv;
void
getFiles(string path, vector<string>& files)
{
struct
_finddata_t fileinfo;
string str;
long
fileHandle = _findfirst(str.assign(path).append(
"/*"
).c_str(), &fileinfo);
if
(fileHandle == -1){
return
;
}
while
(!_findnext(fileHandle, &fileinfo)){
if
((fileinfo.attrib & _A_SUBDIR))
{
if
(strcmp(fileinfo.name,
"."
) != 0 && strcmp(fileinfo.name,
".."
) != 0)
getFiles(str.assign(path).append(
"/"
).append(fileinfo.name), files);
}
else
{
files.push_back(str.assign(path).append(
"/"
).append(fileinfo.name));
}
}
_findclose(fileHandle);
}
int
main(
int
argc,
char
** argv)
{
ofstream in;
in.open(
"svmTrainSet2.txt"
,ios::trunc);
// turn to creat the name of txt
char
* filePath =
"E:/opencv_study/HOG+SVM/code/hat_background/Image/001"
;//the adress of pictrue
vector<std::string> files;
getFiles(filePath, files);
int
size = files.size();
for
(
int
i = 0; i < size; i++)
{
//cout << files[i].c_str() << endl;
Mat img = imread(files[i].c_str());
if
(img.empty())
{
cout <<
"Cannot get image "
<< files[i].c_str() << endl;
getchar();
//return -2;
}
else
{
cout <<
"get image: "
<< files[i].c_str() << endl;
in<<files[i].c_str()<<
"\n"
;
in<<
"0"
<<
"\n"
;
}
}
}
算法以及图像处理交流群:305606122,加群时请回答以下两个数组卷积结果
A[3][3]
B[3][3]