Skip to content

Commit 7d4e609

Browse files
Merge pull request #5 from MicrochipTech/release2023.2
Pushing for 2023.2 release
2 parents b3db3f6 + 35a19f5 commit 7d4e609

File tree

90 files changed

+3429
-3050
lines changed

Some content is hidden

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

90 files changed

+3429
-3050
lines changed

vision/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Please see the readme files in sub-directories for more details.
4848

4949
- To use the SmartHLS Vision library, you should first install the SmartHLS tool, which is part of the [Libero SoC Design Suite](https://www.microchip.com/en-us/products/fpgas-and-plds/fpga-and-soc-design-tools/fpga/libero-software-later-versions).
5050

51-
`Note: This library is designed to work on the latest Libero SoC Design Suite version, 2023.1, and may not be compatible with previous versions of Libero and SmartHLS.`
51+
`Note: This library is designed to work on the latest Libero SoC Design Suite version, 2023.2, and may not be compatible with previous versions of Libero and SmartHLS.`
5252

5353
- The repository uses Git Large File System (LFS) to track media files (e.g., images). So we need to install Git LFS.
5454
- First make sure you have Git and Git LFS installed. If not, you can follow this instruction: https://github.com/git-guides/install-git
@@ -69,7 +69,7 @@ Please see the readme files in sub-directories for more details.
6969
- The SmartHLS Vision library supports using OpenCV functionality in the software testbench of a SmartHLS project.
7070
So we will also download a precompiled OpenCV library using a provided script (see [here](https://microchiptech.github.io/fpga-hls-docs/precompiled_sw.html#ffmpeg-4-4-and-opencv-4-5-4) for more details):
7171
```console
72-
> /cygdrive/c/Microchip/Libero_SoC_v2023.1/SmartHLS-2023.1/SmartHLS/examples/scripts/utils/download_libraries.sh
72+
> /cygdrive/c/Microchip/Libero_SoC_v2023.2/SmartHLS-2023.2/SmartHLS/examples/scripts/utils/download_libraries.sh
7373
```
7474

7575
## Getting Started

vision/demo_designs/PF_Video_kit/README.md

Lines changed: 46 additions & 51 deletions
Large diffs are not rendered by default.
Loading
Loading

vision/demo_designs/PF_Video_kit/hls/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
SRCS=pf_demo.cpp
22
LOCAL_CONFIG = -legup-config=config.tcl
3-
LEVEL = $(LEGUP_ROOT_DIR)/examples
3+
LEVEL = $(SHLS_ROOT_DIR)/examples
44

55
ifeq ($(shell uname -o), Cygwin)
66
# Use cygpath to locate the Windows location
7-
OPENCV_PATH := $(shell cygpath -t mixed $(LEGUP_ROOT_DIR)/precompiled_sw_libraries/opencv4.5.4-x86_64-cygwin)
7+
OPENCV_PATH := $(shell cygpath -t mixed $(SHLS_ROOT_DIR)/precompiled_sw_libraries/opencv4.5.4-x86_64-cygwin)
88
else
9-
OPENCV_PATH := $(LEGUP_ROOT_DIR)/precompiled_sw_libraries/opencv4.5.4-x86_64-linux
9+
OPENCV_PATH := $(SHLS_ROOT_DIR)/precompiled_sw_libraries/opencv4.5.4-x86_64-linux
1010
endif
1111

1212
USER_CXX_FLAG += -I$(OPENCV_PATH)/include/opencv4
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
source $env(LEGUP_ROOT_DIR)/examples/legup.tcl
1+
source $env(SHLS_ROOT_DIR)/examples/legup.tcl
22
set_project PolarFire MPF300 hw_only
33
# set_project PolarFireSoC MPFS250T MiV_SoC
44

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../media_files/test_images/demo_golden.png

vision/demo_designs/PF_Video_kit/hls/pf_demo.cpp

Lines changed: 54 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -21,100 +21,98 @@ using vision::PixelType::HLS_8UC3;
2121

2222
// Define data types used in the design.
2323
using BayerAxisVideoT = vision::AxisVideoFIFO<HLS_8UC1, NPPC_4>;
24-
using RgbAxisVideoT = vision::AxisVideoFIFO<HLS_8UC3, NPPC_4>;
24+
using RGBAxisVideoT = vision::AxisVideoFIFO<HLS_8UC3, NPPC_4>;
2525
using BayerImgT =
2626
vision::Img<HLS_8UC1, HEIGHT, WIDTH, StorageType::FIFO, NPPC_4>;
27-
using RgbImgT = vision::Img<HLS_8UC3, HEIGHT, WIDTH, StorageType::FIFO, NPPC_4>;
28-
29-
// The following 3 top functions are compiled to RTL and are used on board:
30-
void DDR_Read_wrapper(uint64_t *Buf, BayerAxisVideoT &VideoOut, int HRes,
31-
int VRes) {
32-
#pragma HLS function top dataflow
33-
#pragma HLS interface argument(Buf) type(axi_initiator) \
34-
num_elements(NumAxiWords) max_burst_len(256)
35-
36-
vision::AxiMM2AxisVideo<AxiWordWidth, uint64_t, HEIGHT, WIDTH>(
37-
Buf, VideoOut, HRes, VRes);
38-
}
27+
using RGBImgT = vision::Img<HLS_8UC3, HEIGHT, WIDTH, StorageType::FIFO, NPPC_4>;
28+
using GrayImgT =
29+
vision::Img<HLS_8UC1, HEIGHT, WIDTH, StorageType::FIFO, NPPC_4>;
3930

31+
// The following 2 top functions are compiled to RTL and are used on board:
4032
void DDR_Write_wrapper(BayerAxisVideoT &VideoIn, uint64_t *Buf, int HRes,
4133
int VRes) {
42-
#pragma HLS function top dataflow
34+
#pragma HLS function top
4335
#pragma HLS interface argument(Buf) type(axi_initiator) \
4436
num_elements(NumAxiWords) max_burst_len(256)
4537

4638
vision::AxisVideo2AxiMM<AxiWordWidth, uint64_t, HEIGHT, WIDTH>(VideoIn, Buf,
4739
HRes, VRes);
4840
}
4941

50-
void VideoPipelineTop(BayerAxisVideoT &VideoIn, RgbAxisVideoT &VideoOut,
42+
void VideoPipelineTop(uint64_t *Buf, RGBAxisVideoT &VideoOut,
5143
ap_uint<2> BayerFormat = 0) {
5244
#pragma HLS function top
5345
#pragma HLS function dataflow
46+
#pragma HLS interface argument(Buf) type(axi_initiator) \
47+
num_elements(NumAxiWords) max_burst_len(256)
5448
BayerImgT BayerImg;
55-
RgbImgT RGBImage;
56-
vision::AxisVideo2Img(VideoIn, BayerImg);
57-
vision::DeBayer(BayerImg, RGBImage, BayerFormat);
58-
vision::Img2AxisVideo(RGBImage, VideoOut);
49+
RGBImgT RGBInImg, RGBOutImg;
50+
GrayImgT GSImg, CannyImg;
51+
unsigned Thres = 110;
52+
53+
vision::AxiMM2Img<AxiWordWidth>(Buf, BayerImg);
54+
vision::DeBayer(BayerImg, RGBInImg, BayerFormat);
55+
vision::RGB2GRAY(RGBInImg, GSImg);
56+
vision::Canny(GSImg, CannyImg, Thres);
57+
vision::GRAY2RGB(CannyImg, RGBOutImg);
58+
vision::Img2AxisVideo(RGBOutImg, VideoOut);
5959
}
6060

6161
// This main implements a testbench verifying the above top-level functions.
6262
int main() {
6363
// Step 1: create the input to top-level functions.
64-
// - generate an RGB image using pattern generator
65-
// - convert the image to Bayer format
66-
// - then inject the image into an AXI-S video protocol stream.
64+
// - Read an RGB image
65+
// - Convert the image to Bayer format
66+
// - Then inject the image into an AXI-S video protocol stream.
6767
// The resulting pixel stream is similar to the input data coming from the
6868
// camera module on board.
69-
RgbImgT PatternImg;
70-
BayerImgT BayerImgIn;
71-
BayerAxisVideoT InputStream(NumPixelWords), DDRReadFIFO(NumPixelWords);
72-
vision::PatternGenerator<3>(PatternImg);
73-
vision::RGB2Bayer(PatternImg, BayerImgIn);
74-
vision::Img2AxisVideo(BayerImgIn, InputStream);
69+
RGBImgT InImg;
70+
BayerImgT BayerInImg;
71+
BayerAxisVideoT InStream(NumPixelWords), DDRReadFIFO(NumPixelWords);
72+
Mat BGRInMat = cv::imread("toronto_4k.jpg", cv::IMREAD_COLOR);
73+
Mat RGBInMat;
74+
cv::cvtColor(BGRInMat, RGBInMat, cv::COLOR_BGR2RGB);
75+
76+
// Convert the cv Mat into Img class
77+
convertFromCvMat(RGBInMat, InImg);
78+
vision::RGB2Bayer(InImg, BayerInImg);
79+
vision::Img2AxisVideo(BayerInImg, InStream);
7580

7681
// Step 2: pass the input to the top-level functions and obtain the output.
77-
// The InputStream is fed to DDR write and read functions, which write
78-
// incoming data to DDR and read it back.
79-
// The data read from DDR is then forwarded to the video pipeline which does
80-
// DeBayer on the incoming data and outputs data in RGB format.
82+
// The InStream is fed to DDR write function, which writes incoming data
83+
// to DDR.
84+
// The video pipeline reads data from DDR and does DeBayer, RGB2Gray, Canny,
85+
// Gray2RGB, and outputs data in RGB format.
8186

82-
// Intermediate data between DDR writer and DDR reader. You can think of it
83-
// as the DDR memory. 'static' so we don't get stack overflow.
87+
// Intermediate data between DDR writer and video pipeline. You can think of
88+
// it as the DDR memory. 'static' so we don't get stack overflow.
8489
static uint64_t Buf[NumPixelWords];
8590
// Output from
86-
RgbAxisVideoT OutputStream(NumPixelWords);
87-
// Call the three top-level funtions.
88-
DDR_Write_wrapper(InputStream, Buf, WIDTH, HEIGHT);
89-
DDR_Read_wrapper(Buf, DDRReadFIFO, WIDTH, HEIGHT);
90-
VideoPipelineTop(DDRReadFIFO, OutputStream, 0);
91-
91+
RGBAxisVideoT OutputStream(NumPixelWords);
92+
// Call the two top-level functions.
93+
DDR_Write_wrapper(InStream, Buf, WIDTH, HEIGHT);
94+
VideoPipelineTop(Buf, OutputStream, 0);
9295
// Step 3: verify the output data by comparing against an expected image.
9396

9497
// Convert OutputStream to `vision::Img` type and then to `cv::Mat` type.
95-
RgbImgT OutImg;
98+
RGBImgT OutImg;
9699
vision::AxisVideo2Img(OutputStream, OutImg);
97100
cv::Mat HlsOutMat;
98101
convertToCvMat(OutImg, HlsOutMat);
102+
cv::imwrite("hls_out.png", HlsOutMat);
99103

100-
// Create the golden output Mat with the same pattern as above input image.
101-
RgbImgT GoldenImg;
102-
vision::PatternGenerator<3>(GoldenImg);
103-
cv::Mat GoldenMat;
104-
convertToCvMat(GoldenImg, GoldenMat);
104+
// Read the golden image
105+
Mat GoldenMat = cv::imread("demo_golden.png", cv::IMREAD_COLOR);
106+
Mat GoldenRGBMat;
107+
cv::cvtColor(GoldenMat, GoldenRGBMat, cv::COLOR_BGR2RGB);
105108

106109
// Now compare the two Mat's, with a threshold of 0 (any pixel with
107110
// difference in value will be considered as an error).
108-
// Use this commented out line to report location of errors.
109-
// vision::compareMatAndReport<cv::Vec3b>(HlsOutMat, GoldenMat, 0);
110-
float ErrPercent = vision::compareMat(HlsOutMat, GoldenMat, 0);
111-
printf("Percentage of pixels with difference over threshold: %0.2lf%\n",
112-
ErrPercent);
113-
114-
// Consider the test passes if there is less than 1% of pixels in
115-
// difference.
116-
bool Pass = (ErrPercent < 1.f);
117-
printf("%s\n", Pass ? "PASS" : "FAIL");
118111

112+
// Use this commented out line to report location of errors.
113+
// vision::compareMatAndReport<cv::Vec3b>(HlsOutMat, GoldenRGBMat, 0);
114+
float ErrPercent = vision::compareMat(HlsOutMat, GoldenRGBMat, 0);
115+
bool Pass = (ErrPercent == 0.0);
116+
printf("%s\n", Pass ? "Pass" : "Fail");
119117
return Pass ? 0 : 1; // Only return 0 on pass.
120118
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../PF_Video_kit/../../media_files/toronto_4k.jpg

vision/demo_designs/PF_Video_kit/libero/libero_flow.tcl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ new_project -location {./vision_pipeline} -name {vision_pipeline} -project_descr
55
source ../../../rtl/ip_core_versions.tcl
66

77
#Download all the required cores to the vault (Camera and display components will download their required cores separately)
8-
download_core -vlnv "Microsemi:SolutionCore:Display_Controller:${Display_Controller_version}" -location {www.microchip-ip.com/repositories/DirectCore}
98
download_core -vlnv "Actel:SystemBuilder:PF_DDR4:${PF_DDR4_version}" -location {www.microchip-ip.com/repositories/SgCore}
109
download_core -vlnv "Actel:SystemBuilder:PF_SRAM_AHBL_AXI:${PF_SRAM_AHBL_AXI_version}" -location {www.microchip-ip.com/repositories/SgCore}
1110
download_core -vlnv "Actel:DirectCore:COREI2C:${COREI2C_version}" -location {www.microchip-ip.com/repositories/DirectCore}

0 commit comments

Comments
 (0)