forked from timothybrooks/hdr-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request timothybrooks#36 from brotherofken/add_exif2_support
Add LibRaw for input reading.
- Loading branch information
Showing
7 changed files
with
269 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,36 @@ | ||
cmake_minimum_required(VERSION 2.8.11) | ||
cmake_minimum_required(VERSION 3.10) | ||
project(HDR_PLUS) | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_FLAGS "-O3 -g -Wall") | ||
#set(CMAKE_CXX_FLAGS "-O3 -v -g -Wall") # Use -DCMAKE_BUILD_TYPE=Release/Debug instead | ||
find_package(PNG REQUIRED) | ||
|
||
|
||
set(HALIDE_ROOT_DIR "") | ||
|
||
if(" ${HALIDE_ROOT_DIR}" STREQUAL " ") | ||
message( FATAL_ERROR "Specify HALIDE_ROOT_DIR variable in the cmake file." ) | ||
endif() | ||
|
||
find_library(LIBRAW_LIBRARY | ||
NAMES raw raw_r | ||
) | ||
|
||
set(src_files | ||
src/HDRPlus.cpp | ||
src/align.cpp | ||
src/finish.cpp | ||
src/merge.cpp | ||
src/util.cpp | ||
) | ||
src/InputSource.cpp | ||
src/InputSource.h | ||
src/Burst.cpp | ||
src/Burst.h) | ||
|
||
include_directories(/usr/local/lib /usr/local/include ${HALIDE_ROOT_DIR}/bin ${HALIDE_ROOT_DIR}/lib ${HALIDE_ROOT_DIR}/include ${HALIDE_ROOT_DIR}/tools) | ||
|
||
link_directories(/usr/local/lib /usr/local/include ${HALIDE_ROOT_DIR}/bin ${HALIDE_ROOT_DIR}/lib ${HALIDE_ROOT_DIR}/include ${HALIDE_ROOT_DIR}/tools) | ||
|
||
include_directories(${HALIDE_ROOT_DIR}/lib ${HALIDE_ROOT_DIR}/include ${HALIDE_ROOT_DIR}/tools) | ||
link_directories(${HALIDE_ROOT_DIR}/bin ${HALIDE_ROOT_DIR}/lib) | ||
|
||
add_executable(hdrplus ${src_files}) | ||
|
||
target_link_libraries(hdrplus Halide png) | ||
target_link_libraries(hdrplus Halide png ${LIBRAW_LIBRARY}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "Burst.h" | ||
|
||
Halide::Runtime::Buffer<uint16_t> Burst::ToBuffer() const { | ||
if (Raws.empty()) { | ||
return Halide::Runtime::Buffer<uint16_t>(); | ||
} | ||
|
||
Halide::Runtime::Buffer<uint16_t> result(GetWidth(), GetHeight(), Raws.size()); | ||
for (int i = 0; i < Raws.size(); ++i) { | ||
auto resultSlice = result.sliced(2, i); | ||
Raws[i]->CopyToBuffer(resultSlice); | ||
} | ||
return result; | ||
} | ||
|
||
void Burst::CopyToBuffer(Halide::Runtime::Buffer<uint16_t> &buffer) const { | ||
buffer.copy_from(ToBuffer()); | ||
} | ||
|
||
std::vector<AbstractInputSource::SPtr> Burst::LoadRaws(const std::string &dirPath, std::vector<std::string> &inputs) { | ||
std::vector<AbstractInputSource::SPtr> result; | ||
for (const auto& input : inputs) { | ||
const std::string img_path = dirPath + "/" + input; | ||
result.emplace_back(std::make_shared<RawSource>(img_path)); | ||
} | ||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#pragma once | ||
|
||
#include "InputSource.h" | ||
|
||
#include <Halide.h> | ||
|
||
#include <string> | ||
#include <vector> | ||
#include <Halide.h> | ||
|
||
class Burst : public AbstractInputSource { | ||
public: | ||
Burst(std::string dir_path, std::vector<std::string> inputs) | ||
: Dir(std::move(dir_path)) | ||
, Inputs(std::move(inputs)) | ||
, Raws(LoadRaws(Dir, Inputs)) | ||
{} | ||
|
||
~Burst() override = default; | ||
|
||
int GetWidth() const override { return Raws.empty() ? -1 : Raws[0]->GetWidth(); } | ||
|
||
int GetHeight() const override { return Raws.empty() ? -1 : Raws[0]->GetHeight(); } | ||
|
||
int GetBlackLevel() const override { return Raws.empty() ? -1 : Raws[0]->GetBlackLevel(); } | ||
|
||
int GetWhiteLevel() const override { return Raws.empty() ? -1 : Raws[0]->GetWhiteLevel(); } | ||
|
||
WhiteBalance GetWhiteBalance() const override { return Raws.empty() ? WhiteBalance{-1, -1, -1, -1} : Raws[0]->GetWhiteBalance(); } | ||
|
||
Halide::Runtime::Buffer<uint16_t> ToBuffer() const; | ||
|
||
void CopyToBuffer(Halide::Runtime::Buffer<uint16_t>& buffer) const override; | ||
|
||
private: | ||
std::string Dir; | ||
std::vector<std::string> Inputs; | ||
std::vector<AbstractInputSource::SPtr> Raws; | ||
|
||
private: | ||
static std::vector<AbstractInputSource::SPtr> LoadRaws(const std::string& dirPath, std::vector<std::string>& inputs); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.