Hola compañeros muy buenas, se me presento este pequeño problema con Qtcreator, lo que necesito hacer es que un boton realice dos acciones, para poder hacer el "LiveCamera" con una secuencia de fotos se me occurrio hacer un while infinito que no pare de tomar las fotos, pero no entiendo bien como puedo hacerle para que al hacer click en ese mismo boton pare o haga un ´break´ al while
Esta es mi interfaz y en el boton "LiveCamera" hacer lo ya mencionado.
este es el codigo
void MainWindow::on_pushButton_12_clicked()
{
ui->pushButton->setEnabled(false);
ui->pushButton_14->setEnabled(false);
ui->pushButton_3->setEnabled(false);
if( ui->pushButton_12->text() == "LiveCamera")
{
ui->pushButton_12->setText("LiveCamera!");
}
else
{
ui->pushButton_12->setText("Stop");
}
while(1)
{
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
HIDS hCam = 0;
SENSORINFO sInfo;
HWND hWndDisplay;
char* pcImageMemory;
int DisplayWidth, DisplayHeight;
is_InitCamera(&hCam, hWndDisplay);
// You can query information about the sensor type used in the camera
is_GetSensorInfo(hCam, &sInfo);
// Saving the information about the max. image proportions in variables
DisplayWidth = sInfo.nMaxWidth;
DisplayHeight = sInfo.nMaxHeight;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Need to find out the memory size of the pixel and the colour mode
int nColorMode;
int nBitsPerPixel = 24;
if (sInfo.nColorMode == IS_COLORMODE_BAYER)
{
// For color camera models use RGB24 mode
nColorMode = IS_CM_BGR8_PACKED;
nBitsPerPixel = 24;
}
else if (sInfo.nColorMode == IS_COLORMODE_CBYCRY)
{
// For CBYCRY camera models use RGB32 mode
nColorMode = IS_CM_BGRA8_PACKED;
nBitsPerPixel = 32;
}
else
{
// For monochrome camera models use Y8 mode
nColorMode = IS_CM_MONO16;
nBitsPerPixel = 24;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int nMemoryId;
// Assigns a memory for the image and sets it active
is_AllocImageMem(hCam, DisplayWidth, DisplayHeight, nBitsPerPixel, &pcImageMemory, &nMemoryId);
is_SetImageMem(hCam, pcImageMemory, nMemoryId);
// Acquires a single image from the camera
is_FreezeVideo(hCam, IS_WAIT);
int t = 1;
// Parameter definition for saving the image file
IMAGE_FILE_PARAMS ImageFileParams;
QString Q1 = "/home/pi/Pictures/";
QString Img = "LC";
QString Num = QString::number(t);
QString Q2 = ".bmp";
QString Total = Q1 + Img + Num + Q2;
//qDebug() << Total;
wchar_t *Array = new wchar_t[Total.length() + 1];
Total.toWCharArray(Array);
Array[Total.length()] = 0;
qDebug() << Total;
//ImageFileParams.pwchFileName = //L"/home/pi/Pictures/TestImage1"<< (wchar_t*)t<< L".bmp"; // <-- Insert name and location of the image
ImageFileParams.pwchFileName = Array;
ImageFileParams.pnImageID = NULL;
ImageFileParams.ppcImageMem = NULL;
ImageFileParams.nQuality = 0;
ImageFileParams.nFileType = IS_IMG_BMP;
// Saves the image file
if (is_ImageFile(hCam, IS_IMAGE_FILE_CMD_SAVE, (void*)&ImageFileParams, sizeof(ImageFileParams)) == IS_SUCCESS)
{
qDebug() <<"An Image was saved";
}
else
{
qDebug() <<"something went wrong";
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Releases an image memory that was allocated
is_FreeImageMem(hCam, pcImageMemory, nMemoryId);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
QPixmap pixmap(Total);
ui->label->setPixmap(pixmap);
ui->label->setScaledContents(true);
QApplication::processEvents();
delete[] Array;
//qDebug() << Total;
// Disables the hCam camera handle and releases the data structures and memory areas taken up by the uEye camera
is_ExitCamera(hCam);
if(is_ExitCamera(hCam))
{
const char *tot = Total.toAscii();
remove(tot);
}
}
ui->pushButton->setEnabled(true);
ui->pushButton_14->setEnabled(true);
ui->pushButton_3->setEnabled(true);
ui->pushButton_12->setText("LiverCamera!");
}