コード例 #1
0
ファイル: arGetMarkerInfo.cpp プロジェクト: ceezeh/more_t2
 ARMarkerInfo*
Tracker::arGetMarkerInfo(uint8_t *image, ARMarkerInfo2 *marker_info2, int *marker_num, int thresh)
{
    int            id, dir;
    ARFloat         cf;
    int            i, j;

    for( i = j = 0; i < *marker_num; i++ ) {
        marker_infoL[j].area   = marker_info2[i].area;
        marker_infoL[j].pos[0] = marker_info2[i].pos[0];
        marker_infoL[j].pos[1] = marker_info2[i].pos[1];

        if (arGetLine(marker_info2[i].x_coord, marker_info2[i].y_coord, marker_info2[i].vertex, marker_infoL[j].line,
                marker_infoL[j].vertex) < 0)
            continue;

        arGetCode( image,
                   marker_info2[i].x_coord, marker_info2[i].y_coord,
                   marker_info2[i].vertex, &id, &dir, &cf, thresh);

        marker_infoL[j].id  = id;
        marker_infoL[j].dir = dir;
        marker_infoL[j].cf  = cf;

        j++;
    }
    *marker_num = j;

    return( marker_infoL );
}
コード例 #2
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;
}