Update tests, including picamera
This commit is contained in:
parent
1ea308a42d
commit
5be8b0ecab
3 changed files with 15 additions and 20 deletions
Binary file not shown.
|
|
@ -8,7 +8,6 @@ See repository root for licensing information.
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import io
|
import io
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
@ -338,11 +337,9 @@ class BaseCamera(OFMThing):
|
||||||
|
|
||||||
# This runs as an async task, which we wait to complete
|
# This runs as an async task, which we wait to complete
|
||||||
try:
|
try:
|
||||||
total_time, frames, samples = (
|
total_time, frames, samples = self._thing_server_interface.call_async_task(
|
||||||
self._thing_server_interface.call_async_task(
|
self._monitor_framerate,
|
||||||
self._monitor_framerate,
|
duration,
|
||||||
duration,
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
|
@ -359,6 +356,13 @@ class BaseCamera(OFMThing):
|
||||||
"samples": samples,
|
"samples": samples,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.logger.info(
|
||||||
|
("Framerate monitor results: duration=%.2fs, frames=%d, avg_fps=%.2f"),
|
||||||
|
total_time,
|
||||||
|
frames,
|
||||||
|
avg_fps,
|
||||||
|
)
|
||||||
|
|
||||||
with open(log_path, "w") as f:
|
with open(log_path, "w") as f:
|
||||||
json.dump(data, f, indent=2)
|
json.dump(data, f, indent=2)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
"""Test data collection from the Raspberry Picamera."""
|
"""Test data collection from the Raspberry Picamera."""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import time
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
@ -35,19 +34,12 @@ def test_jpeg_and_array(picamera_client):
|
||||||
assert array_main.shape[1::-1] == jpeg_capture.size
|
assert array_main.shape[1::-1] == jpeg_capture.size
|
||||||
|
|
||||||
|
|
||||||
def test_record_framerate_async(picamera_client):
|
def test_record_framerate(picamera_client):
|
||||||
"""Check that asynchronous framerate monitoring creates a valid JSON log."""
|
"""Check that framerate monitoring creates a valid JSON log with good data."""
|
||||||
returned_dir = Path(picamera_client.record_framerate_async(duration=1.0))
|
log_file = Path(picamera_client.record_framerate(duration=1.0))
|
||||||
|
|
||||||
# Wait slightly longer than recording duration for async task completion
|
assert log_file.exists()
|
||||||
time.sleep(1.5)
|
assert log_file.is_file()
|
||||||
|
|
||||||
log_files = list(returned_dir.glob("framerate_*.json"))
|
|
||||||
|
|
||||||
# Ensure exactly one log file was created
|
|
||||||
assert len(log_files) == 1
|
|
||||||
|
|
||||||
log_file = log_files[0]
|
|
||||||
|
|
||||||
# Ensure file is not empty
|
# Ensure file is not empty
|
||||||
assert log_file.stat().st_size > 0
|
assert log_file.stat().st_size > 0
|
||||||
|
|
@ -74,7 +66,6 @@ def test_record_framerate_async(picamera_client):
|
||||||
|
|
||||||
sample = samples[0]
|
sample = samples[0]
|
||||||
|
|
||||||
# Each sample row equivalent
|
|
||||||
assert "timestamp" in sample
|
assert "timestamp" in sample
|
||||||
assert "frame_count" in sample
|
assert "frame_count" in sample
|
||||||
assert "frame_size_bytes" in sample
|
assert "frame_size_bytes" in sample
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue