title: Error C1083 Cannot open include file: 'stdafx.h': No such file or directory
body: <p>I am new to visual studio.I have created a simple console application and then selected an empty project of c++.Then pasted the following code </p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;cstdio&gt;
  #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include "opencv2/core/core.hpp"
  #include "opencv2/imgproc/imgproc.hpp"
  #include "opencv2/calib3d/calib3d.hpp"
  #include "opencv2/highgui/highgui.hpp"
  #include &lt;vector&gt;
  #include "GL/glut.h"      
  #include "GL/glu.h"    
  #include "GL/gl.h"   
  #include &lt;math.h&gt;
  #include &lt;time.h&gt;
  
  using namespace std;
  using namespace cv;
  
  const float zNear = 0.05;
  const float zFar = 500.0;
  int width, height;
  int draw = 0;
  Point FIX_X(0, 0), FIX_Y(0, 0), FIX_Z(0, 0);
  float skew_x, skew_y, skew_z;
  VideoCapture cap(0);
  Mat tmp, test;
  Mat intrinsic_Matrix(3, 3, CV_64F);
  Mat distortion_coeffs(8, 1, CV_64F);
  Mat Projection(4, 4, CV_64FC1);
  double largest_area;
  int largest_contour_index;
  int n = 0;
  int no_of_fingers = 0;
  vector&lt;vector&lt;pair&lt;float, Point&gt;&gt;&gt; position;
  vector&lt;int&gt; finger_count;
  Point first, second, third;
  float size_of_pot = 10;
  int rot_angle = 10;
  
  float distanceP2P(Point a, Point b) {
      float d = sqrt(fabs(pow(a.x - b.x, 2) + pow(a.y - b.y, 2)));
      return d;
  }
  float getAngle(Point s, Point f, Point e) {
      float l1 = distanceP2P(f, s);
      float l2 = distanceP2P(f, e);
      float dot = (s.x - f.x)*(e.x - f.x) + (s.y - f.y)*(e.y - f.y);
      float angle = acos(dot / (l1*l2));
      angle = angle * 180 / 3.147;
      return angle;
  }
  
  
  String intToString(int number) {
      stringstream ss;
      ss &lt;&lt; number;
      string str = ss.str();
      return str;
  }
  
  bool pairCompare(const pair&lt;float, Point&gt;&amp;i, const pair&lt;float, Point&gt;&amp;j) {
      return i.first &lt;j.first;
  
  }
  
  GLfloat* convertMatrixType(const cv::Mat&amp; m)
  {
      typedef double precision;
  
      Size s = m.size();
      GLfloat* mGL = new GLfloat[s.width*s.height];
  
      for (int ix = 0; ix &lt; s.width; ix++)
      {
          for (int iy = 0; iy &lt; s.height; iy++)
          {
              mGL[ix*s.height + iy] = m.at&lt;precision&gt;(iy, ix);
          }
      }
  
      return mGL;
  }
  
  void generateProjectionModelview(const cv::Mat&amp; calibration, const cv::Mat&amp; rotation, const cv::Mat&amp; translation, cv::Mat&amp; projection, cv::Mat&amp; modelview)
  {
      typedef double precision;
  
      projection.at&lt;precision&gt;(0, 0) = 2 * calibration.at&lt;precision&gt;(0, 0) / width;
      projection.at&lt;precision&gt;(1, 0) = 0;
      projection.at&lt;precision&gt;(2, 0) = 0;
      projection.at&lt;precision&gt;(3, 0) = 0;
  
      projection.at&lt;precision&gt;(0, 1) = 0;
      projection.at&lt;precision&gt;(1, 1) = 2 * calibration.at&lt;precision&gt;(1, 1) / height;
      projection.at&lt;precision&gt;(2, 1) = 0;
      projection.at&lt;precision&gt;(3, 1) = 0;
  
      projection.at&lt;precision&gt;(0, 2) = 1 - 2 * calibration.at&lt;precision&gt;(0, 2) / width;
      projection.at&lt;precision&gt;(1, 2) = -1 + (2 * calibration.at&lt;precision&gt;(1, 2) + 2) / height;
      projection.at&lt;precision&gt;(2, 2) = (zNear + zFar) / (zNear - zFar);
      projection.at&lt;precision&gt;(3, 2) = -1;
  
      projection.at&lt;precision&gt;(0, 3) = 0;
      projection.at&lt;precision&gt;(1, 3) = 0;
      projection.at&lt;precision&gt;(2, 3) = 2 * zNear*zFar / (zNear - zFar);
      projection.at&lt;precision&gt;(3, 3) = 0;
  
  
      modelview.at&lt;precision&gt;(0, 0) = rotation.at&lt;precision&gt;(0, 0);
      modelview.at&lt;precision&gt;(1, 0) = rotation.at&lt;precision&gt;(1, 0);
      modelview.at&lt;precision&gt;(2, 0) = rotation.at&lt;precision&gt;(2, 0);
      modelview.at&lt;precision&gt;(3, 0) = 0;
  
      modelview.at&lt;precision&gt;(0, 1) = rotation.at&lt;precision&gt;(0, 1);
      modelview.at&lt;precision&gt;(1, 1) = rotation.at&lt;precision&gt;(1, 1);
      modelview.at&lt;precision&gt;(2, 1) = rotation.at&lt;precision&gt;(2, 1);
      modelview.at&lt;precision&gt;(3, 1) = 0;
  
      modelview.at&lt;precision&gt;(0, 2) = rotation.at&lt;precision&gt;(0, 2);
      modelview.at&lt;precision&gt;(1, 2) = rotation.at&lt;precision&gt;(1, 2);
      modelview.at&lt;precision&gt;(2, 2) = rotation.at&lt;precision&gt;(2, 2);
      modelview.at&lt;precision&gt;(3, 2) = 0;
  
      modelview.at&lt;precision&gt;(0, 3) = translation.at&lt;precision&gt;(0, 0);
      modelview.at&lt;precision&gt;(1, 3) = translation.at&lt;precision&gt;(1, 0);
      modelview.at&lt;precision&gt;(2, 3) = translation.at&lt;precision&gt;(2, 0);
      modelview.at&lt;precision&gt;(3, 3) = 1;
  
      // This matrix corresponds to the change of coordinate systems.
      static double changeCoordArray[4][4] = { { 1, 0, 0, 0 },{ 0, -1, 0, 0 },{ 0, 0, -1, 0 },{ 0, 0, 0, 1 } };
      static Mat changeCoord(4, 4, CV_64FC1, changeCoordArray);
  
      modelview = changeCoord*modelview;
  }
  
  
  void calibrate(Mat &amp;intrinsic_Matrix, Mat &amp;distortion_coeffs)
  {
  
      vector&lt; vector&lt; Point2f&gt; &gt; AllimagePoints;
      vector&lt; vector&lt; Point3f&gt; &gt; AllobjectPoints;
      char str[100];
      stringstream st;
      int no_of_images = 1;
      Size imagesize;
      Mat gray;
      while (no_of_images &lt;= 14)
      {
          st &lt;&lt; "E:/SelectedImages/Selected" &lt;&lt; ++no_of_images &lt;&lt; ".jpg";
          String strcopy3 = st.str();
          st.str("");
          Mat img = imread(strcopy3, 1);
          if (!img.data)
              break;
          imagesize = Size(img.rows, img.cols);
          cvtColor(img, gray, CV_RGB2GRAY);
          vector&lt; Point2f&gt; corners;
          bool sCorner = false;
          sCorner = findChessboardCorners(gray, Size(7, 7), corners);
          if (sCorner)
          {
  
              cornerSubPix(gray, corners, Size(11, 11), Size(-1, -1), TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
              drawChessboardCorners(img, Size(7, 7), corners, sCorner);
              if (corners.size() == 7 * 7)
              {
                  vector&lt; Point2f&gt; v_tImgPT;
                  vector&lt; Point3f&gt; v_tObjPT;
                  for (int j = 0; j&lt; corners.size(); ++j)
                  {
                      Point2f tImgPT;
                      Point3f tObjPT;
  
                      tImgPT.x = corners[j].x;
                      tImgPT.y = corners[j].y;
  
                      tObjPT.x = j % 7 * 3;
                      tObjPT.y = j / 7 * 3;
                      tObjPT.z = 0;
  
                      v_tImgPT.push_back(tImgPT);
                      v_tObjPT.push_back(tObjPT);
                  }
                  AllimagePoints.push_back(v_tImgPT);
                  AllobjectPoints.push_back(v_tObjPT);
              }
  
          }
          st &lt;&lt; "E:/DetectedImages/Detected" &lt;&lt; no_of_images + 1 &lt;&lt; ".jpg";
          String strcopy1 = st.str();
          st.str("");
          imwrite(strcopy1, img);
          //imshow("pattern",img);
          //cvWaitKey(30);
      }
      vector&lt; Mat&gt; rvecs, tvecs;
      if (AllimagePoints.size()&gt;0)
      {
          calibrateCamera(AllobjectPoints, AllimagePoints, imagesize, intrinsic_Matrix, distortion_coeffs, rvecs, tvecs);
      }
  
  }
  
  
  void renderBackgroundGL(const cv::Mat&amp; image)
  {
  
      GLint polygonMode[2];
      glGetIntegerv(GL_POLYGON_MODE, polygonMode);
      glPolygonMode(GL_FRONT, GL_FILL);
      glPolygonMode(GL_BACK, GL_FILL);
  
  
      glLoadIdentity();
      gluOrtho2D(0.0, 1.0, 0.0, 1.0);
  
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
  
  
      static bool textureGenerated = false;
      static GLuint textureId;
      if (!textureGenerated)
      {
          glGenTextures(1, &amp;textureId);
  
          glBindTexture(GL_TEXTURE_2D, textureId);
          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  
          textureGenerated = true;
      }
  
      // Copy the image to the texture.
      glBindTexture(GL_TEXTURE_2D, textureId);
      glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.size().width, image.size().height, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, image.data);
  
      // Draw the image.
      glEnable(GL_TEXTURE_2D);
      glBegin(GL_TRIANGLES);
      glNormal3f(0.0, 0.0, 1.0);
  
      glTexCoord2f(0.0, 1.0);
      glVertex3f(0.0, 0.0, 0.0);
      glTexCoord2f(0.0, 0.0);
      glVertex3f(0.0, 1.0, 0.0);
      glTexCoord2f(1.0, 1.0);
      glVertex3f(1.0, 0.0, 0.0);
  
      glTexCoord2f(1.0, 1.0);
      glVertex3f(1.0, 0.0, 0.0);
      glTexCoord2f(0.0, 0.0);
      glVertex3f(0.0, 1.0, 0.0);
      glTexCoord2f(1.0, 0.0);
      glVertex3f(1.0, 1.0, 0.0);
      glEnd();
      glDisable(GL_TEXTURE_2D);
  
      // Clear the depth buffer so the texture forms the background.
      glClear(GL_DEPTH_BUFFER_BIT);
  
      // Restore the polygon mode state.
      glPolygonMode(GL_FRONT, polygonMode[0]);
      glPolygonMode(GL_BACK, polygonMode[1]);
  }
  
  
  
  
  void display(void)
  {
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      namedWindow("live", 1);
      Mat gray1, test, modelview, dis_img, thresh, img1;
  
      Mat rvec(3, 1, DataType&lt;double&gt;::type);
      Mat tvec(3, 1, DataType&lt;double&gt;::type);
  
      modelview.create(4, 4, CV_64FC1);
      //Projection.create(4, 4, CV_64FC1);
  
      vector&lt; Point2f&gt; corners1;
      vector&lt; Point2f&gt; imagePoints1;
      vector&lt; Point3f&gt; objectPoints1;
      largest_area = 0;
      largest_contour_index = 0;
  
      clock_t clock_1 = clock();
      cap &gt;&gt; dis_img;
      //resize(dis_img,dis_img,Size(180,180),0,0);
      if (!dis_img.data)
      {
          exit(3);
      }
      img1 = dis_img.clone();
      dis_img.copyTo(img1);
      //resize(img1,img1,Size(180,180),0,0);
      cvtColor(dis_img, dis_img, COLOR_BGR2YCrCb);
      inRange(dis_img, Scalar(0, 133, 77), Scalar(255, 173, 127), thresh);
      clock_t clock_2 = clock();
      cout &lt;&lt; "threshold(Skin Color Segmentation) time is :" &lt;&lt; (double)(clock_2 - clock_1) &lt;&lt; endl;
      dilate(thresh, thresh, Mat());
      blur(thresh, thresh, Size(5, 5), Point(-1, -1), BORDER_DEFAULT);
      vector&lt;vector&lt;Point&gt;&gt; contours;
      vector&lt;Point&gt; FingerTips;
      vector&lt;Vec4i&gt; hierachy;
      vector&lt;Vec4i&gt; defects;
      vector&lt;Point&gt; defect_circle;
      vector&lt;vector&lt;Point&gt;&gt; hull(1);
      Point2f  center;
      float radius;
      clock_t clock_3 = clock();
      cout &lt;&lt; "image filtering (smoothing) time is :" &lt;&lt; (double)(clock_3 - clock_2) &lt;&lt; endl;
  
  
      findContours(thresh, contours, hierachy, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
      //cout&lt;&lt;"contour"&lt;&lt;endl; 
      int cont_size = contours.size();
      for (int i = 0; i&lt;cont_size; i++)
      {
          double a = contourArea(contours[i], false);
          if (a&gt;largest_area)
          {
              largest_area = a;
              largest_contour_index = i;
          }
      }
  
      vector&lt;int&gt; hull_index;
      Rect brect;
  
      if (largest_area&gt;0 &amp;&amp; contours[largest_contour_index].size()&gt;5)
      {
  
          approxPolyDP(contours[largest_contour_index], contours[largest_contour_index], 8, true);
          //cout&lt;&lt;"approx_poly"&lt;&lt;endl;
          convexHull(Mat(contours[largest_contour_index]), hull[0], false, true);
          //  cout&lt;&lt;"convex_hull"&lt;&lt;endl;
          brect = boundingRect(contours[largest_contour_index]);
          //cout&lt;&lt;"bounding_rect"&lt;&lt;endl;
          convexHull(Mat(contours[largest_contour_index]), hull_index, true);
          //cout&lt;&lt;"convex_hull2"&lt;&lt;endl;
          convexityDefects(contours[largest_contour_index], hull_index, defects);
          //cout&lt;&lt;"convexity defect"&lt;&lt;endl;
          // Mom ents mom=moments(contours[largest_contour_index]);
          // draw mass center
          //  circle(img,Point(mom.m10/mom.m00,mom.m01/mom.m00),2,cv::Scalar(0),2);
  
  
          Scalar colorw = Scalar(0, 255, 0);
          Scalar color1 = Scalar(0, 0, 255);
          //drawContours(img,contours,largest_contour_index,color,2, 8, hierachy);
          //drawContours(timg,contours,largest_contour_index,color,1, 8, hierachy);
          //drawContours(timg, hull, 0, color1, 1, 8, vector&lt;Vec4i&gt;(), 0, Point() );
          //  drawContours(img, hull, 0, color1, 2, 8, vector&lt;Vec4i&gt;(), 0, Point() );
          int defc_size = defects.size();
  
          Point ptStart;
          Point ptEnd;
          Point ptStart2;
          Point ptEnd2;
          Point ptFar;
          int count = 1;
          int startidx2;
          int endidx2;
          int tolerance = brect.height / 5;
          float angleTol = 95;
          for (int in = 0; in&lt;defc_size; in++)
          {
              //Vec4i&amp; v=(*d); d++;
              int startidx = defects[in].val[0]; ptStart = contours[largest_contour_index].at(startidx);
              int endidx = defects[in].val[1]; ptEnd = contours[largest_contour_index].at(endidx);
              int faridx = defects[in].val[2];  ptFar = contours[largest_contour_index].at(faridx);
              if (in + 1&lt;defc_size)
                  startidx2 = defects[in + 1].val[0]; ptStart = contours[largest_contour_index].at(startidx);
              endidx2 = defects[in + 1].val[1]; ptEnd = contours[largest_contour_index].at(endidx);
  
              if (distanceP2P(ptStart, ptFar) &gt; tolerance &amp;&amp; distanceP2P(ptEnd, ptFar) &gt; tolerance &amp;&amp; getAngle(ptStart, ptFar, ptEnd) &lt; angleTol) {
                  {
                      if (in + 1&lt;defc_size)
                      {
                          if (distanceP2P(ptStart, ptEnd2) &lt; tolerance)
                              contours[largest_contour_index][startidx] = ptEnd2;
                          else {
                              if (distanceP2P(ptEnd, ptStart2) &lt; tolerance)
                                  contours[largest_contour_index][startidx2] = ptEnd;
  
                          }
                      }
                      defect_circle.push_back(ptFar);
                      //  cout&lt;&lt;"ptfar"&lt;&lt;ptFar.x&lt;&lt;"&amp;&amp;"&lt;&lt;ptFar.y&lt;&lt;endl;
  
                      if (count == 1)
                      {
                          FingerTips.push_back(ptStart);
                          cv::circle(img1, ptStart, 2, Scalar(0, 255, 0), 2);
                          putText(img1, intToString(count), ptStart - Point(0, 30), FONT_HERSHEY_PLAIN, 1.2f, Scalar(255, 0, 0), 2);
                      }
                      FingerTips.push_back(ptEnd);
                      count++;
                      putText(img1, intToString(count), ptEnd - Point(0, 30), FONT_HERSHEY_PLAIN, 1.2f, Scalar(255, 0, 0), 2);
                      cv::circle(img1, ptEnd, 2, Scalar(0, 255, 0), 2);
                      //cv::circle( img, ptFar,   2, Scalar(255,255,255 ), 2 );
  
                  }
              }
          }
          //  circle(img, ptStart,2,Scalar(0xFF,0x60,0x02 ), 2, 8, 0 );
  
          //cv::circle( img, ptEnd,   4, Scalar( 0xFF,0x60,0x02 ), 2 );
          clock_t clock_4 = clock();
          cout &lt;&lt; "fingerTip detection  time is :" &lt;&lt; (double)(clock_4 - clock_3) &lt;&lt; endl;
  
          //  cout&lt;&lt;"hii"&lt;&lt;endl;
          bool two_fn = false;
          bool five_fn = false;
  
          if (defect_circle.size() == 1)
          {
              two_fn = true;
              Point fn = FingerTips.back();
              FingerTips.pop_back();
              Point ln = FingerTips.back();
              FingerTips.pop_back();
              Point defect_point = defect_circle.back();
              float curr = getAngle(fn, defect_point, ln);
              curr = curr / 10;
              curr = 10 - curr;
              renderBackgroundGL(img1);
              objectPoints1.push_back(Point3d(9, 6, 0));
              imagePoints1.push_back(defect_point);
  
              objectPoints1.push_back(Point3d(9, 6, 0));
              imagePoints1.push_back(defect_point);
  
  
  
              objectPoints1.push_back(Point3d(19, 6, 0));
              imagePoints1.push_back(fn);
  
              objectPoints1.push_back(Point3d(9, 18, 0));
              imagePoints1.push_back(ln);
  
  
              // cout&lt;&lt;width&lt;&lt;"  &amp;"&lt;&lt;height&lt;&lt;endl;
              //  cout&lt;&lt;"solvepnp"&lt;&lt;endl; 
              solvePnP(Mat(objectPoints1), Mat(imagePoints1), intrinsic_Matrix, distortion_coeffs, rvec, tvec);
  
  
  
              cv::Mat rotation;
              cv::Rodrigues(rvec, rotation);
              double offsetA[3][1] = { 9,6,6 };
              Mat offset(3, 1, CV_64FC1, offsetA);
              tvec = tvec + rotation*offset;
  
  
              generateProjectionModelview(intrinsic_Matrix, rotation, tvec, Projection, modelview);
              glMatrixMode(GL_PROJECTION);
              GLfloat* projection = convertMatrixType(Projection);
              glLoadMatrixf(projection);
              delete[] projection;
  
              glMatrixMode(GL_MODELVIEW);
              GLfloat* modelView = convertMatrixType(modelview);
              glLoadMatrixf(modelView);
              delete[] modelView;
  
              //glTranslatef(0.0f,0.0f,-5.0f);
              glPushMatrix();
              glColor3f(1.0, 0.0, 0.0);
  
              glutWireTeapot(10.0 / curr);
              glPopMatrix();
              glColor3f(1.0, 1.0, 1.0);
  
          }
          //Rotation Module
          if (defect_circle.size() == 4)
          {
  
              five_fn = true;
              minEnclosingCircle(defect_circle, center, radius);
              //circle(img, center, (int)radius,Scalar(255,255,255), 2, 8, 0 );
              circle(img1, center, 2, Scalar(0), 2, 8, 0);
  
              vector&lt;pair&lt;float, Point&gt;&gt; pos;
              for (int in = 0; in&lt;FingerTips.size(); in++)
              {
                  Point p = FingerTips.back();
                  FingerTips.pop_back();
  
                  //if(in==0)
                  //{
                  pos.push_back(make_pair(distanceP2P(center, p), p));
                  //position.push_back(pos);
              }
              //  }
              //else
              //  {
              //      cout&lt;&lt;"size is"&lt;&lt;position.size()&lt;&lt;endl;
              //  position[n].push_back(make_pair(distanceP2P(center,p),p));
              //}
  
              sort(pos.begin(), pos.end(), pairCompare);
              //  vector&lt;pair&lt;float,Point&gt;&gt; now=position[i].back();
              first = pos.back().second;
              pos.pop_back();
              //cout&lt;&lt;"new value :"&lt;&lt;new1.x&lt;&lt;" &amp;&amp; "&lt;&lt;new1.y&lt;&lt;endl;
              second = pos.back().second;
              pos.pop_back();
              third = pos.back().second;
              pos.pop_back();
  
              if (third.y&lt;second.y&amp;&amp;second.y&lt;first.y)
              {
                  //  cout&lt;&lt;"vertical pose"&lt;&lt;endl;
                  FIX_X.x = center.x + 40;
                  FIX_X.y = center.y;
  
                  FIX_Y.x = center.x;
                  FIX_Y.y = center.y - 40;
              }
              skew_x = getAngle(first, center, FIX_X);
              skew_y = getAngle(third, center, FIX_Y);
              cout &lt;&lt; skew_x &lt;&lt; "&amp;" &lt;&lt; skew_y &lt;&lt; endl;
              if (first.x&lt;img1.cols)
                  line(img1, center, first, Scalar(200, 200, 200), 2, 8, 0);
              line(img1, center, FIX_X, Scalar(200, 200, 200), 2, 8, 0);
              if (second.x&lt;img1.cols)
                  line(img1, center, second, Scalar(0, 255, 0), 2, 8, 0);
              if (third.x&lt;img1.cols)
                  line(img1, center, third, Scalar(0, 0, 255), 2, 8, 0);
              line(img1, center, FIX_Y, Scalar(0, 0, 255), 2, 8, 0);
  
              //  line(img1,center,first,Scalar(255,255,255),2,8,0);
              //  line(img1,center,second,Scalar(0,255,255),2,8,0);
              //  line(img1,center,third,Scalar(0,0,255),2,8,0);
  
              renderBackgroundGL(img1);
  
              /*  cvtColor(test, gray1, CV_RGB2GRAY);
              bool sCorner1=findChessboardCorners(gray1, Size(7, 7), corners1);
              imshow("live",test);
              if(sCorner1)
              {
              cornerSubPix(gray1, corners1, Size(11,11), Size(-1,-1), TermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, 30, 0.1));
              if(corners1.size() == 7*7)
              {control pan
  
              for(int j=0; j&lt; corners1.size(); ++j)
              {
              Point2f tImgPT;
              Point3f tObjPT;
  
              tImgPT.x = corners1[j].x;
              tImgPT.y = corners1[j].y;
  
              tObjPT.x = j%7*3;
              tObjPT.y = j/7*3;
              tObjPT.z = 0;
              imagePoints1.push_back(tImgPT);
              objectPoints1.push_back(tObjPT);
              }
  
              vector&lt;Point2f&gt; projectedPoints;
              vector&lt;Point3f&gt; axis;
  
              axis.push_back(Point3f(6,0,0));
              axis.push_back(Point3f(0,6,0));
              axis.push_back(Point3f(0,0,6));  */
              objectPoints1.push_back(Point3d(9, 6, 0));
              imagePoints1.push_back(center);
  
              objectPoints1.push_back(Point3d(9, 18, 0));
              imagePoints1.push_back(first);
  
              objectPoints1.push_back(Point3d(19, 6, 0));
              imagePoints1.push_back(third);
  
              objectPoints1.push_back(Point3d(15, 15, 0));
              imagePoints1.push_back(second);
  
  
              // cout&lt;&lt;width&lt;&lt;"  &amp;"&lt;&lt;height&lt;&lt;endl;
              //  cout&lt;&lt;"solvepnp"&lt;&lt;endl; 
              solvePnP(Mat(objectPoints1), Mat(imagePoints1), intrinsic_Matrix, distortion_coeffs, rvec, tvec);
  
  
  
              cv::Mat rotation;
              cv::Rodrigues(rvec, rotation);
              double offsetA[3][1] = { 9,6,0 };
              Mat offset(3, 1, CV_64FC1, offsetA);
              tvec = tvec + rotation*offset;
  
  
              generateProjectionModelview(intrinsic_Matrix, rotation, tvec, Projection, modelview);
  
              /*  double offsetA[3][1] = {{(7-1.0)/2.0}, {(7-1.0)/2.0}, {0}};
              Mat offset(3, 1, CV_64FC1, offsetA);
              tvec = tvec + rotation*offset;
  
              for(unsigned int row=0; row&lt;3; ++row)
              {
              for(unsigned int col=0; col&lt;3; ++col)
              {
              modelview.at&lt;float&gt;(row, col) = rotation.at&lt;float&gt;(row, col);
              cout&lt;&lt;modelview.at&lt;float&gt;(row,col)&lt;&lt;endl;
              }
              modelview.at&lt;float&gt;(row, 3) = tvec.at&lt;float&gt;(row, 0);
              }
              modelview.at&lt;float&gt;(3, 3) = 1.0f;
              cout&lt;&lt;endl;
  
  
  
              static float changeCoordArray[4][4] = {{-1, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 1}};
              static Mat changeCoord(4, 4, CV_64FC1, changeCoordArray);
  
              modelview = changeCoord*modelview;
  
              cv::Mat glmodelview = cv::Mat::zeros(4, 4, CV_64F);
              transpose(modelview , glmodelview);
              gluLookAt(0.0,2.0,-50.0,0.0,0.5,0.0,0.0,1.0,0.0);
              /*  glMatrixMode(GL_PROJECTION);
              glLoadIdentity();
              float fx=intrinsic_Matrix.at&lt;float&gt;(0,0);
              float fy=intrinsic_Matrix.at&lt;float&gt;(1,1);
              float cf=(2*atanf(0.5*height/fy)*180/3.14);
              float aspect=(width*fy)/(height*fx);
  
              //gluPerspective(cf,1.0, zNear, zFar);
  
  
  
              glMatrixMode(GL_MODELVIEW);
              glLoadIdentity();
  
              glLoadMatrixf(&amp;glmodelview.at&lt;float&gt;(0,0));  */
              glMatrixMode(GL_PROJECTION);
              GLfloat* projection = convertMatrixType(Projection);
              glLoadMatrixf(projection);
              delete[] projection;
  
              glMatrixMode(GL_MODELVIEW);
              GLfloat* modelView = convertMatrixType(modelview);
              glLoadMatrixf(modelView);
              delete[] modelView;
  
              //glTranslat ef(0.0f,0.0f,-5.0f);
              glPushMatrix();
              glColor3f(1.0, 0.0, 0.0);
              glRotatef(skew_x, 1.0, 0.0, 0.0);
              glRotatef(skew_y, 0.0, 1.0, 0.0);
              glutWireTeapot(10.0);
              glPopMatrix();
              glColor3f(1.0, 1.0, 1.0);
              clock_t clock_5 = clock();
              cout &lt;&lt; "interaction time is :" &lt;&lt; (double)(clock_5 - clock_4) &lt;&lt; endl;
          }
          imshow("live", img1);
          cout &lt;&lt; "----------------------------------------------" &lt;&lt; endl;
  
          glFlush();
          glutSwapBuffers();
      }
      waitKey(27);
      glutPostRedisplay();
  }
  void reshape(int x, int y)
  {
      width = x; height = y;
      glViewport(0, 0, width, height);
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      /*Projection.at&lt;float&gt;(0,0) = 2*intrinsic_Matrix.at&lt;float&gt;(0,0)/width;
      Projection.at&lt;float&gt;(1,0) = 0;
      Projection.at&lt;float&gt;(2,0) = 0;
      Projection.at&lt;float&gt;(3,0) = 0;
  
      Projection.at&lt;float&gt;(0,1) = 0;
      Projection.at&lt;float&gt;(1,1) = 2*intrinsic_Matrix.at&lt;float&gt;(1,1)/height;
      Projection.at&lt;float&gt;(2,1) = 0;
      Projection.at&lt;float&gt;(3,1) = 0;
  
      Projection.at&lt;float&gt;(0,2) = 1-2*intrinsic_Matrix.at&lt;float&gt;(0,2)/width;
      Projection.at&lt;float&gt;(1,2) = -1+(2*intrinsic_Matrix.at&lt;float&gt;(1,2)+2)/height;
      Projection.at&lt;float&gt;(2,2) = (zNear+zFar)/(zNear - zFar);
      Projection.at&lt;float&gt;(3,2) = -1;
  
      Projection.at&lt;float&gt;(0,3) = 0;
      Projection.at&lt;float&gt;(1,3) = 0;
      Projection.at&lt;float&gt;(2,3) = 2*zNear*zFar/(zNear - zFar);
      Projection.at&lt;float&gt;(3,3) = 0;
  
      cv::Mat projection = cv::Mat::zeros(4, 4, CV_64F);
      transpose(Projection ,projection);
      glLoadMatrixf(&amp;projection.at&lt;float&gt;(0,0));   */
  
  
      // gluPerspective(60, (GLfloat)width / (GLfloat)height, 1.0, 100.0); 
  
      /* float fx=intrinsic_Matrix.at&lt;float&gt;(0,0);
      float fy=intrinsic_Matrix.at&lt;float&gt;(1,1);
      float cf=(2*atanf(0.5*height/fy)*180/3.14);
      cout&lt;&lt;fx&lt;&lt;"   "&lt;&lt;fy&lt;&lt;endl;
      float aspect=(width*fy)/(height*fx);  */
      //gluPerspective(cf,CALIB_FIX_ASPECT_RATIO, zNear, zFar); 
  
  
      //glMatrixMode(GL_MODELVIEW);
      //  gluPerspective(60,width/height, zNear, zFar);  
      //glOrtho(-100,100,-100.0,100,zNear, zFar);
  
  }
  void init()
  {
      glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
  }
  void main()
  {
      if (!cap.isOpened())
      {
          exit(-1);
      }
      cap &gt;&gt; test;
      if (!test.data)
      {
          exit(-1);
      }
      //  resize(test,test,Size(180,180),0,0);
      width = test.cols;
      height = test.rows;
      cout &lt;&lt; width &lt;&lt; endl;
      calibrate(intrinsic_Matrix, distortion_coeffs);
      glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
      glutInitWindowSize(width, height);
      glutCreateWindow("code4change");
      init();
      glutDisplayFunc(display);
      glutReshapeFunc(reshape);
      glutMainLoop();
  }
  </code></pre>
  
  <p>But when i compile the cide it always get error message "Cannot open include file: 'stdafx.h'".What should i do?.As i know stdafx.h is a c++ headerfile.</p>