source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/LearningCode/Debug/COneShot3dEfficient.cpp @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 5.0 KB
Line 
1/*
2% *  This code was used in the following articles:
3% *  [1] Learning 3-D Scene Structure from a Single Still Image,
4% *      Ashutosh Saxena, Min Sun, Andrew Y. Ng,
5% *      In ICCV workshop on 3D Representation for Recognition (3dRR-07), 2007.
6% *      (best paper)
7% *  [2] 3-D Reconstruction from Sparse Views using Monocular Vision,
8% *      Ashutosh Saxena, Min Sun, Andrew Y. Ng,
9% *      In ICCV workshop on Virtual Representations and Modeling
10% *      of Large-scale environments (VRML), 2007.
11% *  [3] 3-D Depth Reconstruction from a Single Still Image,
12% *      Ashutosh Saxena, Sung H. Chung, Andrew Y. Ng.
13% *      International Journal of Computer Vision (IJCV), Aug 2007.
14% *  [6] Learning Depth from Single Monocular Images,
15% *      Ashutosh Saxena, Sung H. Chung, Andrew Y. Ng.
16% *      In Neural Information Processing Systems (NIPS) 18, 2005.
17% *
18% *  These articles are available at:
19% *  http://make3d.stanford.edu/publications
20% *
21% *  We request that you cite the papers [1], [3] and [6] in any of
22% *  your reports that uses this code.
23% *  Further, if you use the code in image3dstiching/ (multiple image version),
24% *  then please cite [2].
25% * 
26% *  If you use the code in third_party/, then PLEASE CITE and follow the
27% *  LICENSE OF THE CORRESPONDING THIRD PARTY CODE.
28% *
29% *  Finally, this code is for non-commercial use only.  For further
30% *  information and to obtain a copy of the license, see
31% *
32% *  http://make3d.stanford.edu/publications/code
33% *
34% *  Also, the software distributed under the License is distributed on an
35% * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
36% *  express or implied.   See the License for the specific language governing
37% *  permissions and limitations under the License.
38% *
39% */
40////////////////////////////////////////////////////////////////////////
41//
42// COneShot3d.cpp
43//
44// This is the core View3 OpenCV program. The program reads an
45// image from a file, created a wrl file and stores the result.
46//
47////////////////////////////////////////////////////////////////////////
48#include <stdlib.h>
49#include <stdio.h>
50#include <math.h>
51#include <cv.h>
52#include <highgui.h>
53#include <COneShot3d.h>
54
55#define IN_IMAGE        argv[1]
56#define IN_ImgPath              argv[2]
57#define IN_OutPutFolder         argv[3]
58#define IN_ScratchFolder        argv[4]
59#define IN_taskName     argv[5]
60#define IN_DepthPara    argv[6]
61#define IN_VarPara              argv[7]
62#define IN_GroundSkyPara        argv[8]
63#define IN_FeaPara              argv[9]
64#define IN_SFeaPara     argv[10]
65
66#if !defined(MAX)
67#define MAX(A, B)       ((A) > (B) ? (A) : (B))
68#endif
69
70#if !defined(MIN)
71#define MIN(A, B)       ((A) < (B) ? (A) : (B))
72#endif
73
74
75int main(int argc, char *argv[])
76{
77  IplImage* img = 0; 
78  int height,width,step,channels;
79  uchar *data;
80  double *MedSup;
81  double *Sup;
82  int i,j,k;i
83  bool evalScratchFlag=0;
84
85  if(argc<2){
86    printf("Usage: main <image-file-name>\n\7");
87    exit(0);
88  }
89
90  // load an image 
91  img=cvLoadImage(argv[1]);
92  if(!img){
93    printf("Could not load image file: %s\n",argv[1]);
94    exit(0);
95  }
96
97  // get the image data
98  height    = img->height;
99  width     = img->width;
100  step      = img->widthStep;
101  channels  = img->nChannels;
102  data      = (uchar *)img->imageData;
103  printf("Processing a %dx%d image with %d channels\n",height,width,channels); 
104
105  // Set Default parametersi
106  if (IN_ScratchFolder == '')
107     evalScratchFlag = 1;
108 
109  void DefaultParaValues::setFolderNames(char *taskName,
110                  char *DepthPara,
111                  char *VarPara,
112                  char *GroundSkyPara,
113                  bool ScratchFlag,
114                  char *SFeaPara,
115                  char *FeaPara) {taskName=IN_taskName;
116                                  DepthPara=IN_DepthPara;
117                                  VarPara=IN_VarPara;
118                                  IN_GroundSkyPara=GroundSkyPara;
119                                  ScratchFlag=evalScratchFlag;
120                                  SFeaPara=IN_SFeaPara;
121                                  FeaPara=IN_FeaPara;}
122
123/*
124  // create a window
125  cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE);
126  cvMoveWindow("mainWin", 100, 100);
127
128  // show the image
129  cvShowImage("mainWin", img );
130*/ 
131 
132 /*
133
134 // invert the image
135  for(i=0;i<height;i++) for(j=0;j<width;j++) for(k=0;k<channels;k++)
136    data[i*step+j*channels+k]=255-data[i*step+j*channels+k];
137 */
138
139//% ***************************************************
140
141//% Features ===========================================
142
143//  % 1) Basic Superpixel generation and Sup clean
144    Cgen_Sup_efficient(MedSup, Sup, DefaultParaValues, img);
145
146//  % 2) Texture Features and inner multiple Sups generation
147
148//  % 3) Superpixel Features generation
149
150
151//% Inference ==========================================
152
153//  % 1) Generate Ground and Sky mask
154
155//  % 2) Clean Sup{1} (1st Scale) according to the sky mask
156
157//  % 3) Generate predicted (depth:1 Variance:2 )
158
159//  % 4) Plane Parameter MRF
160
161//% ***************************************************
162
163
164  // wait for a key
165  cvWaitKey(0);
166
167  // release the image
168  cvReleaseImage(&img );
169  return 0;
170}
Note: See TracBrowser for help on using the repository browser.