tracciatore di mani con webcam

源代码在线查看: mask.cpp

软件大小: 14443 K
上传用户: tiger452
关键词: tracciatore webcam mani con
下载地址: 免注册下载 普通下载 VIP

相关代码

												#include "Common.h"				#include "Mask.h"				#include "Exceptions.h"				#include 								Mask::Mask()				: m_width(-1),				  m_height(-1),				  m_image_area_ratio(-1),				  m_name("")				{				}								Mask::~Mask()				{				}								void Mask::ParseFrom(string filename)				{				  ifstream mask_file(filename.c_str());				  if (!mask_file.is_open()) {				    throw HVEFileNotFound(filename);				  }								  string line;				  do {				    getline(mask_file, line);				  } while (line=="" || line[0]=='#');								  m_probs.clear();				  if (line==HV_MASK_VERSION_1_0_STRING) {					  // version 1.0								    do {				      getline(mask_file, line);				    } while (line=="" || line[0]=='#');				    float ratio;				    char name[1024];				    int scanned = sscanf(line.c_str(), "Mask %s %dx%d, ratio %f", 				                         name, &m_width, &m_height, &ratio);				    if (scanned!=4) {				      throw HVEFile(filename, string("expected mask metadata, found: ")+line);				    }				    if (name[strlen(name)-1]==',') name[strlen(name)-1] = 0;				    if (name[strlen(name)-1]=='"') name[strlen(name)-1] = 0;				    if (name[0]=='"') {				      m_name = string(&name[1]);				    } else {				      m_name = string(name);				    }				    m_image_area_ratio = ratio;				    m_probs.resize(m_width*m_height);				    for (int row=0; row				      do {				        getline(mask_file, line);				      } while (line=="" || line[0]=='#');				      char* cline = (char*) alloca(line.size()*sizeof(char));				      strcpy(cline, line.c_str());				      char* ctok = strtok(cline, " ");				      for (int col=0; col				        double val = atof(ctok);				        m_probs[row*m_width+col] = val;				        ctok = strtok(NULL, " ");				        if (ctok==NULL && col				          throw HVEFile(filename, string("expected probabilities, found: ")+line);				        }				      }				    }								  } else {				    // wrong version				    throw HVEFile(filename, string("missing or wrong version: ")+line);				  }				  mask_file.close();				}								double Mask::GetProb(int x, int y) const				{				  ASSERT(0				  ASSERT(0				  return m_probs[y*m_width+x];				}							

相关资源