Hello All of member Utopian, now I wanna make a tutorial how to make "Application Face Detection and Digital Imaging with Python," but first you must know, what is numpy and read my previous tutorials to understand in this tutorial.
OpenCV is the main module used to perform processing on the creation of "Application Face Detection and Digital Imaging with Python." OpenCV can perform many tasks, from reading image files, performing color editings, to detecting faces efficiently.
1 . Open your Terminal. Write this command sudo pip install opencv-python
2 . Open your PYCharm. Click File > Settings > Project: facedetector > Project Interpreter > click +.
3 . search opencv-python > click install package.
4 . Test your OpenCV package. Click right on project facedetector > new > Python file > Set Name file with tes-opencv > write this code.
import cv2
print (cv2.__version__)
5 . Run it. if success, congratulation your OpenCV package already installed.
import cv2
print (cv2.__version__)
9 . Run it. if success, congritulation your OpenCV package allready installed.
1 . copy an image file to project facedetector folder.
2 . Create New python file, set name with load-image.
3 . Write this code.
import numpy as np
import cv2 as cv
img = cv.imread('test.jpg',1)
cv.imshow('image',img)
cv.waitKey(0)
cv.destroyAllWindows()
4 . Run it, and see that result.
This code to call numpy and opencv packages.
import numpy as np
import cv2 as cv
This code to make variable img and use opencv to read test.jpg image file and 1 to read image as full color, if 0 to read image as grayscale, if -1 will be opened as is.
img = cv.imread('test.jpg',1)
This code to show image on variable img.
cv.imshow('image',img)
This code to close the window after you click any button. 0 intends to close the window within 0 milliseconds.
cv.waitKey(0)
This code to close all open windows.
cv.destroyAllWindows()
1 . Create New fpython file one project facedetector, and set name save-image
2 . Write this code.
import numpy as np
import cv2 as cv
img = cv.imread('test.jpg',0)
cv.imshow('image',img)
cv.waitKey(0)
cv.imwrite('test2.jpg',img)
cv.destroyAllWindows()
3 . Run it, and see result.
This code to make variable img and use opencv to read test.jpg image file and 0 to read image as grayscale, if 1 to read image as full color, if -1 will be opened as is.
img = cv.imread('test.jpg',0)
This code to save a new image file with name test2.jpg after you click any button.
cv.imwrite('test2.jpg',img)
Okay all this tutorial to continue with another tutorial.