ArcfaceDemo icon indicating copy to clipboard operation
ArcfaceDemo copied to clipboard

您好,您能给说下1:N改M:N大概需要那几个地方的修改吗?

Open justziyang opened this issue 5 years ago • 9 comments

因为官网现在的demo是2.2版本的了,您的是基于2.0改的 我现在想在2.2版本上实现M:N. 辛苦辛苦,感谢~

justziyang avatar Jul 03 '19 03:07 justziyang

因为官网现在的demo是2.2版本的了,您的是基于2.0改的 我现在想在2.2版本上实现M:N. 辛苦辛苦,感谢~

请问你现在研究得如何了?

renhuan avatar Jul 11 '19 01:07 renhuan

请问你现在研究得如何了? 没找到方法,目前暂停了.现在在研究怎么把视频的surfaceview和画框的surfaceview整合到一起,因为我们要推流要远端,只能推一路流.

justziyang avatar Jul 11 '19 02:07 justziyang

这个demo已经是m:n了,而且是加了活体的,主要是把活体检测修改成了Image模式

wangshengyang1996 avatar Jul 12 '19 14:07 wangshengyang1996

请问你现在研究得如何了? 没找到方法,目前暂停了.现在在研究怎么把视频的surfaceview和画框的surfaceview整合到一起,因为我们要推流要远端,只能推一路流.

如果只是画框的话,在压缩数据推流前,在原先的RGB/YUV数据上画框再推就好,但是要是想加上姓名之类的东西就有点难了。我之前写了一套YUV/RGB处理的东西,其中包括在裸数据上画框的功能,函数的定义如下: void drawRectOnNv21(char *nv21, int width, int height, int color, int paintWidth, int left, int top, int right, int bottom)

有需要的话,我可以发你

wangshengyang1996 avatar Jul 14 '19 11:07 wangshengyang1996

请问你现在研究得如何了? 没找到方法,目前暂停了.现在在研究怎么把视频的surfaceview和画框的surfaceview整合到一起,因为我们要推流要远端,只能推一路流.

如果只是画框的话,在压缩数据推流前,在原先的RGB/YUV数据上画框再推就好,但是要是想加上姓名之类的东西就有点难了。我之前写了一套YUV/RGB处理的东西,其中包括在裸数据上画框的功能,函数的定义如下: void drawRectOnNv21(char *nv21, int width, int height, int color, int paintWidth, int left, int top, int right, int bottom)

有需要的话,我可以发你

请问 你用这个人脸检测的时候 如果一直开着 摄像头会不会很烫

renhuan avatar Jul 15 '19 06:07 renhuan

请问你现在研究得如何了? 没找到方法,目前暂停了.现在在研究怎么把视频的surfaceview和画框的surfaceview整合到一起,因为我们要推流要远端,只能推一路流.

如果只是画框的话,在压缩数据推流前,在原先的RGB/YUV数据上画框再推就好,但是要是想加上姓名之类的东西就有点难了。我之前写了一套YUV/RGB处理的东西,其中包括在裸数据上画框的功能,函数的定义如下: void drawRectOnNv21(char *nv21, int width, int height, int color, int paintWidth, int left, int top, int right, int bottom) 有需要的话,我可以发你

请问 你用这个人脸检测的时候 如果一直开着 摄像头会不会很烫

摄像头只负责数据传输,热不热和人脸检测没什么关系,主要还看设备的散热和程序的逻辑导致的CPU发热

wangshengyang1996 avatar Jul 15 '19 06:07 wangshengyang1996

请问你现在研究得如何了? 没找到方法,目前暂停了.现在在研究怎么把视频的surfaceview和画框的surfaceview整合到一起,因为我们要推流要远端,只能推一路流.

如果只是画框的话,在压缩数据推流前,在原先的RGB/YUV数据上画框再推就好,但是要是想加上姓名之类的东西就有点难了。我之前写了一套YUV/RGB处理的东西,其中包括在裸数据上画框的功能,函数的定义如下: void drawRectOnNv21(char *nv21, int width, int height, int color, int paintWidth, int left, int top, int right, int bottom)

有需要的话,我可以发你

您好,能麻烦您给我发一下画的方法吗?我们的数据是YUV420P的~邮箱[email protected],或者您看咋发我方便~

justziyang avatar Jul 16 '19 07:07 justziyang

int rgbToY(int r, int g, int b) {
    return (((66 * r + 129 * g + 25 * b + 128) >> 8) + 16);
}

int rgbToU(int r, int g, int b) {
    return (((-38 * r - 74 * g + 112 * b + 128) >> 8) + 128);
}

int rgbToV(int r, int g, int b) {
    return (((112 * r - 94 * g - 18 * b + 128) >> 8) + 128);
}

int alignIntToByte(int c) {
    return c & 0xFF;
}
void drawRectOnI420(char *i420, int width, int height, int color, int paintWidth, int left, int top,
                    int right, int bottom) {
    int halfWidth = width / 2;
    int r = (color & MASK_R) >> 16;
    int g = (color & MASK_G) >> 8;
    int b = color & MASK_B;
    int y = rgbToY(r, g, b);
    int u = rgbToU(r, g, b);
    int v = rgbToV(r, g, b);
    y = alignIntToByte(y);
    u = alignIntToByte(u);
    v = alignIntToByte(v);

    int innerTop = top + paintWidth;
    int innerBottom = bottom - paintWidth;
    int innerLeft = left + paintWidth;
    int innerRight = right - paintWidth;

    //上边
    int singleLength = right - left;
    int yStartIndex = top * width + left;

    int uStartIndex = width * height + ((top / 2 * width) + left) / 2;
    int vStartIndex = width * height * 5 / 4 + ((top / 2 * width) + left) / 2;

    bool adjustUV = false;
    for (int i = top; i < innerTop; i++) {
        for (int j = 0; j < singleLength; j++) {
            i420[yStartIndex + j] = y;
        }
        yStartIndex += width;
        if (adjustUV = !adjustUV) {
            for (int j = 0; j < singleLength; j += 2) {
                i420[uStartIndex + (j >> 1)] = u;
                i420[vStartIndex + (j >> 1)] = v;
            }
            uStartIndex += halfWidth;
            vStartIndex += halfWidth;
        }
    }

    //左边
    yStartIndex = innerTop * width + left;

    uStartIndex = width * height + (innerTop / 2 * width + left) / 2;
    vStartIndex = width * height * 5 / 4 + (innerTop / 2 * width + left) / 2;

    adjustUV = false;
    for (int i = innerTop; i < innerBottom; i++) {
        for (int j = 0; j < paintWidth; j++) {
            i420[yStartIndex + j] = y;
        }
        yStartIndex += width;
        if (adjustUV = !adjustUV) {
            for (int j = 0; j < paintWidth; j += 2) {
                i420[uStartIndex + (j >> 1)] = u;
                i420[vStartIndex + (j >> 1)] = v;
            }
            uStartIndex += halfWidth;
            vStartIndex += halfWidth;
        }
    }
    //右边
    yStartIndex = innerTop * width + innerRight;
    uStartIndex = width * height + (innerTop / 2 * width + innerRight) / 2;
    vStartIndex = width * height * 5 / 4 + (innerTop / 2 * width + innerRight) / 2;

    adjustUV = false;
    for (int i = innerTop; i < innerBottom; i++) {
        for (int j = 0; j < paintWidth; j++) {
            i420[yStartIndex + j] = y;
        }
        yStartIndex += width;
        if (adjustUV = !adjustUV) {
            for (int j = 0; j < paintWidth; j += 2) {

                i420[uStartIndex + (j >> 1)] = u;
                i420[vStartIndex + (j >> 1)] = v;
            }
            uStartIndex += halfWidth;
            vStartIndex += halfWidth;
        }
    }


    //下边
    yStartIndex = innerBottom * width + left;
    uStartIndex = width * height + ((innerBottom / 2 * width) + left) / 2;
    vStartIndex = width * height * 5 / 4 + ((innerBottom / 2 * width) + left) / 2;


    adjustUV = false;
    for (int i = innerBottom; i < bottom; i++) {
        for (int j = 0; j < singleLength; j++) {
            i420[yStartIndex + j] = y;
        }
        yStartIndex += width;
        if (adjustUV = !adjustUV) {
            for (int j = 0; j < singleLength; j += 2) {
                i420[uStartIndex + (j >> 1)] = u;
                i420[vStartIndex + (j >> 1)] = v;
            }
            uStartIndex += halfWidth;
            vStartIndex += halfWidth;
        }
    }
}

不知道你的YUV420P是I420还是YV12,这个是在I420上画框的,如果是YV12格式的,把UV的位置换换就好

wangshengyang1996 avatar Jul 16 '19 10:07 wangshengyang1996

int rgbToY(int r, int g, int b) {
    return (((66 * r + 129 * g + 25 * b + 128) >> 8) + 16);
}

int rgbToU(int r, int g, int b) {
    return (((-38 * r - 74 * g + 112 * b + 128) >> 8) + 128);
}

int rgbToV(int r, int g, int b) {
    return (((112 * r - 94 * g - 18 * b + 128) >> 8) + 128);
}

int alignIntToByte(int c) {
    return c & 0xFF;
}
void drawRectOnI420(char *i420, int width, int height, int color, int paintWidth, int left, int top,
                    int right, int bottom) {
    int halfWidth = width / 2;
    int r = (color & MASK_R) >> 16;
    int g = (color & MASK_G) >> 8;
    int b = color & MASK_B;
    int y = rgbToY(r, g, b);
    int u = rgbToU(r, g, b);
    int v = rgbToV(r, g, b);
    y = alignIntToByte(y);
    u = alignIntToByte(u);
    v = alignIntToByte(v);

    int innerTop = top + paintWidth;
    int innerBottom = bottom - paintWidth;
    int innerLeft = left + paintWidth;
    int innerRight = right - paintWidth;

    //上边
    int singleLength = right - left;
    int yStartIndex = top * width + left;

    int uStartIndex = width * height + ((top / 2 * width) + left) / 2;
    int vStartIndex = width * height * 5 / 4 + ((top / 2 * width) + left) / 2;

    bool adjustUV = false;
    for (int i = top; i < innerTop; i++) {
        for (int j = 0; j < singleLength; j++) {
            i420[yStartIndex + j] = y;
        }
        yStartIndex += width;
        if (adjustUV = !adjustUV) {
            for (int j = 0; j < singleLength; j += 2) {
                i420[uStartIndex + (j >> 1)] = u;
                i420[vStartIndex + (j >> 1)] = v;
            }
            uStartIndex += halfWidth;
            vStartIndex += halfWidth;
        }
    }

    //左边
    yStartIndex = innerTop * width + left;

    uStartIndex = width * height + (innerTop / 2 * width + left) / 2;
    vStartIndex = width * height * 5 / 4 + (innerTop / 2 * width + left) / 2;

    adjustUV = false;
    for (int i = innerTop; i < innerBottom; i++) {
        for (int j = 0; j < paintWidth; j++) {
            i420[yStartIndex + j] = y;
        }
        yStartIndex += width;
        if (adjustUV = !adjustUV) {
            for (int j = 0; j < paintWidth; j += 2) {
                i420[uStartIndex + (j >> 1)] = u;
                i420[vStartIndex + (j >> 1)] = v;
            }
            uStartIndex += halfWidth;
            vStartIndex += halfWidth;
        }
    }
    //右边
    yStartIndex = innerTop * width + innerRight;
    uStartIndex = width * height + (innerTop / 2 * width + innerRight) / 2;
    vStartIndex = width * height * 5 / 4 + (innerTop / 2 * width + innerRight) / 2;

    adjustUV = false;
    for (int i = innerTop; i < innerBottom; i++) {
        for (int j = 0; j < paintWidth; j++) {
            i420[yStartIndex + j] = y;
        }
        yStartIndex += width;
        if (adjustUV = !adjustUV) {
            for (int j = 0; j < paintWidth; j += 2) {

                i420[uStartIndex + (j >> 1)] = u;
                i420[vStartIndex + (j >> 1)] = v;
            }
            uStartIndex += halfWidth;
            vStartIndex += halfWidth;
        }
    }


    //下边
    yStartIndex = innerBottom * width + left;
    uStartIndex = width * height + ((innerBottom / 2 * width) + left) / 2;
    vStartIndex = width * height * 5 / 4 + ((innerBottom / 2 * width) + left) / 2;


    adjustUV = false;
    for (int i = innerBottom; i < bottom; i++) {
        for (int j = 0; j < singleLength; j++) {
            i420[yStartIndex + j] = y;
        }
        yStartIndex += width;
        if (adjustUV = !adjustUV) {
            for (int j = 0; j < singleLength; j += 2) {
                i420[uStartIndex + (j >> 1)] = u;
                i420[vStartIndex + (j >> 1)] = v;
            }
            uStartIndex += halfWidth;
            vStartIndex += halfWidth;
        }
    }
}

不知道你的YUV420P是I420还是YV12,这个是在I420上画框的,如果是YV12格式的,把UV的位置换换就好

好的好的我的是I420的,我研究一下,感谢感谢~

justziyang avatar Jul 17 '19 03:07 justziyang