|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
30 const int rem = len % pad;
31 return (rem != 0) ? (pad - rem) : 0;
42 char *p = ((
char *)ptr) + addbytes;
44 return reinterpret_cast<T*
>(p);
50 if (ptr ==
nullptr)
return;
52 const char addbytes = *(((
char *)ptr) - 1);
53 delete[]
reinterpret_cast<T*
>(((
char *)ptr) - addbytes);
80 int anchorX,
int anchorY,
int* values,
int nShiftR))
85 ret->anchorX = anchorX;
86 ret->anchorY = anchorY;
89 ret->nShiftR = nShiftR;
90 ret->values =
new int[nCols * nRows];
92 memcpy (
ret->values, values,
sizeof(
int) * nCols * nRows);
108 int anchorX,
int anchorY,
float* values))
113 ret->anchorX = anchorX;
114 ret->anchorY = anchorY;
117 ret->values =
new float[nCols * nRows];
119 memcpy (
ret->values, values,
sizeof(
float) * nCols * nRows);
125 int* anchorX,
int* anchorY,
int** values,
int *nShiftR))
130 *nCols = kernel->
nCols;
131 *nRows = kernel->
nRows;
134 memcpy (*values, kernel->
values,
sizeof(
int) * *nCols * *nRows);
139 int* anchorX,
int* anchorY,
float** values))
144 *nCols = kernel->
nCols;
145 *nRows = kernel->
nRows;
148 memcpy (*values, kernel->
values,
sizeof(
float) * *nCols * *nRows);
153 if (kernel ==
nullptr)
162 if (kernel ==
nullptr)
174 static char *__tmp_res =
nullptr;
175 static int __tmp_size = -1;
184 int *values = ktmp->
values;
190 const int krows = ktmp->
nRows;
191 const int kcols = ktmp->
nCols;
192 const int borderx = kcols / 2;
193 const int bordery = krows / 2;
194 const int w = srcImage->
width;
195 const int h = srcImage->
height;
200 if (__tmp_res ==
nullptr)
204 __tmp_res = AllocAligned<char> (dstImage->
imageSize);
209 if (__tmp_size < dstImage->imageSize)
212 FreeAligned<char> (__tmp_res);
216 __tmp_res = AllocAligned<char> (dstImage->
imageSize);
221 switch (srcImage->
depth)
226 for (
int i = bordery; i < h - bordery; i++)
228 for (
int j = borderx; j < w - borderx; j++)
231 for (
int k = 0; k < krows; k++)
232 for (
int l = 0; l < kcols; l++)
234 tmp += srcImage->
imageData[(i + k - bordery) * w + j + l - borderx]
235 * values[ksize - k * kcols - l - 1];
243 __tmp_res[i * w + j] = char(tmp);
254 for (
int i = bordery; i < h - bordery; i++)
256 for (
int j = borderx; j < w - borderx; j++)
259 for (
int k = 0; k < krows; k++)
260 for (
int l = 0; l < kcols; l++)
262 tmp += srcImage->
imageData[(i + k - bordery) * w + j + l - borderx]
263 * values[ksize - k * kcols - l - 1];
271 __tmp_res[i * w + j] = char(tmp);
292 static float *__tmp_res =
nullptr;
293 static int __tmp_size = -1;
302 float *values = ktmp->
values;
308 const int kcols = ktmp->
nCols;
309 const int krows = ktmp->
nRows;
310 const int borderx = kcols / 2;
311 const int bordery = krows / 2;
312 const int w = srcImage->
width;
313 const int h = srcImage->
height;
319 if (__tmp_res ==
nullptr)
321 __tmp_size = dstImage->
imageSize /
sizeof(float);
323 __tmp_res = AllocAligned<float> (dstImage->
imageSize /
sizeof(
float));
328 if (__tmp_size < (
int)(dstImage->
imageSize /
sizeof(
float)))
332 FreeAligned<float> (__tmp_res);
333 __tmp_size = dstImage->
imageSize /
sizeof(float);
335 __tmp_res = AllocAligned<float> (dstImage->
imageSize /
sizeof(
float));
340 if (srcImage != dstImage)
343 auto* source =
reinterpret_cast<float*
>(srcImage->
imageData);
344 auto* dest =
reinterpret_cast<float*
>(dstImage->
imageData);
345 for (
int i = bordery; i < h - bordery; i++)
347 for (
int j = borderx; j < w - borderx; j++)
350 for (
int k = 0; k < krows; k++)
351 for (
int l = 0; l < kcols; l++)
353 tmp += source[(i + k - bordery) * w + j + l - borderx]
354 * values[ksize - k * kcols - l - 1];
356 dest[i * w + j] = tmp;
364 auto* source =
reinterpret_cast<float*
>(srcImage->
imageData);
366 for (
int i = bordery; i < h - bordery; i++)
368 for (
int j = borderx; j < w - borderx; j++)
371 for (
int k = 0; k < krows; k++)
372 for (
int l = 0; l < kcols; l++)
374 tmp += source[(i + k - bordery) * w + j + l - borderx]
375 * values[ksize - k * kcols - l - 1];
377 __tmp_res[i * w + j] = tmp;
392 static float *__tmp_res =
nullptr;
393 static int __tmp_size = -1;
395 if (xKernel !=
nullptr)
400 if (yKernel !=
nullptr)
408 float *xvalues = (xKernel !=
nullptr) ? xKernel->
values :
nullptr;
409 const int xksize = (xKernel !=
nullptr) ? xKernel->
nCols : 0;
410 float *yvalues = (yKernel !=
nullptr) ? yKernel->
values :
nullptr;
411 const int yksize = (yKernel !=
nullptr) ? yKernel->
nRows : 0;
413 const int borderx = (xKernel !=
nullptr) ? xKernel->
nCols / 2 : 0;
414 const int bordery = (yKernel !=
nullptr) ? yKernel->
nRows / 2 : 0;
415 const int w = srcImage->
width;
416 const int h = srcImage->
height;
422 if (__tmp_res ==
nullptr)
424 __tmp_size = dstImage->
imageSize /
sizeof(float);
426 __tmp_res = AllocAligned<float> (dstImage->
imageSize /
sizeof(
float));
431 if (__tmp_size <
int(dstImage->
imageSize /
sizeof(
float)))
435 FreeAligned<float> (__tmp_res);
436 __tmp_size = dstImage->
imageSize /
sizeof(float);
438 __tmp_res = AllocAligned<float> (dstImage->
imageSize /
sizeof(
float));
444 auto* src =
reinterpret_cast<float*
>(srcImage->
imageData);
445 auto* dst =
reinterpret_cast<float*
>(dstImage->
imageData);
446 if (xKernel !=
nullptr)
450 for (
int i = 0; i < h; i++)
452 for (
int j = borderx; j < w - borderx; j++)
455 for (
int k = 0; k < xksize; k++)
457 tmp += src[i * w + j + k - borderx]
458 * xvalues[xksize - k - 1];
460 __tmp_res[i * w + j] = tmp;
465 if (yKernel !=
nullptr)
469 for (
int i = bordery; i < h - bordery; i++)
472 for (
int j = borderx; j < w - borderx; j++)
475 for (
int k = 0; k < yksize; k++)
477 tmp += __tmp_res[(i + k - bordery) * w + j]
478 * yvalues[yksize - k - 1];
480 dst[i * w + j] = tmp;
500 static char *__tmp_res =
nullptr;
501 static int __tmp_size = -1;
503 if (xKernel !=
nullptr)
508 if (yKernel !=
nullptr)
516 int *xvalues = (xKernel !=
nullptr) ? xKernel->
values :
nullptr;
517 const int xksize = (xKernel !=
nullptr) ? xKernel->
nCols : 0;
518 int *yvalues = (yKernel !=
nullptr) ? yKernel->
values :
nullptr;
519 const int yksize = (yKernel !=
nullptr) ? yKernel->
nRows : 0;
521 const int borderx = (xKernel !=
nullptr) ? xKernel->
nCols / 2 : 0;
522 const int bordery = (yKernel !=
nullptr) ? yKernel->
nRows / 2 : 0;
523 const int w = srcImage->
width;
524 const int h = srcImage->
height;
529 if (__tmp_res ==
nullptr)
533 __tmp_res = AllocAligned<char> (dstImage->
imageSize);
538 if (__tmp_size < dstImage->imageSize)
541 FreeAligned<char> (__tmp_res);
545 __tmp_res = AllocAligned<char> (dstImage->
imageSize);
550 switch (srcImage->
depth)
554 if (xKernel !=
nullptr)
558 for (
int i = 0; i < h; i++)
560 for (
int j = borderx; j < w - borderx; j++)
563 for (
int k = 0; k < xksize; k++)
565 tmp += srcImage->
imageData[i * w + j + k - borderx]
566 * xvalues[xksize - k - 1];
574 __tmp_res[i * w + j] = char(tmp);
579 if (yKernel !=
nullptr)
583 for (
int i = bordery; i < h - bordery; i++)
586 for (
int j = borderx; j < w - borderx; j++)
589 for (
int k = 0; k < yksize; k++)
591 tmp += __tmp_res[(i + k - bordery) * w + j]
592 * yvalues[yksize - k - 1];
600 dstImage->
imageData[i * w + j] = char(tmp);
609 if (xKernel !=
nullptr)
612 for (
int i = 0; i < h; i++)
614 for (
int j = borderx; j < w - borderx; j++)
617 for (
int k = 0; k < xksize; k++)
619 tmp += srcImage->
imageData[i * w + j + k - borderx]
620 * xvalues[xksize - k - 1];
628 __tmp_res[i * w + j] = char(tmp);
633 if (yKernel !=
nullptr)
636 for (
int i = bordery; i < h - bordery; i++)
638 for (
int j = borderx; j < w - borderx; j++)
641 for (
int k = 0; k < yksize; k++)
643 tmp += __tmp_res[(i + k - bordery) * w + j]
644 * yvalues[yksize - k - 1];
652 dstImage->
imageData[i * w + j] = char(tmp);
680 switch (image->
depth)
721 auto* tmp =
reinterpret_cast<float*
>(image->
imageData);
722 const int limit = image->
imageSize /
sizeof(float);
723 for (
int i = 0; i < limit; i++)
725 *tmp++ = float(fillValue);
738 image->
roi =
nullptr;
782 (
int nChannels,
int alphaChannel,
int depth,
783 char* colorModel,
char* channelSeq,
int dataOrder,
784 int origin,
int align,
834 const int linew = width * (depth &
IPL_DEPTH_MASK) / 8 * nChannels;
887 if (image ==
nullptr)
924 for (
int i = 0; i < 4; i++)
925 if ((border >> i) & 0x1)
945 const int size = image->
imageSize /
sizeof(float);
946 auto* tmp =
reinterpret_cast<float*
>(image->
imageData);
947 for (
int i = 0; i < size; i++)
958 switch (srcImage->
depth)
963 auto* src = (
unsigned char *)srcImage->
imageData;
964 auto* dst = (
unsigned char *)dstImage->
imageData;
968 for (
int i = 0; i < size; i++)
970 tmp = *src++ + value;
989 for (
int i = 0; i < size; i++)
991 tmp = *src++ + value;
1019 switch (srcImageA->
depth)
1024 auto* src1 = (
unsigned char *)srcImageA->
imageData;
1025 auto* src2 = (
unsigned char *)srcImageB->
imageData;
1026 auto* dst = (
unsigned char *)dstImage->
imageData;
1030 for (
int i = 0; i < size; i++)
1032 tmp = *src1++ + *src2++;
1049 for (
int i = 0; i < size; i++)
1051 tmp = *src1++ + *src2++;
1064 const int size = srcImageA->
imageSize /
sizeof(float);
1065 auto* src1 =
reinterpret_cast<float*
>(srcImageA->
imageData);
1066 auto* src2 =
reinterpret_cast<float*
>(srcImageB->
imageData);
1067 auto* dst =
reinterpret_cast<float*
>(dstImage->
imageData);
1069 for (
int i = 0; i < size; i++)
1071 *dst++ = *src1++ + *src2++;
1090 switch (srcImageA->
depth)
1095 auto* src1 = (
unsigned char *)srcImageA->
imageData;
1096 auto* src2 = (
unsigned char *)srcImageB->
imageData;
1097 auto* dst = (
unsigned char *)dstImage->
imageData;
1101 for (
int i = 0; i < size; i++)
1103 tmp = *src1++ - *src2++;
1122 for (
int i = 0; i < size; i++)
1124 tmp = *src1++ - *src2++;
1137 const int size = srcImageA->
imageSize /
sizeof(float);
1138 auto* src1 =
reinterpret_cast<float*
>(srcImageA->
imageData);
1139 auto* src2 =
reinterpret_cast<float*
>(srcImageB->
imageData);
1140 auto* dst =
reinterpret_cast<float*
>(dstImage->
imageData);
1142 for (
int i = 0; i < size; i++)
1144 *dst++ = *src1++ - *src2++;
1160 switch (srcImage->
depth)
1165 auto* src = (
unsigned char *)srcImage->
imageData;
1166 auto* dst = (
unsigned char *)dstImage->
imageData;
1170 for (
int i = 0; i < size; i++)
1173 tmp = value - *src++;
1175 tmp = *src++ - value;
1195 for (
int i = 0; i < size; i++)
1198 tmp = value - *src++;
1200 tmp = *src++ - value;
1225 const int size = srcImage->
imageSize /
sizeof(float);
1226 auto* src1 =
reinterpret_cast<float*
>(srcImage->
imageData);
1227 auto* dst =
reinterpret_cast<float*
>(dstImage->
imageData);
1229 for (
int i = 0; i < size; i++)
1231 *dst++ = *src1++ * value;
1237 switch (srcImage->
depth)
1251 for (
int i = 0; i < size; i++)
1270 switch (srcImage->
depth)
1275 auto* src = (
unsigned char *)srcImage->
imageData;
1276 auto* dst = (
unsigned char *)dstImage->
imageData;
1278 for (
int i = 0; i < size; i++)
1280 if (*src++ < threshold)
1294 for (
int i = 0; i < size; i++)
1296 if (*src++ < threshold)
1322 const int h = dstImage->
height;
1323 const int w = dstImage->
width;
1324 const int size = w * h;
1325 for (
int i = 0; i < size; i++)
1327 short tmp = *sdata++;
1337 int width,
int height ))
1345 int xOffset,
int yOffset,
1346 int width,
int height))
1357 auto* sdata = (
unsigned char *)rgbImage->
imageData;
1358 auto* ddata0 = (
unsigned char *)hsvImage->
imageData;
1359 unsigned char *ddata1 = ddata0 + 1;
1360 unsigned char *ddata2 = ddata1 + 1;
1363 double red,green,blue;
1366 const int width = rgbImage->
width;
1367 const int height = rgbImage->
height;
1368 const int size = width * height;
1370 for (
int i = 0; i < size; i++)
1372 blue = *sdata++ / 255.0;
1373 green = *sdata++ / 255.0;
1374 red = *sdata++ / 255.0;
1376 if (red > green && red > blue)
1385 if (green > red && green > blue)
1403 *ddata2 = (
unsigned char)(255.0 * max);
1409 sat = *ddata1 = (
unsigned char)(255 * (max - min) / max);
1420 double rc = (max - red) / (max - min);
1421 double gc = (max - green) / (max - min);
1422 double bc = (max - blue) / (max - min);
1436 yAssert(hue >= 0.0 && hue < 360.0);
1440 hue = (hue / 360.0 * 256.0);
1444 *ddata0 = (
unsigned char)(hue);
1458 unsigned int value))
void iplGetConvKernelFP(IplConvKernelFP *kernel, int *nCols, int *nRows, int *anchorX, int *anchorY, float **values)
#define IPL_DATA_ORDER_PIXEL
void * imageId
must be NULL
T * AllocAligned(int size)
struct _IplTileInfo * tileInfo
must be null
char channelSeq[4]
ignored by OpenCV
int alphaChannel
ignored by OpenCV
void iplDeallocateImage(IplImage *image)
struct _IplImage * maskROI
must be NULL
char * imageDataOrigin
pointer to very origin of image data (not necessarily aligned) - needed for correct deallocation
void iplDeallocateHeader(IplImage *image)
IplConvKernelFP * iplCreateConvKernelFP(int nCols, int nRows, int anchorX, int anchorY, float *values)
IplConvKernel * iplCreateConvKernel(int nCols, int nRows, int anchorX, int anchorY, int *values, int nShiftR)
WARNING: most of this is implemented for PAD_BYTES == 0.
void iplDeallocate(IplImage *image, int flag)
char * imageData
pointer to aligned image data
int BorderConst[4]
ignored by OpenCV
void iplSubtract(IplImage *srcImageA, IplImage *srcImageB, IplImage *dstImage)
struct _IplImage IplImage
struct _IplROI * roi
image ROI.
int PAD_BYTES(int len, int pad)
this might turn out to be useful.
void iplAllocateImage(IplImage *image, int doFill, int fillValue)
void iplHSV2RGB(IplImage *hsvImage, IplImage *rgbImage)
void iplConvolve2D(IplImage *srcImage, IplImage *dstImage, IplConvKernel **kernel, int nKernels, int combineMethod)
int nChannels
Most of OpenCV functions support 1,2,3 or 4 channels.
void iplSubtractS(IplImage *srcImage, IplImage *dstImage, int value, bool flip)
int BorderMode[4]
ignored by OpenCV
void iplSetROI(IplROI *roi, int coi, int xOffset, int yOffset, int width, int height)
IplROI * iplCreateROI(int coi, int xOffset, int yOffset, int width, int height)
void iplMultiplySFP(IplImage *srcImage, IplImage *dstImage, float value)
void iplGetConvKernel(IplConvKernel *kernel, int *nCols, int *nRows, int *anchorX, int *anchorY, int **values, int *nShiftR)
struct _IplTileInfo IplTileInfo
void iplConvolve2DFP(IplImage *srcImage, IplImage *dstImage, IplConvKernelFP **kernel, int nKernels, int combineMethod)
struct _IplConvKernelFP IplConvKernelFP
void iplAdd(IplImage *srcImageA, IplImage *srcImageB, IplImage *dstImage)
#define IPL_IMAGE_ALL_WITHOUT_MASK
char colorModel[4]
ignored by OpenCV
int imageSize
image data size in bytes (==image->height*image->widthStep in case of interleaved data)
void iplRGB2HSV(IplImage *rgbImage, IplImage *hsvImage)
int _iplCalcPadding(int lineSize, int align)
Computes the ipl image padding.
void iplColorToGray(IplImage *srcImage, IplImage *dstImage)
void iplXorS(IplImage *srcImage, IplImage *dstImage, unsigned int value)
void iplAbs(IplImage *srcImage, IplImage *dstImage)
void iplDeleteConvKernelFP(IplConvKernelFP *kernel)
#define IPLAPIIMPL(type, name, arg)
Definition for functions implemented within YARP_sig.
void iplSet(IplImage *image, int fillValue)
int dataOrder
0 - interleaved color channels, 1 - separate color channels.
int width
image width in pixels
int nSize
sizeof(IplImage)
void iplSetFP(IplImage *image, float fillValue)
void iplDeleteConvKernel(IplConvKernel *kernel)
void iplConvolveSep2DFP(IplImage *srcImage, IplImage *dstImage, IplConvKernelFP *xKernel, IplConvKernelFP *yKernel)
void iplAddS(IplImage *srcImage, IplImage *dstImage, int value)
int depth
pixel depth in bits: IPL_DEPTH_8U, IPL_DEPTH_8S, IPL_DEPTH_16S, IPL_DEPTH_32S, IPL_DEPTH_32F and IPL_...
void iplCopy(IplImage *srcImage, IplImage *dstImage)
void iplConvolveSep2D(IplImage *srcImage, IplImage *dstImage, IplConvKernel *xKernel, IplConvKernel *yKernel)
struct _IplConvKernel IplConvKernel
bool compareHeader(IplImage *A, IplImage *B)
void iplThreshold(IplImage *srcImage, IplImage *dstImage, int threshold)
void iplAllocateImageFP(IplImage *image, int doFill, float fillValue)
IplImage * iplCloneImage(const IplImage *img)
int height
image height in pixels
int widthStep
size of aligned image row in bytes
void iplSetBorderMode(IplImage *src, int mode, int border, int constVal)
IplImage * iplCreateImageHeader(int nChannels, int alphaChannel, int depth, char *colorModel, char *channelSeq, int dataOrder, int origin, int align, int width, int height, IplROI *roi, IplImage *maskROI, void *imageId, IplTileInfo *tileInfo)
int origin
0 - top-left origin, 1 - bottom-left origin (Windows bitmaps style)
int align
Alignment of image rows (4 or 8).