UsTK : Ultrasound ToolKit  version 2.0.1 under development (2024-12-17)
tutorial-ultrasonix-qt-grabbing-post-scan.cpp
#include <iostream>
#include <visp3/ustk_core/usConfig.h>
#if (defined(USTK_HAVE_QT5) || defined(USTK_HAVE_VTK_QT)) && (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI))
#include <QApplication>
#include <QStringList>
#include <QtCore/QThread>
#include <visp3/ustk_grabber/usNetworkGrabberPostScan2D.h>
#include <visp3/gui/vpDisplayGDI.h>
#include <visp3/gui/vpDisplayX.h>
int main(int argc, char **argv)
{
// QT application
QApplication app(argc, argv);
qtGrabber->connectToServer();
// record option
if (qApp->arguments().contains(QString("--record"))) {
qtGrabber->activateRecording(
qApp->arguments().at(qApp->arguments().indexOf(QString("--record")) + 1).toStdString());
}
// setting acquisition parameters
if (qApp->arguments().contains(QString("--probeID"))) {
header.probeId = qApp->arguments().at(qApp->arguments().indexOf(QString("--probeID")) + 1).toInt();
} else
header.probeId = 15; // 4DC7 id = 15 by default
if (qApp->arguments().contains(QString("--slotID"))) {
header.slotId = qApp->arguments().at(qApp->arguments().indexOf(QString("--slotID")) + 1).toInt();
} else
header.slotId = 0; // top slot id = 0 by default
if (qApp->arguments().contains(QString("--imagingMode"))) {
header.imagingMode = qApp->arguments().at(qApp->arguments().indexOf(QString("--imagingMode")) + 1).toInt();
} else
header.imagingMode = 0; // B-mode = 0 by default
// Prepare display
#if defined(VISP_HAVE_X11)
vpDisplayX *display = NULL;
#elif defined(VISP_HAVE_GDI)
vpDisplayGDI *display = NULL;
#endif
bool displayInit = false;
bool captureRunning = true;
// sending acquisition parameters
qtGrabber->initAcquisition(header);
// grab a 640*480 post-scan image
qtGrabber->setPostScanMode(true);
qtGrabber->setPostScanHeigh(480);
qtGrabber->setPostScanWidth(640);
// set the ultrsound depth to 140 mm
qtGrabber->setImageDepth(140);
// set the 4DC7 motor on the middle frame
qtGrabber->setMotorPosition(37);
std::cout << "send update" << std::endl;
std::cout << "end update" << std::endl;
qtGrabber->runAcquisition();
std::cout << "waiting ultrasound initialisation..." << std::endl;
// our local grabbing loop
do {
grabbedFrame = qtGrabber->acquire();
std::cout << "MAIN THREAD received frame No : " << grabbedFrame->getFrameCount() << std::endl;
std::cout << *grabbedFrame << std::endl;
// init display
if (!displayInit && grabbedFrame->getHeight() != 0 && grabbedFrame->getWidth() != 0) {
#if defined(VISP_HAVE_X11)
display = new vpDisplayX(*grabbedFrame);
#elif defined(VISP_HAVE_GDI)
display = new vpDisplayGDI(*grabbedFrame);
#endif
qtGrabber->useVpDisplay(display);
displayInit = true;
}
// processing display
if (displayInit) {
if (vpDisplay::getClick(*grabbedFrame, false))
captureRunning = false;
vpDisplay::display(*grabbedFrame);
vpDisplay::displayText(*grabbedFrame, 20, 20, std::string("Click to exit..."), vpColor::red);
vpDisplay::flush(*grabbedFrame);
}
} while (captureRunning);
qtGrabber->stopAcquisition();
if (displayInit) {
delete display;
}
return 0;
}
#else
int main()
{
std::cout << "You should intall Qt5 (with wigdets and network modules), and display X to run this tutorial"
<< std::endl;
return 0;
}
#endif
Class to store additionnal informations arriving on the network with ultrasound images grabbed,...
quint32 getFrameCount() const
Specific class to grab post-scan frames from the ultrasound station on the network.
usFrameGrabbedInfo< usImagePostScan2D< unsigned char > > * acquire()
bool initAcquisition(const usNetworkGrabber::usInitHeaderSent &header)
void setPostScanWidth(int postScanWidth)
void setPostScanHeigh(int postScanHeigh)
void setPostScanMode(bool postScanMode)
void setImageDepth(int imageDepth)
void setMotorPosition(int motorPosition)
VISP_EXPORT void display(const usOrientedPlane3D &plane, const vpImage< ImageDataType > &I, const vpHomogeneousMatrix &imageMworld, double Xscale=3000, double Yscale=3000, const vpColor &color=vpColor::green)
Display usOrientedPlane3D.