Practice
Resources
Contests
Online IDE
New
Free Mock
Events New Scaler
Practice
Improve your coding skills with our resources
Contests
Compete in popular contests with top coders
logo
Events
Attend free live masterclass hosted by top tech professionals
New
Scaler
Explore Offerings by SCALER

Data Analysis

Last Updated: Jan 10, 2022
Go to Problems
Contents

OpenCV

OpenCV is an open-source programming library/package that has been created especially for allowing programmers to work with the world of Computer Vision. The OpenCV package was primarily developed by Intel Corporation.  OpenCV stands for Open-Source Computer Vision (Library). Firstly import cv2. It is a cross-platform library using which we can develop real-time computer vision applications. The main focus, but not limited to, is on image processing, video capture, and analysis including features like face detection and object detection.

 

To begin with, for loading an image into our system RAM (Random Access Memory), we can use the imread() method provided by OpenCV, as shown below.

import cv2
image =cv2.imread("location_of_image")
cv2.imshow('InterviewBit Computer Vision', image)
cv2.waitkey(“1”) # This displays the image indefinitely till you cut the window or press any key


You can read the image with the cv2.imread( ) function and the functioncv2. The  imshow() function is used to display the current image on the screen (in google colab this will be cv2_imshow imported from google.colab.patches).

 

cv2.VideoCapture(0)  function captures video from the computer’s camera. The parameter 0 here is for accessing the camera connected to your computer.

 

ret, frame = capture.read() 

 

is used in order to see the images we captured in the video. Because videos consist of frames here we will read the captured image and then return that image.

(B, G, R) = image[h,w] # here we are extracting the RGB values of a pixel at h,w for height and width.
resized_image = cv2.resize(image, (1000, 200)) 

using this function we can resize the dimensions of an image here as we are resizing here to new dimensions.

We can also rotate an image after generating a 2dmatrix. getRotationMatrix2D() function returns a 2*3 matrix and warpAffline() calculates new x, y coordinates of the image and transforms it. You can try out these functions, along with multiple others, and see how it affects the image.




Video Courses
By

View All Courses
Excel at your interview with Masterclasses Know More
Certificate included
What will you Learn?
Free Mock Assessment
Fill up the details for personalised experience.
Phone Number *
OTP will be sent to this number for verification
+33 *
+33
Change Number
Graduation Year *
Graduation Year *
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
*Enter the expected year of graduation if you're student
Current Employer
Company Name
College you graduated from
College/University Name
Job Title
Job Title
Engineering Leadership
Software Development Engineer (Backend)
Software Development Engineer (Frontend)
Software Development Engineer (Full Stack)
Data Scientist
Android Engineer
iOS Engineer
Devops Engineer
Support Engineer
Research Engineer
Engineering Intern
QA Engineer
Co-founder
SDET
Product Manager
Product Designer
Backend Architect
Program Manager
Release Engineer
Security Leadership
Database Administrator
Data Analyst
Data Engineer
Non Coder
Other
Please verify your phone number
Edit
Resend OTP
By clicking on Start Test, I agree to be contacted by Scaler in the future.
Already have an account? Log in
Free Mock Assessment
Instructions from Interviewbit
Start Test