bool ImageIcon::show(const Glib::ustring &fileName) { if (!Glib::file_test(fileName, Glib::FILE_TEST_EXISTS)) return false; gchar *fName = (gchar *)fileName.c_str(); //g_message("fname:%s\n", fName); if (Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)) { struct stat info; if (stat(fName, &info)) { Glib::ustring err = "cannot get file info"; showBrokenImage(err); return false; } long fileLen = info.st_size; if (fileLen > 0x150000L) { Glib::ustring err = "File too large"; showBrokenImage(err); return false; } } Glib::ustring svg = ".svg"; Glib::ustring svgz = ".svgz"; if (hasSuffix(fileName, svg) || hasSuffix(fileName, svgz) ) { if (!showSvgFile(fileName)) { showBrokenImage(bitmapError); return false; } return true; } else if (isValidImageIconFile(fileName)) { if (!showBitmap(fileName)) { showBrokenImage(bitmapError); return false; } return true; } else { showBrokenImage("unsupported file type"); return false; } }
/** Bitmap-Effekt */ void Effects::showAnimatedBitmap(byte animatedBitmap, byte duration, eColors color) { switch (animatedBitmap) { case ANI_BITMAP_CHAMPGLASS: for (byte i = 0; i < 6; i++) { showBitmap(BITMAP_CHAMPGLASS1 + i % 2, duration, color); } break; case ANI_BITMAP_CHRISTTREE: for (byte i = 0; i < 4; i++) { showBitmap(BITMAP_CHRISTTREE1 + i % 2, duration, color); } break; case ANI_BITMAP_SMILEY_WINK: showBitmap(BITMAP_SMILEY, 2 * duration, color); showBitmap(BITMAP_SMILEY_WINK, duration, color); showBitmap(BITMAP_SMILEY, duration, color); break; default: ; } }
/// \fixme This function is almost an exact duplicate of SVGPreview::set() in ui/dialog/filedialogimpl-gtkmm.cpp. bool ImageIcon::show(const Glib::ustring &fileName) { if (!Glib::file_test(fileName, Glib::FILE_TEST_EXISTS)) { showBrokenImage("File does not exist"); return false; } if (Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)) { gchar *fName = const_cast<gchar *>(fileName.c_str()); // this const-cast seems not necessary, was it put there because of older sys/stat.h version? struct stat info; if (stat(fName, &info)) // stat returns 0 upon success { showBrokenImage("Cannot get file info"); return false; } if (info.st_size > 0x150000L) { showBrokenImage("File too large"); return false; } } Glib::ustring svg = ".svg"; Glib::ustring svgz = ".svgz"; if (hasSuffix(fileName, svg) || hasSuffix(fileName, svgz)) { if (!showSvgFile(fileName)) { showBrokenImage(bitmapError); return false; } return true; } else if (isValidImageIconFile(fileName)) { if (!showBitmap(fileName)) { showBrokenImage(bitmapError); return false; } return true; } else { showBrokenImage("unsupported file type"); return false; } }
void CalibrateThread::run() { Size boardSize, imageSize; float squareSize = 1.f, aspectRatio = 1.f; Mat cameraMatrix, distCoeffs; //QString of = ui->lineEdit_WorkFolder->text() + '/' + ui->lineEdit_OutputName->text(); QByteArray ba = strFileName.toLatin1(); const char* outputFilename = ba.data(); int i, nframes = 0; bool writeExtrinsics = true, writePoints = true; bool undistortImage = false; int flags = 0; VideoCapture capture; bool flipVertical = false; bool showUndistorted = false; int delay = 1000; clock_t prevTimestamp = 0; int mode = CAPTURING; vector<vector<Point2f> > imagePoints; vector<string> imageList; Pattern pattern = CHESSBOARD; boardSize.width = m_width; boardSize.height = m_height; squareSize = m_squaresize; //ui->textEdit_Information->append("\nCalibrating... Please wait for a while\n"); if( imgList.size() == 0 ) { //QMessageBox::warning(NULL, "Error", "Please choose a right folder"); emit popupErrorInformation("Please choose a right folder"); emit closeImageWindow(); return; } else { nframes = imgList.size(); } emit appendText("\nCalibrating... Please wait for a while\n"); //namedWindow( "Image View", 1 ); //bDialog->show(); for(i = 0; i < nframes ;i++) { //ui->textEdit_Information->append("Processing the image No. " + QString::number(i + 1)); emit appendText("Processing the image No. " + QString::number(i + 1)); Mat view, viewGray; bool blink = false; qDebug(imgList.at(i).toLatin1().data()); if( i < (int)imgList.size() ) view = imread(imgList.at(i).toLatin1().data(), 1); if(!view.data) { //QMessageBox::warning(NULL, "Error", ); emit popupErrorInformation("Could not open image files"); return; } imageSize = view.size(); if( flipVertical ) flip( view, view, 0 ); vector<Point2f> pointbuf; cvtColor(view, viewGray, CV_BGR2GRAY); bool found; switch( pattern ) { case CHESSBOARD: found = findChessboardCorners( view, boardSize, pointbuf, CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FAST_CHECK | CV_CALIB_CB_NORMALIZE_IMAGE); break; case CIRCLES_GRID: found = findCirclesGrid( view, boardSize, pointbuf ); break; case ASYMMETRIC_CIRCLES_GRID: found = findCirclesGrid( view, boardSize, pointbuf, CALIB_CB_ASYMMETRIC_GRID ); break; } // improve the found corners' coordinate accuracy if( pattern == CHESSBOARD && found) cornerSubPix( viewGray, pointbuf, Size(11,11), Size(-1,-1), TermCriteria( CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, 30, 0.1 )); if( mode == CAPTURING && found && (!capture.isOpened() || clock() - prevTimestamp > delay*1e-3*CLOCKS_PER_SEC) ) { imagePoints.push_back(pointbuf); prevTimestamp = clock(); blink = capture.isOpened(); } if(found) drawChessboardCorners( view, boardSize, Mat(pointbuf), found ); string msg = mode == CAPTURING ? "100/100" : mode == CALIBRATED ? "Calibrated" : "Press 'g' to start"; int baseLine = 0; Size textSize = getTextSize(msg, 1, 1, 1, &baseLine); Point textOrigin(view.cols - 2*textSize.width - 10, view.rows - 2*baseLine - 10); if( mode == CAPTURING ) { if(undistortImage) msg = format( "%d/%d Undist", (int)imagePoints.size(), nframes ); else msg = format( "%d/%d", (int)imagePoints.size(), nframes ); } putText( view, msg, textOrigin, 1, 1, mode != CALIBRATED ? Scalar(0,0,255) : Scalar(0,255,0)); if( blink ) bitwise_not(view, view); if( mode == CALIBRATED && undistortImage ) { Mat temp = view.clone(); undistort(temp, view, cameraMatrix, distCoeffs); } Mat rgb; cvtColor(view, rgb, CV_BGR2RGB); QImage image32 = QImage(rgb.cols, rgb.rows, QImage::Format_RGB32); QRgb value; for(int r = 0; r < rgb.rows; r++) { for(int c = 0; c < rgb.cols; c++) { value = qRgb(rgb.ptr<uchar>(0)[r * rgb.cols * 3 + c * 3 + 0], rgb.ptr<uchar>(0)[r * rgb.cols * 3 + c * 3 + 1], rgb.ptr<uchar>(0)[r * rgb.cols * 3 + c * 3 + 2]); image32.setPixel(c, r, value); } } emit showBitmap(image32); int key; if(i < nframes - 1) { key = 0xff & waitKey(500); } else { key = waitKey(500); } if( (key & 255) == 27 ) break; if( key == 'u' && mode == CALIBRATED ) undistortImage = !undistortImage; } if(imagePoints.size() > 0) { emit appendText("\n" + QString::number(imagePoints.size()) + " out of " + QString::number(nframes) + " images are effective!\n" ); runAndSave(outputFilename, imagePoints, imageSize, boardSize, pattern, squareSize, aspectRatio, flags, cameraMatrix, distCoeffs, writeExtrinsics, writePoints); } else { emit appendText("Calibrating is not successful! \nPlease change the parameters and try again!"); emit popupErrorInformation("Sorry, no enough points are detected! Please try another group of images!"); emit closeImageWindow(); return; } emit appendText("Calibrating Successfully! \nPlease go to the folder to check the out put files!"); emit closeImageWindow(); if( !capture.isOpened() && showUndistorted ) { Mat view, rview, map1, map2; initUndistortRectifyMap(cameraMatrix, distCoeffs, Mat(), getOptimalNewCameraMatrix(cameraMatrix, distCoeffs, imageSize, 1, imageSize, 0), imageSize, CV_16SC2, map1, map2); for( i = 0; i < (int)imageList.size(); i++ ) { view = imread(imageList[i], 1); if(!view.data) continue; //undistort( view, rview, cameraMatrix, distCoeffs, cameraMatrix ); remap(view, rview, map1, map2, INTER_LINEAR); imshow("Image View", rview); int c = 0xff & waitKey(); if( (c & 255) == 27 || c == 'q' || c == 'Q' ) break; } } return; }
static void showInternalTaskInfo (rtems_id tid) { #ifdef __RTEMS_VIOLATE_KERNEL_VISIBILITY__ int epicsPri; Thread_Control *the_thread; Objects_Locations location; static Thread_Control thread; static char bitbuf[120]; static const struct bitmap taskState[] = { { "RUN", STATES_ALL_SET, STATES_READY }, { "DORM", STATES_DORMANT, STATES_DORMANT }, { "SUSP", STATES_SUSPENDED, STATES_SUSPENDED }, { "TRANS", STATES_TRANSIENT, STATES_TRANSIENT }, { "Delay", STATES_DELAYING, STATES_DELAYING }, { "Wtime", STATES_WAITING_FOR_TIME, STATES_WAITING_FOR_TIME }, { "Wbuf", STATES_WAITING_FOR_BUFFER, STATES_WAITING_FOR_BUFFER }, { "Wseg", STATES_WAITING_FOR_SEGMENT, STATES_WAITING_FOR_SEGMENT }, { "Wmsg" , STATES_WAITING_FOR_MESSAGE, STATES_WAITING_FOR_MESSAGE }, { "Wevnt", STATES_WAITING_FOR_EVENT, STATES_WAITING_FOR_EVENT }, { "Wsem", STATES_WAITING_FOR_SEMAPHORE,STATES_WAITING_FOR_SEMAPHORE }, { "Wmtx", STATES_WAITING_FOR_MUTEX, STATES_WAITING_FOR_MUTEX }, { "Wjoin", STATES_WAITING_FOR_JOIN_AT_EXIT,STATES_WAITING_FOR_JOIN_AT_EXIT }, { "Wrpc", STATES_WAITING_FOR_RPC_REPLY,STATES_WAITING_FOR_RPC_REPLY }, { "Wrate", STATES_WAITING_FOR_PERIOD, STATES_WAITING_FOR_PERIOD }, { "Wsig", STATES_WAITING_FOR_SIGNAL, STATES_WAITING_FOR_SIGNAL }, { NULL, 0, 0 }, }; the_thread = _Thread_Get (tid, &location); if (location != OBJECTS_LOCAL) { fprintf(epicsGetStdout(),"%-30s", " *** RTEMS task gone! ***"); return; } thread = *the_thread; _Thread_Enable_dispatch(); /* * Show both real and current priorities if they differ. * Note that the epicsThreadGetOsiPriorityValue routine is not used here. * If a thread has a priority outside the normal EPICS range then * that priority should be displayed, not the value truncated to * the EPICS range. */ epicsPri = 199-thread.real_priority; if (epicsPri < 0) fprintf(epicsGetStdout()," <0"); else if (epicsPri > 99) fprintf(epicsGetStdout()," >99"); else fprintf(epicsGetStdout()," %4d", epicsPri); if (thread.current_priority == thread.real_priority) fprintf(epicsGetStdout(),"%4d ", (int)thread.current_priority); else fprintf(epicsGetStdout(),"%4d/%-3d", (int)thread.real_priority, (int)thread.current_priority); showBitmap (bitbuf, thread.current_state, taskState); fprintf(epicsGetStdout(),"%8.8s", bitbuf); if (thread.current_state & (STATES_WAITING_FOR_SEMAPHORE | STATES_WAITING_FOR_MUTEX | STATES_WAITING_FOR_MESSAGE)) fprintf(epicsGetStdout()," %8.8x", (int)thread.Wait.id); else fprintf(epicsGetStdout()," %8.8s", ""); #endif }