Measure simultaneous camera pull

This commit is contained in:
Meta Vens 2026-05-21 22:18:34 +01:00
commit 474df468e6
5 changed files with 242 additions and 10 deletions

View file

@ -291,3 +291,47 @@ Raven host check:
Conclusion: the same Kiyo Pro/cable also falls back to high-speed on Raven.
That makes the stock cable or the Kiyo Pro's own SuperSpeed lane the stronger
suspect than the receiver workstation's rear ports.
## 2026-05-21: Simultaneous Local Camera Pull
The first simultaneous pull used one process for KS/UVC cameras and the raw
PS3 Eye probe beside it. Current local visibility is only three camera devices:
- Leap Motion Controller / LeapUVC camera interface;
- Razer Kiyo Pro camera interface;
- one PS3 Eye raw libusbk camera interface.
The regular Kiyo and second PS3 Eye were not present on this rig during this
run.
Probe changes:
- `ks_camera_cadence.exe --multi-ks-baseline` starts all matched KS camera
streams from one process with one start gate.
- The raw PS3 Eye probe was launched at the same time as the KS multi-stream
harness.
- KS matching now limits Kiyo/Leap profiles to `MI_00` so media/audio
interfaces do not masquerade as cameras.
Simultaneous results with PS3 Eye at `640x480@60`:
| Device | Mode | Delivered FPS |
| --- | --- | ---: |
| LeapUVC | 640x240 YUY2 | 40.12 |
| Kiyo Pro | 1920x1080 MJPG | 24.99 |
| PS3 Eye | 640x480 Bayer | 56.06 |
Simultaneous results with PS3 Eye at `320x240@187`:
| Device | Mode | Delivered FPS |
| --- | --- | ---: |
| LeapUVC | 640x240 YUY2 | 81.10 |
| Kiyo Pro | 1920x1080 MJPG | 25.33 |
| PS3 Eye | 320x240 Bayer | 185.74 |
Conclusion: the current local topology can pull the three visible cameras
concurrently, but Leap cadence collapses under shared load compared with its
solo/KS-only result. The PS3 Eye's 320x240 mode is much less damaging than its
640x480 mode, but still drags Leap below its ~110 fps warm steady-state. Before
claiming six-camera viability, plug in the missing regular Kiyo and second PS3
Eye and split high-rate cameras across controllers/hubs deliberately.

View file

@ -7,9 +7,12 @@
#include <winternl.h>
#include <chrono>
#include <atomic>
#include <algorithm>
#include <cstring>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <string>
#include <vector>
#include <thread>
@ -93,6 +96,17 @@ struct PinCandidate
GUID subtype{};
};
struct MultiKsProfile
{
const char* pathNeedle = "";
const char* label = "";
LONG width = 0;
LONG height = 0;
const char* subtype = "";
double minFps = 0.0;
bool forceFastExposure = false;
};
enum class ControlSet
{
Camera,
@ -1209,7 +1223,7 @@ std::vector<PinCandidate> inspectPins(HANDLE filter)
return candidates;
}
bool measureCandidate(HANDLE filter, const PinCandidate& candidate, int queueDepth)
bool measureCandidate(HANDLE filter, const PinCandidate& candidate, int queueDepth, std::atomic<bool>* startGate = nullptr)
{
const ULONG connectBytes = sizeof(KSPIN_CONNECT) + static_cast<ULONG>(candidate.format.size());
std::vector<std::uint8_t> connectStorage(connectBytes);
@ -1338,6 +1352,14 @@ bool measureCandidate(HANDLE filter, const PinCandidate& candidate, int queueDep
return false;
};
if (startGate)
{
while (!startGate->load(std::memory_order_acquire))
{
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
}
const auto start = std::chrono::steady_clock::now();
const auto measureStart = start + std::chrono::seconds(2);
const auto deadline = measureStart + std::chrono::seconds(5);
@ -1482,6 +1504,154 @@ bool measureScenario(HANDLE filter, const PinCandidate& candidate, const Control
std::this_thread::sleep_for(std::chrono::milliseconds(100));
return measured;
}
std::string lowercase(std::string value)
{
std::transform(value.begin(), value.end(), value.begin(), [](unsigned char c) {
return static_cast<char>(std::tolower(c));
});
return value;
}
const PinCandidate* findCandidate(
const std::vector<PinCandidate>& candidates,
LONG width,
LONG height,
const char* subtype,
double minFps)
{
for (const auto& candidate : candidates)
{
const double fps = candidate.interval100ns > 0
? 10000000.0 / static_cast<double>(candidate.interval100ns)
: 0.0;
if (candidate.width == width &&
candidate.height == height &&
fps >= minFps &&
fourccOrGuid(candidate.subtype) == subtype)
{
return &candidate;
}
}
return nullptr;
}
int runMultiKsBaseline()
{
const MultiKsProfile profiles[] = {
{"vid_f182&pid_0003&mi_00", "LeapUVC full stereo IR", 640, 240, "YUY2", 100.0, false},
{"vid_1532&pid_0e05&mi_00", "Kiyo Pro RGB", 1920, 1080, "MJPG", 25.0, false},
{"vid_1532&pid_0e03&mi_00", "Kiyo RGB", 1920, 1080, "MJPG", 25.0, true},
};
struct Worker
{
std::string path;
MultiKsProfile profile;
std::thread thread;
bool matched = false;
bool measured = false;
};
const auto paths = enumerateCapturePaths();
std::vector<Worker> workers;
for (const auto& profile : profiles)
{
for (const auto& path : paths)
{
if (lowercase(path).find(profile.pathNeedle) == std::string::npos)
{
continue;
}
Worker worker{};
worker.path = path;
worker.profile = profile;
worker.matched = true;
workers.push_back(std::move(worker));
}
}
std::printf("multi-ks capture interfaces: %zu selected from %zu\n", workers.size(), paths.size());
if (workers.empty())
{
return 5;
}
std::atomic<bool> startGate(false);
for (auto& worker : workers)
{
worker.thread = std::thread([&startGate, &worker]() {
std::printf("multi-ks preparing: %s path=%s\n", worker.profile.label, worker.path.c_str());
Handle filter(CreateFileA(
worker.path.c_str(),
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
nullptr,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
nullptr));
if (!filter)
{
std::printf("multi-ks open failed: %s error=%s\n", worker.profile.label, lastErrorText().c_str());
return;
}
auto candidates = inspectPins(filter.value);
const PinCandidate* candidate = findCandidate(
candidates,
worker.profile.width,
worker.profile.height,
worker.profile.subtype,
worker.profile.minFps);
if (!candidate)
{
std::printf(
"multi-ks target mode unavailable: %s %ldx%ld %s minFps=%.2f\n",
worker.profile.label,
worker.profile.width,
worker.profile.height,
worker.profile.subtype,
worker.profile.minFps);
return;
}
if (worker.profile.forceFastExposure)
{
setCameraControl(filter.value, KSPROPERTY_CAMERACONTROL_EXPOSURE, -9, KSPROPERTY_CAMERACONTROL_FLAGS_MANUAL);
setVideoProcAmp(filter.value, KSPROPERTY_VIDEOPROCAMP_GAIN, 0, KSPROPERTY_VIDEOPROCAMP_FLAGS_MANUAL);
}
std::printf(
"multi-ks ready: %s pin=%lu %ldx%ld %s target=%.2f\n",
worker.profile.label,
static_cast<unsigned long>(candidate->pinId),
candidate->width,
candidate->height,
fourccOrGuid(candidate->subtype).c_str(),
candidate->interval100ns > 0 ? 10000000.0 / static_cast<double>(candidate->interval100ns) : 0.0);
worker.measured = measureCandidate(filter.value, *candidate, 8, &startGate);
});
}
std::this_thread::sleep_for(std::chrono::seconds(2));
std::printf("multi-ks starting %zu streams\n", workers.size());
startGate.store(true, std::memory_order_release);
bool allMeasured = true;
for (auto& worker : workers)
{
if (worker.thread.joinable())
{
worker.thread.join();
}
allMeasured = allMeasured && worker.measured;
}
std::printf("multi-ks complete: measured=%s\n", allMeasured ? "yes" : "partial");
return allMeasured ? 0 : 6;
}
}
int main(int argc, char** argv)
@ -1505,6 +1675,10 @@ int main(int argc, char** argv)
printUsbVideoDescriptors(static_cast<USHORT>(vendorId), static_cast<USHORT>(productId));
return 0;
}
if (targetVid == "--multi-ks-baseline")
{
return runMultiKsBaseline();
}
bool controlsOnly = false;
bool baselineOnly = false;

View file

@ -53,9 +53,15 @@ Get-Content .\state\evidence.jsonl -Tail 8
`UsbHighSpeed` rather than `UsbSuperSpeed`; measured cadence remains about
25 fps across all tested formats. Verify cable/port SuperSpeed before poking
writable vendor selectors.
- First simultaneous local pull only saw LeapUVC, Kiyo Pro, and one PS3 Eye.
The KS multi-stream harness and raw PS3 Eye probe can pull all three at once,
but Leap drops hard under shared USB load: 40.12 fps when the PS3 Eye runs
640x480@60, and 81.10 fps when the PS3 Eye runs 320x240@187. The regular
Kiyo and second PS3 Eye were absent, so six-camera viability is not proven.
## Immediate Re-entry Instruction
Read `docs/native-rebuild-plan.md`, then make the smallest direct-driver or
runtime-buffer cut that improves the live Mimir machine. Do not restore deleted
script infrastructure because a stale doc once missed it.
Move the raw PS3 Eye cadence probe into `native/probes` or cut the first real
runtime capture driver, then rerun simultaneous pulls with the regular Kiyo and
second PS3 Eye present. Do not restore deleted script infrastructure because a
stale doc once missed it.

View file

@ -13,3 +13,4 @@
{"ts":"2026-05-21T23:10:00+00:00","type":"verification","status":"ok","note":"After moving Kiyo Pro to a motherboard USB3 port, the descriptor path changed to root_hub30 port 7 with bcdUSB 0x0320 and 720p/1080p YUY2/MJPG/H264/NV12 all advertised at 60 fps. Windows still reports USB speed enum 2 (UsbHighSpeed, not UsbSuperSpeed). Baseline cadence remains locked around 25 fps across all tested 720p/1080p formats: YUY2 24.96/24.98, MJPG 25.20/25.03, H264 25.19/25.01, NV12 25.07/25.16. Verify a true SuperSpeed cable/port path before blaming unknown vendor selectors."}
{"ts":"2026-05-21T23:25:00+00:00","type":"verification","status":"ok","note":"Kiyo Pro moved to a second motherboard USB3 port: composite device is now Port_#0008.Hub_#0003 on the same AMD ROOT_HUB30. The device descriptor remains bcdUSB 0x0320 but hub IOCTL reports negotiated speed UsbHighSpeed(2), not UsbSuperSpeed(3). Cadence was not rerun because this is the same high-speed fallback state; next physical test is a known-good USB3 data cable or a known-good SuperSpeed device on the same ports."}
{"ts":"2026-05-22T00:05:00+00:00","type":"verification","status":"ok","note":"Kiyo Pro moved to neighbor sender machine Raven. PnP reports camera/media/composite/microphone interfaces present. Descriptor-only probe reports VID_1532 PID_0E05 on Raven USB3 root hub port 6 with bcdUSB 0x0320 but negotiated speed UsbHighSpeed(2), not UsbSuperSpeed(3); Raven hub inventory reports zero SuperSpeed devices. Same cable/camera failing SuperSpeed on two machines makes the stock cable or Kiyo Pro SuperSpeed lane the stronger suspect."}
{"ts":"2026-05-22T00:30:00+00:00","type":"verification","status":"partial","note":"Simultaneous local camera pull found only three camera devices visible: LeapUVC, Kiyo Pro, and one PS3 Eye; regular Kiyo and the second PS3 Eye were absent. KS multi harness plus raw PS3 Eye probe pulled Leap 640x240 YUY2, Kiyo Pro 1080p MJPG, and PS3 Eye concurrently. With PS3 Eye 640x480@60: Leap 40.12 fps, Kiyo Pro 24.99 fps, PS3 Eye 56.06 fps. With PS3 Eye 320x240@187: Leap 81.10 fps, Kiyo Pro 25.33 fps, PS3 Eye 185.74 fps. Leap loses cadence under shared USB load; split high-rate cameras across controllers before claiming six-camera viability."}

View file

@ -98,10 +98,17 @@ current_status:
motherboard USB3 port changed the path to `root_hub30`, `bcdUSB=0x0320`,
and exposed 720p/1080p YUY2/MJPG/H264/NV12 at 60 fps, but Windows still
reports `UsbHighSpeed` rather than `UsbSuperSpeed`, and baseline cadence is
still about 25 fps across every tested format.
still about 25 fps across every tested format. The first simultaneous local
camera pull only had three visible devices: LeapUVC, Kiyo Pro, and one PS3
Eye. The KS multi-stream harness plus raw PS3 Eye probe pulled all three at
once, but Leap cadence collapsed under shared load: with PS3 Eye at
640x480@60 the set delivered Leap 40.12 fps, Kiyo Pro 24.99 fps, and PS3
Eye 56.06 fps; with PS3 Eye at 320x240@187 it delivered Leap 81.10 fps,
Kiyo Pro 25.33 fps, and PS3 Eye 185.74 fps.
next_action: >
Turn the warmed, queued Leap KS path into an `IMimirVideoCaptureDriver`,
preserve direct control hooks for timing-camera state, and decide whether
Kiyo Pro reaches 60 fps after confirming a true `UsbSuperSpeed` cable/port
path; if it remains locked at 25 fps there, inspect explicit frame-interval
negotiation or vendor selectors.
Move the raw PS3 Eye probe into the repo or replace it with the first
runtime capture driver, then rerun simultaneous pulls with the missing
regular Kiyo and second PS3 Eye present. Keep high-rate cameras split
across controllers/hubs deliberately, because current shared-load tests
show Leap is no longer a stable timing authority under the present USB
topology.