/// Locate the left and right iterators of a span in the state. /// The left iterator points to the leftmost *inside* the span. /// The right iterator points to the rightmost *inside* the span. /// (For a span containing one item, left == right.) /// \param s The span we are locating. /// \return A pair of ItemToken iterators, left and right. pair<ItemTokens::const_iterator, ItemTokens::const_iterator> State::span_iterators(const Span& s) const { Span tmps(_frontier); assert(tmps.left() <= s.left()); assert(tmps.right() >= s.right()); ItemTokens::const_iterator l, r; ItemTokens::const_iterator i; for (i = _frontier.begin(); i != _frontier.end(); i++) { if ((*i)->span().left() == s.left()) break; assert((*i)->span().left() < s.left()); } assert((*i)->span().left() == s.left()); l = i; for (; i != _frontier.end(); i++) { if ((*i)->span().right() == s.right()) break; assert((*i)->span().right() < s.right()); } assert((*i)->span().right() == s.right()); r = i; return make_pair(l, r); }
/// Locate a span in the state. /// \param s The span we are locating. /// \return Those ItemTokens that the span comprises. const ItemTokens State::locate_span(const Span& s) const { Span tmps(_frontier); assert(tmps.left() <= s.left()); assert(tmps.right() >= s.right()); ItemTokens is; ItemTokens::const_iterator i; for (i = _frontier.begin(); i != _frontier.end(); i++) { if ((*i)->span().left() == s.left()) break; assert((*i)->span().left() < s.left()); } assert((*i)->span().left() == s.left()); for (; i != _frontier.end(); i++) { is.push_back(*i); if ((*i)->span().right() == s.right()) break; assert((*i)->span().right() < s.right()); } assert((*i)->span().right() == s.right()); assert(!is.empty()); return is; }
void send_error(Process& host, char const* s) { boost::shared_ptr<Event> tmp( boost::static_pointer_cast<Event>(shared_from_this()) ); std::string tmps(s); proc->error_respond( host, tmp, tmps ); }
syString& syString::operator=(const syString& copy) { if(© == this) { syString tmps(m_Str, false); Helper::reset(this); tmps.m_UseRef = true; m_UseRef = false; m_Str = tmps.m_Str; m_Size = tmps.m_Size; } else { Helper::assign(this,copy.m_Str, copy.m_Size, false); } return *this; }
cv::Mat Player::imgProcessing(int iFrame, int diff){ // read actual frame Mat frame; if (clipEntry->Type == ClipType::Video) { //clipEntry->Video.set(CV_CAP_PROP_POS_MSEC, (double)iFrame*1000/15); //clipEntry->Video.set(CV_CAP_PROP_POS_FRAMES, (double)iFrame); // read frame from video if (!clipEntry->Video.read(frame) || frame.total() == 0) { cerr << "ERROR: Unable to read next frame (#" << iFrame << ") from video." << endl; cerr << "Press ENTER to exit." << endl; cin.get(); exit(EXIT_FAILURE); } while(diff>1){ if (!clipEntry->Video.read(frame) || frame.total() == 0) { cerr << "ERROR: Unable to read next frame (#" << iFrame << ") from video." << endl; cerr << "Press ENTER to exit." << endl; cin.get(); exit(EXIT_FAILURE); } diff--; } } else { // read frame from image string frameFolder = Config.GetClipFolder(*clipEntry); string framePath = frameFolder + "/" + clipEntry->Filenames[iFrame]; string folder = Config.GetClipFolder(*clipEntry); string fname = *(clipEntry->Filenames.begin() + iFrame); string fpath = folder + "/" + fname; frame = imread(fpath); //cout << fpath << endl; if(!frame.data) { // error in opening an image file cerr << "Unable to open image frame: " << fpath << endl; cerr << "Press ENTER to exit." << endl; cin.get(); exit(EXIT_FAILURE); } } // read mask auto foregroundFolder = Config.GetForegroundFolder(*clipEntry); //auto foregroundPath = foregroundFolder + "/" + clipMaskFileNames[iFrame]; char tmp[10]; sprintf(tmp,"%d.bmp",iFrame); string tmps(tmp); auto foregroundPath = foregroundFolder + "/" + tmps; Mat fg = imread(foregroundPath, CV_LOAD_IMAGE_COLOR); auto maskFolder = Config.GetMaskFolder(*clipEntry); sprintf(tmp,"%d.bmp",iFrame); tmps.assign(tmp); auto maskPath = maskFolder + "/" + tmps; Mat mask = imread(maskPath, CV_LOAD_IMAGE_COLOR); // substitute mask in frame for(int i=0; i<frame.rows; i++){ for(int j=0; j<frame.cols; j++){ if(mask.at<Vec3b>(i,j)[0]!=0 || mask.at<Vec3b>(i,j)[1]!=0 || mask.at<Vec3b>(i,j)[2]!=0){ frame.at<Vec3b>(i,j)[0] = mask.at<Vec3b>(i,j)[0]; frame.at<Vec3b>(i,j)[1] = mask.at<Vec3b>(i,j)[0]; frame.at<Vec3b>(i,j)[2] = mask.at<Vec3b>(i,j)[0]; } } } imshow("Foreground",fg); imshow("Display", frame); return frame; }