在 CustusX 中获取视频 source/probe 的视频帧的位置信息

Get position information for videoframes of a video source/probe in CustusX

在实现 GUIExtenderService 的 CustusX 扩展的自定义插件中,我想访问超声波探头的流图像及其位置。

Documentation 说:

VideoSource has two main users: Rendering to screen and recording to disk. VideoGraphics contains the visualization functionality that the Reps uses when rendering in the Views. VideoGraphics needs a Probe to provide position information. Probe also wraps the VideoSource with its own ProbeAdapterVideoSource (using the adapter pattern) in order to add special information not known to the VideoSource, such as pixel spacing.

据我了解,VideoSource 负责图像,Probe 负责位置。如果我从 VideoSource 开始并连接到 newFrame 并使用 getVtkImageData 检索图像,我只会得到图像数据。所以问题是:如何获得图像帧及其对应的帧位置信息? (通过 VideoSourceProbe 或其他方式)。

您需要 Probe 和相关对象的实例:

VisServicesPtr services = VisServices::create(context);
ToolPtr tool = services->trackingService->getTool("myprobe");
ProbePtr probe = tool->getProbe();
VideoSourcePtr video = probe->getRTSource();

现在你有一个 tool,包含一个 probe,包含一个 videovideo 提供图像流,而 toolprobe 提供位置信息。根据 the documentation,图像的位置可以表示为变换 rMv,其中 r 是全局参考 space,v 是以毫米为单位的图像 space。要转换为像素,请乘以图像间距。 rMv 可以通过以下方式找到:

Transform3D rMpr, prMt, tMu, uMv, rMv;
rMpr = services->patientModelService->get_rMpr();
prMt = tool->get_prMt();
tMu = probe->getSector()->get_tMu();
uMv = probe->getSector()->get_uMv();
rMv = rMpr*prMt*tMu*uMv;

转换 rMpr 是患者注册,如果您只进行流式传输,则它是身份。

现在,可以使用以下方法将以像素为单位的像素位置 p 转换为全局 space r:

Vector3D p_v(p[0]*spacing[0], p[1]*spacing[1])    
Vector3D p_r = rMv.coord(p_v);

注意:这样得到的位置将是最后一次采样的跟踪位置,不一定与图像帧同时得到。使用下一个跟踪位置(在图像帧之后接收)进行插值可以提高精度,但这取决于具体的用例。