@@ -7,10 +7,9 @@ import { ImageHelper } from "./image-helper";
77
88export function loadFrameComparer ( nsCapabilities : INsCapabilities ) {
99 try {
10- const frameComparer = frComparer . createFrameComparer ( ) ;
1110 const storage = getStorageByDeviceName ( nsCapabilities ) ;
1211 const logPath = getReportPath ( nsCapabilities ) ;
13- return new FrameComparer ( nsCapabilities , storage , logPath , frameComparer ) ;
12+ return new FrameComparer ( nsCapabilities , storage , logPath ) ;
1413 } catch ( error ) {
1514 console . error ( "In order to use frame comaprer, please read carefully https://github.com/SvetoslavTsenov/frame-comparer/blob/master/README.md for dependecies that are required!" ) ;
1615 }
@@ -20,25 +19,25 @@ export class FrameComparer {
2019 private _framesGeneralName : string = "frame" ;
2120 private _cropImageRect : IRectangle ;
2221
23- constructor ( private _nsCapabilities : INsCapabilities , private _storage : string , private _logPath : string , private _frameComparer : frComparer . FrameComparer ) {
22+ constructor ( private _nsCapabilities : INsCapabilities , private _storage : string , private _logPath : string ) {
2423 this . _cropImageRect = ImageHelper . cropImageDefault ( this . _nsCapabilities ) ;
2524 }
2625
2726 async processVideo ( videoFullName , framesGeneralName ?: string , videoTempStorage = "tempFramesFolder" ) {
2827 this . _framesGeneralName = framesGeneralName || this . _framesGeneralName ;
2928 this . _framesGeneralName = this . _framesGeneralName . replace ( / \s / gi, "" ) ;
30- await this . _frameComparer . processVideo ( videoFullName , videoTempStorage , this . _framesGeneralName ) ;
29+ return await frComparer . FrameComparer . processVideo ( videoFullName , videoTempStorage , this . _framesGeneralName ) ;
3130 }
3231
33- async compareFrameRanges ( imageFrameCount : number , startRange , endRange , logImageComparisonResults : boolean = false , tollerancePixels = 0.1 , verbose = false ) : Promise < boolean > {
34- const result = await this . _frameComparer . compareImageFromVideo ( resolve ( this . _storage , `${ this . _framesGeneralName } ${ imageFrameCount } .png` ) , this . _logPath , startRange , endRange , tollerancePixels , this . _cropImageRect , true , logImageComparisonResults , verbose ) ;
32+ async compareFrameRanges ( frames : Array < string > , imageFrameCount : number , startRange , endRange , logImageComparisonResults : boolean = false , tollerancePixels = 0.1 , verbose = false ) : Promise < boolean > {
33+ const result = await frComparer . FrameComparer . compareImageFromVideo ( frames , resolve ( this . _storage , `${ this . _framesGeneralName } ${ imageFrameCount } .png` ) , this . _logPath , startRange , endRange , tollerancePixels , true , logImageComparisonResults , this . _cropImageRect , verbose ) ;
3534 return result ;
3635 }
3736
38- async compareFrames ( imageFrameCount : number , tolleranceRange = 3 , tollerancePixels = 0.1 , logImageComparisonResults : boolean = false , verbose = false ) : Promise < boolean > {
37+ async compareFrames ( frames : Array < string > , imageFrameCount : number , tolleranceRange = 3 , tollerancePixels = 0.1 , logImageComparisonResults : boolean = false , verbose = false ) : Promise < boolean > {
3938 const start = imageFrameCount - tolleranceRange > 0 ? imageFrameCount - tolleranceRange : 0 ;
4039 const end = imageFrameCount + tolleranceRange ;
41- const result = await this . compareFrameRanges ( imageFrameCount , start , end , logImageComparisonResults , tollerancePixels )
40+ const result = await this . compareFrameRanges ( frames , imageFrameCount , start , end , logImageComparisonResults , tollerancePixels )
4241 return result ;
4342 }
4443}
0 commit comments