Allow setting aspect ratio detection sensitivity

This commit is contained in:
Tamius Han 2019-06-02 00:34:37 +02:00
parent 72dc5ed372
commit 66f9c1b9e3
3 changed files with 23 additions and 9 deletions

View File

@ -111,8 +111,8 @@ var ExtensionConf = {
edgeDetection: {
sampleWidth: 8, // we take a sample this wide for edge detection
detectionThreshold: 4, // sample needs to have this many non-black pixels to be a valid edge
confirmationThreshold: 0, //
singleSideConfirmationThreshold: 0.3, // we need this much edges (out of all samples, not just edges) in order
confirmationThreshold: 1, //
singleSideConfirmationThreshold: 4, // we need this much edges (out of all samples, not just edges) in order
// to confirm an edge in case there's no edges on top or bottom (other
// than logo, of course)
logoThreshold: 0.15, // if edge candidate sits with count greater than this*all_samples, it can't be logo

View File

@ -404,7 +404,8 @@ class EdgeDetect{
var blackbarWidth = edgesTop[0].distance > edgesBottom[0].distance ?
edgesTop[0].distance : edgesBottom[0].distance;
if (edgesTop[0].count + edgesBottom[0].count > this.settings.active.arDetect.edgeDetection.detectionThreshold) {
if (edgesTop[0].count + edgesBottom[0].count > this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold
|| ( edgesTop[0].count > this.settings.active.arDetect.edgeDetection.confirmationThreshold && edgesBottom[0].count > this.settings.active.arDetect.edgeDetection.confirmationThreshold) ){
return {
status: EdgeStatus.AR_KNOWN,
blackbarWidth: blackbarWidth,
@ -437,7 +438,8 @@ class EdgeDetect{
var blackbarWidth = edgesTop[i].distance > edgesBottom[0].distance ?
edgesTop[i].distance : edgesBottom[0].distance;
if (edgesTop[i].count + edgesBottom[0].count > this.settings.active.arDetect.edgeDetection.detectionThreshold) {
if (edgesTop[i].count + edgesBottom[0].count > this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold
|| (edgesTop[i].count > this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold && edgesBottom[0].count > this.settings.active.arDetect.edgeDetection.confirmationThreshold) ) {
return {
status: EdgeStatus.AR_KNOWN,
blackbarWidth: blackbarWidth,
@ -467,7 +469,8 @@ class EdgeDetect{
var blackbarWidth = edgesBottom[i].distance > edgesTop[0].distance ?
edgesBottom[i].distance : edgesTop[0].distance;
if (edgesTop[0].count + edgesBottom[i].count > this.settings.active.arDetect.edgeDetection.detectionThreshold) {
if (edgesTop[0].count + edgesBottom[i].count > this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold
|| (edgesTop[0].count > this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold && edgesBottom[i].count > this.settings.active.arDetect.edgeDetection.confirmationThreshold)) {
return {
status: EdgeStatus.AR_KNOWN,
blackbarWidth: blackbarWidth,
@ -489,7 +492,7 @@ class EdgeDetect{
// either the top or the bottom edge remains undetected, but we have one more trick that we
// can try. It also tries to work around logos.
var edgeDetectionThreshold = this.conf.sampleCols.length * this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold;
const edgeDetectionThreshold = this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold;
if (edges.edgeCandidatesTopCount == 0 && edges.edgeCandidatesBottomCount != 0){
for(var edge of edgesBottom){

View File

@ -330,10 +330,11 @@
<b>Sample width</b> In a bid to detect "false" edges, we take two samples this many pixels wide near the point of our potential edge. One sample must be completely black, the other must contain a set
amount of non-black pixels.<br/>
<b>Detection threshold</b> non-black sample mentioned above needs to contain at least this many non-black pixels.<br/>
<b>Single side confirmation threshold</b> quorum needed to establish aspect ratio in case we manage to detect an edge only on one side of the video. (0-0.5)<br/>
<b>Thickness quorum (per edge)</b> amount of samples that agree on the thincknes of the blackbar that we need in order to establish aspect ratio. Every edge needs to have at least this many. Values higher than {{~~(settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold / 2)}} (quorum (total)/2) are pointless.<br/>
<b>Thickness quorum (total)</b> amount of samples that agree on the thinckess of the blackbar that we need in order to establish aspect ratio in case one of the edges doesn't contain enough samples to achieve quorum.<br/>
<b>Logo threshold</b> if edge candidate sits with count greater than this*all_samples, it can't be a logo or a watermark.<br/>
<b>Ignore middle area</b> When trying to detect area, ignore area between middle and canvasHeight * {this value} pixels towards the edge.<br/>
<b>Detect limit</b> stop search after finding a potential candidate in this many sample columns (%, 0-1)<br/>
<b>Detect limit</b> stop search after finding a potential candidate in this many sample columns<br/>
</div>
<div class="indent">
<div class="flex flex-row row-padding">
@ -358,7 +359,17 @@
</div>
<div class="flex flex-row row-padding">
<div class="flex label-secondary form-label">
Single side confirmation threshold:
Thickness quorum (per edge):
</div>
<div class="flex flex-input">
<input
v-model="settings.active.arDetect.edgeDetection.confirmationThreshold"
/>
</div>
</div>
<div class="flex flex-row row-padding">
<div class="flex label-secondary form-label">
Thicnkess quorum (total):
</div>
<div class="flex flex-input">
<input