@@ -152,17 +152,17 @@ do {
152152
153153 let tempDiff = " \( entryPath) /diff.temp "
154154
155- guard let ncc = try screenshotNCC ( oldImage, latestImage, diffFile: tempDiff) else {
156- print ( " Error checking screenshot NCC . " )
155+ guard let score = try screenshotScore ( oldImage, latestImage, diffFile: tempDiff) else {
156+ print ( " Error checking screenshot score . " )
157157 try handleScreenshotError ( entry: entry)
158158 try rollBack ( oldImage, to: latestImage)
159159 // Continue with the next entry
160160 continue
161161 }
162162
163163 // If the website changed
164- if ncc < kNccThreshold {
165- print ( " Possible change detected (NCC : \( ncc ) ). Confirming... " )
164+ if score < kComparisonThreshold {
165+ print ( " Possible change detected (score : \( score ) ). Confirming... " )
166166
167167 // Take another screenshot to confirm its not just a one-time loading error or inconsistency
168168 // Delete the changed screenshot, otherwise we cannot confirm that taking the screenshot was a success
@@ -173,18 +173,18 @@ do {
173173 continue
174174 }
175175
176- guard let newNCC = try screenshotNCC ( oldImage, latestImage, diffFile: tempDiff) else {
176+ guard let newScore = try screenshotScore ( oldImage, latestImage, diffFile: tempDiff) else {
177177 // Error while confirming screenshot
178- print ( " Error confirming screenshot NCC . " )
178+ print ( " Error confirming screenshot score . " )
179179 try handleScreenshotError ( entry: entry)
180180 try rollBack ( oldImage, to: latestImage)
181181 // Continue with the next entry
182182 continue
183183 }
184184
185- if newNCC < kNccThreshold {
185+ if newScore < kComparisonThreshold {
186186 // If the second screenshot also shows changes, we notify the user
187- print ( " Change confirmed. NCC : \( newNCC ) . Notifying user. " )
187+ print ( " Change confirmed. Score : \( newScore ) . Notifying user. " )
188188
189189 // Save the temp file persistently
190190 let diffFile = " \( entryPath) / \( kDiffFile) "
@@ -197,27 +197,28 @@ do {
197197 try fileManager. moveItem ( atPath: tempDiff, toPath: diffFile)
198198 }
199199
200- // Generate detailed NCC information
201- let nccFile = " \( entryPath) / \( kNccFile ) "
202- if fileManager. fileExists ( atPath: nccFile ) {
203- try fileManager. removeItem ( atPath: nccFile )
200+ // Generate detailed score information
201+ let scoreFile = " \( entryPath) / \( kScoreFile ) "
202+ if fileManager. fileExists ( atPath: scoreFile ) {
203+ try fileManager. removeItem ( atPath: scoreFile )
204204 }
205+ // TODO: Duplicated in Functions.swift
205206 try bash ( " compare " , arguments: [
206207 " -verbose " ,
207208 " -alpha " , " deactivate " ,
208- " -metric " , " NCC " ,
209+ " -metric " , " SSIM " ,
209210 oldImage,
210211 latestImage,
211212 " /dev/null "
212- ] , standardOutput: FileHandle ( forWritingAtPath: nccFile ) )
213+ ] , standardOutput: FileHandle ( forWritingAtPath: scoreFile ) )
213214
214215 // Notify the user
215- try sendTelegramMessage ( " \( entry. name) has changed. NCC : \( ncc ) \( ncc != newNCC ? " , \( newNCC ) " : " " ) " , to: Int ( entry. chatID) , image: latestImage)
216+ try sendTelegramMessage ( " \( entry. name) has changed. Score : \( score ) \( score != newScore ? " , \( newScore ) " : " " ) " , to: Int ( entry. chatID) , image: latestImage)
216217 } else {
217- print ( " Change not confirmed. NCC : \( newNCC ) " )
218+ print ( " Change not confirmed. Score : \( newScore ) " )
218219 }
219220 } else {
220- print ( " No change detected. NCC : \( ncc ) " )
221+ print ( " No change detected. Score : \( score ) " )
221222 }
222223
223224 // Clean up any temp diff files
0 commit comments