• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Targets类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Targets的典型用法代码示例。如果您正苦于以下问题:C++ Targets类的具体用法?C++ Targets怎么用?C++ Targets使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Targets类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Targets

Targets *GetAllActors(Scriptable *Sender, int ga_flags)
{
	Map *map = Sender->GetCurrentArea();

	int i = map->GetActorCount(true);
	Targets *tgts = new Targets();
	while (i--) {
		Actor *ac = map->GetActor(i,true);
		int dist = Distance(Sender->Pos, ac->Pos);
		tgts->AddTarget((Scriptable *) ac, dist, ga_flags);
	}
	return tgts;
}
开发者ID:shadowphoenix,项目名称:gemrb,代码行数:13,代码来源:Matching.cpp


示例2: ClientException

  svn_revnum_t
  Client::commit(const Targets & targets,
                 const char * message,
                 bool recurse,
                 bool keep_locks) throw(ClientException)
  {
    Pool pool;

    m_context->setLogMessage(message);

    svn_client_commit_info_t *commit_info = NULL;

    svn_error_t * error =
      svn_client_commit2(&commit_info,
                         targets.array(pool),
                         recurse,
                         keep_locks,
                         *m_context,
                         pool);
    if (error != NULL)
      throw ClientException(error);

    if (commit_info && SVN_IS_VALID_REVNUM(commit_info->revision))
      return commit_info->revision;

    return -1;
  }
开发者ID:caidongyun,项目名称:kdevplatform,代码行数:27,代码来源:client_modify.cpp


示例3: GetObjectCount

int GetObjectCount(Scriptable* Sender, Object* oC)
{
	if (!oC) {
		return 0;
	}
	// EvaluateObject will return [PC]
	// GetAllObjects will also return Myself (evaluates object filters)
	// i believe we need the latter here
	Targets* tgts = GetAllObjects(Sender->GetCurrentArea(), Sender, oC, 0);
	int count = 0; // silly fallback to avoid potential crashes
	if (tgts) {
		count = tgts->Count();
		delete tgts;
	}
	return count;
}
开发者ID:AlanWasTaken,项目名称:gemrb,代码行数:16,代码来源:Matching.cpp


示例4: Targets

Targets *GetAllActors(Scriptable *Sender, int ga_flags)
{
	Map *map = Sender->GetCurrentArea();

	int i = map->GetActorCount(true);
	Targets *tgts = new Targets();
	//make sure that Sender is always first in the list, even if there
	//are other (e.g. dead) targets at the same location
	tgts->AddTarget(Sender, 0, ga_flags);
	while (i--) {
		Actor *ac = map->GetActor(i,true);
		if (ac != Sender) {
			int dist = Distance(Sender->Pos, ac->Pos);
			tgts->AddTarget(ac, dist, ga_flags);
		}
	}
	return tgts;
}
开发者ID:AlanWasTaken,项目名称:gemrb,代码行数:18,代码来源:Matching.cpp


示例5: GetActorFromObject

Scriptable* GetActorFromObject(Scriptable* Sender, Object* oC, int ga_flags)
{
	Scriptable *aC = NULL;

	Game *game = core->GetGame();
	Targets *tgts = GetAllObjects(Sender->GetCurrentArea(), Sender, oC, ga_flags);
	if (tgts) {
		//now this could return other than actor objects
		aC = tgts->GetTarget(0,-1);
		delete tgts;
		if (aC || !oC || oC->objectFields[0]!=-1) {
			return aC;
		}

		//global actors are always found by object ID!
		return game->GetGlobalActorByGlobalID(oC->objectFields[1]);
	}

	if (!oC) {
		return NULL;
	}

	if (oC->objectName[0]) {
		// if you ActionOverride a global actor, they might not have a map :(
		// TODO: don't allow this to happen?
		if (Sender->GetCurrentArea()) {
			aC = GetActorObject(Sender->GetCurrentArea()->GetTileMap(), oC->objectName );
			if (aC) {
				return aC;
			}
		}

		//global actors are always found by scripting name!
		aC = game->FindPC(oC->objectName);
		if (aC) {
			return aC;
		}
		aC = game->FindNPC(oC->objectName);
		if (aC) {
			return aC;
		}
	}
	return NULL;
}
开发者ID:AlanWasTaken,项目名称:gemrb,代码行数:44,代码来源:Matching.cpp


示例6: GetObjectLevelCount

//TODO:
//check numcreaturesatmylevel(myself, 1)
//when the actor is alone
//it should (obviously) return true if the trigger
//evaluates object filters
//also check numcreaturesgtmylevel(myself,0) with
//actor having at high level
int GetObjectLevelCount(Scriptable* Sender, Object* oC)
{
	if (!oC) {
		return 0;
	}
	// EvaluateObject will return [PC]
	// GetAllObjects will also return Myself (evaluates object filters)
	// i believe we need the latter here
	Targets* tgts = GetAllObjects(Sender->GetCurrentArea(), Sender, oC, 0);
	int count = 0;
	if (tgts) {
		targetlist::iterator m;
		const targettype *tt = tgts->GetFirstTarget(m, ST_ACTOR);
		while (tt) {
			count += ((Actor *) tt->actor)->GetXPLevel(true);
			tt = tgts->GetNextTarget(m, ST_ACTOR);
		}
	}
	delete tgts;
	return count;
}
开发者ID:AlanWasTaken,项目名称:gemrb,代码行数:28,代码来源:Matching.cpp


示例7: throw

  void
  Client::unlock(const Targets & targets, bool force) throw(ClientException)
  {
    Pool pool;

    svn_error_t * error =
      svn_client_unlock(const_cast<apr_array_header_t*>(targets.array(pool)),
                        force,
                        *m_context,
                        pool);
    if (error != NULL)
      throw ClientException(error);
  }
开发者ID:caidongyun,项目名称:kdevplatform,代码行数:13,代码来源:client_modify.cpp


示例8: recognize

FaceDetector_Surf::DetectedFace FaceDetector_Surf::recognize(const cv::Mat &in, cv::Rect roi, const Targets& targets, const TrackedFaces &lastlyTrackedFaces) {


    cv::Point center;
    center.x = roi.x + roi.width/2;
    center.y = roi.y + roi.height/2;

	for(size_t i = 0; i < lastlyTrackedFaces.size(); ++i){
        std::cout << "tracking" << std::endl;
		const TrackedFace* trackedFace = &lastlyTrackedFaces.at(i);
        cv::Point previousCenter;
        previousCenter.x = trackedFace->rect.x + trackedFace->rect.width/2;
        previousCenter.y = trackedFace->rect.y + trackedFace->rect.height/2;

        if(abs(center.x - previousCenter.x) <= 50 && abs(center.y - previousCenter.y) <= 50){
            std::cout << "tracked" << std::endl;
            DetectedFace detectedFace;
            detectedFace.isRecognized = true;
            detectedFace.target = trackedFace->target;
            detectedFace.index = trackedFace->index;
            _availableFlags.at(detectedFace.index) = false;
            return detectedFace;
        }
    }


    Score bestMatch;
    cv::Mat face = in(roi).clone();

    for(size_t i = 0; i < targets.size(); ++i){
        std::cout << "surf[" << i << "]" << std::endl;
        if(!_availableFlags.at(i)) continue;
        std::cout << "available" << std::endl;

        const Target* target =  &targets.at(i);
        cv::Mat model = target->picture;


        // Match the two images
        std::vector<cv::DMatch> matches;
        std::vector<cv::KeyPoint> keypoints1, keypoints2;
        rmatcher.match(model, face ,matches, keypoints1, keypoints2);


        // draw the matches
        /*cv::Mat imageMatches;
        cv::drawMatches(model,keypoints1,          // 1st image and its keypoints
                        face,keypoints2,            // 2nd image and its keypoints
                        matches,                    // the matches
                        imageMatches,               // the image produced
                        cv::Scalar(255,255,255));   // color of the lines*/

        if(matches.size() > bestMatch.first){
            bestMatch = Score(matches.size(), i);
        }
    }

    DetectedFace detectedFace;
    detectedFace.isRecognized = bestMatch.first > 13;
    if(detectedFace.isRecognized){
        detectedFace.target = targets.at(bestMatch.second);
        detectedFace.index = bestMatch.second;
        _availableFlags.at(detectedFace.index) = false;
    }
    else{
        Target target;
        target.picture = face;
        target.name = "Inconnu";
        detectedFace.target = target;
    }

    return detectedFace;
}
开发者ID:aureooms-ulb-2010-2015,项目名称:2012-2013-infof309-facetube,代码行数:73,代码来源:Algorithm_FaceDetector_Surf.cpp


示例9: MatchActor

bool MatchActor(Scriptable *Sender, ieDword actorID, Object* oC)
{
	if (!Sender) {
		return false;
	}
	Actor *ac = Sender->GetCurrentArea()->GetActorByGlobalID(actorID);
	if (!ac) {
		return false;
	}

	// [0]/[ANYONE] can match all actors
	if (!oC) {
		return true;
	}

	bool filtered = false;

	// name matching
	if (oC->objectName[0]) {
		if (strnicmp(ac->GetScriptName(), oC->objectName, 32) != 0) {
			return false;
		}
		filtered = true;
	}

	// IDS targeting
	// (if we already matched by name, we don't do this)
	// TODO: check distance? area? visibility?
	if (!filtered && !DoObjectIDSCheck(oC, ac, &filtered)) return false;

	// globalID hack should never get here
	assert(oC->objectFilters[0] != -1);

	// object filters
	if (oC->objectFilters[0]) {
		// object filters insist on having a stupid targets list,
		// so we waste a lot of time here
		Targets *tgts = new Targets();
		int ga_flags = 0; // TODO: correct?

		// handle already-filtered vs not-yet-filtered cases
		// e.g. LastTalkedToBy(Myself) vs LastTalkedToBy
		if (filtered) tgts->AddTarget(ac, 0, ga_flags);

		tgts = DoObjectFiltering(Sender, tgts, oC, ga_flags);
		if (!tgts) return false;

		// and sometimes object filters are lazy and not only don't filter
		// what we give them, they clear it and return a list :(
		// so we have to search the whole list..
		bool ret = false;
		targetlist::iterator m;
		const targettype *tt = tgts->GetFirstTarget(m, ST_ACTOR);
		while (tt) {
			Actor *actor = (Actor *) tt->actor;
			if (actor->GetGlobalID() == actorID) {
				ret = true;
				break;
			}
			tt = tgts->GetNextTarget(m, ST_ACTOR);
		}
		delete tgts;
		if (!ret) return false;
	}
	return true;
}
开发者ID:AlanWasTaken,项目名称:gemrb,代码行数:66,代码来源:Matching.cpp


示例10: EvaluateObject

/* returns actors that match the [x.y.z] expression */
static Targets* EvaluateObject(Map *map, Scriptable* Sender, Object* oC, int ga_flags)
{
	// if you ActionOverride a global actor, they might not have a map :(
	// TODO: don't allow this to happen?
	if (!map) {
		return NULL;
	}

	if (oC->objectName[0]) {
		//We want the object by its name...
		Scriptable* aC = map->GetActor( oC->objectName, ga_flags );

		/*if (!aC && (ga_flags&GA_GLOBAL) ) {
			aC = FindActorNearby(oC->objectName, map, ga_flags );
		}*/

		//This order is the same as in GetActorObject
		//TODO:merge them
		if (!aC) {
			aC = map->GetTileMap()->GetDoor(oC->objectName);
		}
		if (!aC) {
			aC = map->GetTileMap()->GetContainer(oC->objectName);
		}
		if (!aC) {
			aC = map->GetTileMap()->GetInfoPoint(oC->objectName);
		}

		//return here because object name/IDS targeting are mutually exclusive
		return ReturnScriptableAsTarget(aC);
	}

	if (oC->objectFields[0]==-1) {
		// this is an internal hack, allowing us to pass actor ids around as objects
		Actor* aC = map->GetActorByGlobalID( (ieDword) oC->objectFields[1] );
		if (aC) {
			if (!aC->ValidTarget(ga_flags)) {
				return NULL;
			}
			return ReturnScriptableAsTarget(aC);
		}
		Door *door = map->GetDoorByGlobalID( (ieDword) oC->objectFields[1]);
		if (door) {
			return ReturnScriptableAsTarget(door);
		}

		Container* cont = map->GetContainerByGlobalID((ieDword) oC->objectFields[1]);
		if (cont) {
			return ReturnScriptableAsTarget(cont);
		}

		InfoPoint* trap = map->GetInfoPointByGlobalID((ieDword) oC->objectFields[1]);
		if (trap) {
			return ReturnScriptableAsTarget(trap);
		}

		return NULL;
	}

	Targets *tgts = NULL;

	//we need to get a subset of actors from the large array
	//if this gets slow, we will need some index tables
	int i = map->GetActorCount(true);
	while (i--) {
		Actor *ac = map->GetActor(i, true);
		if (!ac) continue; // is this check really needed?
		// don't return Sender in IDS targeting!
		if (ac == Sender) continue;
		bool filtered = false;
		if (DoObjectIDSCheck(oC, ac, &filtered)) {
			// this is needed so eg. Range trigger gets a good object
			// HACK: our parsing of Attack([0]) is broken
			if (!filtered) {
				// if no filters were applied..
				assert(!tgts);
				return NULL;
			}
			int dist;
			if (DoObjectChecks(map, Sender, ac, dist, (ga_flags & GA_DETECT) != 0)) {
				if (!tgts) tgts = new Targets();
				tgts->AddTarget((Scriptable *) ac, dist, ga_flags);
			}
		}
	}

	return tgts;
}
开发者ID:AlanWasTaken,项目名称:gemrb,代码行数:89,代码来源:Matching.cpp


示例11:

 Targets::Targets(const Targets & targets)
 {
   m_targets = targets.targets();
 }
开发者ID:aka2006,项目名称:RapidSVN,代码行数:4,代码来源:targets.cpp


示例12: main

int main( int argc, char** argv ){
	
//	ipxComm* ipx = new ipxComm( ipxPort ,false);	
	if(argc<3){
		std::cerr<<" no one targets !"<<std::endl;
		return 1;
	}
	int	inUdpPort=14310;
	char * ip = cip;
	inUdpPort = atoi(argv[1]);
	
	std::cout<<" udp to udp translator. udp port listen "<<inUdpPort<<std::endl;	
	
	//sockaddr_in	sa_out;
	//sa_out.sin_family = AF_INET;
	//sa_out.sin_addr.s_addr = inet_addr( ip );
	//sa_out.sin_port = htons( outUdpPort);

	int size = argc-2;
	Targets targets;
	std::string ipStr;
	int ipPort=0;
	for( int i = 2 ; i < argc ;i++ ){
		parseIp( std::string(argv[i]),ipStr,ipPort );
		sockaddr_in	sa_out;
		sa_out.sin_family = AF_INET;
		sa_out.sin_addr.s_addr = inet_addr( ipStr.c_str() );
		sa_out.sin_port = htons( ipPort );
		targets.push_back(sa_out);
		std::cout<<"target "<<ipStr<<":"<<ipPort<<" added "<<std::endl;
	}
 
	int sockOut = socket( PF_INET, SOCK_DGRAM , 0 );
	int sockIn = socket( PF_INET, SOCK_DGRAM , 0 );
	int flag = 1;
	
	sockaddr_in	sa_in;
	sa_in.sin_family = AF_INET;
	sa_in.sin_addr.s_addr = INADDR_ANY;
	sa_in.sin_port = htons( inUdpPort );
	if(!bind(sockIn,(sockaddr*)&sa_in,sizeof(sa_in))){
		std::cout<<" socket binded on port "<<inUdpPort<<std::endl;
	}

	unsigned char* pack = new unsigned char[packSize];
	unsigned char* udpPack = new unsigned char[packSize];
	Net::InfoPackHeader* iph = (Net::InfoPackHeader*)udpPack;
	if(!setsockopt(sockOut,SOL_SOCKET,SO_BROADCAST,&flag,sizeof(flag))){
		std::cout<<"Start work "<<std::endl;
		Targets::iterator start = targets.begin();
		Targets::iterator end = targets.end();
		while(1){		
			if( unsigned  recsize = recv(sockIn,pack,packSize,0)){
				while( start != end ){
					if( sendto(sockOut,pack,recsize,MSG_NOSIGNAL,(sockaddr*)(&(*start)),sizeof(sockaddr_in)) <0 ){
						std::cout<<"can`t send to "<<(*start).sin_port<<std::endl; 
					}else{
						std::cout<<"packsize "<<recsize<<" send to "<<inet_ntoa((*start).sin_addr)<<":"<<ntohs( (*start).sin_port )<<std::endl; 	
					}	
					++start;
				}	
				start = targets.begin();
				std::cout<<std::endl;
			
			}
		}	
	}
	
	return 0;
}
开发者ID:boris-r-v,项目名称:STD,代码行数:70,代码来源:udp2udp.cpp


示例13: process

void FaceDetector_Surf::process(const cv::Mat &in, cv::Mat &out) {
    this->_allTargetsLock.lock();
	Targets targets = this->_allTargets;
	this->_trackedFacesLock.lock();
	TrackedFaces lastlyTrackedFaces = this->_trackedFaces;
	this->_trackedFacesLock.unlock();
	this->_allTargetsLock.unlock();

    _availableFlags.clear();
    _availableFlags.resize(targets.size(), true);

    // Create a new image based on the input image
	//out = in.clone();

	//invert x axis (1 for x axis)
	cv::Mat temp;
	cv::flip(in,temp,1);
	out = temp.clone();

    // There can be more than one face in an image
    std::vector<cv::Rect> faces;

    // Detect the objects and store them in the sequence
	this->_classifier.detectMultiScale(temp, faces, 1.2, 3, CV_HAAR_DO_CANNY_PRUNING, cv::Size(25, 25));

    // Loop the number of faces found.
    for( size_t i = 0; i < faces.size(); ++i )  {
        // Draw the rectangle in the input image
        cv::rectangle( out, faces.at(i), cv::Scalar(255,0,0), 3, 8, 0);
    }

    cv::Point point;
    point.x = 20;
    point.y = 20;

    std::ostringstream faces_;
    faces_ << "Number of Faces : " << faces.size();

    cv::putText(out, faces_.str(), point, cv::FONT_HERSHEY_COMPLEX_SMALL, 0.8, cv::Scalar(255,0,0), 1, CV_AA);

    DetectedFaces detectedFaces;
    TrackedFaces trackedFaces;
    for (const cv::Rect& face : faces){

		DetectedFace detectedFace = recognize(temp, face, targets, lastlyTrackedFaces);

        detectedFaces.push_back(detectedFace);
        if(detectedFace.isRecognized){
            cv::Point label;
            label.x = face.tl().x + face.width/2 - detectedFace.target.name.size()*10/2;
            label.y = face.br().y + 15;
            cv::putText(out, detectedFace.target.name, label, cv::FONT_HERSHEY_COMPLEX_SMALL, 0.8, cv::Scalar(255,0,0), 1, CV_AA);

            TrackedFace trackedFace;
            trackedFace.rect = face;
            trackedFace.target = detectedFace.target;
            trackedFace.index = detectedFace.index;

            trackedFaces.push_back(trackedFace);
        }
    }

    this->_currentFacesLock.lock();
    this->_currentFaces = detectedFaces;
    this->_currentFacesLock.unlock();
	this->_trackedFacesLock.lock();
	this->_trackedFaces = trackedFaces;
	for(size_t ind : this->_removedDuringProcessing){
		size_t j = 0;
		for(size_t i = 0; i < this->_trackedFaces.size(); ++i){
			if(this->_trackedFaces.at(i-j).index == ind){
				this->_trackedFaces.erase(this->_trackedFaces.begin()+i-j);
				++j;
			}
		}
	}
	this->_removedDuringProcessing.clear();
	this->_trackedFacesLock.unlock();


    return;
}
开发者ID:aureooms-ulb-2010-2015,项目名称:2012-2013-infof309-facetube,代码行数:82,代码来源:Algorithm_FaceDetector_Surf.cpp



注:本文中的Targets类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Task类代码示例发布时间:2022-05-31
下一篇:
C++ TargetedWriteBatch类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap