pupilometer/tests/test_segmentation.py
Tempest 1f8da0017c feat: Integrate pupil segmentation infrastructure
This commit introduces the necessary infrastructure for integrating pupil segmentation into the mono camera pipelines.

Key changes include:
- Modifying `gstreamer_pipeline.py` to add a tee element to split mono camera streams, creating a dedicated branch for segmentation output with a placeholder `videoconvert` element and `appsink`. This also includes new callbacks and data structures to handle the segmentation frames.
- Adding a new Flask route `/segmentation_feed/<int:stream_id>` to `app.py` to serve the segmentation video stream to the frontend.
- Updating `index.html` to display the new segmentation feed and implementing cache-busting for all video streams.
- Introducing `test_segmentation.py` to verify the functionality of the new segmentation feed.
- Refine existing UI and visual tests by updating locators and fixing indentation errors to accommodate the new segmentation feature and maintain test stability.
2025-12-11 17:52:08 +07:00

19 lines
669 B
Python

import cv2
import time
import pytest
from playwright.sync_api import Page, expect
def test_segmentation_output(page: Page):
page.goto("http://localhost:5000/")
# Check for the presence of a segmentation feed for the first mono camera (stream 1)
segmentation_feed = page.locator("#segmentation-feed-1")
expect(segmentation_feed).to_be_visible()
# Verify that the segmentation feed is updating
initial_src = segmentation_feed.get_attribute("src")
page.reload()
page.wait_for_selector("#segmentation-feed-1")
new_src = segmentation_feed.get_attribute("src")
assert initial_src != new_src, "Segmentation feed is not updating"