59 #include <config_auto.h> 63 #include "allheaders.h" 98 mat = (l_float32 *)LEPT_CALLOC(9,
sizeof(l_float32));
99 mat[0] = mat[4] = mat[8] = 1;
135 mat = (l_float32 *)LEPT_CALLOC(9,
sizeof(l_float32));
183 l_float32 sina, cosa;
186 mat = (l_float32 *)LEPT_CALLOC(9,
sizeof(l_float32));
189 mat[0] = mat[4] = cosa;
191 mat[2] = xc * (1.0 - cosa) + yc * sina;
193 mat[5] = yc * (1.0 - cosa) - xc * sina;
225 PROCNAME(
"ptaTranslate");
228 return (
PTA *)ERROR_PTR(
"ptas not defined", procName, NULL);
232 return (
PTA *)ERROR_PTR(
"ptad not made", procName, NULL);
233 for (i = 0; i < npts; i++) {
235 ptaAddPt(ptad, x + transx, y + transy);
264 PROCNAME(
"ptaScale");
267 return (
PTA *)ERROR_PTR(
"ptas not defined", procName, NULL);
271 return (
PTA *)ERROR_PTR(
"ptad not made", procName, NULL);
272 for (i = 0; i < npts; i++) {
274 ptaAddPt(ptad, scalex * x, scaley * y);
313 l_float32 x, y, xp, yp, sina, cosa;
316 PROCNAME(
"ptaRotate");
319 return (
PTA *)ERROR_PTR(
"ptas not defined", procName, NULL);
323 return (
PTA *)ERROR_PTR(
"ptad not made", procName, NULL);
326 for (i = 0; i < npts; i++) {
328 xp = xc + (x - xc) * cosa - (y - yc) * sina;
329 yp = yc + (x - xc) * sina + (y - yc) * cosa;
359 PROCNAME(
"boxaTranslate");
362 return (
BOXA *)ERROR_PTR(
"boxas not defined", procName, NULL);
392 PROCNAME(
"boxaScale");
395 return (
BOXA *)ERROR_PTR(
"boxas not defined", procName, NULL);
398 ptad =
ptaScale(ptas, scalex, scaley);
426 PROCNAME(
"boxaRotate");
429 return (
BOXA *)ERROR_PTR(
"boxas not defined", procName, NULL);
455 l_float32 vecs[3], vecd[3];
458 PROCNAME(
"ptaAffineTransform");
461 return (
PTA *)ERROR_PTR(
"ptas not defined", procName, NULL);
463 return (
PTA *)ERROR_PTR(
"transform not defined", procName, NULL);
468 return (
PTA *)ERROR_PTR(
"ptad not made", procName, NULL);
469 for (i = 0; i < npts; i++) {
470 ptaGetPt(ptas, i, &vecs[0], &vecs[1]);
493 PROCNAME(
"boxaAffineTransform");
496 return (
BOXA *)ERROR_PTR(
"boxas not defined", procName, NULL);
498 return (
BOXA *)ERROR_PTR(
"transform not defined", procName, NULL);
529 PROCNAME(
"l_productMatVec");
532 return ERROR_INT(
"matrix not defined", procName, 1);
534 return ERROR_INT(
"input vector not defined", procName, 1);
536 return ERROR_INT(
"result vector not defined", procName, 1);
538 for (i = 0; i < size; i++) {
540 for (j = 0; j < size; j++) {
541 vecd[i] += mat[size * i + j] * vecs[j];
563 l_int32 i, j, k, index;
565 PROCNAME(
"l_productMat2");
568 return ERROR_INT(
"matrix 1 not defined", procName, 1);
570 return ERROR_INT(
"matrix 2 not defined", procName, 1);
572 return ERROR_INT(
"result matrix not defined", procName, 1);
574 for (i = 0; i < size; i++) {
575 for (j = 0; j < size; j++) {
576 index = size * i + j;
578 for (k = 0; k < size; k++)
579 matd[index] += mat1[size * i + k] * mat2[size * k + j];
605 PROCNAME(
"l_productMat3");
608 return ERROR_INT(
"matrix 1 not defined", procName, 1);
610 return ERROR_INT(
"matrix 2 not defined", procName, 1);
612 return ERROR_INT(
"matrix 3 not defined", procName, 1);
614 return ERROR_INT(
"result matrix not defined", procName, 1);
616 if ((matt = (l_float32 *)LEPT_CALLOC((
size_t)size * size,
617 sizeof(l_float32))) == NULL)
618 return ERROR_INT(
"matt not made", procName, 1);
647 PROCNAME(
"l_productMat4");
650 return ERROR_INT(
"matrix 1 not defined", procName, 1);
652 return ERROR_INT(
"matrix 2 not defined", procName, 1);
654 return ERROR_INT(
"matrix 3 not defined", procName, 1);
656 return ERROR_INT(
"result matrix not defined", procName, 1);
658 if ((matt = (l_float32 *)LEPT_CALLOC((
size_t)size * size,
659 sizeof(l_float32))) == NULL)
660 return ERROR_INT(
"matt not made", procName, 1);
BOXA * boxaScale(BOXA *boxas, l_float32 scalex, l_float32 scaley)
boxaScale()
l_float32 * createMatrix2dScale(l_float32 scalex, l_float32 scaley)
createMatrix2dScale()
PTA * ptaTranslate(PTA *ptas, l_float32 transx, l_float32 transy)
ptaTranslate()
l_ok l_productMatVec(l_float32 *mat, l_float32 *vecs, l_float32 *vecd, l_int32 size)
l_productMatVec()
PTA * boxaConvertToPta(BOXA *boxa, l_int32 ncorners)
boxaConvertToPta()
PTA * ptaScale(PTA *ptas, l_float32 scalex, l_float32 scaley)
ptaScale()
l_ok ptaAddPt(PTA *pta, l_float32 x, l_float32 y)
ptaAddPt()
PTA * ptaCreate(l_int32 n)
ptaCreate()
BOXA * boxaTranslate(BOXA *boxas, l_float32 transx, l_float32 transy)
boxaTranslate()
BOXA * ptaConvertToBoxa(PTA *pta, l_int32 ncorners)
ptaConvertToBoxa()
l_int32 ptaGetCount(PTA *pta)
ptaGetCount()
l_ok l_productMat3(l_float32 *mat1, l_float32 *mat2, l_float32 *mat3, l_float32 *matd, l_int32 size)
l_productMat3()
PTA * ptaRotate(PTA *ptas, l_float32 xc, l_float32 yc, l_float32 angle)
ptaRotate()
l_ok ptaGetPt(PTA *pta, l_int32 index, l_float32 *px, l_float32 *py)
ptaGetPt()
l_ok l_productMat4(l_float32 *mat1, l_float32 *mat2, l_float32 *mat3, l_float32 *mat4, l_float32 *matd, l_int32 size)
l_productMat4()
l_ok l_productMat2(l_float32 *mat1, l_float32 *mat2, l_float32 *matd, l_int32 size)
l_productMat2()
BOXA * boxaRotate(BOXA *boxas, l_float32 xc, l_float32 yc, l_float32 angle)
boxaRotate()
PTA * ptaAffineTransform(PTA *ptas, l_float32 *mat)
ptaAffineTransform()
void ptaDestroy(PTA **ppta)
ptaDestroy()
l_float32 * createMatrix2dRotate(l_float32 xc, l_float32 yc, l_float32 angle)
createMatrix2dRotate()
l_float32 * createMatrix2dTranslate(l_float32 transx, l_float32 transy)
createMatrix2dTranslate()
BOXA * boxaAffineTransform(BOXA *boxas, l_float32 *mat)
boxaAffineTransform()