UsTK : Ultrasound ToolKit  version 2.0.1 under development (2025-03-12)
tutorial-ultrasonix-qt-grabbing-RF3D.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(VISP_HAVE_X11) || defined(VISP_HAVE_GDI)) && \
7  defined(USTK_HAVE_FFTW)
8 
9 #include <QApplication>
10 #include <QtCore/QThread>
11 
12 #include <visp3/ustk_core/usImageIo.h>
13 #include <visp3/ustk_core/usRFToPreScan3DConverter.h>
14 #include <visp3/ustk_grabber/usNetworkGrabberRF3D.h>
15 
16 int main(int argc, char **argv)
17 {
18  // QT application
19  QApplication app(argc, argv);
20 
21  usNetworkGrabberRF3D *qtGrabber = new usNetworkGrabberRF3D();
22  qtGrabber->connectToServer();
23  // qtGrabber->setVerbose(true);
24  // setting acquisition parameters
26  header.probeId = 15; // 4DC7 id = 15
27  header.slotId = 0; // top slot id = 0
28  header.imagingMode = 12; // B-mode = 0, RF = 12
29 
30  // prepare image;
32 
33  // prepare converter
35  usRFToPreScan3DConverter converter;
36 
37  bool captureRunning = true;
38 
39  // sending acquisition parameters
40  qtGrabber->initAcquisition(header);
41 
43  qtGrabber->setFramesPerVolume(25);
44  qtGrabber->setMotorActivation(true);
45  qtGrabber->sendAcquisitionParameters();
46 
47  qtGrabber->runAcquisition();
48 
49  std::cout << "waiting ultrasound initialisation..." << std::endl;
50 
51  // our local grabbing loop
52  do {
53  grabbedVolume = qtGrabber->acquire();
54 
55  std::cout << "MAIN THREAD received volume No : " << grabbedVolume->getVolumeCount() << std::endl;
56 
57  // convert RF to pre-scan to save the image
58  converter.convert(*grabbedVolume, preScanImage);
59 
60  QString filename = QString("volume") + QString::number(grabbedVolume->getVolumeCount()) + QString(".mhd");
61  usImageIo::write(preScanImage, filename.toStdString());
62  } while (captureRunning);
63 
64  qtGrabber->stopAcquisition();
65 
66  return 0;
67 }
68 
69 #else
70 int main()
71 {
72  std::cout << "You should intall Qt5 (with wigdets and network modules), FFTW and GDI or X11 to run this tutorial"
73  << std::endl;
74  return 0;
75 }
76 
77 #endif
@ US_ANGLE_PITCH_3
8 motor steps per frame = 1.4634 degrees
static void write(const usImageRF2D< short > &rfImage, const std::string &headerFileName, const std::string &imageExtension2D)
Definition: usImageIo.cpp:104
Specific class to grab RF volumes from the ultrasound station on the network.
usVolumeGrabbedInfo< usImageRF3D< short int > > * acquire()
void setFramesPerVolume(int framesPerVolume)
bool initAcquisition(const usNetworkGrabber::usInitHeaderSent &header)
void setStepsPerFrame(usAcquisitionParameters::usMotorStep stepsPerFrame)
void setMotorActivation(bool activateMotor)
3D conversion from RF signal to pre-scan image
void convert(const usImageRF3D< short int > &rfImage, usImagePreScan3D< unsigned char > &preScanImage)
Class to store additionnal informations arriving on the network with ultrasound volumes grabbed,...
quint32 getVolumeCount() const