Feature size
Define the smallest defect, edge or code element that must be detected or measured reliably.
Knowledge · Fundamentals
The smallest relevant detail, the available installation space and the lens determine how many sensor pixels are useful for the inspection.

Decision
Resolution only matters once you know how many pixels you want across the smallest critical feature width, and whether lighting and motion keep those pixels usable.
Define the smallest defect, edge or code element that must be detected or measured reliably.
Rule of thumb: several pixels across that width, more for gauging, fewer for coarse presence. Always validate.
FOV must cover the part (plus margin) at the available WD. Lens + sensor size close that triangle.
Approach
Include depth of field, lens distortion and mounting angle in the calculation. Otherwise the geometry may work on paper but fail on the line.
Measure the real mount position and clearance, not the ideal catalogue WD.
Pick a sensor size and focal length that deliver FOV at that WD, with room for focus and depth.
Calculate pixels per millimetre and pixels across the relevant detail. Measurement usually requires more image information than presence detection.
Test representative parts under line conditions. Motion blur, reflections and limited depth of field can make the calculated pixel density unusable.
Limits
There is no universal megapixel table. Confirm the lens calculation with representative parts under production lighting and motion.
Sub-pixel gauging needs different margins than presence/absence.
Sometimes another lens or a second camera beats a more expensive sensor.
Thicker parts or tilt need DOF awareness, resolution alone will not fix it.

Send the smallest detail size, a field-of-view sketch and the available working distance. We can check the camera and lens combination.