Opencv Android的代码优化

时间:2012-10-08 22:08:06

标签: android c++ optimization image-processing opencv

我在Android上使用这个opencv代码进行强度均衡。执行时间约为每帧300毫秒(720x480)。有没有人对可能的时间优化有所了解?

以下是代码:

        cvtColor(image, hsvImage, CV_BGR2HSV);
        // Get intensity
        intensity = hsvImage.at<Vec3b>((int)reference.Point_::y, (int)reference.Point_::x);
        float value = (float)REGULAR_INTENSITY / intensity[2];
        float saturation = (float)REGULAR_SATURATION / intensity[1];
        if (counter == 15 && (int)intensity[2] < REGULAR_INTENSITY) {
            equalization = false;
        }
        // Modify intensity
        float transformedSaturation, transformedValue;
        for(int i = 0; i < hsvImage.rows; i++) {
            unsigned char *data = hsvImage.ptr(i);
            for(int j = 0; j < hsvImage.cols; j++) {
                transformedSaturation = (uchar)*++data * saturation;
                if (transformedSaturation > MAX_COLOR) {
                    transformedSaturation = MAX_COLOR;
                }
                *data++ = transformedSaturation;
                transformedValue = (uchar)*data * value;
                if (transformedValue > MAX_COLOR) {
                    transformedValue = MAX_COLOR;
                }
                *data++ = transformedValue;
            }
        }
        cvtColor(hsvImage, image, CV_HSV2BGR);

1 个答案:

答案 0 :(得分:2)

您是否尝试过使用OpenCV transform?我想它已经过优化,但我不知道饱和的演员表(即如果&gt; max_color,那么=最大颜色)