Skip to main content

Open_cv_first_project

Step 1 - connect local server first (click on connect button)

install packages commands are there..

command (i) !pip install cmake dlib face_recognition numpy opencv-python

command (ii) !pip install opencv-python

Step 2 - connect google drive folder where your picture uploaded.

command (i)  from google.colab import drive

command (ii) drive.mount('/gdrive/') 

=> click on link which show in your screen and allow all services than copy paist link those you get in screen 
then your drive will be connect with google colab.

command (iii) %cd /gdrive/My Drive/Open CV Project

=> using this connect your drive folder..

command (iv) ls

=> this command show you those images names on screen.

step 3 - show image on screen.
command (i)  import cv2

command (ii) from google.colab.patches import cv2_imshow

command (iii) image = cv2.imread('test.jpg')

=> read image using this command and store one variable (image)

command (iv) cv2_imshow(image)

=> using this command show the image on desktop.




step 4 - create a image using command (this will be work when some other picture all ready present in folder/copy paist)

command (i) cv2.imwrite('abc.jpg',image)

output => true //that mean picture will be added.

=> using this command create a one more image in drive folder.

command (ii) ls

    => using this command watch all image and there you can see your new image name which you provide that will be show there




step 5 - resize images

command (i)- img = cv2.resize(image,(200,200))

=> command for resize image 

command (ii)- cv2_imshow(img)

=> show image command




step 6- rotate image
command (i)- rows,cols = image.shape[:2]

command (ii)- M = cv2.getRotationMatrix2D((cols/2,rows/2),90,1)

command (iii)- dst = cv2.warpAffine(image,M,(cols,rows))

command (iv)- cv2_imshow(dst)




step 7- zoom on images

command (i)- import numpy as np

command (ii)- M = np.float32([[1,0,-100],[0,1,-100]])

command (iii)- dst = cv2.warpAffine(image,M,(cols,rows))

command (iv)- cv2_imshow(dst)




step 8- show edges in images

command (i)-   edge=cv2.Canny(image,50,100)

command (ii)-  cv2_imshow(edge)





Comments