UsTK : Ultrasound ToolKit  version 2.0.1 under development (2025-01-22)
tutorial-ustk-virtual-server-preScan3D.cpp
1 
3 #include <iostream>
4 #include <visp3/ustk_core/usConfig.h>
5 
6 #if (defined(USTK_HAVE_QT5) || defined(USTK_HAVE_VTK_QT)) && \
7  (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV))
8 
9 #include <QApplication>
10 #include <QtCore/QStringList>
11 #include <QtCore/QThread>
12 
13 #include <visp3/ustk_core/usMHDSequenceWriter.h>
14 #include <visp3/ustk_grabber/usNetworkGrabberPreScan3D.h>
15 
16 #include <visp3/gui/vpDisplayGDI.h>
17 #include <visp3/gui/vpDisplayOpenCV.h>
18 #include <visp3/gui/vpDisplayX.h>
19 
20 int main(int argc, char **argv)
21 {
22  // QT application
23  QApplication app(argc, argv);
24 
26  qtGrabber->setIPAddress("127.0.0.1"); // local loop, server must be running on same computer
27  qtGrabber->connectToServer();
28 
29  // record option
30  if (qApp->arguments().contains(QString("--output"))) {
31  qtGrabber->activateRecording(
32  qApp->arguments().at(qApp->arguments().indexOf(QString("--output")) + 1).toStdString());
33  }
34 
35  // setting acquisition parameters
37  header.probeId = 0; // 4DC7 id = 15
38  header.slotId = 0; // top slot id = 0
39  header.imagingMode = 0; // B-mode = 0
40 
42 
43  bool captureRunning = true;
44  // qtGrabber->setVerbose(true);
45  // sending acquisition parameters
46  qtGrabber->initAcquisition(header);
47  std::cout << "init success" << std::endl;
48  qtGrabber->runAcquisition();
49 
50  std::cout << "waiting ultrasound initialisation..." << std::endl;
51 
52  // our grabbing loop
53  do {
54  if (qtGrabber->isFirstFrameAvailable()) {
55  grabbedFrame = qtGrabber->acquire();
56 
57  std::cout << "MAIN THREAD received volume No : " << grabbedFrame->getVolumeCount() << std::endl;
58 
59  } else {
60  vpTime::wait(10);
61  }
62  } while (captureRunning);
63 
64  return app.exec();
65 }
66 
67 #else
68 int main()
69 {
70  std::cout << "You should intall Qt5 (with wigdets and network modules), and display X to run this tutorial"
71  << std::endl;
72  return 0;
73 }
74 
75 #endif
Specific class to grab pre-scan volumes from the ultrasound station on the network.
usVolumeGrabbedInfo< usImagePreScan3D< unsigned char > > * acquire()
void activateRecording(std::string path)
bool initAcquisition(const usNetworkGrabber::usInitHeaderSent &header)
void setIPAddress(const std::string &s_ip)
Class to store additionnal informations arriving on the network with ultrasound volumes grabbed,...
quint32 getVolumeCount() const