image_quality_check 0.2.4 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a5e8a3bce1a00b6023e31a34dc3e1acabc1dc9d80450f059a7934d7ef2925d4e
4
- data.tar.gz: 515cebc68693cbc6d213846c428dd9111665fd6588e189349f2ec32a4c5677a6
3
+ metadata.gz: a810f6dcf2ceadf8e6304d9f8541f940f09372dccf6e030e545d568cf8958fd5
4
+ data.tar.gz: 96fa32d7aee06e29793a458adf07ccacea40e522772aac775ebd088b31a15a15
5
5
  SHA512:
6
- metadata.gz: dab40cad5a0269f737635b721ae62b86d875aa69e88e23189924236370afa3256df316e5517d4c9106ec7df832707eb4e1973cd19923505bfccb8e0c84291350
7
- data.tar.gz: 0d6bbac089bc474a671d125eed15f3dc0222c738d5ff8a2b26fda0a6692bd924372371324bc9ff1b21a28369ad6f33aba5aee52bf8bbf20e31c7520ee8a7ab18
6
+ metadata.gz: 16bf50f9ba0f0da20af8941714ea6ff96aa6369786a54669bd29197d5f9f36b08df1ee0af2c7fc3605e3c03afc51aae5d25f42620ce7ed1ebeb138f52993b668
7
+ data.tar.gz: ece0ea9ec666d0917faba163245e340ca34d5e78ac560fb2c23ce14162ccbc99ba6b4fa45ed438be96142e46f25ea8b9b4a134473127127e7d900366ddcb3d3a
data/.gitignore CHANGED
@@ -7,3 +7,5 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
  spec/.examples.txt
10
+ Gemfile.lock
11
+ .tool-versions
@@ -12,7 +12,12 @@ img = cv2.imread(sys.argv[1], 0)
12
12
  clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8,8))
13
13
  img = clahe.apply(img)
14
14
 
15
- face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')
15
+ if hasattr(cv2, 'data'):
16
+ prefix = cv2.data.haarcascades
17
+ else:
18
+ prefix = '/usr/share/opencv4/haarcascades/'
19
+
20
+ face_cascade = cv2.CascadeClassifier(prefix + 'haarcascade_frontalface_default.xml')
16
21
  faces_detect = face_cascade.detectMultiScale(img, scaleFactor=1.5, minNeighbors=3)
17
22
 
18
23
  for (x, y, w, h) in faces_detect:
@@ -32,10 +37,10 @@ else:
32
37
  face = img
33
38
 
34
39
 
35
- smile_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_smile.xml')
40
+ smile_cascade = cv2.CascadeClassifier(prefix + 'haarcascade_smile.xml')
36
41
  smile_detect = smile_cascade.detectMultiScale(face, minNeighbors=40, scaleFactor=1.14)
37
42
 
38
- eye_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_eye.xml')
43
+ eye_cascade = cv2.CascadeClassifier(prefix + 'haarcascade_eye.xml')
39
44
  eye_detect = eye_cascade.detectMultiScale(face, minNeighbors=15)
40
45
 
41
46
  out['hasSmile'] = len(smile_detect) > 0
@@ -62,6 +62,13 @@ class ImageQualityCheck::DetermineQuality
62
62
 
63
63
  def read!(tmp_file)
64
64
  case @column.class.to_s
65
+ when 'ActiveStorage::Attached::One'
66
+ if !@column.blob || !File.exist?(@column.blob.service.send(:path_for, @column.blob.key))
67
+ false
68
+ else
69
+ FileUtils.cp(@column.blob.service.send(:path_for, @column.blob.key), tmp_file.path)
70
+ true
71
+ end
65
72
  when "Paperclip::Attachment"
66
73
  if !@column.path || !File.exist?(@column.path)
67
74
  false
@@ -9,7 +9,7 @@ module ImageQualityCheck::DSL
9
9
  def rules_for(klass, attachment)
10
10
  rule = @rules[[klass.to_s, attachment.to_s]]
11
11
  unless rule
12
- raise NotImplemented, I18n.t("image_quality_check.dsl.no_qualities_defined_for", klass: (klass), attachment: (attachment))
12
+ raise NotImplementedError, I18n.t("image_quality_check.dsl.no_qualities_defined_for", klass: (klass), attachment: (attachment))
13
13
  end
14
14
  @current_rule = []
15
15
  class_exec(&rule)
@@ -1,3 +1,3 @@
1
1
  module ImageQualityCheck
2
- VERSION = "0.2.4"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: image_quality_check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Wienert
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-13 00:00:00.000000000 Z
11
+ date: 2024-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  requirements: []
76
- rubygems_version: 3.2.15
76
+ rubygems_version: 3.5.16
77
77
  signing_key:
78
78
  specification_version: 4
79
79
  summary: Thin gem wrapper that uses imagemagick and python-opencv to help determine