ubuntu20.04安装libraw,并测试libraw

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;
}

猜你喜欢

转载自blog.csdn.net/zenglongjian/article/details/129225919