AI Engineering6 min read

Computer Vision Engineer

Builds production vision pipelines - Claude vision API, image preprocessing, OCR, classification, and structured extraction from images and documents.

computer visionimage processingClaude visionobject detectionOCR

The Computer Vision Engineer integrates vision capabilities into production applications - using Claude's vision API for image understanding, OCR, layout parsing, and structured data extraction, alongside traditional CV pipelines for preprocessing and routing. Vision inputs add significant cost and latency; this agent optimises both while maintaining accuracy.

Claude Vision API

import Anthropic from '@anthropic-ai/sdk';
import fs from 'fs';

const client = new Anthropic();

// Analyse a local image file
async function analyseImage(imagePath: string, prompt: string): Promise {
  const imageData = fs.readFileSync(imagePath);
  const base64Image = imageData.toString('base64');
  const mediaType = imagePath.endsWith('.png') ? 'image/png' : 'image/jpeg';

  const response = await client.messages.create({
    model: 'claude-sonnet-5',
    max_tokens: 1024,
    messages: [{
      role: 'user',
      content: [
        {
          type: 'image',
          source: { type: 'base64', media_type: mediaType, data: base64Image },
        },
        { type: 'text', text: prompt },
      ],
    }],
  });
  return response.content[0].type === 'text' ? response.content[0].text : '';
}

// Extract structured data from a receipt
const result = await analyseImage('./receipt.jpg',
  'Extract: vendor name, date, total amount, and line items as JSON. Respond with raw JSON only.'
);

Image Preprocessing for Cost & Accuracy

import sharp from 'sharp';

// Resize before sending to Claude - reduces tokens and cost
async function preprocessImage(inputPath: string, outputPath: string) {
  await sharp(inputPath)
    .resize(1568, 1568, {   // Claude's optimal resolution (1568×1568 max)
      fit: 'inside',
      withoutEnlargement: true,
    })
    .jpeg({ quality: 85 }) // JPEG is smaller than PNG for photos
    .toFile(outputPath);
}

// Cost estimates (Claude Sonnet 5):
// 200×200 image  ≈ 765 tokens  ≈ $0.002
// 1000×1000 image ≈ 1334 tokens ≈ $0.004
// 2000×2000 image ≈ 5332 tokens ≈ $0.016
// Resize to 1000px max side for most use cases - 3× cost saving vs 2000px

Routing Architecture

Not every image needs Claude. Route by complexity to minimise cost:

  • Simple classification (damaged/not damaged, face detected/not) → use a small fine-tuned CNN (ONNX Runtime). Claude for edge cases only.
  • OCR on standard forms → try open-source Tesseract or AWS Textract first. Claude for handwriting or unusual layouts.
  • Layout understanding / reasoning (invoices, complex tables, mixed content) → Claude is best-in-class; cost is justified.
  • Image description / captioning → Claude for high quality; smaller models for bulk/low-priority pipelines.

Explore all agents

Browse the full library of specialized AI agents.