1. Home
  2. Explore
  3. Computer Science
  4. Python OpenCV Computer Vision

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Python OpenCV Computer Vision

  • 141Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Foundations
  • spaceFlip card
  • KI knew it
  • DI didn't know it
  • ←Previous card
  • →Next card

What is OpenCV?

Tap to flipClick to flipspace

An open-source computer vision library available for Python, C++, and Java.

Or swipe the card

141 cards

  1. What is OpenCV?

    An open-source computer vision library available for Python, C++, and Java.

  2. What does computer vision primarily focus on?

    Deriving insights from media files such as images and videos.

  3. What Python version is recommended for this course?

    Python 3.7 or newer.

  4. How can you check the installed Python version from a terminal?

    Run python --version.

  5. Which package installation command installs OpenCV with its contribution modules?

    Run pip install opencv-contrib-python.

  6. How does opencv-contrib-python differ from opencv-python?

    It includes the main OpenCV functionality plus additional contribution modules.

  7. What is NumPy used for in OpenCV work?

    Scientific computing and manipulation of matrices and arrays, including reshaping and transformations.

  8. What is the purpose of the Sierra utility package described in the content?

    It provides helper functions intended to speed up computer vision workflows.

  9. What major topics are covered in the OpenCV course?

    Media I/O, image transformations, drawing, color spaces, bitwise operations, masking, histograms, thresholding, edge detection, face analysis, and deep learning.

  10. What is the difference between face detection and face recognition?

    Face detection finds whether and where a face is present; face recognition identifies whose face it is.

  11. What does cv2.imread return?

    An image represented as a matrix of pixels.

  12. How do you read an image from a relative path in OpenCV?

    Pass the relative file path to cv2.imread, such as cv2.imread('photos/cat.jpg').

  13. What does cv2.imshow do?

    Displays an image matrix in a new window.

  14. Why is cv2.waitKey(0) commonly used after cv2.imshow?

    It waits indefinitely for a keyboard key press before continuing.

  15. What does cv2.VideoCapture accept as an argument?

    Either a camera index or a path to a video file.

  16. Which camera index usually refers to a computer's default webcam?

    Index 0.

  17. How are video files read in OpenCV?

    Frames are read sequentially inside a loop using capture.read().

  18. What does capture.read() return?

    A Boolean indicating success and the next video frame.

  19. How can a video-reading loop be stopped when the user presses the D key?

    Break when cv2.waitKey(20) & 0xFF == ord('d').

  20. What cleanup operations should follow video processing?

    Release the capture object and destroy all OpenCV windows.

  21. What commonly causes an OpenCV negative 215 assertion error during media loading?

    OpenCV could not find or read the specified image, video, or next video frame.

  22. Why are images and videos often resized or rescaled?

    To reduce computational strain and processing requirements.

  23. What does rescaling a frame mean?

    Changing its width and height by a chosen scale factor.

  24. How are an image's width and height obtained from frame.shape?

    The width is frame.shape[1]; the height is frame.shape[0].

  25. What does cv2.resize do?

    Resizes an image or frame to specified dimensions.

  26. Which interpolation method is commonly useful when shrinking an image?

    cv2.INTER_AREA.

  27. Which interpolation methods may be used when enlarging an image?

    cv2.INTER_LINEAR or cv2.INTER_CUBIC.

  28. What is the limitation of increasing a camera's resolution through software?

    A camera generally cannot capture beyond its maximum hardware capability.

  29. What does capture.set(3, width) control?

    The width of a live video capture.

  30. What does capture.set(4, height) control?

    The height of a live video capture.

  31. When does the capture.set resolution method work?

    For live video from a camera or webcam, not generally for existing video files.

  32. How can a blank image be created with NumPy for drawing?

    Use an array of zeros with the desired height, width, and channel count, typically with data type uint8.

  33. What does assigning a color to every pixel of a blank image do?

    It fills the entire image with that color.

  34. What is the BGR representation of green in OpenCV?

    (0,255,0)(0, 255, 0)(0,255,0).

  35. What is the BGR representation of red in OpenCV?

    (0,0,255)(0, 0, 255)(0,0,255).

  36. What does cv2.rectangle require?

    An image, two corner points, a color, and a thickness; a line type may also be supplied.

  37. How can a rectangle be filled using cv2.rectangle?

    Set the thickness to -1 or use cv2.FILLED.

  38. What does cv2.circle require?

    An image, center coordinates, radius, color, and thickness.

  39. How can a circle be filled?

    Set its thickness to -1.

  40. What does cv2.line do?

    Draws a line between two points on an image.

  41. What does cv2.putText do?

    Writes text on an image.

  42. What kind of fonts can be used with cv2.putText?

    OpenCV's built-in Hershey fonts, such as simplex, duplex, complex, and triplex.

  43. How is a BGR image converted to grayscale?

    Use cv2.cvtColor(image, cv2.COLOR_BGR2GRAY).

  44. What does grayscale preserve and remove?

    It preserves intensity information but removes color information.

  45. What is the purpose of blurring an image?

    To reduce noise and unwanted detail.

  46. What does the kernel size represent in a blur operation?

    The dimensions of the neighborhood used to compute a pixel's new value.

  47. What restriction applies to Gaussian blur kernel dimensions?

    The kernel dimensions must be odd numbers.

  48. What does the Canny edge detector identify?

    Edges or sharp intensity changes in an image.

  49. How can blurring affect Canny edge detection?

    It can reduce the number of detected edges by removing noise and fine detail.

  50. What does dilation do to an image's features?

    It expands or thickens foreground features such as detected edges.

  51. What does erosion do?

    It shrinks or thins foreground features.

  52. What does array slicing provide for images?

    A way to crop a selected region using pixel-coordinate ranges.

  53. What is translation in image processing?

    Shifting an image along the horizontal and vertical axes.

  54. What matrix is used for 2D image translation?

    A matrix of the form [10x01y]\begin{bmatrix}1&0&x\\0&1&y\end{bmatrix}[10​01​xy​].

  55. What is the effect of a negative translation xxx value?

    The image shifts left.

  56. What is the effect of a negative translation yyy value?

    The image shifts up.

  57. What does image rotation change?

    The orientation of the image around a chosen rotation point.

  58. What does cv2.getRotationMatrix2D require?

    A rotation center, an angle, and a scale value.

  59. What is the effect of a positive rotation angle in the described OpenCV example?

    The image rotates counterclockwise.

  60. Why can black triangular regions appear after rotation?

    Some output pixels fall outside the original image area and have no source content.

  61. What are the flip codes for cv2.flip?

    Zero flips vertically, one flips horizontally, and negative one flips both directions.

  62. What is a contour?

    A curve or boundary joining continuous points along the boundary of an object.

  63. Are contours and edges mathematically identical?

    No. They are different concepts, although contours can often be treated like object edges in practice.

  64. What does cv2.findContours return?

    A collection of contours and a hierarchy describing their relationships.

  65. What does RETR_LIST retrieve?

    All contours in the image without establishing a hierarchy.

  66. What does RETR_EXTERNAL retrieve?

    Only the outermost or external contours.

  67. What does RETR_TREE retrieve?

    All contours while preserving their full hierarchical relationships.

  68. What is the difference between CHAIN_APPROX_NONE and CHAIN_APPROX_SIMPLE?

    CHAIN_APPROX_NONE keeps all contour points; CHAIN_APPROX_SIMPLE compresses redundant points.

  69. How can blurring affect contour detection?

    It can substantially reduce the number of detected contours by removing noisy details.

  70. What is a color space?

    A system for representing pixel colors.

  71. What color ordering does OpenCV use when reading images by default?

    BGR: blue, green, and red.

  72. What does HSV stand for?

    Hue, saturation, and value.

  73. Why can displaying an OpenCV image with Matplotlib produce inverted colors?

    OpenCV reads the image as BGR, while Matplotlib interprets it as RGB.

  74. How can a BGR image be converted for correct RGB display?

    Use cv2.cvtColor(image, cv2.COLOR_BGR2RGB).

  75. Can a grayscale image be converted directly to HSV in the described workflow?

    No. Convert grayscale to BGR first, then convert BGR to HSV.

  76. What does cv2.split do?

    Separates a multichannel image into its individual color-channel arrays.

  77. How are individual color channels displayed by default?

    As grayscale intensity images.

  78. What do bright regions in a displayed color-channel image indicate?

    A high concentration or intensity of that channel's color.

  79. Why do individual color channels have shapes without an explicit channel count?

    Each isolated channel is a single-channel, effectively grayscale array.

  80. What does cv2.merge do?

    Combines separate channel arrays into a multichannel image.

  81. How can an individual color channel be displayed in its actual color?

    Merge that channel with blank arrays for the other two channels.

  82. What is the purpose of smoothing or blurring?

    To reduce noise caused by sensors, lighting, or image capture.

  83. How does averaging blur determine a center pixel?

    It replaces the center with the average of surrounding pixel intensities.

  84. How does Gaussian blur differ from averaging blur?

    Gaussian blur assigns different weights to neighboring pixels instead of treating them equally.

  85. How does median blur determine a pixel value?

    It uses the median of neighboring pixel intensities.

  86. How does bilateral filtering differ from traditional blurring?

    It smooths an image while preserving edges.

  87. What does bilateral filter diameter control?

    The size of the pixel neighborhood considered.

  88. What does the bilateral filter's color sigma affect?

    How much color variation among neighboring pixels influences the blur.

  89. What does the bilateral filter's space sigma affect?

    How far spatially from the center pixel neighboring pixels can influence the calculation.

  90. What do bitwise image operations operate on?

    Binary pixel values, where zero represents off and one represents on conceptually.

  91. What does bitwise AND return for two binary image shapes?

    Only their intersection.

  92. What does bitwise OR return?

    The union of the active regions in both images.

  93. What does bitwise XOR return?

    The non-intersecting active regions.

  94. What does bitwise NOT do?

    Inverts binary pixel values, changing white to black and black to white.

  95. What is masking used for?

    Focusing processing on selected regions of an image while excluding unwanted areas.

  96. What size must an OpenCV mask have relative to its source image?

    The mask must have the same dimensions as the source image.

  97. How is a masked image commonly produced?

    Apply bitwise AND between the source image and itself while supplying the mask.

  98. What does an image histogram show?

    The distribution of pixel intensities.

  99. What does the x-axis of a grayscale histogram represent?

    Pixel-intensity values or bins.

  100. What does the y-axis of a histogram represent?

    The number of pixels in each intensity bin.

  101. How can a histogram be limited to one region of an image?

    Provide a binary mask when calculating the histogram.

  102. What is thresholding?

    Converting an image into a binary representation based on pixel values.

  103. How does simple binary thresholding classify a pixel?

    Pixels above the threshold become the maximum value; pixels below it become zero.

  104. What does binary inverse thresholding do?

    It assigns the maximum value to pixels below the threshold and zero to pixels above it.

  105. What is a limitation of simple thresholding?

    The threshold value must be manually chosen.

  106. What is adaptive thresholding?

    Thresholding that computes a local threshold for different image neighborhoods.

  107. What does the block size represent in adaptive thresholding?

    The neighborhood size used to calculate the local threshold.

  108. How does mean adaptive thresholding determine the threshold?

    It uses the mean intensity of the local neighborhood, adjusted by a constant.

  109. How does Gaussian adaptive thresholding differ from mean adaptive thresholding?

    It uses a weighted neighborhood average, giving different weights to pixels.

  110. What is the Laplacian method used for?

    Computing image gradients to highlight edge-like regions.

  111. Why are absolute values used after computing some gradients?

    Gradient calculations can produce negative values, but image pixel values cannot be negative.

  112. In which directions does the Sobel method compute gradients?

    Along the x and y directions.

  113. How can Sobel x and Sobel y results be combined in the described workflow?

    Use a bitwise OR operation.

  114. Why is Canny often preferred over basic gradient methods?

    It is a multi-stage method that generally produces cleaner edge detections.

  115. What does a classifier do in face detection?

    Determines whether an image region is positive or negative for a target object, such as a face.

  116. What must a classifier generally be trained on?

    Many positive and negative example images.

  117. What are Haar cascades?

    Pre-trained cascade classifiers used to detect objects such as faces.

  118. What face detector is used in the described example?

    The frontal-face Haar cascade classifier.

  119. Why is a face image converted to grayscale before Haar-cascade detection?

    The classifier relies primarily on structural edges rather than color or skin tone.

  120. What does detectMultiScale return?

    Rectangular coordinates for detected objects or faces.

  121. What does the scale factor in detectMultiScale control?

    The image-scale reduction used when searching for objects at different sizes.

  122. What does minNeighbors control in Haar-cascade detection?

    How many neighboring detections are required before a region is accepted as an object.

  123. Why can Haar cascades detect false faces?

    They are sensitive to image noise and structures that resemble facial patterns.

  124. What is the general process for training OpenCV's built-in face recognizer?

    Collect face regions as features, assign numerical labels, train the recognizer, and save the trained model.

  125. Why are identity labels converted from names to numbers?

    Numerical labels provide a compact mapping between each identity and its training examples.

  126. What two lists form the face-recognition training data?

    A features list containing face image arrays and a labels list containing corresponding identities.

  127. Why is the trained face recognizer saved to a YAML file?

    So it can be loaded and used later without retraining.

  128. What does a face recognizer's prediction typically include?

    A predicted identity label and a confidence or distance value.

  129. Why can the built-in face recognizer produce unreliable results in the example?

    It was trained on a relatively small dataset and is less powerful than a deep learning model.

  130. Why are thousands of images per class often preferable for recognition models?

    More examples improve the model's ability to learn variations within each identity.

  131. Why are deep learning models often preferred for advanced computer vision?

    They can learn complex visual features and often outperform simpler recognition methods.

  132. What role does OpenCV play in the described deep learning workflow?

    It reads and resizes images before they are passed to the neural network.

  133. Why must training images usually have the same dimensions?

    Neural networks expect consistently shaped input tensors.

  134. Why are grayscale images used in the described Simpsons model?

    Color is not required for the example, so the images use one channel.

  135. What is normalization of image data?

    Scaling pixel values into a standard range, such as zero to one.

  136. What is one-hot encoding used for in the classification model?

    Converting integer class labels into binary class vectors.

  137. How is a dataset split into training and validation data in the example?

    About 80% is used for training and 20% for validation.

  138. What is image data augmentation?

    Generating varied training examples from existing images.

  139. What is the purpose of a GPU during deep learning training?

    To accelerate the computations required to train the neural network.

  140. What does a learning-rate schedule do?

    Adjusts the learning rate during training.

  141. What was the final application of the course?

    Building a deep computer vision model to classify characters from The Simpsons.

Card 1 of 141
Card 1 of 141

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent