Skip to content

Commit 969d6b9

Browse files
committed
Updated 2018.3 xfOpenCV version
1 parent 802ca33 commit 969d6b9

File tree

365 files changed

+15266
-3293
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

365 files changed

+15266
-3293
lines changed
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
/* Optimization type */
22

3-
#define RO 0 // Resource Optimized (8-pixel implementation)
4-
#define NO 1 // Normal Operation (1-pixel implementation)
3+
#define RO 0 // Resource Optimized (8-pixel implementation)
4+
#define NO 1 // Normal Operation (1-pixel implementation)
5+
6+
7+
#define GRAY 1
8+
9+
#define FILTER_SIZE 3
10+
11+
#define KERNEL_SHAPE XF_SHAPE_CROSS
12+
13+
#define ITERATIONS 1
14+
515

616

HLS_Use_Model/AXI_Sample/xf_dilation_accel.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030

3131
#include "xf_dilation_config.h"
3232

33-
void dilation_accel(xf::Mat<TYPE, HEIGHT, WIDTH, NPC1> &_src,xf::Mat<TYPE, HEIGHT, WIDTH, NPC1> &_dst)
33+
void dilation_accel(xf::Mat<TYPE, HEIGHT, WIDTH, NPC1> &_src,xf::Mat<TYPE, HEIGHT, WIDTH, NPC1> &_dst, unsigned char kernel[FILTER_SIZE*FILTER_SIZE])
3434
{
3535

36-
xf::dilate<XF_BORDER_CONSTANT,TYPE ,HEIGHT, WIDTH,NPC1>(_src, _dst);
36+
37+
xf::dilate<XF_BORDER_REPLICATE, TYPE ,HEIGHT, WIDTH, KERNEL_SHAPE, FILTER_SIZE, FILTER_SIZE, ITERATIONS, NPC1>(_src, _dst, kernel);
38+
3739
}
Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,65 @@
11
/***************************************************************************
2-
Copyright (c) 2018, Xilinx, Inc.
3-
All rights reserved.
2+
Copyright (c) 2018, Xilinx, Inc.
3+
All rights reserved.
44
5-
Redistribution and use in source and binary forms, with or without modification,
6-
are permitted provided that the following conditions are met:
5+
Redistribution and use in source and binary forms, with or without modification,
6+
are permitted provided that the following conditions are met:
77
8-
1. Redistributions of source code must retain the above copyright notice,
9-
this list of conditions and the following disclaimer.
8+
1. Redistributions of source code must retain the above copyright notice,
9+
this list of conditions and the following disclaimer.
1010
11-
2. Redistributions in binary form must reproduce the above copyright notice,
12-
this list of conditions and the following disclaimer in the documentation
13-
and/or other materials provided with the distribution.
11+
2. Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
1414
15-
3. Neither the name of the copyright holder nor the names of its contributors
16-
may be used to endorse or promote products derived from this software
17-
without specific prior written permission.
15+
3. Neither the name of the copyright holder nor the names of its contributors
16+
may be used to endorse or promote products derived from this software
17+
without specific prior written permission.
1818
19-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21-
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22-
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24-
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25-
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28-
29-
***************************************************************************/
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22+
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25+
HOWEVER CXFSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3028
29+
***************************************************************************/
3130
#ifndef _XF_HEADERS_H_
3231
#define _XF_HEADERS_H_
3332

33+
3434
#include <stdio.h>
3535
#include <stdlib.h>
36-
37-
36+
#include <stdint.h>
37+
#include "ap_int.h"
38+
#include "hls_stream.h"
3839

3940
#if __SDSCC__
4041
#undef __ARM_NEON__
4142
#undef __ARM_NEON
4243
#include "opencv2/opencv.hpp"
43-
#include "opencv2/imgproc/imgproc.hpp"
4444
#include "opencv2/highgui/highgui.hpp"
45+
#include "opencv2/imgproc/imgproc.hpp"
4546
#define __ARM_NEON__
4647
#define __ARM_NEON
4748
#else
48-
#include "opencv2/opencv.hpp"
49+
#include "opencv/cv.h"
50+
#include "opencv/highgui.h"
4951
#include "opencv2/imgproc/imgproc.hpp"
50-
#include "opencv2/highgui/highgui.hpp"
5152
#endif
5253

5354

55+
5456
#if __SDSCC__
5557
#include "sds_lib.h"
5658
#define TIME_STAMP_INIT unsigned int clock_start, clock_end; clock_start = sds_clock_counter();
5759
#define TIME_STAMP { clock_end = sds_clock_counter(); printf("elapsed time %lu \n", clock_end-clock_start); clock_start = sds_clock_counter(); }
5860
#endif
5961

6062
#include "common/xf_sw_utils.h"
61-
#include "common/xf_axi.h"
62-
#endif//_XF_HEADERS_H_
6363

64+
65+
#endif//_XF_HEADERS_H_

HLS_Use_Model/AXI_Sample/xf_ip_accel_app.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include "xf_dilation_config.h"
22

3-
void dilation_accel(xf::Mat<TYPE, HEIGHT, WIDTH, NPC1> &_src,xf::Mat<TYPE, HEIGHT, WIDTH, NPC1> &_dst);
3+
void dilation_accel(xf::Mat<TYPE, HEIGHT, WIDTH, NPC1> &_src,xf::Mat<TYPE, HEIGHT, WIDTH, NPC1> &_dst, unsigned char kernel[FILTER_SIZE*FILTER_SIZE]);
44

5-
void ip_accel_app(hls::stream< ap_axiu<8,1,1,1> >& _src,hls::stream< ap_axiu<8,1,1,1> >& _dst,int height,int width)
5+
void ip_accel_app(hls::stream< ap_axiu<8,1,1,1> >& _src,hls::stream< ap_axiu<8,1,1,1> >& _dst,int height,int width, unsigned char kernel[FILTER_SIZE*FILTER_SIZE])
66
{
77
#pragma HLS INTERFACE axis register both port=_src
88
#pragma HLS INTERFACE axis register both port=_dst
@@ -16,7 +16,7 @@ void ip_accel_app(hls::stream< ap_axiu<8,1,1,1> >& _src,hls::stream< ap_axiu<8,1
1616

1717
xf::AXIvideo2xfMat(_src, imgInput1);
1818

19-
dilation_accel(imgInput1,imgOutput1);
19+
dilation_accel(imgInput1,imgOutput1, kernel);
2020

2121
xf::xfMat2AXIvideo(imgOutput1, _dst);
2222

HLS_Use_Model/Standalone_HLS_Example/script.tcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
############################################################
44
open_project dilation_project
55
set_top dilation_accel
6-
add_files ./xf_dilation_accel.cpp -cflags "-D__XFCV_HLS_MODE__ -I../../include -I../../include/src --std=c++0x"
6+
add_files ./xf_dilation_accel.cpp -cflags "-D__XFCV_HLS_MODE__ -I../../include --std=c++0x"
77
add_files -tb ./testcase55.jpg
8-
add_files -tb ./xf_dilation_tb.cpp -cflags "-D__XFCV_HLS_MODE__ -I../../include -I../../include/src --std=c++0x"
8+
add_files -tb ./xf_dilation_tb.cpp -cflags "-D__XFCV_HLS_MODE__ -I../../include --std=c++0x"
99
open_solution "solution1"
1010
set_part {xczu9eg-ffvb1156-2-i} -tool vivado
1111
create_clock -period 10 -name default
Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
/* Optimization type */
22

3-
#define RO 0 // Resource Optimized (8-pixel implementation)
4-
#define NO 1 // Normal Operation (1-pixel implementation)
3+
#define RO 0 // Resource Optimized (8-pixel implementation)
4+
#define NO 1 // Normal Operation (1-pixel implementation)
5+
6+
7+
#define GRAY 1
8+
9+
#define FILTER_SIZE 3
10+
11+
#define KERNEL_SHAPE XF_SHAPE_CROSS
12+
13+
#define ITERATIONS 1
514

615

716

HLS_Use_Model/Standalone_HLS_Example/xf_dilation_accel.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030

3131
#include "xf_dilation_config.h"
3232

33-
void dilation_accel(xf::Mat<TYPE, HEIGHT, WIDTH, NPC1> &_src,xf::Mat<TYPE, HEIGHT, WIDTH, NPC1> &_dst)
33+
void dilation_accel(xf::Mat<TYPE, HEIGHT, WIDTH, NPC1> &_src,xf::Mat<TYPE, HEIGHT, WIDTH, NPC1> &_dst, unsigned char kernel[FILTER_SIZE*FILTER_SIZE])
3434
{
3535

36-
xf::dilate<XF_BORDER_CONSTANT,TYPE ,HEIGHT, WIDTH,NPC1>(_src, _dst);
36+
37+
xf::dilate<XF_BORDER_REPLICATE, TYPE ,HEIGHT, WIDTH, KERNEL_SHAPE, FILTER_SIZE, FILTER_SIZE, ITERATIONS, NPC1>(_src, _dst,kernel);
38+
3739
}

HLS_Use_Model/Standalone_HLS_Example/xf_dilation_config.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4040

4141

4242
/* config width and height */
43-
#define WIDTH 1920
44-
#define HEIGHT 1080
43+
#define WIDTH 3840
44+
#define HEIGHT 2160
4545

4646

4747
/* define the input and output types */
@@ -55,9 +55,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5555

5656
#define TYPE XF_8UC1
5757

58-
void dilation_accel(xf::Mat<TYPE, HEIGHT, WIDTH, NPC1> &_src,xf::Mat<TYPE, HEIGHT, WIDTH, NPC1> &_dst);
59-
60-
58+
void dilation_accel(xf::Mat<TYPE, HEIGHT, WIDTH, NPC1> &_src,xf::Mat<TYPE, HEIGHT, WIDTH, NPC1> &_dst, unsigned char kernel[FILTER_SIZE*FILTER_SIZE]);
6159
#endif // _XF_DILATION_CONFIG_H_
6260

6361

HLS_Use_Model/Standalone_HLS_Example/xf_dilation_tb.cpp

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ int main(int argc, char** argv)
4545

4646
cv::Mat in_img,in_img1,out_img,ocv_ref;
4747
cv::Mat in_gray,in_gray1,diff;
48-
48+
#if GRAY
4949
// reading in the color image
5050
in_gray = cv::imread(argv[1], 0);
51+
#endif
5152

5253

5354
if (in_gray.data == NULL)
@@ -57,24 +58,39 @@ int main(int argc, char** argv)
5758
}
5859

5960

60-
61-
//cvtColor(in_gray,in_gray,CV_BGR2GRAY);
61+
#if GRAY
6262
// create memory for output images
6363
ocv_ref.create(in_gray.rows,in_gray.cols,CV_8UC1);
6464
out_img.create(in_gray.rows,in_gray.cols,CV_8UC1);
6565
diff.create(in_gray.rows,in_gray.cols,CV_8UC1);
66-
///////////////// Opencv Reference ////////////////////////
67-
cv::Mat element = cv::getStructuringElement( 0,cv::Size(3, 3), cv::Point(-1, -1));
68-
cv::dilate(in_gray, ocv_ref, element, cv::Point(-1, -1), 1, cv::BORDER_CONSTANT);
69-
cv::imwrite("out_ocv.jpg", ocv_ref);
66+
#endif
7067

7168

7269

70+
cv::Mat element = cv::getStructuringElement( KERNEL_SHAPE,cv::Size(FILTER_SIZE, FILTER_SIZE), cv::Point(-1, -1));
71+
cv::dilate(in_gray, ocv_ref, element, cv::Point(-1, -1), ITERATIONS, cv::BORDER_CONSTANT);
72+
cv::imwrite("out_ocv.jpg", ocv_ref);
73+
///////////////////// End of OpenCV reference ////////////////
74+
75+
//////////////////// HLS TOP function call /////////////////
76+
7377
static xf::Mat<TYPE, HEIGHT, WIDTH, NPC1> imgInput(in_gray.rows,in_gray.cols);
7478
static xf::Mat<TYPE, HEIGHT, WIDTH, NPC1> imgOutput(in_gray.rows,in_gray.cols);
7579

7680

77-
//imgInput = xf::imread<TYPE, HEIGHT, WIDTH, NPC1>(argv[1], 0);
81+
#if __SDSCC__
82+
unsigned char *structure_element=(unsigned char *)sds_alloc_non_cacheable(sizeof(unsigned char)*FILTER_SIZE*FILTER_SIZE);
83+
#else
84+
unsigned char structure_element[FILTER_SIZE*FILTER_SIZE];
85+
#endif
86+
87+
88+
for(int i=0;i<(FILTER_SIZE*FILTER_SIZE);i++)
89+
{
90+
structure_element[i]=element.data[i];
91+
}
92+
93+
// unsigned char iterations=2;
7894

7995
imgInput.copyTo(in_gray.data);
8096

@@ -85,7 +101,7 @@ int main(int argc, char** argv)
85101
hw_ctr.start();
86102
#endif
87103

88-
dilation_accel(imgInput, imgOutput);
104+
dilation_accel(imgInput, imgOutput, structure_element);
89105

90106
#if __SDSCC__
91107
hw_ctr.stop();
Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,65 @@
11
/***************************************************************************
2-
Copyright (c) 2018, Xilinx, Inc.
3-
All rights reserved.
2+
Copyright (c) 2018, Xilinx, Inc.
3+
All rights reserved.
44
5-
Redistribution and use in source and binary forms, with or without modification,
6-
are permitted provided that the following conditions are met:
5+
Redistribution and use in source and binary forms, with or without modification,
6+
are permitted provided that the following conditions are met:
77
8-
1. Redistributions of source code must retain the above copyright notice,
9-
this list of conditions and the following disclaimer.
8+
1. Redistributions of source code must retain the above copyright notice,
9+
this list of conditions and the following disclaimer.
1010
11-
2. Redistributions in binary form must reproduce the above copyright notice,
12-
this list of conditions and the following disclaimer in the documentation
13-
and/or other materials provided with the distribution.
11+
2. Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
1414
15-
3. Neither the name of the copyright holder nor the names of its contributors
16-
may be used to endorse or promote products derived from this software
17-
without specific prior written permission.
15+
3. Neither the name of the copyright holder nor the names of its contributors
16+
may be used to endorse or promote products derived from this software
17+
without specific prior written permission.
1818
19-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21-
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22-
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24-
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25-
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28-
29-
***************************************************************************/
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22+
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25+
HOWEVER CXFSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3028
29+
***************************************************************************/
3130
#ifndef _XF_HEADERS_H_
3231
#define _XF_HEADERS_H_
3332

33+
3434
#include <stdio.h>
3535
#include <stdlib.h>
36-
37-
36+
#include <stdint.h>
37+
#include "ap_int.h"
38+
#include "hls_stream.h"
3839

3940
#if __SDSCC__
4041
#undef __ARM_NEON__
4142
#undef __ARM_NEON
4243
#include "opencv2/opencv.hpp"
43-
#include "opencv2/imgproc/imgproc.hpp"
4444
#include "opencv2/highgui/highgui.hpp"
45+
#include "opencv2/imgproc/imgproc.hpp"
4546
#define __ARM_NEON__
4647
#define __ARM_NEON
4748
#else
48-
#include "opencv2/opencv.hpp"
49+
#include "opencv/cv.h"
50+
#include "opencv/highgui.h"
4951
#include "opencv2/imgproc/imgproc.hpp"
50-
#include "opencv2/highgui/highgui.hpp"
5152
#endif
5253

5354

55+
5456
#if __SDSCC__
5557
#include "sds_lib.h"
5658
#define TIME_STAMP_INIT unsigned int clock_start, clock_end; clock_start = sds_clock_counter();
5759
#define TIME_STAMP { clock_end = sds_clock_counter(); printf("elapsed time %lu \n", clock_end-clock_start); clock_start = sds_clock_counter(); }
5860
#endif
5961

6062
#include "common/xf_sw_utils.h"
61-
#include "common/xf_axi.h"
62-
#endif//_XF_HEADERS_H_
6363

64+
65+
#endif//_XF_HEADERS_H_

0 commit comments

Comments
 (0)