LVB Porn Detection

Last updated: 2020-02-25 10:48:28

PDF

To activate LVB porn detection, you need to activate LVB screencapturing first either in the LVB Console Or via API. This document describes how to implement LVB porn detection through API.

Activating LVB Porn Detection

As the LVB porn detection feature is based on the LVB screencapturing feature, you have to activate LVB screencapturing first before you can activate LVB porn detection. Steps are as follows:

1. Create a porn detection-enabled LVB screencapturing template

Called CreateLiveSnapshotTemplate to create a LVB screenshot template with porn detection by setting PornFlag = 1

2. Create a porn detection-enabled LVB screencapturing rule

Call CreateLiveSnapshotRule to create a porn detection-enabled LVB screencapturing rule and associate the LVB screencapturing template ID created in step 1 to the AppID, DomainName, AppName, and StreamName of the live broadcast that needs to undergo porn detection.

3. Start a live broadcast and start porn detection

After a porn detection-enabled LVB screencapturing rule is created, the porn detection feature will be automatically enabled for new live broadcasts. If you want to enable porn detection for a live broadcast that is in progress, you need to stop and restart the broadcast for the feature to take effect.

Getting the LVB Porn Detection Result

After LVB porn detection is enabled, you can configure the registered callback domain name in the porn detection callback template to have the LVB backend callback the porn detection result.

By default, only suspicious results will be called back.

The steps are as follows:

1. Create an LVB porn detection callback template

Called CreateLiveCallbackTemplate to set the PornCensorshipNotifyUrl parameter to your domain name and create a LVB porn detection callback template.

2. Create an LVB porn detection callback rule

Called CreateLiveCallbackRule to create LVB screenshot rule with porn detection feature, and transfer the LVB screenshot template created in the previous step, ID Associate, to LVB AppId, DomainName, and AppName dimensions that need porn detection callback.

3. Get the porn detection result

The LVB backend sends the porn detection result to your registered domain name through an HTTP POST request where the result is stored in the HTTP body in JSON format. You can determine whether the live broadcast is pornographic by the confidence field alone.

We recommend using the type Of the picture or the confidence of an image to judge whether it is pornographic. A confidence value above 83 marks the image as suspicious. As the detection system cannot achieve 100% accuracy, there may be false positives or false negatives, and human confirmation is recommended.

The complete protocol is as follows:

Parameter Required Data Type DESCRIPTION
Tid Yes Number Alert policy ID; video content alert: 20001
StreamId Port: 789 String Stream name
ChannelId Port: 789 String Channel ID
Img Yes String Link to the alerted image
Type Required Array Picture type, 0: normal picture, 1: pornographic picture, 2: sexy picture, 3: political picture, 4: illegal picture, 5: terrorism picture, 6-9: other picture
Confidence Yes Number Confidence of the detected pornographic image in the range of 0mur100, which is an overall score of normalScore, hotScore, and pornScore. If the confidence is greater than 83, the image is considered a suspected image
NormalScore Yes Number Normal score of the image
HotScore Yes Number Sexual score of the image
PornScore Yes Number Pornographic score of the image
Level Port: 789 Number Image level
OcrMsg Port: 789 String OCR information of the image (if any)
ScreenshotTime Yes Number Screencaptured time
SendTime Yes Number Request send time (UNIX timestamp)
AbductionRisk Port: 789 Array An array containing the AbductionRisk structure
FaceDetails Port: 789 Array An array containing the face attribute (faceDetail) structure
GameDetails Port: 789 Object Game details
PolityScore Optional Number The picture is the score of the picture related to politics.
IllegalScore Optional Number The picture is the score of the illegal picture.
TerrorScore Optional Number The picture is the score of the picture related to terrorism.
SimilarScore Optional Number Picture recognition score
stream_param Optional String Push parameter
app Optional string Push domain name
appid Optional Number Service id
appname Optional String Push path

AbductionRisk description

Parameter Required Data Type DESCRIPTION
Level Yes Number Risk level in the range of 0Mur4. The higher the number, the higher the risk. 3 and 4 indicate maliciousness and should be handled
Type Yes Number Risk type. 20002: porn

FaceDetail description

Parameter Name Required Type DESCRIPTION
Gender Port: 789 Number Gender [ 0 (female)-100 (male)]
Age Port: 789 Number Age
Expression Port: 789 Number Expression [ 0 (normal)-50 (smile)-100 (laugh)]
Beauty Port: 789 Number Charm [ 0-100]
x Port: 789 Number X coordinate of the top-left corner of the face frame
Y Port: 789 Number Y coordinate of the top-left corner of the face frame
Width Port: 789 Number Face frame width
Height Port: 789 Number Face frame height

GameDetails description

Parameter Name Required Type DESCRIPTION
Battlegrounds Port: 789 Object PUBG information
gameList Port: 789 Array Game list

gameList

Parameter Name Required Type DESCRIPTION
Name Port: 789 String Game name
Confidence Port: 789 Number Probability

In addition, the HTTP header contains the TPD-SecretID And TPD-CallBack-Auth Fields which can be used for user authentication.
Signature calculation: Signature = base64_encode(hash_hmac('SHA1', $Body, $SecretKey, true)) , where SecretKey is the SecretKey corresponding to the SecretId.

Below is a sample request:
HTTP Header:

TPD-SecretID : SecretId

TPD-CallBack-Auth: Signature

TPD-CallBack-Version : version

HTTP Body:

{
    "ocrMsg":"",

    "type":[2],

    "confidence":0,

    "normalScore":2,

    "hotScore":97,

    "pornScore":0,

    "screenshotTime":1575513174,

    "level":0,

    "img":"http://test-10000.cos.ap-shanghai.myqcloud.com/2019-12-05/teststream-screenshot-10-32-54-960x540.jpg",

    "abductionRisk":[ ],

    "faceDetails":[ ],

    "sendTime":1575513176,

    "illegalScore":0,

    "polityScore":0,

    "similarScore":0,

    "terrorScore":0,

    "tid":20001,

    "streamId":"teststream",

    "channelId":"teststream",

    "stream_param":"txSecret=40f38f69f574fd51126c421a3d96c374&txTime=5DEBEC80",

    "app":"testlive.myqcloud.com",

    "appname":"live",

    "appid":10000
}  

Disabling LVB Porn Detection

LVB porn detection can be disabled by deleting or modifying the screencapturing rule or template. Both deletion and modification are effective only for new live broadcasts. If you want to disable LVB porn detection for a live broadcast that has already started, you have to stop and restart the stream.

1. Delete or modify the porn detection-enabled screencapturing rule

Called DeleteLiveSnapshotRule to delete the corresponding LVB screenshot specifications under DomainName, AppName and StreamName through the template ID.

2. Delete or modify the porn detection-enabled screencapturing template

Called ModifyLiveSnapshotTemplate to modify the porn detection flag of LVB template to 0.