ubuntu20.04安装libraw,并测试libraw

本文指导如何从官方网站下载LibRaw,通过编译步骤安装,并解决aclocal-1.15缺失的问题。然后在CMakeLists中配置OpenCV3,用C++编写代码读取并处理raw图像,展示了一个使用LibRaw和OpenCV显示Bayer图像的示例。
摘要由CSDN通过智能技术生成

1、下载安装包并解压到目录

https://www.libraw.org/download

2、编译安装

autoreconf --install

cd LibRaw-X.YY

./configure # with optional args

make

sudo make install

3、问题一 'aclocal-1.15' is missing on your system.

第一次时,直接执行的./configure,接着make

在make时出现报错:'aclocal-1.15' is missing on your system.

参考https://blog.csdn.net/DeliaPu/article/details/126486906

  1. 测试libraw及使用(clion,opencv3.4.18)

  1. cmakelist文件

cmake_minimum_required(VERSION 3.24)
project(untitled)


IF(NOT CMAKE_BUILD_TYPE)
    SET(CMAKE_BUILD_TYPE Release)
ENDIF()
find_package(OpenCV 3 REQUIRED)



set(CMAKE_CXX_STANDARD 17)

add_executable(untitled2 main.cpp sift.cpp sift.h)
target_link_libraries(untitled2
        ${OpenCV_LIBS}
        )

main.cpp


#include <iostream>
#include <libraw/libraw.h>
#include <opencv2/opencv.hpp>
int main(int argc, char *argv[])
{
    // Read raw image with libraw
    LibRaw RawProcessor;
    int result = RawProcessor.open_file(argv[1]);
    if (result != LIBRAW_SUCCESS)
    {
        std::cerr << "Cannot open file: " << libraw_strerror(result) << std::endl;
        return 1;
    }
    RawProcessor.unpack();
    cv::Mat bayer_image(RawProcessor.imgdata.sizes.height, RawProcessor.imgdata.sizes.width, CV_16UC1, RawProcessor.imgdata.rawdata.raw_image);
    cv::Mat rgb_image;
    cv::cvtColor(bayer_image, rgb_image, cv::COLOR_BayerRG2RGB);
    // Display image with OpenCV
    cv::imshow("Image", rgb_image);
    cv::waitKey(0);
    return 0;
}
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值