title: OpenCV : libopencv_core.so.2.4: cannot open shared object file: No such file or directory
body: <p>I recently installed Opencv-2.4.6
  I wrote a code for bird's eye view transformation(it's not the final code).
  With the earlier version of Opencv(2.4.3), it was being executed.</p>
  
  <p>And now I am getting a error while running. </p>
  
  <p><em><strong></em>**error while loading shared libraries: libopencv_core.so.2.4: cannot open shared object file: No such file or directory*<em>*</em></strong>
  There are no compilation errors.</p>
  
  <p>The code is:</p>
  
  <pre><code>// This code will take undistorted images as input and give the bird's eye view using them
  // First we need to calculate the homography matrix
  #include "opencv2/highgui/highgui.hpp"
  #include "opencv2/core/core.hpp"
  #include "opencv2/imgproc/imgproc_c.h"
  #include &lt;opencv2/imgproc/imgproc.hpp&gt;
  #include &lt;iostream&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;math.h&gt;
  #define heightBirdEyeView 800
  #define widthBirdEyeView 800    //earlier was 300 300
  using namespace cv;         
  using namespace std;
  
  //global/
  //camera parameters input
  
  //resolution values
  /*
  float resolution_x=50, resolution_y=50;
  
  //camera height and tilt
  float height_camera = 1.25;
  float tilt_camera=12;
  
  //focal length in x and y
  float focal_length_x = 354.05700;
  float focal_length_y = 353.65297;*/
  
  //intensity finding function
      // find the intensity for the transformed point
  
  /*float findintensity(float corrected_x,float corrected_y)
  {
  int intensity;
  if((corrected_x&gt;=1&amp;&amp;corrected_x&lt;=widthBirdEyeView)&amp;&amp;(corrected_y&gt;=1&amp;&amp;corrected_y&lt;=heightBirdEyeView))
  intensity=(1- (corrected_y-floor(corrected_y)))*(1-(corrected_x-floor(corrected_x)))*(undistor_img.at&lt;uchar&gt;(floor(corrected_y),floor(corrected_x)))+(1-( corrected_y-floor(corrected_y)))*(corrected_x-floor(corrected_x))*(undistor_img.at&lt;uchar&gt;(floor(corrected_y), ceil(corrected_x)))+(corrected_y-floor(corrected_y))*(1-(corrected_x-floor(corrected_x)))*(undistor_img.at&lt;uchar&gt;(ceil(corrected_y),floor(corrected_x)))+(corrected_y-floor(corrected_y))*(corrected_x-floor(corrected_x))*(undistor_img.at&lt;uchar&gt;(ceil(corrected_y), ceil(corrected_x)));
  else
  intensity=0;
  return intensity;
  }*/
  
  
  int main(int argc, char** argv)
  { 
  //loading the undistorted image
  Mat undistor_img=imread(argv[1], 1);
  namedWindow("undistorted image");
  
  
  int intensity_change=0;
  Mat undistor_img_hsv;
  cvtColor( undistor_img,undistor_img_hsv, CV_RGB2HSV);
  
  imshow("undistorted image", undistor_img);
  imshow("hsv image",undistor_img_hsv);
  cout&lt;&lt;"size="&lt;&lt;undistor_img_hsv.rows&lt;&lt;" "&lt;&lt;undistor_img_hsv.cols&lt;&lt;endl; // for obs7.jpg the columns are 220 and the rows are 165
  //cout&lt;&lt;"undistorted image="&lt;&lt;undistor_img_hsv&lt;&lt;endl;
  
  // erode the image
  Mat eroded;
  erode(undistor_img_hsv,eroded,Mat());
  imshow("eroded",eroded);
  
  //dilate the image
  Mat dilated;
  dilate(eroded,dilated,Mat());
  imshow("dilated",dilated);
  
  Mat output;
  resize(undistor_img_hsv,output,cv::Size(heightBirdEyeView,widthBirdEyeView));// this will be having the orthogonal transform
  int i,j;
  for(i=0;i&lt;=heightBirdEyeView;i++)
  {
  for(j=0;j&lt;widthBirdEyeView;j++)
  output.at&lt;uchar&gt;(i,j)=0;
  }
  imshow("output",output);
  //should have size as that of height and width of the bird eye view
  
  //camera parameters input
  
  //resolution values
  float resolution_x=50, resolution_y=50;
  
  //camera height and tilt
  float height_camera = 1.25;
  float tilt_camera=12;
  
  //focal length in x and y
  float focal_length_x = 354.05700;
  float focal_length_y = 353.65297;
  
  //generate transformation matrix
  float H1[3][3]={resolution_x,0,widthBirdEyeView/2+1,
          0,-1*resolution_y,heightBirdEyeView,
          0,0,1};
  Mat transformation_matrix(3,3,CV_32FC1,H1);
  cout&lt;&lt;"transformation matrix="&lt;&lt;endl&lt;&lt;transformation_matrix&lt;&lt;endl&lt;&lt;endl;
  
  
  //generate top view matrix
  float H2[3][3]={height_camera/focal_length_x,0,0,
          0,0,height_camera,
          0,cos(tilt_camera)/focal_length_y,sin(tilt_camera)};
  Mat topview_matrix(3,3,CV_32FC1,H2);
  cout&lt;&lt;"topview matrix="&lt;&lt;endl&lt;&lt;topview_matrix&lt;&lt;endl&lt;&lt;endl;
  
  //generate scale matrix
  float H3[3][3]={1,0,undistor_img.rows,
          0,1,undistor_img.rows,
          0,0,1};
  Mat scale_matrix(3,3,CV_32FC1,H3);
  cout&lt;&lt;"scale matrix="&lt;&lt;endl&lt;&lt;scale_matrix&lt;&lt;endl&lt;&lt;endl;
  
  //generate homography matrix
  Mat homography_matrix=transformation_matrix*topview_matrix/scale_matrix;
  cout&lt;&lt;"homography matrix="&lt;&lt;endl&lt;&lt;homography_matrix&lt;&lt;endl&lt;&lt;endl;
  
  Mat transpose_homography_matrix =homography_matrix;
  Mat temp_matrix =homography_matrix;
  
  //cout&lt;&lt;"temp_matrix=" &lt;&lt;endl&lt;&lt;temp_matrix&lt;&lt;endl&lt;&lt;endl;
  
  //transpose of homography matrix
  for (int i=0;i&lt;3;i++)
  {
      for (int j=0;j&lt;3;j++)
      transpose_homography_matrix.at&lt;float&gt;(i,j)=temp_matrix.at&lt;float&gt;(j,i);
  }
  //cout&lt;&lt;"transpose homography matrix="&lt;&lt;endl&lt;&lt;transpose_homography_matrix&lt;&lt;endl&lt;&lt;endl;
  
  float bev_zero[heightBirdEyeView][widthBirdEyeView];        //bev_zero will be the new image matrix
  for(int i=0;i&lt;heightBirdEyeView;i++)
  {
      for(int j=0;j&lt;widthBirdEyeView;j++)
      bev_zero[i][j]=0;
  }
  Mat new_point_matrix; // this 3x1 matrix will be used to give new point for all old points in old image
  //(undistor_img_hsv.rows,undistor_img_hsv.cols,CV_32FC1,bev_zero);
  //cout&lt;&lt;endl&lt;&lt;new_point_matrix&lt;&lt;endl&lt;&lt;endl;
  //new_point_matrix=
  //Mat new_point_matrix;
  float corrected_x,corrected_y;
  
  Mat old_point_matrix;
  
  //conversion from point to its new point
  for(int k=0;k&lt;undistor_img_hsv.cols;k++)
  {
      for(int l=0;l&lt;undistor_img_hsv.rows;l++)
      {
      float point[3][1]={k,
                 l,
                 1};
      Mat old_point_matrix(3,1,CV_32FC1,point);
      //get the new points for new view
      //corrected_x=bev_zero[0][0]/bev_zero[2][0];
      //corrected_y=bev_zero[1][0]/bev_zero[2][0];
      new_point_matrix=transpose_homography_matrix*old_point_matrix;
      cout&lt;&lt;"old point="&lt;&lt;old_point_matrix&lt;&lt;",new point="&lt;&lt;new_point_matrix&lt;&lt;endl; // every old point in the old image has got a new corresponding point
  
      //cout&lt;&lt;"new x="&lt;&lt;corrected_x&lt;&lt;", new y="&lt;&lt;corrected_y&lt;&lt;endl&lt;&lt;endl;
      //cout&lt;&lt;bev_zero[0][0]&lt;&lt;bev_zero[1][0]&lt;&lt;endl&lt;&lt;endl;
      //cout&lt;&lt;"new x="&lt;&lt;new_point_matrix.at&lt;float&gt;(0,0)/new_point_matrix.at&lt;float&gt;(2,0)&lt;&lt;endl;
      //cout&lt;&lt;", new y="&lt;&lt;new_point_matrix.at&lt;float&gt;(1,0)/new_point_matrix.at&lt;float&gt;(2,0)&lt;&lt;endl;x
      //new_point_matrix=new_point_matrix/new_point_matrix.at&lt;float&gt;(2,0);
  
      //find corrected values
      corrected_x=abs(new_point_matrix.at&lt;float&gt;(0,0)/new_point_matrix.at&lt;float&gt;(2,0));
      corrected_y=abs(new_point_matrix.at&lt;float&gt;(1,0)/new_point_matrix.at&lt;float&gt;(2,0));
      //cout&lt;&lt;"point= ("&lt;&lt;corrected_x&lt;&lt;","&lt;&lt;corrected_y&lt;&lt;")"&lt;&lt;endl;
      //cout&lt;&lt;"old point= ("&lt;&lt;k&lt;&lt;","&lt;&lt;l&lt;&lt;")"&lt;&lt;endl;
      cout&lt;&lt;"corrected_x="&lt;&lt;corrected_x&lt;&lt;endl&lt;&lt;"corrected_y="&lt;&lt;corrected_y&lt;&lt;endl;
  
      float intensity; // to store intensity values
      // based on the corrected values, find out the intensity points
      //cout&lt;&lt;findintensity(corrected_x,corrected_y)&lt;&lt;endl;
      if((corrected_x&gt;=1&amp;&amp;corrected_x&lt;=widthBirdEyeView)&amp;&amp;(corrected_y&gt;=1&amp;&amp;corrected_y&lt;=heightBirdEyeView))
  {
  intensity_change++;
  intensity=(1- (corrected_y-floor(corrected_y)))*(1-(corrected_x-floor(corrected_x)))*(undistor_img.at&lt;uchar&gt;(floor(corrected_y),floor(corrected_x)))+(1-( corrected_y-floor(corrected_y)))*(corrected_x-floor(corrected_x))*(undistor_img.at&lt;uchar&gt;(floor(corrected_y), ceil(corrected_x)))+(corrected_y-floor(corrected_y))*(1-(corrected_x-floor(corrected_x)))*(undistor_img.at&lt;uchar&gt;(ceil(corrected_y),floor(corrected_x)))+(corrected_y-floor(corrected_y))*(corrected_x-floor(corrected_x))*(undistor_img.at&lt;uchar&gt;(ceil(corrected_y), ceil(corrected_x)));
  }
  else
  intensity=0;
  cout&lt;&lt;"intensity="&lt;&lt;intensity&lt;&lt;endl;
  //cout&lt;&lt;new_point_matrix&lt;&lt;endl;
  cout&lt;&lt;floor(new_point_matrix.at&lt;float&gt;(0,0))&lt;&lt;endl;
  cout&lt;&lt;int(new_point_matrix.at&lt;float&gt;(1,0))&lt;&lt;endl;
  // now I just need to give this intensity value to the corresponding point for the old point
  //output.at&lt;uchar&gt;(floor(new_point_matrix.at&lt;float&gt;(0,0)),floor(new_point_matrix.at&lt;float&gt;(1,0)))=intensity;
  //cout&lt;&lt;"value="&lt;&lt;new_point_matrix.at&lt;uchar&gt;(0,150);
  //cout&lt;&lt;"value21="&lt;&lt;undistor_img.at&lt;uchar&gt;(0,150);
  //cout&lt;&lt;"pixel intensity at this point="&lt;&lt;new_point_matrix&lt;&lt;endl;
  
      cout&lt;&lt;endl;
      }
  }
  //cout&lt;&lt;"intensity changed "&lt;&lt;intensity_change&lt;&lt;" times."&lt;&lt;endl; 
  //imshow("output",output);
  //cout&lt;&lt;"old point matrix="&lt;&lt;old_point_matrix&lt;&lt;endl;
  //cout&lt;&lt;"new point matrix="&lt;&lt;new_point_matrix&lt;&lt;endl;
  //cout&lt;&lt;"pixel intensity at this point="&lt;&lt;new_point_matrix&lt;&lt;endl; //ERROR HERE
      //cout&lt;&lt;"changed new point="&lt;&lt;new_point_matrix&lt;&lt;endl;
  
  /*
  
  Mat p_new(3,1,CV_32FC1); // this will give the coordinates in the bird's eye view 
  float corrected_x,corrected_y;
  //float Floor_corrected_y,Floor_corrected_x,Ceil_corrected_x,Ceil_corrected_y,Ratio_corrected_x,Ratio_corrected_y;
  
  int a=0,b=0;
  // counters for if and else blocks
  
  //now we need matrix with coordinates of the image plane, to be projected
  for(int p=0; p&lt;heightBirdEyeView;p++)
  {
      uchar* data= undistor_img.ptr&lt;uchar&gt;(p);
      uchar* hdata= birdeyeview_img.ptr&lt;uchar&gt;(p);
      for(int q=0;q&lt;widthBirdEyeView;q++)
      {
      //birdeyeview_img.at&lt;cv::Vec3b&gt;(q,p)[0]=transpose_homography_matrix*undistor_img.at&lt;cv::Vec3b&gt;(q,p)[0];
      //birdeyeview_img.at&lt;cv::Vec3b&gt;(q,p)[1]=transpose_homography_matrix*undistor_img.at&lt;cv::Vec3b&gt;(q,p)[1];
      //birdeyeview_img.at&lt;cv::Vec3b&gt;(q,p)[2]=transpose_homography_matrix*undistor_img.at&lt;cv::Vec3b&gt;(q,p)[2];
      //birdeyeview_img.at&lt;uchar&gt;(q,p)=transpose_homography_matrix*undistor_img.at&lt;uchar&gt;(q,p);
      //birdeyeview_img.at&lt;uchar&gt;(q,p)=transpose_homography_matrix*int(undistor_img.at&lt;int&gt;(q,p));
  
      //cout&lt;&lt;transpose_homography_matrix*undistor_img.at&lt;int&gt;(q,p)&lt;&lt;endl;
      int M[]={q,p,1};
      Mat p_old(3,1,CV_32FC1,M); //holding the positions in undistorted image
      //cout&lt;&lt;transpose_homography_matrix*p_old&lt;&lt;endl;
      p_new=transpose_homography_matrix*p_old;
      //cout&lt;&lt;endl&lt;&lt;p_new;    
      //cout&lt;&lt;endl&lt;&lt;p_new.at&lt;float&gt;(0,0);
      //cout&lt;&lt;endl&lt;&lt;p_new[1];
      //cout&lt;&lt;endl&lt;&lt;p_new[2];
      //cout&lt;&lt;endl&lt;&lt;cvmGet(p_new,0,0);
      corrected_x=p_new.at&lt;float&gt;(0,0)/p_new.at&lt;float&gt;(2,0);
      corrected_y=p_new.at&lt;float&gt;(1,0)/p_new.at&lt;float&gt;(2,0);
  
      //cout&lt;&lt;"the pixel intensity to be assigned="&lt;&lt;(1- (corrected_y-floor(corrected_y)))*(1-(corrected_x-floor(corrected_x)))*((int)undistor_img.at&lt;uchar&gt;(floor(corrected_y),floor(corrected_x)))
              //                          +(1-( corrected_y-floor(corrected_y)))*(corrected_x-floor(corrected_x))*((int)undistor_img.at&lt;uchar&gt;(floor(corrected_y), ceil(corrected_x)))
              //                            +( corrected_y-floor(corrected_y))*(1-(corrected_x-floor(corrected_x)))*((int)undistor_img.at&lt;uchar&gt;(ceil(corrected_y),floor(corrected_x)))
               //                          +( corrected_y-floor(corrected_y))*(corrected_x-floor(corrected_x))*((int)undistor_img.at&lt;uchar&gt;(ceil(corrected_y), ceil(corrected_x)))&lt;&lt;endl;
      //cout&lt;&lt;"values to be greater than 1"&lt;&lt;corrected_x&lt;&lt;","&lt;&lt;corrected_y&lt;&lt;endl;
      //cout&lt;&lt;"those should be less than"&lt;&lt;undistor_img.rows&lt;&lt;"and"&lt;&lt;undistor_img.cols&lt;&lt;endl;
      //cout&lt;&lt;corrected_x&lt;&lt;" "&lt;&lt;corrected_y&lt;&lt;endl;
  
      if (((abs(corrected_y)&gt;=1)&amp;&amp;(corrected_y&lt;=undistor_img.rows))&amp;&amp;((abs(corrected_x)&gt;=1)&amp;&amp;(corrected_x&lt;=undistor_img.cols)))     
             {// Floor_corrected_y = floor(corrected_y);
               //Ceil_corrected_y = ceil(corrected_y);
               //Floor_corrected_x = floor(corrected_x);
               //Ceil_corrected_x = ceil(corrected_x);
              // Ratio_corrected_y = corrected_y-floor(corrected_y);
              // Ratio_corrected_x = corrected_x-floor(corrected_x);        
      //birdeyeview_img.at&lt;uchar&gt;(p,q)=(1-(corrected_y-floor(corrected_y)))*(1-(corrected_x-floor(corrected_x)))*((int)undistor_img.at&lt;uchar&gt;(floor(corrected_y),floor(corrected_x)))
                    //                     +(1-( corrected_y-floor(corrected_y)))*(corrected_x-floor(corrected_x))*((int)undistor_img.at&lt;uchar&gt;(floor(corrected_y), ceil(corrected_x)))
                    //                      +( corrected_y-floor(corrected_y))*(1-(corrected_x-floor(corrected_x)))*((int)undistor_img.at&lt;uchar&gt;(ceil(corrected_y),floor(corrected_x)))
                      //                   +( corrected_y-floor(corrected_y))*(corrected_x-floor(corrected_x))*((int)undistor_img.at&lt;uchar&gt;(ceil(corrected_y), ceil(corrected_x)));
      //cout&lt;&lt;"if read"&lt;&lt;endl;
      //hdata[q]=(1- (corrected_y-floor(corrected_y)))*(1-(corrected_x-floor(corrected_x)))*data[q] +(1-( corrected_y-floor(corrected_y)))*(corrected_x-floor(corrected_x))*data[q] +( corrected_y-floor(corrected_y))*(1-(corrected_x-floor(corrected_x)))*data[q]+( corrected_y-floor(corrected_y))*(corrected_x-floor(corrected_x))*data[q];   //works to some extent
      hdata[q]=(1- (corrected_y-floor(corrected_y)))*(1-(corrected_x-floor(corrected_x)))*undistor_img.at&lt;uchar&gt;(floor(corrected_y),floor(corrected_x))            +(1-( corrected_y-floor(corrected_y)))*(corrected_x-floor(corrected_x))*undistor_img.at&lt;uchar&gt;(floor(corrected_y), ceil(corrected_x))+( corrected_y-floor(corrected_y))*(1-(corrected_x-floor(corrected_x)))*undistor_img.at&lt;uchar&gt;(ceil(corrected_y),floor(corrected_x)) +( corrected_y-floor(corrected_y))*(corrected_x-floor(corrected_x))*undistor_img.at&lt;uchar&gt;(ceil(corrected_y), ceil(corrected_x));    
      a++;}
      //birdeyeview_img.at&lt;uchar&gt;(q,p)=(1- (corrected_y-floor(corrected_y)))*(1-(corrected_x-floor(corrected_x)))*(undistor_img.at&lt;uchar&gt;(floor(corrected_y),floor(corrected_x)))
            //                            +(1-( corrected_y-floor(corrected_y)))*(corrected_x-floor(corrected_x))*(undistor_img.at&lt;uchar&gt;(floor(corrected_y), ceil(corrected_x)))
              //                            +(corrected_y-floor(corrected_y))*(1-(corrected_x-floor(corrected_x)))*(undistor_img.at&lt;uchar&gt;(ceil(corrected_y),floor(corrected_x)))
                //                         +(corrected_y-floor(corrected_y))*(corrected_x-floor(corrected_x))*(undistor_img.at&lt;uchar&gt;(ceil(corrected_y), ceil(corrected_x))); 
  //}
  
      else{
      b++;
      hdata[q]=data[q];
      //birdeyeview_img.at&lt;uchar&gt;(p,q)=255;
      //hdata[q]=undistor_img.at&lt;uchar&gt;(round(corrected_y),round(corrected_x));
      //hdata[q]=(int)undistor_img.at&lt;uchar&gt;(q,p);//gives sm output
      //hdata[q]= undistor_img.ptr&lt;uchar&gt;(p,q);
      //hdata[q]= undistor_img.at&lt;uchar&gt;(p,q);//works to sm extent
      //cout&lt;&lt;endl&lt;&lt;"pixel value"&lt;&lt;(int) undistor_img.at&lt;uchar&gt;(p,q);
      //birdeyeview_img.at&lt;uchar&gt;(q,p)=undistor_img.at&lt;uchar&gt;(round(corrected_y),round(corrected_x));
      }
      //cout&lt;&lt;(int)birdeyeview_img.at&lt;uchar&gt;(p,q)&lt;&lt;endl;
      //birdeyeview_img.at&lt;uchar&gt;(p,q)=0;}
      //cout&lt;&lt;"else read"&lt;&lt;endl;}
      //undistor_img.at&lt;uchar&gt;(p,q)=(int)undistor_img.at&lt;uchar&gt;(round(corrected_y),round(corrected_x));}
      //birdeyeview_img.at&lt;uchar&gt;(p,q)=124;
      //cout&lt;&lt;endl&lt;&lt;(int)undistor_img.at&lt;uchar&gt;(p,q);
      //cout&lt;&lt;endl&lt;&lt;(int)birdeyeview_img.at&lt;uchar&gt;(p,q);
      //cout&lt;&lt;"working here1"&lt;&lt;endl;
      }
  
  }
  //flip(birdeyeview_img,birdeyeview_img,1);
  //  perspectiveTransform(undistor_img,birdeyeview_img ,homography_matrix);
  //cout&lt;&lt;"bird"&lt;&lt;birdeyeview_img&lt;&lt;endl;
  //cout&lt;&lt;"working here2"&lt;&lt;endl;
  //cout&lt;&lt;birdeyeview_img&lt;&lt;endl;
  cout&lt;&lt;"input channels="&lt;&lt;undistor_img.channels()&lt;&lt;endl;
  //cout&lt;&lt;"grayscaled image channels="&lt;&lt;gray_undistor_img.channels()&lt;&lt;endl;
  cout&lt;&lt;"output channels="&lt;&lt;birdeyeview_img.channels()&lt;&lt;endl;
  cout&lt;&lt;"if was read"&lt;&lt;a &lt;&lt;"times"&lt;&lt;endl;
  cout&lt;&lt;"else was read"&lt;&lt;b &lt;&lt;"times"&lt;&lt;endl;
  imshow("bird's eye view image",birdeyeview_img);
  cout&lt;&lt;"input size="&lt;&lt;undistor_img.rows&lt;&lt;"X"&lt;&lt;undistor_img.cols&lt;&lt;endl;
  cout&lt;&lt;"result size="&lt;&lt;birdeyeview_img.rows&lt;&lt;"X"&lt;&lt;birdeyeview_img.cols&lt;&lt;endl;
  
  //cout&lt;&lt;"working here3"&lt;&lt;endl;
  */
  cvWaitKey();
  }``
  </code></pre>
  
  <p>Can someone help what to do?</p>