void TestGPURayCaster::testSetImages() { vtkImageDataPtr data = vtkImageData::New(); cx::ImagePtr image1(new cx::Image("i1", data)); cx::ImagePtr image2(new cx::Image("i2", data)); cx::ImagePtr image3(new cx::Image("i3", data)); cx::ImagePtr image4(new cx::Image("i4", data)); cx::ImagePtr image5(new cx::Image("i5", data)); std::vector<cx::ImagePtr> images; uint64_t mTime = mRep->mActor->GetMTime(); images.push_back(image1); CPPUNIT_ASSERT_EQUAL((size_t)0, mRep->getImages().size()); mRep->setImages(images); CPPUNIT_ASSERT_EQUAL((size_t)1, mRep->getImages().size()); CPPUNIT_ASSERT_EQUAL(QString("i1"), mRep->getImages()[0]->getUid()); CPPUNIT_ASSERT(mRep->mActor->GetMTime() > mTime); mTime = mRep->mActor->GetMTime(); mRep->setImages(images); uint64_t mNewTime = mRep->mActor->GetMTime(); CPPUNIT_ASSERT_EQUAL(mTime, mNewTime); images.push_back(image2); images.push_back(image3); images.push_back(image4); images.push_back(image5); mRep->setImages(images); CPPUNIT_ASSERT_EQUAL((size_t)4, mRep->getImages().size()); CPPUNIT_ASSERT_EQUAL(QString("i1"), mRep->getImages()[0]->getUid()); CPPUNIT_ASSERT_EQUAL(QString("i2"), mRep->getImages()[1]->getUid()); CPPUNIT_ASSERT_EQUAL(QString("i3"), mRep->getImages()[2]->getUid()); CPPUNIT_ASSERT_EQUAL(QString("i4"), mRep->getImages()[3]->getUid()); }
int Product::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; #ifndef QT_NO_PROPERTIES if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QString*>(_v) = id(); break; case 1: *reinterpret_cast< QString*>(_v) = description(); break; case 2: *reinterpret_cast< QString*>(_v) = longdescription(); break; case 3: *reinterpret_cast< QString*>(_v) = longtext(); break; case 4: *reinterpret_cast< QString*>(_v) = image1(); break; case 5: *reinterpret_cast< QString*>(_v) = image2(); break; case 6: *reinterpret_cast< QString*>(_v) = image3(); break; case 7: *reinterpret_cast< QString*>(_v) = catid(); break; case 8: *reinterpret_cast< QString*>(_v) = subcatid(); break; } _id -= 9; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setId(*reinterpret_cast< QString*>(_v)); break; case 1: setDescription(*reinterpret_cast< QString*>(_v)); break; case 2: setLongDescription(*reinterpret_cast< QString*>(_v)); break; case 3: setLongText(*reinterpret_cast< QString*>(_v)); break; case 4: setImage1(*reinterpret_cast< QString*>(_v)); break; case 5: setImage2(*reinterpret_cast< QString*>(_v)); break; case 6: setImage2(*reinterpret_cast< QString*>(_v)); break; case 7: setCatId(*reinterpret_cast< QString*>(_v)); break; case 8: setSubCatId(*reinterpret_cast< QString*>(_v)); break; } _id -= 9; } else if (_c == QMetaObject::ResetProperty) { _id -= 9; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 9; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 9; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 9; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 9; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 9; } else if (_c == QMetaObject::RegisterPropertyMetaType) { if (_id < 9) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 9; } #endif // QT_NO_PROPERTIES return _id; }
void ImageTest::testShortImage() { debug(LOG_DEBUG, DEBUG_LOG, 0, "testShortImage() begin"); Image<unsigned short> image2(640, 480); convertImage(image2, *image); CPPUNIT_ASSERT(image2.pixel(13, 15) == ((13 + 15 * 640) % 160) * 256); Image<unsigned char> image3(640,480); convertImage(image3, image2); CPPUNIT_ASSERT(image3 == *image); image3.pixel(14, 15) = 1; CPPUNIT_ASSERT(!(image3 == *image)); debug(LOG_DEBUG, DEBUG_LOG, 0, "testShortImage() end"); }
void MultiVolumeRaycaster::updateResult(DataContainer& dataContainer) { ImageRepresentationGL::ScopedRepresentation image1(dataContainer, p_sourceImage1.getValue()); ImageRepresentationGL::ScopedRepresentation image2(dataContainer, p_sourceImage2.getValue()); ImageRepresentationGL::ScopedRepresentation image3(dataContainer, p_sourceImage3.getValue()); ScopedTypedData<CameraData> camera(dataContainer, p_camera.getValue()); ScopedTypedData<RenderData> geometryImage(dataContainer, p_geometryImageId.getValue(), true); ScopedTypedData<LightSourceData> light(dataContainer, p_lightId.getValue()); std::vector<const ImageRepresentationGL*> images; if (image1) { images.push_back(image1); if (getInvalidationLevel() & INVALID_VOXEL_HIERARCHY1){ _vhm1->createHierarchy(image1, p_transferFunction1.getTF()); validate(INVALID_VOXEL_HIERARCHY1); } } if (image2) { images.push_back(image2); if (getInvalidationLevel() & INVALID_VOXEL_HIERARCHY2){ _vhm2->createHierarchy(image2, p_transferFunction2.getTF()); validate(INVALID_VOXEL_HIERARCHY2); } } if (image3) { images.push_back(image3); if (getInvalidationLevel() & INVALID_VOXEL_HIERARCHY3){ _vhm3->createHierarchy(image3, p_transferFunction3.getTF()); validate(INVALID_VOXEL_HIERARCHY3); } } if (images.size() >= 3 && camera != nullptr) { auto eepp = computeEntryExitPoints(images, camera, geometryImage); dataContainer.addData(p_outputImageId.getValue() + ".entrypoints", eepp.first); dataContainer.addData(p_outputImageId.getValue() + ".exitpoints", eepp.second); auto rc = performRaycasting(dataContainer, images, camera, eepp.first, eepp.second, light); dataContainer.addData(p_outputImageId.getValue(), rc); } else { LDEBUG("No suitable input data found!"); } }
void MultiVolumeRaycaster::updateProperties(DataContainer& dataContainer) { ImageRepresentationGL::ScopedRepresentation image1(dataContainer, p_sourceImage1.getValue()); ImageRepresentationGL::ScopedRepresentation image2(dataContainer, p_sourceImage2.getValue()); ImageRepresentationGL::ScopedRepresentation image3(dataContainer, p_sourceImage3.getValue()); if (image1) p_transferFunction1.setImageHandle(image1.getDataHandle()); else p_transferFunction1.setImageHandle(DataHandle(nullptr)); if (image2) p_transferFunction2.setImageHandle(image2.getDataHandle()); else p_transferFunction2.setImageHandle(DataHandle(nullptr)); if (image3) p_transferFunction3.setImageHandle(image3.getDataHandle()); else p_transferFunction3.setImageHandle(DataHandle(nullptr)); }
void ImageTest::testYUYVImage() { debug(LOG_DEBUG, DEBUG_LOG, 0, "testYUYVImage() begin"); // test the conversion of an individual pixel YUYV<unsigned char> p((unsigned char)47, 11); unsigned char v; convertPixel(v, p); CPPUNIT_ASSERT(47 == v); // convert a complete image Image<YUYV<unsigned char> > image2(640, 480); convertImage(image2, *image); CPPUNIT_ASSERT(image2.pixel(13, 15).y == (13 + 15 * 640) % 160); // convert to an unsigned short image Image<unsigned char> image3(640, 480); convertImage(image3, image2); CPPUNIT_ASSERT(image3 == *image); image3.pixel(14,15) = 1; CPPUNIT_ASSERT(!(image3 == *image)); debug(LOG_DEBUG, DEBUG_LOG, 0, "testYUYVImage() end"); }
void TerrainWeightEditor::DecomposeImageToCanvases(const QImage& image) { QLabel *canvas1 = editor_widget_->findChild<QLabel *>("canvas_1"); QLabel *canvas2 = editor_widget_->findChild<QLabel *>("canvas_2"); QLabel *canvas3 = editor_widget_->findChild<QLabel *>("canvas_3"); QLabel *canvas4 = editor_widget_->findChild<QLabel *>("canvas_4"); assert(canvas1 && canvas2 && canvas3 && canvas4); int width = image.width(); int height = image.height(); QImage::Format format = image.format(); QImage image1(width,height,format); QImage image2(width,height,format); QImage image3(width,height,format); QImage image4(width,height,format); for(int i=0;i<width;i++) { for(int j=0; j<height;j++) { QRgb color = image.pixel(i,j); int alpha = qAlpha(color); int red = qRed(color); int green = qGreen(color); int blue = qBlue(color); image1.setPixel(i,j, QColor(red,red,red).rgba()); image2.setPixel(i,j, QColor(green,green,green).rgba()); image3.setPixel(i,j, QColor(blue,blue,blue).rgba()); image4.setPixel(i,j, QColor(alpha,alpha,alpha).rgba()); } } canvas1->setPixmap(QPixmap::fromImage(image1)); canvas2->setPixmap(QPixmap::fromImage(image2)); canvas3->setPixmap(QPixmap::fromImage(image3)); canvas4->setPixmap(QPixmap::fromImage(image4)); }
void TestCube::setPairs(vector<shared_ptr<ImagePair>> &pairs) { shared_ptr<Image> image1(new Image()); shared_ptr<Image> image2(new Image()); shared_ptr<Image> image3(new Image()); shared_ptr<ImagePair> pair1(new ImagePair()); shared_ptr<ImagePair> pair2(new ImagePair()); pair1->image1 = image1; pair1->image2 = image2; pair2->image1 = image2; pair2->image2 = image3; TestCube::setKeypointsImg1(image1->keypoints_); TestCube::setKeypointsImg2(image2->keypoints_); TestCube::setKeypointsImg3(image3->keypoints_); TestCube::setMatches(8, pair1->matches); TestCube::setMatches(9, pair2->matches); pairs.push_back(pair1); pairs.push_back(pair2); }
void prob3b(){ // filenames std::string train1 = "Data_Prog2/Training_1.ppm"; std::string ref1 = "Data_Prog2/ref1.ppm"; // variable declarations int M, N, Q; bool type; // make image objects readImageHeader(train1.c_str(), N, M, Q, type); ImageType image1(N, M, Q); ImageType refimage1(N, M, Q); readImage(train1.c_str(),image1); readImage(ref1.c_str(),refimage1); // make skin colors Matrix skin_colors, non_skin_colors; makeColorMatrices(image1, refimage1, skin_colors, non_skin_colors, true); // estimate parameters for skin-color class std::vector<double> mean1 = getSampleMean(skin_colors); std::cout << "sample_mean1 = "; print_vec(mean1); Matrix cov1 = getSampleVar(skin_colors, mean1); std::cout << "sample_cov1 = "; print_matrix(cov1); // set up parameters for non-skin-color class std::vector<double> mean2 = getSampleMean(non_skin_colors); Matrix cov2 = getSampleVar(non_skin_colors, mean2); std::cout << "sample_mean2 = "; print_vec(mean2); std::cout << "sample_cov2 = "; print_matrix(cov2); // make classifier QuadraticDiscriminant classifier(mean1, mean2, cov1, cov2, 0.08, 0.92); std::string out1 = "Data_Prog2/out1b.ppm"; testSkinRecognition(classifier, image1, refimage1, out1, true); std::string train3 = "Data_Prog2/Training_3.ppm"; std::string ref3 = "Data_Prog2/ref3.ppm"; readImageHeader(train3.c_str(), N, M, Q, type); ImageType image3(N, M, Q); ImageType refimage3(N, M, Q); readImage(train3.c_str(),image3); readImage(ref3.c_str(),refimage3); std::string out3 = "Data_Prog2/out3b.ppm"; testSkinRecognition(classifier, image3, refimage3, out3, true); std::string train6 = "Data_Prog2/Training_6.ppm"; std::string ref6 = "Data_Prog2/ref6.ppm"; readImageHeader(train6.c_str(), N, M, Q, type); ImageType image6(N, M, Q); ImageType refimage6(N, M, Q); readImage(train6.c_str(),image6); readImage(ref6.c_str(),refimage6); std::string out6 = "Data_Prog2/out6b.ppm"; testSkinRecognition(classifier, image6, refimage6, out6, true); }
void WindowTexture::generateWindowTexture() //randomly generate windows texture for buildings { CBitmap image0("building/texture/1.bmp"); glBindTexture(GL_TEXTURE_2D, m_nTextureId[0]); //bind this texture to be active glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,image0.GetWidth(),image0.GetHeight(),0,GL_RGBA,GL_UNSIGNED_BYTE,image0.GetBits()); //load data into texture glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); //specify minificaton filtering glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); //specify magnificaton filtering glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); //specify texture coordinate treatment glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); //specify texture coordinate treatment glEnable(GL_TEXTURE_2D); CBitmap image1("building/texture/2.bmp"); glBindTexture(GL_TEXTURE_2D, m_nTextureId[1]); //bind this texture to be active glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,image1.GetWidth(),image1.GetHeight(),0,GL_RGBA,GL_UNSIGNED_BYTE,image1.GetBits()); //load data into texture glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); //specify minificaton filtering glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); //specify magnificaton filtering glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); //specify texture coordinate treatment glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); //specify texture coordinate treatment glEnable(GL_TEXTURE_2D); CBitmap image2("building/texture/3.bmp"); glBindTexture(GL_TEXTURE_2D, m_nTextureId[2]); //bind this texture to be active glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,image2.GetWidth(),image2.GetHeight(),0,GL_RGBA,GL_UNSIGNED_BYTE,image2.GetBits()); //load data into texture glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); //specify minificaton filtering glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); //specify magnificaton filtering glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); //specify texture coordinate treatment glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); //specify texture coordinate treatment glEnable(GL_TEXTURE_2D); CBitmap image3("building/texture/4.bmp"); glBindTexture(GL_TEXTURE_2D, m_nTextureId[3]); //bind this texture to be active glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,image3.GetWidth(),image3.GetHeight(),0,GL_RGBA,GL_UNSIGNED_BYTE,image3.GetBits()); //load data into texture glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); //specify minificaton filtering glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); //specify magnificaton filtering glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); //specify texture coordinate treatment glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); //specify texture coordinate treatment glEnable(GL_TEXTURE_2D); CBitmap image4("building/texture/5.bmp"); glBindTexture(GL_TEXTURE_2D, m_nTextureId[4]); //bind this texture to be active glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,image4.GetWidth(),image4.GetHeight(),0,GL_RGBA,GL_UNSIGNED_BYTE,image4.GetBits()); //load data into texture glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); //specify minificaton filtering glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); //specify magnificaton filtering glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); //specify texture coordinate treatment glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); //specify texture coordinate treatment glEnable(GL_TEXTURE_2D); CBitmap image100("building/texture/mailbox_asdf.bmp"); glBindTexture(GL_TEXTURE_2D, m_nTextureId[numTex]); //bind this texture to be active glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,image100.GetWidth(),image100.GetHeight(),0,GL_RGBA,GL_UNSIGNED_BYTE,image100.GetBits()); //load data into texture glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); //specify minificaton filtering glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); //specify magnificaton filtering glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); //specify texture coordinate treatment glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); //specify texture coordinate treatment glEnable(GL_TEXTURE_2D); textureBounded = true; }
/* * Constructs a Smilies which is a child of 'parent', with the * name 'name' and widget flags set to 'f' */ Smilies::Smilies( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { QPixmap image0( SmallIcon("face_smile") ); QPixmap image1( SmallIcon("face_angel") ); QPixmap image2( SmallIcon("face_embarrassed") ); QPixmap image3( SmallIcon("face_yell") ); QPixmap image4( SmallIcon("face_wink") ); QPixmap image5( SmallIcon("face_glasses") ); QPixmap image6( SmallIcon("face_moneymouth") ); QPixmap image7( SmallIcon("face_crossedlips") ); QPixmap image8( SmallIcon("face_sad") ); QPixmap image9( SmallIcon("face_scream") ); QPixmap image10( SmallIcon("face_cry") ); QPixmap image11( SmallIcon("face_burp") ); QPixmap image12( SmallIcon("face_kiss") ); QPixmap image13( SmallIcon("face_think") ); QPixmap image14( SmallIcon("face_tongue") ); QPixmap image15( SmallIcon("face_luke") ); QPixmap image16( SmallIcon("face_bigsmile") ); QPixmap image17( SmallIcon("face_oneeye") ); if ( !name ) setName( "Smilies" ); resize( 124, 139 ); setCaption( tr( "kaim-smiles" ) ); SmiliesLayout = new QGridLayout( this ); SmiliesLayout->setSpacing( 0 ); SmiliesLayout->setMargin( 0 ); smile = new QToolButton( this, "smile" ); smile->setText( tr( " " ) ); smile->setPixmap( image0 ); SmiliesLayout->addWidget( smile, 0, 0 ); angel = new QToolButton( this, "angel" ); angel->setText( tr( " " ) ); angel->setPixmap( image1 ); SmiliesLayout->addWidget( angel, 2, 3 ); embarrassed = new QToolButton( this, "embarrassed" ); embarrassed->setText( tr( " " ) ); embarrassed->setPixmap( image2 ); SmiliesLayout->addWidget( embarrassed, 2, 2 ); yell = new QToolButton( this, "yell" ); yell->setText( tr( " " ) ); yell->setPixmap( image3 ); SmiliesLayout->addWidget( yell, 1, 2 ); wink = new QToolButton( this, "wink" ); wink->setText( tr( " " ) ); wink->setPixmap( image4 ); SmiliesLayout->addWidget( wink, 0, 3 ); glasses = new QToolButton( this, "glasses" ); glasses->setText( tr( " " ) ); glasses->setPixmap( image5 ); SmiliesLayout->addWidget( glasses, 2, 0 ); moneymouth = new QToolButton( this, "moneymouth" ); moneymouth->setText( tr( " " ) ); moneymouth->setPixmap( image6 ); SmiliesLayout->addWidget( moneymouth, 3, 3 ); crossedlips = new QToolButton( this, "crossedlips" ); crossedlips->setText( tr( " " ) ); crossedlips->setPixmap( image7 ); SmiliesLayout->addWidget( crossedlips, 3, 2 ); sad = new QToolButton( this, "sad" ); sad->setText( tr( " " ) ); sad->setPixmap( image8 ); SmiliesLayout->addWidget( sad, 0, 2 ); scream = new QToolButton( this, "scream" ); scream->setText( tr( " " ) ); scream->setPixmap( image9 ); SmiliesLayout->addWidget( scream, 1, 1 ); cry = new QToolButton( this, "cry" ); cry->setText( tr( " " ) ); cry->setPixmap( image10 ); SmiliesLayout->addWidget( cry, 3, 1 ); burp = new QToolButton( this, "burp" ); burp->setText( tr( " " ) ); burp->setPixmap( image11 ); SmiliesLayout->addWidget( burp, 2, 1 ); kiss = new QToolButton( this, "kiss" ); kiss->setText( tr( " " ) ); kiss->setPixmap( image12 ); SmiliesLayout->addWidget( kiss, 1, 3 ); think = new QToolButton( this, "think" ); think->setText( tr( " " ) ); think->setPixmap( image13 ); SmiliesLayout->addWidget( think, 3, 0 ); tongue = new QToolButton( this, "tongue" ); tongue->setText( tr( " " ) ); tongue->setPixmap( image14 ); SmiliesLayout->addWidget( tongue, 1, 0 ); luke = new QToolButton( this, "luke" ); luke->setText( tr( " " ) ); luke->setPixmap( image15 ); SmiliesLayout->addWidget( luke, 4, 2 ); bigsmile = new QToolButton( this, "bigsmile" ); bigsmile->setText( tr( " " ) ); bigsmile->setPixmap( image16 ); SmiliesLayout->addWidget( bigsmile, 0, 1 ); oneeye = new QToolButton( this, "oneeye" ); oneeye->setText( tr( " " ) ); oneeye->setPixmap( image17 ); SmiliesLayout->addWidget( oneeye, 4, 1 ); QObject::connect( smile, SIGNAL(clicked()), SLOT(smileClicked()) ); QObject::connect( angel, SIGNAL(clicked()), SLOT(angelClicked()) ); QObject::connect( embarrassed, SIGNAL(clicked()), SLOT(embarrassedClicked()) ); QObject::connect( yell, SIGNAL(clicked()), SLOT(yellClicked()) ); QObject::connect( wink, SIGNAL(clicked()), SLOT(winkClicked()) ); QObject::connect( glasses, SIGNAL(clicked()), SLOT(glassesClicked()) ); QObject::connect( moneymouth, SIGNAL(clicked()), SLOT(moneymouthClicked()) ); QObject::connect( crossedlips, SIGNAL(clicked()), SLOT(crossedlipsClicked()) ); QObject::connect( sad, SIGNAL(clicked()), SLOT(sadClicked()) ); QObject::connect( scream, SIGNAL(clicked()), SLOT(screamClicked()) ); QObject::connect( cry, SIGNAL(clicked()), SLOT(cryClicked()) ); QObject::connect( burp, SIGNAL(clicked()), SLOT(burpClicked()) ); QObject::connect( kiss, SIGNAL(clicked()), SLOT(kissClicked()) ); QObject::connect( think, SIGNAL(clicked()), SLOT(thinkClicked()) ); QObject::connect( tongue, SIGNAL(clicked()), SLOT(tongueClicked()) ); QObject::connect( luke, SIGNAL(clicked()), SLOT(lukeClicked()) ); QObject::connect( bigsmile, SIGNAL(clicked()), SLOT(bigsmileClicked()) ); QObject::connect( oneeye, SIGNAL(clicked()), SLOT(oneeyeClicked()) ); }
int main(int, char *[]) { double testrad = 5.5, testx = 127.25, testy = 127.75; //< Actual location of spot double seedrad = 6, seedx = 120, seedy = 118; //< Start location for tracking int avgcount; //< How many samples to average over double pixacc; //< Pixel accuracy desired double err, minerr, maxerr, sumerr; double raderr, minraderr, maxraderr, sumraderr; double biasx, biasy; printf("Generating default test image with radius %lg disk at %lg, %lg\n", testrad, testx, testy); disc_image image(0,255, 0,255, 127, 5, testx, testy, testrad, 250); printf("-----------------------------------------------------------------\n"); printf("Generating default spot tracker\n"); disk_spot_tracker tracker(seedrad); printf("Looking for best fit within the image\n"); tracker.locate_good_fit_in_image(image, 0, seedx, seedy); printf("Optimization, starting at found location %lg, %lg, rad %lg\n", seedx, seedy, seedrad); int i; double x,y, rad, fit; tracker.take_single_optimization_step(image, 0, x,y, seedx, seedy); for (i = 0; i < 5; i++) { tracker.take_single_optimization_step(image, 0, x, y, true, true, true); rad = tracker.get_radius(); fit = tracker.get_fitness(); printf("Next step: X = %8.3lg, Y = %8.3lg, rad = %8.3lg, fit = %12.5lg\n", x,y,rad, fit); } printf("Chasing around a slightly noisy spot using full optimization\n"); testrad = 5.5, testx = 127.25, testy = 127.75; //< Actual location of spot seedrad = 6, seedx = 120, seedy = 118; //< Start location for tracking avgcount = 50; minerr = 1000; maxerr = 0; sumerr = 0; minraderr = 1000; maxraderr = 0; sumraderr = 0; biasx = 0; biasy = 0; for (i = 0; i < avgcount; i++) { testrad += ( (rand()/(double)(RAND_MAX)) - 0.5) * 2 * 1; if (testrad < 3) { testrad = 3; } testx += ( (rand()/(double)(RAND_MAX)) - 0.5) * 2 * (testrad/2); testy += ( (rand()/(double)(RAND_MAX)) - 0.5) * 2 * (testrad/2); { disc_image image2(0,255, 0,255, 127, 5, testx, testy, testrad, 250); tracker.optimize(image2, 0, x, y); rad = tracker.get_radius(); fit = tracker.get_fitness(); err = sqrt( (x-testx)*(x-testx) + (y-testy)*(y-testy) ); if (err < minerr) { minerr = err; } if (err > maxerr) { maxerr = err; } sumerr += err; raderr = fabs(rad-testrad); if (raderr < minraderr) { minraderr = raderr; } if (raderr > maxraderr) { maxraderr = raderr; } sumraderr += raderr; biasx += x - testx; biasy += y - testy; if (i == 0) { printf("First opt: real coords (%g,%g), found coords (%g,%g)\n", testx,testy, x,y); } } } printf("Pos err: min=%g, max=%g, mean=%g, xbias = %g, ybias = %g\n", minerr, maxerr, sumerr/avgcount, biasx/avgcount, biasy/avgcount); printf("Rad err: min=%g, max=%g, mean=%g\n", minraderr, maxraderr, sumraderr/avgcount); testrad = 5.5; pixacc = 0.05; avgcount = 50; x = 120.5; y = 120; printf("Chasing around a slightly noisy disk of known radius %g to %g pixel\n", testrad, pixacc); compute_disk_chase_statistics(tracker, testrad, pixacc, avgcount, minerr, maxerr, sumerr, biasx, biasy, x,y); printf("Pos err: min=%g, max=%g, mean=%g, xbias = %g, ybias = %g\n", minerr, maxerr, sumerr/avgcount, biasx/avgcount, biasy/avgcount); x = 120.5; y = 120; printf("Chasing around a slightly noisy cone of known radius %g to %g pixel\n", testrad, pixacc); compute_cone_chase_statistics(tracker, testrad, pixacc, avgcount, minerr, maxerr, sumerr, biasx, biasy, x,y); printf("Pos err: min=%g, max=%g, mean=%g, xbias = %g, ybias = %g\n", minerr, maxerr, sumerr/avgcount, biasx/avgcount, biasy/avgcount); pixacc = 0.05; testrad = 5.5; tracker.set_pixel_accuracy(pixacc); printf("Timing how long it takes to optimize pos to %g pixels from a nearby position on average\n", pixacc); avgcount = 1000; struct timeval start, end; tracker.optimize(image, 0, x,y); // Get back to the correct starting location gettimeofday(&start, NULL); for (i = 0; i < avgcount; i++) { tracker.optimize_xy(image, 0, x, y, x + ( (rand()/(double)(RAND_MAX)) - 0.5) * 2 * (testrad/2), y + ( (rand()/(double)(RAND_MAX)) - 0.5) * 2 * (testrad/2)); } gettimeofday(&end, NULL); printf(" Time: %lg seconds per optimization\n", duration(end, start)/avgcount); printf("-----------------------------------------------------------------\n"); printf("Generating interpolating spot tracker\n"); disk_spot_tracker_interp interptracker(seedrad); printf("Looking for best fit within the image\n"); interptracker.locate_good_fit_in_image(image, 0, seedx, seedy); printf("Optimization, starting at found location %lg, %lg, rad %lg\n", seedx, seedy, seedrad); interptracker.take_single_optimization_step(image, 0, x,y, seedx, seedy); for (i = 0; i < 5; i++) { interptracker.take_single_optimization_step(image, 0, x, y, true, true, true); rad = interptracker.get_radius(); fit = interptracker.get_fitness(); printf("Next step: X = %8.3lg, Y = %8.3lg, rad = %8.3lg, fit = %12.5lg\n", x,y,rad, fit); } printf("Chasing around a slightly noisy spot using full optimization\n"); testrad = 5.5, testx = 127.25, testy = 127.75; //< Actual location of spot seedrad = 6, seedx = 120, seedy = 118; //< Start location for tracking avgcount = 50; minerr = 1000; maxerr = 0; sumerr = 0; minraderr = 1000; maxraderr = 0; sumraderr = 0; biasx = 0; biasy = 0; for (i = 0; i < avgcount; i++) { testrad += ( (rand()/(double)(RAND_MAX)) - 0.5) * 2 * 1; if (testrad < 3) { testrad = 3; } testx += ( (rand()/(double)(RAND_MAX)) - 0.5) * 2 * (testrad/2); testy += ( (rand()/(double)(RAND_MAX)) - 0.5) * 2 * (testrad/2); { disc_image image2(0,255, 0,255, 127, 5, testx, testy, testrad, 250); interptracker.optimize(image2, 0, x, y); rad = interptracker.get_radius(); fit = interptracker.get_fitness(); err = sqrt( (x-testx)*(x-testx) + (y-testy)*(y-testy) ); if (err < minerr) { minerr = err; } if (err > maxerr) { maxerr = err; } sumerr += err; raderr = fabs(rad-testrad); if (raderr < minraderr) { minraderr = raderr; } if (raderr > maxraderr) { maxraderr = raderr; } sumraderr += raderr; biasx += x - testx; biasy += y - testy; if (i == 0) { printf("First opt: real coords (%g,%g), found coords (%g,%g)\n", testx,testy, x,y); } } } printf("Pos err: min=%g, max=%g, mean=%g, xbias = %g, ybias = %g\n", minerr, maxerr, sumerr/avgcount, biasx/avgcount, biasy/avgcount); printf("Rad err: min=%g, max=%g, mean=%g\n", minraderr, maxraderr, sumraderr/avgcount); testrad = 5.5; pixacc = 0.05; avgcount = 50; x = 120.5; y = 120; printf("Chasing around a slightly noisy disk of known radius %g to %g pixel\n", testrad, pixacc); compute_disk_chase_statistics(interptracker, testrad, pixacc, avgcount, minerr, maxerr, sumerr, biasx,biasy, x,y); printf("Pos err: min=%g, max=%g, mean=%g, xbias = %g, ybias = %g\n", minerr, maxerr, sumerr/avgcount, biasx/avgcount, biasy/avgcount); x = 120.5; y = 120; printf("Chasing around a slightly noisy cone of known radius %g to %g pixel\n", testrad, pixacc); compute_cone_chase_statistics(interptracker, testrad, pixacc, avgcount, minerr, maxerr, sumerr, biasx,biasy, x,y); printf("Pos err: min=%g, max=%g, mean=%g, xbias = %g, ybias = %g\n", minerr, maxerr, sumerr/avgcount, biasx/avgcount, biasy/avgcount); testrad = 5.5; pixacc = 0.05; x = 120.5; y = 120; disc_image image3(0,255,0,255,127,0,x,y,testrad, 250); printf("Optimizing a slightly noisy disk of known radius %g at %g,%g\n", testrad, x,y); interptracker.optimize_xy(image3, 0, x, y, floor(x), ceil(y)); printf(" Found a spot of radius %g at %g,%g\n", interptracker.get_radius(), interptracker.get_x(), interptracker.get_y()); pixacc = 0.05; testrad = 5.5; interptracker.set_pixel_accuracy(pixacc); printf("Timing how long it takes to optimize pos to %g pixels from a nearby position on average\n", pixacc); avgcount = 100; interptracker.optimize(image, 0, x,y); // Get back to the correct starting location gettimeofday(&start, NULL); for (i = 0; i < avgcount; i++) { interptracker.optimize_xy(image, 0, x, y, x + ( (rand()/(double)(RAND_MAX)) - 0.5) * 2 * (testrad/2), y + ( (rand()/(double)(RAND_MAX)) - 0.5) * 2 * (testrad/2)); } gettimeofday(&end, NULL); printf(" Time: %lg seconds per optimization\n", duration(end, start)/avgcount); printf("-----------------------------------------------------------------\n"); printf("Generating interpolating cone spot tracker\n"); cone_spot_tracker_interp conetracker(seedrad); printf("Looking for best fit within the image\n"); conetracker.locate_good_fit_in_image(image, 0, seedx, seedy); printf("Optimization, starting at found location %lg, %lg, rad %lg\n", seedx, seedy, seedrad); conetracker.take_single_optimization_step(image, 0, x,y, seedx, seedy); for (i = 0; i < 5; i++) { conetracker.take_single_optimization_step(image, 0, x, y, true, true, true); rad = conetracker.get_radius(); fit = conetracker.get_fitness(); printf("Next step: X = %8.3lg, Y = %8.3lg, rad = %8.3lg, fit = %12.5lg\n", x,y,rad, fit); } printf("Chasing around a slightly noisy spot using full optimization\n"); testrad = 5.5, testx = 127.25, testy = 127.75; //< Actual location of spot seedrad = 6, seedx = 120, seedy = 118; //< Start location for tracking avgcount = 50; minerr = 1000; maxerr = 0; sumerr = 0; minraderr = 1000; maxraderr = 0; sumraderr = 0; biasx = 0; biasy = 0; for (i = 0; i < avgcount; i++) { testrad += ( (rand()/(double)(RAND_MAX)) - 0.5) * 2 * 1; if (testrad < 3) { testrad = 3; } testx += ( (rand()/(double)(RAND_MAX)) - 0.5) * 2 * (testrad/2); testy += ( (rand()/(double)(RAND_MAX)) - 0.5) * 2 * (testrad/2); { disc_image image2(0,255, 0,255, 127, 5, testx, testy, testrad, 250); conetracker.optimize(image2, 0, x, y); rad = conetracker.get_radius(); fit = conetracker.get_fitness(); err = sqrt( (x-testx)*(x-testx) + (y-testy)*(y-testy) ); if (err < minerr) { minerr = err; } if (err > maxerr) { maxerr = err; } sumerr += err; raderr = fabs(rad-testrad); if (raderr < minraderr) { minraderr = raderr; } if (raderr > maxraderr) { maxraderr = raderr; } sumraderr += raderr; biasx += x - testx; biasy += y - testy; if (i == 0) { printf("First opt: real coords (%g,%g), found coords (%g,%g)\n", testx,testy, x,y); } } } printf("Pos err: min=%g, max=%g, mean=%g, xbias = %g, ybias = %g\n", minerr, maxerr, sumerr/avgcount, biasx/avgcount, biasy/avgcount); printf("Rad err: min=%g, max=%g, mean=%g\n", minraderr, maxraderr, sumraderr/avgcount); testrad = 5.5; pixacc = 0.05; avgcount = 50; x = 120.5; y = 120; printf("Chasing around a slightly noisy disk of known radius %g to %g pixel\n", testrad, pixacc); // Make the radius slightly larger than the radius of the spot. compute_disk_chase_statistics(conetracker, 1.3*testrad, pixacc, avgcount, minerr, maxerr, sumerr, biasx,biasy, x,y); printf("Pos err: min=%g, max=%g, mean=%g, xbias = %g, ybias = %g\n", minerr, maxerr, sumerr/avgcount, biasx/avgcount, biasy/avgcount); x = 120.5; y = 120; printf("Chasing around a slightly noisy cone of known radius %g to %g pixel\n", testrad, pixacc); // Make the radius slightly larger than the radius of the spot. compute_cone_chase_statistics(conetracker, 1.3*testrad, pixacc, avgcount, minerr, maxerr, sumerr, biasx,biasy, x,y); printf("Pos err: min=%g, max=%g, mean=%g, xbias = %g, ybias = %g\n", minerr, maxerr, sumerr/avgcount, biasx/avgcount, biasy/avgcount); testrad = 5.5; pixacc = 0.05; x = 120.5; y = 120; disc_image image4(0,255,0,255,127,0,x,y,testrad, 250); printf("Optimizing a slightly noisy disk of known radius %g at %g,%g\n", testrad, x,y); conetracker.optimize_xy(image4, 0, x, y, floor(x), ceil(y)); printf(" Found a spot of radius %g at %g,%g\n", conetracker.get_radius(), conetracker.get_x(), conetracker.get_y()); pixacc = 0.05; testrad = 5.5; conetracker.set_pixel_accuracy(pixacc); printf("Timing how long it takes to optimize pos to %g pixels from a nearby position on average\n", pixacc); avgcount = 100; conetracker.optimize(image, 0, x,y); // Get back to the correct starting location gettimeofday(&start, NULL); for (i = 0; i < avgcount; i++) { conetracker.optimize_xy(image, 0, x, y, x + ( (rand()/(double)(RAND_MAX)) - 0.5) * 2 * (testrad/2), y + ( (rand()/(double)(RAND_MAX)) - 0.5) * 2 * (testrad/2)); } gettimeofday(&end, NULL); printf(" Time: %lg seconds per optimization\n", duration(end, start)/avgcount); printf("-----------------------------------------------------------------\n"); printf("Generating interpolating symmetric spot tracker\n"); symmetric_spot_tracker_interp symmetrictracker(seedrad); printf("Looking for best fit within the image\n"); symmetrictracker.locate_good_fit_in_image(image, 0, seedx, seedy); printf("Optimization, starting at found location %lg, %lg, rad %lg\n", seedx, seedy, seedrad); symmetrictracker.take_single_optimization_step(image, 0, x,y, seedx, seedy); for (i = 0; i < 5; i++) { symmetrictracker.take_single_optimization_step(image, 0, x, y, true, true, true); rad = symmetrictracker.get_radius(); fit = symmetrictracker.get_fitness(); printf("Next step: X = %8.3lg, Y = %8.3lg, rad = %8.3lg, fit = %12.5lg\n", x,y,rad, fit); } printf("Chasing around a slightly noisy spot using full optimization\n"); testrad = 5.5, testx = 127.25, testy = 127.75; //< Actual location of spot seedrad = 6, seedx = 120, seedy = 118; //< Start location for tracking avgcount = 50; minerr = 1000; maxerr = 0; sumerr = 0; minraderr = 1000; maxraderr = 0; sumraderr = 0; biasx = 0; biasy = 0; for (i = 0; i < avgcount; i++) { testrad += ( (rand()/(double)(RAND_MAX)) - 0.5) * 2 * 1; if (testrad < 3) { testrad = 3; } testx += ( (rand()/(double)(RAND_MAX)) - 0.5) * 2 * (testrad/2); testy += ( (rand()/(double)(RAND_MAX)) - 0.5) * 2 * (testrad/2); { disc_image image2(0,255, 0,255, 127, 5, testx, testy, testrad, 250); symmetrictracker.optimize(image2, 0, x, y); rad = symmetrictracker.get_radius(); fit = symmetrictracker.get_fitness(); err = sqrt( (x-testx)*(x-testx) + (y-testy)*(y-testy) ); if (err < minerr) { minerr = err; } if (err > maxerr) { maxerr = err; } sumerr += err; raderr = fabs(rad-testrad); if (raderr < minraderr) { minraderr = raderr; } if (raderr > maxraderr) { maxraderr = raderr; } sumraderr += raderr; biasx += x - testx; biasy += y - testy; if (i == 0) { printf("First opt: real coords (%g,%g), found coords (%g,%g)\n", testx,testy, x,y); } } } printf("Pos err: min=%g, max=%g, mean=%g, xbias = %g, ybias = %g\n", minerr, maxerr, sumerr/avgcount, biasx/avgcount, biasy/avgcount); printf("Rad err: min=%g, max=%g, mean=%g\n", minraderr, maxraderr, sumraderr/avgcount); testrad = 5.5; pixacc = 0.01; avgcount = 50; x = 120.5; y = 120; printf("Chasing around a slightly noisy disk of known radius %g to %g pixel\n", testrad, pixacc); // Make the radius slightly larger than the radius of the spot. compute_disk_chase_statistics(symmetrictracker, 1.3*testrad, pixacc, avgcount, minerr, maxerr, sumerr, biasx,biasy, x,y); printf("Pos err: min=%g, max=%g, mean=%g, xbias = %g, ybias = %g\n", minerr, maxerr, sumerr/avgcount, biasx/avgcount, biasy/avgcount); x = 120.5; y = 120; printf("Chasing around a slightly noisy cone of known radius %g to %g pixel\n", testrad, pixacc); // Make the radius slightly larger than the radius of the spot. compute_disk_chase_statistics(symmetrictracker, 1.3*testrad, pixacc, avgcount, minerr, maxerr, sumerr, biasx,biasy, x,y); printf("Pos err: min=%g, max=%g, mean=%g, xbias = %g, ybias = %g\n", minerr, maxerr, sumerr/avgcount, biasx/avgcount, biasy/avgcount); testrad = 5.5; pixacc = 0.05; x = 120.5; y = 120; disc_image image5(0,255,0,255,127,0,x,y,testrad, 250); printf("Optimizing a slightly noisy disk of known radius %g at %g,%g\n", testrad, x,y); symmetrictracker.optimize_xy(image5, 0, x, y, floor(x), ceil(y)); printf(" Found a spot of radius %g at %g,%g\n", symmetrictracker.get_radius(), symmetrictracker.get_x(), symmetrictracker.get_y()); pixacc = 0.05; testrad = 5.5; symmetrictracker.set_pixel_accuracy(pixacc); printf("Timing how long it takes to optimize pos to %g pixels from a nearby position on average\n", pixacc); avgcount = 100; symmetrictracker.optimize(image, 0, x,y); // Get back to the correct starting location gettimeofday(&start, NULL); for (i = 0; i < avgcount; i++) { symmetrictracker.optimize_xy(image, 0, x, y, x + ( (rand()/(double)(RAND_MAX)) - 0.5) * 2 * (testrad/2), y + ( (rand()/(double)(RAND_MAX)) - 0.5) * 2 * (testrad/2)); } gettimeofday(&end, NULL); printf(" Time: %lg seconds per optimization\n", duration(end, start)/avgcount); printf("-----------------------------------------------------------------\n"); printf("Generating Gaussian spot tracker\n"); testrad = 5.5, testx = 127.25, testy = 127.75; //< Actual location of spot seedrad = 6, seedx = 120, seedy = 118; //< Start location for tracking Gaussian_spot_tracker Gaussiantracker(seedrad, false, 0.25, 0.25, 1.0, 127, 11689); printf("Looking for best fit within the image\n"); Gaussiantracker.locate_good_fit_in_image(image, 0, seedx, seedy); printf("Optimization, starting at found location %lg, %lg, rad %lg\n", seedx, seedy, seedrad); Gaussiantracker.take_single_optimization_step(image, 0, x,y, seedx, seedy); for (i = 0; i < 5; i++) { Gaussiantracker.take_single_optimization_step(image, 0, x, y, true, true, true); rad = Gaussiantracker.get_radius(); fit = Gaussiantracker.get_fitness(); printf("Next step: X = %8.3lg, Y = %8.3lg, rad = %8.3lg, fit = %12.5lg\n", x,y,rad, fit); } printf("Chasing around a slightly noisy spot using full optimization\n"); avgcount = 50; minerr = 1000; maxerr = 0; sumerr = 0; minraderr = 1000; maxraderr = 0; sumraderr = 0; biasx = 0; biasy = 0; for (i = 0; i < avgcount; i++) { testrad += ( (rand()/(double)(RAND_MAX)) - 0.5) * 2 * 1; if (testrad < 3) { testrad = 3; } testx += ( (rand()/(double)(RAND_MAX)) - 0.5) * 2 * (testrad/2); testy += ( (rand()/(double)(RAND_MAX)) - 0.5) * 2 * (testrad/2); { disc_image image2(0,255, 0,255, 127, 5, testx, testy, testrad, 250); Gaussiantracker.optimize(image2, 0, x, y); rad = Gaussiantracker.get_radius(); fit = Gaussiantracker.get_fitness(); err = sqrt( (x-testx)*(x-testx) + (y-testy)*(y-testy) ); if (err < minerr) { minerr = err; } if (err > maxerr) { maxerr = err; } sumerr += err; raderr = fabs(rad-testrad); if (raderr < minraderr) { minraderr = raderr; } if (raderr > maxraderr) { maxraderr = raderr; } sumraderr += raderr; biasx += x - testx; biasy += y - testy; if (i == 0) { printf("First opt: real coords (%g,%g), found coords (%g,%g)\n", testx,testy, x,y); } } } printf("Pos err: min=%g, max=%g, mean=%g, xbias = %g, ybias = %g\n", minerr, maxerr, sumerr/avgcount, biasx/avgcount, biasy/avgcount); // XXX Radius error meaningless here because radius not optimized. //printf("Rad err: min=%g, max=%g, mean=%g\n", minraderr, maxraderr, sumraderr/avgcount); testrad = 5.5; pixacc = 0.01; avgcount = 50; x = 120.5; y = 120; printf("Chasing around a slightly noisy disk of known radius %g to %g pixel\n", testrad, pixacc); // Make the radius slightly larger than the radius of the spot. compute_disk_chase_statistics(Gaussiantracker, 1.3*testrad, pixacc, avgcount, minerr, maxerr, sumerr, biasx,biasy, x,y); printf("Pos err: min=%g, max=%g, mean=%g, xbias = %g, ybias = %g\n", minerr, maxerr, sumerr/avgcount, biasx/avgcount, biasy/avgcount); x = 120.5; y = 120; printf("Chasing around a slightly noisy cone of known radius %g to %g pixel\n", testrad, pixacc); // Make the radius slightly larger than the radius of the spot. compute_disk_chase_statistics(Gaussiantracker, 1.3*testrad, pixacc, avgcount, minerr, maxerr, sumerr, biasx,biasy, x,y); printf("Pos err: min=%g, max=%g, mean=%g, xbias = %g, ybias = %g\n", minerr, maxerr, sumerr/avgcount, biasx/avgcount, biasy/avgcount); testrad = 5.5; pixacc = 0.05; x = 120.5; y = 120; disc_image image6(0,255,0,255,127,0,x,y,testrad, 250); printf("Optimizing a slightly noisy disk of known radius %g at %g,%g\n", testrad, x,y); Gaussiantracker.optimize(image6, 0, x, y, floor(x), ceil(y)); printf(" Found a spot of radius %g at %g,%g\n", Gaussiantracker.get_radius(), Gaussiantracker.get_x(), Gaussiantracker.get_y()); pixacc = 0.05; testrad = 5.5; Gaussiantracker.set_pixel_accuracy(pixacc); printf("Timing how long it takes to optimize pos to %g pixels from a nearby position on average\n", pixacc); avgcount = 10; Gaussiantracker.optimize(image, 0, x,y); // Get back to the correct starting location gettimeofday(&start, NULL); for (i = 0; i < avgcount; i++) { Gaussiantracker.optimize_xy(image, 0, x, y, x + ( (rand()/(double)(RAND_MAX)) - 0.5) * 2 * (testrad/2), y + ( (rand()/(double)(RAND_MAX)) - 0.5) * 2 * (testrad/2)); } gettimeofday(&end, NULL); printf(" Time: %lg seconds per optimization\n", duration(end, start)/avgcount); //----------------------------------------------------------------------------------------------- // Testing the Z-tracking classes. printf("-----------------------------------------------------------------\n"); // Construct a PSF kernel by making a number of disc images and sticking them into it. disc_image *discs[10]; PSF_File *psf = new PSF_File("deleteme.tif", 25, false); for (i = 0; i < 10; i++) { discs[i] = new disc_image(0,128, 0,128, 0, 0.0, 64,64, i+10, 255, 4); psf->append_line(*discs[i], 64, 64); } delete psf; // Test the best-fit-finding code radial_average_tracker_Z Ztrack("deleteme.tif"); double z = 0.0; Ztrack.locate_best_fit_in_depth(*discs[5], 0, 64, 64, z); printf("Z best fit should be 5, found at %lf\n", z); // Test the optimization code Ztrack.optimize(*discs[7], 0, 64, 64, z); printf("Z optimum should be 7, found at %lf\n", z); // Test on a novel image disc_image test_disc(0,128, 0,128, 0, 0.0, 64,64, 5.5+10, 255, 4); Ztrack.optimize(test_disc, 0, 64, 64, z); printf("Z optimum should be 5.5, found at %lf\n", z); // Delete the PSF file unlink("deleteme.tif"); return 0; }
void StatusBar::drawOn(Surface & surface) { switch (lives) { case 3: { Image image("images/galaxian/GalaxianGalaxip.gif"); Rect rect = image.getRect(); rect.x = W-32; rect.y = H-32; surface.put_image(image, rect); Image image2("images/galaxian/GalaxianGalaxip.gif"); Rect rect2 = image2.getRect(); rect2.x = W-64; rect2.y = H-32; surface.put_image(image2, rect2); Image image3("images/galaxian/GalaxianGalaxip.gif"); Rect rect3 = image3.getRect(); rect3.x = W-96; rect3.y = H-32; surface.put_image(image3, rect3); break; } case 2: { Image image("images/galaxian/GalaxianGalaxip.gif"); Rect rect = image.getRect(); rect.x = W-32; rect.y = H-32; surface.put_image(image, rect); Image image2("images/galaxian/GalaxianGalaxip.gif"); Rect rect2 = image2.getRect(); rect2.x = W-64; rect2.y = H-32; surface.put_image(image2, rect2); break; } case 1: { Image image("images/galaxian/GalaxianGalaxip.gif"); Rect rect = image.getRect(); rect.x = W-32; rect.y = H-32; surface.put_image(image, rect); break; } default: break; } //printing score Font font("fonts/FreeSans.ttf", 32); Color c = {0,255,0}; Color b = {225,255, 0}; Image imagescoretext(font.render("Score:",c)); Rect rectscoretext = imagescoretext.getRect(); rectscoretext.x = 5; rectscoretext.y = H- 42; surface.put_image(imagescoretext, rectscoretext); //converting int to string std::stringstream strmsc; strmsc << score; Image imagescore(font.render(strmsc.str().c_str(), b)); Rect rectscore = imagescore.getRect(); rectscore.x = 170; rectscore.y = H-42; surface.put_image(imagescore, rectscore); Image imagehittext(font.render("Kills:",c)); Rect recthittext = imagehittext.getRect(); recthittext.x = 300; recthittext.y = H- 42; surface.put_image(imagehittext, recthittext); std::stringstream strmki; strmki << kills; Image imagekills(font.render(strmki.str().c_str(), b)); Rect rectkills = imagekills.getRect(); rectkills.x = 430; rectkills.y = H-42; surface.put_image(imagekills, rectkills); }