#include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QElapsedTimer loading; loading.start(); cv::Mat image = cv::imread("C://Effective_Bayer.tif", cv::IMREAD_GRAYSCALE); if (image.empty()) qDebug() << "Image vide"; else { qDebug() << "[CPU] Chargement OK : " << loading.elapsed() << "ms"; loading.restart(); cv::Mat image = cv::imread("C://Effective_Bayer.tif", cv::IMREAD_GRAYSCALE); cv::UMat image2; image.copyTo(image2); qDebug() << "[GPU] Chargement OK : " << loading.elapsed() << "ms"; qDebug() << "Height : " << image.size().height; qDebug() << "Width : " << image.size().width; if (image.channels() != 1) { qDebug() << image.channels() << "channels found, need 1 only"; return 0; } qDebug() << "Channels : " << image.channels(); qDebug() << "\r\r"; cv::Mat image_debayer_cpu(image.size().height, image.size().width, CV_16UC3); cv::UMat image_debayer_gpu(image.size().height, image.size().width, CV_16UC3); std::vector compression_params; compression_params.push_back(259); compression_params.push_back(1); loading.restart(); cv::cvtColor(image, image_debayer_cpu, cv::COLOR_BayerBG2BGR); qDebug() << "[CPU] cv::COLOR_BayerBG2BGR done in :\t\t" << loading.elapsed() << "ms"; loading.restart(); cv::cvtColor(image, image_debayer_cpu, cv::COLOR_BayerBG2BGR_EA); qDebug() << "[CPU] cv::COLOR_BayerBG2BGR_EA done in :\t" << loading.elapsed() << "ms"; loading.restart(); cv::cvtColor(image, image_debayer_cpu, cv::COLOR_BayerBG2BGR_VNG); qDebug() << "[CPU] cv::COLOR_BayerBG2BGR_VNG done in :\t" << loading.elapsed() << "ms"; loading.restart(); cv::cvtColor(image, image_debayer_cpu, cv::COLOR_BayerBG2BGRA); qDebug() << "[CPU] cv::COLOR_BayerBG2BGRA done in :\t\t" << loading.elapsed() << "ms"; if (cv::ocl::haveOpenCL() == true) { cv::ocl::Context ctx = cv::ocl::Context::getDefault(); if (!ctx.ptr()) { qDebug() << "OpenCL is not available"; return 1; } cv::ocl::Device device = cv::ocl::Device::getDefault(); if (!device.compilerAvailable()) { qDebug() << "OpenCL compiler is not available"; return 1; } loading.restart(); cv::cvtColor(image, image_debayer_gpu, cv::COLOR_BayerBG2BGR); qDebug() << "[GPU] cv::COLOR_BayerBG2BGR done in :\t\t" << loading.elapsed() << "ms"; loading.restart(); cv::cvtColor(image, image_debayer_gpu, cv::COLOR_BayerBG2BGR_EA); qDebug() << "[GPU] cv::COLOR_BayerBG2BGR_EA done in :\t" << loading.elapsed() << "ms"; loading.restart(); cv::cvtColor(image, image_debayer_gpu, cv::COLOR_BayerBG2BGR_VNG); qDebug() << "[GPU] cv::COLOR_BayerBG2BGR_VNG done in :\t" << loading.elapsed() << "ms"; loading.restart(); cv::cvtColor(image, image_debayer_gpu, cv::COLOR_BayerBG2BGRA); qDebug() << "[GPU] cv::COLOR_BayerBG2BGRA done in :\t\t" << loading.elapsed() << "ms"; loading.restart(); cv::imwrite("Output.tif", image_debayer_cpu, compression_params); qDebug() << "saved in : " << loading.elapsed() << "ms"; } } return a.exec(); }