In preparation for machine learning images, we are trying to trim and save only the face part from a large number of images.
The image before trimming is saved in the model folder, and the trimmed face image is going to be saved in the save folder.
When I executed the following program code, no error message was displayed, but no trimmed face images were saved in the save folder.
C: \ Users \ Taisei \ Anaconda3 \ envs \ opencv \ lib \ site-packages \ numpy \ _distributor_init.py: 32: UserWarning: loaded more than 1 DLL from .libs: C: \ Users \ Taisei \ Anaconda3 \ envs \ opencv \ lib \ site-packages \ numpy \ .libs \ libopenblas.PYQHXLVVQ7VESDPUVUADXEVJOBGHJPAY.gfortran-win_amd64.dll C: \ Users \ Taisei \ Anaconda3 \ envs \ opencv \ lib \ site-packages \ numpy \ .libs \ libopenblas.TXA6YQSD3GCQQC22GEQ54J2UDCXDXHWN.gfortran-win_amd64.dll stacklevel = 1) ↑ Execution ends here.
import cv2 import matplotlib.pyplot as plt import numpy as np import sys, os from PIL import Image #Specify input file path in_jpg = "C: \ python code \ model" out_jpg = "C: \ python code \ save" #Functions that return results in a list def get_file (dir_path): filenames = os.listdir (dir_path) return filenames pic = get_file (in_jpg) for i in pic: # Load image image_gs = cv2.imread (in_jpg + i) # Load face recognition feature file --- (Specify cascade file path) cascade = cv2.CascadeClassifier ('C: \\ Users \\ Taisei \\ Anaconda3 \\ envs \\ OpenCV \\ Lib \\ site-packages \\ cv2 \\ data \\ haarcascade_frontalface_default.xml') # Perform face recognition face_list = cascade.detectMultiScale (image_gs, scaleFactor = 1.1, minNeighbors = 1, minSize = (1,1)) # Cut out only face and save no = 1; for rect in face_list: x = rect  y = rect  width = rect  height = rect  dst = image_gs [y: y + height, x: x + width] save_path = out_jpg + '/' + 'out_ (' + str (i) + ')' + str (no) + '.jpg' #Save recognition result a = cv2.imwrite (save_path, dst) plt.show (plt.imshow (np.asarray (Image.open (save_path))))) print (no) no + = 1
Please describe what you tried for the problem here.Supplemental information (FW/tool version etc.)
The referenced site was macOS, but I'm Windows10, so there may be a problem.
Answer # 1
image_gs = cv2.imread (in_jpg + i)
Check this line, the name of the file you are trying to read (
in_jpg + i).
Since there is a library for it properly, let's use it.
- a large number of errors when installing the python library
- python - how to stream images processed by opencv in real time
- unity how to attach a large number of images
- i want to click and number a few images like a switch in python
- python - i got an error in opencv
- python - i want to connect the images in two folders in order
- python - when you want to judge by the number of characters from the back with a regular expression
- python - detect whole body and upper body with opencv
- python - images are not displayed in the flask app launched with docker
- python - valueerror: field'id' expected a number but got'suzukitadashi'
- where is the minor version number of python that starts by default specified?
- python - sumy by specifying the maximum number of characters with sumy
- python 3x - i want to set a response type bot that sends messages and images to discord with google colaboratory
- python - i don't see the error in the face cropping program with opencv
- python opencv recording time
- python opencv color index
- how to automate tweets with images from spython with json files
- python - i want to move images with pygame
- python - how to get the number of searches for a specific word within the period
- python - i want to add a line number to the data frame
- Capture a video stream of computer windows using Python
- Error starting OpenCV Python
- python : Error starting
- Python OpenCV Color
- How to force the server on Flask to execute my Python code block?
- python : Importerror: DLL LOAD FAILED: The specified module is not found. Will not see CV2.
- python : How to create median image?
- python : Celeba Dataset is incorrect?