HoviTron Video Pipeline
Data Structures | Public Member Functions
DynamicInputProvider Class Reference
Inheritance diagram for DynamicInputProvider:
InputProvider

Public Member Functions

 DynamicInputProvider (const std::string &libraryPath, VulkanWrapper &vkw)
 
std::vector< StreamParametersenumerateStreamsParameters () const override
 
std::vector< StreamImageenumerateStreamImages (uint32_t streamIndex, bool depth) const override
 
void acquireStreamsFrames (const Extrinsics &targetViewExtrinsics, std::span< StreamFrameInfo > outFrameInfos) override
 
void releaseStreamsFrames () override
 
virtual std::vector< StreamParametersenumerateStreamsParameters () const =0
 
virtual std::vector< StreamImageenumerateStreamImages (uint32_t streamIndex, bool depth) const =0
 
virtual void acquireStreamsFrames (const Extrinsics &targetViewExtrinsics, std::span< StreamFrameInfo > outFrameInfos)=0
 
virtual void releaseStreamsFrames ()=0
 

Additional Inherited Members

- Public Types inherited from InputProvider
enum class  ProjectionType { PROJECTION_INVALID , PROJECTION_PERSPECTIVE , PROJECTION_EQUIRECTANGULAR }
 
using Intrinsics = std::variant< PerspectiveIntrinsics, EquirectangularIntrinsics >
 Union of possible intrinsics types data.
 

Detailed Description

Definition at line 25 of file DynamicInputProvider.h.

Constructor & Destructor Documentation

◆ DynamicInputProvider()

DynamicInputProvider::DynamicInputProvider ( const std::string &  libraryPath,
VulkanWrapper vkw 
)

Definition at line 47 of file DynamicInputProvider.cpp.

47 : vkw(vkw)
48{
49 loadLibrary(libraryPath);
50 init();
51}

◆ ~DynamicInputProvider()

DynamicInputProvider::~DynamicInputProvider ( )

Definition at line 517 of file DynamicInputProvider.cpp.

517 {
518 hvtCheck(hvt.stopStreaming, context);
519 hvtCheck(hvt.destroyStreamingContext, context);
520}

Member Function Documentation

◆ acquireStreamsFrames()

void DynamicInputProvider::acquireStreamsFrames ( const Extrinsics targetViewExtrinsics,
std::span< StreamFrameInfo outFrameInfos 
)
overridevirtual

Implements InputProvider.

Definition at line 427 of file DynamicInputProvider.cpp.

427 {
428 auto extrinsicsToHvt = [](Extrinsics ex){
429 return HvtExtrinsics{
430 .position = HvtPosition{
431 .x = ex.position.x,
432 .y = ex.position.y,
433 .z = ex.position.z
434 },
435 .rotation = HvtRotation{
436 .yaw = ex.rotation.x,
437 .pitch = ex.rotation.y,
438 .roll = ex.rotation.z
439 }
440 };
441 };
442
443 // Take next sync slot
444 currentSyncSlot = (currentSyncSlot+1) % syncInfos.size();
445 auto& currentSync = syncInfos.at(currentSyncSlot);
446
447 // Get stream frame info from the module
448 std::vector<HvtStreamFrameInfo> hvtFrameInfos(outFrameInfos.size());
450 .viewerExtrinsics = extrinsicsToHvt(targetViewExtrinsics),
451 .frameInfoCount = (uint32_t)hvtFrameInfos.size(),
452 .pStreamFrameInfos = hvtFrameInfos.data(),
453 .signalSemaphore = currentSync.acquireHvt
454 };
455 hvtCheck(hvt.acquireStreamsFrames, context, &ainfos);
456
457
458 //Fill the output frames info
459 for(int i = 0; i < outFrameInfos.size(); i++) {
460 const auto& hfi = hvtFrameInfos.at(i);
461 auto& fi = outFrameInfos[i];
462
463 auto ext = hfi.extrinsics;
464 auto intr = hfi.intrinsics;
465
466 if (cachedStreamParameters.at(i).projectionType == ProjectionType::PROJECTION_PERSPECTIVE) {
467 fi = StreamFrameInfo{
468 .imageIndex = hfi.imageIndex,
469 .extrinsics = Extrinsics{
470 .position = {ext.position.x,ext.position.y,ext.position.z},
471 .rotation = {ext.rotation.yaw, ext.rotation.pitch, ext.rotation.roll}
472 },
473 .intrinsics = Intrinsics{ //TODO handle the equirectangular case
474 PerspectiveIntrinsics{
475 .focals = {hfi.intrinsics.perspective.focalX, hfi.intrinsics.perspective.focalY},
476 .principle = {hfi.intrinsics.perspective.principlePointX, hfi.intrinsics.perspective.principlePointY}
477 }
478 }
479 };
480 }
481 else if(cachedStreamParameters.at(i).projectionType == ProjectionType::PROJECTION_EQUIRECTANGULAR) {
482 fi = StreamFrameInfo{
483 .imageIndex = hfi.imageIndex,
484 .extrinsics = Extrinsics{
485 .position = {ext.position.x,ext.position.y,ext.position.z},
486 .rotation = {ext.rotation.yaw, ext.rotation.pitch, ext.rotation.roll}
487 },
488 .intrinsics = Intrinsics{
489 EquirectangularIntrinsics{
490 .verticalRange = {hfi.intrinsics.equirectangular.verticalRange[0], hfi.intrinsics.equirectangular.verticalRange[1]},
491 .horizontalRange = {hfi.intrinsics.equirectangular.horizontalRange[0], hfi.intrinsics.equirectangular.horizontalRange[1]}
492 }
493 }
494 };
495 }
496 else {
497 throw std::runtime_error("Invalid projection type !");
498 }
499 }
500
501 //Wait on the image sempahore
502 vk::PipelineStageFlags waitStage = vk::PipelineStageFlagBits::eTopOfPipe;
503 vkw.context.graphicsQueue.submit(
504 vk::SubmitInfo(*currentSync.acquireSemaphore, waitStage));
505}
std::variant< PerspectiveIntrinsics, EquirectangularIntrinsics > Intrinsics
Union of possible intrinsics types data.
Definition: InputProvider.h:67
vk::Queue graphicsQueue
Definition: VulkanContext.h:89
VulkanContext context
Parameters for query of the current frames infos.

◆ enumerateStreamImages()

std::vector< DynamicInputProvider::StreamImage > DynamicInputProvider::enumerateStreamImages ( uint32_t  streamIndex,
bool  depth 
) const
overridevirtual

Implements InputProvider.

Definition at line 418 of file DynamicInputProvider.cpp.

418 {
419 const auto& stream = streamStorage.at(streamIndex);
420 if(depth) {
421 return stream.depthImages;
422 } else {
423 return stream.colorImages;
424 }
425}

◆ enumerateStreamsParameters()

std::vector< DynamicInputProvider::StreamParameters > DynamicInputProvider::enumerateStreamsParameters ( ) const
overridevirtual

Implements InputProvider.

Definition at line 414 of file DynamicInputProvider.cpp.

414 {
415 return cachedStreamParameters;
416}

◆ releaseStreamsFrames()

void DynamicInputProvider::releaseStreamsFrames ( )
overridevirtual

Implements InputProvider.

Definition at line 507 of file DynamicInputProvider.cpp.

507 {
508 auto& currentSync = syncInfos.at(currentSyncSlot);
509
510 // Submit a signal that we are done with the image
511 vkw.context.graphicsQueue.submit(
512 vk::SubmitInfo({},{},{},*currentSync.releaseSempahore));
513
514 hvtCheck(hvt.releaseStreamsFrames, context, currentSync.releaseHvt); //TODO pass proper semaphore
515}

The documentation for this class was generated from the following files: