CommandLineParser modified

CommandLineParser modified
pull/276/head
Wangyida 10 years ago
parent 2563390a25
commit 97d835ec93
  1. 5
      modules/cnn_3dobj/README.md
  2. 3
      modules/cnn_3dobj/include/opencv2/cnn_3dobj.hpp
  3. 26
      modules/cnn_3dobj/samples/sphereview_3dobj_demo.cpp
  4. 10
      modules/cnn_3dobj/src/cnn_3dobj.cpp

@ -12,7 +12,8 @@ $ mkdir build
$ cd build
$ cmake ..
$ 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
float Z;
public:
std::vector<float> vertexNormalsList;
std::vector<float> vertexList;
std::vector<cv::Point3d> CameraPos;
std::vector<cv::Point3d> CameraPos_temp;
float radius;
float diff;
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.
*/

@ -42,13 +42,29 @@ using namespace cv;
using namespace std;
using namespace cv::cnn_3dobj;
int main(int argc, char *argv[]){
float radius = atof(argv[1]);
int ite_depth = argv[2][0] - '0';
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.}"
"{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);
std::vector<cv::Point3d> campos = ViewSphere.CameraPos;
std::fstream imglabel;
std::string plymodel = argv[3];
imglabel.open("../data/label_ape.txt");
char* p=(char*)labeldir.data();
imglabel.open(p);
//IcoSphere ViewSphere(16,0);
//std::vector<cv::Point3d>* campos = ViewSphere.CameraPos;
bool camera_pov = (true);
@ -100,7 +116,7 @@ int main(int argc, char *argv[]){
char* temp = new char;
sprintf (temp,"%d",pose);
string filename = temp;
filename = "../data/images_ape/" + filename;
filename = imagedir + filename;
filename += ".png";
myWindow.saveScreenshot(filename);
}

@ -13,7 +13,7 @@ namespace cv{ namespace cnn_3dobj{
int depth = depth_in;
X *= radius;
Z *= radius;
diff = 0.00000005964;
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 },
{ 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{
// Iterate over points
for (int i = 0; i < 20; ++i) {
subdivide(vdata[tindices[i][1]], vdata[tindices[i][2]],
vdata[tindices[i][3]], depth);
subdivide(vdata[tindices[i][0]], vdata[tindices[i][1]],
vdata[tindices[i][2]], depth);
}
CameraPos_temp.push_back(CameraPos[0]);
for (int j = 1; j<int(CameraPos.size()); j++)
{
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;
if(k == j-1)
CameraPos_temp.push_back(CameraPos[j]);
@ -114,6 +114,4 @@ namespace cv{ namespace cnn_3dobj{
subdivide(v3, v31, v23, depth - 1);
subdivide(v12, v23, v31, depth - 1);
}
}}

Loading…
Cancel
Save