python镜头畸变校正,lensfun的包装器

lensfunp的Python项目详细描述


Linux/macOS Build StatusWindows Build Status

lensfunpy是用于lensfun库的易于使用的python包装器。

API Documentation

示例代码

如何找到相机和镜头:

importlensfunpycam_maker='NIKON CORPORATION'cam_model='NIKON D3S'lens_maker='Nikon'lens_model='Nikkor 28mm f/2.8D AF'db=lensfunpy.Database()cam=db.find_cameras(cam_maker,cam_model)[0]lens=db.find_lenses(cam,lens_maker,lens_model)[0]print(cam)# Camera(Maker: NIKON CORPORATION; Model: NIKON D3S; Variant: ;#        Mount: Nikon F AF; Crop Factor: 1.0; Score: 0)print(lens)# Lens(Maker: Nikon; Model: Nikkor 28mm f/2.8D AF; Type: RECTILINEAR;#      Focal: 28.0-28.0; Aperture: 2.79999995232-2.79999995232;#      Crop factor: 1.0; Score: 110)

如何校正镜头失真:

importcv2# OpenCV libraryfocal_length=28.0aperture=1.4distance=10image_path='/path/to/image.tiff'undistorted_image_path='/path/to/image_undist.tiff'im=cv2.imread(image_path)height,width=im.shape[0],im.shape[1]mod=lensfunpy.Modifier(lens,cam.crop_factor,width,height)mod.initialize(focal_length,aperture,distance)undist_coords=mod.apply_geometry_distortion()im_undistorted=cv2.remap(im,undist_coords,None,cv2.INTER_LANCZOS4)cv2.imwrite(undistorted_image_path,im_undistorted)

也可以通过SciPy而不是opencv应用修正。 lensfunpy.util模块 包含处理opencv和scipy的rgb图像的便利函数。

安装

为python 2.7、3.4、3.5、3.6和3.7提供了用于linux、macos和windows的二进制控制盘。 这些可以用简单的pip install lensfunpy安装。 目前,Linux和MacOS控制盘仅提供64位版本。

在Linux/MacOS上从源代码安装

如果需要使用特定的lensfun版本,或者不能使用提供的二进制控制盘 然后按照本节中的步骤从源代码构建lensfunpy。

首先,在系统上安装lensfun库。

在ubuntu上,您可以使用以下命令获得(过时的)版本:

sudo apt-get install liblensfun-dev

或者从git存储库安装最新的开发人员版本:

git clone git://git.code.sf.net/p/lensfun/code lensfun
cd lensfun
cmake .
sudo make install

之后,使用pip install lensfunpy --no-binary lensfunpy安装lensfunpy。

如果出现错误“importerror:liblensfun.so.0:无法打开共享对象文件:没有这样的文件或目录” 尝试使用lensfunpy时,请执行以下操作:

echo"/usr/local/lib"| sudo tee /etc/ld.so.conf.d/99local.conf
sudo ldconfig

从源代码编译时,lensfun库安装在/usr/local/lib中,显然未搜索此文件夹 对于某些Linux发行版中的库,默认情况下为。 注意,在某些系统上,安装路径可能略有不同,例如/usr/local/lib/x86_64-linux-gnu/usr/local/lib64

numpy依赖性

伦斯芬比取决于纽比。支持的最低numpy版本取决于您的python版本:

Pythonnumpy
2.7>= 1.7
3.4>= 1.8
3.5>= 1.9
3.6>= 1.11
3.7>= 1.14

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Java中ArrayList的超简单问题   Java 8在一段时间后过期   java如何创建具有用户定义维度的矩阵,并使用从上到下、从左到右的递增值填充它?   java从JDBC重启mysql   带有sqlite的java LiveData未更新UI   带有JDialog的java小程序在Mac OSX中未正确隐藏   java ActionListener无法从公共类引用数组?   java Apache Digester:NoSuchMethodException:没有这样的可访问方法   安卓中数据库中的java数据没有以正确的格式检索   java快速排序实现:使用random pivot时几乎排序   安卓 Java:高效的ArrayList过滤?   java如何在单独的文件中制作GUI程序   jasper报告如何从JSP或Java代码在JasperReport中传递参数值?