Skip to content

External server

Live Tracking > Save results > Measure > External server

TraCell can hand part of the work to another program: it sends the crops of the tracked cells in batches and takes back numbers, which become columns of the session's tables. The other program can run on the same computer or on another one, and can compute anything: a measurement, a classifier, a neural network.

The server is yours

TraCell only sends the crops and reads the answer. Writing the server, running it, keeping it reachable and what it computes are your responsibility. TraCell ships an example to start from.

How it works

  1. TraCell cuts a small picture (crop) of every tracked cell in every frame of a partition. Pixels outside the tracked cell contour are black; pixels inside keep their original ROI/scale values. This is independent of which crop files you choose to save.
  2. It posts them to your address in batches (64 crops per request unless you change it), one request after the other.
  3. Your server answers each request with one or more values per crop.
  4. Each output becomes a column in tables/partition_0001.csv of the session folder, beside the cell's position and size. cells.csv gets each cell's mean of it (<output>_mean), as the Dashboard shows.

This runs behind the session: the camera never waits for the server. Connection failures, timeouts and temporary HTTP errors (408, 429 and 5xx) are retried, up to three times in all. Other HTTP errors, such as 400 (invalid request) or 404 (wrong address), fail immediately and log the server's explanation. If a request still fails, that partition gets no measured columns, and the log says so; after two partitions in a row without an answer the server is left out for the rest of the session, so a server that is down does not hold everything up.

Settings

Setting Meaning
Address Where the crops are posted, for example http://127.0.0.1:8000 or http://192.168.1.20:8000/cells
Crops per request The batch size. Smaller batches answer sooner; larger ones mean fewer requests
Timeout Seconds to wait for the answer to one batch

The crop size is set beside Cell crops in the same group.

What is sent and what must come back

One request per batch, compressed with deflate (Content-Encoding: deflate): a JSON header, then the pixels of all crops as bytes, row after row, gray values from 0 to 255. This is the binary-data form of the Open Inference Protocol; a batch of 64 crops of 32 px is about 36 KB, where the same pixels written as JSON numbers would be about 320 KB.

POST <address>
Content-Encoding: deflate
Inference-Header-Content-Length: <length of the JSON header>

{"inputs": [{"name": "crops", "shape": [64, 32, 32], "datatype": "UINT8",
             "parameters": {"binary_data_size": 65536}}]}<65536 bytes of pixels>

shape is (crops, height, width). When the experiment is calibrated (Edit > Experiment, the pixel size), the header has a second input with the size of one crop pixel in micrometers, after the scale, so your server can answer in micrometers without a number typed twice; without a calibration it is not there:

{"name": "um_per_px", "shape": [1], "datatype": "FP32", "data": [0.6757]}

Reading a request, in Python:

body = zlib.decompress(body)
length = int(headers["Inference-Header-Content-Length"])
inputs = json.loads(body[:length])["inputs"]
crops = np.frombuffer(body[length:], np.uint8).reshape(inputs[0]["shape"])

The answer:

{"outputs": [{"name": "brightness", "shape": [64], "data": [101.5, 98.2, ...]},
             {"name": "class", "shape": [64, 2], "data": [0.9, 0.1, 0.2, 0.8, ...]}]}

One value per crop gives a column with the output's name (brightness). Several values per crop give numbered columns (class_0, class_1). The order of the crops must be kept. An output may not have the name of a column the table already has (partition, particle_id, frame, x, y, area, perimeter, eq_diameter, circularity, complete, time_s, and when calibrated x_um, y_um, perimeter_um, eq_diameter_um, area_um2): TraCell refuses such an answer. A prefix of your own (dn_area) avoids that.

A server in 50 lines

Help > Example Scripts opens a folder with crop_server.py: a complete server that needs only Python and NumPy. Copy it, put your processing into its process function and run it:

python crop_server.py

It then listens on http://127.0.0.1:8000, which is the address TraCell starts with.

If you already run an inference server

The request and the answer have the form of the Open Inference Protocol (KServe v2), which Triton, KServe, TorchServe and MLServer speak. Give the model's full address, for example http://server:8000/v2/models/cells/infer. This was not tested against such a server.

How fast

Measured on 16 October 2026 with a lab server on another computer, reached through a VPN (Tailscale) over home Wi-Fi: a classifier and a segmentation of each crop on a laptop GPU, crops of 32 px in batches of 64.

Per batch of 64 crops Pixels as JSON numbers (before) Compressed bytes (now)
Size of the request 320 KB 30 to 36 KB
Upload about 140 ms about 33 ms (median; slowest 130 ms)
Upload and the server's work about 160 ms about 56 ms

That is more than 1,000 crops a second, and the answers were identical value for value. A 5,000-frame session on a virtual camera (a side-view recording, 10 partitions of 500 frames) had every partition measured: the measurement ran behind the session and never held the camera up.

Limits

  • Tested against a small test server, the shipped example and one lab server on another computer.
  • The measured columns are in the saved tables. The Live Dashboard does not show them.