Esempio n. 1
0
static void
choose_refpoints(amcaceo_encode_ctx *ctx) {
	unsigned long *v = ctx->input;
	size_t len = ctx->input_len;
	int k, i;

	for (k = 0; k < 3; k++) {
		unsigned long prefix;

		ctx->best_count = 0;
		ctx->best_refpoint = 0;
		ctx->best_prefix = 0;

		/*
		 * Try various prefixes and choose the best one.
		 */
		for (i = 0; i < len; i++) {
			prefix = v[i] >> ((k + 1) * 4);
			census(ctx, k, prefix);
		}
		if (k == 1) {
			for (i = 0; i < 8; i++) {
				prefix = 0xd8 + i;
				census(ctx, k, prefix);
			}
		} else if (k == 2) {
			prefix = 0xd;
			census(ctx, k, prefix);
		}
		ctx->refpoint[k] = ctx->best_refpoint;
		ctx->prefix[k] = ctx->best_prefix;
	}
}
Esempio n. 2
0
void
HeapSnapshot::TakeCensus(JSContext* cx, JS::HandleObject options,
                         JS::MutableHandleValue rval, ErrorResult& rv)
{
  JS::ubi::Census census(cx);
  if (NS_WARN_IF(!census.init())) {
    rv.Throw(NS_ERROR_OUT_OF_MEMORY);
    return;
  }

  JS::ubi::CountTypePtr rootType;
  if (NS_WARN_IF(!JS::ubi::ParseCensusOptions(cx,  census, options, rootType))) {
    rv.Throw(NS_ERROR_UNEXPECTED);
    return;
  }

  JS::ubi::RootedCount rootCount(cx, rootType->makeCount());
  if (NS_WARN_IF(!rootCount)) {
    rv.Throw(NS_ERROR_OUT_OF_MEMORY);
    return;
  }

  JS::ubi::CensusHandler handler(census, rootCount);

  {
    JS::AutoCheckCannotGC nogc;

    JS::ubi::CensusTraversal traversal(JS_GetRuntime(cx), handler, nogc);
    if (NS_WARN_IF(!traversal.init())) {
      rv.Throw(NS_ERROR_OUT_OF_MEMORY);
      return;
    }

    if (NS_WARN_IF(!traversal.addStart(getRoot()))) {
      rv.Throw(NS_ERROR_OUT_OF_MEMORY);
      return;
    }

    if (NS_WARN_IF(!traversal.traverse())) {
      rv.Throw(NS_ERROR_UNEXPECTED);
      return;
    }
  }

  if (NS_WARN_IF(!handler.report(rval))) {
    rv.Throw(NS_ERROR_OUT_OF_MEMORY);
    return;
  }
}
Esempio n. 3
0
void SGMCensus::init(MultiViewMatcher& mvm, const cv::Mat& leftImg, const cv::Mat& rightImg)
{
	height = leftImg.rows;
	width = leftImg.cols;
	dispCnt = params.dispEnd - params.dispStart + 1;    
	FeatureDescriptor::init(mvm, leftImg, rightImg);
	census.init(mvm, leftImg, rightImg);
	memset(data, 0xF, g_maxWidth*g_maxHeight*g_maxDispCnt*sizeof(int));
	for(int row = 0; row < height; ++row)
		for(int col = 0; col < width; ++col)
			for(int disp = 0; disp < dispCnt; ++disp)
			{
				int cost = census(row, col, disp);
				data[row][col][disp]= cost;
			}
	sgm();
}
Esempio n. 4
0
int CHuman::HumanAlarmRun(Mat &displayframe)
{
	int time_use=0;
	struct timeval start;
	struct timeval end;

  gettimeofday(&start,NULL);


	Mat tmpframe;
	Mat blobdealFrame;
	vector< vector<Point> >  contours;
	Rect contoursRect;

	alarm =0;

	displayframe.copyTo(tmpframe);
	displayframe.copyTo(blobdealFrame);

	vector<blobnode>().swap(humanlistpro);

	 m_zoomRows  =   tmpframe.rows  /m_rowsZoomRate;
	 m_zoomCols  =   tmpframe.cols   /m_colsZoomRate;

	 w_Rate = (float)tmpframe.cols / m_zoomCols;
	 h_Rate = (float)tmpframe.rows / m_zoomRows;


	Mat morph = Mat(tmpframe.rows ,tmpframe.cols,CV_8UC1);

	mog(tmpframe,foregrondframe,0.001);   // 0.001

	frameindex++;
	if(frameindex<250) return 2;
	if(frameindex >= 250) frameindex =250;
	foregrondframe.copyTo(mask);
	threshold(mask, mask, 200, 255, THRESH_BINARY);

	cv::erode(mask, mask, cv::Mat());

	cv::dilate(mask, mask, cv::Mat());

	algorithmMorphology_Operations(mask, mask);

	findContours(mask, contours, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);

	m_BlobRects.clear();
	for(int i=0;i<contours.size();i++)
	{
		contoursRect = boundingRect(contours[i]);
		if(fabs(contourArea(contours[i])) > 600.0)
		{
			//rectangle(displayframe, contoursRect,color_rect, 2, 8, 0);
			m_BlobRects.push_back(contoursRect);
		}
	}

	if((t_camera[m_index].t_Camvarparam.t_CamHumAlarm.Flag & 0x02)  == 0x02){
		for(int i=0;i<t_camera[m_index].t_Camvarparam.t_CamHumAlarm.DirectionLines.size();i++)
		{
			line(displayframe,t_camera[m_index].t_Camvarparam.t_CamHumAlarm.DirectionLines[i].Start,t_camera[m_index].t_Camvarparam.t_CamHumAlarm.DirectionLines[i].End,Scalar(255));
		}

	}


	if((t_camera[m_index].t_Camvarparam.t_CamHumAlarm.Flag & 0x01)  == 1){

		for(int ii=0;ii<t_camera[m_index].t_Camvarparam.t_CamHumAlarm.MonitorZoneRects.size();ii++)
		{
			rectangle(displayframe, t_camera[m_index].t_Camvarparam.t_CamHumAlarm.MonitorZoneRects[ii], Scalar( 255, 0, 0 ), 2, 8, 0);//��
		}
	}

	human_detect(morph,displayframe);

	if((t_camera[m_index].t_Camvarparam.t_CamHumAlarm.Flag & 0x01)  == 1){
		census(displayframe);// for human statistics
	}

	if((t_camera[m_index].t_Camvarparam.t_CamHumAlarm.Flag & 0x02)  == 0x02){
		blobdeal(displayframe);
	}

        if(humanstatis.numAll<(humanstatis.doorin[0]+humanstatis.doorin[1]-humanstatis.doorout[0]-humanstatis.doorout[1]))
        		humanstatis.numAll = humanstatis.doorin[0]+humanstatis.doorin[1]-humanstatis.doorout[0]-humanstatis.doorout[1];

	 //dbgprint("door1:in=%d,out=%d  door2:in=%d,out=%d\n",humanstatis.doorin[0],humanstatis.doorout[0],humanstatis.doorin[1],humanstatis.doorout[1]);

	if(humanstatis.numAll >= t_camera[m_index].t_Camvarparam.t_CamHumAlarm.MaxNum){
				//printf("humanstatis.numAll is %d\n",humanstatis.numAll);
				//printf("t_Camera.t_SinCam[m_index].t_Camvarparam.t_CamHumAlarm.MaxNum is %d\n",t_Camera.t_SinCam[m_index].t_Camvarparam.t_CamHumAlarm.MaxNum);
				alarm =1;
	}

	char dstr[100];
	sprintf(dstr, "door1:in=%d,out=%d  door2:in=%d,out=%d",humanstatis.doorin[0],humanstatis.doorout[0],humanstatis.doorin[1],humanstatis.doorout[1]);
	putText(displayframe,dstr,cvPoint(200,25),CV_FONT_HERSHEY_COMPLEX, 0.5, cvScalar(0,0,255));


	//printf("humanstatis Num:%d, humanstatisIn:%d,humanstatisOut:%d\n",humanstatis.numAll,humanstatis.inAll,humanstatis.outAll);


	//char dstr[100];
  //sprintf(dstr,  "in=%d,out=%d",humanstatis.doorin,humanstatis.doorout);
  //putText(displayframe,dstr,cvPoint(25,25),CV_FONT_HERSHEY_COMPLEX, 1, cvScalar(0,0,255));
	//printf("doorin=%d,doorout=%d\n",humanstatis.doorin,humanstatis.doorout);

	morph.release();
	vector<Point>().swap(object); //vector<Point>
	vector<blobnode>().swap(humanlist);

	gettimeofday(&end,NULL);
	time_use=(end.tv_sec-start.tv_sec)*1000+(end.tv_usec-start.tv_usec)/1000;//΢��
	//printf("time_use is %d\n",time_use);

	return 0;
}
Esempio n. 5
0
void Census(Param height, Param width, uint8_t* gray, OUT uint8_t* cen){
	printf("Census\n");
	census(height, width, gray, cen);
}
Esempio n. 6
0
void Census(Param height, Param width, uint8_t* gray, OUT uint8_t* cen){
#if VERBOSE
	printf("Census\n");
#endif
	census(height, width, gray, cen);
}