STDMETHODIMP USTelemedScanConverterPlugin::SetScanConverterPlugin(IDispatch* plugin) { // make sure that there is no scan converter plugin registered already this->ReleasePlugin(); HRESULT hr; // it is ok to call this method with a nullptr plugin to remove // a previous callback if (plugin == nullptr) { MITK_INFO("IUsgfwScanConverterPluginCB")("ScanConverterPlugin") << "nullptr plugin set to the scan converter. The callback for the previous plugin is removed now."; return S_OK; } // get Telemed API plugin from the COM library Usgfw2Lib::IUsgScanConverterPlugin* tmp_plugin; hr = plugin->QueryInterface(__uuidof(Usgfw2Lib::IUsgScanConverterPlugin), (void**)&tmp_plugin); if (FAILED(hr)) { MITK_WARN("IUsgfwScanConverterPluginCB")("ScanConverterPlugin") << "Could not query com interface for IUsgScanConverterPlugin (" << hr << ")."; return hr; } // get the converter for scan lines from the COM library and // save it as a member attribute hr = tmp_plugin->get_ScanConverter((IUnknown**)&m_Plugin); if (FAILED(hr)) { MITK_WARN("IUsgfwScanConverterPluginCB")("ScanConverterPlugin") << "Could not get ScanConverter from plugin (" << hr << ")."; return hr; } SAFE_RELEASE(tmp_plugin); // now the callback can be set -> interface functions of this // object will be called from now on when new image data is // available hr = m_Plugin->SetCallback(this,USPC_BUFFER_INTERIM_OUTPUT); if (FAILED(hr)) { MITK_WARN("IUsgfwScanConverterPluginCB")("ScanConverterPlugin") << "Could not set callback for plugin (" << hr << ")."; return hr; } return S_OK; }
void QmitkPythonSnippets::SaveStringMap(const QString &filename, const QmitkPythonSnippets::QStringMap &) const { MITK_DEBUG("QmitkPythonSnippets") << "saving to xml file " << filename.toStdString(); if( filename.isEmpty() ) { MITK_WARN("QmitkPythonSnippets") << "empty auto save file path given. quit."; return; } QFile file(filename); file.open(QIODevice::WriteOnly); if( !file.isOpen() ) { MITK_WARN("QmitkPythonSnippets") << "could not open file " << filename.toStdString() << " for writing"; return; } QXmlStreamWriter xmlWriter(&file); xmlWriter.setAutoFormatting(true); xmlWriter.writeStartDocument(); xmlWriter.writeStartElement(SNIPPETS_ROOT_XML_ELEMENT_NAME); QStringMap::const_iterator it = d->m_Snippets.begin(); while( it != d->m_Snippets.end() ) { { MITK_DEBUG("QmitkPythonSnippets") << "SNIPPETS_XML_ELEMENT_NAME " << SNIPPETS_XML_ELEMENT_NAME.toStdString(); MITK_DEBUG("QmitkPythonSnippets") << "writing item " << it.key().toStdString(); } xmlWriter.writeStartElement(SNIPPETS_XML_ELEMENT_NAME); xmlWriter.writeAttribute( "key", it.key() ); xmlWriter.writeAttribute( "value", it.value() ); xmlWriter.writeEndElement(); ++it; } xmlWriter.writeEndDocument(); if( file.isOpen() ) file.close(); { MITK_DEBUG("QmitkPythonSnippets") << "SaveStringMap successful "; } }
void QmitkUSNavigationStepMarkerIntervention::UpdateSensorsNames() { mitk::USCombinedModality::Pointer combinedModality = this->GetCombinedModality(false); if (combinedModality.IsNull()) { return; } mitk::NavigationDataSource::Pointer navigationDataSource = combinedModality->GetNavigationDataSource(); if (navigationDataSource.IsNull()) { return; } if (!m_NeedleSensorName.empty()) { try { m_NeedleSensorIndex = navigationDataSource->GetOutputIndex(m_NeedleSensorName); } catch (const std::exception &e) { MITK_WARN("QmitkUSAbstractNavigationStep") ("QmitkUSNavigationStepPlacementPlanning") << "Cannot get index for needle sensor name: " << e.what(); } } if (this->GetNavigationStepState() >= QmitkUSAbstractNavigationStep::State_Active) { m_NeedleProjectionFilter->SelectInput(m_NeedleSensorIndex); } if (!m_ReferenceSensorName.empty()) { try { m_ReferenceSensorIndex = navigationDataSource->GetOutputIndex(m_ReferenceSensorName); } catch (const std::exception &e) { MITK_WARN("QmitkUSAbstractNavigationStep") ("QmitkUSNavigationStepPlacementPlanning") << "Cannot get index for reference sensor name: " << e.what(); } } if (this->GetNavigationStepState() >= QmitkUSAbstractNavigationStep::State_Active) { m_NodeDisplacementFilter->SelectInput(m_ReferenceSensorIndex); } ui->freezeImageButton->SetCombinedModality(combinedModality, m_ReferenceSensorIndex); }
void QmitkImageStatisticsView::JumpToCoordinates(int row ,int col) { if(m_SelectedDataNodes.isEmpty()) { MITK_WARN("QmitkImageStatisticsView") << "No data node selected for statistics calculation." ; return; } mitk::Point3D world; if (row==4 && !m_WorldMinList.empty()) world = m_WorldMinList[col]; else if (row==3 && !m_WorldMaxList.empty()) world = m_WorldMaxList[col]; else return; mitk::IRenderWindowPart* part = this->GetRenderWindowPart(); if (part) { part->GetQmitkRenderWindow("axial")->GetSliceNavigationController()->SelectSliceByPoint(world); part->GetQmitkRenderWindow("sagittal")->GetSliceNavigationController()->SelectSliceByPoint(world); part->GetQmitkRenderWindow("coronal")->GetSliceNavigationController()->SelectSliceByPoint(world); mitk::SliceNavigationController::GeometryTimeEvent timeEvent(this->m_SelectedImage->GetTimeGeometry(), col); part->GetQmitkRenderWindow("axial")->GetSliceNavigationController()->SetGeometryTime(timeEvent); } }
mitk::NavigationDataSet::Pointer mitk::NavigationDataReaderXML::ReadNavigationDataSet() { mitk::NavigationDataSet::Pointer navigationDataSet = mitk::NavigationDataSet::New(m_NumberOfOutputs); mitk::NavigationData::Pointer curNavigationData; do { std::vector<mitk::NavigationData::Pointer> navDatas(m_NumberOfOutputs); for (unsigned int n = 0; n < m_NumberOfOutputs; ++n) { curNavigationData = this->ReadVersion1(); if (curNavigationData.IsNull()) { if (n != 0) { MITK_WARN("mitkNavigationDataReaderXML") << "Different number of NavigationData objects for different tools. Ignoring last ones."; } break; } navDatas.at(n) = curNavigationData; } if (curNavigationData.IsNotNull()) { navigationDataSet->AddNavigationDatas(navDatas); } } while (curNavigationData.IsNotNull()); return navigationDataSet; }
void KinectDevice::GetDistances(float* distanceArray, int& imageSequence) { m_ImageMutex->Lock(); if (m_CameraActive) { // 1) copy the image buffer // 2) convert the distance values from m to mm // 3) Flip around y- axis (vertical axis) /* this->m_Controller->GetDistances(this->m_SourceDataBuffer[this->m_CurrentPos], this->m_DistanceArray); for (int i=0; i<this->m_CaptureHeight; i++) { for (int j=0; j<this->m_CaptureWidth; j++) { distanceArray[i*this->m_CaptureWidth+j] = 1000 * this->m_DistanceArray[(i+1)*this->m_CaptureWidth-1-j]; } } */ for (int i=0; i<this->m_PixelNumber; i++) { distanceArray[i] = this->m_DistanceDataBuffer[this->m_CurrentPos][i]; // * 1000 } imageSequence = this->m_ImageSequence; } else { MITK_WARN("ToF") << "Warning: Data can only be acquired if camera is active."; } m_ImageMutex->Unlock(); }
void OclResourceServiceImpl::InsertProgram(cl_program _program_in, std::string name, bool forceOverride) { typedef std::pair < std::string, ProgramData > MapElemPair; std::pair< ProgramMapType::iterator, bool> retValue; ProgramData data; data.counter = 1; data.program = _program_in; data.mutex = itk::FastMutexLock::New(); // program is not stored, insert first instance (count = 1) m_ProgramStorageMutex->Lock(); retValue = m_ProgramStorage.insert( MapElemPair(name, data) ); m_ProgramStorageMutex->Unlock(); // insertion failed, i.e. a program with same name exists if( !retValue.second ) { std::string overrideMsg(""); if( forceOverride ) { // overwrite old instance m_ProgramStorage[name].program = _program_in; overrideMsg +=" The old program was overwritten!"; } MITK_WARN("OpenCL.ResourceService") << "The program " << name << " already exists." << overrideMsg; } }
mitk::NavigationData::Pointer mitk::NavigationDataSet::GetNavigationDataForIndex( unsigned int index, unsigned int toolIndex ) const { if ( index >= m_NavigationDataVectors.size() ) { MITK_WARN("NavigationDataSet") << "There is no NavigationData available at index " << index << "."; return nullptr; } if ( toolIndex >= m_NavigationDataVectors.at(index).size() ) { MITK_WARN("NavigationDataSet") << "There is NavigatitionData available at index " << index << " for tool " << toolIndex << "."; return nullptr; } return m_NavigationDataVectors.at(index).at(toolIndex); }
void OclResourceServiceImpl::RemoveProgram(const std::string& name) { ProgramMapType::iterator it = m_ProgramStorage.find(name); cl_int status = 0; cl_program program = NULL; if( it != m_ProgramStorage.end() ) { it->second.mutex->Lock(); // decrease reference by one it->second.counter -= 1; it->second.mutex->Unlock(); // remove from the storage if( it->second.counter == 0 ) { program = it->second.program; m_ProgramStorageMutex->Lock(); m_ProgramStorage.erase(it); m_ProgramStorageMutex->Unlock(); } // delete the program if( program ) { status = clReleaseProgram(program); CHECK_OCL_ERR( status ); } } else { MITK_WARN("OpenCL.ResourceService") << "Program name [" <<name <<"] passed for deletion not found."; } }
void QmitkNavigationDataPlayerView::OnOpenFile() { mitk::NavigationDataReaderInterface::Pointer reader = NULL; QString filter = tr("NavigationData File (*.csv *.xml)"); QString fileName = QFileDialog::getOpenFileName(NULL, tr("Open NavigationData Set"), "", filter); if ( fileName.isNull() ) { return; } // user pressed cancel try { m_Data = dynamic_cast<mitk::NavigationDataSet*> (mitk::IOUtil::LoadBaseData(fileName.toStdString()).GetPointer()); } catch ( const mitk::Exception &e ) { MITK_WARN("NavigationDataPlayerView") << "could not open file " << fileName.toStdString(); QMessageBox::critical(0, "Error Reading File", "The file '" + fileName +"' could not be read.\n" + e.GetDescription() ); return; } // Update Labels m_Controls->m_LblFilePath->setText(fileName); m_Controls->m_LblFrames->setText(QString::number(m_Data->Size())); m_Controls->m_LblTools->setText(QString::number(m_Data->GetNumberOfTools())); // Initialize Widgets and create Player this->OnSelectPlayer(); this->SetInteractionComponentsEnabledState(true); }
bool mitk::USCombinedModality::OnActivation() { if ( m_UltrasoundDevice.IsNull() ) { MITK_ERROR("USCombinedModality")("USDevice") << "UltrasoundDevice must not be null."; mitkThrow() << "UltrasoundDevice must not be null."; } mitk::TrackingDeviceSource::Pointer trackingDeviceSource = dynamic_cast<mitk::TrackingDeviceSource*>(m_TrackingDevice.GetPointer()); if ( trackingDeviceSource.IsNull() ) { MITK_WARN("USCombinedModality")("USDevice") << "Cannot start tracking as TrackingDeviceSource is null."; } trackingDeviceSource->StartTracking(); // activate ultrasound device only if it is not already activated if ( m_UltrasoundDevice->GetDeviceState() >= mitk::USDevice::State_Activated ) { return true; } else { return m_UltrasoundDevice->Activate(); } }
bool mitk::NodeDisplacementFilter::AddNode( mitk::DataNode::Pointer node ) { // Consistency Checks if (node.IsNull()) { MITK_WARN("NodeDisplacementFilter") << "Null Node passed to NodeDisplacementFilter. Ignoring Node...."; return false; } if (node->GetData() == 0) { MITK_WARN("NodeDisplacementFilter") << "Empty Node passed to NodeDisplacementFilter. Ignoring Node...."; return false; } if(m_SelectedInput == -1) { MITK_ERROR("NodeDisplacementFilter") << "Cannot add nodes before input Stream was selected"; mitkThrow() << "Cannot add nodes before input Stream was selected"; } this->Update(); // make sure we are working on current data mitk::NavigationData::Pointer reference = this->GetOutput(m_SelectedInput); if (! reference->IsDataValid()) { MITK_WARN("NodeDisplacementFilter") << "Cannot add node while selected tool is not tracked. Ignoring Node...."; return false; } // find transformation and add node mitk::AffineTransform3D::Pointer inverseAffineTransform = mitk::AffineTransform3D::New(); if ( ! reference->GetAffineTransform3D()->GetInverse(inverseAffineTransform) ) { MITK_ERROR("NodeDisplacementFilter") << "Could not get the inverse transformation of the navigation data transformation."; mitkThrow() << "Could not get the inverse transformation of the navigation data transformation."; } inverseAffineTransform->Compose(node->GetData()->GetGeometry()->GetIndexToWorldTransform(), true); m_Transforms.push_back(inverseAffineTransform); m_Nodes.push_back(node); return true; }
HistogramStatisticsCalculator::MeasurementType HistogramStatisticsCalculator::GetUPP() { if (!m_StatisticsCalculated) { MITK_WARN("Statistics have not yet been calculated, running calculation now..."); CalculateStatistics(); } return m_UPP; }
bool CropOpenCVImageFilter::OnFilterImage( cv::Mat& image ) { if (m_CropRegion.width == 0) { MITK_WARN("AbstractOpenCVImageFilter")("CropOpenCVImageFilter") << "Cropping cannot be done without setting a non-empty crop region first."; return false; } cv::Size imageSize = image.size(); if (m_CropRegion.x >= imageSize.width || m_CropRegion.y >= imageSize.height) { MITK_WARN("AbstractOpenCVImageFilter")("CropOpenCVImageFilter") << "Cannot crop if top left corner of the roi is outside the image boundaries."; return false; } // We can try and correct too large boundaries (do this only once // after a new crop region was set. if (m_NewCropRegionSet) { m_NewCropRegionSet = false; if ( m_CropRegion.x + m_CropRegion.width > imageSize.width) { m_CropRegion.width = imageSize.width - m_CropRegion.x; MITK_WARN("AbstractOpenCVImageFilter")("CropOpenCVImageFilter") << "Changed too large roi in x direction to fit the image size."; } if ( m_CropRegion.y + m_CropRegion.height > imageSize.height) { m_CropRegion.height = imageSize.height - m_CropRegion.y; MITK_WARN("AbstractOpenCVImageFilter")("CropOpenCVImageFilter") << "Changed too large roi in y direction to fit the image size."; } } // crop image and copy cropped region into the input image cv::Mat buffer = image(m_CropRegion); buffer.copyTo(image); return true; }
void mitk::NavigationToolStorage::UnRegisterMicroservice(){ if (!m_ServiceRegistration) { MITK_WARN("NavigationToolStorage") << "Cannot unregister microservice as it wasn't registered before."; return; } m_ServiceRegistration.Unregister(); m_ServiceRegistration = 0; }
void KinectDevice::GetAllImages(float* distanceArray, float* amplitudeArray, float* intensityArray, char* sourceDataArray, int requiredImageSequence, int& capturedImageSequence, unsigned char* rgbDataArray) { if (m_CameraActive) { // 1) copy the image buffer // 2) convert the distance values from m to mm // 3) Flip around y- axis (vertical axis) // check for empty buffer if (this->m_ImageSequence < 0) { // buffer empty MITK_INFO << "Buffer empty!! "; capturedImageSequence = this->m_ImageSequence; return; } // determine position of image in buffer int pos = 0; if ((requiredImageSequence < 0) || (requiredImageSequence > this->m_ImageSequence)) { capturedImageSequence = this->m_ImageSequence; pos = this->m_CurrentPos; //MITK_INFO << "Required image not found! Required: " << requiredImageSequence << " delivered/current: " << this->m_ImageSequence; } else if (requiredImageSequence <= this->m_ImageSequence - this->m_BufferSize) { capturedImageSequence = (this->m_ImageSequence - this->m_BufferSize) + 1; pos = (this->m_CurrentPos + 1) % this->m_BufferSize; //MITK_INFO << "Out of buffer! Required: " << requiredImageSequence << " delivered: " << capturedImageSequence << " current: " << this->m_ImageSequence; } else // (requiredImageSequence > this->m_ImageSequence - this->m_BufferSize) && (requiredImageSequence <= this->m_ImageSequence) { capturedImageSequence = requiredImageSequence; pos = (this->m_CurrentPos + (10-(this->m_ImageSequence - requiredImageSequence))) % this->m_BufferSize; } // write image data to float arrays for (int i=0; i<this->m_PixelNumber; i++) { distanceArray[i] = this->m_DistanceDataBuffer[pos][i]; amplitudeArray[i] = this->m_AmplitudeDataBuffer[pos][i]; intensityArray[i] = this->m_IntensityDataBuffer[pos][i]; rgbDataArray[i*3] = this->m_RGBDataBuffer[pos][i*3]; rgbDataArray[i*3+1] = this->m_RGBDataBuffer[pos][i*3+1]; rgbDataArray[i*3+2] = this->m_RGBDataBuffer[pos][i*3+2]; } } else { MITK_WARN("ToF") << "Warning: Data can only be acquired if camera is active."; } }
void ToFCameraPMDRawDataCamBoardDevice::GetDistances(float* distanceArray, int& imageSequence) { if (m_CameraActive) { this->ResizeOutputImage(m_DistanceArray, distanceArray); imageSequence = this->m_ImageSequence; } else { MITK_WARN("ToF") << "Warning: Data can only be acquired if camera is active."; } }
bool mitk::USVideoDevice::OnActivation() { // make sure that video device is ready before aquiring images if (!m_Source->GetIsReady()) { MITK_WARN("mitkUSDevice")("mitkUSVideoDevice") << "Could not activate us video device. Check if video grabber is configured correctly."; return false; } MITK_INFO << "Activated UsVideoDevice!"; return true; }
bool mitk::USDevice::GetIsFreezed() { if (!this->GetIsActive()) { MITK_WARN("mitkUSDevice")("mitkUSTelemedDevice") << "Cannot get freeze state if the hardware interface is not ready. " "Returning false..."; return false; } return m_IsFreezed; }
bool mitk::LiveWireTool2D::IsPositionEventInsideImageRegion(mitk::InteractionPositionEvent *positionEvent, mitk::BaseData *data) { bool IsPositionEventInsideImageRegion = data != nullptr && data->GetGeometry()->IsInside(positionEvent->GetPositionInWorld()); if (!IsPositionEventInsideImageRegion) { MITK_WARN("LiveWireTool2D") << "PositionEvent is outside ImageRegion!"; return false; } return true; }
void KinectV2Device::GetAllImages(float* distanceArray, float* amplitudeArray, float* intensityArray, char* sourceDataArray, int requiredImageSequence, int& capturedImageSequence, unsigned char* rgbDataArray) { if (m_CameraActive) { // check for empty buffer if (this->m_ImageSequence < 0) { // buffer empty MITK_WARN << "Buffer empty!! "; capturedImageSequence = this->m_ImageSequence; return; } // determine position of image in buffer int pos = 0; if ((requiredImageSequence < 0) || (requiredImageSequence > this->m_ImageSequence)) { capturedImageSequence = this->m_ImageSequence; pos = this->m_CurrentPos; } else if (requiredImageSequence <= this->m_ImageSequence - this->m_BufferSize) { capturedImageSequence = (this->m_ImageSequence - this->m_BufferSize) + 1; pos = (this->m_CurrentPos + 1) % this->m_BufferSize; } else // (requiredImageSequence > this->m_ImageSequence - this->m_BufferSize) && (requiredImageSequence <= this->m_ImageSequence) { capturedImageSequence = requiredImageSequence; pos = (this->m_CurrentPos + (10-(this->m_ImageSequence - requiredImageSequence))) % this->m_BufferSize; } // write image data to arrays m_ImageMutex->Lock(); memcpy(distanceArray, this->m_DistanceDataBuffer[pos], this->m_DepthBufferSize); memcpy(amplitudeArray, this->m_AmplitudeDataBuffer[pos], this->m_DepthBufferSize); memcpy(rgbDataArray, this->m_RGBDataBuffer[pos], this->m_RGBBufferSize); vtkSmartPointer<vtkPolyData> deepCopyOfPoly = vtkSmartPointer<vtkPolyData>::New(); deepCopyOfPoly->DeepCopy(this->m_PolyData); m_ImageMutex->Unlock(); //Since the standard method GetAllImages does not allow transfering a surface, //we use a property to pass the surface to the workbench. mitk::Surface::Pointer surface = mitk::Surface::New(); surface->SetVtkPolyData( deepCopyOfPoly ); this->SetProperty("ToFSurface", mitk::SmartPointerProperty::New( surface )); this->Modified(); } else { MITK_WARN("ToF") << "Warning: Data can only be acquired if camera is active."; } }
void mitk::USZonesInteractor::UpdateSurface(mitk::DataNode::Pointer dataNode) { if (!dataNode->GetData()) { MITK_WARN("USZonesInteractor")("DataInteractor") << "Cannot update surface for node as no data is set to the node."; return; } mitk::Point3D origin = dataNode->GetData()->GetGeometry()->GetOrigin(); float radius; if (!dataNode->GetFloatProperty(DATANODE_PROPERTY_SIZE, radius)) { MITK_WARN("USZonesInteractor")("DataInteractor") << "Cannut update surface for node as no radius is specified in the node properties."; return; } mitk::Surface::Pointer zone = mitk::Surface::New(); // create a vtk sphere with given radius vtkSphereSource *vtkData = vtkSphereSource::New(); vtkData->SetRadius(radius); vtkData->SetCenter(0, 0, 0); vtkData->SetPhiResolution(20); vtkData->SetThetaResolution(20); vtkData->Update(); zone->SetVtkPolyData(vtkData->GetOutput()); vtkData->Delete(); // set vtk sphere and origin to data node (origin must be set // again, because of the new sphere set as data) dataNode->SetData(zone); dataNode->GetData()->GetGeometry()->SetOrigin(origin); // update the RenderWindow to show the changed surface mitk::RenderingManager::GetInstance()->RequestUpdateAll(); }
void KinectDevice::GetDistances(float*, int& imageSequence) { m_ImageMutex->Lock(); if (m_CameraActive) { imageSequence = this->m_ImageSequence; } else { MITK_WARN("ToF") << "Warning: Data can only be acquired if camera is active."; } m_ImageMutex->Unlock(); }
void mitk::IGTLClient::Receive() { //try to receive a message, if the socket is not present anymore stop the //communication unsigned int status = this->ReceivePrivate(this->m_Socket); if ( status == IGTL_STATUS_NOT_PRESENT ) { this->StopCommunicationWithSocket(this->m_Socket); //inform observers about loosing the connection to this socket this->InvokeEvent(LostConnectionEvent()); MITK_WARN("IGTLClient") << "Lost connection to server socket."; } }
float mitk::pa::SpectralUnmixingSO2::CalculateTHb(float Hb, float HbO2) { float result = (Hb + HbO2); if (result != result) { MITK_WARN(m_Verbose) << "SO2 VALUE NAN! WILL BE SET TO ZERO!"; return 0; } else { return result; } }
bool mitk::NavigationDataSet::AddNavigationDatas( std::vector<mitk::NavigationData::Pointer> navigationDatas ) { // test if tool with given index exist if ( navigationDatas.size() != m_NumberOfTools ) { MITK_WARN("NavigationDataSet") << "Tried to add too many or too few navigation Datas to NavigationDataSet. " << m_NumberOfTools << " required, tried to add " << navigationDatas.size() << "."; return false; } // test for consistent timestamp if ( m_NavigationDataVectors.size() > 0) { for (std::vector<mitk::NavigationData::Pointer>::size_type i = 0; i < navigationDatas.size(); i++) if (navigationDatas[i]->GetIGTTimeStamp() <= m_NavigationDataVectors.back()[i]->GetIGTTimeStamp()) { MITK_WARN("NavigationDataSet") << "IGTTimeStamp of new NavigationData should be newer than timestamp of last NavigationData."; return false; } } m_NavigationDataVectors.push_back(navigationDatas); return true; }
void KinectV2Device::GetDistances(float* distanceArray, int& imageSequence) { m_ImageMutex->Lock(); if (m_CameraActive) { memcpy(distanceArray, this->m_DistanceDataBuffer[this->m_CurrentPos], this->m_DepthBufferSize); imageSequence = this->m_ImageSequence; } else { MITK_WARN("ToF") << "Warning: Data can only be acquired if camera is active."; } m_ImageMutex->Unlock(); }
mitk::AffineTransform3D::Pointer mitk::USCombinedModality::GetCalibration() { std::string calibrationKey = this->GetIdentifierForCurrentCalibration(); if (calibrationKey.empty()) { MITK_WARN("USCombinedModality")("USDevice") << "Could not get a key for the calibration."; return 0; } // find calibration for combination of probe identifier and depth std::map<std::string, mitk::AffineTransform3D::Pointer>::iterator calibrationIterator = m_Calibrations.find(calibrationKey); if (calibrationIterator == m_Calibrations.end()) { MITK_WARN("USCombinedModality")("USDevice") << "No calibration found for selected probe and depth."; return 0; } return calibrationIterator->second; }
void mitk::IGTLServer::Receive() { unsigned int status = IGTL_STATUS_OK; SocketListType socketsToBeRemoved; //the server can be connected with several clients, therefore it has to check //all registered clients SocketListIteratorType it; m_ReceiveListMutex->Lock(); auto it_end = this->m_RegisteredClients.end(); for (it = this->m_RegisteredClients.begin(); it != it_end; ++it) { //it is possible that ReceivePrivate detects that the current socket is //already disconnected. Therefore, it is necessary to remove this socket //from the registered clients list status = this->ReceivePrivate(*it); if (status == IGTL_STATUS_NOT_PRESENT) { //remember this socket for later, it is not a good idea to remove it //from the list directly because we iterate over the list at this point socketsToBeRemoved.push_back(*it); MITK_WARN("IGTLServer") << "Lost connection to a client socket. "; } else if (status != 1) { MITK_WARN("IGTLServer") << "IGTL Message with status: " << status; } } m_ReceiveListMutex->Unlock(); if (socketsToBeRemoved.size() > 0) { //remove the sockets that are not connected anymore this->StopCommunicationWithSocket(socketsToBeRemoved); //inform observers about loosing the connection to these sockets this->InvokeEvent(LostConnectionEvent()); } }
cv::Rect mitk::GrabCutOpenCVImageFilter::GetBoundingRectFromMask(cv::Mat mask) { cv::Mat nonPropablyBackgroundMask, modelPoints; cv::compare(mask, cv::GC_PR_BGD, nonPropablyBackgroundMask, cv::CMP_NE); cv::findNonZero(nonPropablyBackgroundMask, modelPoints); if (modelPoints.empty()) { MITK_WARN("AbstractOpenCVImageFilter")("GrabCutOpenCVImageFilter") << "Cannot find any foreground points. Returning full image size as bounding rectangle."; return cv::Rect(0, 0, mask.rows, mask.cols); } // calculate bounding rect around the model points cv::Rect boundingRect = cv::boundingRect(modelPoints); // substract additional width to x and y value (and make sure that they aren't outside the image then) boundingRect.x = static_cast<unsigned int>(boundingRect.x) > m_AdditionalWidth ? boundingRect.x - m_AdditionalWidth : 0; boundingRect.y = static_cast<unsigned int>(boundingRect.y) > m_AdditionalWidth ? boundingRect.y - m_AdditionalWidth : 0; // add additional width to width of bounding rect (twice as x value was moved before) // and make sure that the bounding rect will stay inside the image borders) if ( static_cast<unsigned int>(boundingRect.x + boundingRect.width) + 2 * m_AdditionalWidth < static_cast<unsigned int>(mask.size().width) ) { boundingRect.width += 2 * m_AdditionalWidth; } else { boundingRect.width = mask.size().width - boundingRect.x - 1; } // add additional width to height of bounding rect (twice as y value was moved before) // and make sure that the bounding rect will stay inside the image borders) if ( static_cast<unsigned int>(boundingRect.y + boundingRect.height) + 2 * m_AdditionalWidth < static_cast<unsigned int>(mask.size().height) ) { boundingRect.height += 2 * m_AdditionalWidth; } else { boundingRect.height = mask.size().height - boundingRect.y - 1; } assert(boundingRect.x + boundingRect.width < mask.size().width); assert(boundingRect.y + boundingRect.height < mask.size().height); return boundingRect; }