Esempio n. 1
0
int arGetMarkerInfo( ARUint8 *image, int xsize, int ysize, int pixelFormat, ARMarkerInfo2 *markerInfo2, int marker2_num,
                     ARPattHandle *pattHandle, int imageProcMode, int pattDetectMode, ARParamLTf *arParamLTf, ARdouble pattRatio,
                     ARMarkerInfo *markerInfo, int *marker_num,
                     const AR_MATRIX_CODE_TYPE matrixCodeType )
{
    int            i, j, result;
#ifndef ARDOUBLE_IS_FLOAT
    float pos0, pos1;
#endif

    for( i = j = 0; i < marker2_num; i++ ) {
        markerInfo[j].area   = markerInfo2[i].area;
#ifdef ARDOUBLE_IS_FLOAT
        if (arParamObserv2IdealLTf(arParamLTf, markerInfo2[i].pos[0], markerInfo2[i].pos[1],
                                   &(markerInfo[j].pos[0]), &(markerInfo[j].pos[1]) ) < 0) continue;
#else
        if (arParamObserv2IdealLTf(arParamLTf, (float)markerInfo2[i].pos[0], (float)markerInfo2[i].pos[1], &pos0, &pos1) < 0) continue;
        markerInfo[j].pos[0] = (ARdouble)pos0;
        markerInfo[j].pos[1] = (ARdouble)pos1;
#endif
        //arParamObserv2Ideal( dist_factor, markerInfo2[i].pos[0], markerInfo2[i].pos[1],
        //                     &(markerInfo[j].pos[0]), &(markerInfo[j].pos[1]), dist_function_version );

        if( arGetLine(markerInfo2[i].x_coord, markerInfo2[i].y_coord, markerInfo2[i].coord_num,
                      markerInfo2[i].vertex, arParamLTf,
                      markerInfo[j].line, markerInfo[j].vertex) < 0 ) continue;

        result = arPattGetIDGlobal( pattHandle, imageProcMode, pattDetectMode, image, xsize, ysize, pixelFormat, arParamLTf, markerInfo[j].vertex, pattRatio, 
                     &markerInfo[j].idPatt, &markerInfo[j].dirPatt, &markerInfo[j].cfPatt,
                     &markerInfo[j].idMatrix, &markerInfo[j].dirMatrix, &markerInfo[j].cfMatrix,
                      matrixCodeType, &markerInfo[j].errorCorrected, &markerInfo[j].globalID );

        if      (result == 0)  markerInfo[j].cutoffPhase = AR_MARKER_INFO_CUTOFF_PHASE_NONE;
        else if (result == -1) markerInfo[j].cutoffPhase = AR_MARKER_INFO_CUTOFF_PHASE_MATCH_GENERIC;
        else if (result == -2) markerInfo[j].cutoffPhase = AR_MARKER_INFO_CUTOFF_PHASE_MATCH_CONTRAST;
        else if (result == -3) markerInfo[j].cutoffPhase = AR_MARKER_INFO_CUTOFF_PHASE_MATCH_BARCODE_NOT_FOUND;
        else if (result == -4) markerInfo[j].cutoffPhase = AR_MARKER_INFO_CUTOFF_PHASE_MATCH_BARCODE_EDC_FAIL;
        else if (result == -5) markerInfo[j].cutoffPhase = AR_MARKER_INFO_CUTOFF_PHASE_HEURISTIC_TROUBLESOME_MATRIX_CODES;
        else if (result == -6) markerInfo[j].cutoffPhase = AR_MARKER_INFO_CUTOFF_PHASE_PATTERN_EXTRACTION;
  
        // If not mixing template matching and matrix code detection, then copy id, dir and cf
        // from values in appropriate type.
        if (pattDetectMode == AR_TEMPLATE_MATCHING_COLOR || pattDetectMode == AR_TEMPLATE_MATCHING_MONO) {
            markerInfo[j].id  = markerInfo[j].idPatt;
            markerInfo[j].dir = markerInfo[j].dirPatt;
            markerInfo[j].cf  = markerInfo[j].cfPatt;
        } else if( pattDetectMode == AR_MATRIX_CODE_DETECTION ) {
            markerInfo[j].id  = markerInfo[j].idMatrix;
            markerInfo[j].dir = markerInfo[j].dirMatrix;
            markerInfo[j].cf  = markerInfo[j].cfMatrix;
        }

        j++;
    }
    *marker_num = j;

    return 0;
}
Esempio n. 2
0
int ar2ScreenCoord2MarkerCoord( const ARParamLT *cparamLT, const float  trans[3][4], const float  sx, const float  sy, float  *mx, float  *my )
{
    float   ix, iy;
    float   wtrans[3][4];
    float   c11, c12, c21, c22, b1, b2;
    float   m;

    if( cparamLT == NULL ) {
        c11 = trans[2][0] * sx - trans[0][0];
        c12 = trans[2][1] * sx - trans[0][1];
        c21 = trans[2][0] * sy - trans[1][0];
        c22 = trans[2][1] * sy - trans[1][1];
        b1  = trans[0][3] - trans[2][3] * sx;
        b2  = trans[1][3] - trans[2][3] * sy;
    }
    else {
        if( arParamObserv2IdealLTf( &cparamLT->paramLTf, sx, sy, &ix, &iy) < 0 ) return -1;
        arUtilMatMuldff( cparamLT->param.mat, trans, wtrans );
        c11 = wtrans[2][0] * ix - wtrans[0][0];
        c12 = wtrans[2][1] * ix - wtrans[0][1];
        c21 = wtrans[2][0] * iy - wtrans[1][0];
        c22 = wtrans[2][1] * iy - wtrans[1][1];
        b1  = wtrans[0][3] - wtrans[2][3] * ix;
        b2  = wtrans[1][3] - wtrans[2][3] * iy;
    }

    m = c11 * c22 - c12 * c21;
    if( m == 0.0F ) return -1;
    *mx = (c22 * b1 - c12 * b2) / m;
    *my = (c11 * b2 - c21 * b1) / m;

    return 0;
}
Esempio n. 3
0
int ar2MarkerCoord2ScreenCoord2(const ARParamLT *cparamLT, const float trans[3][4], const float mx, const float my, float  *sx, float  *sy)
{
    float wtrans[3][4];
    float hx, hy, h;
    float ix, iy;
    float ix1, iy1;

    if (cparamLT != NULL)
    {
        arUtilMatMuldff(cparamLT->param.mat, trans, wtrans);
        hx = wtrans[0][0] * mx
             + wtrans[0][1] * my
             + wtrans[0][3];
        hy = wtrans[1][0] * mx
             + wtrans[1][1] * my
             + wtrans[1][3];
        h = wtrans[2][0] * mx
            + wtrans[2][1] * my
            + wtrans[2][3];
        ix = hx / h;
        iy = hy / h;
    }
    else
    {
        hx = trans[0][0] * mx
             + trans[0][1] * my
             + trans[0][3];
        hy = trans[1][0] * mx
             + trans[1][1] * my
             + trans[1][3];
        h = trans[2][0] * mx
            + trans[2][1] * my
            + trans[2][3];
        *sx = hx / h;
        *sy = hy / h;
        return 0;
    }

    if (arParamIdeal2ObservLTf(&cparamLT->paramLTf, ix, iy, sx, sy) < 0)
        return -1;

    if (arParamObserv2IdealLTf(&cparamLT->paramLTf, *sx, *sy, &ix1, &iy1) < 0)
        return -1;

    if ((ix - ix1) * (ix - ix1) + (iy - iy1) * (iy - iy1) > 1.0F)
        return -1;

    return 0;
}