|
12 | 12 | # get a test in here.
|
13 | 13 |
|
14 | 14 | import argparse
|
| 15 | +from enum import Enum |
| 16 | +import fcntl |
15 | 17 | import json
|
16 | 18 | import os
|
17 | 19 | import os.path
|
18 | 20 | import subprocess
|
19 | 21 | import sys
|
20 | 22 | from timeit import default_timer as timer
|
| 23 | +import v4l2 |
21 | 24 | import numpy as np
|
22 | 25 |
|
23 | 26 |
|
| 27 | +def get_platform(): |
| 28 | + platform = 'vc4' |
| 29 | + try: |
| 30 | + for num in range(5): |
| 31 | + device = '/dev/video' + str(num) |
| 32 | + if os.path.exists(device): |
| 33 | + with open(device, 'rb+', buffering=0) as fd: |
| 34 | + caps = v4l2.v4l2_capability() |
| 35 | + fcntl.ioctl(fd, v4l2.VIDIOC_QUERYCAP, caps) |
| 36 | + decoded = caps.card.decode('utf-8') |
| 37 | + if decoded == 'rp1-cfe': |
| 38 | + platform = 'pisp' |
| 39 | + break |
| 40 | + elif decoded == 'unicam': |
| 41 | + break |
| 42 | + except Exception: |
| 43 | + pass |
| 44 | + |
| 45 | + return platform |
| 46 | + |
| 47 | + |
24 | 48 | class TestFailure(Exception):
|
25 | 49 | def __init__(self, message):
|
26 | 50 | self.message = message
|
@@ -345,6 +369,7 @@ def check_timestamps(file, preamble):
|
345 | 369 |
|
346 | 370 |
|
347 | 371 | def test_vid(exe_dir, output_dir):
|
| 372 | + platform = get_platform() |
348 | 373 | executable = os.path.join(exe_dir, 'libcamera-vid')
|
349 | 374 | output_h264 = os.path.join(output_dir, 'test.h264')
|
350 | 375 | output_mjpeg = os.path.join(output_dir, 'test.mjpeg')
|
@@ -383,6 +408,10 @@ def test_vid(exe_dir, output_dir):
|
383 | 408 | check_time(time_taken, 2, 6, "test_vid: mjpeg test")
|
384 | 409 | check_size(output_mjpeg, 1024, "test_vid: mjpeg test")
|
385 | 410 |
|
| 411 | + if platform == 'pisp': |
| 412 | + print("skipping unsupported Pi 5 libcamera-vid tests") |
| 413 | + return |
| 414 | + |
386 | 415 | # "segment test". As above, write the output in single frame segements.
|
387 | 416 | print(" segment test")
|
388 | 417 | retcode, time_taken = run_executable([executable, '-t', '2000', '--codec', 'mjpeg',
|
|
0 commit comments