MCPcopy Create free account
hub / github.com/SunOner/sunone_aimbot_2 / VirtualCameraCapture

Method VirtualCameraCapture

sunone_aimbot_2/capture/virtual_camera.cpp:350–443  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

348} // namespace
349
350VirtualCameraCapture::VirtualCameraCapture(
351 int w,
352 int h,
353 const std::string& cameraName,
354 int captureFps,
355 bool verbose)
356 : targetWidth_(w)
357 , targetHeight_(h)
358 , selectedCameraName_(cameraName)
359 , captureFps_(captureFps)
360 , verbose_(verbose)
361{
362 auto candidates = GetCameraCandidates(false);
363 if (candidates.empty())
364 candidates = GetCameraCandidates(true);
365
366 if (candidates.empty())
367 {
368 throw std::runtime_error("[VirtualCamera] No camera devices found");
369 }
370
371 const std::string requestedName = selectedCameraName_;
372 if (!requestedName.empty() && OtherTools::ToLowerAscii(OtherTools::TrimAscii(requestedName)) != "none")
373 {
374 int exact = FindExactNameMatch(candidates, requestedName);
375 int partial = (exact >= 0) ? exact : FindPartialNameMatch(candidates, requestedName);
376 if (exact < 0 && partial < 0)
377 {
378 std::cerr << "[VirtualCamera] Requested camera not found: " << requestedName
379 << ". Will use fallback search." << std::endl;
380 }
381 }
382
383 cap_ = std::make_unique<cv::VideoCapture>();
384 bool opened = false;
385
386 auto openByOrder = [&](const std::vector<CameraCandidate>& list) -> bool
387 {
388 const auto order = BuildOpenOrder(list, requestedName);
389 for (int idx : order)
390 {
391 if (idx < 0 || idx >= static_cast<int>(list.size()))
392 continue;
393
394 if (TryOpenCandidate(list[idx], *cap_, verbose_))
395 {
396 selectedCameraName_ = list[idx].displayName;
397 return true;
398 }
399 }
400 return false;
401 };
402
403 opened = openByOrder(candidates);
404 if (!opened)
405 {
406 candidates = GetCameraCandidates(true);
407 opened = openByOrder(candidates);

Callers

nothing calls this directly

Calls 12

GetCameraCandidatesFunction · 0.85
ToLowerAsciiFunction · 0.85
TrimAsciiFunction · 0.85
FindExactNameMatchFunction · 0.85
FindPartialNameMatchFunction · 0.85
BuildOpenOrderFunction · 0.85
TryOpenCandidateFunction · 0.85
evenFunction · 0.85
getMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected