diff --git a/modules/cnn_3dobj/samples/datagen_all.sh b/modules/cnn_3dobj/samples/datagen_all.sh index c8238db83..4ce98af64 100755 --- a/modules/cnn_3dobj/samples/datagen_all.sh +++ b/modules/cnn_3dobj/samples/datagen_all.sh @@ -82,9 +82,4 @@ ./sphereview_test -plymodel=/Users/yidawang/Downloads/PASCAL3D+_release1.1/CAD/train/01.ply -label_class=11 -label_item=1 -bakgrdir=/Users/yidawang/Documents/database/backgrd_pascal/train_pascal/ -z_range=0.2 ./sphereview_test -plymodel=/Users/yidawang/Downloads/PASCAL3D+_release1.1/CAD/train/02.ply -label_class=11 -label_item=2 -bakgrdir=/Users/yidawang/Documents/database/backgrd_pascal/train_pascal/ -z_range=0.2 ./sphereview_test -plymodel=/Users/yidawang/Downloads/PASCAL3D+_release1.1/CAD/train/03.ply -label_class=11 -label_item=3 -bakgrdir=/Users/yidawang/Documents/database/backgrd_pascal/train_pascal/ -z_range=0.2 -./sphereview_test -plymodel=/Users/yidawang/Downloads/PASCAL3D+_release1.1/CAD/train/04.ply -label_class=11 -label_item=4 -bakgrdir=/Users/yidawang/Documents/database/backgrd_pascal/train_pascal/ -z_range=0.2 - -./sphereview_test -plymodel=/Users/yidawang/Downloads/PASCAL3D+_release1.1/CAD/tvmonitor/01.ply -label_class=12 -label_item=1 -bakgrdir=/Users/yidawang/Documents/database/backgrd_pascal/tvmonitor_pascal/ -z_range=0.5 -./sphereview_test -plymodel=/Users/yidawang/Downloads/PASCAL3D+_release1.1/CAD/tvmonitor/02.ply -label_class=12 -label_item=2 -bakgrdir=/Users/yidawang/Documents/database/backgrd_pascal/tvmonitor_pascal/ -z_range=0.5 -./sphereview_test -plymodel=/Users/yidawang/Downloads/PASCAL3D+_release1.1/CAD/tvmonitor/03.ply -label_class=12 -label_item=3 -bakgrdir=/Users/yidawang/Documents/database/backgrd_pascal/tvmonitor_pascal/ -z_range=0.5 -./sphereview_test -plymodel=/Users/yidawang/Downloads/PASCAL3D+_release1.1/CAD/tvmonitor/04.ply -label_class=12 -label_item=4 -bakgrdir=/Users/yidawang/Documents/database/backgrd_pascal/tvmonitor_pascal/ -z_range=0.5 \ No newline at end of file +./sphereview_test -plymodel=/Users/yidawang/Downloads/PASCAL3D+_release1.1/CAD/train/04.ply -label_class=11 -label_item=4 -bakgrdir=/Users/yidawang/Documents/database/backgrd_pascal/train_pascal/ -z_range=0.2 \ No newline at end of file diff --git a/modules/cnn_3dobj/samples/datagen_front.sh b/modules/cnn_3dobj/samples/datagen_front.sh index 43bffb182..e3d8b5184 100755 --- a/modules/cnn_3dobj/samples/datagen_front.sh +++ b/modules/cnn_3dobj/samples/datagen_front.sh @@ -16,7 +16,6 @@ ./sphereview_test -plymodel=/Users/yidawang/Downloads/PASCAL3D+_release1.1/CAD/boat/01.ply -label_class=3 -label_item=1 -bakgrdir=/Users/yidawang/Documents/database/backgrd_pascal/boat_pascal/ -z_range=0.6 -front_view=1 ./sphereview_test -plymodel=/Users/yidawang/Downloads/PASCAL3D+_release1.1/CAD/boat/02.ply -label_class=3 -label_item=2 -bakgrdir=/Users/yidawang/Documents/database/backgrd_pascal/boat_pascal/ -z_range=0.6 -front_view=1 -./sphereview_test -plymodel=/Users/yidawang/Downloads/PASCAL3D+_release1.1/CAD/boat/03.ply -label_class=3 -label_item=3 -bakgrdir=/Users/yidawang/Documents/database/backgrd_pascal/boat_pascal/ -z_range=0.6 -front_view=1 ./sphereview_test -plymodel=/Users/yidawang/Downloads/PASCAL3D+_release1.1/CAD/boat/04.ply -label_class=3 -label_item=4 -bakgrdir=/Users/yidawang/Documents/database/backgrd_pascal/boat_pascal/ -z_range=0.6 -front_view=1 ./sphereview_test -plymodel=/Users/yidawang/Downloads/PASCAL3D+_release1.1/CAD/boat/05.ply -label_class=3 -label_item=5 -bakgrdir=/Users/yidawang/Documents/database/backgrd_pascal/boat_pascal/ -z_range=0.6 -front_view=1 ./sphereview_test -plymodel=/Users/yidawang/Downloads/PASCAL3D+_release1.1/CAD/boat/06.ply -label_class=3 -label_item=6 -bakgrdir=/Users/yidawang/Documents/database/backgrd_pascal/boat_pascal/ -z_range=0.6 -front_view=1 @@ -48,4 +47,9 @@ ./sphereview_test -plymodel=/Users/yidawang/Downloads/PASCAL3D+_release1.1/CAD/train/01.ply -label_class=11 -label_item=1 -bakgrdir=/Users/yidawang/Documents/database/backgrd_pascal/train_pascal/ -z_range=0.2 -front_view=1 ./sphereview_test -plymodel=/Users/yidawang/Downloads/PASCAL3D+_release1.1/CAD/train/02.ply -label_class=11 -label_item=2 -bakgrdir=/Users/yidawang/Documents/database/backgrd_pascal/train_pascal/ -z_range=0.2 -front_view=1 ./sphereview_test -plymodel=/Users/yidawang/Downloads/PASCAL3D+_release1.1/CAD/train/03.ply -label_class=11 -label_item=3 -bakgrdir=/Users/yidawang/Documents/database/backgrd_pascal/train_pascal/ -z_range=0.2 -front_view=1 -./sphereview_test -plymodel=/Users/yidawang/Downloads/PASCAL3D+_release1.1/CAD/train/04.ply -label_class=11 -label_item=4 -bakgrdir=/Users/yidawang/Documents/database/backgrd_pascal/train_pascal/ -z_range=0.2 -front_view=1 \ No newline at end of file +./sphereview_test -plymodel=/Users/yidawang/Downloads/PASCAL3D+_release1.1/CAD/train/04.ply -label_class=11 -label_item=4 -bakgrdir=/Users/yidawang/Documents/database/backgrd_pascal/train_pascal/ -z_range=0.2 -front_view=1 + +./sphereview_test -plymodel=/Users/yidawang/Downloads/PASCAL3D+_release1.1/CAD/tvmonitor/01.ply -label_class=12 -label_item=1 -bakgrdir=/Users/yidawang/Documents/database/backgrd_pascal/tvmonitor_pascal/ -z_range=0.3 -front_view=1 +./sphereview_test -plymodel=/Users/yidawang/Downloads/PASCAL3D+_release1.1/CAD/tvmonitor/02.ply -label_class=12 -label_item=2 -bakgrdir=/Users/yidawang/Documents/database/backgrd_pascal/tvmonitor_pascal/ -z_range=0.3 -front_view=1 +./sphereview_test -plymodel=/Users/yidawang/Downloads/PASCAL3D+_release1.1/CAD/tvmonitor/03.ply -label_class=12 -label_item=3 -bakgrdir=/Users/yidawang/Documents/database/backgrd_pascal/tvmonitor_pascal/ -z_range=0.3 -front_view=1 +./sphereview_test -plymodel=/Users/yidawang/Downloads/PASCAL3D+_release1.1/CAD/tvmonitor/04.ply -label_class=12 -label_item=4 -bakgrdir=/Users/yidawang/Documents/database/backgrd_pascal/tvmonitor_pascal/ -z_range=0.3 -front_view=1 \ No newline at end of file diff --git a/modules/cnn_3dobj/samples/demo_sphereview_data.cpp b/modules/cnn_3dobj/samples/demo_sphereview_data.cpp index 836758783..c9bdebb8f 100755 --- a/modules/cnn_3dobj/samples/demo_sphereview_data.cpp +++ b/modules/cnn_3dobj/samples/demo_sphereview_data.cpp @@ -130,8 +130,11 @@ int main(int argc, char *argv[]) double obj_dist, bg_dist, y_range; if (front_view) { + if (label_class == 12) + obj_dist = 340; + else + obj_dist = 240; ite_depth = ite_depth + 1; - obj_dist = 240; bg_dist = 700; y_range = 0.85; } @@ -193,8 +196,6 @@ int main(int argc, char *argv[]) /* Set background color. */ myWindow.setBackgroundColor(viz::Color::gray()); myWindow.spin(); - /* Add light. */ - //myWindow.addLight(Vec3d(0,0,100000), Vec3d(0,0,0), viz::Color::white(), viz::Color::gray(), viz::Color::black(), viz::Color::white()); /* Create a Mesh widget, loading .ply models. */ viz::Mesh objmesh = viz::Mesh::load(plymodel); /* Get the center of the generated mesh widget, cause some .ply files, this could be ignored if you are using PASCAL database*/ @@ -235,6 +236,11 @@ int main(int argc, char *argv[]) { cnt_img = 0; for(int pose = 0; pose < static_cast(campos.size()); pose++){ + /* Add light. */ + // double alpha1 = rand()%(314/2)/100; + // double alpha2 = rand()%(314*2)/100; + // printf("%f %f %f/n", ceil(10000*sqrt(1 - sin(alpha1)*sin(alpha1))*sin(alpha2)), 10000*sqrt(1 - sin(alpha1)*sin(alpha1))*cos(alpha2), sin(alpha1)*10000); + // myWindow.addLight(Vec3d(10000*sqrt(1 - sin(alpha1)*sin(alpha1))*sin(alpha2),10000*sqrt(1 - sin(alpha1)*sin(alpha1))*cos(alpha2),sin(alpha1)*10000), Vec3d(0,0,0), viz::Color::white(), viz::Color::white(), viz::Color::black(), viz::Color::white()); int label_x, label_y, label_z; label_x = static_cast(campos.at(pose).x*100); label_y = static_cast(campos.at(pose).y*100); @@ -245,6 +251,10 @@ int main(int argc, char *argv[]) imglabel << filename << ' ' << label_class << endl; filename = imagedir + filename; /* Get the pose of the camera using makeCameraPoses. */ + if (front_view) + { + cam_focal_point.y = cam_focal_point.y - label_x/30; + } Affine3f cam_pose = viz::makeCameraPose(campos.at(pose)*obj_dist+cam_focal_point, cam_focal_point, cam_y_dir*obj_dist+cam_focal_point); /* Get the transformation matrix from camera coordinate system to global. */ Affine3f transform = viz::makeTransformToGlobal(Vec3f(1.0f,0.0f,0.0f), Vec3f(0.0f,1.0f,0.0f), Vec3f(0.0f,0.0f,1.0f), campos.at(pose));