@@ -382,6 +382,57 @@ class WindowSceneImpl : public WindowScene
382
382
}
383
383
}
384
384
385
+ void getCompositorTexture (const String& compname, const String& texname, OutputArray out,
386
+ int mrtIndex) CV_OVERRIDE
387
+ {
388
+ CompositorManager& cm = CompositorManager::getSingleton ();
389
+ CompositorChain* chain = cm.getCompositorChain (frameSrc->getViewport (0 ));
390
+ CV_Assert (chain && " no active compositors" );
391
+
392
+ CompositorInstance* inst = chain->getCompositor (compname);
393
+ if (!inst)
394
+ CV_Error_ (Error::StsBadArg, (" no active compositor named: %s" , compname.c_str ()));
395
+
396
+ TexturePtr tex = inst->getTextureInstance (texname, mrtIndex);
397
+ if (!tex)
398
+ CV_Error_ (Error::StsBadArg, (" no texture named: %s" , texname.c_str ()));
399
+
400
+ PixelFormat src_type = tex->getFormat ();
401
+ int dst_type;
402
+ switch (src_type)
403
+ {
404
+ case PF_BYTE_RGB:
405
+ dst_type = CV_8UC3;
406
+ break ;
407
+ case PF_BYTE_RGBA:
408
+ dst_type = CV_8UC4;
409
+ break ;
410
+ case PF_FLOAT32_RGB:
411
+ dst_type = CV_32FC3;
412
+ break ;
413
+ case PF_FLOAT32_RGBA:
414
+ dst_type = CV_32FC4;
415
+ break ;
416
+ case PF_DEPTH16:
417
+ dst_type = CV_16U;
418
+ break ;
419
+ default :
420
+ CV_Error (Error::StsNotImplemented, " unsupported texture format" );
421
+ }
422
+
423
+ out.create (tex->getHeight (), tex->getWidth (), dst_type);
424
+
425
+ Mat mat = out.getMat ();
426
+ PixelBox pb (tex->getWidth (), tex->getHeight (), 1 , src_type, mat.ptr ());
427
+ tex->getBuffer ()->blitToMemory (pb, pb);
428
+
429
+ if (CV_MAT_CN (dst_type) < 3 )
430
+ return ;
431
+
432
+ // convert to OpenCV channel order
433
+ cvtColor (mat, mat, CV_MAT_CN (dst_type) == 3 ? COLOR_RGB2BGR : COLOR_RGBA2BGRA);
434
+ }
435
+
385
436
void setBackground (const Scalar& color) CV_OVERRIDE
386
437
{
387
438
// hide background plane
0 commit comments