qubitless on Nostr: This type of thing is great as a termux shortcut imo, but a little elbow grease will ...
This type of thing is great as a termux shortcut imo, but a little elbow grease will be needed to make it smooth, simple web app a lot easier if you have a server.
Plausible chatgpt vomit:
./faceblur input.jpg output.jpg
```python
import cv2
import sys
# Load the pre-trained face detector from OpenCV
face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')
# Function to anonymize the detected faces
def anonymize_faces(image):
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=5)
# Iterate through each face and anonymize it
for (x, y, w, h) in faces:
face_roi = image[y:y+h, x:x+w]
blurred_roi = cv2.GaussianBlur(face_roi, (99, 99), 30)
image[y:y+h, x:x+w] = blurred_roi
return image
def main():
if len(sys.argv) != 3:
print("Usage: ./faceblur input.jpg output.jpg")
return
input_path = sys.argv[1]
output_path = sys.argv[2]
# Load the image
image = cv2.imread(input_path)
if image is None:
print(f"Failed to load image: {input_path}")
return
# Apply anonymization on the faces
anonymized_image = anonymize_faces(image)
# Save the anonymized image
cv2.imwrite(output_path, anonymized_image)
print(f"Anonymized image saved to: {output_path}")
if __name__ == "__main__":
main()
```
Setup in Termux:
```bash
#!/bin/bash
# Install necessary packages
pkg install python -y
pkg install clang -y
pkg install libjpeg-turbo -y
# Set up OpenCV
pip install numpy
LDFLAGS="-L/system/lib/" CPATH="/system/include/" pip install opencv-python-headless
# Download the Haarcascade XML file
curl -O https://raw.githubusercontent.com/opencv/opencv/master/data/haarcascades/haarcascade_frontalface_default.xml
# Create the temp directory to store images
mkdir temp
echo "Prerequisites installed successfully!"
```
Plausible chatgpt vomit:
./faceblur input.jpg output.jpg
```python
import cv2
import sys
# Load the pre-trained face detector from OpenCV
face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')
# Function to anonymize the detected faces
def anonymize_faces(image):
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=5)
# Iterate through each face and anonymize it
for (x, y, w, h) in faces:
face_roi = image[y:y+h, x:x+w]
blurred_roi = cv2.GaussianBlur(face_roi, (99, 99), 30)
image[y:y+h, x:x+w] = blurred_roi
return image
def main():
if len(sys.argv) != 3:
print("Usage: ./faceblur input.jpg output.jpg")
return
input_path = sys.argv[1]
output_path = sys.argv[2]
# Load the image
image = cv2.imread(input_path)
if image is None:
print(f"Failed to load image: {input_path}")
return
# Apply anonymization on the faces
anonymized_image = anonymize_faces(image)
# Save the anonymized image
cv2.imwrite(output_path, anonymized_image)
print(f"Anonymized image saved to: {output_path}")
if __name__ == "__main__":
main()
```
Setup in Termux:
```bash
#!/bin/bash
# Install necessary packages
pkg install python -y
pkg install clang -y
pkg install libjpeg-turbo -y
# Set up OpenCV
pip install numpy
LDFLAGS="-L/system/lib/" CPATH="/system/include/" pip install opencv-python-headless
# Download the Haarcascade XML file
curl -O https://raw.githubusercontent.com/opencv/opencv/master/data/haarcascades/haarcascade_frontalface_default.xml
# Create the temp directory to store images
mkdir temp
echo "Prerequisites installed successfully!"
```