#include "tinyxml.h"
#include <iostream>
#include <string>
#include <windows.h>
#include<vector>
#include<fstream>
#include<opencv2/opencv.hpp>
#include <time.h>
using namespace std;
using namespace cv;
int main()
{
srand((unsigned)time(NULL));
//data值全部存到out.txt里面 存的格式需要后续处理
ofstream outfile("out.txt");
//string filefullname = "D:\\openpose\\windows\\OpenPoseDemo\\image\\1.xml";
//const char* filepath = filefullname.c_str();;
//TiXmlDocument doc(filepath);
TiXmlDocument doc("D:\\openpose\\windows\\OpenPoseDemo\\image\\1.xml");
bool loadOkay = doc.LoadFile(TIXML_DEFAULT_ENCODING);
/*f (!loadOkay) {
printf("Could not load test file %s. Error='%s'. Exiting.\n", filepath, doc.ErrorDesc());
exit(1);
}*/
TiXmlElement* root = doc.RootElement();
for (TiXmlElement* elem = root->FirstChildElement(); elem != NULL; elem = elem->NextSiblingElement())
{
string elemName = elem->Value();
if (!elemName.compare("pose_0"))
{
for (TiXmlElement* pose_0elem = elem->FirstChildElement(); pose_0elem != NULL; pose_0elem = pose_0elem->NextSiblingElement())
{
string pose_0elemName = pose_0elem->Value();
if (!pose_0elemName.compare("data"))
{
TiXmlNode *e = pose_0elem->FirstChild();
const char *expr = e->ToText()->Value();
char *buf = new char[strlen(expr) + 1];
/* strcpy(buf, expr);
cout << expr << endl;*/
outfile << expr<<endl ;
}
}
}
}
ifstream infile("out.txt");
vector<float>datanums;
float keys;
while (infile >> keys)
{
datanums.push_back(keys);
}
float maxx = 0;
float maxy = 0;
for (int i = 0; i < datanums.size(); i++)
{
if (i % 3 == 0)
{
if (datanums[i]>maxx)
{
maxx= datanums[i];
}
}
if (i % 3 == 1)
{
if (datanums[i]>maxy)
{
maxy = datanums[i];
}
}
}
float minx=maxx;
float miny=maxy;
for (int i = 0; i < datanums.size(); i++)
{
if (i % 3 == 0)
{
if (datanums[i]<minx)
{
minx = datanums[i];
}
}
if (i % 3 == 1)
{
if (datanums[i]<miny)
{
miny = datanums[i];
}
}
}
Mat img = imread("D:\\openpose\\windows\\OpenPoseDemo\\image\\c_rendered.jpg");
float a = rand() % 11 * 2;
minx = minx -a ;//(rand() % 11 - 5) * 1.0
float b = rand() % 11 * 2;
miny = miny - b;
maxy = maxy + 40 + rand() % 11 * 2;
float c = rand() % 11 * 2;
maxx = maxx+rand() % 11 * 2;
float d= rand() % 11 *2;
cout << a << ' ' << b << ' ' << c << ' ' << d<<endl;
cout << maxx << ' ' << maxy << endl;
cout << minx << ' ' << miny << endl;
Rect bbox(minx, miny, maxx - minx, maxy - miny);
rectangle(img, bbox, cv::Scalar(255, 0, 0), 2);
imshow("bbox", img);
waitKey(0);
outfile.close();
return 0;
}
#include <iostream>
#include <string>
#include <windows.h>
#include<vector>
#include<fstream>
#include<opencv2/opencv.hpp>
#include <time.h>
using namespace std;
using namespace cv;
int main()
{
srand((unsigned)time(NULL));
//data值全部存到out.txt里面 存的格式需要后续处理
ofstream outfile("out.txt");
//string filefullname = "D:\\openpose\\windows\\OpenPoseDemo\\image\\1.xml";
//const char* filepath = filefullname.c_str();;
//TiXmlDocument doc(filepath);
TiXmlDocument doc("D:\\openpose\\windows\\OpenPoseDemo\\image\\1.xml");
bool loadOkay = doc.LoadFile(TIXML_DEFAULT_ENCODING);
/*f (!loadOkay) {
printf("Could not load test file %s. Error='%s'. Exiting.\n", filepath, doc.ErrorDesc());
exit(1);
}*/
TiXmlElement* root = doc.RootElement();
for (TiXmlElement* elem = root->FirstChildElement(); elem != NULL; elem = elem->NextSiblingElement())
{
string elemName = elem->Value();
if (!elemName.compare("pose_0"))
{
for (TiXmlElement* pose_0elem = elem->FirstChildElement(); pose_0elem != NULL; pose_0elem = pose_0elem->NextSiblingElement())
{
string pose_0elemName = pose_0elem->Value();
if (!pose_0elemName.compare("data"))
{
TiXmlNode *e = pose_0elem->FirstChild();
const char *expr = e->ToText()->Value();
char *buf = new char[strlen(expr) + 1];
/* strcpy(buf, expr);
cout << expr << endl;*/
outfile << expr<<endl ;
}
}
}
}
ifstream infile("out.txt");
vector<float>datanums;
float keys;
while (infile >> keys)
{
datanums.push_back(keys);
}
float maxx = 0;
float maxy = 0;
for (int i = 0; i < datanums.size(); i++)
{
if (i % 3 == 0)
{
if (datanums[i]>maxx)
{
maxx= datanums[i];
}
}
if (i % 3 == 1)
{
if (datanums[i]>maxy)
{
maxy = datanums[i];
}
}
}
float minx=maxx;
float miny=maxy;
for (int i = 0; i < datanums.size(); i++)
{
if (i % 3 == 0)
{
if (datanums[i]<minx)
{
minx = datanums[i];
}
}
if (i % 3 == 1)
{
if (datanums[i]<miny)
{
miny = datanums[i];
}
}
}
Mat img = imread("D:\\openpose\\windows\\OpenPoseDemo\\image\\c_rendered.jpg");
float a = rand() % 11 * 2;
minx = minx -a ;//(rand() % 11 - 5) * 1.0
float b = rand() % 11 * 2;
miny = miny - b;
maxy = maxy + 40 + rand() % 11 * 2;
float c = rand() % 11 * 2;
maxx = maxx+rand() % 11 * 2;
float d= rand() % 11 *2;
cout << a << ' ' << b << ' ' << c << ' ' << d<<endl;
cout << maxx << ' ' << maxy << endl;
cout << minx << ' ' << miny << endl;
Rect bbox(minx, miny, maxx - minx, maxy - miny);
rectangle(img, bbox, cv::Scalar(255, 0, 0), 2);
imshow("bbox", img);
waitKey(0);
outfile.close();
return 0;
}