33 #include "usVirtualServer.h"
42 : QObject(parent), m_tcpServer(), m_serverIsSendingImages(false), m_consoleListener()
46 m_volumePauseTmp =
false;
47 m_pauseDurationOffset = 0;
48 m_pauseIndexOffset = 0;
52 if (qApp->arguments().contains(QString(
"--pause"))) {
54 m_pauseImageNumber = qApp->arguments().at(qApp->arguments().indexOf(QString(
"--pause")) + 1).toInt();
55 std::cout <<
"Pause activated on image N. : " << m_pauseImageNumber <<
"\n";
58 if (qApp->arguments().contains(QString(
"--rewind"))) {
60 std::cout <<
"Rewind option activated\n";
65 setSequencePath(sequencePath);
69 connect(&m_tcpServer, SIGNAL(newConnection()),
this, SLOT(acceptTheConnection()));
76 connect(&m_consoleListener, SIGNAL(quitPause()),
this, SLOT(quitPause()));
79 QString portNum = QString::number(8080);
80 bool status = m_tcpServer.listen(QHostAddress::Any, portNum.toUShort());
84 std::cout <<
"TCP server Started\nServer now listening on port# " << portNum.toStdString() << std::endl;
86 std::cout <<
"TCP server start failure" << m_tcpServer.errorString().toStdString() << std::endl;
98 void usVirtualServer::acceptTheConnection()
101 connectionSoc = m_tcpServer.nextPendingConnection();
103 connect(connectionSoc, SIGNAL(readyRead()),
this, SLOT(readIncomingData()));
105 connect(connectionSoc, SIGNAL(disconnected()),
this, SLOT(connectionAboutToClose()));
111 void usVirtualServer::readIncomingData()
120 in.setDevice(connectionSoc);
121 #if defined(USTK_HAVE_VTK_QT4)
122 in.setVersion(QDataStream::Qt_4_8);
124 in.setVersion(QDataStream::Qt_5_0);
142 QDataStream out(&block, QIODevice::WriteOnly);
143 #if defined(USTK_HAVE_VTK_QT4)
144 out.setVersion(QDataStream::Qt_4_8);
146 out.setVersion(QDataStream::Qt_5_0);
149 out << confirmHeader.
initOk;
152 writeInitAcquisitionParameters(out, headerInit.
imagingMode);
154 connectionSoc->write(block);
155 }
else if (
id == 2) {
156 throw(vpException(vpException::fatalError,
"no update available for virtual server !"));
157 }
else if (
id == 3) {
163 std::cout <<
"ERROR : unknown data received !" << std::endl;
170 void usVirtualServer::connectionAboutToClose()
173 std::cout <<
"Connection to client closed" << std::endl;
176 connectionSoc->close();
179 #ifdef VISP_HAVE_XML2
186 setSequencePath(m_sequencePath);
192 void usVirtualServer::writeInitAcquisitionParameters(QDataStream &stream,
int imagingMode)
195 int transmitFrequency = 0;
196 int samplingFrequency = 0;
197 bool postScanMode =
false;
198 int postScanHeight = 0;
199 int postScanWidth = 0;
202 bool activateMotor =
false;
203 int motorPosition = 0;
204 int framesPerVolume = 1;
205 int stepsPerFrame = 0;
206 int transmitFrequencyMin = 0;
207 int samplingFrequencyMin = 0;
208 int imagingModeMin = 0;
209 int imageDepthMin = 0;
211 int motorPositionMin = 0;
212 int framesPerVolumeMin = 1;
213 int stepsPerFrameMin = 0;
214 int transmitFrequencyMax = 0;
215 int samplingFrequencyMax = 0;
216 int imagingModeMax = 27;
217 int imageDepthMax = 0;
219 int motorPositionMax = 0;
220 int framesPerVolumeMax = 0;
221 int stepsPerFrameMax = 0;
232 imageDepth = m_preScanImage2d.
getDepth();
233 imageDepthMin = m_preScanImage2d.
getDepth();
234 imageDepthMax = m_preScanImage2d.
getDepth();
244 imageDepth = m_postScanImage2d.
getDepth();
245 imageDepthMin = m_postScanImage2d.
getDepth();
246 imageDepthMax = m_postScanImage2d.
getDepth();
251 stream << transmitFrequency;
252 stream << samplingFrequency;
253 stream << imagingMode;
254 stream << postScanMode;
255 stream << postScanHeight;
256 stream << postScanWidth;
257 stream << imageDepth;
259 stream << activateMotor;
260 stream << motorPosition;
261 stream << framesPerVolume;
262 stream << stepsPerFrame;
263 stream << transmitFrequencyMin;
264 stream << samplingFrequencyMin;
265 stream << imagingModeMin;
266 stream << imageDepthMin;
268 stream << motorPositionMin;
269 stream << framesPerVolumeMin;
270 stream << stepsPerFrameMin;
271 stream << transmitFrequencyMax;
272 stream << samplingFrequencyMax;
273 stream << imagingModeMax;
274 stream << imageDepthMax;
276 stream << motorPositionMax;
277 stream << framesPerVolumeMax;
278 stream << stepsPerFrameMax;
286 void usVirtualServer::setSequencePath(
const std::string sequencePath)
289 if (vpIoTools::checkFilename(sequencePath)) {
291 m_sequencePath = sequencePath;
292 #ifdef VISP_HAVE_XML2
297 uint64_t timestampTmp;
298 m_sequenceReaderPostScan.
open(m_postScanImage2d, timestampTmp);
302 m_nextImageTimestamp) {
303 throw(vpException(vpException::fatalError),
"usVirtualServer error : successives timestamps are equal !");
306 m_isMHDSequence =
false;
310 uint64_t timestampTmp;
311 m_sequenceReaderPreScan.
open(m_preScanImage2d, timestampTmp);
315 m_nextImageTimestamp) {
316 throw(vpException(vpException::fatalError),
"usVirtualServer error : successives timestamps are equal !");
318 invertRowsColsOnPreScan();
320 m_isMHDSequence =
false;
322 throw(vpException(vpException::badValue),
"usVirtualServer error : trying to open a xml image sequence not "
323 "managed (neither pre-scan 2D nor post-scan 2D)or with no timestamp "
331 else if (vpIoTools::checkDirectory(sequencePath) &&
337 uint64_t timestampTmp;
338 m_MHDSequenceReader.
acquire(m_rfImage2d, timestampTmp);
341 if (imageHeader.
timeStamp == m_nextImageTimestamp)
342 throw(vpException(vpException::fatalError),
"usVirtualServer error : successives timestamps are equal !");
345 uint64_t timestampTmp;
346 m_MHDSequenceReader.
acquire(m_preScanImage2d, timestampTmp);
350 m_nextImageTimestamp)
351 throw(vpException(vpException::fatalError),
"usVirtualServer error : successives timestamps are equal !");
353 invertRowsColsOnPreScan();
356 uint64_t timestampTmp;
357 m_MHDSequenceReader.
acquire(m_postScanImage2d, timestampTmp);
361 m_nextImageTimestamp)
362 throw(vpException(vpException::fatalError),
"usVirtualServer error : successives timestamps are equal !");
365 m_timestamps.clear();
366 m_MHDSequenceReader.
acquire(m_rfImage3d, m_timestamps);
367 imageHeader.
timeStamp = m_timestamps.at(0);
368 m_nextImageTimestamp = m_timestamps.at(1);
369 if (imageHeader.
timeStamp == m_nextImageTimestamp)
370 throw(vpException(vpException::fatalError),
"usVirtualServer error : successives timestamps are equal !");
373 m_timestamps.clear();
374 m_MHDSequenceReader.
acquire(m_preScanImage3d, m_timestamps);
375 imageHeader.
timeStamp = m_timestamps.at(0);
376 m_nextImageTimestamp = m_timestamps.at(1);
377 if (imageHeader.
timeStamp == m_nextImageTimestamp)
378 throw(vpException(vpException::fatalError),
379 "usVirtualServer error : successives timestamps are equal !");
381 m_preScanImage3d.
getFrame(m_preScanImage2d, 0);
383 invertRowsColsOnPreScan();
385 throw(vpException(vpException::badValue),
"usVirtualServer error : trying to open a mhd image sequence "
386 "not managed, or with no timestamps associated to sequence "
394 m_isMHDSequence =
true;
396 throw(vpException(vpException::badValue,
"usVirtualServer error : sequence path incorrect !"));
403 void usVirtualServer::startSendingLoop()
406 sendingLoopSequenceMHD();
408 sendingLoopSequenceXml();
414 void usVirtualServer::sendingLoopSequenceXml()
416 #ifdef VISP_HAVE_XML2
417 bool endOfSequence =
false;
418 while (m_serverIsSendingImages && !endOfSequence) {
424 uint64_t localTimestamp;
425 m_sequenceReaderPreScan.
acquire(m_preScanImage2d, localTimestamp);
426 invertRowsColsOnPreScan();
427 imageHeader.
timeStamp = localTimestamp + m_pauseDurationOffset;
429 imageHeader.
frameCount + 1 - m_pauseIndexOffset)
430 m_nextImageTimestamp =
432 m_pauseDurationOffset;
435 uint64_t deltaT = m_nextImageTimestamp - imageHeader.
timeStamp;
436 m_nextImageTimestamp += deltaT;
438 m_pauseDurationOffset += deltaT;
439 m_pauseIndexOffset++;
442 if (imageHeader.
frameCount == m_pauseImageNumber)
445 uint64_t localTimestamp;
446 m_sequenceReaderPreScan.
acquire(m_preScanImage2d, localTimestamp);
447 invertRowsColsOnPreScan();
456 uint64_t localTimestamp;
457 m_sequenceReaderPreScan.
acquire(m_preScanImage2d, localTimestamp);
458 invertRowsColsOnPreScan();
461 imageHeader.
frameCount + 1 - m_pauseIndexOffset)
462 m_nextImageTimestamp =
466 uint64_t deltaT = m_nextImageTimestamp - imageHeader.
timeStamp;
467 m_nextImageTimestamp += deltaT;
469 m_pauseDurationOffset += deltaT;
470 m_pauseIndexOffset++;
473 if (imageHeader.
frameCount == m_pauseImageNumber)
476 uint64_t localTimestamp;
477 m_sequenceReaderPostScan.
acquire(m_postScanImage2d, localTimestamp);
485 if (m_usePause && imageHeader.
frameCount == m_pauseImageNumber)
488 if (m_usePause && m_pauseOn) {
489 uint64_t deltaT = 40;
490 m_nextImageTimestamp += deltaT;
492 m_pauseDurationOffset += deltaT;
494 m_pauseIndexOffset++;
501 QDataStream out(&block, QIODevice::WriteOnly);
502 #if defined(USTK_HAVE_VTK_QT4)
503 out.setVersion(QDataStream::Qt_4_8);
505 out.setVersion(QDataStream::Qt_5_0);
513 out << (int)m_preScanImage2d.getHeight() * m_preScanImage2d.getWidth();
516 out << m_preScanImage2d.getHeight();
517 out << m_preScanImage2d.getWidth();
525 out << (int)(m_postScanImage2d.
getDepth() / 1000.0);
530 out.writeRawData((
char *)m_preScanImage2d.bitmap,
531 (int)m_preScanImage2d.getHeight() * m_preScanImage2d.getWidth());
535 out << (int)m_postScanImage2d.getHeight() * m_postScanImage2d.getWidth();
538 out << m_postScanImage2d.getWidth();
539 out << m_postScanImage2d.getHeight();
547 out << (int)(m_postScanImage2d.
getDepth() / 1000.0);
552 out.writeRawData((
char *)m_postScanImage2d.bitmap,
553 (int)m_postScanImage2d.getHeight() * m_postScanImage2d.getWidth());
558 connectionSoc->write(block);
559 qApp->processEvents();
561 std::cout <<
"new frame sent, No " << imageHeader.
frameCount << std::endl;
565 vpTime::wait((
double)(m_nextImageTimestamp - imageHeader.
timeStamp));
568 throw(vpException(vpException::badValue),
569 "usVirtualServer error : cannot use xml sequence, xml2 dependency is missing !");
576 void usVirtualServer::sendingLoopSequenceMHD()
578 bool endOfSequence =
false;
579 while (m_serverIsSendingImages && !endOfSequence) {
587 unsigned int currentNumberOfWholeSequenceSent = 0;
588 if (imageHeader.
frameCount - m_pauseIndexOffset >=
590 currentNumberOfWholeSequenceSent =
595 if (currentNumberOfWholeSequenceSent == 0) {
599 uint64_t localTimestamp;
600 m_MHDSequenceReader.
acquire(m_rfImage2d, localTimestamp);
607 uint64_t tmpTimpstamp;
608 m_MHDSequenceReader.
getImage(imageIndex - 1, tmpImg, tmpTimpstamp);
610 m_nextImageTimestamp = (imageHeader.
timeStamp - tmpTimpstamp) + imageHeader.
timeStamp;
614 }
else if (currentNumberOfWholeSequenceSent % 2 == 0) {
621 uint64_t localTimestamp;
622 m_MHDSequenceReader.
getImage(imageIndex, m_rfImage2d, localTimestamp);
624 uint64_t previousTimestamp;
626 m_MHDSequenceReader.
getImage(imageIndex - 1, tmpImg, previousTimestamp);
627 uint64_t deltaTimestamp = localTimestamp - previousTimestamp;
631 uint64_t nextTimestamp;
632 uint64_t deltaTimestampNext;
635 m_MHDSequenceReader.
getImage(imageIndex + 1, tmpImg, nextTimestamp);
636 deltaTimestampNext = nextTimestamp - localTimestamp;
639 m_MHDSequenceReader.
getImage(imageIndex - 1, tmpImg, nextTimestamp);
640 deltaTimestampNext = localTimestamp - nextTimestamp;
642 m_nextImageTimestamp += deltaTimestampNext;
652 uint64_t localTimestamp;
653 m_MHDSequenceReader.
getImage(imageIndex, m_rfImage2d, localTimestamp);
655 uint64_t previousTimestamp;
657 m_MHDSequenceReader.
getImage(imageIndex + 1, tmpImg, previousTimestamp);
658 uint64_t deltaTimestamp = previousTimestamp - localTimestamp;
662 uint64_t nextTimestamp;
663 uint64_t deltaTimestampNext;
664 if (imageIndex != 0) {
666 m_MHDSequenceReader.
getImage(imageIndex - 1, tmpImg, nextTimestamp);
667 deltaTimestampNext = localTimestamp - nextTimestamp;
670 m_MHDSequenceReader.
getImage(imageIndex + 1, tmpImg, nextTimestamp);
671 deltaTimestampNext = nextTimestamp - localTimestamp;
673 m_nextImageTimestamp += deltaTimestampNext;
677 uint64_t localTimestamp;
678 m_MHDSequenceReader.
acquire(m_rfImage2d, localTimestamp);
679 imageHeader.
timeStamp = localTimestamp + m_pauseDurationOffset;
680 if (!m_MHDSequenceReader.
end())
681 m_nextImageTimestamp = m_MHDSequenceReader.
getNextTimeStamp() + m_pauseDurationOffset;
685 uint64_t deltaT = m_nextImageTimestamp - imageHeader.
timeStamp;
686 m_nextImageTimestamp += deltaT;
688 m_pauseDurationOffset += deltaT;
689 m_pauseIndexOffset++;
692 if (imageHeader.
frameCount == m_pauseImageNumber)
694 }
else if (m_useRewind) {
696 unsigned int currentNumberOfWholeSequenceSent = 0;
702 if (currentNumberOfWholeSequenceSent == 0) {
705 uint64_t localTimestamp;
706 m_MHDSequenceReader.
acquire(m_rfImage2d, localTimestamp);
713 uint64_t tmpTimpstamp;
714 m_MHDSequenceReader.
getImage(imageIndex - 1, tmpImg, tmpTimpstamp);
716 m_nextImageTimestamp = (imageHeader.
timeStamp - tmpTimpstamp) + imageHeader.
timeStamp;
720 }
else if (currentNumberOfWholeSequenceSent % 2 == 0) {
726 uint64_t localTimestamp;
727 m_MHDSequenceReader.
getImage(imageIndex, m_rfImage2d, localTimestamp);
729 uint64_t previousTimestamp;
731 m_MHDSequenceReader.
getImage(imageIndex - 1, tmpImg, previousTimestamp);
732 uint64_t deltaTimestamp = localTimestamp - previousTimestamp;
736 uint64_t nextTimestamp;
737 uint64_t deltaTimestampNext;
740 m_MHDSequenceReader.
getImage(imageIndex + 1, tmpImg, nextTimestamp);
741 deltaTimestampNext = nextTimestamp - localTimestamp;
744 m_MHDSequenceReader.
getImage(imageIndex - 1, tmpImg, nextTimestamp);
745 deltaTimestampNext = localTimestamp - nextTimestamp;
747 m_nextImageTimestamp += deltaTimestampNext;
756 uint64_t localTimestamp;
757 m_MHDSequenceReader.
getImage(imageIndex, m_rfImage2d, localTimestamp);
759 uint64_t previousTimestamp;
761 m_MHDSequenceReader.
getImage(imageIndex + 1, tmpImg, previousTimestamp);
762 uint64_t deltaTimestamp = previousTimestamp - localTimestamp;
766 uint64_t nextTimestamp;
767 uint64_t deltaTimestampNext;
768 if (imageIndex != 0) {
770 m_MHDSequenceReader.
getImage(imageIndex - 1, tmpImg, nextTimestamp);
771 deltaTimestampNext = localTimestamp - nextTimestamp;
774 m_MHDSequenceReader.
getImage(imageIndex + 1, tmpImg, nextTimestamp);
775 deltaTimestampNext = nextTimestamp - localTimestamp;
777 m_nextImageTimestamp += deltaTimestampNext;
781 uint64_t localTimestamp;
782 m_MHDSequenceReader.
acquire(m_rfImage2d, localTimestamp);
784 if (!m_MHDSequenceReader.
end())
793 unsigned int currentNumberOfWholeSequenceSent = 0;
794 if (imageHeader.
frameCount - m_pauseIndexOffset >=
796 currentNumberOfWholeSequenceSent =
801 if (currentNumberOfWholeSequenceSent == 0) {
805 uint64_t localTimestamp;
806 m_MHDSequenceReader.
acquire(m_preScanImage2d, localTimestamp);
807 invertRowsColsOnPreScan();
814 uint64_t tmpTimpstamp;
815 m_MHDSequenceReader.
getImage(imageIndex - 1, tmpImg, tmpTimpstamp);
817 m_nextImageTimestamp = (imageHeader.
timeStamp - tmpTimpstamp) + imageHeader.
timeStamp;
821 }
else if (currentNumberOfWholeSequenceSent % 2 == 0) {
828 uint64_t localTimestamp;
829 m_MHDSequenceReader.
getImage(imageIndex, m_preScanImage2d, localTimestamp);
830 invertRowsColsOnPreScan();
832 uint64_t previousTimestamp;
834 m_MHDSequenceReader.
getImage(imageIndex - 1, tmpImg, previousTimestamp);
835 uint64_t deltaTimestamp = localTimestamp - previousTimestamp;
839 uint64_t nextTimestamp;
840 uint64_t deltaTimestampNext;
843 m_MHDSequenceReader.
getImage(imageIndex + 1, tmpImg, nextTimestamp);
844 deltaTimestampNext = nextTimestamp - localTimestamp;
847 m_MHDSequenceReader.
getImage(imageIndex - 1, tmpImg, nextTimestamp);
848 deltaTimestampNext = localTimestamp - nextTimestamp;
850 m_nextImageTimestamp += deltaTimestampNext;
860 uint64_t localTimestamp;
861 m_MHDSequenceReader.
getImage(imageIndex, m_preScanImage2d, localTimestamp);
862 invertRowsColsOnPreScan();
864 uint64_t previousTimestamp;
866 m_MHDSequenceReader.
getImage(imageIndex + 1, tmpImg, previousTimestamp);
867 uint64_t deltaTimestamp = previousTimestamp - localTimestamp;
871 uint64_t nextTimestamp;
872 uint64_t deltaTimestampNext;
873 if (imageIndex != 0) {
875 m_MHDSequenceReader.
getImage(imageIndex - 1, tmpImg, nextTimestamp);
876 deltaTimestampNext = localTimestamp - nextTimestamp;
879 m_MHDSequenceReader.
getImage(imageIndex + 1, tmpImg, nextTimestamp);
880 deltaTimestampNext = nextTimestamp - localTimestamp;
882 m_nextImageTimestamp += deltaTimestampNext;
886 uint64_t localTimestamp;
887 m_MHDSequenceReader.
acquire(m_preScanImage2d, localTimestamp);
888 invertRowsColsOnPreScan();
889 imageHeader.
timeStamp = localTimestamp + m_pauseDurationOffset;
890 if (!m_MHDSequenceReader.
end())
891 m_nextImageTimestamp = m_MHDSequenceReader.
getNextTimeStamp() + m_pauseDurationOffset;
895 uint64_t deltaT = m_nextImageTimestamp - imageHeader.
timeStamp;
896 m_nextImageTimestamp += deltaT;
898 m_pauseDurationOffset += deltaT;
899 m_pauseIndexOffset++;
902 if (imageHeader.
frameCount == m_pauseImageNumber)
904 }
else if (m_useRewind) {
906 unsigned int currentNumberOfWholeSequenceSent = 0;
912 if (currentNumberOfWholeSequenceSent == 0) {
915 uint64_t localTimestamp;
916 m_MHDSequenceReader.
acquire(m_preScanImage2d, localTimestamp);
917 invertRowsColsOnPreScan();
924 uint64_t tmpTimpstamp;
925 m_MHDSequenceReader.
getImage(imageIndex - 1, tmpImg, tmpTimpstamp);
927 m_nextImageTimestamp = (imageHeader.
timeStamp - tmpTimpstamp) + imageHeader.
timeStamp;
931 }
else if (currentNumberOfWholeSequenceSent % 2 == 0) {
937 uint64_t localTimestamp;
938 m_MHDSequenceReader.
getImage(imageIndex, m_preScanImage2d, localTimestamp);
939 invertRowsColsOnPreScan();
941 uint64_t previousTimestamp;
943 m_MHDSequenceReader.
getImage(imageIndex - 1, tmpImg, previousTimestamp);
944 uint64_t deltaTimestamp = localTimestamp - previousTimestamp;
948 uint64_t nextTimestamp;
949 uint64_t deltaTimestampNext;
952 m_MHDSequenceReader.
getImage(imageIndex + 1, tmpImg, nextTimestamp);
953 deltaTimestampNext = nextTimestamp - localTimestamp;
956 m_MHDSequenceReader.
getImage(imageIndex - 1, tmpImg, nextTimestamp);
957 deltaTimestampNext = localTimestamp - nextTimestamp;
959 m_nextImageTimestamp += deltaTimestampNext;
968 uint64_t localTimestamp;
969 m_MHDSequenceReader.
getImage(imageIndex, m_preScanImage2d, localTimestamp);
970 invertRowsColsOnPreScan();
972 uint64_t previousTimestamp;
974 m_MHDSequenceReader.
getImage(imageIndex + 1, tmpImg, previousTimestamp);
975 uint64_t deltaTimestamp = previousTimestamp - localTimestamp;
979 uint64_t nextTimestamp;
980 uint64_t deltaTimestampNext;
981 if (imageIndex != 0) {
983 m_MHDSequenceReader.
getImage(imageIndex - 1, tmpImg, nextTimestamp);
984 deltaTimestampNext = localTimestamp - nextTimestamp;
987 m_MHDSequenceReader.
getImage(imageIndex + 1, tmpImg, nextTimestamp);
988 deltaTimestampNext = nextTimestamp - localTimestamp;
990 m_nextImageTimestamp += deltaTimestampNext;
994 uint64_t localTimestamp;
995 m_MHDSequenceReader.
acquire(m_preScanImage2d, localTimestamp);
996 invertRowsColsOnPreScan();
998 if (!m_MHDSequenceReader.
end())
1007 unsigned int currentNumberOfWholeSequenceSent = 0;
1008 if (imageHeader.
frameCount - m_pauseIndexOffset >=
1010 currentNumberOfWholeSequenceSent =
1015 if (currentNumberOfWholeSequenceSent == 0) {
1019 uint64_t localTimestamp;
1020 m_MHDSequenceReader.
acquire(m_postScanImage2d, localTimestamp);
1027 uint64_t tmpTimpstamp;
1028 m_MHDSequenceReader.
getImage(imageIndex - 1, tmpImg, tmpTimpstamp);
1030 m_nextImageTimestamp = (imageHeader.
timeStamp - tmpTimpstamp) + imageHeader.
timeStamp;
1034 }
else if (currentNumberOfWholeSequenceSent % 2 == 0) {
1041 uint64_t localTimestamp;
1042 m_MHDSequenceReader.
getImage(imageIndex, m_postScanImage2d, localTimestamp);
1044 uint64_t previousTimestamp;
1046 m_MHDSequenceReader.
getImage(imageIndex - 1, tmpImg, previousTimestamp);
1047 uint64_t deltaTimestamp = localTimestamp - previousTimestamp;
1048 imageHeader.
timeStamp += deltaTimestamp;
1051 uint64_t nextTimestamp;
1052 uint64_t deltaTimestampNext;
1055 m_MHDSequenceReader.
getImage(imageIndex + 1, tmpImg, nextTimestamp);
1056 deltaTimestampNext = nextTimestamp - localTimestamp;
1059 m_MHDSequenceReader.
getImage(imageIndex - 1, tmpImg, nextTimestamp);
1060 deltaTimestampNext = localTimestamp - nextTimestamp;
1062 m_nextImageTimestamp += deltaTimestampNext;
1072 uint64_t localTimestamp;
1073 m_MHDSequenceReader.
getImage(imageIndex, m_postScanImage2d, localTimestamp);
1075 uint64_t previousTimestamp;
1077 m_MHDSequenceReader.
getImage(imageIndex + 1, tmpImg, previousTimestamp);
1078 uint64_t deltaTimestamp = previousTimestamp - localTimestamp;
1079 imageHeader.
timeStamp += deltaTimestamp;
1082 uint64_t nextTimestamp;
1083 uint64_t deltaTimestampNext;
1084 if (imageIndex != 0) {
1086 m_MHDSequenceReader.
getImage(imageIndex - 1, tmpImg, nextTimestamp);
1087 deltaTimestampNext = localTimestamp - nextTimestamp;
1090 m_MHDSequenceReader.
getImage(imageIndex + 1, tmpImg, nextTimestamp);
1091 deltaTimestampNext = nextTimestamp - localTimestamp;
1093 m_nextImageTimestamp += deltaTimestampNext;
1097 uint64_t localTimestamp;
1098 m_MHDSequenceReader.
acquire(m_postScanImage2d, localTimestamp);
1099 imageHeader.
timeStamp = localTimestamp + m_pauseDurationOffset;
1100 if (!m_MHDSequenceReader.
end())
1101 m_nextImageTimestamp = m_MHDSequenceReader.
getNextTimeStamp() + m_pauseDurationOffset;
1105 uint64_t deltaT = m_nextImageTimestamp - imageHeader.
timeStamp;
1106 m_nextImageTimestamp += deltaT;
1108 m_pauseDurationOffset += deltaT;
1109 m_pauseIndexOffset++;
1112 if (imageHeader.
frameCount == m_pauseImageNumber)
1114 }
else if (m_useRewind) {
1116 unsigned int currentNumberOfWholeSequenceSent = 0;
1122 if (currentNumberOfWholeSequenceSent == 0) {
1125 uint64_t localTimestamp;
1126 m_MHDSequenceReader.
acquire(m_postScanImage2d, localTimestamp);
1133 uint64_t tmpTimpstamp;
1134 m_MHDSequenceReader.
getImage(imageIndex - 1, tmpImg, tmpTimpstamp);
1136 m_nextImageTimestamp = (imageHeader.
timeStamp - tmpTimpstamp) + imageHeader.
timeStamp;
1140 }
else if (currentNumberOfWholeSequenceSent % 2 == 0) {
1146 uint64_t localTimestamp;
1147 m_MHDSequenceReader.
getImage(imageIndex, m_postScanImage2d, localTimestamp);
1149 uint64_t previousTimestamp;
1151 m_MHDSequenceReader.
getImage(imageIndex - 1, tmpImg, previousTimestamp);
1152 uint64_t deltaTimestamp = localTimestamp - previousTimestamp;
1153 imageHeader.
timeStamp += deltaTimestamp;
1156 uint64_t nextTimestamp;
1157 uint64_t deltaTimestampNext;
1160 m_MHDSequenceReader.
getImage(imageIndex + 1, tmpImg, nextTimestamp);
1161 deltaTimestampNext = nextTimestamp - localTimestamp;
1164 m_MHDSequenceReader.
getImage(imageIndex - 1, tmpImg, nextTimestamp);
1165 deltaTimestampNext = localTimestamp - nextTimestamp;
1167 m_nextImageTimestamp += deltaTimestampNext;
1176 uint64_t localTimestamp;
1177 m_MHDSequenceReader.
getImage(imageIndex, m_postScanImage2d, localTimestamp);
1179 uint64_t previousTimestamp;
1181 m_MHDSequenceReader.
getImage(imageIndex + 1, tmpImg, previousTimestamp);
1182 uint64_t deltaTimestamp = previousTimestamp - localTimestamp;
1183 imageHeader.
timeStamp += deltaTimestamp;
1186 uint64_t nextTimestamp;
1187 uint64_t deltaTimestampNext;
1188 if (imageIndex != 0) {
1190 m_MHDSequenceReader.
getImage(imageIndex - 1, tmpImg, nextTimestamp);
1191 deltaTimestampNext = localTimestamp - nextTimestamp;
1194 m_MHDSequenceReader.
getImage(imageIndex + 1, tmpImg, nextTimestamp);
1195 deltaTimestampNext = nextTimestamp - localTimestamp;
1197 m_nextImageTimestamp += deltaTimestampNext;
1201 uint64_t localTimestamp;
1202 m_MHDSequenceReader.
acquire(m_postScanImage2d, localTimestamp);
1204 if (!m_MHDSequenceReader.
end())
1213 unsigned int currentNumberOfWholeSequenceSent = 0;
1215 if (imageHeader.
frameCount - m_pauseIndexOffset >=
1217 currentNumberOfWholeSequenceSent =
1218 ((imageHeader.
frameCount - m_pauseIndexOffset -
1224 if (currentNumberOfWholeSequenceSent == 0) {
1227 m_MHDSequenceReader.
getImage(volumeIndex, m_rfImage3d, m_timestamps);
1228 imageHeader.
timeStamp = m_timestamps.at(0);
1229 m_nextImageTimestamp = m_timestamps.at(1);
1232 }
else if (currentNumberOfWholeSequenceSent % 2 == 0) {
1233 int volumeIndex = (((imageHeader.
frameCount - m_pauseIndexOffset -
1239 m_MHDSequenceReader.
getImage(volumeIndex, m_rfImage3d, m_timestamps);
1243 ((imageHeader.
frameCount - m_pauseIndexOffset -
1248 m_MHDSequenceReader.
getImage(volumeIndex, m_rfImage3d, m_timestamps);
1252 m_MHDSequenceReader.
acquire(m_rfImage3d, m_timestamps);
1253 imageHeader.
timeStamp = m_timestamps.at(0) + m_pauseDurationOffset;
1254 m_nextImageTimestamp = m_timestamps.at(1) + m_pauseDurationOffset;
1261 m_MHDSequenceReader.
acquire(m_rfImage3dTemp,
1265 }
else if (m_useRewind) {
1267 unsigned int currentNumberOfWholeSequenceSent = 0;
1271 currentNumberOfWholeSequenceSent =
1277 if (currentNumberOfWholeSequenceSent == 0) {
1279 m_MHDSequenceReader.
acquire(m_rfImage3d, m_timestamps);
1280 imageHeader.
timeStamp = m_timestamps.at(0);
1281 m_nextImageTimestamp = m_timestamps.at(1);
1284 }
else if (currentNumberOfWholeSequenceSent % 2 == 0) {
1285 int volumeIndex = (((imageHeader.
frameCount -
1291 m_MHDSequenceReader.
getImage(volumeIndex, m_rfImage3d, m_timestamps);
1300 m_MHDSequenceReader.
getImage(volumeIndex, m_rfImage3d, m_timestamps);
1304 m_MHDSequenceReader.
acquire(m_rfImage3d, m_timestamps);
1305 imageHeader.
timeStamp = m_timestamps.at(0);
1306 m_nextImageTimestamp = m_timestamps.at(1);
1314 unsigned int currentNumberOfWholeSequenceSent = 0;
1316 if (imageHeader.
frameCount - m_pauseIndexOffset >=
1318 currentNumberOfWholeSequenceSent =
1319 ((imageHeader.
frameCount - m_pauseIndexOffset -
1325 if (currentNumberOfWholeSequenceSent == 0) {
1328 m_MHDSequenceReader.
getImage(volumeIndex, m_preScanImage3d, m_timestamps);
1329 imageHeader.
timeStamp = m_timestamps.at(0);
1330 m_nextImageTimestamp = m_timestamps.at(1);
1333 }
else if (currentNumberOfWholeSequenceSent % 2 == 0) {
1334 int volumeIndex = (((imageHeader.
frameCount - m_pauseIndexOffset -
1340 m_MHDSequenceReader.
getImage(volumeIndex, m_preScanImage3d, m_timestamps);
1344 ((imageHeader.
frameCount - m_pauseIndexOffset -
1349 m_MHDSequenceReader.
getImage(volumeIndex, m_preScanImage3d, m_timestamps);
1353 m_MHDSequenceReader.
acquire(m_preScanImage3d, m_timestamps);
1354 imageHeader.
timeStamp = m_timestamps.at(0) + m_pauseDurationOffset;
1355 m_nextImageTimestamp = m_timestamps.at(1) + m_pauseDurationOffset;
1362 m_MHDSequenceReader.
acquire(m_preScanImage3dTemp,
1366 }
else if (m_useRewind) {
1368 unsigned int currentNumberOfWholeSequenceSent = 0;
1372 currentNumberOfWholeSequenceSent =
1379 if (currentNumberOfWholeSequenceSent == 0) {
1381 m_MHDSequenceReader.
acquire(m_preScanImage3d, m_timestamps);
1382 imageHeader.
timeStamp = m_timestamps.at(0);
1383 m_nextImageTimestamp = m_timestamps.at(1);
1386 }
else if (currentNumberOfWholeSequenceSent % 2 == 0) {
1387 int volumeIndex = (((imageHeader.
frameCount -
1393 m_MHDSequenceReader.
getImage(volumeIndex, m_preScanImage3d, m_timestamps);
1402 m_MHDSequenceReader.
getImage(volumeIndex, m_preScanImage3d, m_timestamps);
1406 m_MHDSequenceReader.
acquire(m_preScanImage3d, m_timestamps);
1407 imageHeader.
timeStamp = m_timestamps.at(0);
1408 m_nextImageTimestamp = m_timestamps.at(1);
1414 if (m_usePause && imageHeader.
frameCount == m_pauseImageNumber)
1417 if (m_usePause && m_pauseOn) {
1418 uint64_t deltaT = 40;
1419 m_nextImageTimestamp += deltaT;
1421 m_pauseDurationOffset += deltaT;
1423 m_pauseIndexOffset++;
1431 QDataStream out(&block, QIODevice::WriteOnly);
1432 #if defined(USTK_HAVE_VTK_QT4)
1433 out.setVersion(QDataStream::Qt_4_8);
1435 out.setVersion(QDataStream::Qt_5_0);
1454 out << (int)(m_rfImage2d.
getDepth() * 1000.0);
1459 out.writeRawData((
char *)m_rfImage2d.bitmap, (int)m_rfImage2d.
getHeight() * m_rfImage2d.
getWidth() * 2);
1461 endOfSequence = m_MHDSequenceReader.
end() && !m_useRewind;
1463 connectionSoc->write(block);
1464 qApp->processEvents();
1466 std::cout <<
"new frame sent, No " << imageHeader.
frameCount << std::endl;
1471 vpTime::wait((
double)(m_nextImageTimestamp - imageHeader.
timeStamp));
1476 QDataStream out(&block, QIODevice::WriteOnly);
1477 #if defined(USTK_HAVE_VTK_QT4)
1478 out.setVersion(QDataStream::Qt_4_8);
1480 out.setVersion(QDataStream::Qt_5_0);
1487 out << (int)m_preScanImage2d.getHeight() * m_preScanImage2d.getWidth();
1490 out << m_preScanImage2d.getHeight();
1491 out << m_preScanImage2d.getWidth();
1499 out << (int)(m_preScanImage2d.
getDepth() * 1000.0);
1504 out.writeRawData((
char *)m_preScanImage2d.bitmap,
1505 (int)m_preScanImage2d.getHeight() * m_preScanImage2d.getWidth());
1507 endOfSequence = m_MHDSequenceReader.
end() && !m_useRewind;
1509 connectionSoc->write(block);
1510 qApp->processEvents();
1512 std::cout <<
"new frame sent, No " << imageHeader.
frameCount << std::endl;
1517 vpTime::wait((
double)(m_nextImageTimestamp - imageHeader.
timeStamp));
1522 QDataStream out(&block, QIODevice::WriteOnly);
1523 #if defined(USTK_HAVE_VTK_QT4)
1524 out.setVersion(QDataStream::Qt_4_8);
1526 out.setVersion(QDataStream::Qt_5_0);
1533 out << (int)m_postScanImage2d.getHeight() * m_postScanImage2d.getWidth();
1536 out << m_postScanImage2d.getWidth();
1537 out << m_postScanImage2d.getHeight();
1545 out << (int)(m_postScanImage2d.
getDepth() * 1000.0);
1550 out.writeRawData((
char *)m_postScanImage2d.bitmap,
1551 (int)m_postScanImage2d.getHeight() * m_postScanImage2d.getWidth());
1553 endOfSequence = m_MHDSequenceReader.
end() && !m_useRewind;
1555 connectionSoc->write(block);
1556 qApp->processEvents();
1558 std::cout <<
"new frame sent, No " << imageHeader.
frameCount << std::endl;
1563 vpTime::wait((
double)(m_nextImageTimestamp - imageHeader.
timeStamp));
1567 bool endOfVolume =
false;
1568 unsigned int currentFrameInVolume = 0;
1569 while (!endOfVolume) {
1571 QDataStream out(&block, QIODevice::WriteOnly);
1572 #if defined(USTK_HAVE_VTK_QT4)
1573 out.setVersion(QDataStream::Qt_4_8);
1575 out.setVersion(QDataStream::Qt_5_0);
1580 unsigned int framePositionInVolume;
1582 framePositionInVolume = m_rfImage3d.
getFrameNumber() - currentFrameInVolume - 1;
1584 framePositionInVolume = currentFrameInVolume;
1588 m_rfImage3dTemp.
getFrame(m_rfImage2d, framePositionInVolume);
1589 imageHeader.
timeStamp = m_timestampsTemp.at(currentFrameInVolume) + m_pauseDurationOffset;
1591 currentFrameInVolume + 1) {
1592 m_nextImageTimestamp =
1594 if (m_volumePauseTmp)
1597 m_nextImageTimestamp = m_timestampsTemp.at(currentFrameInVolume + 1) + m_pauseDurationOffset;
1599 m_rfImage3d.
getFrame(m_rfImage2d, framePositionInVolume);
1600 imageHeader.
timeStamp = m_timestamps.at(currentFrameInVolume) + m_pauseDurationOffset;
1601 if (m_rfImage3dTemp.
getFrameNumber() == currentFrameInVolume + 1)
1602 m_nextImageTimestamp = m_timestampsTemp.at(currentFrameInVolume + 1) +
1603 m_pauseDurationOffset;
1605 m_nextImageTimestamp = m_timestamps.at(currentFrameInVolume + 1) + m_pauseDurationOffset;
1608 uint64_t deltaT = m_nextImageTimestamp - imageHeader.
timeStamp;
1609 m_pauseDurationOffset += deltaT;
1610 m_pauseIndexOffset++;
1611 }
else if (m_useRewind) {
1613 unsigned int currentNumberOfWholeSequenceSent = 0;
1616 currentNumberOfWholeSequenceSent =
1622 if (currentNumberOfWholeSequenceSent == 0) {
1627 m_rfImage3d.
getFrame(m_rfImage2d, currentFrameInVolume);
1631 imageHeader.
timeStamp = m_timestamps.at(currentFrameInVolume) + m_pauseDurationOffset;
1633 if (m_MHDSequenceReader.
end()) {
1634 m_nextImageTimestamp = imageHeader.
timeStamp + (m_timestamps.at(currentFrameInVolume) -
1635 m_timestamps.at(currentFrameInVolume - 1));
1637 m_nextImageTimestamp =
1640 m_nextImageTimestamp =
1643 }
else if (m_timestamps.size() != currentFrameInVolume + 1)
1644 m_nextImageTimestamp = m_timestamps.at(currentFrameInVolume + 1);
1646 }
else if (currentNumberOfWholeSequenceSent % 2 == 0) {
1651 m_rfImage3d.
getFrame(m_rfImage2d, currentFrameInVolume);
1658 delta = m_timestamps.at(currentFrameInVolume) - m_timestamps.at(currentFrameInVolume - 1);
1660 }
else if (currentFrameInVolume == 0) {
1661 deltaNext = m_timestamps.at(currentFrameInVolume + 1) - m_timestamps.at(currentFrameInVolume);
1664 delta = m_timestamps.at(currentFrameInVolume) - m_timestamps.at(currentFrameInVolume - 1);
1665 deltaNext = m_timestamps.at(currentFrameInVolume + 1) - m_timestamps.at(currentFrameInVolume);
1668 m_nextImageTimestamp = imageHeader.
timeStamp + deltaNext;
1674 m_rfImage3d.
getFrame(m_rfImage2d, currentFrameInVolume);
1681 delta = m_timestamps.at(currentFrameInVolume) - m_timestamps.at(currentFrameInVolume - 1);
1683 }
else if (currentFrameInVolume == 0) {
1684 deltaNext = m_timestamps.at(currentFrameInVolume + 1) - m_timestamps.at(currentFrameInVolume);
1687 delta = m_timestamps.at(currentFrameInVolume) - m_timestamps.at(currentFrameInVolume - 1);
1688 deltaNext = m_timestamps.at(currentFrameInVolume + 1) - m_timestamps.at(currentFrameInVolume);
1691 m_nextImageTimestamp = imageHeader.
timeStamp + deltaNext;
1697 m_rfImage3d.
getFrame(m_rfImage2d, currentFrameInVolume);
1700 imageHeader.
timeStamp = m_timestamps.at(currentFrameInVolume) + m_pauseDurationOffset;
1702 if (m_MHDSequenceReader.
end())
1703 m_nextImageTimestamp = imageHeader.
timeStamp;
1706 m_pauseDurationOffset;
1709 m_pauseDurationOffset;
1711 }
else if (m_timestamps.size() != currentFrameInVolume + 1)
1712 m_nextImageTimestamp = m_timestamps.at(currentFrameInVolume + 1) + m_pauseDurationOffset;
1732 out << (int)(m_rfImage3d.
getDepth() * 1000.0);
1737 out.writeRawData((
char *)m_rfImage2d.bitmap, (int)m_rfImage2d.
getHeight() * m_rfImage2d.
getWidth() * 2);
1739 connectionSoc->write(block);
1740 qApp->processEvents();
1742 std::cout <<
"new frame sent, No " << imageHeader.
frameCount << std::endl;
1745 currentFrameInVolume++;
1746 endOfVolume = m_rfImage3d.
getFrameNumber() == currentFrameInVolume;
1747 endOfSequence = (m_MHDSequenceReader.
end() && endOfVolume && !m_useRewind);
1750 vpTime::wait((
double)(m_nextImageTimestamp - imageHeader.
timeStamp));
1753 bool endOfVolume =
false;
1754 unsigned int currentFrameInVolume = 0;
1755 while (!endOfVolume) {
1757 QDataStream out(&block, QIODevice::WriteOnly);
1758 #if defined(USTK_HAVE_VTK_QT4)
1759 out.setVersion(QDataStream::Qt_4_8);
1761 out.setVersion(QDataStream::Qt_5_0);
1766 unsigned int framePositionInVolume;
1768 framePositionInVolume = m_preScanImage3d.
getFrameNumber() - currentFrameInVolume - 1;
1770 framePositionInVolume = currentFrameInVolume;
1775 m_preScanImage3dTemp.
getFrame(m_preScanImage2d, framePositionInVolume);
1776 imageHeader.
timeStamp = m_timestampsTemp.at(currentFrameInVolume) + m_pauseDurationOffset;
1778 currentFrameInVolume + 1) {
1779 m_nextImageTimestamp =
1781 if (m_volumePauseTmp)
1784 m_nextImageTimestamp = m_timestampsTemp.at(currentFrameInVolume + 1) + m_pauseDurationOffset;
1786 m_preScanImage3d.
getFrame(m_preScanImage2d, framePositionInVolume);
1787 imageHeader.
timeStamp = m_timestamps.at(currentFrameInVolume) + m_pauseDurationOffset;
1789 currentFrameInVolume + 1)
1790 m_nextImageTimestamp = m_timestampsTemp.at(currentFrameInVolume + 1) +
1791 m_pauseDurationOffset;
1793 m_nextImageTimestamp = m_timestamps.at(currentFrameInVolume + 1) + m_pauseDurationOffset;
1795 invertRowsColsOnPreScan();
1797 uint64_t deltaT = m_nextImageTimestamp - imageHeader.
timeStamp;
1798 m_pauseDurationOffset += deltaT;
1799 m_pauseIndexOffset++;
1800 }
else if (m_useRewind) {
1802 unsigned int currentNumberOfWholeSequenceSent = 0;
1805 currentNumberOfWholeSequenceSent =
1812 if (currentNumberOfWholeSequenceSent == 0) {
1815 m_preScanImage3d.
getFrame(m_preScanImage2d, m_preScanImage3d.
getFrameNumber() - currentFrameInVolume - 1);
1817 m_preScanImage3d.
getFrame(m_preScanImage2d, currentFrameInVolume);
1820 invertRowsColsOnPreScan();
1823 imageHeader.
timeStamp = m_timestamps.at(currentFrameInVolume) + m_pauseDurationOffset;
1825 currentFrameInVolume + 1) {
1826 if (m_MHDSequenceReader.
end()) {
1827 m_nextImageTimestamp = imageHeader.
timeStamp + (m_timestamps.at(currentFrameInVolume) -
1828 m_timestamps.at(currentFrameInVolume - 1));
1830 m_nextImageTimestamp =
1833 m_nextImageTimestamp =
1836 }
else if (m_timestamps.size() != currentFrameInVolume + 1)
1837 m_nextImageTimestamp = m_timestamps.at(currentFrameInVolume + 1);
1839 }
else if (currentNumberOfWholeSequenceSent % 2 == 0) {
1842 m_preScanImage3d.
getFrame(m_preScanImage2d, m_preScanImage3d.
getFrameNumber() - currentFrameInVolume - 1);
1844 m_preScanImage3d.
getFrame(m_preScanImage2d, currentFrameInVolume);
1847 invertRowsColsOnPreScan();
1853 currentFrameInVolume + 1) {
1854 delta = m_timestamps.at(currentFrameInVolume) - m_timestamps.at(currentFrameInVolume - 1);
1856 }
else if (currentFrameInVolume == 0) {
1857 deltaNext = m_timestamps.at(currentFrameInVolume + 1) - m_timestamps.at(currentFrameInVolume);
1860 delta = m_timestamps.at(currentFrameInVolume) - m_timestamps.at(currentFrameInVolume - 1);
1861 deltaNext = m_timestamps.at(currentFrameInVolume + 1) - m_timestamps.at(currentFrameInVolume);
1864 m_nextImageTimestamp = imageHeader.
timeStamp + deltaNext;
1868 m_preScanImage3d.
getFrame(m_preScanImage2d, m_preScanImage3d.
getFrameNumber() - currentFrameInVolume - 1);
1870 m_preScanImage3d.
getFrame(m_preScanImage2d, currentFrameInVolume);
1873 invertRowsColsOnPreScan();
1879 currentFrameInVolume + 1) {
1880 delta = m_timestamps.at(currentFrameInVolume) - m_timestamps.at(currentFrameInVolume - 1);
1882 }
else if (currentFrameInVolume == 0) {
1883 deltaNext = m_timestamps.at(currentFrameInVolume + 1) - m_timestamps.at(currentFrameInVolume);
1886 delta = m_timestamps.at(currentFrameInVolume) - m_timestamps.at(currentFrameInVolume - 1);
1887 deltaNext = m_timestamps.at(currentFrameInVolume + 1) - m_timestamps.at(currentFrameInVolume);
1890 m_nextImageTimestamp = imageHeader.
timeStamp + deltaNext;
1894 m_preScanImage3d.
getFrame(m_preScanImage2d, m_preScanImage3d.
getFrameNumber() - currentFrameInVolume - 1);
1896 m_preScanImage3d.
getFrame(m_preScanImage2d, currentFrameInVolume);
1897 invertRowsColsOnPreScan();
1899 imageHeader.
timeStamp = m_timestamps.at(currentFrameInVolume) + m_pauseDurationOffset;
1900 if (m_preScanImage3d.
getFrameNumber() == currentFrameInVolume + 1) {
1901 if (m_MHDSequenceReader.
end())
1902 m_nextImageTimestamp = imageHeader.
timeStamp;
1905 m_pauseDurationOffset;
1908 m_pauseDurationOffset;
1910 }
else if (m_timestamps.size() != currentFrameInVolume + 1)
1911 m_nextImageTimestamp = m_timestamps.at(currentFrameInVolume + 1) + m_pauseDurationOffset;
1923 out << m_preScanImage3d.
getWidth();
1932 out << (int)(m_preScanImage3d.
getDepth() * 1000.0);
1933 out << (double)vpMath::deg(m_preScanImage3d.
getFramePitch());
1938 out.writeRawData((
char *)m_preScanImage2d.bitmap,
1939 (int)m_preScanImage2d.getHeight() * m_preScanImage2d.getWidth());
1941 connectionSoc->write(block);
1942 qApp->processEvents();
1944 std::cout <<
"new frame sent, No " << imageHeader.
frameCount << std::endl;
1947 currentFrameInVolume++;
1948 endOfVolume = m_preScanImage3d.
getFrameNumber() == currentFrameInVolume;
1949 endOfSequence = (m_MHDSequenceReader.
end() && endOfVolume && !m_useRewind);
1953 vpTime::wait((
double)(m_nextImageTimestamp - imageHeader.
timeStamp));
1962 void usVirtualServer::invertRowsColsOnPreScan()
1965 m_preScanImage2d.
resize(temp.getWidth(), temp.getHeight());
1967 for (
unsigned int i = 0; i < m_preScanImage2d.getHeight(); i++)
1968 for (
unsigned int j = 0; j < m_preScanImage2d.getWidth(); j++)
1969 m_preScanImage2d(i, j, temp(j, i));
1975 void usVirtualServer::runAcquisition(
bool run)
1977 m_serverIsSendingImages = run;
1986 void usVirtualServer::quitPause()
1991 m_volumePauseTmp =
true;
unsigned int getHeight() const
unsigned int getWidth() const
static usHeaderFormatType getHeaderFormat(const std::string &headerfilename)
double getHeightResolution() const
double getWidthResolution() const
void resize(const unsigned int h, const unsigned int w)
void getFrame(usImagePreScan2D< Type > &image, unsigned int index)
void setImagePreScanSettings(const usImagePreScanSettings &preScanSettings)
unsigned int getHeight() const
unsigned int getWidth() const
void getFrame(usImageRF2D< Type > &image, unsigned int index) const
unsigned int getWidth() const
unsigned int getHeight() const
void acquire(usImageRF2D< short int > &image, uint64_t ×tamp)
std::vector< uint64_t > getNextTimeStamps()
void getImage(unsigned int imageNumber, usImageRF2D< short int > &image, uint64_t ×tamp)
void setSequenceDirectory(const std::string sequenceDirectory)
us::ImageType getImageType() const
uint64_t getNextTimeStamp()
int getTotalImageNumber() const
unsigned int getFrameNumber() const
double getMotorRadius() const
double getFramePitch() const
usMotorType getMotorType() const
Reading of sequences of ultrasound images.
void open(ImageType &image, uint64_t ×tamp)
void acquire(ImageType &image)
void setSequenceFileName(const std::string &sequenceFileName)
std::vector< uint64_t > getSequenceTimestamps() const
int getTransmitFrequency() const
double getScanLinePitch() const
double getTransducerRadius() const
int getSamplingFrequency() const
unsigned int getScanLineNumber() const
void startSendingLoopSignal()
void runAcquisitionSignal(bool run)
usVirtualServer(std::string sequencePath, QObject *parent=0)