QmitkTrackingDeviceConfigurationWidget::QmitkTrackingDeviceConfigurationWidget(QWidget* parent, Qt::WindowFlags f)
  : QWidget(parent, f)
{
  //initialize worker thread
  m_TestConnectionWorker = new QmitkTrackingDeviceConfigurationWidgetConnectionWorker();
  m_ScanPortsWorker = new QmitkTrackingDeviceConfigurationWidgetScanPortsWorker();
  m_ScanPortsWorkerThread = new QThread();
  m_TestConnectionWorkerThread = new QThread();

   //initializations
  m_Controls = NULL;
  CreateQtPartControl(this);
  CreateConnections();
  m_MTCalibrationFile = "";
  m_AdvancedUserControl = true;

  //initialize a few UI elements
  this->m_TrackingDeviceConfigurated = false;
  AddOutput("<br>NDI Polaris selected"); //Polaris is selected by default
  m_Controls->m_trackingDeviceChooser->setCurrentIndex(0);
  m_Controls->m_TrackingSystemWidget->setCurrentIndex(0);
  //reset a few things
  ResetOutput();

  //restore old UI settings
  LoadUISettings();
}
void QmitkTrackingDeviceConfigurationWidget::TrackingDeviceChanged()
{
  //show the correspondig widget
  m_Controls->m_TrackingSystemWidget->setCurrentIndex(m_Controls->m_trackingDeviceChooser->currentIndex());

  //the new trackingdevice is not configurated yet
  m_TrackingDeviceConfigurated = false;

  //reset output
  ResetOutput();

  //print output and do further initializations
  if (m_Controls->m_trackingDeviceChooser->currentIndex()==0)//NDI Polaris
    {
    AddOutput("<br>NDI Polaris selected");
    }
  else if (m_Controls->m_trackingDeviceChooser->currentIndex()==1)  //NDI Aurora
    {
    AddOutput("<br>NDI Aurora selected");
    }
  else if (m_Controls->m_trackingDeviceChooser->currentIndex()==2) //ClaronTechnology MicronTracker 2
    {
    AddOutput("<br>Microntracker selected");
    if (!mitk::ClaronTrackingDevice::New()->IsDeviceInstalled())
      {
      AddOutput("<br>ERROR: not installed!");
      }
    else if (this->m_MTCalibrationFile == "") //if configuration file for MicronTracker is empty: load default
      {
      mitk::ClaronTrackingDevice::Pointer tempDevice = mitk::ClaronTrackingDevice::New();
      m_MTCalibrationFile = tempDevice->GetCalibrationDir();
      Poco::Path myPath = Poco::Path(m_MTCalibrationFile.c_str());
      m_Controls->m_MTCalibrationFile->setText("Calibration File: " + QString(myPath.getFileName().c_str()));
      }
    }
  else if (m_Controls->m_trackingDeviceChooser->currentIndex()==3)
  {
    AddOutput("<br>Optitrack selected");
    if (!mitk::OptitrackTrackingDevice::New()->IsDeviceInstalled())
      {
      AddOutput("<br>ERROR: not installed!");
      }
  }

emit TrackingDeviceSelectionChanged();
}
QmitkTrackingDeviceConfigurationWidget::QmitkTrackingDeviceConfigurationWidget(QWidget* parent, Qt::WindowFlags f)
  : QWidget(parent, f)
  , m_Controls(nullptr)
  , m_TrackingDevice(nullptr)
  , m_DeviceToWidgetIndexMap()
{
  //initializations
  CreateQtPartControl(this);
  CreateConnections();

  RefreshTrackingDeviceCollection();

  //initialize a few UI elements
  AddOutput("<br>First Element selected"); //Order from Collection List

  //reset a few things
  ResetOutput();

  //restore old UI settings
  LoadUISettings();
}
QmitkTrackingDeviceConfigurationWidget::QmitkTrackingDeviceConfigurationWidget(QWidget* parent, Qt::WindowFlags f)
  : QWidget(parent, f)
{
  //initialize worker thread
  m_TestConnectionWorker = new QmitkTrackingDeviceConfigurationWidgetConnectionWorker();
  m_ScanPortsWorker = new QmitkTrackingDeviceConfigurationWidgetScanPortsWorker();
  m_ScanPortsWorkerThread = new QThread();
  m_TestConnectionWorkerThread = new QThread();

  m_Controls = NULL;
  CreateQtPartControl(this);
  CreateConnections();
  m_MTCalibrationFile = "";

  //reset a few things
  ResetOutput();
  AddOutput("<br>NDI Polaris selected");
  this->m_TrackingDeviceConfigurated = false;

  m_AdvancedUserControl = true;
}
void QmitkTrackingDeviceConfigurationWidget::TrackingDeviceChanged()
{
  const std::string currentDevice = this->GetCurrentDeviceName();

  //show the correspondig widget
  m_Controls->m_TrackingSystemWidget->setCurrentIndex(m_DeviceToWidgetIndexMap[currentDevice]);

  //reset output
  ResetOutput();

  AddOutput("<br>");
  AddOutput(currentDevice);
  AddOutput(" selected");

  QmitkAbstractTrackingDeviceWidget* widget = GetWidget(currentDevice);

  if (widget == nullptr || !widget->IsDeviceInstalled())
  {
    AddOutput("<br>ERROR: not installed!");
  }

  emit TrackingDeviceSelectionChanged();
}
Ejemplo n.º 6
0
VideoRenderDirect3D9::~VideoRenderDirect3D9()
{
    ResetOutput();
}
Ejemplo n.º 7
0
void VideoRenderDirect3D9::RefreshFrame(VideoFrame *Frame, const QSizeF &Size)
{
    if (!m_direct3D9Window)
        return;

    IDirect3DDevice9 *device = m_direct3D9Window->GetDevice();

    if (device && Frame && !Frame->m_corrupt)
    {
        // check for a size change
        if (m_rawVideoTexture)
        {
            if ((m_rawVideoTexture->m_usedSize.width() != (Frame->m_rawWidth / 2)) || (m_rawVideoTexture->m_usedSize.height() != Frame->m_rawHeight))
            {
                LOG(VB_GENERAL, LOG_INFO, QString("Video frame size changed from %1x%2 to %3x%4")
                    .arg(m_rawVideoTexture->m_usedSize.width() * 2).arg(m_rawVideoTexture->m_usedSize.height())
                    .arg(Frame->m_rawWidth).arg(Frame->m_rawHeight));
                ResetOutput();
            }
        }

        // create a texture if needed
        if (!m_rawVideoTexture)
        {
            QSize size(Frame->m_rawWidth / 2, Frame->m_rawHeight);
            m_rawVideoTexture = m_direct3D9Window->CreateTexture(device, size);

            if (!m_rawVideoTexture)
            {
                LOG(VB_GENERAL, LOG_ERR, "Failed to create video texture");
                return;
            }

            // standard texture vertices only use width and height, we need the offset
            // as well to ensure texture inversion works
            m_rawVideoTexture->m_fullVertices = true;

            LOG(VB_GENERAL, LOG_INFO, QString("Created video texture %1x%2").arg(Frame->m_rawWidth).arg(Frame->m_rawHeight));
        }

        // create a yuv to rgb shader
        // NB we could use yuv picture formats but we then have no control over
        // colourspace and adjustments
        if (!m_yuvShader)
        {
            unsigned int vertexsize   = sizeof(YUV2RGBVertexShader) / sizeof(char);
            unsigned int fragmentsize = sizeof(YUV2RGBFragmentShader) / sizeof(char);

            QByteArray fragment(YUV2RGBFragmentShader, fragmentsize);
            fragment.replace("SELECT_COLUMN", QByteArray::number(m_rawVideoTexture->m_size.width(), 'f', 8));

            m_yuvShader = m_direct3D9Window->CreateShader(device, YUV2RGBVertexShader, vertexsize,
                                                          fragment.data(), fragment.size());

            if (!m_yuvShader)
                return;
        }

        // create rgb texture
        if (!m_rgbVideoTexture)
        {
            QSize size(Frame->m_rawWidth, Frame->m_rawHeight);
            m_rgbVideoTexture = m_direct3D9Window->CreateTexture(device, size);

            if (!m_rgbVideoTexture)
            {
                LOG(VB_GENERAL, LOG_ERR, "Failed to create RGB video texture");
                return;
            }

            m_rgbVideoTexture->m_fullVertices = true;
        }

        // update the raw video texture
        D3DLOCKED_RECT d3drect;
        if (SUCCEEDED(m_rawVideoTexture->m_surface->LockRect(&d3drect, NULL, 0)))
        {
            void* buffer = d3drect.pBits;
            //if (d3drect.Pitch != m_rawVideoTexture->m_size.width() * 4)
            //    LOG(VB_GENERAL, LOG_WARNING, QString("Unexpected pitch %1 - expected %2").arg(d3drect.Pitch).arg(m_rawVideoTexture->m_size.width() * 4));

            PixelFormat informat = Frame->m_secondaryPixelFormat != PIX_FMT_NONE ? Frame->m_secondaryPixelFormat : Frame->m_pixelFormat;

            if (informat != m_outputFormat)
            {
                AVPicture in;
                avpicture_fill(&in, Frame->m_buffer, informat, Frame->m_adjustedWidth, Frame->m_adjustedHeight);
                AVPicture out;
                avpicture_fill(&out, (uint8_t*)buffer, m_outputFormat, d3drect.Pitch >> 1/*Frame->m_rawWidth*/, Frame->m_rawHeight);

                m_conversionContext = sws_getCachedContext(m_conversionContext,
                                                           Frame->m_rawWidth, Frame->m_rawHeight, informat,
                                                           Frame->m_rawWidth, Frame->m_rawHeight, m_outputFormat,
                                                           SWS_FAST_BILINEAR, NULL, NULL, NULL);
                if (m_conversionContext != NULL)
                {
                    if (sws_scale(m_conversionContext, in.data, in.linesize, 0, Frame->m_rawHeight, out.data, out.linesize) < 1)
                        LOG(VB_GENERAL, LOG_ERR, "Software scaling/conversion failed");
                }
                else
                {
                    LOG(VB_GENERAL, LOG_ERR, "Failed to create software conversion context");
                }
            }
            else
            {