void HOGTrainer::testIt(const string fileName) { if (trained != "") { char key = 27; Scalar sReference(0, 255, 0); Scalar sTrained(0, 0, 255); Mat img, draw; Ptr<SVM> svm; HOGDescriptor hog; HOGDescriptor my_hog; my_hog.winSize = size; VideoCapture *video; vector<Rect> locations; // Load the sTrained SVM. svm = StatModel::load<SVM>(trained); // Set the sTrained svm to my_hog vector<float> hog_detector; getSVMDetector(svm, hog_detector); my_hog.setSVMDetector(hog_detector); // Set the people detector. hog.setSVMDetector(hog.getDefaultPeopleDetector()); // Open the camera. video = new VideoCapture(fileName); if (!video->isOpened()) { cerr << "Unable to open the device 0" << endl; exit(-1); } bool end_of_process = false; while (!end_of_process) { video->read(img); if (img.empty()) break; draw = img.clone(); locations.clear(); hog.detectMultiScale(img, locations); drawLocations(draw, locations, sReference); locations.clear(); my_hog.detectMultiScale(img, locations); drawLocations(draw, locations, sTrained); imshow("Video", draw); key = (char) waitKey(10); if (27 == key) end_of_process = true; } } }
layoutEditPreviewDialog::layoutEditPreviewDialog(NineMLLayout * inSrcNineMLLayout, glConnectionWidget * glConn, QWidget *parent) : QDialog(parent) { srcNineMLLayout = inSrcNineMLLayout; glView = glConn; QObject::connect(this, SIGNAL(drawLayout(vector<loc>)), glView, SLOT(drawLocations(vector<loc>))); this->setModal(true); this->setMinimumSize(200, 400); this->setWindowTitle("Preview layout"); //this->setWindowIcon(); // add the main layout this->setLayout(new QVBoxLayout); this->layout()->setContentsMargins(0,0,0,0); // make the dialog scrollable this->layout()->addWidget(new QScrollArea); QWidget * content = new QWidget; ((QScrollArea *) this->layout()->itemAt(0)->widget())->setWidget(content); ((QScrollArea *) this->layout()->itemAt(0)->widget())->setWidgetResizable(true); content->setLayout(new QFormLayout); QFormLayout * contentLayout = (QFormLayout *) content->layout(); QSpinBox * numNeurons = new QSpinBox; numNeurons->setRange(1, 20000000); numNeurons->setProperty("name", "numNeurons"); numNeurons->setValue(99.0); QObject::connect(numNeurons, SIGNAL(valueChanged(QString)), this, SLOT(reDraw(QString))); contentLayout->addRow("Number of neurons:", numNeurons); // start adding the items if (srcNineMLLayout->ParameterList.size() > 1) { contentLayout->addRow("<b>Parameters</b>", new QLabel("")); } // add the parameters for (uint i = 0; i < srcNineMLLayout->ParameterList.size(); ++i) { if (srcNineMLLayout->ParameterList[i]->name != "numNeurons") { // add to main layout QDoubleSpinBox * value = new QDoubleSpinBox; value->setRange(-200000, 200000); value->setSingleStep(0.1); value->setDecimals(3); value->setValue(1.0); value->setProperty("name", srcNineMLLayout->ParameterList[i]->name); QObject::connect(value, SIGNAL(valueChanged(QString)), this, SLOT(reDraw(QString))); contentLayout->addRow(srcNineMLLayout->ParameterList[i]->name + ":", value); } } if (srcNineMLLayout->StateVariableList.size() > 3) { contentLayout->addRow("<b>State variables</b>", new QLabel("")); } // add the state vars for (uint i = 0; i < srcNineMLLayout->StateVariableList.size(); ++i) { if (srcNineMLLayout->StateVariableList[i]->name != "x" && srcNineMLLayout->StateVariableList[i]->name != "y" && srcNineMLLayout->StateVariableList[i]->name != "z") { // add to main layout QDoubleSpinBox * value = new QDoubleSpinBox; value->setRange(-200000, 200000); value->setSingleStep(0.1); value->setDecimals(3); value->setValue(1.0); value->setProperty("name", srcNineMLLayout->StateVariableList[i]->name); QObject::connect(value, SIGNAL(valueChanged(QString)), this, SLOT(reDraw(QString))); contentLayout->addRow(srcNineMLLayout->StateVariableList[i]->name + ":", value); } } contentLayoutRef = contentLayout; // force a redraw! numNeurons->setValue(100.0); }