Giter Club home page Giter Club logo

image-acquisition-from-web-camera's Introduction

Image Acquisition from Web Camera

Aim

To write a python program using OpenCV to capture the image from the web camera and do the following image manipulations.

  1. Write the frame as JPG
  2. Display the video
  3. Display the video by resizing the window
  4. Rotate and display the video

Software Used

Anaconda - Python 3.7

Algorithm

Step 1:

 Import cv2 and capture the video using cv2.VideoCapture(0)

Step 2:

 Write the captured image using cv2.imwrite("NewPicture.jpg",frame)

Step 3:

 Resize the image using cv2.resize() to get a four-split screen.

Step 4:

 Rotate the image using cv2.rotate(smaller_frame,cv2.cv2.ROTATE_180)

Step 5:

 Display the image until the key to close the window is pressed.


Program:

Developed By: Shafeeq Ahamed.S
Register No: 212221230092

i) Write the frame as JPG file

obj = cv2.VideoCapture(0)
while(True):
    cap,frame = obj.read()
    cv2.imshow('video_image.jpg',frame)
    cv2.imwrite("out.jpg",frame)
    if cv2.waitKey(1) == ord('q'):
        break
obj.release()
cv2.destroyAllWindows()

ii) Display the video

obj = cv2.VideoCapture(0)
while(True):
    cap,frame = obj.read()
    cv2.imshow('video_image',frame)
    if cv2.waitKey(1) == ord('q'):
        break
obj.release()
cv2.destroyAllWindows()

iii) Display the video by resizing the window

obj = cv2.VideoCapture(0)
while True:
    cap, frame = obj.read()
    h = int(obj.get(4))
    w = int(obj.get(3))
    sm_frame = cv2.resize(frame, (0,0), fx=0.5 , fy=0.5)
    im = np.ones(frame.shape,np.uint8)*200
    im[125:(h//2)+125,135:(w//2)+135] = sm_frame
    cv2.imshow("Pic",im)
    if cv2.waitKey(1) == ord('q'):
        break
obj.release()
cv2.destroyAllWindows()

iv) Rotate and display the video

obj = cv2.VideoCapture(0)
while True:
    cap, frame = obj.read()
    h = int(obj.get(4))
    w = int(obj.get(3))
    im = np.ones(frame.shape,np.uint8)*185
    sf = cv2.resize(frame, (0,0), fx=0.5 , fy=0.5)
     - #+/- 80
    im[75:(height//2)+155, 35:(width//2)-45] = cv2.rotate(sf,cv2.ROTATE_90_CLOCKWISE)
    im[:height//2, width//2:] = sf
    im[height//2:, width//2:] = cv2.rotate(sf,cv2.ROTATE_180)
    cv2.imshow("Pic",im)
    if cv2.waitKey(1) == ord('q'):
        break
obj.release()
cv2.destroyAllWindows()

Output

i) Write the frame as JPG image

image

ii) Display the video

image

iii) Display the video by resizing the window

image

iv) Rotate and display the video

image

Result:

Thus the image is accessed from webcamera and displayed using openCV.

image-acquisition-from-web-camera's People

Contributors

shafeeqahameds avatar etjabajasphin 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.