UsTK : Ultrasound ToolKit  version 2.0.1 under development (2025-01-22)
tutorial-local-grabbing-pre-scan2D-display.cpp
1 
3 #include <iostream>
4 #include <visp3/ustk_core/usConfig.h>
5 
6 #if defined(VISP_HAVE_MODULE_USTK_GUI) && defined(VISP_HAVE_MODULE_USTK_GRABBER)
7 
8 #include <visp3/ustk_grabber/usNetworkGrabberPreScan2D.h>
9 #include <visp3/ustk_gui/usImageDisplayWidgetRobotControl.h>
10 
11 #include <QApplication>
12 #include <QMainWindow>
13 
14 int main(int argc, char **argv)
15 {
16 
17  QApplication app(argc, argv);
18  app.setApplicationName(QString("USTK display widget"));
19 
20  // image
22 
23  // Qt widgets
25  widget->updateFrame(*preScan);
26  QMainWindow window;
27  window.setCentralWidget(widget);
28  window.show();
29 
30  // grabber
31  QThread *grabbingThread = new QThread();
33  // qtGrabber->setVerbose(true);
34  qtGrabber->setIPAddress("127.0.0.1"); // local loop, server must be running on same computer
35  qtGrabber->connectToServer();
37  header.probeId = 15; // 4DC7 id = 15
38  header.slotId = 0; // top slot id = 0
39  header.imagingMode = 0; // B-mode = 0
40  qtGrabber->initAcquisition(header);
41  qtGrabber->runAcquisition();
42  qtGrabber->moveToThread(grabbingThread);
43  grabbingThread->start();
44  // our grabbing loop
45  do {
46  if (qtGrabber->isFirstFrameAvailable()) {
47  preScan = qtGrabber->acquire();
48  widget->updateFrame(*preScan);
49  }
50  } while (window.isVisible());
51 
52  // disconnect from server
53  qtGrabber->disconnectFromServer();
54  grabbingThread->quit();
55  return 0;
56 }
57 
58 #else
59 int main()
60 {
61  std::cout << "You should build ustk_gui and ustk_grabber to run this tutorial" << std::endl;
62  return 0;
63 }
64 
65 #endif
Qt widget class for 2D ultrasound image display, containing robot control tools.
void updateFrame(const vpImage< unsigned char > img)
Specific class to grab pre-scan frames from the ultrasound station on the network.
usFrameGrabbedInfo< usImagePreScan2D< unsigned char > > * acquire()
bool initAcquisition(const usNetworkGrabber::usInitHeaderSent &header)
void setIPAddress(const std::string &s_ip)