/*
* Copyright 2019 Xilinx, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "common/xf_headers.hpp"
#include "xf_median_blur_config.h"
int main(int argc, char** argv) {
if (argc != 2) {
fprintf(stderr, "Usage: %s <INPUT IMAGE PATH 1>", argv[0]);
return EXIT_FAILURE;
}
cv::Mat in_img, out_img, ocv_ref, diff, cnv_img, cnv_out_img;
// Reading in the image:
#if GRAY
in_img = cv::imread(argv[1], 0); // reading in the gray image
#else
in_img = cv::imread(argv[1], 1); // reading in the color image
cnv_img.create(in_img.rows, in_img.cols, CV_8UC4);
cv::cvtColor(in_img, cnv_img, cv::COLOR_BGR2BGRA);
#endif
if (in_img.data == NULL) {
fprintf(stderr, "ERROR: Cannot open image %s\n ", argv[1]);
return EXIT_FAILURE;
}
// create memory for output image
#if GRAY
ocv_ref.create(in_img.rows, in_img.cols, CV_8UC1);
out_img.create(in_img.rows, in_img.cols, CV_8UC1); // create memory for output image
diff.create(in_img.rows, in_img.cols, CV_8UC1);
#else
ocv_ref.create(in_img.rows, in_img.cols, CV_8UC3);
out_img.create(in_img.rows, in_img.cols, CV_8UC4); // create memory for output image
cnv_out_img.create(in_img.rows, in_img.cols, CV_8UC3);
diff.create(in_img.rows, in_img.cols, CV_8UC3);
#endif
// OpenCV reference:
cv::medianBlur(in_img, ocv_ref, WINDOW_SIZE);
// OpenCL section:
#if GRAY
size_t image_in_size_bytes = in_img.rows * in_img.cols * 1 * sizeof(unsigned char);
#else
size_t image_in_size_bytes = in_img.rows * in_img.cols * 3 * sizeof(unsigned char);
#endif
size_t image_out_size_bytes = image_in_size_bytes;
// Call the top function
median_blur_accel((ap_uint<PTR_WIDTH>*)cnv_img.data, cnv_img.rows, cnv_img.cols, (ap_uint<PTR_WIDTH>*)out_img.data);
cv::cvtColor(out_img, cnv_out_img, cv::COLOR_BGRA2BGR);
// Write down output images:
cv::imwrite("hls_out.jpg", cnv_out_img); // kernel output
cv::imwrite("ref_img.jpg", ocv_ref); // reference image
absdiff(ocv_ref, cnv_out_img, diff);
// Save the difference image for debugging purpose:
cv::imwrite("error.png", diff);
float err_per;
xf::cv::analyzeDiff(diff, 10, err_per);
return 0;
}
/media/masaaki/Ubuntu_Disk/Xilinx_github/Vitis_Libraries/vision/L1/include/imgproc/xf_median_blur.hpp: In instantiation of ‘void xf::cv::xFMedianNxN(xf::cv::Mat<TYPE, ROWS, COLS, NPC>&, xf::cv::Mat<TYPE, ROWS, COLS, NPC>&, ap_uint<8>, uint16_t, uint16_t) [with int ROWS = 600; int COLS = 800; int PLANES = 4; int TYPE = 7; int NPC = 1; int WORDWIDTH = 0; int TC = 801; int WIN_SZ = 3; int WIN_SZ_SQ = 9; uint16_t = short unsigned int]’:
/media/masaaki/Ubuntu_Disk/Xilinx_github/Vitis_Libraries/vision/L1/include/imgproc/xf_median_blur.hpp:462:56: required from ‘void xf::cv::medianBlur(xf::cv::Mat<TYPE, ROWS, COLS, NPC>&, xf::cv::Mat<TYPE, ROWS, COLS, NPC>&) [with int FILTER_SIZE = 3; int BORDER_TYPE = 1; int TYPE = 7; int ROWS = 600; int COLS = 800; int NPC = 1]’
../../../xf_median_blur_accel.cpp:41:104: required from here
/media/masaaki/Ubuntu_Disk/Xilinx_github/Vitis_Libraries/vision/L1/include/imgproc/xf_median_blur.hpp:363:22: エラー: no type named ‘uname’ in ‘struct PixelType<7>’
XF_PTUNAME(TYPE) OutputValues[XF_NPIXPERCYCLE(NPC)];
^~~~~~~~~~~~
/media/masaaki/Ubuntu_Disk/Xilinx_github/Vitis_Libraries/vision/L1/include/imgproc/xf_median_blur.hpp:368:22: エラー: no type named ‘uname’ in ‘struct PixelType<7>’
XF_PTUNAME(TYPE) src_buf[WIN_SZ][XF_NPIXPERCYCLE(NPC) + (WIN_SZ - 1)];
^~~~~~~
/media/masaaki/Ubuntu_Disk/Xilinx_github/Vitis_Libraries/vision/L1/include/imgproc/xf_median_blur.hpp:368:22: エラー: no type named ‘uname’ in ‘struct PixelType<7>’
/media/masaaki/Ubuntu_Disk/Xilinx_github/Vitis_Libraries/vision/L1/include/imgproc/xf_median_blur.hpp:363:22: エラー: no type named ‘uname’ in ‘struct PixelType<7>’
XF_PTUNAME(TYPE) OutputValues[XF_NPIXPERCYCLE(NPC)];
^~~~~~~~~~~~
make: *** [obj/xf_median_blur_accel.o] Error 1
ERROR: [SIM 211-100] 'csim_design' failed: compilation error(s).
INFO: [SIM 211-3] *************** CSIM finish ***************
INFO: [HLS 200-111] Finished Command csim_design CPU user time: 4.12 seconds. CPU system time: 0.3 seconds. Elapsed time: 3.89 seconds; current allocated memory: 164.609 MB.
日 | 月 | 火 | 水 | 木 | 金 | 土 |
---|---|---|---|---|---|---|
- | - | - | - | - | 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 | - | - | - | - | - | - |