UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Observer kiniman_2000
Observer
185 Views
Registered: ‎10-21-2018

xfOpenCV pass from scalar to xf::Mat issue

Hello, I have the below code, trying to convert a picture to grayscale with Converttogrey function and I am using xfopencv library. I have used a similar function with hls library and it works, but with xfopencv I can´t use the operator >> or write.

void converttogrey(xf::Mat<TYPE, HEIGHT, WIDTH, NPC1> &img_in,xf::Mat<TYPE, HEIGHT, WIDTH, NPC1> &img_out){

	RGB_PIX pin;	// scalar 3, unsigned char
	GREY_PIX pout;	// scalar 3, unsigned char
	Pixel grey_val;	// integer 10 bits

	L_row: for(int row = 0; row < 512; row++) {
#pragma HLS LOOP_TRIPCOUNT min=1 max=512
		L_col: for(int col = 0; col < 512; col++) {
#pragma HLS LOOP_TRIPCOUNT min=1 max=512
#pragma HLS PIPELINE rewind

		//img_in >> pin;	//Format not valid for xfopencv library
			
		pin.val[0]=img_in.data[row*WIDTH + col].range(7,0);
		pin.val[1]=img_in.data[row*WIDTH + col].range(15,8);
		pin.val[2]=img_in.data[row*WIDTH + col].range(23,16);

			grey_val = const1 * pin.val[0] + const2 * pin.val[1] + const3 * pin.val[2];

			pout.val[0] = grey_val;
			pout.val[1] = grey_val;
			pout.val[2] = grey_val;

				   //img_out << pout; Format not valid for xfopencv library
			//img_out.data[row * WIDTH + col] = pout.val;  //Return a black image
			img_out.data[row * WIDTH + col].range(7,0) = pout.val[0];
			img_out.data[row * WIDTH + col].range(15,8) = pout.val[1];
			img_out.data[row * WIDTH + col].range(23,16) = pout.val[2];									}
												}
	}

I am getting an error because of the last 3 lines, but I don´t find a way to pass from the scalar "pout" to the xf:mat "img_out". Could you please help with this?

Stream '_dst.data.V'  failed dataflow checking: it cannot be read and written in the same function:  'converttogrey'.
ERROR: [HLS 200-70] Pre-synthesis failed.

 

0 Kudos
1 Reply
Xilinx Employee
Xilinx Employee
112 Views
Registered: ‎08-20-2018

Re: xfOpenCV pass from scalar to xf::Mat issue

Hi @kiniman_2000 

As there is dataflow error, I suggest to first complete the code migration and when your application is working then apply optimization techniques (eg. Pragma) so we can narrow down the exact issue.

Best Regards,
Nutan
-------------------------------------------------------------------------------
Please don't forget to reply, kudo and accept as a solution
0 Kudos