Intel® Integrated Performance Primitives
Community support and discussions relating to developing high-performance vision, signal, security, and storage applications.
Announcements
Intel Customer Support will be observing the Martin Luther King holiday on Monday, Jan. 17, and will return on Tues. Jan. 18.
For the latest information on Intel’s response to the Log4j/Log4Shell vulnerability, please see Intel-SA-00646

how to use ippiHaarClassifierInit_32f

风__付
Beginner
346 Views

hi,

when i use opencv and with  ipp 2018 

and  found ippiHaarClassifierInit_32f would return -8 error. code like this.

......................

#ifdef HAVE_IPP
    int can_use_ipp = !out->has_tilted_features && !out->is_tree && out->isStumpBased;

    if( can_use_ipp )
    {
        int ipp_datasize = cascade->count*sizeof(out->ipp_stages[0]);
        float ipp_weight_scale=(float)(1./((orig_window_size.width-icv_object_win_border*2)*
            (orig_window_size.height-icv_object_win_border*2)));

        out->ipp_stages = (void**)cvAlloc( ipp_datasize );
        memset( out->ipp_stages, 0, ipp_datasize );

        ipp_features = (CvRect*)cvAlloc( max_count*3*sizeof(ipp_features[0]) );
        ipp_weights = (float*)cvAlloc( max_count*3*sizeof(ipp_weights[0]) );
        ipp_thresholds = (float*)cvAlloc( max_count*sizeof(ipp_thresholds[0]) );
        ipp_val1 = (float*)cvAlloc( max_count*sizeof(ipp_val1[0]) );
        ipp_val2 = (float*)cvAlloc( max_count*sizeof(ipp_val2[0]) );
        ipp_counts = (int*)cvAlloc( max_count*sizeof(ipp_counts[0]) );

        for( i = 0; i < cascade->count; i++ )
        {
            CvHaarStageClassifier* stage_classifier = cascade->stage_classifier + i;
            for( j = 0, k = 0; j < stage_classifier->count; j++ )
            {
                CvHaarClassifier* classifier = stage_classifier->classifier + j;
                int rect_count = 2 + (classifier->haar_feature->rect[2].r.width != 0);

                ipp_thresholds = classifier->threshold[0];
                ipp_val1 = classifier->alpha[0];
                ipp_val2 = classifier->alpha[1];
                ipp_counts = rect_count;

                for( l = 0; l < rect_count; l++, k++ )
                {
                    ipp_features = classifier->haar_feature->rect.r;
                    //ipp_features.y = orig_window_size.height - ipp_features.y - ipp_features.height;
                    ipp_weights = classifier->haar_feature->rect.weight*ipp_weight_scale;
                }
            }

            returnVal =  ippiHaarClassifierInit_32f((IppiHaarClassifier_32f*)out->ipp_stages,
                (const IppiRect*)ipp_features, ipp_weights, ipp_thresholds,
                ipp_val1, ipp_val2, ipp_counts, stage_classifier->count);
            if(returnVal < 0 )
                break;
        }

        if( i < cascade->count )
        {
            for( j = 0; j < i; j++ )
                if( out->ipp_stages )
                    ippFree( (IppiHaarClassifier_32f*)out->ipp_stages );
            cvFree( &out->ipp_stages );
        }
    }
#endif

...........................

but if i change ipp version to 6.1

the code just like this

.........................

#ifdef HAVE_IPP
    int can_use_ipp = !out->has_tilted_features && !out->is_tree && out->isStumpBased;

    if( can_use_ipp )
    {
        int ipp_datasize = cascade->count*sizeof(out->ipp_stages[0]);
        float ipp_weight_scale=(float)(1./((orig_window_size.width-icv_object_win_border*2)*
            (orig_window_size.height-icv_object_win_border*2)));

        out->ipp_stages = (void**)cvAlloc( ipp_datasize );
        memset( out->ipp_stages, 0, ipp_datasize );

        ipp_features = (CvRect*)cvAlloc( max_count*3*sizeof(ipp_features[0]) );
        ipp_weights = (float*)cvAlloc( max_count*3*sizeof(ipp_weights[0]) );
        ipp_thresholds = (float*)cvAlloc( max_count*sizeof(ipp_thresholds[0]) );
        ipp_val1 = (float*)cvAlloc( max_count*sizeof(ipp_val1[0]) );
        ipp_val2 = (float*)cvAlloc( max_count*sizeof(ipp_val2[0]) );
        ipp_counts = (int*)cvAlloc( max_count*sizeof(ipp_counts[0]) );

        for( i = 0; i < cascade->count; i++ )
        {
            CvHaarStageClassifier* stage_classifier = cascade->stage_classifier + i;
            for( j = 0, k = 0; j < stage_classifier->count; j++ )
            {
                CvHaarClassifier* classifier = stage_classifier->classifier + j;
                int rect_count = 2 + (classifier->haar_feature->rect[2].r.width != 0);

                ipp_thresholds = classifier->threshold[0];
                ipp_val1 = classifier->alpha[0];
                ipp_val2 = classifier->alpha[1];
                ipp_counts = rect_count;

                for( l = 0; l < rect_count; l++, k++ )
                {
                    ipp_features = classifier->haar_feature->rect.r;
                    //ipp_features.y = orig_window_size.height - ipp_features.y - ipp_features.height;
                    ipp_weights = classifier->haar_feature->rect.weight*ipp_weight_scale;
                }
            }

            if( ippiHaarClassifierInitAlloc_32f( (IppiHaarClassifier_32f**)&out->ipp_stages,
                (const IppiRect*)ipp_features, ipp_weights, ipp_thresholds,
                ipp_val1, ipp_val2, ipp_counts, stage_classifier->count ) < 0 )
                break;
        }

        if( i < cascade->count )
        {
            for( j = 0; j < i; j++ )
                if( out->ipp_stages )
                    ippiHaarClassifierFree_32f( (IppiHaarClassifier_32f*)out->ipp_stages );
            cvFree( &out->ipp_stages );
        }
    }
#endif

............................................

it would work well. the different between above code  is ippiHaarClassifierInitAlloc_32f and ippiHaarClassifierInit_32f

so i'm not sure what's the problem with 2018 ipp. please help, or any one can send me a example code to use ippiHaarClassifierInit_32f

thank 's a lot.

0 Kudos
2 Replies
Ruqiu_C_Intel
Employee
346 Views

Hello,

The function ippiHaarClassifierInitAlloc_32f has been removed from IPP9.0. As workaround, please use ippiHaarClassifierGetSize + ippMalloc + ippiHaarClassifierInit_32f to replace the function ippiHaarClassifierInitAlloc_32f .

Regards,

Ruqiu

风__付
Beginner
346 Views

RUQIU C. (Intel) wrote:

Hello,

The function ippiHaarClassifierInitAlloc_32f has been removed from IPP9.0. As workaround, please use ippiHaarClassifierGetSize + ippMalloc + ippiHaarClassifierInit_32f to replace the function ippiHaarClassifierInitAlloc_32f .

Regards,

Ruqiu

thank you 

and  can you send me an example for how to use  ippiHaarClassifierGetSize + ippMalloc + ippiHaarClassifierInit_32f 

i could not find such things from the documentation 

Reply