2

我在 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);
4

1 回答 1

2

您是否尝试过使用 OpenCV转换?我想它是优化的,但我不知道饱和投射(即如果 > max_color,则 = 最大颜色)

于 2012-10-09T15:45:29.767 回答