Commit 97d835ec authored by Wangyida's avatar Wangyida

CommandLineParser modified

CommandLineParser modified
parent 2563390a
...@@ -12,7 +12,8 @@ $ mkdir build ...@@ -12,7 +12,8 @@ $ mkdir build
$ cd build $ cd build
$ cmake .. $ cmake ..
$ make $ make
$ ./sphereview_test 350 2 ../ape.ply $ ./sphereview_test -radius=350 -ite_depth=1 -plymodel=../ape.ply -imagedir=../data/images_ape/
============================================== ==============================================
Then press 'q' to run the demo for images generation, parameter '350' represent the radius of the sphere and '2' stand for the depth of the sphere building iteration and '../ape.ply' represent the .ply model demo :$ ./sphereview_test -radius=350 -ite_depth=1 -plymodel=../ape.ply -imagedir=../data/images_ape/
Then press 'q' to run the demo for images generation when you see the gray background and a coordinate.
============================================== ==============================================
...@@ -76,13 +76,12 @@ class CV_EXPORTS_W IcoSphere ...@@ -76,13 +76,12 @@ class CV_EXPORTS_W IcoSphere
float Z; float Z;
public: public:
std::vector<float> vertexNormalsList; std::vector<float> vertexNormalsList;
std::vector<float> vertexList; std::vector<float> vertexList;
std::vector<cv::Point3d> CameraPos; std::vector<cv::Point3d> CameraPos;
std::vector<cv::Point3d> CameraPos_temp; std::vector<cv::Point3d> CameraPos_temp;
float radius; float radius;
float diff;
IcoSphere(float radius_in, int depth_in); IcoSphere(float radius_in, int depth_in);
/** @brief Make all view points having the some distance from the focal point used by the camera view. /** @brief Make all view points having the some distance from the focal point used by the camera view.
*/ */
......
...@@ -42,13 +42,29 @@ using namespace cv; ...@@ -42,13 +42,29 @@ using namespace cv;
using namespace std; using namespace std;
using namespace cv::cnn_3dobj; using namespace cv::cnn_3dobj;
int main(int argc, char *argv[]){ int main(int argc, char *argv[]){
float radius = atof(argv[1]); const String keys = "{help | | demo :$ ./sphereview_test -radius=350 -ite_depth=1 -plymodel=../ape.ply -imagedir=../data/images_ape/ -labeldir=../data/label_ape.txt, then press 'q' to run the demo for images generation when you see the gray background and a coordinate.}"
int ite_depth = argv[2][0] - '0'; "{radius | 350 | Distanse from camera to object, used for adjust view for the reason that differet scale of .ply model.}"
"{ite_depth | 1 | Iteration of sphere generation, we add points on the middle of lines of sphere and adjust the radius suit for the original radius.}"
"{plymodel | ../ape.ply | path of the '.ply' file for image rendering. }"
"{imagedir | ../data/images_ape/ | path of the generated images for one particular .ply model. }"
"{labeldir | ../data/label_ape.txt | path of the generated images for one particular .ply model. }";
cv::CommandLineParser parser(argc, argv, keys);
parser.about("Demo for Sphere View data generation");
if (parser.has("help"))
{
parser.printMessage();
return 0;
}
float radius = parser.get<float>("radius");
int ite_depth = parser.get<int>("ite_depth");
string plymodel = parser.get<string>("plymodel");
string imagedir = parser.get<string>("imagedir");
string labeldir = parser.get<string>("labeldir");
cv::cnn_3dobj::IcoSphere ViewSphere(10,ite_depth); cv::cnn_3dobj::IcoSphere ViewSphere(10,ite_depth);
std::vector<cv::Point3d> campos = ViewSphere.CameraPos; std::vector<cv::Point3d> campos = ViewSphere.CameraPos;
std::fstream imglabel; std::fstream imglabel;
std::string plymodel = argv[3]; char* p=(char*)labeldir.data();
imglabel.open("../data/label_ape.txt"); imglabel.open(p);
//IcoSphere ViewSphere(16,0); //IcoSphere ViewSphere(16,0);
//std::vector<cv::Point3d>* campos = ViewSphere.CameraPos; //std::vector<cv::Point3d>* campos = ViewSphere.CameraPos;
bool camera_pov = (true); bool camera_pov = (true);
...@@ -100,7 +116,7 @@ int main(int argc, char *argv[]){ ...@@ -100,7 +116,7 @@ int main(int argc, char *argv[]){
char* temp = new char; char* temp = new char;
sprintf (temp,"%d",pose); sprintf (temp,"%d",pose);
string filename = temp; string filename = temp;
filename = "../data/images_ape/" + filename; filename = imagedir + filename;
filename += ".png"; filename += ".png";
myWindow.saveScreenshot(filename); myWindow.saveScreenshot(filename);
} }
......
...@@ -13,7 +13,7 @@ namespace cv{ namespace cnn_3dobj{ ...@@ -13,7 +13,7 @@ namespace cv{ namespace cnn_3dobj{
int depth = depth_in; int depth = depth_in;
X *= radius; X *= radius;
Z *= radius; Z *= radius;
diff = 0.00000005964;
float vdata[12][3] = { { -X, 0.0f, Z }, { X, 0.0f, Z }, float vdata[12][3] = { { -X, 0.0f, Z }, { X, 0.0f, Z },
{ -X, 0.0f, -Z }, { X, 0.0f, -Z }, { 0.0f, Z, X }, { 0.0f, Z, -X }, { -X, 0.0f, -Z }, { X, 0.0f, -Z }, { 0.0f, Z, X }, { 0.0f, Z, -X },
{ 0.0f, -Z, X }, { 0.0f, -Z, -X }, { Z, X, 0.0f }, { -Z, X, 0.0f }, { 0.0f, -Z, X }, { 0.0f, -Z, -X }, { Z, X, 0.0f }, { -Z, X, 0.0f },
...@@ -32,15 +32,15 @@ namespace cv{ namespace cnn_3dobj{ ...@@ -32,15 +32,15 @@ namespace cv{ namespace cnn_3dobj{
// Iterate over points // Iterate over points
for (int i = 0; i < 20; ++i) { for (int i = 0; i < 20; ++i) {
subdivide(vdata[tindices[i][1]], vdata[tindices[i][2]], subdivide(vdata[tindices[i][0]], vdata[tindices[i][1]],
vdata[tindices[i][3]], depth); vdata[tindices[i][2]], depth);
} }
CameraPos_temp.push_back(CameraPos[0]); CameraPos_temp.push_back(CameraPos[0]);
for (int j = 1; j<int(CameraPos.size()); j++) for (int j = 1; j<int(CameraPos.size()); j++)
{ {
for (int k = 0; k<j; k++) for (int k = 0; k<j; k++)
{ {
if (CameraPos.at(k).x==CameraPos.at(j).x && CameraPos.at(k).y==CameraPos.at(j).y && CameraPos.at(k).z==CameraPos.at(j).z) if (CameraPos.at(k).x-CameraPos.at(j).x<diff && CameraPos.at(k).y-CameraPos.at(j).y<diff && CameraPos.at(k).z-CameraPos.at(j).z<diff)
break; break;
if(k == j-1) if(k == j-1)
CameraPos_temp.push_back(CameraPos[j]); CameraPos_temp.push_back(CameraPos[j]);
...@@ -114,6 +114,4 @@ namespace cv{ namespace cnn_3dobj{ ...@@ -114,6 +114,4 @@ namespace cv{ namespace cnn_3dobj{
subdivide(v3, v31, v23, depth - 1); subdivide(v3, v31, v23, depth - 1);
subdivide(v12, v23, v31, depth - 1); subdivide(v12, v23, v31, depth - 1);
} }
}} }}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment