コード例 #1
0
ファイル: dns_manager.cpp プロジェクト: hill9932/CodeCorner
void CDNSManager::threadFunc()
{
    while (!isStop())
    {
        if (m_pendingRecords.size() == 0)
        {
            getNextRecords(GetMainRecordCallback);
        }

        //
        // use libevent to do the dns lookup
        //
        s_pendingLookupCount = m_pendingRecords.size();
        vector<DNS_RECORD_t*>::iterator it = m_pendingRecords.begin();
        for (; it != m_pendingRecords.end(); ++it)
        {
            lookupDNS(**it);
        }

        if (s_pendingLookupCount == 0)
        {
            if (!addRecords())  // add the new records to database
                SleepMS(10);
        }
        else
        {
            event_base_dispatch(m_evbase);  // wait until all the lookup are finished
            updateRecords();
        }
    }
}
コード例 #2
0
ファイル: control.cpp プロジェクト: jokerlee/college
void control( void )
{
	while (1)
	{
	 	if ( isWait() )
			waiting();	

		eleStat.dir = newDirection( eleStat.dir, eleStat.floor );

		if ( isStop( eleStat.dir, eleStat.floor ) )
			stop( eleStat.dir, eleStat.floor );


		showDir( eleStat.dir );

		if ( eleStat.dir != 0 && !isStop( eleStat.dir, eleStat.floor ) )
			move( eleStat.dir, &eleStat.floor );
	}			 
}
コード例 #3
0
ファイル: VideoProcessor.cpp プロジェクト: 1a2b/QtEVM
/** 
 * prevFrame	-	display the prev frame of the sequence
 *
 */
void VideoProcessor::prevFrame()
{
    if(isStop())
        pauseIt();
    if (curPos >= 0){
        curPos -= 1;
        jumpTo(curPos);
    }
    emit updateProgressBar();
}
コード例 #4
0
void Player::Play()
{
    if (!isRunning())
    {
        if (isStop())
        {
            stop = false;
        }
        start(LowPriority);
    }
}
コード例 #5
0
ファイル: control.cpp プロジェクト: jokerlee/college
int newDirection( int dir, int floor )
{
	int i;
	if ( dir == 0 )
		for ( i=1; i<=maxFloor; i++ )
			if ( isStop( dir, i ) )
				return (i-floor)>0?1:-1;
	if ( dir == 0 ) dir = 1;
	//搜同方向
	for ( i=floor+dir; i<=maxFloor && i>0; i+=dir )
		if ( isStop( dir, i ) )
			return dir;
	//搜反方向
	for ( i=floor-dir; i<=maxFloor && i>0; i-=dir )
		if ( isStop( -dir, i ) )
			return -dir;
	
	//无请求
	return 0;
}
コード例 #6
0
ファイル: VideoProcessor.cpp プロジェクト: 1a2b/QtEVM
/** 
 * nextFrame	-	display the next frame of the sequence
 *
 */
void VideoProcessor::nextFrame()
{
    if(isStop())
        pauseIt();
    curPos += 1;
    if (curPos <= length){
        curPos += 1;
        jumpTo(curPos);
    }
    emit updateProgressBar();
}
コード例 #7
0
ファイル: processex.cpp プロジェクト: visualfc/liteide
void Process::stop(int ms)
{
    if (isStop()) {
        return;
    }
    terminate();
    closeReadChannel(QProcess::StandardOutput);
    closeReadChannel(QProcess::StandardError);
    if (!waitForFinished(ms)) {
        kill();
    }
}
コード例 #8
0
ファイル: CQifuluxingshi.cpp プロジェクト: ZTOMarcy/GPS
int CQifuluxingshi::run(){
	double minSpeed = 3;
	if (runTimes==0 && m_Car->m_speed >= theSpeedBeforeEnter){
		runTimes = 1;
		SetMessage(_T("通过起伏路面前未减速-10"));
		return 1;
	}

	if (isStop()){
		SetMessage(_T("中途停车-100"));
		return 0;
	}
	if (m_Car->m_speed > minSpeed){ //如果车速过快
		SetMessage(_T("通过起伏路面时,车速控制不当,车辆严重跳跃-100"));
		return 0;
	}

	if (!flag_passLine1&&isCutLine1()){
		flag_passLine1 = true;
	}

	if (!flag_passLine2&&isCutLine2()){
		if (flag_passLine1 == false){
			SetMessage(_T("乱序"));
			return 0;
		}
		else{
			SetMessage(_T("结束"));
			return 0;
		}
	}


	if (flag_isAllInTestRange == false){
		if (isCutLine3() || isCutLine4()){
			SetMessage(_T("出界"));
			return 0;
		}
		if (isInTestRange()){
			flag_isAllInTestRange = true;
		}
	}

	if (flag_isAllInTestRange){
		if (!isInTestRange()){
			SetMessage(_T("出界"));
			return 0;
		}
	}

	return 1;
}
コード例 #9
0
ファイル: workThread.cpp プロジェクト: RoyLzr/NetTalk
void ReadLineUserInput::Execute()
{
    while(true)
    {
        if(isStop())
            break;
        if(readLineOnce()<0)
        {
            printf("user input read once error \n");
            std::cout << strerror(errno) << std::endl;
        }
    }
}
コード例 #10
0
ファイル: VideoProcessor.cpp プロジェクト: 1a2b/QtEVM
/** 
 * playIt	-	play the frames of the sequence
 *
 */
void VideoProcessor::playIt()
{
    // current frame
    cv::Mat input;

    // if no capture device has been set
    if (!isOpened())
        return;

    // is playing
    stop = false;

    // update buttons
    emit updateBtn();

    while (!isStop()) {

        // read next frame if any
        if (!getNextFrame(input))
            break;

        curPos = capture.get(CV_CAP_PROP_POS_FRAMES);

        // display input frame
        emit showFrame(input);

        // update the progress bar
        emit updateProgressBar();

        // introduce a delay
        emit sleep(delay);
    }
    if (!isStop()){
        emit revert();
    }
}
コード例 #11
0
ファイル: VideoProcessor.cpp プロジェクト: 1a2b/QtEVM
/** 
 * jumpTo	-	Jump to a position
 *
 * @param index	-	frame index
 *
 * @return True if success. False otherwise
 */
bool VideoProcessor::jumpTo(long index)
{
    if (index >= length){
        return 1;
    }

    cv::Mat frame;
    bool re = capture.set(CV_CAP_PROP_POS_FRAMES, index);

    if (re && !isStop()){
        capture.read(frame);
        emit showFrame(frame);
    }

    return re;
}
コード例 #12
0
int checkCost(long r, long g, long b){
	int x = -1;
	//HEURISTIC TABLE
	RGB HTable[25];
	HTable[0].red=42;HTable[0].green=59;HTable[0].blue=27.5;//
	HTable[1].red=60.5;HTable[1].green=40;HTable[1].blue=25;//
	HTable[4].red=45.5;HTable[4].green=41;HTable[4].blue=12.5;//
	HTable[5].red=42.5;HTable[5].green=50;HTable[5].blue=48;//
	HTable[6].red=67.5;HTable[6].green=81;HTable[6].blue=20;
	HTable[7].red=100;HTable[7].green=50;HTable[7].blue=0;
	HTable[8].red=33.5;HTable[8].green=50.5;HTable[8].blue=32.5;
	HTable[9].red=47.5;HTable[9].green=23;HTable[9].blue=19;
	HTable[10].red=100;HTable[10].green=93;HTable[10].blue=34.5;
	HTable[11].red=54;HTable[11].green=64;HTable[11].blue=30;
	HTable[13].red=100;HTable[13].green=0;HTable[13].blue=50;
	HTable[14].red=54;HTable[14].green=48.5;HTable[14].blue=29;
	HTable[16].red=68.5;HTable[16].green=87.5;HTable[16].blue=31;
	HTable[17].red=100;HTable[17].green=35.5;HTable[17].blue=45;
	HTable[18].red=55;HTable[18].green=58;HTable[18].blue=50;
	HTable[20].red=50;HTable[20].green=0;HTable[20].blue=100;
	HTable[23].red=0;HTable[23].green=100;HTable[23].blue=100;
	HTable[24].red=82.5;HTable[24].green=54;HTable[24].blue=36.5;
	for (int i=0;i<=24;i++){
			if((i!=2) && (i!=3) && (i!=12) && (i!=15) && (i!=19) && (i!=21) && (i!=22)){
				int range;
				if(isIntersection(r,g,b)){
				  return 100;
			  }
			  if(isStop(r,g,b)){
				  return 101;
			  }
				if(i==14){//pengecualian untuk abu2
				 	range = 5;
				} else {
					range = 25;
				}
				if((r <= HTable[i].red + range) && (r >= HTable[i].red - range) && (g >= HTable[i].green - range) && (g <= HTable[i].green + range) && (b >= HTable[i].blue - range) && (b <= HTable[i].blue + range)){
					x = i;
					break;
				}
			}
	}
	return x;

}
コード例 #13
0
ファイル: CQuxian.cpp プロジェクト: ZTOMarcy/GPS
int CQuxian::run(){
	if (isStop()){
		SetMessage(_T("中途停车"));
		return 0;
	}
	if (!isInTestRange()){
		SetMessage(_T("出界"));
		return 0;
	}
	if (flag_in == false){
		if (isIn()){
			flag_in = true;
		}
	}
	if ((flag_in == true)&&(flag_out==false)){
		if (isOut()){
			flag_out = true;
			SetMessage(_T("结束"));
			return 0;
		}
	}
	return 1;
}
コード例 #14
0
ファイル: CCefang.cpp プロジェクト: ZTOMarcy/GPS
int CCefang::run(){

	if (isStop()){
		if (flag_isLastTimeStoped == false){  //停车的瞬间
			if (flag_isAllInTestRange == false){
				SetMessage(_T("车还没有全部进入就停车了,中途停车"));
				return 0;
			}
			if (flag_backCar&&flag_intoGarage&&isInGarage()){
				SetMessage(_T("停在了车库里面"));
			}

			if (flag_inPass1 && flag_backCar && flag_intoGarage){  //如果完成了考试的各个小环节
				SetMessage(_T("考试结束"));	//表示考试完毕
				return 0;
			}

			flag_isLastTimeStoped = true;
		}
		else{
			SetMessage(_T("停车时间太久,认定为中途停车"));
			return 0;
		}
	}
	else{
		if (flag_isLastTimeStoped == true){  //起步的瞬间
			if (flag_inPass1&&!flag_intoGarage&&!flag_backCar){
				if (isBackCar()){
					flag_backCar = true;
				}
			}
		}
		flag_isLastTimeStoped = false;
	}


	if (!flag_inPass1){     //如果没有经过过一号线
		if (isCutLine1()){  //经过了1号线
			flag_inPass1 = true;
			SetMessage(_T("经过了1号线"));
		}
	}


	if (flag_isAllInTestRange == false){
		if (flag_inPass1 && isInTestRange()){ //如果过了一号线以后整个车进入了考试区域,那么之后车就不能再出界了,直到考试完毕
			flag_isAllInTestRange = true;
			SetMessage(_T("全部进入了考场"));
		}
	}

	if (flag_inPass1 && !flag_isAllInTestRange){  //如果过了一号线
		if (isCutLine2() || isCutLine4()){  //压边线了
			SetMessage(_T("车身出线-20102")); //车身出线 
			return 0;
		}
	}


	if (flag_backCar == false){
		if (isInGarage()){
			SetMessage(_T("3不按规定路线、顺序行驶-20101"));
			return 0;
		}
	}

	if (!flag_inPass1){      //如果进场方向错误
		if (isCutLine3()){ 
			SetMessage(_T("2不按规定路线、顺序行驶-20101"));
			return 0;
		}
	}



	if (flag_isAllInTestRange){    //如果全部进入了考试场地以后
		if (isInTestRange() == false){		//如果有部分出线
			SetMessage(_T("车身出线-20102")); //车身出线 
			return 0;
		}
	}

	if (!flag_intoGarage && flag_backCar){
		if (isInGarage()){
			flag_intoGarage = true;
			SetMessage(_T("进入了车库里面"));
		}
	}
	return 1; //
}
コード例 #15
0
ファイル: VideoProcessor.cpp プロジェクト: 1a2b/QtEVM
/**
 * colorMagnify	-	color magnification
 *
 */
void VideoProcessor::colorMagnify()
{
    // set filter
    setSpatialFilter(GAUSSIAN);
    setTemporalFilter(IDEAL);

    // create a temp file
    createTemp();

    // current frame
    cv::Mat input;
    // output frame
    cv::Mat output;
    // motion image

    cv::Mat motion;
    // temp image
    cv::Mat temp;

    // video frames
    std::vector<cv::Mat> frames;
    // down-sampled frames
    std::vector<cv::Mat> downSampledFrames;
    // filtered frames
    std::vector<cv::Mat> filteredFrames;

    // concatenate image of all the down-sample frames
    cv::Mat videoMat;
    // concatenate filtered image
    cv::Mat filtered;

    // if no capture device has been set
    if (!isOpened())
        return;

    // set the modify flag to be true
    modify = true;

    // is processing
    stop = false;

    // save the current position
    long pos = curPos;

    // jump to the first frame
    jumpTo(0);

    // 1. spatial filtering
    while (getNextFrame(input) && !isStop()) {
        input.convertTo(temp, CV_32FC3);
        frames.push_back(temp.clone());
        // spatial filtering
        std::vector<cv::Mat> pyramid;
        spatialFilter(temp, pyramid);
        downSampledFrames.push_back(pyramid.at(levels-1));
        // update process
        std::string msg= "Spatial Filtering...";
        emit updateProcessProgress(msg, floor((fnumber++) * 100.0 / length));
    }
    if (isStop()){
        emit closeProgressDialog();
        fnumber = 0;
        return;
    }
    emit closeProgressDialog();

    // 2. concat all the frames into a single large Mat
    // where each column is a reshaped single frame
    // (for processing convenience)
    concat(downSampledFrames, videoMat);

    // 3. temporal filtering
    temporalFilter(videoMat, filtered);

    // 4. amplify color motion
    amplify(filtered, filtered);

    // 5. de-concat the filtered image into filtered frames
    deConcat(filtered, downSampledFrames.at(0).size(), filteredFrames);

    // 6. amplify each frame
    // by adding frame image and motions
    // and write into video
    fnumber = 0;
    for (int i=0; i<length-1 && !isStop(); ++i) {
        // up-sample the motion image        
        upsamplingFromGaussianPyramid(filteredFrames.at(i), levels, motion);
	resize(motion, motion, frames.at(i).size());
        temp = frames.at(i) + motion;
        output = temp.clone();
        double minVal, maxVal;
        minMaxLoc(output, &minVal, &maxVal); //find minimum and maximum intensities
        output.convertTo(output, CV_8UC3, 255.0/(maxVal - minVal),
                  -minVal * 255.0/(maxVal - minVal));
        tempWriter.write(output);
        std::string msg= "Amplifying...";
        emit updateProcessProgress(msg, floor((fnumber++) * 100.0 / length));
    }
    if (!isStop()) {
        emit revert();
    }
    emit closeProgressDialog();

    // release the temp writer
    tempWriter.release();

    // change the video to the processed video
    setInput(tempFile);

    // jump back to the original position
    jumpTo(pos);
}
コード例 #16
0
ファイル: VideoProcessor.cpp プロジェクト: 1a2b/QtEVM
/** 
 * motionMagnify	-	eulerian motion magnification
 *
 */
void VideoProcessor::motionMagnify()
{
    // set filter
    setSpatialFilter(LAPLACIAN);
    setTemporalFilter(IIR);

    // create a temp file
    createTemp();

    // current frame
    cv::Mat input;
    // output frame
    cv::Mat output;

    // motion image
    cv::Mat motion;

    std::vector<cv::Mat> pyramid;
    std::vector<cv::Mat> filtered;

    // if no capture device has been set
    if (!isOpened())
        return;

    // set the modify flag to be true
    modify = true;

    // is processing
    stop = false;

    // save the current position
    long pos = curPos;
    // jump to the first frame
    jumpTo(0);

    while (!isStop()) {

        // read next frame if any
        if (!getNextFrame(input))
            break;

        input.convertTo(input, CV_32FC3, 1.0/255.0f);

        // 1. convert to Lab color space
        cv::cvtColor(input, input, CV_BGR2Lab);

        // 2. spatial filtering one frame
        cv::Mat s = input.clone();
        spatialFilter(s, pyramid);

        // 3. temporal filtering one frame's pyramid
        // and amplify the motion
        if (fnumber == 0){      // is first frame
            lowpass1 = pyramid;
            lowpass2 = pyramid;
            filtered = pyramid;
        } else {
            for (int i=0; i<levels; ++i) {
                curLevel = i;
                temporalFilter(pyramid.at(i), filtered.at(i));
            }

            // amplify each spatial frequency bands
            // according to Figure 6 of paper            
            cv::Size filterSize = filtered.at(0).size();
            int w = filterSize.width;
            int h = filterSize.height;

            delta = lambda_c/8.0/(1.0+alpha);
            // the factor to boost alpha above the bound
            // (for better visualization)
            exaggeration_factor = 2.0;

            // compute the representative wavelength lambda
            // for the lowest spatial frequency band of Laplacian pyramid
            lambda = sqrt(w*w + h*h)/3;  // 3 is experimental constant

            for (int i=levels; i>=0; i--) {
                curLevel = i;

                amplify(filtered.at(i), filtered.at(i));

                // go one level down on pyramid
                // representative lambda will reduce by factor of 2
                lambda /= 2.0;
            }
        }

        // 4. reconstruct motion image from filtered pyramid
        reconImgFromLaplacianPyramid(filtered, levels, motion);

        // 5. attenuate I, Q channels
        attenuate(motion, motion);

        // 6. combine source frame and motion image
        if (fnumber > 0)    // don't amplify first frame
            s += motion;

        // 7. convert back to rgb color space and CV_8UC3
        output = s.clone();
        cv::cvtColor(output, output, CV_Lab2BGR);
        output.convertTo(output, CV_8UC3, 255.0, 1.0/255.0);

        // write the frame to the temp file
        tempWriter.write(output);

        // update process
        std::string msg= "Processing...";
        emit updateProcessProgress(msg, floor((fnumber++) * 100.0 / length));
    }
    if (!isStop()){
        emit revert();
    }
    emit closeProgressDialog();

    // release the temp writer
    tempWriter.release();

    // change the video to the processed video 
    setInput(tempFile);

    // jump back to the original position
    jumpTo(pos);
}