tencent cloud

Feedback

Live Porn Detection

Last updated: 2023-02-27 15:47:12
    To use the porn detection capability of CSS, you need to enable screencapturing. You can use the porn detection feature either by configuring it in the CSS console or by using APIs. This document shows you how to use porn detection APIs.

    Must-Knows

    If your COS bucket allows public read access and has politically sensitive, pornographic, or other inappropriate content, to avoid the bucket being blocked, please delete the content first.

    Enabling Porn Detection

    Because the porn detection feature is based on screencapturing, you need to enable screencapturing first.

    1. Create a screencapturing template with porn detection enabled

    Call CreateLiveSnapshotTemplate, setting PornFlag to 1 to create a screencapturing template with porn detection enabled.

    2. Create a screencapturing rule

    Call CreateLiveSnapshotRule, setting TemplateId to the ID of the screencapturing template created in step 1 to associate the template with the target AppId, DomainName, AppName, and StreamName.

    3. Start live streaming

    After you create a screencapturing rule with porn detection enabled, the porn detection feature will be automatically enabled for new streams. If you want to enable porn detection for an ongoing stream, you need to stop and restart the stream.

    Getting the Porn Detection Result

    After porn detection is enabled, you can configure a registered domain name in the porn detection callback template to receive callbacks of porn detection results.
    Note:
    By default, callbacks are sent only if suspicious content is detected.

    1. Create a porn detection callback template

    Call CreateLiveCallbackTemplate, setting PornCensorshipNotifyUrl to your domain name to create a porn detection callback template.

    2. Create a porn detection callback rule

    Call CreateLiveCallbackRule, setting TemplateId to the ID of the callback template created in step 1 to associate the template with the target AppId, DomainName, and AppName.

    3. Get the porn detection result

    The CSS backend will send porn detection results to your domain in the form of HTTP POST requests. You can find the results in JSON format in the request body. The type field indicates whether a live stream contains pornographic content.
    Note:
    The system cannot achieve 100% accuracy. There may be false positives or false negatives. We recommend you review the images suspected of being pornographic using the type field.

    The parameters are as follows:

    Parameter
    Required
    Data Type
    Description
    streamId
    No
    String
    The stream name.
    channelId
    No
    String
    The channel ID.
    img
    Yes
    String
    The link of the suspicious image.
    type
    Yes
    Array
    The value of the label with the highest priority in the detection result. For details, see the description in label.
    score
    Yes
    Array
    The confidence score.
    ocrMsg
    No
    String
    The OCR result (if any).
    suggestion
    Yes
    String
    The suggestion. Valid values:
    Block
    Review
    Pass
    label
    Yes
    String
    The label with the highest priority in the detection result (LabelResults). This is the result generated by the model. Please handle different types of violations based on your business needs.
    subLabel
    Yes
    String
    The sub-label of the label with the highest priority in the detection result, such as porn - sexual acts. If no sub-labels are hit, this field will be empty.
    labelResults
    No
    The label hit results generated by the category model, including the detection of pornographic content, ads, terrorist content, and politically sensitive content. <br>Note: This field may return null, indicating that no valid values can be obtained.
    objectResults
    No
    The detection results generated by the object model, including the label name, hit score, coordinates, scenario, and suggestion for suspicious objects, advertising logos, QR codes, etc. For details, see the data structure of ObjectResults.
    Note: This field may return null, indicating that no valid values can be obtained.
    ocrResults
    No
    The OCR result, including the text recognized, the text coordinates, and the suggestion. For details, see the data structure of OcrResults.
    Note: This field may return null, indicating that no valid values can be obtained.
    libResults
    No
    The detection results generated by the block/allowlist library.
    screenshotTime
    Yes
    Number
    The time when the screenshot was taken.
    sendTime
    Yes
    Number
    The Unix timestamp when the request was sent.
    stream_param
    No
    String
    The push parameter.
    app
    No
    String
    The push domain.
    appid
    No
    Number
    The application ID.
    appname
    No
    String
    The push path.

    LabelResult

    The label hit result generated by the category model.
    Parameter
    Type
    Description
    Scene
    String
    The scene identified by the model, such as advertising, pornographic, and harmful.
    Suggestion
    String
    The operation suggested by the system for the current label. Please handle different types of violations based on your business needs. Valid values:
    Block
    Review
    Pass
    label
    String
    The label hit.
    SubLabel
    String
    The sub-label.
    Score
    Integer
    The confidence score for the label.
    Details
    The sub-label hit details.

    LabelDetailItem

    The sub-label hit details.
    Parameter
    Type
    Description
    Id
    Integer
    The sequence ID.
    Name
    String
    The sub-label.
    Score
    Integer
    The sub-label score. Value range: 0-100.

    ObjectResult

    The object detection result.
    Parameter
    Type
    Description
    Scene
    String
    The object scene identified, such as QR code, logo, and OCR.
    Suggestion
    String
    The operation suggested by the system for the current label. Please handle different types of violations based on your business needs. Valid values:
    Block
    Review
    Pass
    label
    String
    The label hit.
    SubLabel
    String
    The sub-label.
    Score
    Integer
    The sub-label score. Value range: 0-100
    Names
    Array of String
    The object names.
    Details
    Array of ObjectDetail
    The object detection details.

    ObjectDetail

    The object detection details. If the scene identified is object, advertising logo, or QR code, this parameter returns the label name, label value, label score, and location information.
    Parameter
    Type
    Description
    Id
    Integer
    The ID of the object identified.
    Name
    String
    The label hit.
    Value
    String
    The value or content of the label hit. For example, if the label is QR code (QrCode), this parameter is the URL of the QR code.
    Score
    Integer
    The score of the label hit. Value range: 0-100. For example, QrCode 99 indicates a high likelihood that the content is a QR code.
    Location
    The coordinates (of the top-left corner), dimensions, and rotation of the object detection frame.

    Location

    The location information of the suspicious content.
    Parameter
    Type
    Description
    X
    Float
    The horizontal coordinate of the top-left corner.
    Y
    Float
    The vertical coordinate of the top-left corner.
    Width
    Float
    The width.
    Height
    Float
    The height.
    Rotate
    Float
    The rotation angle of the detection frame.

    OcrResult

    The OCR result.
    Parameter
    Type
    Description
    Scene
    String
    The scene identified. Default value: OCR.
    Suggestion
    String
    The operation suggested by the system for the label with the highest priority. Please handle different types of violations based on your business needs. Valid values:
    Block
    Review
    Pass
    label
    String
    The label hit.
    SubLabel
    String
    The sub-label.
    Score
    Integer
    The confidence score of the sub-label. Value range: 0-100.
    Text
    String
    The text.
    Details
    Array of OcrTextDetail
    The OCR details.

    OcrTextDetail

    The OCR details.
    Parameter
    Type
    Description
    Text
    String
    The text recognized (up to 5,000 bytes).
    label
    String
    The label hit.
    Keywords
    Array of String
    The keywords hit under the label.
    Score
    Integer
    The confidence score of the label. Value range: 0-100.
    Location
    The OCR text coordinates.

    LibResult

    The result generated by the block/allowlist library.
    Parameter
    Type
    Description
    Scene
    String
    The scene identified. Default value: Similar.
    Suggestion
    String
    The operation suggested by the system. Please handle different types of violations based on your business needs. Returned values:
    Block
    Review
    Pass
    label
    String
    The label hit.
    SubLabel
    String
    The sub-label.
    Score
    Integer
    The confidence score. Value range: 0-100.
    Details
    Array of LibDetail
    The block/allowlist library detection details.

    LibDetail

    The custom library or block/allowlist library detection details.
    Parameter
    Type
    Description
    Id
    Integer
    The sequence ID.
    ImageId
    String
    The image ID.
    label
    String
    The label hit.
    Tag
    String
    A custom label.
    Score
    Integer
    The confidence score. Value range: 0-100.

    Sample callback

    {
    "ocrMsg": "",
    "type": [1],
    "socre": 99,
    "screenshotTime": 1610640000,
    "level": 0,
    "img": "http://1.1.1.1/download/porn/test.jpg",
    "abductionRisk": [],
    "faceDetails": [],
    "sendTime": 1615859827,
    "suggestion": "Block",
    "label": "Porn",
    "subLabel": "PornHigh",
    "labelResults": [{
    "HitFlag": 0,
    "Scene": "Illegal",
    "Suggestion": "Pass",
    "Label": "Normal",
    "SubLabel": "",
    "Score": 0,
    "Details": []
    }, {
    "HitFlag": 1,
    "Scene": "Porn",
    "Suggestion": "Block",
    "Label": "Porn",
    "SubLabel": "PornHigh",
    "Score": 99,
    "Details": [{
    "Id": 0,
    "Name": "PornHigh",
    "Score": 99
    }, {
    "Id": 1,
    "Name": "WomenChest",
    "Score": 99
    }]
    }, {
    "HitFlag": 0,
    "Scene": "Sexy",
    "Suggestion": "Pass",
    "Label": "Normal",
    "SubLabel": "",
    "Score": 0,
    "Details": []
    }, {
    "HitFlag": 0,
    "Scene": "Terror",
    "Suggestion": "Pass",
    "Label": "Normal",
    "SubLabel": "",
    "Score": 0,
    "Details": []
    }],
    "objectResults": [{
    "HitFlag": 0,
    "Scene": "QrCode",
    "Suggestion": "Pass",
    "Label": "Normal",
    "SubLabel": "",
    "Score": 0,
    "Names": [],
    "Details": []
    }, {
    "HitFlag": 0,
    "Scene": "MapRecognition",
    "Suggestion": "Pass",
    "Label": "Normal",
    "SubLabel": "",
    "Score": 0,
    "Names": [],
    "Details": []
    }, {
    "HitFlag": 0,
    "Scene": "PolityFace",
    "Suggestion": "Pass",
    "Label": "Normal",
    "SubLabel": "",
    "Score": 0,
    "Names": [],
    "Details": []
    }],
    "ocrResults": [{
    "HitFlag": 0,
    "Scene": "OCR",
    "Suggestion": "Pass",
    "Label": "Normal",
    "SubLabel": "",
    "Score": 0,
    "Text": "",
    "Details": []
    }],
    "streamId": "teststream",
    "channelId": "teststream",
    "stream_param": "txSecret=40f38f69f574fd51126c421a3d96c374&txTime=5DEBEC80",
    "app": "5000.myqcloud.com",
    "appname": "live",
    "appid": 10000,
    "event_type": 317,
    "sign": "ac920c3e66**********78cf1b5de2c63",
    "t": 1615860427
    }
    

    Disabling Porn Detection

    You can disable porn detection by deleting the screencapturing rule or modifying the screencapturing template. The change only takes effect for new streams. If you want to disable porn detection for an ongoing stream, you need to stop and restart the stream.

    1. Delete the screencapturing rule

    Call DeleteLiveSnapshotRule, passing in the DomainName, AppName, and StreamName bound to the screencapturing template ID to delete the screencapturing rule.

    2. Modify the screencapturing template

    Call ModifyLiveSnapshotTemplate, setting PornFlag to 0.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support