10 #include "PlusConfigure.h" 18 #include <vtkImageData.h> 19 #include <vtkObjectFactory.h> 21 #include <vtksys/SystemTools.hxx> 22 #include <vtkClientSocket.h> 28 #include <vtkPNGPrivate.h> 48 class vtkPlusBkProFocusOemVideoSource::vtkInternal
55 vtkSmartPointer<vtkClientSocket> VtkSocket;
56 std::vector<char> OemMessage;
59 vtkImageData* DecodedImageFrame;
61 std::vector<unsigned char> DecodingBuffer;
63 std::vector<png_bytep> DecodingLineBuffer;
70 this->DecodedImageFrame = vtkImageData::New();
73 virtual ~vtkInternal()
76 this->DecodedImageFrame->Delete();
77 this->DecodedImageFrame = NULL;
78 this->External = NULL;
87 this->
Internal =
new vtkInternal(
this);
152 LOG_TRACE(
"vtkPlusBkProFocusOemVideoSource::InternalConnect");
154 if (this->
Internal->Channel == NULL)
158 LOG_ERROR(
"Cannot connect: no output channel is specified for device " << this->
GetDeviceId());
166 this->
Internal->VtkSocket = vtkSmartPointer<vtkClientSocket>::New();
169 LOG_DEBUG(
"BK scanner OEM port: " << this->
OemPort);
174 LOG_INFO(
"Offline testing on");
179 LOG_DEBUG(
"Connecting to BK scanner");
183 LOG_ERROR(
"Could not connect to BKProFocusOem:" 185 <<
", OEM port = " << this->
OemPort);
188 LOG_DEBUG(
"Connected to BK scanner");
195 LOG_ERROR(
"Cound not init BK scanner");
205 LOG_DEBUG(
"Connected to BK scanner");
222 query =
"QUERY:GRAB_FRAME \"ON\",";
224 std::stringstream ss;
226 query += ss.str().c_str();
235 query +=
",\"OVERLAY\"";
240 LOG_DEBUG(
"Start data streaming. Query: " << query);
251 std::string query =
"QUERY:GRAB_FRAME \"OFF\";";
252 LOG_DEBUG(
"Stop data streaming. Query: " << query);
264 LOG_TRACE(
"Disconnect from BKProFocusOem");
275 if (this->
Internal->VtkSocket->GetConnected())
277 this->
Internal->VtkSocket->CloseSocket();
304 unsigned char* uncompressedPixelBuffer = 0;
305 unsigned int uncompressedPixelBufferSize = 0;
306 int numBytesProcessed = 0;
311 std::string query =
"query:capture_image \"PNG\";";
312 LOG_TRACE(
"Query from vtkPlusBkProFocusOemVideoSource: " << query);
323 size_t numBytesReceived = this->
Internal->OemMessage.size();
326 for (numBytesProcessed = 0; this->
Internal->OemMessage[numBytesProcessed] !=
'#' && numBytesProcessed < numBytesReceived; numBytesProcessed++)
330 int numChars = (
int)this->
Internal->OemMessage[numBytesProcessed] - (
int)(
'0');
332 LOG_TRACE(
"Number of bytes in the image size: " << numChars);
335 LOG_ERROR(
"Failed to read image from BK OEM interface");
339 for (
int k = 0; k < numChars; k++, numBytesProcessed++)
341 uncompressedPixelBufferSize = uncompressedPixelBufferSize * 10 + ((
int)this->
Internal->OemMessage[numBytesProcessed] -
'0');
343 LOG_TRACE(
"uncompressedPixelBufferSize = " << uncompressedPixelBufferSize);
345 uncompressedPixelBuffer = (
unsigned char*) & (this->
Internal->OemMessage[numBytesProcessed]);
353 timeStamp[k] = this->
Internal->OemMessage[numBytesProcessed];
356 unsigned int _timestamp = *(
int*)timeStamp;
368 this->
Internal->DecodedImageFrame->AllocateScalars(VTK_UNSIGNED_CHAR, 3);
370 (
unsigned char*) & (this->
Internal->OemMessage[numBytesProcessed]),
371 (
unsigned char*)this->Internal->DecodedImageFrame->GetScalarPointer());
375 this->
Internal->DecodedImageFrame->AllocateScalars(VTK_UNSIGNED_CHAR, 1);
376 std::memcpy(this->
Internal->DecodedImageFrame->GetScalarPointer(),
377 (
void*) & (this->
Internal->OemMessage[numBytesProcessed]),
378 uncompressedPixelBufferSize);
379 LOG_TRACE(uncompressedPixelBufferSize <<
" bytes copied, start at " << numBytesProcessed);
386 LOG_ERROR(
"Failed to decode received PNG image on channel " << this->
Internal->Channel->GetChannelId());
395 LOG_ERROR(
"Unable to retrieve the video source in the BKProFocusOem device on channel " << this->
Internal->Channel->GetChannelId());
401 LOG_DEBUG(
"Set up BK ProFocus image buffer");
402 int* frameDimensions = this->
Internal->DecodedImageFrame->GetDimensions();
403 if (frameDimensions[0] < 0 || frameDimensions[1] < 0 || frameDimensions[2] < 0)
405 LOG_ERROR(
"Invalid frame dimensions.");
408 FrameSizeType frameSizeInPix = { static_cast<unsigned int>(frameDimensions[0]), static_cast<unsigned int>(frameDimensions[1]), static_cast<unsigned int>(frameDimensions[2]) };
410 if (this->
Internal->DecodedImageFrame->GetNumberOfScalarComponents() == 1)
419 aSource->
SetInputFrameSize(frameSizeInPix[0], frameSizeInPix[1], frameSizeInPix[2]);
421 LOG_DEBUG(
"Frame size: " << frameSizeInPix[0] <<
"x" << frameSizeInPix[1]
422 <<
", pixel type: " << vtkImageScalarTypeNameMacro(this->
Internal->DecodedImageFrame->GetScalarType())
423 <<
", buffer image orientation: " << igsioCommon::GetStringFromUsImageOrientation(aSource->
GetInputImageOrientation()));
427 double spacingZ_mm = 1.0;
434 LOG_ERROR(
"Error adding item to video source " << aSource->
GetSourceId() <<
" on channel " << this->
Internal->Channel->GetChannelId());
447 LOG_TRACE(
"Before client read");
450 LOG_ERROR(
"Failed to read response from BK OEM interface");
455 std::istringstream replyStream(fullMessage);
457 std::string messageString;
458 std::getline(replyStream, messageString,
' ');
460 std::istringstream messageStream(messageString);
461 std::string messageType;
462 std::string messageName;
463 std::string messageSubtype;
464 std::getline(messageStream, messageType,
':');
465 std::getline(messageStream, messageName,
':');
466 std::getline(messageStream, messageSubtype,
':');
468 LOG_DEBUG(
"Process message from BK: " << fullMessage);
470 if (messageString.compare(
"DATA:CAPTURE_IMAGE") == 0)
474 else if (messageString.compare(
"DATA:GRAB_FRAME") == 0)
479 else if ((messageType.compare(
"DATA") == 0) || (messageType.compare(
"SDATA") == 0))
481 if (messageName.compare(
"US_WIN_SIZE") == 0)
485 else if ((messageName.compare(
"B_GEOMETRY_SCANAREA") == 0) && (messageSubtype.compare(
"A") == 0))
489 else if ((messageName.compare(
"B_GEOMETRY_PIXEL") == 0) && (messageSubtype.compare(
"A") == 0))
493 else if ((messageName.compare(
"B_GEOMETRY_TISSUE") == 0) && (messageSubtype.compare(
"A") == 0))
497 else if ((messageName.compare(
"B_GEOMETRY_US_FRAME_GRAB") == 0) && (messageSubtype.compare(
"A") == 0))
501 else if ((messageName.compare(
"B_GAIN") == 0) && (messageSubtype.compare(
"A") == 0))
505 else if (messageName.compare(
"TRANSDUCER_LIST") == 0)
509 else if ((messageName.compare(
"TRANSDUCER") == 0) && (messageSubtype.compare(
"A") == 0))
514 else if ((messageString.compare(
"EVENT:TRANSDUCER_CONNECT;") == 0)
515 || (messageString.compare(
"EVENT:TRANSDUCER_DISCONNECT;") == 0)
516 || (messageString.compare(
"EVENT:TRANSDUCER_SELECTED;") == 0))
520 else if (messageString.compare(
"EVENT:FREEZE;") == 0)
524 else if (messageString.compare(
"EVENT:UNFREEZE;") == 0)
526 LOG_DEBUG(
"Unfreeze");
528 else if (messageString.compare(
"ACK;") == 0)
530 LOG_DEBUG(
"Acknowledge message received");
534 LOG_WARNING(
"Received unknown message from BK: " << messageString);
544 std::string retval(this->
Internal->OemMessage.begin(), this->
Internal->OemMessage.end());
551 std::vector<char> rawMessage;
553 unsigned totalBytes = 0;
554 int receivedBytes = 1;
555 while (
character != EOT && receivedBytes >= 1)
557 receivedBytes = this->
Internal->VtkSocket->Receive(&character, 1);
563 receivedBytes = this->
Internal->VtkSocket->Receive(&character, 1);
564 if (receivedBytes == 1)
569 LOG_TRACE(
"Number of bytes in binary data block size: " << numChars);
570 if (numChars <= 1 || numChars >= 9)
572 LOG_ERROR(
"Error in binary data block from BK OEM interface. Incorrect character after block start (#): " <<
character <<
"(char num: " << (
int)
character <<
")" <<
" (should be 6 or 7) ");
577 unsigned int uncompressedPixelBufferSize = 0;
578 for (
int k = 0; k < numChars; k++, totalBytes++)
580 receivedBytes = this->
Internal->VtkSocket->Receive(&character, 1);
581 if (receivedBytes != 1)
583 LOG_ERROR(
"Error in binary data block from BK OEM interface. Missing block size character.");
586 uncompressedPixelBufferSize = uncompressedPixelBufferSize * 10 + ((
int)
character - (
int)
'0');
588 LOG_DEBUG(
"uncompressedPixelBufferSize = " << uncompressedPixelBufferSize);
590 int rawSize = rawMessage.size();
591 rawMessage.resize(rawSize + uncompressedPixelBufferSize);
592 receivedBytes = this->
Internal->VtkSocket->Receive(&rawMessage[rawSize], uncompressedPixelBufferSize,
true);
594 if (receivedBytes != uncompressedPixelBufferSize)
596 LOG_ERROR(
"Failed to read full binary data block from BK OEM interface receivedBytes: " << receivedBytes);
599 totalBytes += uncompressedPixelBufferSize;
605 totalBytes += receivedBytes;
610 LOG_ERROR(
"Error in binary data block from BK OEM interface. No character after block start #");
617 if (receivedBytes < 1)
619 LOG_ERROR(
"Error in binary data block from BK OEM interface. No data.");
631 int receivedBytes = this->
Internal->VtkSocket->Receive(&character, 1);
632 if (receivedBytes != 0 &&
character != EOT)
634 LOG_WARNING(
"Unspecified charactes received. Adding these to image.");
638 receivedBytes = receivedBytes + this->
Internal->VtkSocket->Receive(&character, 1);
640 LOG_DEBUG(
"Added additional characters to image: " << receivedBytes);
643 return receivedBytes;
649 std::vector<char> retval;
650 unsigned int inPos = 1;
651 while (inPos < inMessage.size() - 1)
653 if ((inMessage[inPos]) != ESC)
655 retval.push_back(inMessage[inPos++]);
660 retval.push_back(~inMessage[inPos++]);
709 LOG_DEBUG(
"Get ultrasound image size from BKProFocusOem");
711 std::string query =
"QUERY:US_WIN_SIZE;";
712 LOG_TRACE(
"Query from vtkPlusBkProFocusOemVideoSource: " << query);
719 std::string stringVal;
720 std::getline(replyStream, stringVal,
',');
722 std::getline(replyStream, stringVal,
';');
732 LOG_DEBUG(
"Get ultrasound geometry from BKProFocusOem");
734 std::string query =
"QUERY:B_GEOMETRY_SCANAREA:A;";
735 LOG_TRACE(
"Query from vtkPlusBkProFocusOemVideoSource: " << query);
743 std::string stringVal;
744 std::getline(replyStream, stringVal,
',');
746 std::getline(replyStream, stringVal,
',');
748 std::getline(replyStream, stringVal,
',');
750 std::getline(replyStream, stringVal,
',');
752 std::getline(replyStream, stringVal,
',');
754 std::getline(replyStream, stringVal,
',');
756 std::getline(replyStream, stringVal,
',');
758 std::getline(replyStream, stringVal,
';');
769 std::string query =
"QUERY:B_GEOMETRY_PIXEL:A;";
770 LOG_TRACE(
"Query from vtkPlusBkProFocusOemVideoSource: " << query);
778 std::string stringVal;
779 std::getline(replyStream, stringVal,
',');
781 std::getline(replyStream, stringVal,
',');
783 std::getline(replyStream, stringVal,
',');
785 std::getline(replyStream, stringVal,
';');
795 std::string query =
"QUERY:B_GEOMETRY_US_FRAME_GRAB:A;";
796 LOG_TRACE(
"Query from vtkPlusBkProFocusOemVideoSource: " << query);
804 std::string stringVal;
805 std::getline(replyStream, stringVal,
',');
807 std::getline(replyStream, stringVal,
',');
809 std::getline(replyStream, stringVal,
',');
811 std::getline(replyStream, stringVal,
';');
824 std::string query =
"QUERY:B_GEOMETRY_TISSUE:A;";
825 LOG_TRACE(
"Query from vtkPlusBkProFocusOemVideoSource: " << query);
833 std::string stringVal;
834 std::getline(replyStream, stringVal,
',');
836 std::getline(replyStream, stringVal,
',');
838 std::getline(replyStream, stringVal,
',');
840 std::getline(replyStream, stringVal,
';');
849 std::string query =
"QUERY:B_GAIN:A;";
850 LOG_TRACE(
"Query from vtkPlusBkProFocusOemVideoSource: " << query);
858 std::string stringVal;
859 std::getline(replyStream, stringVal,
';');
861 LOG_DEBUG(
"Ultrasound gain. gain_percent: " <<
gain_percent);
869 std::string query =
"QUERY:TRANSDUCER_LIST;";
870 LOG_TRACE(
"Query from vtkPlusBkProFocusOemVideoSource: " << query);
878 std::string probeName;
879 std::string probeType;
881 std::getline(replyStream, probeName,
',');
882 std::getline(replyStream, probeType,
',');
885 std::getline(replyStream, probeName,
',');
886 std::getline(replyStream, probeType,
',');
889 std::getline(replyStream, probeName,
',');
890 std::getline(replyStream, probeType,
',');
893 std::getline(replyStream, probeName,
',');
894 std::getline(replyStream, probeType,
';');
901 IGTLIO_PROBE_TYPE probeTypeEnum =
UNKNOWN;
903 if (probeTypeString.compare(
"C") == 0)
905 probeTypeEnum = SECTOR;
907 else if (probeTypeString.compare(
"L") == 0)
909 probeTypeEnum = LINEAR;
911 else if (probeTypeString.compare(
"M") == 0)
913 probeTypeEnum = MECHANICAL;
916 if (
port.compare(
"A") == 0)
920 else if (
port.compare(
"B") == 0)
924 else if (
port.compare(
"C") == 0)
928 else if (
port.compare(
"M") == 0)
938 std::istringstream inStream(inString);
939 std::getline(inStream, retval,
'"');
940 std::getline(inStream, retval,
'"');
949 std::string query =
"QUERY:TRANSDUCER:A;";
950 LOG_TRACE(
"Query from vtkPlusBkProFocusOemVideoSource: " << query);
958 std::string probePortString;
959 std::string probeName;
960 std::getline(replyStream, probePortString,
',');
961 std::getline(replyStream, probeName,
';');
969 std::string query =
"CONFIG:DATA:SUBSCRIBE ";
970 query +=
"\"US_WIN_SIZE\"";
971 query +=
",\"B_GEOMETRY_SCANAREA\"";
972 query +=
",\"B_GEOMETRY_PIXEL\"";
973 query +=
",\"B_GEOMETRY_US_FRAME_GRAB\"";
974 query +=
",\"B_GEOMETRY_TISSUE\"";
975 query +=
",\"B_GAIN\"";
976 query +=
",\"TRANSDUCER\"";
978 LOG_TRACE(
"Query from vtkPlusBkProFocusOemVideoSource: " << query);
987 std::string query =
"CONFIG:EVENTS 1;";
988 LOG_TRACE(
"Command from vtkPlusBkProFocusOemVideoSource: " << query);
1006 if (!this->
Internal->VtkSocket->Send(codedQuery.c_str(), codedQuery.size()))
1017 const char special[] = { SOH, EOT, ESC, 0 };
1019 for (
unsigned int i = 0;
i < query.size();
i++)
1022 if (NULL != strchr(special, ch))
1037 XML_READ_STRING_ATTRIBUTE_REQUIRED(
ScannerAddress, deviceConfig);
1038 XML_READ_SCALAR_ATTRIBUTE_REQUIRED(
int,
OemPort, deviceConfig);
1040 XML_READ_BOOL_ATTRIBUTE_OPTIONAL(
ColorEnabled, deviceConfig);
1050 XML_WRITE_STRING_ATTRIBUTE_IF_NOT_EMPTY(
ScannerAddress, deviceConfig);
1051 std::stringstream ss;
1053 deviceConfig->SetAttribute(
"OemPort", ss.str().c_str());
1066 LOG_WARNING(
"vtkPlusBkProFocusOemVideoSource is expecting one output channel and there are " << this->
OutputChannels.size() <<
" channels. First output channel will be used.");
1071 LOG_ERROR(
"No output channels defined for vtkPlusBkProFocusOemVideoSource. Cannot proceed.");
1084 if (png_ptr->io_ptr == NULL)
1086 LOG_ERROR(
"ReadDataFromInputStream failed, no input pointer is set");
1087 png_error(png_ptr,
"ReadDataFromInputStream failed, no input pointer is set");
1091 unsigned char* bufferPointer = (
unsigned char*)png_ptr->io_ptr;
1092 memcpy(outBytes, bufferPointer, byteCountToRead);
1093 bufferPointer += byteCountToRead;
1095 png_ptr->io_ptr = bufferPointer;
1101 LOG_ERROR(
"PNG error: " << (
message ?
message :
"no details available"));
1107 LOG_WARNING(
"PNG warning: " << (
message ?
message :
"no details available"));
1113 std::vector<unsigned char> fileReadBuffer;
1119 LOG_ERROR(
"Failed to read png");
1122 fseek(fp, 0, SEEK_END);
1123 size_t fileSizeInBytes = ftell(fp);
1125 fileReadBuffer.resize(fileSizeInBytes);
1126 pngBuffer = &(fileReadBuffer[0]);
1127 fread(pngBuffer, 1, fileSizeInBytes, fp);
1131 unsigned int headerSize = 8;
1132 unsigned char* header = pngBuffer;
1133 int is_png = !png_sig_cmp(header, 0, headerSize);
1136 LOG_ERROR(
"Invalid PNG header");
1140 png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL, NULL, NULL);
1143 LOG_ERROR(
"Failed to decode PNG buffer");
1147 png_infop info_ptr = png_create_info_struct(png_ptr);
1150 png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
1151 LOG_ERROR(
"Failed to decode PNG buffer");
1155 png_infop end_info = png_create_info_struct(png_ptr);
1158 png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
1159 LOG_ERROR(
"Failed to decode PNG buffer");
1166 if (setjmp(png_jmpbuf(png_ptr)))
1168 png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
1169 LOG_ERROR(
"Failed to decode PNG buffer");
1176 png_set_sig_bytes(png_ptr, 8);
1177 png_read_info(png_ptr, info_ptr);
1180 int bit_depth, color_type, interlace_type;
1181 int compression_type, filter_method;
1183 png_get_IHDR(png_ptr, info_ptr,
1185 &bit_depth, &color_type, &interlace_type,
1186 &compression_type, &filter_method);
1190 if (color_type == PNG_COLOR_TYPE_PALETTE)
1192 png_set_palette_to_rgb(png_ptr);
1196 if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
1198 #if PNG_LIBPNG_VER >= 10400 1199 png_set_expand_gray_1_2_4_to_8(png_ptr);
1201 png_set_gray_1_2_4_to_8(png_ptr);
1206 if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
1208 png_set_tRNS_to_alpha(png_ptr);
1213 #ifndef VTK_WORDS_BIGENDIAN 1214 png_set_swap(png_ptr);
1222 png_read_update_info(png_ptr, info_ptr);
1224 int rowbytes = png_get_rowbytes(png_ptr, info_ptr);
1226 unsigned char* tempImage = &(this->
Internal->DecodingBuffer[0]);
1228 this->
Internal->DecodingLineBuffer.resize(height);
1229 png_bytep* row_pointers = &(this->
Internal->DecodingLineBuffer[0]);
1230 for (
unsigned int ui = 0; ui <
height; ++ui)
1232 row_pointers[ui] = tempImage + rowbytes * ui;
1234 png_read_image(png_ptr, row_pointers);
1236 int numberOfScalarComponents = png_get_channels(png_ptr, info_ptr);
1238 if (
width * numberOfScalarComponents != rowbytes)
1240 LOG_WARNING(
"There is padding at the end of PNG lines, image may be skewed");
1243 decodedImage->SetExtent(0,
width - 1, 0,
height - 1, 0, 0);
1247 numberOfScalarComponents = 1;
1250 int bitDepth = png_get_bit_depth(png_ptr, info_ptr);
1251 #if (VTK_MAJOR_VERSION < 6) 1254 decodedImage->SetScalarTypeToUnsignedChar();
1258 decodedImage->SetScalarTypeToUnsignedShort();
1260 decodedImage->SetNumberOfScalarComponents(numberOfScalarComponents);
1261 decodedImage->AllocateScalars();
1265 decodedImage->AllocateScalars(VTK_UNSIGNED_CHAR, numberOfScalarComponents);
1269 decodedImage->AllocateScalars(VTK_UNSIGNED_SHORT, numberOfScalarComponents);
1281 unsigned char*
destination = (
unsigned char*)decodedImage->GetScalarPointer();
1282 for (
unsigned int i = 0;
i <
width *
height * numberOfScalarComponents; ++
i)
1289 png_read_end(png_ptr, NULL);
1290 png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
1300 this->
FrameFields[IGTLIO_KEY_PROBE_TYPE].first = FRAMEFIELD_FORCE_SERVER_SEND;
1303 igsioCommon::JoinTokensIntoString<double>(this->
CalculateOrigin(), output,
' ');
1304 this->
FrameFields[IGTLIO_KEY_ORIGIN].first = FRAMEFIELD_FORCE_SERVER_SEND;
1305 this->
FrameFields[IGTLIO_KEY_ORIGIN].second = output;
1306 igsioCommon::JoinTokensIntoString<double>(this->
CalculateAngles(), output,
' ');
1307 this->
FrameFields[IGTLIO_KEY_ANGLES].first = FRAMEFIELD_FORCE_SERVER_SEND;
1308 this->
FrameFields[IGTLIO_KEY_ANGLES].second = output;
1310 this->
FrameFields[IGTLIO_KEY_BOUNDING_BOX].first = FRAMEFIELD_FORCE_SERVER_SEND;
1311 this->
FrameFields[IGTLIO_KEY_BOUNDING_BOX].second = output;
1312 igsioCommon::JoinTokensIntoString<double>(this->
CalculateDepths(), output,
' ');
1313 this->
FrameFields[IGTLIO_KEY_DEPTHS].first = FRAMEFIELD_FORCE_SERVER_SEND;
1314 this->
FrameFields[IGTLIO_KEY_DEPTHS].second = output;
1315 this->
FrameFields[IGTLIO_KEY_LINEAR_WIDTH].first = FRAMEFIELD_FORCE_SERVER_SEND;
1318 this->
FrameFields[IGTLIO_KEY_SPACING_X].first = FRAMEFIELD_FORCE_SERVER_SEND;
1320 this->
FrameFields[IGTLIO_KEY_SPACING_Y].first = FRAMEFIELD_FORCE_SERVER_SEND;
1334 std::vector<double> retval;
1335 int* dimensions = this->
Internal->DecodedImageFrame->GetDimensions();
1336 double originX = dimensions[0] / 2.0;
1352 originY = 0 - (originHeightAboveBox_mm / this->
GetSpacingY());
1357 retval.push_back(originX);
1358 retval.push_back(originY);
1359 retval.push_back(originZ);
1366 std::vector<double> retval;
1369 retval.push_back(0);
1370 retval.push_back(0);
1377 retval.push_back(0);
1378 retval.push_back(0);
1385 std::vector<double> retval;
1387 int* dimensions = this->
Internal->DecodedImageFrame->GetDimensions();
1389 retval.push_back(0);
1390 retval.push_back(dimensions[0] - 1);
1391 retval.push_back(0);
1392 retval.push_back(dimensions[1] - 1);
1393 retval.push_back(0);
1394 retval.push_back(0);
1401 std::vector<double> retval;
1404 int* dimensions = this->
Internal->DecodedImageFrame->GetDimensions();
1405 double* spacing = this->
Internal->DecodedImageFrame->GetSpacing();
1406 retval.push_back(0);
1407 retval.push_back(dimensions[1] * spacing[1]);
1411 double originDistanceToStartLine_mm = 0.0;
1422 double depthStart = this->
GetStartDepth() + originDistanceToStartLine_mm;
1423 double depthEnd = this->
GetStopDepth() + originDistanceToStartLine_mm;
1425 retval.push_back(depthStart);
1426 retval.push_back(depthEnd);
1435 int* dimensions = this->
Internal->DecodedImageFrame->GetDimensions();
1436 double* spacing = this->
Internal->DecodedImageFrame->GetSpacing();
1437 return dimensions[0] * spacing[0];
1447 bool sectorProbe =
false;
1459 return width_radians;
1526 double spacingX_mm = 0.1;
1548 double spacingY_mm = 0.1;
PlusStatus ProcessMessagesAndReadNextImage()
virtual void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
void ParseGeometryPixel(std::istringstream &replyStream)
virtual PlusStatus InternalDisconnect()
PhidgetLCD_Font const char * character
PlusStatus QueryGeometryUsGrabFrame()
void ParseGeometryTissue(std::istringstream &replyStream)
US_IMAGE_TYPE GetImageType()
virtual std::vector< double > CalculateAngles() override
int grabFramePixelRight_pix
#define XML_FIND_DEVICE_ELEMENT_REQUIRED_FOR_WRITING(deviceConfig, rootConfigElement)
std::string RemoveQuotationMarks(std::string inString)
Class for acquiring ultrasound images from BK ultrasound systems through the OEM interface.
double GetStopLineAngle()
std::string GetSourceId() const
int grabFramePixelLeft_pix
PlusStatus ConfigEventsOn()
std::string ScannerAddress
PlusStatus QueryImageSize()
virtual std::string GetDeviceId() const
double StartLineAngle_rad
PlusStatus SetInputFrameSize(unsigned int x, unsigned int y, unsigned int z)
int grabFramePixelBottom_pix
virtual PlusStatus AddItem(vtkImageData *frame, US_IMAGE_ORIENTATION usImageOrientation, US_IMAGE_TYPE imageType, long frameNumber, double unfilteredTimestamp=UNDEFINED_TIMESTAMP, double filteredTimestamp=UNDEFINED_TIMESTAMP, const igsioFieldMapType *customFields=NULL)
void ParseTransducerList(std::istringstream &replyStream)
double CalculateWidthInRadians()
static PlusStatus ConvertToBGR24(ComponentOrdering outputOrdering, PixelEncoding inputCompression, int width, int height, unsigned char *s, unsigned char *d)
PlusStatus StopContinuousDataStreaming()
virtual PlusStatus InternalConnect()
bool RequireImageOrientationInConfiguration
virtual unsigned int GetNumberOfScalarComponents()
PlusStatus SetImageType(US_IMAGE_TYPE imageType)
PlusStatus StartContinuousDataStreaming()
bool ContinuousStreamingEnabled
char * OfflineTestingFilePath
PlusStatus SetPixelType(igsioCommon::VTKScalarPixelType pixelType)
PlusStatus InternalUpdate()
std::string ReadBufferIntoString()
PlusStatus QueryTransducer()
PlusStatus RequestParametersFromScanner()
void PngErrorCallback(png_structp png_ptr, png_const_charp message)
void SetProbeTypeForPort(std::string port, std::string probeTypeString)
virtual std::vector< double > CalculateDepths() override
PlusStatus QueryGeometryScanarea()
virtual PlusStatus Disconnect()
PlusStatus SubscribeToParameterChanges()
unsigned long FrameNumber
vtkPlusBkProFocusOemVideoSource()
virtual IGTLIO_PROBE_TYPE GetProbeType() override
void PngWarningCallback(png_structp png_ptr, png_const_charp message)
void ParseGain(std::istringstream &replyStream)
void ParseGeometryScanarea(std::istringstream &replyStream)
~vtkPlusBkProFocusOemVideoSource()
virtual PlusStatus WriteConfiguration(vtkXMLDataElement *config)
void ParseTransducerData(std::istringstream &replyStream)
PlusStatus QueryGeometryTissue()
virtual PlusStatus StopRecording()
PlusStatus QueryGeometryPixel()
IGTLIO_PROBE_TYPE probeTypePortA
igsioFieldMapType FrameFields
Container to hold calculated field values.
#define XML_FIND_DEVICE_ELEMENT_REQUIRED_FOR_READING(deviceConfig, rootConfigElement)
vtkStandardNewMacro(vtkPlusBkProFocusOemVideoSource)
PhidgetLCD_Font int * width
virtual std::vector< double > CalculateOrigin() override
PlusStatus AddParametersToFrameFields()
virtual US_IMAGE_ORIENTATION GetInputImageOrientation()
static const int TIMESTAMP_SIZE
std::array< unsigned int, 2 > UltrasoundWindowSize
virtual PlusStatus InternalStartRecording()
bool StartThreadForInternalUpdates
int addAdditionalBinaryDataToImageUntilEOTReached(char &character, std::vector< char > &rawMessage)
static PlusStatus ConvertToGray(int inputCompression, int width, int height, unsigned char *s, unsigned char *d)
PhidgetLCD_Font int int * height
PlusStatus QueryTransducerList()
static const char * KEY_DEPTH
virtual std::vector< double > CalculateBoundingBox() override
double CalculateDepthMm()
Contains an optional timestamped circular buffer containing the video images and a number of timestam...
static const char * KEY_GAIN
ChannelContainer OutputChannels
void ParseGeometryUsGrabFrame(std::istringstream &replyStream)
PlusStatus SetNumberOfScalarComponents(unsigned int numberOfScalarComponents)
double GetStartLineAngle()
IGTLIO_PROBE_TYPE probeTypePortC
PlusStatus DecodePngImage(unsigned char *pngBuffer, unsigned int pngBufferSize, vtkImageData *decodedImage)
virtual void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
virtual PlusStatus NotifyConfigured()
std::vector< char > removeSpecialCharacters(std::vector< char > inMessage)
IGTLIO_PROBE_TYPE probeTypePortM
int grabFramePixelTop_pix
virtual PlusStatus InternalUpdate()
void ParseImageSize(std::istringstream &replyStream)
PlusStatus ReadNextMessage()
virtual PlusStatus InternalStopRecording()
virtual int GetNumberOfItems()
virtual PlusStatus ReadConfiguration(vtkXMLDataElement *config)
IGTLIO_PROBE_TYPE probeTypePortB
PlusStatus SendQuery(std::string query)
std::string AddSpecialCharacters(std::string query)
virtual double CalculateLinearWidth() override
void ReadDataFromByteArray(png_structp png_ptr, png_bytep outBytes, png_size_t byteCountToRead)
Interface to a 3D positioning tool, video source, or generalized data stream.