Beispiel #1
0
void	colle04(int x, int y)
{
	int xa;
	int ya;
	int pos;

	xa = 1;
	ya = 1;
	pos = 0;
	while (ya <= y)
	{
		xa = 1;
		ft_putchar('\n');
		while (xa <= x)
		{
			if (ya == 1)
			{
				pos = 0;
				detection(xa,ya,x,y,pos);
			}
			else if (ya == y)
			{
				pos = 6;
				detection(xa,ya,x,y,pos);
			}
			else
			{
				pos = 3;
				detection(xa,ya,x,y,pos);
			}
			xa++;
		}
		ya++;
	}
}
Beispiel #2
0
void movement::lookAroundFindBall() {
	ballDetection detection(p3dxptr);
	int ballseen = detection.moveToBall();
	int rotatedToBall = detection.rotateToBall();
	while(p3dxptr->isConnected() && (key == 'l')) {
		p3dxptr->comInt(ArCommands::VEL, Vel_Value);
		while((p3dxptr->getClosestSonarRange(-105, 105) > 500) || (ballseen == 1)) {
			ballseen = detection.moveToBall();
			detection.reached();
		}
		p3dxptr->comInt(ArCommands::VEL, 0);
		//ArUtil::sleep(500);
		if(p3dxptr->getClosestSonarRange(1,105) <= 500) {
			p3dxptr->comInt(ArCommands::RVEL, -Rot_Value);
		}
		if(p3dxptr->getClosestSonarRange(-105,0) <= 500) {
			p3dxptr->comInt(ArCommands::RVEL, Rot_Value);
		}
		while(p3dxptr->getClosestSonarRange(-105, 105) <= 500) {
			ballseen = detection.moveToBall();
			detection.reached();
		}
		p3dxptr->comInt(ArCommands::RVEL, 0);
		ArUtil::sleep(500);
		//cout << "Weiter erkunden? druecke l" << endl;
		
		//}
	}
}
Beispiel #3
0
int main(int argc, char **argv)
{
	long long L1,L2;
	timeval tv;
//Initialize MPI enviroment
	MPI::Init(argc,argv);
	totalProcNum=MPI::COMM_WORLD.Get_size();
	nowProcID=MPI::COMM_WORLD.Get_rank();	
	
	if(nowProcID==0)
	{
		init(maxN);
		gettimeofday(&tv,NULL);
		L1=tv.tv_sec*1000*1000+tv.tv_usec;
		LUResolveSeq(maxN,A);
		gettimeofday(&tv,NULL);
		L2=tv.tv_sec*1000*1000+tv.tv_usec;
		printf("Sequen time: %lldus\n",L2-L1);	
	}
	MPI::COMM_WORLD.Barrier();
//There just use barrier to sychronize and prevent other Processes begin to timing


	gettimeofday(&tv,NULL);
	L1=tv.tv_sec*1000*1000+tv.tv_usec;
	LUResolveMPI(maxN,B);
	gettimeofday(&tv,NULL);
	L2=tv.tv_sec*1000*1000+tv.tv_usec;
	printf("I am Process %d, MPINop time: %lldus\n",nowProcID,L2-L1);		

//	gettimeofday(&tv,NULL);
//	L1=tv.tv_sec*1000*1000+tv.tv_usec;
	//LUResolveMPIPipeLine(maxN,C);
//	gettimeofday(&tv,NULL);
//	L2=tv.tv_sec*1000*1000+tv.tv_usec;
//	printf("I am Process %d, MPIPip time: %lldus\n",nowProcID,L2-L1);		
	
	if(nowProcID==0)
	{
		detection();
		printf("errors is: %lf\n",error);
	}	
	MPI::Finalize();
	return 0;

}
Beispiel #4
0
//--------------------------------------------------------------
void Vision::computerVision(){
    
    bool bNewFrame = false;
    
    vidGrabber.update();
    bNewFrame = vidGrabber.isFrameNew();
    
	if (bNewFrame){
        
        if( vidGrabber.getPixels() != NULL ){
            
            colorImg.setFromPixels(vidGrabber.getPixels(), capW, capH);
            
            detection();
            
		}
	} 
}
Beispiel #5
0
void	algo(t_all *a)
{
    t_sqr	s;

    s.px = 0;
    s.py = 0;
    s.t = 1;
    while (a->tab[s.py][s.px])
    {
        while (a->tab[s.py][s.px])
        {
            if (a->tab[s.py][s.px] == '.')
                detection(a, &s);
            s.px = s.px + 1;
        }
        s.py = s.py + 1;
        s.px = 0;
    }
}
Beispiel #6
0
std::vector<vector<float> > _SSD::detect(Frame* pFrame)
{
    vector<vector<float> > detections;

    if(pFrame==NULL)return detections;
    if(pFrame->empty())return detections;

    Blob<float>* input_layer = net_->input_blobs()[0];
    input_layer->Reshape(1, num_channels_, input_geometry_.height, input_geometry_.width);
    /* Forward dimension change to all layers. */
    net_->Reshape();

    std::vector<cv::cuda::GpuMat> input_channels;
    WrapInputLayer(&input_channels);
    Preprocess(*pFrame->getGMat(), &input_channels);

//	std::vector<cv::Mat> input_channels;
//	WrapInputLayer(&input_channels);
//	Preprocess(*pFrame->getCMat(), &input_channels);

    net_->Forward();

    /* Copy the output layer to a std::vector */
    Blob<float>* result_blob = net_->output_blobs()[0];
    const float* result = result_blob->cpu_data();
    const int num_det = result_blob->height();
    for (int k = 0; k < num_det; ++k)
    {
        if (result[0] == -1)
        {
            // Skip invalid detection.
            result += 7;
            continue;
        }
        vector<float> detection(result, result + 7);
        detections.push_back(detection);
        result += 7;
    }

    return detections;
}
Beispiel #7
0
static bool cast_priest_spell(int Ind, int spell)
{
	player_type 	*p_ptr = Players[Ind];
	object_type		*o_ptr;
	int py = p_ptr->py;
	int px = p_ptr->px;
	int Depth = p_ptr->dun_depth;

	int dir;

	int plev = p_ptr->lev;
	
	switch (spell)
	{
		case PRAYER_DETECT_EVIL:
		{
			(void)detect_evil(Ind);
			break;
		}

		case PRAYER_CURE_LIGHT_WOUNDS:
		{
			(void)hp_player(Ind, damroll(2, 10));
			(void)set_cut(Ind, p_ptr->cut - 10);
			break;
		}
		/* MAngband-specific: Heal Projectile */
		case PRAYER_CURE_LIGHT_WOUNDS + SPELL_PROJECTED:
		{
			if (!get_aim_dir(Ind, &dir)) return FALSE;
			(void)heal_player_ball(Ind, dir, damroll(2, 8));
			break;
		}

		case PRAYER_BLESS:
		{
			(void)set_blessed(Ind, p_ptr->blessed + randint(12) + 12);
			break;
		}

		case PRAYER_REMOVE_FEAR:
		{
			(void)set_afraid(Ind, 0);
			break;
		}

		case PRAYER_CALL_LIGHT:
		{
			msg_prayer("%s calls light.");
			(void)lite_area(Ind, damroll(2, (plev / 2)), (plev / 10) + 1);
			break;
		}

		case PRAYER_FIND_TRAPS:
		{
			(void)detect_trap(Ind);//detect_traps(Ind)
			break;
		}

		case PRAYER_DETECT_DOORS_STAIRS:
		{
			(void)detect_sdoor(Ind);//detect_doors(Ind);
			//(void)detect_stairs();
			break;
		}

		case PRAYER_SLOW_POISON:
		{
			(void)set_poisoned(Ind, p_ptr->poisoned / 2);
			break;
		}

		case PRAYER_SCARE_MONSTER:
		{
			if (!get_aim_dir(Ind, &dir)) return (FALSE);
			(void)fear_monster(Ind, dir, plev);
			break;
		}

		case PRAYER_PORTAL:
		{
			msg_prayer("%s blinks away!");
			teleport_player(Ind, plev * 3);
			break;
		}

		case PRAYER_CURE_SERIOUS_WOUNDS:
		{
			(void)hp_player(Ind, damroll(4, 10));
			(void)set_cut(Ind, (p_ptr->cut / 2) - 20);
			break;
		}
		/* MAngband-specific: Heal Projectile */
		case PRAYER_CURE_SERIOUS_WOUNDS + SPELL_PROJECTED:
		{
			if (!get_aim_dir(Ind, &dir)) return FALSE;
			(void)heal_player_ball(Ind, dir, damroll(4, 10));
			break;
		}

		case PRAYER_CHANT:
		{
			(void)set_blessed(Ind, p_ptr->blessed + randint(24) + 24);
			break;
		}

		case PRAYER_SANCTUARY:
		{
			msg_prayer("For a brief moment, %s is enclosed by a deep blue aura.");
			(void)sleep_monsters_touch(Ind);
			break;
		}

		case PRAYER_SATISFY_HUNGER:
		{
			(void)set_food(Ind, PY_FOOD_MAX - 1);
			break;
		}

		case PRAYER_REMOVE_CURSE:
		{
			remove_curse(Ind);
			break;
		}

		case PRAYER_RESIST_HEAT_COLD:
		{
			(void)set_oppose_fire(Ind, p_ptr->oppose_fire + randint(10) + 10);
			(void)set_oppose_cold(Ind, p_ptr->oppose_cold + randint(10) + 10);
			break;
		}

		case PRAYER_NEUTRALIZE_POISON:
		{
			(void)set_poisoned(Ind, 0);
			break;
		}

		case PRAYER_ORB_OF_DRAINING:
		{
			if (!get_aim_dir(Ind, &dir)) return (FALSE);
			msg_prayer("%s fires a holy orb!"); 
			fire_ball(Ind, GF_HOLY_ORB, dir,
			          (damroll(3, 6) + plev +
			           (plev / ((p_ptr->cp_ptr->flags & CF_BLESS_WEAPON) ? 2 : 4))),
			          ((plev < 30) ? 2 : 3));
			break;
		}

		case PRAYER_CURE_CRITICAL_WOUNDS:
		{
			(void)hp_player(Ind, damroll(6, 10));
			(void)set_cut(Ind, 0);
			break;
		}
		/* MAngband-specific: Heal Projectile */
		case PRAYER_CURE_CRITICAL_WOUNDS + SPELL_PROJECTED:
		{
			if (!get_aim_dir(Ind, &dir)) return FALSE;
			(void)heal_player_ball(Ind, dir, damroll(6, 10));
			break;
		}

		case PRAYER_SENSE_INVISIBLE:
		{
			(void)set_tim_invis(Ind, p_ptr->tim_invis + randint(24) + 24);
			break;
		}

		case PRAYER_PROTECTION_FROM_EVIL:
		{
			(void)set_protevil(Ind, p_ptr->protevil + randint(25) + 3 * p_ptr->lev);
			break;
		}

		case PRAYER_EARTHQUAKE:
		{
			msg_prayer("%s murmurs, and the ground shakes!");
			earthquake(Depth, py, px, 10);
			break;
		}

		case PRAYER_SENSE_SURROUNDINGS:
		{
			map_area(Ind);
			break;
		}

		case PRAYER_CURE_MORTAL_WOUNDS:
		{
			(void)hp_player(Ind, damroll(8, 10));
			(void)set_stun(Ind, 0);
			(void)set_cut(Ind, 0);
			break;
		}
		/* MAngband-specific: Heal Projectile */
		case PRAYER_CURE_MORTAL_WOUNDS + SPELL_PROJECTED:
		{
			if (!get_aim_dir(Ind, &dir)) return FALSE;
			(void)heal_player_ball(Ind, dir, damroll(8, 10));
			break;
		}

		case PRAYER_TURN_UNDEAD:
		{
			msg_prayer("%s tries to turn undead.");
			(void)turn_undead(Ind);
			break;
		}

		case PRAYER_PRAYER:
		{
			(void)set_blessed(Ind, p_ptr->blessed + randint(48) + 48);
			break;
		}

		case PRAYER_DISPEL_UNDEAD:
		{
			msg_prayer("%s dispells undead.");
			(void)dispel_undead(Ind, randint(plev * 3));
			break;
		}

		case PRAYER_HEAL:
		{
			(void)hp_player(Ind, 300);
			(void)set_stun(Ind, 0);
			(void)set_cut(Ind, 0);
			break;
		}
		/* MAngband-specific: Heal Projectile */
		case PRAYER_HEAL + SPELL_PROJECTED:
		{
			if (!get_aim_dir(Ind, &dir)) return FALSE;
			(void)heal_player_ball(Ind, dir, 300);
			break;
		}

		case PRAYER_DISPEL_EVIL:
		{
			msg_prayer("%s dispells evil.");
			(void)dispel_evil(Ind, randint(plev * 3));
			break;
		}

		case PRAYER_GLYPH_OF_WARDING:
		{
			if (warding_glyph(Ind))
			{
				msg_prayer("%s lays down a glyph of warding.");
			}
			break;
		}

		case PRAYER_HOLY_WORD:
		{
			msg_prayer("%s shouts the holy word.");
			(void)dispel_evil(Ind, randint(plev * 4));
			(void)hp_player(Ind, 1000);
			(void)set_afraid(Ind, 0);
			(void)set_poisoned(Ind, 0);
			(void)set_stun(Ind, 0);
			(void)set_cut(Ind, 0);
			break;
		}

		case PRAYER_DETECT_MONSTERS:
		{
			(void)detect_creatures(Ind, TRUE);
			break;
		}

		case PRAYER_DETECTION:
		{
			(void)detection(Ind);//detect_all(Ind)
			break;
		}

		case PRAYER_PERCEPTION:
		{
			return ident_spell(Ind);
		}

		case PRAYER_PROBING:
		{
			(void)probing(Ind);
			break;
		}

		case PRAYER_CLAIRVOYANCE:
		{
			msg_prayer("An image of your surroundings forms in your mind...");
			wiz_lite(Ind);
			break;
		}

		case PRAYER_CURE_SERIOUS_WOUNDS2:
		{
			(void)hp_player(Ind, damroll(4, 10));
			(void)set_cut(Ind, 0);
			break;
		}
		/* MAngband-specific: Heal Projectile */
		case PRAYER_CURE_SERIOUS_WOUNDS2 + SPELL_PROJECTED:
		{
			if (!get_aim_dir(Ind, &dir)) return FALSE;
			(void)heal_player_ball(Ind, dir, damroll(4, 10));
			break;
		}

		case PRAYER_CURE_MORTAL_WOUNDS2:
		{
			(void)hp_player(Ind, damroll(8, 10));
			(void)set_stun(Ind, 0);
			(void)set_cut(Ind, 0);
			break;
		}
		/* MAngband-specific: Heal Projectile */
		case PRAYER_CURE_MORTAL_WOUNDS2 + SPELL_PROJECTED:
		{
			if (!get_aim_dir(Ind, &dir)) return FALSE;
			(void)heal_player_ball(Ind, dir, damroll(8, 10));
			break;
		}

		case PRAYER_HEALING:
		{
			(void)hp_player(Ind, 2000);
			(void)set_stun(Ind, 0);
			(void)set_cut(Ind, 0);
			break;
		}
		/* MAngband-specific: Heal Projectile */
		case PRAYER_HEALING + SPELL_PROJECTED:
		{
			if (!get_aim_dir(Ind, &dir)) return FALSE;
			(void)heal_player_ball(Ind, dir, 2000);
			break;
		}
		/* With MAngband-specific addon: ressurect ghosts */
		case PRAYER_RESTORATION:
		{
			if (!do_scroll_life(Ind))
			{
				(void)do_res_stat(Ind, A_STR);
				(void)do_res_stat(Ind, A_INT);
				(void)do_res_stat(Ind, A_WIS);
				(void)do_res_stat(Ind, A_DEX);
				(void)do_res_stat(Ind, A_CON);
				(void)do_res_stat(Ind, A_CHR);
			}
			break;
		}
		/* With Mangband-sepcific addon: restore others */
		case PRAYER_REMEMBRANCE:
		{
			if (!do_restoreXP_other(Ind))
			{
				(void)restore_level(Ind);
			}
			break;
		}

		case PRAYER_DISPEL_UNDEAD2:
		{
			msg_prayer("%s dispells undead.");
			(void)dispel_undead(Ind, randint(plev * 4));
			break;
		}

		case PRAYER_DISPEL_EVIL2:
		{
			msg_prayer("%s dispells evil.");
			(void)dispel_evil(Ind, randint(plev * 4));
			break;
		}

		case PRAYER_BANISH_EVIL:
		{
			msg_prayer("%s speaks a holy curse on nearby evil!");
			if (banish_evil(Ind, 100))
			{
				msg_print(Ind, "The power of your god banishes evil!");
			}
			break;
		}

		case PRAYER_WORD_OF_DESTRUCTION:
		{
			msg_prayer("%s unleashes a spell of great power!");
			destroy_area(Depth, py, px, 15, TRUE);
			break;
		}

		case PRAYER_ANNIHILATION:
		{
			if (!get_aim_dir(Ind, &dir)) return (FALSE);
			msg_prayer("%s fires a massive bolt filled with pure energy!");
			drain_life(Ind, dir, 200);
			break;
		}

		case PRAYER_UNBARRING_WAYS:
		{
			msg_prayer("%s sways his hands.");
			(void)destroy_doors_touch(Ind);
			break;
		}

		case PRAYER_RECHARGING:
		{
			return recharge(Ind, 15);
		}

		case PRAYER_DISPEL_CURSE:
		{
			(void)remove_all_curse(Ind);
			break;
		}

		case PRAYER_ENCHANT_WEAPON:
		{
			return enchant_spell(Ind, rand_int(4) + 1, rand_int(4) + 1, 0);
		}

		case PRAYER_ENCHANT_ARMOUR:
		{
			return enchant_spell(Ind, 0, 0, rand_int(3) + 2);
		}

		case PRAYER_ELEMENTAL_BRAND:
		{
			brand_weapon(Ind);
			break;
		}

		case PRAYER_BLINK:
		{
			msg_prayer("%s blinks away!");
			teleport_player(Ind, 10);
			break;
		}

		case PRAYER_TELEPORT_SELF:
		{
			msg_prayer("%s teleports away!");
			teleport_player(Ind, plev * 8);
			break;
		}

		case PRAYER_TELEPORT_OTHER:
		{
			if (!get_aim_dir(Ind, &dir)) return (FALSE);
			msg_prayer("%s prays for divine intervention.");
			(void)teleport_monster(Ind, dir);
			break;
		}

		case PRAYER_TELEPORT_LEVEL:
		{
			(void)teleport_player_level(Ind);
			break;
		}

		case PRAYER_WORD_OF_RECALL:
		{
			o_ptr = &p_ptr->inventory[get_spell_book(Ind, spell)];
			set_recall(Ind, o_ptr);
			break;
		}

		case PRAYER_ALTER_REALITY:
		{
			(void)alter_reality(Ind, FALSE);
			break;
		}

		/* Paranoia: shouldn't happen with safe clients */
		default:
		{
			msg_print(Ind, "You cannot project that spell on other players.");
			return (FALSE);
		}
	}

	/* Success */
	return (TRUE);
}
int main()
{
	const char *topoFileName = "topo.csv";
	const char *resultFileName = "result.csv";

	FILE * topocsv = fopen(topoFileName, "r");
	FILE * resultcsv = fopen(resultFileName, "r");
	if( !topocsv || !resultcsv )
	{
		printf("open file error!(1)\n");
		exit(EXIT_FAILURE);
	}

	Topo topo[5000];
	int topoCount = 0, topoIndex = 0;
	
	//保存经过的所有节点的数组
	int node[1000];
	int nodeArrayCount = 0;

	//存储topo.csv文件的一行字符串
	//存储sample_result.csv文件的一整行字符串
	char routeEdgeString[5000] = {0};
	int routeEdgeStringIndex = 0;

	//临时变量声明区
	//临时存储从文件读取的一行字符串数据
	char tmpStrLine[20] = {0};
	int tmpmpStrLineIndex = 0;
	int tmpEdgeNumber = 0;

	//初始化
	memset(topo, 0, 5000*sizeof(Topo));
	memset(routeEdgeString, 0, 5000);

	for(int i=0; i<1000; i++)
		node[i] = -1;

	//初始化topo数组
	while( !feof(topocsv) )
	{
		fgets(tmpStrLine, 20, topocsv);
		topo[topoCount].edgeNumber = atoi(tmpStrLine);
		while( tmpStrLine[tmpmpStrLineIndex++] != ',' )
			continue;
		topo[topoCount].src = atoi(&tmpStrLine[tmpmpStrLineIndex]);
		while( tmpStrLine[tmpmpStrLineIndex++] != ',' )
			continue;
		topo[topoCount].dst = atoi(&tmpStrLine[tmpmpStrLineIndex]);

		topoCount++;
		tmpmpStrLineIndex = 0;
	}

	fgets(routeEdgeString, 10000, resultcsv);
	if( strcmp(routeEdgeString, "NA") == 0 )
	{
		printf("NA\n");
		return 1;
	}

	tmpEdgeNumber = atoi(routeEdgeString);
	while(topo[topoIndex].edgeNumber != tmpEdgeNumber)
			topoIndex++;
	if( topoIndex==topoCount )
	{
		printf("error!\n");
		exit(EXIT_FAILURE);
	}
	printf("%d-->%d", topo[topoIndex].src, topo[topoIndex].dst);
	node[nodeArrayCount++] = topo[topoIndex].src;
	node[nodeArrayCount++] = topo[topoIndex].dst;

	topoIndex = 0;

	while(1)
	{
		while(routeEdgeString[routeEdgeStringIndex++] != '|' && routeEdgeString[routeEdgeStringIndex])
			continue;

		if(routeEdgeString[routeEdgeStringIndex] == '\0')
			break;

		tmpEdgeNumber = atoi(&routeEdgeString[routeEdgeStringIndex]);

		while(topo[topoIndex].edgeNumber != tmpEdgeNumber)
			topoIndex++;
		if( topoIndex==topoCount )
		{
			printf("error!\n");
			exit(EXIT_FAILURE);
		}

		printf("-->%d", topo[topoIndex].dst);
		node[nodeArrayCount++] = topo[topoIndex].dst;

		topoIndex = 0;
	}


	printf("\n");

	if(detection(node, nodeArrayCount))
		printf("OK\n");
	else
		printf("Error\n");


	printf("\n");

	fclose(topocsv);
	fclose(resultcsv);
	
	return 0;
}
Beispiel #9
0
/*!
 * \brief Processor::run
 */
void VideoProcessor::run()
{
    QVector<int> lightPixelsNumbers;
    QVector<double> lightPixelsMeans;
    QVector<double> timeStamps;
    
    if(autodetection){
        emit detection();
        QRect rect = lightDetector->detectLight(filename, qMakePair(range.first, range.second)); 
        if(stop){
            stop = false;
            return;
        }
        imageProcessor->setBounds(rect);
        emit rectChanged(rect);
    }
    
    CaptureWrapper capture(filename);
    try{
        capture.isOpened();
        
        int frameNumber = int(capture.get(CV_CAP_PROP_FRAME_COUNT));
        int fps = Utils::Video::getAVIFPS(filename.toStdString());
        
        lightDetector->fixRange(range, fps, frameNumber);
        
        if(range.first >= range.second 
                && range.first > std::numeric_limits<double>::epsilon() 
                && range.second > std::numeric_limits<double>::epsilon()){
            return;
        }
        
        int absIndex = 0;
        
        for(int i = 0; i < int(range.first * fps); ++i, ++absIndex){
            capture.grab();
        }
        
        cv::Mat frame;
        
        for(int i = int(range.first * fps); i < int(range.second * fps); i++){
            if (stop) {
                stop = false;
                break;
            }
            
            capture >> frame;
            
            cv::Mat grayFrame;
            cv::cvtColor(frame, grayFrame, CV_BGR2GRAY, 1);
            cv::flip(grayFrame, grayFrame, 0);
            
            QPair<int, double> processingResult;
            
            if(imageProcessor){
                imageProcessor->setH_size(QSize(640, 480));
                processingResult = imageProcessor->process(grayFrame);
            }else{
                QMessageBox::critical(0, "Error", "No image processor is set!\nContact with developer!");
                processingResult = qMakePair(0, 0.0l);
            }
            
            lightPixelsNumbers.push_back(processingResult.first);
            lightPixelsMeans.push_back(processingResult.second);
            
            absIndex++;
            
            int relIndex = absIndex - int(range.first * fps);
            
            const int hundreds = int((range.second - range.first) * fps) / 100;
            if (hundreds && !(relIndex % (hundreds))) {
                emit progress(relIndex / (hundreds));
            }
            
            double timestamp = absIndex / double(fps);
            timeStamps.push_back(timestamp);
            emit time(timestamp);
            
            QThread::currentThread()->usleep(50);
        }
        
        
        std::shared_ptr<Results> results(new Results);
        results->resultsNumbers = lightPixelsNumbers;
        results->resultMeans = lightPixelsMeans;
        results->timeStamps = timeStamps;

    
        emit displayResults(results);
        emit progress(100);
    }
    catch(CaptureError e){
        QMessageBox::critical(0, "Error", e.getMessage());
        return;
    }
}
Beispiel #10
0
static void detectionWithPrediction(float** quotaBuffer,
                                    char* indexVector,
                                    float** pDiffVecScfb,
                                    int nSfb,
                                    const unsigned char* pFreqBandTable,
                                    float** sfmOrig,
                                    float** sfmSbr,
                                    unsigned char ** detectionVectors,
                                    unsigned char* prevFrameSfbHarm,
                                    GUIDE_VECTORS* guideVectors,
                                    int noEstPerFrame,
                                    int totNoEst,
                                    int newDetectionAllowed,
                                    unsigned char* pAddHarmonicsScaleFactorBands)
{
  int est = 0,i;
  int start;

  

   /* counting previous operation */

      
  memset(pAddHarmonicsScaleFactorBands,0,nSfb*sizeof(unsigned char));

  
  if(newDetectionAllowed){

     
    if(totNoEst > 1){

      
      start = noEstPerFrame;

          
      memcpy(guideVectors[noEstPerFrame].guideVectorDiff,guideVectors[0].guideVectorDiff,nSfb*sizeof(float));

          
      memcpy(guideVectors[noEstPerFrame].guideVectorOrig,guideVectors[0].guideVectorOrig,nSfb*sizeof(float));

          
      memset(guideVectors[noEstPerFrame-1].guideVectorDetected,0,nSfb*sizeof(unsigned char));
    }
    else{

      
      start = 0;
    }
  }
  else{

    
    start = 0;
  }


   /* guideVectors[],
                  detectionVectors[]
                  quotaBuffer[]
                  pDiffVecScfb[]
                  sfmOrig[]
                  sfmSbr[]
               */
  
  for(est = start; est < totNoEst; est++){

    
    if(est > 0){
          
      memcpy(guideVectors[est].guideVectorDetected,detectionVectors[est-1],nSfb*sizeof(unsigned char));
    }

        
    memset(detectionVectors[est], 0, nSfb*sizeof(unsigned char));

     
    if(est < totNoEst-1){
          
      memset(guideVectors[est+1].guideVectorDiff,0,nSfb*sizeof(float));

          
      memset(guideVectors[est+1].guideVectorOrig,0,nSfb*sizeof(float));

          
      memset(guideVectors[est+1].guideVectorDetected,0,nSfb*sizeof(unsigned char));

      
      detection(quotaBuffer[est],
                indexVector,
                pDiffVecScfb[est],
                nSfb,
                detectionVectors[est],
                pFreqBandTable,
                sfmOrig[est],
                sfmSbr[est],
                guideVectors[est],
                guideVectors[est+1],
                newDetectionAllowed);
    }
    else{
          
      memset(guideVectors[est].guideVectorDiff,0,nSfb*sizeof(float));

          
      memset(guideVectors[est].guideVectorOrig,0,nSfb*sizeof(float));

          
      memset(guideVectors[est].guideVectorDetected,0,nSfb*sizeof(unsigned char));

      
      detection(quotaBuffer[est],
                indexVector,
                pDiffVecScfb[est],
                nSfb,
                detectionVectors[est],
                pFreqBandTable,
                sfmOrig[est],
                sfmSbr[est],
                guideVectors[est],
                guideVectors[est],
                newDetectionAllowed);
    }


  }



  
  if(newDetectionAllowed){

     
    if(totNoEst > 1){

       
      transientCleanUp(quotaBuffer,
                       pDiffVecScfb,
                       nSfb,
                       detectionVectors,
                       pFreqBandTable,
                       guideVectors[noEstPerFrame],
                       newDetectionAllowed,
                       start,
                       totNoEst);
    }
    else{

       
       transientCleanUp(quotaBuffer,
                       pDiffVecScfb,
                       nSfb,
                       detectionVectors,
                       pFreqBandTable,
                       guideVectors[0],
                       newDetectionAllowed,
                       start,
                       totNoEst);
    }
  }



   /* pAddHarmonicsScaleFactorBands[] */
  
  for(i = 0; i< nSfb; i++){

     /* detectionVectors[][] */
    
    for(est = start; est < totNoEst; est++){

       
      pAddHarmonicsScaleFactorBands[i] = pAddHarmonicsScaleFactorBands[i] || detectionVectors[est][i];
    }
  }


  
  if(!newDetectionAllowed){
     /* pAddHarmonicsScaleFactorBands[]
                    prevFrameSfbHarm[]
                 */
    
    for(i=0;i<nSfb;i++){

       
      if(pAddHarmonicsScaleFactorBands[i] - prevFrameSfbHarm[i] > 0)
      {

        
        pAddHarmonicsScaleFactorBands[i] = 0;
      }
    }
  }

  
}