34
34
35
35
X-untagged[:#] Use daniel's tool as generator:
36
36
X http://toolserver.org/~daniel/WikiSense/UntaggedImages.php
37
-
38
-
39
37
"""
40
38
41
39
#
@@ -214,10 +212,10 @@ def _detect_Faces_CV(self):
214
212
# how small and how many features are detected as faces (or eyes)
215
213
scale = max ([1. , np .average (np .array (img .shape )[0 :2 ]/ 500. )])
216
214
except IOError :
217
- pywikibot .output (u'WARNING: unknown file type [_detect_Faces_CV]' )
215
+ pywikibot .warning (u'unknown file type [_detect_Faces_CV]' )
218
216
return
219
217
except AttributeError :
220
- pywikibot .output (u'WARNING: unknown file type [_detect_Faces_CV]' )
218
+ pywikibot .warning (u'unknown file type [_detect_Faces_CV]' )
221
219
return
222
220
223
221
#detectAndDraw( image, cascade, nestedCascade, scale );
@@ -419,10 +417,10 @@ def _detect_People_CV(self):
419
417
scale = max ([1. , np .average (np .array (img .shape )[0 :2 ]/ 400. )])
420
418
#scale = max([1., np.average(np.array(img.shape)[0:2]/300.)])
421
419
except IOError :
422
- pywikibot .output (u'WARNING: unknown file type [_detect_People_CV]' )
420
+ pywikibot .warning (u'unknown file type [_detect_People_CV]' )
423
421
return
424
422
except AttributeError :
425
- pywikibot .output (u'WARNING: unknown file type [_detect_People_CV]' )
423
+ pywikibot .warning (u'unknown file type [_detect_People_CV]' )
426
424
return
427
425
428
426
# similar to face detection
@@ -529,10 +527,10 @@ def _util_get_Geometry_CVnSCIPY(self):
529
527
# how small and how many features are detected
530
528
scale = max ([1. , np .average (np .array (img .shape )[0 :2 ]/ 500. )])
531
529
except IOError :
532
- pywikibot .output (u'WARNING: unknown file type [_detect_Geometry_CV]' )
530
+ pywikibot .warning (u'unknown file type [_detect_Geometry_CV]' )
533
531
return self ._buffer_Geometry
534
532
except AttributeError :
535
- pywikibot .output (u'WARNING: unknown file type [_detect_Geometry_CV]' )
533
+ pywikibot .warning (u'unknown file type [_detect_Geometry_CV]' )
536
534
return self ._buffer_Geometry
537
535
538
536
# similar to face or people detection
@@ -750,7 +748,7 @@ def _detect_SegmentColors_JSEGnPIL(self): # may be SLIC other other too...
750
748
(l , t ) = (0 , 0 )
751
749
i = im
752
750
except IOError :
753
- pywikibot .output (u'WARNING: unknown file type [_detect_SegmentColors_JSEGnPIL]' )
751
+ pywikibot .warning (u'unknown file type [_detect_SegmentColors_JSEGnPIL]' )
754
752
return
755
753
756
754
result = []
@@ -764,7 +762,7 @@ def _detect_SegmentColors_JSEGnPIL(self): # may be SLIC other other too...
764
762
##(pic, scale) = self._util_detect_ColorSegments_JSEG(pic) # (final split)
765
763
#hist = self._util_get_ColorSegmentsHist_PIL(i, pic, scale) #
766
764
except TypeError :
767
- pywikibot .output (u'WARNING: unknown file type [_detect_SegmentColors_JSEGnPIL]' )
765
+ pywikibot .warning (u'unknown file type [_detect_SegmentColors_JSEGnPIL]' )
768
766
return
769
767
i = 0
770
768
# (may be do an additional region merge according to same color names...)
@@ -805,7 +803,7 @@ def _detect_AverageColor_PILnCV(self):
805
803
i = Image .open (self .image_path_JPEG )
806
804
h = i .histogram ()
807
805
except IOError :
808
- pywikibot .output (u'WARNING: unknown file type [_detect_AverageColor_PILnCV]' )
806
+ pywikibot .warning (u'unknown file type [_detect_AverageColor_PILnCV]' )
809
807
return
810
808
811
809
result = self ._util_average_Color_colormath (h )
@@ -863,7 +861,7 @@ def _detect_Properties_PIL(self):
863
861
try :
864
862
i = Image .open (self .image_path )
865
863
except IOError :
866
- pywikibot .output (u'WARNING: unknown (image) file type [_detect_Properties_PIL]' )
864
+ pywikibot .warning (u'unknown (image) file type [_detect_Properties_PIL]' )
867
865
return
868
866
869
867
# http://mail.python.org/pipermail/image-sig/1999-May/000740.html
@@ -906,7 +904,7 @@ def _detect_Properties_PIL(self):
906
904
# result = {}
907
905
# # DO NOT use ImageMagick (identify) instead of PIL to get these info !!
908
906
else :
909
- pywikibot .output (u'WARNING: unknown (generic) file type [_detect_Properties_PIL]' )
907
+ pywikibot .warning (u'unknown (generic) file type [_detect_Properties_PIL]' )
910
908
return
911
909
912
910
result ['Dimensions' ] = self .image_size
@@ -1001,7 +999,7 @@ def _util_detect_ColorSegments_JSEG(self, im):
1001
999
try :
1002
1000
smallImg = im .resize ( tuple (np .int_ (np .array (im .size )/ scale )), Image .ANTIALIAS )
1003
1001
except IOError :
1004
- pywikibot .output (u'WARNING: unknown file type [_util_detect_ColorSegments_JSEG]' )
1002
+ pywikibot .warning (u'unknown file type [_util_detect_ColorSegments_JSEG]' )
1005
1003
return
1006
1004
1007
1005
#im.thumbnail(size, Image.ANTIALIAS) # size is 640x480
@@ -1070,7 +1068,7 @@ def _util_get_ColorSegmentsHist_PIL(self, im, pic, scale):
1070
1068
try :
1071
1069
smallImg = im .resize ( tuple (np .int_ (np .array (im .size )/ scale )), Image .ANTIALIAS )
1072
1070
except IOError :
1073
- pywikibot .output (u'WARNING: unknown file type [_util_get_ColorSegmentsHist_PIL]' )
1071
+ pywikibot .warning (u'unknown file type [_util_get_ColorSegmentsHist_PIL]' )
1074
1072
return
1075
1073
1076
1074
imgsize = float (smallImg .size [0 ]* smallImg .size [1 ])
@@ -1190,10 +1188,10 @@ def _detect_Trained_CV(self, info_desc, cascade_file, maxdim=500.):
1190
1188
# how small and how many features are detected
1191
1189
scale = max ([1. , np .average (np .array (img .shape )[0 :2 ]/ maxdim )])
1192
1190
except IOError :
1193
- pywikibot .output (u'WARNING: unknown file type [_detect_Trained_CV]' )
1191
+ pywikibot .warning (u'unknown file type [_detect_Trained_CV]' )
1194
1192
return
1195
1193
except AttributeError :
1196
- pywikibot .output (u'WARNING: unknown file type [_detect_Trained_CV]' )
1194
+ pywikibot .warning (u'unknown file type [_detect_Trained_CV]' )
1197
1195
return
1198
1196
1199
1197
# similar to face detection
@@ -1358,10 +1356,10 @@ def _detect_EmbeddedText_poppler(self):
1358
1356
# pdfinterp.process_pdf(rsrcmgr, device, fp, set(), maxpages=0, password='',
1359
1357
# caching=True, check_extractable=False)
1360
1358
#except AssertionError:
1361
- # pywikibot.output (u'WARNING: pdfminer missed, may be corrupt [_detect_EmbeddedText_poppler]')
1359
+ # pywikibot.warning (u'pdfminer missed, may be corrupt [_detect_EmbeddedText_poppler]')
1362
1360
# return
1363
1361
#except TypeError:
1364
- # pywikibot.output (u'WARNING: pdfminer missed, may be corrupt [_detect_EmbeddedText_poppler]')
1362
+ # pywikibot.warning (u'pdfminer missed, may be corrupt [_detect_EmbeddedText_poppler]')
1365
1363
# return
1366
1364
#fp.close()
1367
1365
#device.close()
@@ -1417,7 +1415,7 @@ def _recognize_OpticalCodes_dmtxNzbar(self):
1417
1415
1418
1416
scale = max ([1. , np .average (np .array (img .size )/ 200. )])
1419
1417
except IOError :
1420
- pywikibot .output (u'WARNING: unknown file type [_recognize_OpticalCodes_dmtxNzbar]' )
1418
+ pywikibot .warning (u'unknown file type [_recognize_OpticalCodes_dmtxNzbar]' )
1421
1419
return
1422
1420
1423
1421
smallImg = img .resize ( (int (img .size [0 ]/ scale ), int (img .size [1 ]/ scale )) )
@@ -1454,7 +1452,7 @@ def _recognize_OpticalCodes_dmtxNzbar(self):
1454
1452
img = Image .open (self .image_path_JPEG ).convert ('L' )
1455
1453
width , height = img .size
1456
1454
except IOError :
1457
- pywikibot .output (u'WARNING: unknown file type [_recognize_OpticalCodes_dmtxNzbar]' )
1455
+ pywikibot .warning (u'unknown file type [_recognize_OpticalCodes_dmtxNzbar]' )
1458
1456
return
1459
1457
1460
1458
scanner = zbar .ImageScanner ()
@@ -1504,10 +1502,10 @@ def _detect_Chessboard_CV(self):
1504
1502
1505
1503
scale = max ([1. , np .average (np .array (im .shape )[0 :2 ]/ 1000. )])
1506
1504
except IOError :
1507
- pywikibot .output (u'WARNING: unknown file type [_detect_Chessboard_CV]' )
1505
+ pywikibot .warning (u'unknown file type [_detect_Chessboard_CV]' )
1508
1506
return
1509
1507
except AttributeError :
1510
- pywikibot .output (u'WARNING: unknown file type [_detect_Chessboard_CV]' )
1508
+ pywikibot .warning (u'unknown file type [_detect_Chessboard_CV]' )
1511
1509
return
1512
1510
1513
1511
smallImg = np .empty ( (cv .Round (im .shape [1 ]/ scale ), cv .Round (im .shape [0 ]/ scale )), dtype = np .uint8 )
@@ -1522,7 +1520,7 @@ def _detect_Chessboard_CV(self):
1522
1520
#found_all, corners = cv.FindChessboardCorners( im, chessboard_dim )
1523
1521
found_all , corners = cv2 .findChessboardCorners ( im , chessboard_dim )
1524
1522
except cv2 .error , e :
1525
- pywikibot .output (u'%s' % e )
1523
+ pywikibot .error (u'%s' % e )
1526
1524
1527
1525
#cv2.drawChessboardCorners( im, chessboard_dim, corners, found_all )
1528
1526
##cv2.imshow("win", im)
@@ -1806,7 +1804,7 @@ def _detect_Faces_EXIF(self):
1806
1804
try :
1807
1805
(width , height ) = (int (float (width )+ 0.5 ), int (float (height )+ 0.5 ))
1808
1806
except ValueError :
1809
- pywikibot .output (u'WARNING: %s contains incompatible unit(s), skipped' % ((width , height ),))
1807
+ pywikibot .warning (u'%s contains incompatible unit(s), skipped' % ((width , height ),))
1810
1808
return
1811
1809
else :
1812
1810
(width , height ) = self .image_size
@@ -1921,8 +1919,8 @@ def _detect_Faces_EXIF(self):
1921
1919
available = [item in res for item in ['FacesDetected' , 'ValidAFPoints' ]]
1922
1920
unknown = ['face' in item .lower () for item in res .keys ()]
1923
1921
if make and (True in (available + unknown )):
1924
- pywikibot .output (u"WARNING: skipped '%s' since not supported (yet) [_detect_Faces_EXIF]" % make )
1925
- pywikibot .output (u"WARNING: FacesDetected: %s - ValidAFPoints: %s" % tuple (available ))
1922
+ pywikibot .warning (u"skipped '%s' since not supported (yet) [_detect_Faces_EXIF]" % make )
1923
+ pywikibot .warning (u"FacesDetected: %s - ValidAFPoints: %s" % tuple (available ))
1926
1924
1927
1925
# finally, rotate face coordinates if image was rotated
1928
1926
if wasRotated :
@@ -2209,7 +2207,7 @@ def _detect_AudioFeatures_YAAFE(self):
2209
2207
2210
2208
# Load important components
2211
2209
if (yaafe .loadComponentLibrary ('yaafe-io' )!= 0 ):
2212
- pywikibot .output (u'WARNING: cannot load yaafe-io component library !' ) # ! needed, else it will crash !
2210
+ pywikibot .warning (u'cannot load yaafe-io component library !' ) # ! needed, else it will crash !
2213
2211
2214
2212
# Build a DataFlow object using FeaturePlan
2215
2213
fp = yaafe .FeaturePlan (sample_rate = 44100 , normalize = 0.98 , resample = False )
@@ -2764,7 +2762,7 @@ def downloadImage(self):
2764
2762
#self.image_size = (None, None)
2765
2763
mime = mimetypes .guess_all_extensions ('%s/%s' % tuple (self .image_mime [0 :2 ]))
2766
2764
if self .image_fileext .lower () not in mime :
2767
- pywikibot .output (u'WARNING: File extension does not match MIME type! File extension should be %s.' % mime )
2765
+ pywikibot .warning (u'File extension does not match MIME type! File extension should be %s.' % mime )
2768
2766
2769
2767
# SVG: rasterize the SVG to bitmap (MAY BE GET FROM WIKI BY DOWNLOAD?...)
2770
2768
# (Mediawiki uses librsvg too: http://commons.wikimedia.org/wiki/SVG#SVGs_in_MediaWiki)
@@ -3481,12 +3479,12 @@ def main():
3481
3479
Bot .downloadImage ()
3482
3480
except IOError , err :
3483
3481
# skip if download not possible
3484
- pywikibot .output (u"WARNING: %s, skipped..." % err )
3482
+ pywikibot .warning (u"%s, skipped..." % err )
3485
3483
continue
3486
3484
except Exception , err :
3487
3485
# skip on any unexpected error, but report it
3488
- pywikibot .output (u"ERROR: %s" % err )
3489
- pywikibot .output (u"ERROR: was not able to process page %s !!!\n " % \
3486
+ pywikibot .error (u"%s" % err )
3487
+ pywikibot .error (u"was not able to process page %s !!!\n " % \
3490
3488
image .title (asLink = True ))
3491
3489
continue
3492
3490
resultCheck = Bot .checkStep ()
@@ -3496,8 +3494,8 @@ def main():
3496
3494
if ret :
3497
3495
outresult .append ( ret )
3498
3496
except AttributeError :
3499
- pywikibot .output (u"ERROR: was not able to process page %s !!!\n " % \
3500
- image .title (asLink = True ))
3497
+ pywikibot .error (u"was not able to process page %s !!!\n " % \
3498
+ image .title (asLink = True ))
3501
3499
limit += - 1
3502
3500
if not tagged :
3503
3501
posfile = open (os .path .join (scriptdir , 'cache/catimages_start' ), "w" )
@@ -3548,13 +3546,13 @@ def trainbot(generator, Bot, image_old_namespace, image_namespace):
3548
3546
Bot .downloadImage ()
3549
3547
except IOError , err :
3550
3548
# skip if download not possible
3551
- pywikibot .output (u"WARNING: %s, skipped..." % err )
3549
+ pywikibot .warning (u"%s, skipped..." % err )
3552
3550
continue
3553
3551
except Exception , err :
3554
3552
# skip on any unexpected error, but report it
3555
- pywikibot .output (u"ERROR: %s" % err )
3556
- pywikibot .output (u"ERROR: was not able to process page %s !!!\n " % \
3557
- image .title (asLink = True ))
3553
+ pywikibot .error (u"%s" % err )
3554
+ pywikibot .error (u"was not able to process page %s !!!\n " % \
3555
+ image .title (asLink = True ))
3558
3556
continue
3559
3557
3560
3558
# gather all features (information) related to current image
0 commit comments