UsTK : Ultrasound ToolKit  version 2.0.1 under development (2025-02-01)
tutorial-elastography-3D-acquisition.cpp
1 
3 #include <iostream>
4 #include <visp3/ustk_core/usConfig.h>
5 
6 #if (defined(USTK_HAVE_QT5) || defined(USTK_HAVE_VTK_QT)) && defined(USTK_HAVE_FFTW)
7 
8 #include <QApplication>
9 #include <QtCore/QThread>
10 
11 #include <visp3/ustk_grabber/usNetworkGrabberRF3D.h>
12 
13 int main(int argc, char **argv)
14 {
15  // QT application
16  QApplication app(argc, argv);
17 
18  usNetworkGrabberRF3D *qtGrabber = new usNetworkGrabberRF3D();
19  qtGrabber->connectToServer();
20 
21  std::string preCompressedDirectory, postCompressedDirectory;
22 
23  // record directories
24  if (qApp->arguments().contains(QString("--preCompressed"))) {
25  preCompressedDirectory =
26  qApp->arguments().at(qApp->arguments().indexOf(QString("--preCompressed")) + 1).toStdString();
27  } else {
28  std::cout << "You need to specify the directory to record the pre-compressed volumes with --preCompressed option\n";
29  throw vpException(vpException::fatalError, "No output directory specified for pre-compressed volumes !");
30  }
31  if (qApp->arguments().contains(QString("--postCompressed"))) {
32  postCompressedDirectory =
33  qApp->arguments().at(qApp->arguments().indexOf(QString("--postCompressed")) + 1).toStdString();
34  } else {
35  std::cout
36  << "You need to specify the directory to record the post-compressed volumes with --postCompressed option\n";
37  throw vpException(vpException::fatalError, "No output directory specified for post-compressed volumes !");
38  }
39 
40  // setting acquisition parameters
42  header.probeId = 15; // 4DC7 id = 15
43  header.slotId = 0; // top slot id = 0
44  header.imagingMode = 12; // B-mode = 0, RF = 12
45 
46  // prepare image;
48 
49  // sending acquisition parameters
50  qtGrabber->initAcquisition(header);
51  qtGrabber->activateRecording(preCompressedDirectory);
53  qtGrabber->setFramesPerVolume(15);
54  qtGrabber->setMotorActivation(true);
55  qtGrabber->sendAcquisitionParameters();
56 
57  qtGrabber->runAcquisition();
58 
59  std::cout << "Start pre-compressed volumes acquisition" << std::endl;
60 
61  // our local grabbing loop
62  double t0 = vpTime::measureTimeMs();
63  do {
64  if (qtGrabber->isFirstFrameAvailable()) {
65  grabbedFrame = qtGrabber->acquire();
66 
67  std::cout << "MAIN THREAD received volume No : " << grabbedFrame->getVolumeCount() << std::endl;
68  }
69 
70  else {
71  vpTime::wait(10);
72  }
73  } while (vpTime::measureTimeMs() - t0 < 10000); // we wait 10sec
74 
75  qtGrabber->stopAcquisition();
76  qtGrabber->disconnectFromServer();
77 
78  // HERE we wait 5s that the user moves the probe down to acquire post-compressed volumes
79  std::cout << "NOW MOVE THE PROBE DOWN TO ACQUIRE POST-COMPRESSED FRAMES (5sec before next acquisition)" << std::endl;
80  vpTime::wait(5000);
81 
82  // Then we acquire another set of volumes for post-compression
83  delete qtGrabber;
84  qtGrabber = new usNetworkGrabberRF3D();
85  qtGrabber->connectToServer();
86 
87  // setting acquisition parameters
88  header.probeId = 15; // 4DC7 id = 15
89  header.slotId = 0; // top slot id = 0
90  header.imagingMode = 12; // B-mode = 0, RF = 12
91 
92  // sending acquisition parameters
93  qtGrabber->initAcquisition(header);
94  qtGrabber->activateRecording(postCompressedDirectory);
96  qtGrabber->setFramesPerVolume(15);
97  qtGrabber->setMotorActivation(true);
98  qtGrabber->sendAcquisitionParameters();
99  qtGrabber->runAcquisition();
100  std::cout << "Start post-compressed volumes acquisition" << std::endl;
101 
102  // our local grabbing loop
103  t0 = vpTime::measureTimeMs();
104  do {
105  if (qtGrabber->isFirstFrameAvailable()) {
106  grabbedFrame = qtGrabber->acquire();
107 
108  std::cout << "MAIN THREAD received volume No : " << grabbedFrame->getVolumeCount() << std::endl;
109  }
110 
111  else {
112  vpTime::wait(10);
113  t0 = vpTime::measureTimeMs();
114  }
115  } while (vpTime::measureTimeMs() - t0 < 10000); // we wait 10sec
116 
117  qtGrabber->stopAcquisition();
118 
119  return 0;
120 }
121 
122 #else
123 int main()
124 {
125  std::cout << "You should intall FFTW and Qt to run this tutorial" << std::endl;
126  return 0;
127 }
128 
129 #endif
@ US_ANGLE_PITCH_3
8 motor steps per frame = 1.4634 degrees
Specific class to grab RF volumes from the ultrasound station on the network.
void activateRecording(std::string path)
usVolumeGrabbedInfo< usImageRF3D< short int > > * acquire()
void setFramesPerVolume(int framesPerVolume)
bool initAcquisition(const usNetworkGrabber::usInitHeaderSent &header)
void setStepsPerFrame(usAcquisitionParameters::usMotorStep stepsPerFrame)
void setMotorActivation(bool activateMotor)
Class to store additionnal informations arriving on the network with ultrasound volumes grabbed,...
quint32 getVolumeCount() const