.. _program_listing_file__tmp_ws_src_vitis_common_include_imgproc_xf_aec.hpp: Program Listing for File xf_aec.hpp =================================== |exhale_lsh| :ref:`Return to documentation for file ` (``/tmp/ws/src/vitis_common/include/imgproc/xf_aec.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp /* * Copyright 2020 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. */ #ifndef _XF_AEC_HPP_ #define _XF_AEC_HPP_ #include "../common/xf_common.hpp" #include "hls_math.h" #include "hls_stream.h" #include "xf_bgr2hsv.hpp" #include "xf_channel_combine.hpp" #include "xf_channel_extract.hpp" #include "xf_cvt_color.hpp" #include "xf_cvt_color_1.hpp" #include "xf_duplicateimage.hpp" #include "xf_hist_equalize.hpp" #include "xf_histogram.hpp" template T xf_satcast_aec(int in_val){}; template <> inline ap_uint<8> xf_satcast_aec >(int v) { v = (v > 255 ? 255 : v); v = (v < 0 ? 0 : v); return v; }; template <> inline ap_uint<10> xf_satcast_aec >(int v) { v = (v > 1023 ? 1023 : v); v = (v < 0 ? 0 : v); return v; }; template <> inline ap_uint<12> xf_satcast_aec >(int v) { v = (v > 4095 ? 4095 : v); v = (v < 0 ? 0 : v); return v; }; template <> inline ap_uint<16> xf_satcast_aec >(int v) { v = (v > 65535 ? 65535 : v); v = (v < 0 ? 0 : v); return v; }; namespace xf { namespace cv { template void autoexposurecorrection(xf::cv::Mat& src, xf::cv::Mat& dst, uint32_t hist_array1[1][256], uint32_t hist_array2[1][256]) { #pragma HLS INLINE OFF int rows = src.rows; int cols = src.cols; uint16_t cols_shifted = cols >> (XF_BITSHIFT(NPC)); uint16_t rows_shifted = rows; xf::cv::Mat bgr2hsv(rows, cols); xf::cv::Mat hsvimg1(rows, cols); xf::cv::Mat hsvimg2(rows, cols); xf::cv::Mat hsvimg3(rows, cols); xf::cv::Mat himage(rows, cols); xf::cv::Mat simage(rows, cols); xf::cv::Mat vimage(rows, cols); xf::cv::Mat vimage1(rows, cols); xf::cv::Mat vimage2(rows, cols); xf::cv::Mat vimage_eq(rows, cols); xf::cv::Mat imgHelper6(rows, cols); assert(((rows <= ROWS) && (cols <= COLS)) && "ROWS and COLS should be greater than input image"); // clang-format off #pragma HLS DATAFLOW // clang-format on // Convert RGBA to HSV: xf::cv::bgr2hsv(src, bgr2hsv); xf::cv::duplicateimages(bgr2hsv, hsvimg1, hsvimg2, hsvimg3); xf::cv::extractChannel(hsvimg1, himage, 0); xf::cv::extractChannel(hsvimg2, simage, 1); xf::cv::extractChannel(hsvimg3, vimage, 2); xf::cv::duplicateMat(vimage, vimage1, vimage2); // xf::cv::equalizeHist(vimage1, vimage2, // vimage_eq); xFHistogramKernel> (XF_BITSHIFT(NPC))) >> 1), XF_CHANNELS(SIN_CHANNEL_TYPE, NPC)>(vimage1, hist_array1, rows_shifted, cols_shifted); xFEqualize> XF_BITSHIFT(NPC))>(vimage2, hist_array2, vimage_eq, rows_shifted, cols_shifted); xf::cv::merge(vimage_eq, simage, himage, imgHelper6); xf::cv::hsv2bgr(imgHelper6, dst); } } } #endif