×

Multiple-Choice Questions

Web Technologies MCQs

Computer Science Subjects MCQs

Databases MCQs

Programming MCQs

Testing Software MCQs

Digital Marketing Subjects MCQs

Cloud Computing Softwares MCQs

AI/ML Subjects MCQs

Engineering Subjects MCQs

Office Related Programs MCQs

Management MCQs

More

Python OpenCV MCQs (Multiple-Choice Questions)

Python OpenCV is a Python interface for OpenCV, an open-source computer vision library used for image processing, video analysis, object detection, feature detection, and other computer vision tasks. OpenCV-Python works closely with NumPy arrays for representing and manipulating image data.

Python OpenCV MCQs

These Python OpenCV multiple-choice questions cover important concepts such as image reading and writing, color spaces, pixels, NumPy arrays, image transformations, filtering, thresholding, morphology, edge detection, contours, video processing, cameras, and object detection.

List of Python OpenCV MCQs

Practice these Python OpenCV MCQs with answers and explanations to improve your knowledge of OpenCV and prepare for exams, interviews, quizzes, and technical assessments.

1. What does OpenCV primarily provide?

  1. Computer vision and image processing functionality
  2. Relational database management
  3. Web application routing
  4. Operating system administration

Answer: A) Computer vision and image processing functionality

Explanation:

OpenCV is an open-source library that provides algorithms and tools for computer vision, image processing, video analysis, and related tasks.

2. Which Python package is commonly imported to use OpenCV?

  1. opencv
  2. cv2
  3. openvision
  4. pyvision

Answer: B) cv2

Explanation:

The Python bindings for OpenCV are commonly imported using import cv2.

3. OpenCV-Python is primarily a set of bindings for which OpenCV language API?

  1. JavaScript
  2. C++
  3. Ruby
  4. PHP

Answer: B) C++

Explanation:

OpenCV is primarily implemented in C++, while OpenCV-Python provides Python bindings that expose OpenCV functionality to Python programs.

4. Which library is heavily used with OpenCV-Python for image array operations?

  1. NumPy
  2. Flask
  3. Django
  4. Requests

Answer: A) NumPy

Explanation:

OpenCV-Python represents images as NumPy arrays, making NumPy operations important for accessing pixels, regions of interest, and image data.

5. Which function is used to read an image from a file?

  1. cv2.imread()
  2. cv2.readImage()
  3. cv2.load()
  4. cv2.openImage()

Answer: A) cv2.imread()

Explanation:

cv2.imread() loads an image from a file and returns the image as an array when the file can be read successfully.

6. Which function is used to save an image to a file?

  1. cv2.save()
  2. cv2.imwrite()
  3. cv2.writeImage()
  4. cv2.store()

Answer: B) cv2.imwrite()

Explanation:

cv2.imwrite() writes an image to a specified file.

7. What does cv2.imread() generally return when an image cannot be read?

  1. True
  2. None
  3. An empty string
  4. A text error message

Answer: B) None

Explanation:

In Python, cv2.imread() returns None when the image cannot be loaded, such as when the file is missing or invalid.

8. Which function displays an image in an OpenCV window?

  1. cv2.display()
  2. cv2.show()
  3. cv2.imshow()
  4. cv2.view()

Answer: C) cv2.imshow()

Explanation:

cv2.imshow() displays an image in a named OpenCV window.

9. Which function is commonly used to wait for a keyboard event in an OpenCV GUI application?

  1. cv2.waitKey()
  2. cv2.waitEvent()
  3. cv2.keyWait()
  4. cv2.pause()

Answer: A) cv2.waitKey()

Explanation:

cv2.waitKey() waits for a keyboard event for a specified amount of time and is commonly used with OpenCV display windows.

10. Which function creates a named OpenCV window?

  1. cv2.createWindow()
  2. cv2.namedWindow()
  3. cv2.openWindow()
  4. cv2.window()

Answer: B) cv2.namedWindow()

Explanation:

cv2.namedWindow() creates a window that can be used for displaying images and other GUI elements.

11. What color channel order does OpenCV commonly use when reading a color image?

  1. RGB
  2. GRB
  3. BGR
  4. RBG

Answer: C) BGR

Explanation:

OpenCV commonly represents a three-channel color image in Blue, Green, Red (BGR) order rather than the RGB order commonly used in other libraries.

12. In OpenCV's BGR representation, what does the first channel represent?

  1. Red
  2. Green
  3. Blue
  4. Alpha

Answer: C) Blue

Explanation:

For a standard three-channel BGR image, the first channel contains blue values, followed by green and red.

13. Which flag can be used with cv2.imread() to load an image as grayscale?

  1. cv2.IMREAD_GRAY
  2. cv2.IMREAD_GRAYSCALE
  3. cv2.GRAYSCALE
  4. cv2.READ_GRAY

Answer: B) cv2.IMREAD_GRAYSCALE

Explanation:

cv2.IMREAD_GRAYSCALE instructs OpenCV to load the image in grayscale mode.

14. Which function converts an image from one color space to another?

  1. cv2.colorChange()
  2. cv2.cvtColor()
  3. cv2.convertColor()
  4. cv2.changeColor()

Answer: B) cv2.cvtColor()

Explanation:

cv2.cvtColor() converts image data between supported color spaces.

15. Which conversion code converts a BGR image to grayscale?

  1. cv2.COLOR_RGB2GRAY
  2. cv2.COLOR_BGR2GRAY
  3. cv2.COLOR_GRAY2BGR
  4. cv2.COLOR_BGR2RGB

Answer: B) cv2.COLOR_BGR2GRAY

Explanation:

cv2.COLOR_BGR2GRAY converts a BGR image into a single-channel grayscale image.

16. Which NumPy property can be used to obtain the dimensions of an image array?

  1. shape
  2. dimension
  3. sizeOf
  4. resolution

Answer: A) shape

Explanation:

The NumPy shape property provides the size of each dimension of an image array.

17. For a typical color image represented as a NumPy array, what do the first two dimensions represent?

  1. Width and color only
  2. Height and width
  3. Channels and width
  4. Depth and channels

Answer: B) Height and width

Explanation:

For a typical OpenCV color image array, the first dimension represents height and the second represents width. A third dimension represents color channels.

18. How can a region of interest be selected from an image in OpenCV-Python?

  1. Using NumPy slicing
  2. Using only cv2.roi()
  3. Using SQL queries
  4. Using cv2.region()

Answer: A) Using NumPy slicing

Explanation:

OpenCV-Python images are NumPy arrays, so array slicing can be used to select a rectangular region of interest.

19. Which function resizes an image?

  1. cv2.resize()
  2. cv2.scale()
  3. cv2.changeSize()
  4. cv2.resizeImage()

Answer: A) cv2.resize()

Explanation:

cv2.resize() changes the spatial dimensions of an image using a selected interpolation method.

20. Which OpenCV function is commonly used for rotating an image by a predefined 90-degree orientation?

  1. cv2.rotate()
  2. cv2.turn()
  3. cv2.rotation()
  4. cv2.spin()

Answer: A) cv2.rotate()

Explanation:

cv2.rotate() performs rotations using predefined rotation flags such as 90 degrees clockwise or counterclockwise.

21. Which function performs an affine transformation in OpenCV?

  1. cv2.warpAffine()
  2. cv2.affine()
  3. cv2.transformAffine()
  4. cv2.applyAffine()

Answer: A) cv2.warpAffine()

Explanation:

cv2.warpAffine() applies an affine transformation matrix to an image.

22. Which function performs a perspective transformation?

  1. cv2.warpPerspective()
  2. cv2.perspective()
  3. cv2.warpProject()
  4. cv2.projectImage()

Answer: A) cv2.warpPerspective()

Explanation:

cv2.warpPerspective() applies a perspective transformation using a transformation matrix.

23. Which interpolation method uses the nearest pixel when resizing an image?

  1. cv2.INTER_NEAREST
  2. cv2.INTER_LINEAR
  3. cv2.INTER_CUBIC
  4. cv2.INTER_AREA

Answer: A) cv2.INTER_NEAREST

Explanation:

INTER_NEAREST uses nearest-neighbor interpolation, selecting the nearest source pixel.

24. Which function applies a Gaussian blur to an image?

  1. cv2.gaussianBlur()
  2. cv2.GaussianBlur()
  3. cv2.gaussianFilter()
  4. cv2.blurGaussian()

Answer: B) cv2.GaussianBlur()

Explanation:

cv2.GaussianBlur() applies Gaussian filtering to an image and is commonly used for smoothing.

25. Which function performs median filtering?

  1. cv2.medianBlur()
  2. cv2.medianFilter()
  3. cv2.blurMedian()
  4. cv2.filterMedian()

Answer: A) cv2.medianBlur()

Explanation:

cv2.medianBlur() applies median filtering and is commonly useful for reducing certain types of image noise.

26. Which OpenCV function performs bilateral filtering?

  1. cv2.bilateralFilter()
  2. cv2.bilateralBlur()
  3. cv2.edgeFilter()
  4. cv2.edgeBlur()

Answer: A) cv2.bilateralFilter()

Explanation:

cv2.bilateralFilter() performs edge-preserving smoothing by considering both spatial and intensity differences.

27. Which function applies a fixed-level threshold to an image?

  1. cv2.threshold()
  2. cv2.applyThreshold()
  3. cv2.binary()
  4. cv2.segment()

Answer: A) cv2.threshold()

Explanation:

cv2.threshold() applies a fixed thresholding operation to array elements. OpenCV supports several threshold types.

28. Which thresholding method automatically determines a threshold from the image histogram?

  1. Otsu's thresholding
  2. Manual thresholding
  3. Nearest thresholding
  4. Median thresholding

Answer: A) Otsu's thresholding

Explanation:

Otsu's method automatically determines a threshold value based on the image histogram and is commonly used for separating foreground and background.

29. Which OpenCV function performs adaptive thresholding?

  1. cv2.adaptiveThreshold()
  2. cv2.localThreshold()
  3. cv2.autoThreshold()
  4. cv2.dynamicThreshold()

Answer: A) cv2.adaptiveThreshold()

Explanation:

cv2.adaptiveThreshold() calculates a threshold for smaller regions of an image rather than applying one global threshold to the entire image.

30. Which function performs Canny edge detection?

  1. cv2.edgeDetect()
  2. cv2.Canny()
  3. cv2.detectEdges()
  4. cv2.Edge()

Answer: B) cv2.Canny()

Explanation:

cv2.Canny() implements the Canny edge detection algorithm for detecting significant edges in an image.

31. Which functions are commonly used for image gradients in OpenCV?

  1. cv2.Sobel(), cv2.Scharr(), and cv2.Laplacian()
  2. cv2.Canny(), cv2.Hough(), and cv2.Blur()
  3. cv2.Read(), cv2.Write(), and cv2.Show()
  4. cv2.Merge(), cv2.Split(), and cv2.Resize()

Answer: A) cv2.Sobel(), cv2.Scharr(), and cv2.Laplacian()

Explanation:

OpenCV provides Sobel, Scharr, and Laplacian operations for calculating image gradients and derivatives.

32. Which function performs erosion in OpenCV?

  1. cv2.erode()
  2. cv2.erosion()
  3. cv2.shrink()
  4. cv2.reduceObject()

Answer: A) cv2.erode()

Explanation:

cv2.erode() performs morphological erosion using a specified structuring element.

33. Which function performs dilation?

  1. cv2.expand()
  2. cv2.dilate()
  3. cv2.dilation()
  4. cv2.grow()

Answer: B) cv2.dilate()

Explanation:

cv2.dilate() performs morphological dilation using a structuring element.

34. Which function performs advanced morphological operations such as opening and closing?

  1. cv2.morphologyEx()
  2. cv2.morphology()
  3. cv2.morph()
  4. cv2.advancedMorph()

Answer: A) cv2.morphologyEx()

Explanation:

cv2.morphologyEx() performs advanced morphological transformations based on operations such as erosion and dilation.

35. What is morphological opening generally composed of?

  1. Dilation followed by erosion
  2. Erosion followed by dilation
  3. Thresholding followed by dilation
  4. Blurring followed by thresholding

Answer: B) Erosion followed by dilation

Explanation:

Morphological opening is defined as erosion followed by dilation using the same structuring element.

36. What is morphological closing generally composed of?

  1. Erosion followed by dilation
  2. Dilation followed by erosion
  3. Thresholding followed by erosion
  4. Blurring followed by dilation

Answer: B) Dilation followed by erosion

Explanation:

Morphological closing is defined as dilation followed by erosion using the same structuring element.

37. Which function creates a structuring element for morphological operations?

  1. cv2.getStructuringElement()
  2. cv2.createKernel()
  3. cv2.makeStructure()
  4. cv2.kernelElement()

Answer: A) cv2.getStructuringElement()

Explanation:

cv2.getStructuringElement() creates a structuring element such as a rectangle, ellipse, or cross-shaped kernel for morphological operations.

38. What is a contour in OpenCV?

  1. A curve joining continuous points along a boundary
  2. A database record
  3. A color conversion table
  4. A video codec

Answer: A) A curve joining continuous points along a boundary

Explanation:

Contours represent curves joining continuous points along boundaries with the same color or intensity and are useful for shape analysis and object detection.

39. Which function finds contours in an image?

  1. cv2.findContours()
  2. cv2.detectContours()
  3. cv2.getContours()
  4. cv2.searchContours()

Answer: A) cv2.findContours()

Explanation:

cv2.findContours() detects contours in a binary or suitably prepared image.

40. Which function draws contours on an image?

  1. cv2.paintContours()
  2. cv2.drawContours()
  3. cv2.renderContours()
  4. cv2.showContours()

Answer: B) cv2.drawContours()

Explanation:

cv2.drawContours() draws detected contours onto an image.

41. Which contour retrieval mode retrieves all contours and establishes a full hierarchy?

  1. cv2.RETR_EXTERNAL
  2. cv2.RETR_LIST
  3. cv2.RETR_TREE
  4. cv2.RETR_SIMPLE

Answer: C) cv2.RETR_TREE

Explanation:

cv2.RETR_TREE retrieves contours and reconstructs a complete hierarchy of nested contours.

42. Which function calculates the area of a contour?

  1. cv2.contourArea()
  2. cv2.areaContour()
  3. cv2.calculateArea()
  4. cv2.objectArea()

Answer: A) cv2.contourArea()

Explanation:

cv2.contourArea() calculates the area enclosed by a contour.

43. Which function calculates the perimeter or arc length of a contour?

  1. cv2.arcLength()
  2. cv2.contourLength()
  3. cv2.perimeter()
  4. cv2.lengthContour()

Answer: A) cv2.arcLength()

Explanation:

cv2.arcLength() calculates the arc length of a curve or contour.

44. Which class is commonly used to capture video from a camera in OpenCV-Python?

  1. cv2.VideoCapture
  2. cv2.CameraCapture
  3. cv2.VideoReader
  4. cv2.Camera

Answer: A) cv2.VideoCapture

Explanation:

cv2.VideoCapture provides an interface for capturing frames from cameras, video files, or other supported video sources.

45. Which method reads the next frame from a VideoCapture object?

  1. read()
  2. next()
  3. capture()
  4. frame()

Answer: A) read()

Explanation:

The read() method retrieves the next video frame and returns a success indicator along with the frame.

46. Which OpenCV class is used to write video frames to a video file?

  1. cv2.VideoWriter
  2. cv2.VideoSave
  3. cv2.VideoOutput
  4. cv2.VideoRecorder

Answer: A) cv2.VideoWriter

Explanation:

cv2.VideoWriter provides an interface for writing video frames to a video file.

47. Which function is commonly used to detect circles using the Hough Circle Transform?

  1. cv2.HoughCircles()
  2. cv2.detectCircles()
  3. cv2.findCircles()
  4. cv2.CircleTransform()

Answer: A) cv2.HoughCircles()

Explanation:

cv2.HoughCircles() implements the Hough Circle Transform for detecting circles in images.

48. Which OpenCV technique can be used to detect straight lines?

  1. Hough Line Transform
  2. Median Transform
  3. Color Transform
  4. Pixel Transform

Answer: A) Hough Line Transform

Explanation:

The Hough Line Transform is used to detect straight lines in images and is available through OpenCV functions such as cv2.HoughLines().

49. Which OpenCV feature is specifically designed for detecting objects such as faces using cascade classifiers?

  1. Haar Cascade Classifier
  2. Median Filter
  3. Gaussian Pyramid
  4. Color Mapper

Answer: A) Haar Cascade Classifier

Explanation:

OpenCV provides cascade classifiers, including Haar feature-based cascades, for object detection tasks such as face detection.

50. Which statement best describes OpenCV-Python?

  1. A Python interface for OpenCV used for computer vision tasks
  2. A Python-only database engine
  3. A web framework for creating REST APIs
  4. A package exclusively for numerical statistics

Answer: A) A Python interface for OpenCV used for computer vision tasks

Explanation:

OpenCV-Python provides Python bindings for OpenCV and is used for image processing, video analysis, object detection, feature detection, and many other computer vision applications.

Advertisement
Advertisement

Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2026 www.includehelp.com. All rights reserved.