@@ -122,6 +122,32 @@ <h2>Define or Detect the Region</h2>
122122 min ="1 " max ="32 " value ="5 "> < span id ="sibGrayDisplay "> </ span > </ br >
123123 </ div >
124124
125+ < input type ="checkbox " id ="hsvContrast " name ="rpMode " value ="RPM_GENERAL_HSV_CONTRAST ">
126+ < label for ="hsvContrast " class ="tooltip "
127+ aria-label ="Detects region using the general algorithm based on HSV colour contrast. "
128+ data-balloon-pos ="down " data-balloon-length ="fit "> General HSV Contrast Mode (16) </ label > < br />
129+
130+ <!-- Mode Arguments for the hsv contrast pre-detection mode-->
131+ < div class ="hsvContrastForm arguments ">
132+ < label for ="midHSV " class ="tooltip "
133+ aria-label ="If the image dimension is larger than the given value, the library will enable the feature of pre-detecting barcode regions. Otherwise, it will skip this step when searching for barcodes. "
134+ data-balloon-pos ="down " data-balloon-length ="fit "> Minimum Image Dimension</ label >
135+ < input type ="range " id ="midHSV " name ="minImageDim " data-require-pair ="#hsvContrast " min ="16384 "
136+ max ="2147483647 " value ="262144 "> < span id ="midHSVDisplay "> </ span > </ br >
137+
138+ < label for ="sensHSV " class ="tooltip "
139+ aria-label ="The higher the sensitivity, the more effort the library will take to detect regions. "
140+ data-balloon-pos ="down " data-balloon-length ="fit "> Sensitivity</ label >
141+ < input type ="range " id ="sensHSV " name ="sensitivity " data-require-pair ="#hsvContrast " min ="1 "
142+ max ="9 " value ="1 "> < span id ="sensHSVDisplay "> </ span > </ br >
143+
144+ < label for ="sibHSV " class ="tooltip "
145+ aria-label ="The block size used for region predetection would be 2 to the power of N, with N being the SpatialIndexBlockSize "
146+ data-balloon-pos ="down " data-balloon-length ="fit "> Spatial Index Block Size</ label >
147+ < input type ="range " id ="sibHSV " name ="SpatialIndexBlockSize " data-require-pair ="#hsvContrast "
148+ min ="1 " max ="32 " value ="5 "> < span id ="sibHSVDisplay "> </ span > </ br >
149+ </ div >
150+
125151 < input type ="checkbox " id ="autoRPM " name ="rpMode " value ="RPM_AUTO ">
126152 < label for ="autoRPM " class ="tooltip "
127153 aria-label ="Lets the library choose an algorithm automatically to detect region. "
@@ -209,6 +235,12 @@ <h2>Define or Detect the Region</h2>
209235 grayContrastForm [ 0 ] . style . display = "block" ;
210236 settings . furtherModes . regionPredetectionModes [ rpmCount ] = Dynamsoft . DBR . EnumRegionPredetectionMode . RPM_GENERAL_GRAY_CONTRAST ;
211237 break ;
238+ case "RPM_GENERAL_HSV_CONTRAST" :
239+ // First, display the mode arguments form for HSV Contrast mode the update the settings
240+ let hsvContrastForm = document . getElementsByClassName ( "hsvContrastForm" ) ;
241+ hsvContrastForm [ 0 ] . style . display = "block" ;
242+ settings . furtherModes . regionPredetectionModes [ rpmCount ] = Dynamsoft . DBR . EnumRegionPredetectionMode . RPM_GENERAL_HSV_CONTRAST ;
243+ break ;
212244 case "RPM_GENERAL" :
213245 settings . furtherModes . regionPredetectionModes [ rpmCount ] = Dynamsoft . DBR . EnumRegionPredetectionMode . RPM_GENERAL ;
214246 break ;
@@ -301,7 +333,6 @@ <h2>Define or Detect the Region</h2>
301333 }
302334 }
303335 }
304-
305336 /* Done with mode arguments for the RGB Contrast mode */
306337
307338 /* Now for the mode arguments of the Gray contrast mode, which are the same as the RGB contrast mode */
@@ -362,6 +393,64 @@ <h2>Define or Detect the Region</h2>
362393 }
363394 }
364395 /* Done with the mode arguments for the gray contrast pre-detection mode */
396+
397+ let midHSV = document . getElementById ( "midHSV" ) ;
398+ midHSV . onchange = async function ( ) {
399+ document . getElementById ( "midHSVDisplay" ) . innerHTML = midHSV . value . toString ( ) ;
400+ let settings = await scanner . getRuntimeSettings ( ) ;
401+ // Get the index of the HSV Contrast mode in the scale up modes array
402+ for ( var i = 0 ; i <= 8 ; i ++ ) {
403+ try {
404+ if ( settings . scaleUpModes [ i ] == Dynamsoft . DBR . EnumRegionPredetectionMode . RPM_GENERAL_HSV_CONTRAST )
405+ //once the index is found, use the index to set the mode argument.
406+ await scanner . setModeArgument ( "RegionPredetectionMode" , i , "MinImageDimension" , midHSV . value . toString ( ) ) ; // set the min image dimension
407+ else
408+ continue ; // if not HSV contrast, skip to next iteration
409+ } catch ( ex ) {
410+ console . log ( ex . message ) ;
411+ }
412+ }
413+ }
414+
415+ // Then, the sensitivity
416+ let sensitivityHSV = document . getElementById ( "sensHSV" ) ;
417+ sensitivityHSV . onchange = async function ( ) {
418+ document . getElementById ( "sensHSVDisplay" ) . innerHTML = sensitivityHSV . value . toString ( ) ;
419+ let settings = await scanner . getRuntimeSettings ( ) ;
420+ // Get the index of the HSV Contrast mode in the scale up modes array
421+ for ( var i = 0 ; i <= 8 ; i ++ ) {
422+ try {
423+ if ( settings . scaleUpModes [ i ] == Dynamsoft . DBR . EnumRegionPredetectionMode . RPM_GENERAL_HSV_CONTRAST )
424+ //once the index is found, use the index to set the mode argument.
425+ await scanner . setModeArgument ( "RegionPredetectionMode" , i , "Sensitivity" , sensitivityHSV . value . toString ( ) ) ; // set the min image dimension
426+ else
427+ continue ; // if not HSV contrast, skip to next iteration
428+ } catch ( ex ) {
429+ console . log ( ex . message ) ;
430+ }
431+ }
432+ }
433+
434+ // Now for the spatial index block size
435+ let sibHSV = document . getElementById ( "sibHSV" ) ;
436+ sibHSV . onchange = async function ( ) {
437+ document . getElementById ( "sibHSVDisplay" ) . innerHTML = sibHSV . value . toString ( ) ;
438+ let settings = await scanner . getRuntimeSettings ( ) ;
439+ // Get the index of the HSV Contrast mode in the scale up modes array
440+ for ( var i = 0 ; i <= 8 ; i ++ ) {
441+ try {
442+ if ( settings . scaleUpModes [ i ] == Dynamsoft . DBR . EnumRegionPredetectionMode . RPM_GENERAL_HSV_CONTRAST )
443+ //once the index is found, use the index to set the mode argument.
444+ await scanner . setModeArgument ( "RegionPredetectionMode" , i , "SpatialIndexBlockSize" , sibHSV . value . toString ( ) ) ; // set the min image dimension
445+ else
446+ continue ; // if not HSV contrast, skip to next iteration
447+ } catch ( ex ) {
448+ console . log ( ex . message ) ;
449+ }
450+ }
451+ }
452+
453+ /* Done with mode arguments for the HSV Contrast mode */
365454 }
366455 </ script >
367456</ body >
0 commit comments