Coder Social home page Coder Social logo

trellixvulnteam / opencvfullproject_94vs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from krbutani/opencvfullproject

0.0 0.0 0.0 68.41 MB

Open CV Full Project Study

Python 96.98% C 2.30% Fortran 0.06% PowerShell 0.14% HTML 0.01% Batchfile 0.01% Cython 0.52%

opencvfullproject_94vs's Introduction

Learn Open CV Using Python

To Learn Open CV with easy way

Table of contents

Setup

  • Install Python ( Install below version of latest version )
  • Install PyCham
  • Create Project and add require library

How to install library

  • Goto File > Settings > Project > Python Interpreter
  • Press + Icon
  • Search name of library
  • Press Install Package button

Required Library

  • opencv-python
  • numpy

Read Image

The image will appear until you close the program

  • File: readimage.py
import cv2
img = cv2.imread("res/face.jpg")
cv2.imshow("Output",img)
cv2.waitKey(0) 

Read Video

The video will appear until you close the program or press q

  • File: readvideo.py
import cv2
cap = cv2.VideoCapture("res/road2.mp4")
while True:
    success, img = cap.read()
    if success:
        cv2.imshow("Video",img) 
        if cv2.waitKey(0) & 0xFF == ord('q'):
            break

Read WebCam

  • File: readwebcam.py
import cv2
cap = cv2.VideoCapture(0)
cap.set(3,640) # Width
cap.set(4,480) # Height
cap.set(10,80) # increase the brightness level level between 0 to 100
while True:
    success, img = cap.read()
    if success:
        cv2.imshow("Video",img) # show image
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break

Require Basic Function

This function is need in OpenCV Developement.

  • File: basicfunction.py
import cv2
import numpy as np

kernel = np.ones((5,5),np.uint8)
img = cv2.imread("res/face.jpg")

imgGray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
cv2.imshow("Gray Image", imgGray)

imgBlur = cv2.GaussianBlur(imgGray,(7,7),0)
cv2.imshow("Blur Image", imgBlur)

imgCanny = cv2.Canny(img,150,200)
cv2.imshow("Canny Image", imgCanny)

imgDialation = cv2.dilate(imgCanny,kernel,iterations=1)
cv2.imshow("Dialation Image",imgDialation)

imgEroded = cv2.erode(imgDialation,kernel,iterations=1)
cv2.imshow("Eroded Image",imgEroded)

cv2.waitKey(0)

Resize and Crop Image

  • File: imageresizeorcrop.py
import cv2
import numpy as np

img = cv2.imread("res/face.jpg")
print(img.shape) # its return 3 Value first width , seocnd height, third Type of image Like RGB, GRAY

imgResize = cv2.resize(img,(300,400))
imgCroped = img[300:600,300:1000]

cv2.imshow("Image", img)
cv2.imshow("Resize Image", imgResize)
cv2.imshow("Croped Image", imgCroped)
cv2.waitKey(0)

Draw Shape and Text

  • File: drawshapeandtext.py
import cv2
import numpy as np

imp = np.zeros((512,512,3),np.uint8)
print(imp.shape)

imp[:] = 255,255,255
# imp[200:300,100:300] = 0,255,0

cv2.line(imp,(0,0),(imp.shape[1],imp.shape[0]),(0,0,0),5)
cv2.rectangle(imp,(0,0),(250,350),(0,0,255),cv2.FILLED)
cv2.circle(imp,(400,200),100,(0,0,255),2)
cv2.putText(imp,"Hello World!",(000,400),cv2.FONT_HERSHEY_SIMPLEX,2,(255,0,0))

cv2.imshow("Show Image", imp)
cv2.waitKey(0)

opencvfullproject_94vs's People

Contributors

krbutani avatar trellixvulnteam avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.