<div dir="ltr"><div><div><div></div>I'm using Scilab API list function to access 2D/3D matrices from Scilab environment in the C++ code. This list is then converted into a Mat object and passed to OpenCV. <br><br></div>I'm having trouble accessing the child elements of the list. <br><br>int retrieveImage(Mat &image,int pos)<br>{<br><br>   SciErr sciErr;<br>   int iRows=0,iCols=0,i,j,k=0;<br>   int *piAddr = NULL;<br>   int *piAddrChild = NULL;<br>   int iPrec = 0,iItem = 0;<br><br>   //retrieving number of items in the list and type of data(integer/float)<br>   sciErr = getVarAddressFromPosition(pvApiCtx,pos,&piAddr);<br>   if(sciErr.iErr)  <br>   {<br>       printError(&sciErr, 0);<br>       return 0;<br>   }<br>   sciErr = getListItemAddress(pvApiCtx,piAddr,1,&piAddrChild);<br>   if(sciErr.iErr)  <br>   {<br>       printError(&sciErr, 0);<br>       return 0;<br>   }<br>   sciErr = getListItemNumber(pvApiCtx,piAddr,&iItem);<br>   if(sciErr.iErr)  <br>   {<br>       printError(&sciErr, 0);<br>       return 0;<br>   }<br>   <br>   if(isIntegerType(pvApiCtx, piAddrChild))<br>   {<br></div>     // Retrieve 2D/3D matrices of int type<br><div>   }<br>   else //for floating point/ double precision values<br>   {<br>       if(iItem==3)<br>       {<br>          <br>           double *pstDataR = NULL;<br>           double *pstDataG = NULL;<br>           double *pstDataB = NULL;<br>           sciErr = getVarAddressFromPosition(pvApiCtx,pos,&piAddr);<br>           if(sciErr.iErr)  <br>           {<br>               printError(&sciErr, 0);<br>               return 0;<br>           }<br>           <br>           //retrive the matrix of the R values  <br>           sciErr = getMatrixOfDoubleInList(pvApiCtx, piAddr, 1, &iRows, &iCols, &pstDataR);<br>           if(sciErr.iErr)<br>           {<br>               printError(&sciErr, 0);<br>               return 0;<br>           }<br>           <br>           //retrive address of the list<br>           sciErr = getVarAddressFromPosition(pvApiCtx,pos,&piAddr);<br>           if(sciErr.iErr)  <br>           {<br>               printError(&sciErr, 0);<br>               return 0;<br>           }              <br>           //retrive the matrix of the G values <br>           sciErr = getMatrixOfDoubleInList(pvApiCtx, piAddr, 2, &iRows, &iCols, &pstDataG);<br>           if(sciErr.iErr)<br>           {<br>               printError(&sciErr, 0);<br>               return 0;<br>           }<br>           <br>           //retrive address of the list<br>           sciErr = getVarAddressFromPosition(pvApiCtx,pos,&piAddr);<br>           if(sciErr.iErr)  <br>           {<br>               printError(&sciErr, 0);<br>               return 0;<br>           }  <br>           //retrive the matrix of the B values <br>           sciErr = getMatrixOfDoubleInList(pvApiCtx, piAddr, 3, &iRows, &iCols, &pstDataB);<br>           if(sciErr.iErr)<br>           {<br>               printError(&sciErr, 0);<br>               return 0;<br>           }<br>           <br>           //creating an image matrix with the no. of rows and columns we retrieved, and assigning it to be of the form 8-bit unsinged integers<br>           image = Mat(iRows,iCols,CV_64FC3);<br><br>           //Now that we have the 3 matrices(R,G,B), we need to assign those values to the pixels. The following code does this<br>           k=0;<br>           for(i=0;i<iRows;i++)<br>           {<br>               for(j=0;j<iCols;j++)<br>               {<br>                   <a href="http://image.at">image.at</a><Vec3d>(i,j)[2]=pstDataR[i+iRows*j];<br>                   <a href="http://image.at">image.at</a><Vec3d>(i,j)[1]=pstDataG[i+iRows*j];<br>                   <a href="http://image.at">image.at</a><Vec3d>(i,j)[0]=pstDataB[i+iRows*j];<br>               }<br>           }<br>       }<br>       else<br>       {<br></div><div>           // Grayscale images<br></div><div>           double *pstDataR = NULL;<br>           sciErr = getVarAddressFromPosition(pvApiCtx,pos,&piAddr);<br>           if(sciErr.iErr)  <br>           {<br>               printError(&sciErr, 0);<br>               return 0;<br>           }<br>           //retrive one 2D matrix of image <br>           sciErr = getMatrixOfDoubleInList(pvApiCtx, piAddr, 1, &iRows, &iCols, &pstDataR);<br>           if(sciErr.iErr)<br>           {<br>               printError(&sciErr, 0);<br>               return 0;<br>           }<br><br>           image = Mat(iRows,iCols,CV_64FC1);<br><br>           //Assigning image matrix values to pixels<br>           k=0;<br>           for(i=0;i<iRows;i++)<br>               for(j=0;j<iCols;j++)<br>                   <a href="http://image.at">image.at</a><double>(i,j)=pstDataR[i+iRows*j];                   <br>       }<br>   }<br>   return 1;<br>}<br><br></div><div>When I use this function, I get the error-<br><br>API Error:<br>   in getMatrixOfDoubleInList: Unable to get address of item #2 in argument #1<br>   in getMatrixOfDouble: Invalid argument type, double matrix expected<br> <br><br></div><div>What is wrong with the code?<br><br></div><div>Shamika<br></div></div>