Autocoder

Computer Vision Interview Questions and Answers

Last updated 2026-11-19

Computer vision interviews combine image-processing basics, CNN mechanics, task-specific metrics for detection and segmentation, and practical engineering. The calculations are small, such as one convolution, an IoU, or an average precision, and interviewers use them to check that you understand what a metric really measures.

The answers below include those calculations and code for non-maximum suppression and an OpenCV pipeline. Neural network fundamentals such as backpropagation and batch normalisation are on the deep learning page, and the surrounding modelling process is in how to crack the data science interview.

Typical roundsCV theory, metrics calculations, Python and OpenCV coding, project discussion
Core skillsCNNs, detection, segmentation, OpenCV, PyTorch
Questions here14 worked questions

What to revise

A way to answer a vision case

Ask about the camera and the environment first: lighting, angle, resolution and frame rate. Choose the task formulation (classification, detection or segmentation) from what the decision needs. Start from a pretrained backbone, fine-tune with augmentation that matches real variation, and measure with the task metric on data from the deployment setting. Mention latency and the device the model must run on.

Computer Vision Interview Questions and Answers: questions with worked answers

  1. 1

    Apply a Sobel x filter by hand to the patch [[1,2,3],[4,5,6],[7,8,9]].

    easy

    The Sobel x kernel is [[-1,0,1],[-2,0,2],[-1,0,1]]. Multiply elementwise and sum: row 1 gives -1 x 1 + 1 x 3 = 2, row 2 gives -2 x 4 + 2 x 6 = 4, row 3 gives -1 x 7 + 1 x 9 = 2. The total is 8, a positive horizontal gradient, since intensity rises left to right. Strictly, convolution flips the kernel while CNN libraries compute cross-correlation, which is what this is, and the difference does not matter because kernels are learned.

  2. 2

    Compute the output size of a convolution with a 224 x 224 input, a 7 x 7 kernel, stride 2 and padding 3.

    easy

    Output = floor((W - K + 2P) / S) + 1 = floor((224 - 7 + 6) / 2) + 1 = floor(111.5) + 1 = 112. This is the first layer of ResNet, which halves the spatial size. With "same" padding and stride 1 the size is unchanged, with padding (K - 1) / 2 for odd K. Pooling with a 2 x 2 window and stride 2 also halves each dimension.

  3. 3

    What is the receptive field of three stacked 3 x 3 convolutions, and why stack them instead of using one 7 x 7?

    medium

    With stride 1, each extra 3 x 3 layer adds 2 to the receptive field: 3, 5, 7. So three 3 x 3 layers see a 7 x 7 region. For C input and output channels the parameters are 3 x (3 x 3 x C x C) = 27 C^2 versus 49 C^2 for one 7 x 7 layer; for C = 64 that is 110,592 versus 200,704. Stacking also adds two more nonlinearities, so the network is both cheaper and more expressive. This idea comes from VGG.

  4. 4

    Why are convolutions used rather than fully connected layers on images?

    easy

    A 224 x 224 x 3 image has 150,528 values. One fully connected layer with 1,000 units would need about 150.5 million weights and would ignore the image structure. Convolutions share a small kernel across all positions, so parameters do not grow with image size, and they build in translation equivariance: a feature detector works wherever the pattern appears. Local connectivity matches the fact that nearby pixels are related.

  5. 5

    Compute IoU for boxes (0, 0, 4, 4) and (2, 2, 6, 6).

    easy

    Each box is 4 x 4 = 16. The intersection is from (2, 2) to (4, 4), an area of 2 x 2 = 4. The union is 16 + 16 - 4 = 28. IoU = 4 / 28 = 0.143. IoU is 1 for identical boxes and 0 for disjoint ones. A detection typically counts as correct when IoU with a ground-truth box of the same class is at least 0.5.

    python
    def iou(a, b):
        x1, y1 = max(a[0], b[0]), max(a[1], b[1])
        x2, y2 = min(a[2], b[2]), min(a[3], b[3])
        inter = max(0, x2 - x1) * max(0, y2 - y1)
        area = lambda r: (r[2] - r[0]) * (r[3] - r[1])
        return inter / (area(a) + area(b) - inter)
    
    print(iou((0, 0, 4, 4), (2, 2, 6, 6)))   # 0.1428...
  6. 6

    Implement non-maximum suppression.

    medium

    Sort boxes by score. Repeatedly take the best remaining box, keep it, and discard every remaining box whose IoU with it exceeds a threshold, such as 0.5. For three boxes where A (0.9) and B (0.8) overlap with IoU 0.7 and C (0.7) overlaps A with IoU 0.1, A is kept, B is suppressed and C is kept. Worst-case time is O(n^2). Soft-NMS lowers scores instead of deleting boxes, which helps crowded scenes.

    python
    import numpy as np
    
    def nms(boxes, scores, thr=0.5):
        order = list(np.argsort(scores)[::-1])
        keep = []
        while order:
            i = order.pop(0)
            keep.append(i)
            order = [j for j in order if iou(boxes[i], boxes[j]) < thr]
        return keep
  7. 7

    Compute average precision. Two ground-truth objects; detections in confidence order are TP, FP, TP.

    hard

    After detection 1: precision 1/1, recall 1/2. After 2: precision 1/2, recall 1/2. After 3: precision 2/3, recall 2/2. Take the precision envelope (the maximum precision at any recall at least r): 1.0 for recall up to 0.5, and 0.667 from 0.5 to 1.0. AP is the area: 0.5 x 1.0 + 0.5 x 0.667 = 0.833. mAP averages AP across classes; COCO also averages over IoU thresholds from 0.5 to 0.95 in steps of 0.05, which rewards tight localisation.

  8. 8

    One-stage versus two-stage detectors.

    medium

    Two-stage detectors such as Faster R-CNN first propose regions and then classify and refine each one. They are typically more accurate for small or crowded objects but slower. One-stage detectors such as YOLO and SSD predict boxes and classes directly in one pass on a dense grid, giving real-time speed. Newer one-stage models and transformer-based detectors such as DETR, which removes NMS using set prediction, have narrowed the accuracy gap. Choose by latency budget and the target hardware.

  9. 9

    Semantic versus instance segmentation, and Dice versus IoU.

    medium

    Semantic segmentation labels each pixel with a class and does not separate two objects of the same class; instance segmentation also separates individual objects. For predicted mask A with 100 pixels, ground truth B with 80 pixels and 60 overlapping, IoU = 60 / (100 + 80 - 60) = 0.5 and Dice = 2 x 60 / (100 + 80) = 0.667. They are related by Dice = 2 IoU / (1 + IoU). Dice loss is popular for class-imbalanced medical segmentation.

  10. 10

    What is focal loss and why is it used in detection?

    hard

    Dense detectors see a huge number of easy background boxes, which dominate the gradient. Focal loss is FL = -(1 - p_t)^gamma log(p_t). With gamma = 2, an easy example with p_t = 0.9 has its loss scaled by 0.1^2 = 0.01, while a hard one with p_t = 0.1 is scaled by 0.9^2 = 0.81. This shifts training to hard examples. It was introduced with RetinaNet to make a one-stage detector match two-stage accuracy.

  11. 11

    How do you train a good classifier with only a few thousand images?

    medium

    Start from a backbone pretrained on a large dataset, replace the head and train it first with the backbone frozen, then unfreeze and fine-tune with a smaller learning rate. Use augmentation that reflects real variation: flips (only if the label is flip-invariant), crops, colour jitter and blur. Check class balance, use a stratified validation split and watch for duplicate or near-duplicate images across splits, which inflate scores. Consider test-time augmentation and a self-supervised or foundation-model embedding with a simple classifier as a baseline.

  12. 12

    Compare Vision Transformers with CNNs.

    medium

    A ViT splits an image into patches (a 224 x 224 image with 16 x 16 patches gives 14 x 14 = 196 tokens plus a class token), embeds them and applies standard transformer layers. It has less built-in bias such as locality and translation equivariance, so it needs more data or strong pretraining to beat CNNs, but it scales very well with data. CNNs remain efficient on small data and on edge devices. Hybrids and hierarchical designs such as Swin combine local windows with attention.

  13. 13

    Show a basic OpenCV preprocessing and edge-detection pipeline, and mention the colour-order trap.

    easy

    OpenCV loads images as BGR, whereas most deep learning libraries and matplotlib expect RGB, so convert before feeding a model or plotting. For classic edge detection: convert to grey, blur to suppress noise, then apply Canny, which computes gradients, thins edges by non-maximum suppression and links them with two hysteresis thresholds. When resizing for a model, preserve the aspect ratio with padding if distortion would hurt.

    python
    import cv2
    img = cv2.imread('road.jpg')                  # BGR, uint8
    rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)    # for models and matplotlib
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    blur = cv2.GaussianBlur(gray, (5, 5), 1.4)
    edges = cv2.Canny(blur, 50, 150)

Frequently asked questions

Do computer vision interviews require OpenCV?

For applied roles, yes: reading images, colour spaces, resizing, contours and simple filters. For research-style roles, deep learning frameworks matter more.

Which datasets and tasks should I know?

ImageNet classification, COCO detection and segmentation and Pascal VOC are the common references for metrics and pretrained models.

How do I handle real-world deployment questions?

Talk about latency, model size, quantisation, the target hardware and monitoring for drift such as new lighting or camera positions.

How much deep learning theory is needed?

Enough to explain convolution, pooling, normalisation, residual connections, and how to fine-tune. The deep learning page covers the fundamentals.

Related guides

More in Role-wise Interview Questions by Job and Tech Stack

See all in this section