I am working on an image processing algorithm to detect markers. The code uses the opencv library and works perfectly fine. However I have been asked to put it into HDL using HLS to optimize the design. The thing is HLS doesn't allow the use of many structures and forms used in a standard code.
My main problem here is that I use a variable defined as a Vec3b
, which can't be synthesized by HLS.
I read this from the opencv documentation :
Vec : template class for short numerical vectors, a partial case of Matx
template<typename _Tp, int n> class Vec : public Matx<_Tp, n, 1> {...};
typedef Vec<uchar, 3> Vec3b;
Without entering into details about HLS, I would like to know if it is possible to replace the Vec3b
type by one that could be synthesizable like Scalar_
or get it back as a simple Matx
.
Concerning the scalars, i found this in the doc :
It is possible to convert Vec<T,2> to/from Point_, Vec<T,3> to/from Point3_ , and Vec<T,4> to CvScalar or Scalar_. Use operator[] to access the elements of Vec.
I also put the whole code here in case it is needed. I am not the author, so it is written in spanish.
void recorroHorizontal(){
for(int i=0;i<480;i++){
colorAux=enHSB.at<Vec3b>(0,i); //Cuidado con el acceso al revés
int punto_anterior = (int)(colorAux[2]);
for(int j=1;j<640-1;j++){
colorAux=enHSB.at<Vec3b>(i,j); //al reves j e i
float brightness=colorAux[2];
int brightnessi=(int)(brightness);
h_pendientes[i][j]=brightnessi- punto_anterior;
if(!(h_pendientes[i][j]>VALOR_PENDIENTE || h_pendientes[i][j]<-VALOR_PENDIENTE)){
if(!(h_pendientes[i][j] + h_pendientes[i][j-1] >VALOR_PENDIENTE_TRUNCAR || h_pendientes[i][j] + h_pendientes[i][j+1]<-VALOR_PENDIENTE_TRUNCAR)){
h_pendientes[i][j]=0;
}
}
if(j<2 || i<2 || 640-1 ==i){h_pendientes[i][j]=0;}
punto_anterior=brightnessi;
original[i][j]=brightnessi;
}
}
}