You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
MpPreview/app/src/main/cpp/hdr.cpp

68 lines
1.3 KiB
C++

#include <jni.h>
#include <string>
#include <vector>
#include <fcntl.h>
#include <unistd.h>
#include <omp.h>
#include <android/imagedecoder.h>
#include <android/log.h>
#include <media/NdkImage.h>
#include <opencv2/opencv.hpp>
#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include "hdr.h"
int main( int argc, char** argv )
{
if (argc != 7)
{
return -1;
}
std::string outputPath = argv[1];
std::string tmpFilePath = argv[2];
std::vector<float> times;
times.push_back((double)(atoi(argv[3])) / 1000000000.0);
times.push_back((double)(atoi(argv[5])) / 1000000000.0);
std::vector<std::string> paths;
paths.push_back(std::string(argv[4]));
paths.push_back(std::string(argv[6]));
std::vector<cv::Mat> images;
images.resize(2);
printf("Start Decode");
#pragma omp parallel for num_threads(2)
for (int idx = 0; idx < 2; idx++)
{
images[idx] = cv::imread(paths[idx].c_str());
}
printf("End Decode");
cv::Mat rgb;
printf("Start MakeHDR3");
makeHdr(times, images, rgb);
printf("End MakeHDR3");
std::vector<int> params;
params.push_back(cv::IMWRITE_JPEG_QUALITY);
params.push_back(100);
if (cv::imwrite(outputPath.c_str(), rgb, params))
{
printf("End HDR3");
return JNI_TRUE;
}
return 0;
}