This tutorial expains how to apply a confidence map algorithm in real-time on frames grabbed from ultrasonix station.
Note that the source code used in this tutorial can be downloaded using the following command :
The following code shows how to apply a confidence map algorithm on a pre-scan image grabbed in real-time, and display the result.
You will need Qt and X11 to run the following code.
#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/usNetworkGrabberPreScan2D.h>
#include <visp3/ustk_confidence_map/usScanlineConfidence2D.h>
#include <visp3/gui/vpDisplayGDI.h>
#include <visp3/gui/vpDisplayX.h>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
if (qApp->arguments().contains(QString("--probeID"))) {
header.
probeId = qApp->arguments().at(qApp->arguments().indexOf(QString(
"--probeID")) + 1).toInt();
} else
if (qApp->arguments().contains(QString("--slotID"))) {
header.
slotId = qApp->arguments().at(qApp->arguments().indexOf(QString(
"--slotID")) + 1).toInt();
} else
if (qApp->arguments().contains(QString("--imagingMode"))) {
header.
imagingMode = qApp->arguments().at(qApp->arguments().indexOf(QString(
"--imagingMode")) + 1).toInt();
} else
#if defined(VISP_HAVE_X11)
vpDisplayX *displayConf = NULL;
#elif defined(VISP_HAVE_GDI)
vpDisplayGDI *displayConf = NULL;
#endif
bool displayInit = false;
bool captureRunning = true;
do {
grabbedFrame = qtGrabber->
acquire();
confidenceProcessor.
run(confidence, *grabbedFrame);
std::cout <<
"MAIN THREAD received frame No : " << grabbedFrame->
getFrameCount() << std::endl;
std::cout << *grabbedFrame << std::endl;
if (!displayInit && grabbedFrame->getHeight() != 0 && grabbedFrame->getWidth() != 0) {
#if defined(VISP_HAVE_X11)
display =
new vpDisplayX(*grabbedFrame);
displayConf = new vpDisplayX(confidence);
#elif defined(VISP_HAVE_GDI)
display =
new vpDisplayGDI(*grabbedFrame);
displayConf = new vpDisplayGDI(confidence);
#endif
displayInit = true;
}
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);
vpDisplay::display(confidence);
vpDisplay::displayText(confidence, 20, 20, std::string("Click to exit..."), vpColor::red);
vpDisplay::flush(confidence);
}
} while (captureRunning);
if (displayInit) {
delete displayConf;
}
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 pre-scan frames from the ultrasound station on the network.
usFrameGrabbedInfo< usImagePreScan2D< unsigned char > > * acquire()
void useVpDisplay(vpDisplay *display)
bool initAcquisition(const usNetworkGrabber::usInitHeaderSent &header)
Process a pre-scan image to determine the confidence map.
void run(usImagePreScan2D< unsigned char > &preScanConfidence, const usImagePreScan2D< unsigned char > &preScanImage)