15 selected computer vision interview questions grouped by seniority level. Use them to review fundamentals, practical trade-offs, and senior-level production reasoning.
1What is a discrete 2D convolution on an image, and how does it relate to kernels, filters, and cross-correlation?
Discrete 2D convolution on an image is a linear, spatial filtering operation where a matrix of weights (a kernel) slides across the input image. At each spatial location, it computes an element-wise product between the kernel weights and the overlapping local image patch (receptive field) and sums the results (often adding a bias term) to produce a single pixel value in the output feature map. In classical mathematics and signal processing, true convolution involves flipping (rotating by 180 degrees) the kernel horizontally and vertically before computing the sliding inner product: $(I * K)(i, j) = \sum_m \sum_n I(i - m, j - n) K(m, n)$. In contrast, cross-correlation computes the sliding dot product directly without flipping the kernel: $(I \star K)(i, j) = \sum_m \sum_n I(i + m, j + n) K(m, n)$. In deep learning frameworks like PyTorch and TensorFlow, the operation implemented under the name "convolution" is actually cross-correlation. Because kernel weights are learnable parameters optimized directly via backpropagation, the network simply learns the appropriately oriented weights, making the mathematical kernel flip computationally redundant during both training and inference.
2When would you use RGB, HSV, Lab, YCbCr, or grayscale representations in a vision pipeline?
Use the representation that preserves the cues needed by the task and matches the model's training preprocessing. RGB is common for learned models; many OpenCV APIs use BGR, so verify channel order rather than assuming a framework enforces it. HSV/HSL can make color thresholding convenient, but hue is unstable near zero saturation and is not generally invariant to illumination or white-balance changes. CIE Lab separates lightness from opponent color coordinates and is approximately perceptually uniform under specified viewing/reference-white assumptions; Euclidean Delta E 1976 is only an approximate perceptual difference measure. YCbCr separates luma Y' from color-difference channels and supports chroma subsampling in many image/video formats; coefficients, range, and transfer functions depend on the standard. Grayscale is useful when color is unnecessary, reducing raw channel storage from three channels to one at equal precision, but it does not guarantee a two-thirds reduction in total model compute. Preserve color when it carries label information, and verify scaling and conversion conventions.
import cv2
import numpy as np
# Sample image: saturated red under normal and shaded lighting
img_bgr = np.zeros((100, 100, 3), dtype=np.uint8)
img_bgr[:, :50] = [0, 0, 255] # Bright Red in BGR
img_bgr[:, 50:] = [0, 0, 120] # Shaded/Dark Red in BGR
# Convert to HSV (OpenCV H: 0-179, S: 0-255, V: 0-255)
img_hsv = cv2.cvtColor(img_bgr, cv2.COLOR_BGR2HSV)
# Red Hue wraps around 0/180; track red with single Hue range [0, 10] & high saturation
lower_red = np.array([0, 100, 50])
upper_red = np.array([10, 255, 255])
mask_hsv = cv2.inRange(img_hsv, lower_red, upper_red)
print("HSV segmented pixels:", np.count_nonzero(mask_hsv), "out of", mask_hsv.size)
3Why are channel-wise image normalization, per-image normalization, and consistent pixel scaling important in vision systems?
Use the pixel range, channel order, and normalization expected by the trained model consistently in training and inference. For 8-bit images, division by 255 maps values to [0,1], which rescales but does not center them at zero; mapping to [-1,1] centers the range, not necessarily the data mean. Images can also use other integer depths or floating-point physical units. Large unscaled values can make optimization poorly conditioned, but do not inevitably cause exploding gradients. Dataset channel standardization uses (x-mu_c)/sigma_c with training-set statistics or the pretrained model's prescribed constants; it gives zero mean and unit variance on the distribution used to estimate them, not every new image or dataset. Per-image z-score uses that image's mean and standard deviation with protection against near-zero variance; min-max scaling is a different operation. InstanceNorm is a neural-network layer that typically normalizes each sample and channel over spatial dimensions, not a synonym for all per-image preprocessing. Per-image normalization may reduce brightness/contrast variation but can remove useful absolute-intensity information, so validate it for the task.
import torch
import torchvision.transforms as T
from PIL import Image
import numpy as np
# Create a mock uint8 RGB image
raw_img = Image.fromarray(np.random.randint(0, 256, (224, 224, 3), dtype=np.uint8))
# Standard transform pipeline:
# 1. ToTensor scales uint8 [0, 255] -> float32 [0.0, 1.0] and permutes HWC -> CHW
# 2. Normalize standardizes per-channel using dataset mean and std
preprocess = T.Compose([
T.ToTensor(),
T.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
])
tensor_img = preprocess(raw_img)
print("Tensor shape:", tensor_img.shape)
print("Tensor dtype:", tensor_img.dtype)
print("Channel 0 min/max:", round(tensor_img[0].min().item(), 2), round(tensor_img[0].max().item(), 2))
4How do geometric and photometric augmentations encourage invariance, and how do you decide whether an augmentation preserves labels?
Geometric augmentations (such as rotation, translation, scaling, and flipping) alter the spatial coordinate mapping of pixels, while photometric augmentations (such as brightness, contrast, hue jitter, and blur) alter pixel intensity and color channels without modifying spatial coordinates. In classification, both categories expose the model to realistic variations, encouraging it to learn invariant representations where predictions remain stable despite changes in pose, viewpoint, or lighting conditions. In spatial prediction tasks (detection and segmentation), geometric transforms require matching transformations to ground-truth boxes or masks to preserve equivariance. Deciding whether an augmentation preserves labels requires evaluating domain semantics and physical priors. A transform is label-preserving if the resulting image remains a plausible instance of the original target class without altering its semantic identity. For example, horizontal flipping preserves identity for general objects (like cars or animals), but alters identity or invalidates characters in optical character recognition (OCR) and digit classification. Similarly, full 360-degree rotation is valid in histology or satellite imagery where no canonical orientation exists, but unnatural in autonomous driving where upside-down objects violate real-world physical constraints.
5What are nearest-neighbor, bilinear, bicubic, and area interpolation, and how can resizing introduce aliasing or blur?
Interpolation methods estimate pixel intensities at continuous coordinates when resampling onto a new discrete grid: - **Nearest-Neighbor:** Assigns the intensity of the closest discrete pixel. It is computationally $O(1)$ and preserves exact original values, but creates blocky artifacts when upsampling and severe jagged edges when downsampling. - **Bilinear Interpolation:** Computes a distance-weighted average of the $2 \times 2$ (4 nearest) neighbor pixels using linear interpolation along both axes, yielding smooth transitions with moderate blurring. - **Bicubic Interpolation:** Samples a $4 \times 4$ (16 nearest) neighborhood using cubic polynomial kernels. It captures local intensity gradients, producing sharper edges and smoother curves than bilinear, but can produce overshoot/ringing artifacts around sharp transitions. - **Area (Box) Interpolation:** Computes the fractional area overlap of target pixels projected onto source pixels and averages the underlying source intensities. It is especially effective for downsampling without moiré. **Aliasing vs. Blur Mechanics:** - **Aliasing** occurs during downsampling when high-frequency content exceeds the Nyquist frequency ($f_s / 2$) of the new sampling rate without sufficient low-pass filtering. High frequencies fold back into lower frequency bands, producing false patterns, moiré, and jagged edges. - **Blur** occurs when interpolation kernels act as low-pass smoothing filters that attenuate legitimate high frequencies (e.g., bilinear smoothing) or when high-frequency details are averaged out during downsampling.
6What real-world visual failure modes should a vision system be evaluated against, and how do they shift the input distribution?
Real-world visual failure modes fall into several broad categories: environmental conditions (low light, direct glare, rain, snow, fog), sensor and optical effects (motion blur, defocus blur, high ISO sensor noise, rolling shutter skew), compression and transmission degradation (JPEG blockiness, video bitrate throttling, downsampling), and semantic/spatial shifts (partial occlusion, truncation, out-of-distribution object poses). These failure modes shift the input distribution away from nominal training domains at multiple levels. At the pixel level, they alter luminance and chrominance histograms, destroy local contrast, reduce the signal-to-noise ratio (SNR), and introduce artificial high-frequency artifacts or blur kernels. At the structural and semantic level, they attenuate edge gradients, obscure key visual features, distort silhouettes, and hide critical diagnostic regions. When models trained on clean data encounter these shifted inputs, low-level convolutional or attention feature extractors fail to activate correctly, producing dropped detections, hallucinated false positives on noise patterns, and overconfident errors.
7How do classical descriptors such as HOG represent image structure, and what limitations do they have compared with learned CNN features?
The Histogram of Oriented Gradients (HOG) is a classical handcrafted feature descriptor designed to capture local object shape and appearance through the distribution of intensity gradient orientations. The HOG computation pipeline involves: (1) calculating horizontal and vertical image gradients (e.g., with 1D derivative filters [-1, 0, 1]) to obtain gradient magnitude and orientation; (2) dividing the image into small spatial regions called 'cells' (such as 8x8 pixels) and accumulating 1D histograms of gradient orientations weighted by gradient magnitude; (3) grouping adjacent cells into larger overlapping 'blocks' (such as 2x2 cells) and normalizing block feature vectors (using L2-norm or L1-sqrt) to achieve robustness against local illumination, contrast, and shadowing variations; and (4) concatenating normalized block vectors into a final 1D feature representation, historically paired with linear SVMs for pedestrian and object detection. Compared to learned Convolutional Neural Network (CNN) features, HOG has major limitations: First, HOG features are fixed and handcrafted, capturing only low-level local edge orientation statistics without the ability to learn task-specific hierarchical representations (such as textures, object parts, and semantic concepts). Second, HOG provides very limited geometric invariance: while block normalization handles monotonic illumination changes and small spatial shifts within cells, HOG is fragile under 3D out-of-plane rotations, significant scale variations, non-rigid pose articulations, and heavy background clutter. In contrast, CNNs learn multi-layer non-linear abstractions optimized end-to-end for the target objective.
8A dense 2D convolution takes three input channels and produces sixteen channels with a five-by-five kernel. How many trainable parameters does it have, and do stride or padding change the count?
For a dense convolution with groups = 1, each of the 16 output channels has a 5 × 5 filter spanning all 3 input channels. The weight count is therefore 16 × 3 × 5 × 5 = 1200. If the layer includes one bias per output channel, add 16 for a total of 1216 trainable parameters; with bias disabled, the total remains 1200. Stride and padding change where filters are applied and the output spatial dimensions, but not the number of shared filter weights or biases. Input image width and height likewise affect activation size and computation, not this parameter count. Grouped or depthwise convolution would use a different channel-connectivity formula, but the question specifies a dense convolution, so that reduction does not apply.
9Given image embedding vectors and a query vector, how would you return the k nearest results and scale retrieval as the collection grows?
For an exact baseline, compute similarity and keep top k in a bounded heap or use a partial selection. Normalize embeddings when implementing cosine by dot product. Benchmark an approximate index against exact recall, latency and memory before switching.
10What information can radar or lidar supply that is difficult to recover from a single camera image, and what integration costs come with it?
A single camera image gives rich appearance but has ambiguity about absolute depth and physical scale without additional assumptions. Lidar measures ranges to sampled surfaces and can provide useful 3D geometry. Radar can measure range and Doppler radial velocity, often remaining useful in poor lighting and some conditions that degrade optical sensors. These sensors do not provide perfect interchangeable truth: radar can have multipath and limited angular detail, while lidar has reflectivity, weather, and sampling limitations. Fusion requires accurate time synchronization, intrinsic/extrinsic calibration, coordinate transforms, association of observations, and uncertainty handling. It also adds hardware cost, power, bandwidth, compute, maintenance, and failure-detection requirements. I would measure the complementary improvement on difficult scenarios and define degraded behavior when one sensor is unavailable, rather than assuming adding sensors automatically increases reliability.
11What annotation noise modes occur in vision datasets, and how would you detect or mitigate them?
Computer vision datasets commonly exhibit four primary annotation noise modes: 1. **Categorical Label Noise:** An image or object is assigned the wrong class label (e.g., misclassifying a cat as a dog, or confusing subtle fine-grained classes). 2. **Missing Annotations (Omission Noise):** Valid foreground objects are left unannotated. In object detection, omitted targets are treated as background negatives, directly penalizing correct model detections during training. 3. **Bounding-Box / Keypoint Jitter (Localization Noise):** Inaccurate, loose, or shifted bounding box coordinates and landmark locations caused by human annotator inconsistency. 4. **Mask Boundary Ambiguity:** Inconsistent or coarse segmentation outlines along complex or blurry boundaries (e.g., hair, semi-transparent surfaces, motion blur). **Detection and Mitigation Strategies:** - **Loss Outlier Tracking & Confident Learning:** Tracking sample loss across training epochs identifies persistent high-loss outliers, which often indicate mislabeled or omitted instances. Algorithms like Confident Learning estimate noise distributions to prune or correct errors. - **Out-of-Fold (OOF) Prediction Discrepancies:** Training cross-validation models and comparing holdout predictions against ground truth highlights mislabeled images and missing bounding boxes. - **Inter-Annotator Agreement (IAA) & Adjudication:** Measuring metrics like Cohen's Kappa (classification) or mean Intersection-over-Union (localization) across multiple annotators flags low-agreement samples for consensus review. - **Robust Loss Formulations:** Using label smoothing, noise-tolerant classification losses, or robust IoU-based regression losses reduces sensitivity to jitter and mislabeling.
import torch
import torch.nn.functional as F
def find_label_noise_candidates(model, dataloader, device, top_k=50):
model.eval()
sample_losses = []
with torch.no_grad():
for batch_idx, (images, targets, sample_ids) in enumerate(dataloader):
images, targets = images.to(device), targets.to(device)
logits = model(images)
loss_per_sample = F.cross_entropy(logits, targets, reduction='none')
for sid, l, target, pred in zip(sample_ids, loss_per_sample.cpu(), targets.cpu(), logits.argmax(dim=-1).cpu()):
sample_losses.append({'id': sid, 'loss': l.item(), 'target': target.item(), 'pred': pred.item()})
sample_losses.sort(key=lambda x: x['loss'], reverse=True)
return sample_losses[:top_k]
12How does class imbalance affect image classification, detection, and dense prediction training?
Class imbalance affects optimization dynamics and loss landscapes across vision tasks: 1. **Image Classification:** When majority classes outnumber minority classes, empirical risk minimization causes parameter updates to be dominated by majority class gradients. The model learns the empirical class prior $P(Y)$ and biases its decision boundary against rare classes. This yields high overall top-1 accuracy while suffering from severe minority recall collapse. 2. **Object Detection:** - *Foreground-Background Imbalance:* In dense single-stage and anchor-based detectors, hundreds of thousands of candidate locations are evaluated per image, where >99% are background. Even if individual easy background anchors yield small losses, their vast aggregate gradient swamps the informative gradient signals from sparse foreground objects. - *Foreground Class Imbalance:* Common object categories appear orders of magnitude more frequently than rare categories, reducing the effective sample size and learning signal for rare classes. 3. **Dense Prediction (Segmentation):** Pixel-level imbalance is severe because large background and 'stuff' classes (e.g., road, sky) occupy millions of pixels, whereas small 'thing' classes (e.g., traffic signs, pedestrians) may occupy fewer than 0.1% of image pixels. Standard per-pixel cross-entropy loss is dominated by large-area classes, leading to the under-segmentation or complete disappearance of small, thin structures.
13How would you train a compact CNN to regress the center, dimensions and angle of a single oriented object box?
Use a lightweight backbone and a regression head with normalized center and positive dimensions. Represent angle periodically, define equivalent box conventions, and select by rotated IoU on held-out data within the parameter budget.
14How would you design a computer vision feature that helps triage visible hardware faults from customer-support photos?
Define the supported visible fault taxonomy and the triage action for each class, explicitly excluding hidden electrical/mechanical diagnoses a photo cannot establish. Guide customers to capture required angles with quality checks for blur, lighting and device identity. Build a consented dataset linked to technician-confirmed outcomes, splitting by device/customer/time to prevent near-duplicate leakage. Use detection/segmentation where localization helps, combine permitted product metadata and return calibrated confidence, evidence regions and an abstain/escalation path. No visible defect must not be interpreted as proof the hardware is safe or functional. Optimize for the costs of missed serious faults versus unnecessary escalation, evaluating per-class recall/precision, calibration and coverage across devices and photo conditions. Keep recommendations within approved support procedures, protect personal/background information and run a human-reviewed pilot. Monitor drift and disagreement, feeding verified outcomes back into labeling rather than treating model predictions as truth.
15How would you optimize a real-time vision pipeline when the detector is slower than the target frame rate?
When an object detector cannot sustain the target frame rate (e.g., running at 15-20 FPS on a 60 FPS video feed), a robust production architecture decouples detection from the real-time presentation loop using an asynchronous multi-threaded pipeline combining heavy detection with lightweight tracking. In this hybrid architecture, an ingestion thread captures video frames continuously. The heavy detector runs asynchronously as a 'keyframe detector' on a background worker thread. Meanwhile, a lightweight tracker (such as Lucas-Kanade optical flow or a correlation filter, optionally combined with Kalman prediction) runs synchronously on every frame at full 60 FPS, maintaining predicted object state between detector updates. ByteTrack/BoT-SORT are tracking-by-detection systems: without new detections they need an explicit prediction/visual-tracking policy, and track age, uncertainty, and new-object recall must be monitored. To handle lag and backpressure without introducing unbounded latency or stale frames, bounded ring buffers and latest-frame drop policies are used. When the detector finishes a frame T_0 at time T_curr, its output is stale. The pipeline performs coordinate realignment/back-projection: it associates the delayed detection results with the historical tracklet state at T_0, updates identities and missed tracks, and propagates the corrections forward to T_curr via the tracking motion vectors or Kalman filter predict steps.
import queue
import threading
frame_queue = queue.Queue(maxsize=1) # Drop stale frames, keep latest
det_result_queue = queue.Queue()
def detector_worker():
while True:
frame, frame_id, timestamp = frame_queue.get()
boxes, scores, classes = heavy_detector.infer(frame)
det_result_queue.put({'frame_id': frame_id, 'boxes': boxes, 'timestamp': timestamp})
def realtime_pipeline(video_stream):
tracker = FastTracker() # e.g. Optical flow or Kalman tracker
for frame, frame_id, timestamp in video_stream:
if frame_queue.empty():
frame_queue.put((frame, frame_id, timestamp))
if not det_result_queue.empty():
det_result = det_result_queue.get()
tracker.reconcile_and_correct(det_result, current_frame_id=frame_id)
active_tracks = tracker.update(frame)
display_or_downstream(frame, active_tracks)