image_quality_check 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/exe/image_quality_blur +8 -3
- data/lib/image_quality_check/determine_quality.rb +7 -0
- data/lib/image_quality_check/dsl.rb +2 -2
- data/lib/image_quality_check/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a810f6dcf2ceadf8e6304d9f8541f940f09372dccf6e030e545d568cf8958fd5
|
4
|
+
data.tar.gz: 96fa32d7aee06e29793a458adf07ccacea40e522772aac775ebd088b31a15a15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16bf50f9ba0f0da20af8941714ea6ff96aa6369786a54669bd29197d5f9f36b08df1ee0af2c7fc3605e3c03afc51aae5d25f42620ce7ed1ebeb138f52993b668
|
7
|
+
data.tar.gz: ece0ea9ec666d0917faba163245e340ca34d5e78ac560fb2c23ce14162ccbc99ba6b4fa45ed438be96142e46f25ea8b9b4a134473127127e7d900366ddcb3d3a
|
data/.gitignore
CHANGED
data/exe/image_quality_blur
CHANGED
@@ -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
|
-
|
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(
|
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(
|
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
|
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)
|
@@ -20,7 +20,7 @@ module ImageQualityCheck::DSL
|
|
20
20
|
@current_rule << { name: name, block: block, weight: weight }
|
21
21
|
end
|
22
22
|
|
23
|
-
def preferred_formats_rule(
|
23
|
+
def preferred_formats_rule(weight: 1, **formats)
|
24
24
|
rule I18n.t("image_quality_check.dsl.format"), weight: weight do |result, on_error|
|
25
25
|
final_score = nil
|
26
26
|
formats.each do |f, score|
|
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.
|
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:
|
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.
|
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
|