コード例 #1
0
void FacialFeatureRecognizer::processCase(int caseId)
{
    DatabaseReader dbReader(databaseConnection);
    CaseManager* caseManager = new CaseManager(databaseConnection, caseId);
    QString filename = dbReader.getOriginalImageFilename(caseManager->getCaseId());
    filename = "/home/zane/Documents/COS301/MainProject/QFRSSWeb/caseImages/" + filename;

    Mat imageTaken = imread(filename.toStdString(), CV_LOAD_IMAGE_UNCHANGED);
    ImageData* imageData = new ImageData();
    imageData->image = imageTaken;
    imageData = faceDetectFilter->filter(imageData);
    if (imageData->faces.size() == 0)
    {
        caseManager->setProgress(-1);
        caseManager->setStatus("No faces in image");
        return;
    }
    if (imageData->faces.size() > 1)
    {
        caseManager->setProgress(-1);
        caseManager->setStatus("More than one face in image");
        return;
    }
    imageData = preProcessingFilter->filter(imageData);

    caseManager->setProgress(0);
    caseManager->setStatus("busy");

    GetFaceDetailsResponse* response = dbReader.getAllFaceFilenamesAndIds();
    vector<QString> faceFilenames = response->faceFilnames;
    vector<int> faceIds = response->ids;
    float size = faceFilenames.size();

    for (unsigned int i = 0; i < faceFilenames.size(); i++)
    {
        Mat temp = imread(faceFilenames[i].toStdString(), CV_LOAD_IMAGE_UNCHANGED);
        double percentageMatch = compareFaces(imageData->faces[0], temp);
        if (percentageMatch <= threshold)
        {
            percentageMatch = scaleToPercentage(compareFaces(imageData->faces[0], temp));
            caseManager->updateCaseStatus(faceIds[i], percentageMatch);
        }
        float progress = i / size * 100.0;
        caseManager->setProgress(progress);
    }
    caseManager->setStatus("finished");
}
コード例 #2
0
ParticleInfo::ParticleInfo( const std::string& dbFile)
{
  // Open a FileReader for the supplied db file
  FileReader dbReader(dbFile);

  if (dbReader.isValid()) {
    // Create variables
    std::string name;
    int pdg(0), charge(0);
    double mass(0.0);

    while (dbReader.nextLine()) {
      name = dbReader.getField<std::string>(1);
      if (dbReader.inputFailed()) {
        continue;
      }

      pdg = dbReader.getField<int>(2);
      if (dbReader.inputFailed()) {
        continue;
      }

      charge = dbReader.getField<int>(3);
      if (dbReader.inputFailed()) {
        continue;
      }

      mass = dbReader.getField<double>(4);
      if (dbReader.inputFailed()) {
        continue;
      }

      // Fill collections...
      name_to_id.insert(std::make_pair(name, pdg));
      id_to_name.insert(std::make_pair(pdg, name));
      id_to_charge.insert(std::make_pair(pdg, charge));
      id_to_mass.insert(std::make_pair(pdg, mass));

    }
  }
}