Computer Vision p1.1



Hello world ! Welcome to my second blog post on computer vision .
If you want to learn Computer vision from scratch you are at the right place.
In the previous blog I discussed about how my future blogs gonna be.So lets get started .
                Image result for learning from scratch gif


Image Processing p1: Image formation

Overview:

Image formation in eyes.
Image formation by image sensors.
Python code for capturing image.


How images are formed in the eye?

Our eyes are windows to the wonders of the world all we know experience and 
discover ponder and cherish let's peer in to the workings of the eye.
                            Image result for human eye 
The amount of light that enters the eye is controlled by the circular and radial muscles in the iris, which contract and relax to alter the size of the pupil. The light first passes through a tough protective sheet called the cornea, and then moves into the lens. This adjustable structure bends the light, focusing it down to a point on the retina, at the back of the eye.

The retina is covered in millions of light-sensitive receptors known as rods and cones. Each receptor contains pigment molecules, which change shape when they are hit by light, triggering an electrical message that travels to the brain via the optic nerve.     
                         Image result for image formation in eye

We as a human beings come equipped with two eyes that work together to form stereovision.We ll go to the term stereo vision in future blogs.

Have ever thought how camera works?

                                        Image result for camera                                        
Imagine how difficult it could have been if there was no invention of camera!
We capture every moment with our smart phone camera.Lets see how those camera sensor works.
Camera consists of a image sensor which mimics human eyes.Image sensors capture images in the form of photons(light packets)  and converts then in to electric signals.
These signals are then amplified and further processed by Analog to Digital converter and processor. These discrete signals generated forms a pixel.We will learn about pixels in next blog.

There are two types of image sensors : CCD and CMOS.

If you want to learn CCD and CMOS in detail go through this video:
   CCD vs CMOS.
CMOS sensor is used in most of the digital camera sensors.


Python code for capturing image.

We can capture live video by webcam camera or from android device and process it .

1)Capturing image from web cam.

first install numpy and opencv for python.



import numpy as np
import cv2

cap = cv2.VideoCapture(0)

while(True):
    # Capture frame-by-frame
    ret, frame = cap.read()

    # Our operations on the frame come here
    
    # Display the resulting frame
    cv2.imshow('frame',frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()


 2) Capturing image from android smart phone to your python code.

If you dont have web cam this is the best option. Also if you want wireless camera for your application you can use this method.
You need to have your android smart phone and pc connected to same LAN  connection.

Install Ip web cam from play store to your smart phone.
Make sure your smart phone and pc is connected to same network.
Start the app and you will find  start server option.
After starting server you will see the IP address assigned to your smart phone ,note that.
My Ip address was 192.168.0.105:8080


import numpy as np
import cv2
import time
 

cap = cv2.VideoCapture()
cap.open("http://192.168.0.105:8080/video?.mjpeg")    #change ip address
time.sleep(0.1)  


while(True):
    # Capture frame-by-frame
    ret, frame = cap.read()

    # Our operations on the frame come here
    
    # Display the resulting frame
    cv2.imshow('frame',frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()



Note:
The above method using Ip web cam on smart phone heats up the smart phone and draining the battery faster .

Comments

  1. Attractive section of content. I just stumbled upon your site and in accession capital to assert that I get in fact enjoyed account your blog posts. Any way I will be subscribing to your augment and even I achievement you access consistently quickly.

    Image computers | New laptops in pakistan | Used laptops in pakistan
    Printers in pakistan | Networking items in pakistan | Laptop batteries in pakistan | Graphics cards in pakistan

    ReplyDelete

Post a Comment

Popular posts from this blog

Computer Vision