- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我最近安装了Opencv-2.4.6我写了一个鸟瞰图转换的代码(不是最终代码)。在Opencv(2.4.3)的早期版本中,它正在被执行。
现在我在运行时遇到错误。
**加载共享库时出错:libopencv_core.so.2.4:无法打开共享对象文件:没有这样的文件或目录** 没有编译错误。
代码是:
// 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 <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#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>=1&&corrected_x<=widthBirdEyeView)&&(corrected_y>=1&&corrected_y<=heightBirdEyeView))
intensity=(1- (corrected_y-floor(corrected_y)))*(1-(corrected_x-floor(corrected_x)))*(undistor_img.at<uchar>(floor(corrected_y),floor(corrected_x)))+(1-( corrected_y-floor(corrected_y)))*(corrected_x-floor(corrected_x))*(undistor_img.at<uchar>(floor(corrected_y), ceil(corrected_x)))+(corrected_y-floor(corrected_y))*(1-(corrected_x-floor(corrected_x)))*(undistor_img.at<uchar>(ceil(corrected_y),floor(corrected_x)))+(corrected_y-floor(corrected_y))*(corrected_x-floor(corrected_x))*(undistor_img.at<uchar>(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<<"size="<<undistor_img_hsv.rows<<" "<<undistor_img_hsv.cols<<endl; // for obs7.jpg the columns are 220 and the rows are 165
//cout<<"undistorted image="<<undistor_img_hsv<<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<=heightBirdEyeView;i++)
{
for(j=0;j<widthBirdEyeView;j++)
output.at<uchar>(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<<"transformation matrix="<<endl<<transformation_matrix<<endl<<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<<"topview matrix="<<endl<<topview_matrix<<endl<<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<<"scale matrix="<<endl<<scale_matrix<<endl<<endl;
//generate homography matrix
Mat homography_matrix=transformation_matrix*topview_matrix/scale_matrix;
cout<<"homography matrix="<<endl<<homography_matrix<<endl<<endl;
Mat transpose_homography_matrix =homography_matrix;
Mat temp_matrix =homography_matrix;
//cout<<"temp_matrix=" <<endl<<temp_matrix<<endl<<endl;
//transpose of homography matrix
for (int i=0;i<3;i++)
{
for (int j=0;j<3;j++)
transpose_homography_matrix.at<float>(i,j)=temp_matrix.at<float>(j,i);
}
//cout<<"transpose homography matrix="<<endl<<transpose_homography_matrix<<endl<<endl;
float bev_zero[heightBirdEyeView][widthBirdEyeView]; //bev_zero will be the new image matrix
for(int i=0;i<heightBirdEyeView;i++)
{
for(int j=0;j<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<<endl<<new_point_matrix<<endl<<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<undistor_img_hsv.cols;k++)
{
for(int l=0;l<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<<"old point="<<old_point_matrix<<",new point="<<new_point_matrix<<endl; // every old point in the old image has got a new corresponding point
//cout<<"new x="<<corrected_x<<", new y="<<corrected_y<<endl<<endl;
//cout<<bev_zero[0][0]<<bev_zero[1][0]<<endl<<endl;
//cout<<"new x="<<new_point_matrix.at<float>(0,0)/new_point_matrix.at<float>(2,0)<<endl;
//cout<<", new y="<<new_point_matrix.at<float>(1,0)/new_point_matrix.at<float>(2,0)<<endl;x
//new_point_matrix=new_point_matrix/new_point_matrix.at<float>(2,0);
//find corrected values
corrected_x=abs(new_point_matrix.at<float>(0,0)/new_point_matrix.at<float>(2,0));
corrected_y=abs(new_point_matrix.at<float>(1,0)/new_point_matrix.at<float>(2,0));
//cout<<"point= ("<<corrected_x<<","<<corrected_y<<")"<<endl;
//cout<<"old point= ("<<k<<","<<l<<")"<<endl;
cout<<"corrected_x="<<corrected_x<<endl<<"corrected_y="<<corrected_y<<endl;
float intensity; // to store intensity values
// based on the corrected values, find out the intensity points
//cout<<findintensity(corrected_x,corrected_y)<<endl;
if((corrected_x>=1&&corrected_x<=widthBirdEyeView)&&(corrected_y>=1&&corrected_y<=heightBirdEyeView))
{
intensity_change++;
intensity=(1- (corrected_y-floor(corrected_y)))*(1-(corrected_x-floor(corrected_x)))*(undistor_img.at<uchar>(floor(corrected_y),floor(corrected_x)))+(1-( corrected_y-floor(corrected_y)))*(corrected_x-floor(corrected_x))*(undistor_img.at<uchar>(floor(corrected_y), ceil(corrected_x)))+(corrected_y-floor(corrected_y))*(1-(corrected_x-floor(corrected_x)))*(undistor_img.at<uchar>(ceil(corrected_y),floor(corrected_x)))+(corrected_y-floor(corrected_y))*(corrected_x-floor(corrected_x))*(undistor_img.at<uchar>(ceil(corrected_y), ceil(corrected_x)));
}
else
intensity=0;
cout<<"intensity="<<intensity<<endl;
//cout<<new_point_matrix<<endl;
cout<<floor(new_point_matrix.at<float>(0,0))<<endl;
cout<<int(new_point_matrix.at<float>(1,0))<<endl;
// now I just need to give this intensity value to the corresponding point for the old point
//output.at<uchar>(floor(new_point_matrix.at<float>(0,0)),floor(new_point_matrix.at<float>(1,0)))=intensity;
//cout<<"value="<<new_point_matrix.at<uchar>(0,150);
//cout<<"value21="<<undistor_img.at<uchar>(0,150);
//cout<<"pixel intensity at this point="<<new_point_matrix<<endl;
cout<<endl;
}
}
//cout<<"intensity changed "<<intensity_change<<" times."<<endl;
//imshow("output",output);
//cout<<"old point matrix="<<old_point_matrix<<endl;
//cout<<"new point matrix="<<new_point_matrix<<endl;
//cout<<"pixel intensity at this point="<<new_point_matrix<<endl; //ERROR HERE
//cout<<"changed new point="<<new_point_matrix<<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<heightBirdEyeView;p++)
{
uchar* data= undistor_img.ptr<uchar>(p);
uchar* hdata= birdeyeview_img.ptr<uchar>(p);
for(int q=0;q<widthBirdEyeView;q++)
{
//birdeyeview_img.at<cv::Vec3b>(q,p)[0]=transpose_homography_matrix*undistor_img.at<cv::Vec3b>(q,p)[0];
//birdeyeview_img.at<cv::Vec3b>(q,p)[1]=transpose_homography_matrix*undistor_img.at<cv::Vec3b>(q,p)[1];
//birdeyeview_img.at<cv::Vec3b>(q,p)[2]=transpose_homography_matrix*undistor_img.at<cv::Vec3b>(q,p)[2];
//birdeyeview_img.at<uchar>(q,p)=transpose_homography_matrix*undistor_img.at<uchar>(q,p);
//birdeyeview_img.at<uchar>(q,p)=transpose_homography_matrix*int(undistor_img.at<int>(q,p));
//cout<<transpose_homography_matrix*undistor_img.at<int>(q,p)<<endl;
int M[]={q,p,1};
Mat p_old(3,1,CV_32FC1,M); //holding the positions in undistorted image
//cout<<transpose_homography_matrix*p_old<<endl;
p_new=transpose_homography_matrix*p_old;
//cout<<endl<<p_new;
//cout<<endl<<p_new.at<float>(0,0);
//cout<<endl<<p_new[1];
//cout<<endl<<p_new[2];
//cout<<endl<<cvmGet(p_new,0,0);
corrected_x=p_new.at<float>(0,0)/p_new.at<float>(2,0);
corrected_y=p_new.at<float>(1,0)/p_new.at<float>(2,0);
//cout<<"the pixel intensity to be assigned="<<(1- (corrected_y-floor(corrected_y)))*(1-(corrected_x-floor(corrected_x)))*((int)undistor_img.at<uchar>(floor(corrected_y),floor(corrected_x)))
// +(1-( corrected_y-floor(corrected_y)))*(corrected_x-floor(corrected_x))*((int)undistor_img.at<uchar>(floor(corrected_y), ceil(corrected_x)))
// +( corrected_y-floor(corrected_y))*(1-(corrected_x-floor(corrected_x)))*((int)undistor_img.at<uchar>(ceil(corrected_y),floor(corrected_x)))
// +( corrected_y-floor(corrected_y))*(corrected_x-floor(corrected_x))*((int)undistor_img.at<uchar>(ceil(corrected_y), ceil(corrected_x)))<<endl;
//cout<<"values to be greater than 1"<<corrected_x<<","<<corrected_y<<endl;
//cout<<"those should be less than"<<undistor_img.rows<<"and"<<undistor_img.cols<<endl;
//cout<<corrected_x<<" "<<corrected_y<<endl;
if (((abs(corrected_y)>=1)&&(corrected_y<=undistor_img.rows))&&((abs(corrected_x)>=1)&&(corrected_x<=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<uchar>(p,q)=(1-(corrected_y-floor(corrected_y)))*(1-(corrected_x-floor(corrected_x)))*((int)undistor_img.at<uchar>(floor(corrected_y),floor(corrected_x)))
// +(1-( corrected_y-floor(corrected_y)))*(corrected_x-floor(corrected_x))*((int)undistor_img.at<uchar>(floor(corrected_y), ceil(corrected_x)))
// +( corrected_y-floor(corrected_y))*(1-(corrected_x-floor(corrected_x)))*((int)undistor_img.at<uchar>(ceil(corrected_y),floor(corrected_x)))
// +( corrected_y-floor(corrected_y))*(corrected_x-floor(corrected_x))*((int)undistor_img.at<uchar>(ceil(corrected_y), ceil(corrected_x)));
//cout<<"if read"<<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<uchar>(floor(corrected_y),floor(corrected_x)) +(1-( corrected_y-floor(corrected_y)))*(corrected_x-floor(corrected_x))*undistor_img.at<uchar>(floor(corrected_y), ceil(corrected_x))+( corrected_y-floor(corrected_y))*(1-(corrected_x-floor(corrected_x)))*undistor_img.at<uchar>(ceil(corrected_y),floor(corrected_x)) +( corrected_y-floor(corrected_y))*(corrected_x-floor(corrected_x))*undistor_img.at<uchar>(ceil(corrected_y), ceil(corrected_x));
a++;}
//birdeyeview_img.at<uchar>(q,p)=(1- (corrected_y-floor(corrected_y)))*(1-(corrected_x-floor(corrected_x)))*(undistor_img.at<uchar>(floor(corrected_y),floor(corrected_x)))
// +(1-( corrected_y-floor(corrected_y)))*(corrected_x-floor(corrected_x))*(undistor_img.at<uchar>(floor(corrected_y), ceil(corrected_x)))
// +(corrected_y-floor(corrected_y))*(1-(corrected_x-floor(corrected_x)))*(undistor_img.at<uchar>(ceil(corrected_y),floor(corrected_x)))
// +(corrected_y-floor(corrected_y))*(corrected_x-floor(corrected_x))*(undistor_img.at<uchar>(ceil(corrected_y), ceil(corrected_x)));
//}
else{
b++;
hdata[q]=data[q];
//birdeyeview_img.at<uchar>(p,q)=255;
//hdata[q]=undistor_img.at<uchar>(round(corrected_y),round(corrected_x));
//hdata[q]=(int)undistor_img.at<uchar>(q,p);//gives sm output
//hdata[q]= undistor_img.ptr<uchar>(p,q);
//hdata[q]= undistor_img.at<uchar>(p,q);//works to sm extent
//cout<<endl<<"pixel value"<<(int) undistor_img.at<uchar>(p,q);
//birdeyeview_img.at<uchar>(q,p)=undistor_img.at<uchar>(round(corrected_y),round(corrected_x));
}
//cout<<(int)birdeyeview_img.at<uchar>(p,q)<<endl;
//birdeyeview_img.at<uchar>(p,q)=0;}
//cout<<"else read"<<endl;}
//undistor_img.at<uchar>(p,q)=(int)undistor_img.at<uchar>(round(corrected_y),round(corrected_x));}
//birdeyeview_img.at<uchar>(p,q)=124;
//cout<<endl<<(int)undistor_img.at<uchar>(p,q);
//cout<<endl<<(int)birdeyeview_img.at<uchar>(p,q);
//cout<<"working here1"<<endl;
}
}
//flip(birdeyeview_img,birdeyeview_img,1);
// perspectiveTransform(undistor_img,birdeyeview_img ,homography_matrix);
//cout<<"bird"<<birdeyeview_img<<endl;
//cout<<"working here2"<<endl;
//cout<<birdeyeview_img<<endl;
cout<<"input channels="<<undistor_img.channels()<<endl;
//cout<<"grayscaled image channels="<<gray_undistor_img.channels()<<endl;
cout<<"output channels="<<birdeyeview_img.channels()<<endl;
cout<<"if was read"<<a <<"times"<<endl;
cout<<"else was read"<<b <<"times"<<endl;
imshow("bird's eye view image",birdeyeview_img);
cout<<"input size="<<undistor_img.rows<<"X"<<undistor_img.cols<<endl;
cout<<"result size="<<birdeyeview_img.rows<<"X"<<birdeyeview_img.cols<<endl;
//cout<<"working here3"<<endl;
*/
cvWaitKey();
}``
有人可以帮忙做什么吗?
最佳答案
只需打开名为/etc/ld.so.conf.d/opencv.conf
的文件,然后插入
/usr/local/opencv/
然后输入:sudo ldconfig
关于c++ - OpenCV : libopencv_core. so.2.4:无法打开共享对象文件:没有这样的文件或目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19164343/
我开始学习 Oracle JavaSE 认证考试。 我创建了一个 IntelliJ Idea 项目来处理我的训练源代码。我想尽量减少 IntelliJ Idea 的帮助。 我只想使用:颜色语法、终端选
默认情况下,.DPR 和 .DPROJ 的文件扩展名描述是相同的,因此在资源管理器中打开具有相同基本名称的项目文件时,两个文件描述都会列为“Delphi 项目文件”,这提供了一个选择开发人员 - 要打
我目前正在从 android 网站了解 Navigation Drawer,我正在使用他们的示例 http://developer.android.com/training/implementing-
我需要帮助。 我在 A3:A500 列中有单词和数字 我需要改变他们的名字。 如果单元格包含单词“previ”,则如果单元格是数字,则将字母“p”放入新列中。如果它是一个词,那么不要放“p” ...就
我正在尝试编写一些 VBA,它允许按钮添加一个空行,保持相同的格式,就在 SUM 公式所在的行上方。 到目前为止,我实现了创建一个空行,但我不知道如何实现代码以让该新行继承相同的格式样式(包括边框和格
我在共享网络驱动器上有两个工作簿: 工作簿 A(表) 工作簿 B(数据透视表 - 连接到源工作簿 A) 我正在尝试,当打开 Workbook B 时,运行宏并执行以下操作: 取消保护工作簿 B 上的某
我正在开发一个需要在在线/离线模式下进行测试的应用程序,所以我想知道是否有任何方法可以打开/关闭 iPad 模拟器的互联网连接(不关闭我的 MAC 的互联网服务)。请帮忙 最佳答案 不,模拟器使用与您
我需要对目录的所有文件执行我的脚本(搜索)。以下是有效的方法。我只是问哪个最好。 (我需要格式的文件名:parsedchpt31_4.txt) 全局: my $parse_corpus; #(for
在我的代码中,我想有条件地执行一些操作: #ifdef DEBUG NSLog(@"I'm in debug mode"); #endif 我已配置“项目”->“编辑项目设置”->“构建”选项卡,以便
我编写了一个小程序来比较笔记本电脑的性能。为了使程序CPU更加密集,我用一些多线程代码(通过Parallel API实现)实现了Rabin-Karp模式匹配算法。 我注意到,当在关闭编译器优化标志的情
使用以下代码来关闭模态并打开第二个模态。总是遇到同样的问题可以关闭一个但不能打开第二个,或者如果我更改顺序我可以打开一个但不能关闭另一个。 (我想我已经尝试过101版本了)。如果有人能帮忙的话。
blue sky 默认情况下,当指针悬停时显示标题。 是否可以切换它,例如: $('#button').on('click', function(){ if (something) {turn
我正在编写一个简单的宏,它将打开、保存和关闭一个 Excel 文件(例如 myworkbook.xlsx),但我无法执行此操作。我的文件 myworkbook.xlsx 位于以下位置: C:\User
我正在加载两个 geoJson 层 - 出于测试目的,两个层都是相同的数据,但是是从两个不同的 json 文件中提取的。当我在图层 Controller 中打开和关闭图层时,图层的绘制顺序会发生变化。
我在我的设置 Activity 中发现,当用户单击 ToggleButton 时,它应该在整个应用程序中静音,但它不起作用。我在教程类中放入的 SoundPool onClick 按钮声音仍在 onC
我有一部双卡手机。如果我想打开飞行模式,两个 SIM 卡都会发生这种情况。 是否可以通过编程方式仅对一张SIM卡进行操作(用户可以选择两者之一)?我看到了here上的帖子,他们一直工作到 API 16
我目前正在开发一个带有一些 pipe() 和重定向的 C shell 程序。 我使用 dup2() stdout 和 stderr (1 & 2) 重定向。 当我用 int fd = open("te
Jquery: 有没有办法捕获浏览器打开“打开/另存为”对话框时触发的事件? Open/Save dialog example http://qpack.orcanos.com/helpcenter/
我知道你可以用 window.close 关闭 window.open 但还有其他方法吗?我有一个打开 facebook 连接的弹出窗口,我想在用户连接到 facebook 时关闭弹出窗口,然后刷新父
我搜索一个事件,如果不存在,则搜索一种方法来了解屏幕是否关闭(电源选项 - 控制面板 - 关闭显示设置)。 这些解决方案都不适合我。 所以要么我在某个地方错了,要么就是不合适。 How to get
我是一名优秀的程序员,十分优秀!