|
7 | 7 | from pathlib import Path
|
8 | 8 | from typing import Sequence, Mapping
|
9 | 9 |
|
10 |
| -import cv2 |
11 | 10 | import numpy as np
|
12 | 11 | import rawpy
|
13 | 12 | from PySide6.QtCore import QFile, QIODevice, QDir, QFileInfo, QModelIndex, Qt, QStringListModel
|
@@ -87,46 +86,8 @@ def get_raw_thumbnail(path: Path):
|
87 | 86 | return thumb
|
88 | 87 |
|
89 | 88 |
|
90 |
| -def anonymize_image(image): |
91 |
| - # Convert the image to grayscale |
92 |
| - decoded_image = cv2.imdecode(np.frombuffer(image.data, np.uint8), -1) |
93 |
| - gray = cv2.cvtColor(decoded_image, cv2.COLOR_BGR2GRAY) |
94 |
| - |
95 |
| - # Load the cascade classifier for detecting cars |
96 |
| - cascades = ( |
97 |
| - str(Path(Path(__file__).parent, 'cars.xml')), |
98 |
| - str(Path(cv2.data.haarcascades, 'haarcascade_russian_plate_number.xml')) |
99 |
| - ) |
100 |
| - |
101 |
| - for cascade in cascades: |
102 |
| - car_cascade = cv2.CascadeClassifier(cascade) |
103 |
| - |
104 |
| - # Detect cars in the image |
105 |
| - cars = car_cascade.detectMultiScale(gray, 1.1, 1) |
106 |
| - |
107 |
| - # Iterate over the detected cars |
108 |
| - for (x, y, w, h) in cars: |
109 |
| - # Blur the license plate |
110 |
| - decoded_image[y + h - 20:y + h, x:x + w] = cv2.GaussianBlur( |
111 |
| - decoded_image[y + h - 20:y + h, x:x + w], (23, 23), 30) |
112 |
| - |
113 |
| - # Load the cascade classifier for detecting faces |
114 |
| - face_cascade = cv2.CascadeClassifier(str(Path(cv2.data.haarcascades, 'haarcascade_frontalface_default.xml'))) |
115 |
| - |
116 |
| - # Detect faces in the image |
117 |
| - faces = face_cascade.detectMultiScale(gray, 1.3, 5) |
118 |
| - |
119 |
| - # Iterate over the detected faces |
120 |
| - for (x, y, w, h) in faces: |
121 |
| - # Blur the face |
122 |
| - decoded_image[y:y + h, x:x + w] = cv2.GaussianBlur(decoded_image[y:y + h, x:x + w], (23, 23), 30) |
123 |
| - |
124 |
| - return cv2.imencode('.jpg', decoded_image)[1].tobytes() |
125 |
| - |
126 |
| - |
127 | 89 | def generate_thumbnail(thumbnail_dir_path: Path, path: Path) -> QPixmap:
|
128 | 90 | thumbnail = get_raw_thumbnail(path)
|
129 |
| - thumbnail = anonymize_image(thumbnail) |
130 | 91 |
|
131 | 92 | thumb_pixmap = QPixmap()
|
132 | 93 | thumb_pixmap.loadFromData(thumbnail)
|
|
0 commit comments