cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
xf_gammacorrection_accel.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Xilinx, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
29 #include "../include/xf_gammacorrection_config.h"
30 
31 
38 void gammacorrection_accel(xf::cv::Mat<IN_TYPE, HEIGHT, WIDTH, NPC1>& imgInput1,
39  xf::cv::Mat<OUT_TYPE, HEIGHT, WIDTH, NPC1>& imgOutput,
40  float gammaval) {
41  xf::cv::gammacorrection<IN_TYPE, OUT_TYPE, HEIGHT, WIDTH, NPC1>(imgInput1, imgOutput, gammaval);
42 }
43 
44 
45 
52 //extern "C" {
54  ap_uint<INPUT_PTR_WIDTH>* img_inp, ap_uint<OUTPUT_PTR_WIDTH>* img_out, int rows, int cols, int threshold, int k) {
55 // clang-format off
56 /* #pragma HLS INTERFACE m_axi port=img_inp offset=slave bundle=gmem1
57  #pragma HLS INTERFACE m_axi port=img_out offset=slave bundle=gmem2
58 
59  #pragma HLS INTERFACE s_axilite port=rows bundle=control
60  #pragma HLS INTERFACE s_axilite port=cols bundle=control
61  #pragma HLS INTERFACE s_axilite port=threshold bundle=control
62  #pragma HLS INTERFACE s_axilite port=k bundle=control
63  #pragma HLS INTERFACE s_axilite port=return bundle=control
64  // clang-format on
65 */
66  const int pROWS = HEIGHT;
67  const int pCOLS = WIDTH;
68  const int pNPC1 = NPIX;
69 
70  xf::cv::Mat<XF_8UC1, HEIGHT, WIDTH, NPIX> in_mat(rows, cols);
71 // clang-format off
72  #pragma HLS stream variable=in_mat.data depth=2
73  // clang-format on
74 
75  xf::cv::Mat<XF_8UC1, HEIGHT, WIDTH, NPIX> out_mat(rows, cols);
76 // clang-format off
77  #pragma HLS stream variable=out_mat.data depth=2
78 // clang-format on
79 
80 // clang-format off
81  #pragma HLS DATAFLOW
82  // clang-format on
83  xf::cv::Array2xfMat<INPUT_PTR_WIDTH, IN_TYPE, HEIGHT, WIDTH, NPIX>(img_inp, in_mat);
84  float gammaval = 0.2;
85  xf::cv::gammacorrection<IN_TYPE, OUT_TYPE, HEIGHT, WIDTH, NPC1>(in_mat, out_mat, gammaval);
86  xf::cv::xfMat2Array<OUTPUT_PTR_WIDTH, OUT_TYPE, HEIGHT, WIDTH, NPIX>(out_mat, img_out);
87 }
88 //}
89 
90 
91 
98 //extern "C" {
100  hls::stream<ap_axiu<INPUT_PTR_WIDTH, 0, 0, 0> >& img_in_axi_stream,
101  hls::stream<ap_axiu<OUTPUT_PTR_WIDTH, 0, 0, 0> >& img_out_axi_stream,
102  int rows, int cols, int threshold, int k) {
103  // clang-format on
104 
105  const int pROWS = HEIGHT;
106  const int pCOLS = WIDTH;
107  const int pNPC1 = NPIX;
108 
109  xf::cv::Mat<IN_TYPE, HEIGHT, WIDTH, NPIX> in_mat(rows, cols);
110  // clang-format off
111  #pragma HLS stream variable=in_mat.data depth=2
112  // clang-format on
113 
114  xf::cv::Mat<OUT_TYPE, HEIGHT, WIDTH, NPIX> out_mat(rows, cols);
115  // clang-format off
116  #pragma HLS stream variable=out_mat.data depth=2
117  // clang-format on
118 
119  // clang-format off
120  #pragma HLS DATAFLOW
121  // clang-format on
122 
123  xf::cv::axiStrm2xfMat<INPUT_PTR_WIDTH, IN_TYPE, HEIGHT, WIDTH, NPIX>(
124  img_in_axi_stream, in_mat);
125  float gammaval = 0.2;
126  xf::cv::gammacorrection<IN_TYPE, OUT_TYPE, HEIGHT, WIDTH, NPC1>(in_mat, out_mat, gammaval);
127  xf::cv::xfMat2axiStrm<OUTPUT_PTR_WIDTH, OUT_TYPE, HEIGHT, WIDTH, NPIX>(
128  out_mat, img_out_axi_stream);
129 
130 
131 }
132 //}
133 
134 
135 
136 
void gammacorrection_accel(xf::cv::Mat< XF_8UC1, 256, 256, XF_NPPC1 > &imgInput1, xf::cv::Mat< XF_8UC1, 256, 256, XF_NPPC1 > &imgOutput, float gammaval)
Top-level accelerated function of the Gammacorrection Application with xf::cv I/F.
void GammacorrectionAccelArray(ap_uint< 64 > *img_inp, ap_uint< 64 > *img_out, int rows, int cols, int threshold, int k)
Top-level accelerated function of the Gammacorrection Application with array I/F.
void GammacorrectionAccelStream(hls::stream< ap_axiu< 64, 0, 0, 0 > > &img_in_axi_stream, hls::stream< ap_axiu< 64, 0, 0, 0 > > &img_out_axi_stream, int rows, int cols, int threshold, int k)
Top-level accelerated function of the Gammacorrection Application with array I/F.
#define WIDTH
#define NPIX
#define HEIGHT