Medical Imaging Interaction Toolkit  2023.12.00
Medical Imaging Interaction Toolkit
mitk::SegmentAnythingPythonService Class Reference

Segment Anything Model Python process handler class. More...

#include <mitkSegmentAnythingPythonService.h>

Inheritance diagram for mitk::SegmentAnythingPythonService:
Collaboration diagram for mitk::SegmentAnythingPythonService:

Public Types

enum  Status { READY, OFF, KILLED, CUDAError }
 

Public Member Functions

 SegmentAnythingPythonService (std::string, std::string, std::string, unsigned int)
 
 ~SegmentAnythingPythonService ()
 
virtual void SetMitkTempDir (std::string _arg)
 
virtual std::string GetMitkTempDir () const
 
void StartAsyncProcess ()
 Creates temp directories and calls start_python_daemon function async. More...
 
void StopAsyncProcess ()
 Writes KILL to the control file to stop the daemon process. More...
 
void TransferImageToProcess (const Image *, std::string &UId)
 Writes image as nifity file with unique id (UId) as file name. More...
 
void TransferPointsToProcess (std::stringstream &)
 Writes csv stringstream of points to a csv file for python daemon to read. More...
 
LabelSetImage::Pointer RetrieveImageFromProcess (long timeOut=-1)
 Waits for output nifity file from the daemon to appear and reads it as a mitk::Image. More...
 

Static Public Member Functions

static void onPythonProcessEvent (itk::Object *, const itk::EventObject &, void *)
 Static function to print out everything from itk::EventObject. Used as callback in mitk::ProcessExecutor object. More...
 
static bool CheckStatus ()
 Checks CurrentStatus enum variable and returns true if daemon is READY (to read files) state, false is OFF state or throws exception if daemon is found KILL or Cuda error state. More...
 

Static Public Attributes

static Status CurrentStatus
 

Detailed Description

Segment Anything Model Python process handler class.

Definition at line 30 of file mitkSegmentAnythingPythonService.h.

Member Enumeration Documentation

◆ Status

Enumerator
READY 
OFF 
KILLED 
CUDAError 

Definition at line 33 of file mitkSegmentAnythingPythonService.h.

Constructor & Destructor Documentation

◆ SegmentAnythingPythonService()

mitk::SegmentAnythingPythonService::SegmentAnythingPythonService ( std::string  ,
std::string  ,
std::string  ,
unsigned int   
)

◆ ~SegmentAnythingPythonService()

mitk::SegmentAnythingPythonService::~SegmentAnythingPythonService ( )

Member Function Documentation

◆ CheckStatus()

static bool mitk::SegmentAnythingPythonService::CheckStatus ( )
static

Checks CurrentStatus enum variable and returns true if daemon is READY (to read files) state, false is OFF state or throws exception if daemon is found KILL or Cuda error state.

Returns
bool

◆ GetMitkTempDir()

virtual std::string mitk::SegmentAnythingPythonService::GetMitkTempDir ( ) const
virtual

◆ onPythonProcessEvent()

static void mitk::SegmentAnythingPythonService::onPythonProcessEvent ( itk::Object *  ,
const itk::EventObject &  ,
void *   
)
static

Static function to print out everything from itk::EventObject. Used as callback in mitk::ProcessExecutor object.

◆ RetrieveImageFromProcess()

LabelSetImage::Pointer mitk::SegmentAnythingPythonService::RetrieveImageFromProcess ( long  timeOut = -1)

Waits for output nifity file from the daemon to appear and reads it as a mitk::Image.

Returns
Image::Pointer

◆ SetMitkTempDir()

virtual void mitk::SegmentAnythingPythonService::SetMitkTempDir ( std::string  _arg)
virtual

◆ StartAsyncProcess()

void mitk::SegmentAnythingPythonService::StartAsyncProcess ( )

Creates temp directories and calls start_python_daemon function async.

◆ StopAsyncProcess()

void mitk::SegmentAnythingPythonService::StopAsyncProcess ( )

Writes KILL to the control file to stop the daemon process.

◆ TransferImageToProcess()

void mitk::SegmentAnythingPythonService::TransferImageToProcess ( const Image ,
std::string &  UId 
)

Writes image as nifity file with unique id (UId) as file name.

◆ TransferPointsToProcess()

void mitk::SegmentAnythingPythonService::TransferPointsToProcess ( std::stringstream &  )

Writes csv stringstream of points to a csv file for python daemon to read.

Member Data Documentation

◆ CurrentStatus

Status mitk::SegmentAnythingPythonService::CurrentStatus
static

Definition at line 97 of file mitkSegmentAnythingPythonService.h.


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