// DPMSample.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
using namespace std;
using namespace cv;
vector<string> split(string str,string pattern);
int _tmain(int argc, _TCHAR* argv[])
{
ifstream data("list.txt");
ofstream new_txt;
new_txt.open("DATA-MODEL-all.txt",ios::app|ios::out);
string buf;
while(data)
{
if(getline(data,buf))
{
Mat img;
img=imread(buf);
char result[500];
sprintf(result,"%d %d %d %d %s",1,1,img.cols-1,img.rows-1,buf.c_str());
new_txt<<result<<endl;
}
}
new_txt.close();
return 0;
}
//字符串分割函数//
vector<string> split(string str,string pattern)
{
string::size_type pos;
vector<string> result;
str+=pattern;//扩展字符串以方便操作//
int size=str.size();
for(int i=0; i<size; i++)
{
pos=str.find(pattern,i);
if(pos<size)
{
string s=str.substr(i,pos-i);
result.push_back(s);
i=pos+pattern.size()-1;
}
}
return result;
}
//
#include "stdafx.h"
#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
using namespace std;
using namespace cv;
vector<string> split(string str,string pattern);
int _tmain(int argc, _TCHAR* argv[])
{
ifstream data("list.txt");
ofstream new_txt;
new_txt.open("DATA-MODEL-all.txt",ios::app|ios::out);
string buf;
while(data)
{
if(getline(data,buf))
{
Mat img;
img=imread(buf);
char result[500];
sprintf(result,"%d %d %d %d %s",1,1,img.cols-1,img.rows-1,buf.c_str());
new_txt<<result<<endl;
}
}
new_txt.close();
return 0;
}
//字符串分割函数//
vector<string> split(string str,string pattern)
{
string::size_type pos;
vector<string> result;
str+=pattern;//扩展字符串以方便操作//
int size=str.size();
for(int i=0; i<size; i++)
{
pos=str.find(pattern,i);
if(pos<size)
{
string s=str.substr(i,pos-i);
result.push_back(s);
i=pos+pattern.size()-1;
}
}
return result;
}