コード例 #1
0
ファイル: image_refocus.cpp プロジェクト: csuhanshuai/Gallery
bool ImageRefocus::createRefocusInstance() {
    ALOGI("<createRefocusInstance>createRefocusInstance start");
    // init
    mRefocusInitInfo.pTuningInfo = &mRefocusTuningInfo;

    getTime(&mStartSec, &mStartNsec);

    mRefocus = mRefocus->createInstance(DRV_REFOCUS_OBJ_SW);

    getTime(&mEndSec, &mEndNsec);
    mTimeDiff = getTimeDiff(mStartSec, mStartNsec, mEndSec, mEndNsec);
    ALOGI("<createRefocusInstance>performance createInstance time:%d", mTimeDiff);

    MUINT32 initResult;

    getTime(&mStartSec, &mStartNsec);

    initResult = mRefocus->RefocusInit((MUINT32 *)&mRefocusInitInfo, 0);

    getTime(&mEndSec, &mEndNsec);
    mTimeDiff = getTimeDiff(mStartSec, mStartNsec, mEndSec, mEndNsec);
    ALOGI("<createRefocusInstance>performance RefocusInit time %d", mTimeDiff);

    if (initResult != S_REFOCUS_OK) {
        ALOGI("ERROR: image refocus createRefocusInstance fail ");
        return FAIL;
    }
    ALOGI("<createRefocusInstance>createRefocusInstance success ");
    return SUCCESS;
}
コード例 #2
0
ファイル: image_refocus.cpp プロジェクト: csuhanshuai/Gallery
void ImageRefocus::saveRefocusImage(const char *saveFileName, int inSampleSize) {
    char file[FILE_NAME_LENGTH];
    FILE *fp;
    unsigned char *jpgBuf = NULL;
    unsigned int jpegSize = 0;

    mRefocusImageInfo.TouchCoordX = mRefocusImageInfo.TouchCoordX * inSampleSize;
    mRefocusImageInfo.TouchCoordY = mRefocusImageInfo.TouchCoordY * inSampleSize;
    mRefocusImageInfo.DepthOfField = mRefocusImageInfo.DepthOfField * inSampleSize;
    getTime(&mStartSec, &mStartNsec);
    initRefocusIMGSource(mSourceFileName, mRefocusImageInfo.TargetWidth * inSampleSize,
            mRefocusImageInfo.TargetHeight * inSampleSize, 0);
    if (createRefocusInstance() && setBufferAddr() && generate()) {
        ALOGI("<saveRefocusImage>image refocus init end, success");
    } else {
        ALOGI("ERROR: image refocus init fail!!!");
        return;
    }
    getTime(&mEndSec, &mEndNsec);
    mTimeDiff = getTimeDiff(mStartSec, mStartNsec, mEndSec, mEndNsec);
    ALOGI("<saveRefocusImage>performance generate time:%d", mTimeDiff);

    sprintf(file, "%s", saveFileName);
    ALOGI("<saveRefocusImage>test file:%s", file);
    fp = fopen(file, "w");
    if (fp == NULL) {
        ALOGI("ERROR: Open file %s failed!!!", file);
        return;
    }

    // should free this memory when not use it !!!
    int imageWidth = mRefocusResultInfo.RefocusImageWidth;
    int imageHeight = mRefocusResultInfo.RefocusImageHeight;
    jpgBuf = (unsigned char *) malloc(imageWidth * imageHeight);
    if (jpgBuf == NULL) {
        ALOGI("ERROR: Can not allocate memory!!!");
        fclose(fp);
        return;
    }
    if (NULL != m_DebugUtils) {
        m_DebugUtils->dumpBufferToFile("save.yuv", mRefocusResultInfo.RefocusedYUVImageAddr,
                imageWidth*imageHeight*3/2);
    }

    ALOGI("<saveRefocusImage>RefocusedYUVImageAddr:%p", (size_t)mRefocusResultInfo.RefocusedYUVImageAddr);
    getTime(&mStartSec, &mStartNsec);
    m_pJpegFactory->yv12ToJpg((unsigned char *)mRefocusResultInfo.RefocusedYUVImageAddr, imageWidth * imageHeight,
            imageWidth, imageHeight, jpgBuf, imageWidth * imageHeight, &jpegSize);
    getTime(&mEndSec, &mEndNsec);
    mTimeDiff = getTimeDiff(mStartSec, mStartNsec, mEndSec, mEndNsec);
    ALOGI("<saveRefocusImage>performance yv12ToJpg time:%d", mTimeDiff);
    dumpBufferToFile(jpgBuf, jpegSize, file);
    free(jpgBuf);
    fclose(fp);
    jpgBuf = NULL;
}
コード例 #3
0
ファイル: image_refocus.cpp プロジェクト: csuhanshuai/Gallery
bool ImageRefocus::generate() {
    MUINT32 result;
    // algorithm - gen depth map
    ALOGI("<generate>generate start,RcfyError:%d,JPSOrientation:%d",
            mRefocusImageInfo.RcfyError, mRefocusImageInfo.JPSOrientation);

    getTime(&mStartSec, &mStartNsec);
    result = mRefocus->RefocusFeatureCtrl(REFOCUS_FEATURE_ADD_IMG, (void *)&mRefocusImageInfo, NULL);
    getTime(&mEndSec, &mEndNsec);
    mTimeDiff = getTimeDiff(mStartSec, mStartNsec, mEndSec, mEndNsec);
    ALOGI("<generate>REFOCUS_FEATURE_ADD_IMG time:%d, result:%d", mTimeDiff, result);

    if (result != S_REFOCUS_OK) {
        ALOGI("ERROR: image refocus ADD_IMG fail ");
        return FAIL;
    }

    getTime(&mStartSec, &mStartNsec);
    result = mRefocus->RefocusMain();
    getTime(&mEndSec, &mEndNsec);
    mTimeDiff = getTimeDiff(mStartSec, mStartNsec, mEndSec, mEndNsec);
    ALOGI("<generate>RefocusMain time:%d, result:%d", mTimeDiff, result);

    if (result != S_REFOCUS_OK) {
        ALOGI("ERROR: image refocus RefocusMain fail ");
        return FAIL;
    }
    getTime(&mStartSec, &mStartNsec);
    result = mRefocus->RefocusFeatureCtrl(REFOCUS_FEATURE_GET_RESULT, NULL, (void *)&mRefocusResultInfo);
    getTime(&mEndSec, &mEndNsec);
    mTimeDiff = getTimeDiff(mStartSec, mStartNsec, mEndSec, mEndNsec);
    ALOGI("<generate>REFOCUS_FEATURE_GET_RESULT time:%d, result:%d", mTimeDiff, result);

    ALOGI("<generate>RefocusImageWidth:%d,RefocusImageHeight:%d,DepthBufferWidth:%d,DepthBufferHeight:%d",
            mRefocusResultInfo.RefocusImageWidth, mRefocusResultInfo.RefocusImageHeight,
            mRefocusResultInfo.DepthBufferWidth, mRefocusResultInfo.DepthBufferHeight);
    ALOGI("<generate>DepthBufferSize:%d,DepthBufferAddr:%p", mRefocusResultInfo.DepthBufferSize,
            mRefocusImageInfo.DepthBufferAddr);
    if (result != S_REFOCUS_OK) {
        ALOGI("ERROR: image refocus GET_RESULT fail ");
        return FAIL;
    }
    if (mRefocusImageInfo.DepthBufferAddr == NULL) {
        MUINT8* depthBuffer = new MUINT8[mRefocusResultInfo.DepthBufferSize];
        memcpy(depthBuffer, mRefocusResultInfo.DepthBufferAddr, mRefocusResultInfo.DepthBufferSize);
        mRefocusImageInfo.DepthBufferAddr = depthBuffer;
        mRefocusImageInfo.DepthBufferSize = mRefocusResultInfo.DepthBufferSize;
        copyRefocusResultInfo(&mRefocusResultInfo);
        ALOGI("<generate>copy depthBuffer from %p to %p", mRefocusResultInfo.DepthBufferAddr, depthBuffer);
    }
    return SUCCESS;
}
コード例 #4
0
ファイル: image_refocus.cpp プロジェクト: csuhanshuai/Gallery
bool ImageRefocus::setBufferAddr() {
    ALOGI("<setBufferAddr> start");
    // get buffer size
    MUINT32 result;
    MUINT32 buffer_size;

    getTime(&mStartSec, &mStartNsec);

    ALOGI("<setBufferAddr> TargetWidth %d, TargetHieght %d, TargetImgAddr %p  ImgNum %d, Width %d Height %d ImgAddr %p "
            "DepthBufferAddr %p  DepthBufferSize %d Orientation %d  MainCamPos %d", mRefocusImageInfo.TargetWidth,
            mRefocusImageInfo.TargetHeight, mRefocusImageInfo.TargetImgAddr, mRefocusImageInfo.ImgNum,
            mRefocusImageInfo.Width, mRefocusImageInfo.Height, mRefocusImageInfo.ImgAddr,
            mRefocusImageInfo.DepthBufferAddr, mRefocusImageInfo.DepthBufferSize ,
            mRefocusImageInfo.JPSOrientation , mRefocusImageInfo.MainCamPos);

    result = mRefocus->RefocusFeatureCtrl(REFOCUS_FEATURE_GET_WORKBUF_SIZE, (void *)&mRefocusImageInfo,
            (void *)&buffer_size);

    getTime(&mEndSec, &mEndNsec);
    mTimeDiff = getTimeDiff(mStartSec, mStartNsec, mEndSec, mEndNsec);
    ALOGI("<setBufferAddr>performance get_workbuff_size time:%d", mTimeDiff);

    ALOGI("<setBufferAddr>REFOCUS_FEATURE_GET_WORKBUF_SIZE buffer size  %d, result %d ", buffer_size, result);
    if (result != S_REFOCUS_OK) {
        ALOGI("ERROR: image refocus GET_WORKBUF_SIZE fail ");
        return FAIL;
    }

    // set buffer address
    // unsigned char *pWorkingBuffer = new unsigned char[buffer_size];
    pWorkingBuffer = (unsigned char *) malloc(buffer_size);
    mRefocusInitInfo.WorkingBuffAddr = (MUINT8*)pWorkingBuffer;

    getTime(&mStartSec, &mStartNsec);

    ALOGI("<setBufferAddr> SET_WORKBUF_ADDR start");
    result = mRefocus->RefocusFeatureCtrl(REFOCUS_FEATURE_SET_WORKBUF_ADDR,
            (void *)&mRefocusInitInfo.WorkingBuffAddr, NULL);

    getTime(&mEndSec, &mEndNsec);
    mTimeDiff = getTimeDiff(mStartSec, mStartNsec, mEndSec, mEndNsec);
    ALOGI("<setBufferAddr>performance mRefocus->set_workbuff_size time:%d", mTimeDiff);

    if (result != S_REFOCUS_OK) {
        ALOGI("ERROR: image refocus SET_WORKBUF_ADDR fail ");
        return FAIL;
    }
    ALOGI("<setBufferAddr> SET_WORKBUF_ADDR success");
    return SUCCESS;
}
コード例 #5
0
ファイル: GameLoop.cpp プロジェクト: slacker247/3dGameEngine
	void GameLoop::loop()
	{
		
		beforeExeTime = clock();
		
		long deltaTime = getTimeDiff();
		// Set state
		if(!this->m_States[this->m_CurrentState]->isLoaded())
		{
			// display loading screen
			loaders::LoadState::loadState(this->m_States[this->m_CurrentState]);
		}
		// calc user movement
		// calc ai movement
		// calc physics
		// pre render (pixel shaders, camera effects)
		// render
		static int frameNum = 0;
		if(frame)
			frameNum++;
		if(frameNum > 1743)
			frameNum = 0;
		((renderers::OpenGLRender*)m_Renderer)->frame = frameNum;
		m_Renderer->draw(m_States[this->m_CurrentState]);
		// post render

		long t_current = clock();
		afterExeTime = clock();
		exeTimer = t_current - afterExeTime + 5;
		if (exeTimer < 5)
		{
			exeTimer = 5;
		}

	}
コード例 #6
0
ファイル: log.cpp プロジェクト: Zycon42/nat64
std::ostream& pLog() {
    timeval time = getTimeDiff();

    std::ostream& str = std::clog;
    str << "[" << time.tv_sec << "." << time.tv_usec << "] ";
    return str;
}
コード例 #7
0
ファイル: log.cpp プロジェクト: Zycon42/nat64
std::ostream& pError() {
    timeval time = getTimeDiff();

    std::ostream& str = std::cerr;
    str << "[" << time.tv_sec << "." << time.tv_usec << "] ";
    return str;
}
コード例 #8
0
ファイル: timeUtils.hpp プロジェクト: bailey-lab/cppprogutils
	/**@brief Start a new lap, log the time since last time point and reset the currentLap_ to now
	 *
	 * @param newLapName A name for the new lap, defaults to current lap number
	 * @param lastLapName A name for the last lap if a change is desired otherwise is logged as currentLapName_;
	 */
	void startNewLap(const std::string & newLapName = "",
			const std::string & lastLapName = ""){
		auto timeNew = sch::high_resolution_clock::now();
		if(lastLapName == ""){
			lapTimes_.emplace_back(currentLapName_, getTimeDiff(currentLap_, timeNew));
		}else{
			lapTimes_.emplace_back(lastLapName, getTimeDiff(currentLap_, timeNew));
		}

		if(newLapName == ""){
			currentLapName_ = to_string(lapTimes_.size() + 1);
		}else{
			currentLapName_ = newLapName;
		}
		currentLap_ = timeNew;
	}
コード例 #9
0
ファイル: client.c プロジェクト: nechutny/IPK
/**
 * Handle SIGINT and close socket and SIGUSR1
 *
 * For SIGUSR1 do calculations for correct output
 *
 * @param	int	sig	Signal code
 */
void term(int sig)
{
	if(sig == SIGUSR1)
	{
		printf("=== [ Interval %d/%d ] === \n", count, arg.interval*arg.rate);
		time_fix = getTimeDiff();
		time_t ti;
		struct tm *foo;
		time( &ti);
		foo = localtime( &ti );
		char tim[20];
		strftime(tim, 20, "%Y-%m-%d-%H:%M:%S", foo);

		char *filename = malloc(sizeof(char)*96);

		sprintf(filename, "%s%s-%d-%d", OUTPUT_FILE_PREFIX, arg.server, arg.size, arg.rate);

		FILE* fp = fopen(filename, "a");
		// calculate interval
		fprintf(fp, "%s, %d, %d, %d, %d, %d, %.3f, %.3f, %.3f\n",
			tim,							// Time
			arg.interval,						// IntLen
			arg.interval*arg.rate,					// Pckt Sent
			count,							// Pckt Recv
			arg.interval*arg.rate*arg.size,				// Bytes Send
			count*arg.size,						// Bytes Recv
			(((double)rtt_sum)/count)/1000,				// Avg Delay
			((double)(diff_max-diff_min)/1000),			// Jitter PDV(x) = t(x) - A(x)
			(out_of_order == 0) ? 0.0 : (out_of_order/count)	// OutOfOrder %
		);
		fclose(fp);
		free(filename);
		count = -1;
		rtt_sum = 0;
		out_of_order = 0;
		diff_min = -1;
		diff_max = 0;
		time_fix = getTimeDiff()-time_fix;
	}
	else
	{
		close(sockfd);
		//printf("Exiting\n");
		exit(0);
	}
}
コード例 #10
0
ファイル: UtilMisc.cpp プロジェクト: aromis/desura-app
void getTimeDiffFromNow(const char* dateTime, uint32 &days, uint32 &hours)
{
	days = 0;
	hours = 0;

	std::string now_str = getNowAsDateTime();

	return getTimeDiff(now_str.c_str(), dateTime, days, hours);
}
コード例 #11
0
ファイル: client.c プロジェクト: nechutny/IPK
/**
 * Receive data from server and set corresponding values to global variables
 *
 * @param	arguments	arg	Arguments structure
 */
void receiveData(arguments arg)
{
	char *recvline = malloc(arg.size+1);
	memset(recvline, 0,  arg.size);
	int n = 1;
	uint32_t tim = 0, seq = 0, last_seq = 0, diff = 0;
	count = -1;
	rtt_sum = 0;
	out_of_order = 0;
	diff_min = -1;
	diff_max = 0;
	uint32_t last_tim = 0;

	struct timeval tv;
	tv.tv_sec = 10;  /* 10 Secs Timeout */
	tv.tv_usec = 0;  // Not init'ing this can cause strange errors
	setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv,sizeof(struct timeval));



	while (n != 0)
	{
		n = recvfrom(sockfd, recvline, arg.size, 0, NULL, NULL);
		count++;
		memcpy(&seq, recvline, 4);
		memcpy(&tim, recvline+4, 4);

		if(seq != last_seq && last_tim != tim)
		{
			diff = getTimeDiff()-tim;
			if(seq < last_seq)
			{
				out_of_order++;
			}
			else
			{
				last_seq = seq;
			}

			printf("Received #%d\t- #%d\t- %d.%dms\n", count, seq, (diff/1000), (diff%1000));
			time_fix = 0;
			rtt_sum += diff;
			if(diff_min > diff)
			{
				diff_min = diff;
			}
			if(diff_max < diff)
			{
				diff_max = diff;
			}
			last_tim = tim;
		}
	}

	free(recvline);
}
コード例 #12
0
int main(int argc, char *argv[])
{
    int sockfd, portno, n;

    struct sockaddr_in serv_addr;
    struct hostent *server;

		struct timespec start,stop;
		long accum;

    char buffer[256];
    bzero(buffer,256);
    if (argc < 4) {
       fprintf(stderr,"usage %s hostname port message_length\n", argv[0]);
       exit(0);
    }
    portno = atoi(argv[2]);
    sockfd = socket(AF_INET, SOCK_STREAM, 0);
    if (sockfd < 0) 
        error("ERROR opening socket");
    server = gethostbyname(argv[1]);
    if (server == NULL) {
        fprintf(stderr,"ERROR, no such host\n");
        exit(0);
    }
    bzero((char *) &serv_addr, sizeof(serv_addr));
    serv_addr.sin_family = AF_INET;
    bcopy((char *)server->h_addr, 
         (char *)&serv_addr.sin_addr.s_addr,
         server->h_length);
    serv_addr.sin_port = htons(portno);
    if (connect(sockfd,(struct sockaddr *)&serv_addr,sizeof(serv_addr)) < 0) 
        error("ERROR connecting");

    int message_length = atoi(argv[3]);
    char *string = (char*)malloc(message_length*sizeof(char*));
    rand_str(string,message_length);

		clock_gettime(CLOCK_REALTIME, &start);
    n = write(sockfd,string,strlen(string));
    if (n < 0) 
         error("ERROR writing to socket");
    n = read(sockfd,buffer,255);
		clock_gettime(CLOCK_REALTIME, &stop);
    if (n < 0) 
         error("ERROR reading from socket");
		accum = (stop.tv_sec - start.tv_sec)*1000000000 + (stop.tv_nsec - start.tv_nsec);
		uint64_t diff = getTimeDiff(start, stop);
		printf("Latency : %llu\n", (unsigned long long int)diff);

    //printf("%s\n",buffer);
    return 0;
}
コード例 #13
0
ファイル: Device.cpp プロジェクト: caomw/mobot
void Device::updateTimeDiff() {
  printf("Updating time diff...\n");

  struct timeval tp1;
  struct timeval tp2;
  double mach_time;

  sleep(1);
  gettimeofday(&tp1, NULL);
  double ms1 = tp1.tv_sec * 1000 + tp1.tv_usec / 1000.0;

  sendCommand(TCPDeviceCommandGetMachTime, NULL, 0);

  int n = read(cmd_fd, &mach_time, 255);

  if (n < 0) {
    perror("ERROR reading from socket");
    return;
  }

  gettimeofday(&tp2, NULL);
  double ms2 = tp2.tv_sec * 1000 + tp2.tv_usec / 1000.0;

  double ms = ms2 - ms1;
  double time_diff = (ms1 + ms / 2) - mach_time;

  _time_diff->add(time_diff);
  parser->time_diff = getTimeDiff();

  printf("Device: %s\n", name);
  printf("---------------------------\n");

  printf("mach_time: %f\n", mach_time);
  printf("%f time diff (server - device)\n", time_diff);
  printf("%f ms elapsed\n", ms);
  printf("ms1: %f\nms2: %f\n", ms1, ms2);

  printf("%f avg diff\n", getTimeDiff());
  printf("\n");
}
コード例 #14
0
ファイル: image_refocus.cpp プロジェクト: csuhanshuai/Gallery
void ImageRefocus::saveDepthMapInfo(MUINT8* depthBufferArray, MUINT8* xmpDepthBufferArray) {
    ALOGI("<saveDepthMapInfo>DepthBufferSize %d ", mRefocusResultInfo.DepthBufferSize);
    memcpy(depthBufferArray, (MUINT8*)mRefocusResultInfo.DepthBufferAddr, mRefocusResultInfo.DepthBufferSize);
    memcpy(xmpDepthBufferArray, (MUINT8*)mRefocusResultInfo.XMPDepthMapAddr,
           mRefocusResultInfo.XMPDepthWidth * mRefocusResultInfo.XMPDepthHeight);

    if (mDepthRotation != ORIENTATION_0) {
        getTime(&mStartSec, &mStartNsec);

        int offset = 0;
        int bufferWidth = 0;
        int bufferHeight = 0;
        int depthBufferWidth = mRefocusResultInfo.DepthBufferWidth;
        int depthBufferHeight = mRefocusResultInfo.DepthBufferHeight;
        int metaBufferWidth = mRefocusResultInfo.MetaBufferWidth;
        int metaBufferHeight = mRefocusResultInfo.MetaBufferHeight;
        char name[FILE_NAME_LENGTH];
        for (int i = 0; i < DEPTH_BUFFER_SECTION_SIZE; i++) {
            if (i == WMI_DEPTH_MAP_INDEX) {
                offset = 0;
                bufferWidth = depthBufferWidth;
                bufferHeight = depthBufferHeight;
            } else if (i == VAR_BUFFER_INDEX || i == DVEC_MAP_INDEX) {
                continue;  // no need to rotate
            } else if (i == DS4_BUFFER_Y_INDEX) {
                offset = depthBufferWidth * depthBufferHeight + (i - 1) * metaBufferWidth * metaBufferHeight;
                bufferWidth = depthBufferWidth;
                bufferHeight = depthBufferHeight;
            } else {
                offset = depthBufferWidth * depthBufferHeight + (i - 1)* metaBufferWidth * metaBufferHeight;
                bufferWidth = metaBufferWidth;
                bufferHeight = metaBufferHeight;
            }
            ALOGI("<saveDepthMapInfo>rotate section %d: offset %d, bufferWidth %d, bufferHeight %d", i, offset,
                    bufferWidth, bufferHeight);
            if (NULL != m_DebugUtils) {
                sprintf(name, "section_%d_before_rotate.ppm", i);
                m_DebugUtils->dumpBufferToPPM(name, depthBufferArray + offset, bufferWidth, bufferHeight, 5, 3);
            }
            rotateBuffer((MUINT8*)mRefocusResultInfo.DepthBufferAddr + offset, depthBufferArray + offset,
                    bufferWidth, bufferHeight,  mDepthRotation);
            if (NULL != m_DebugUtils) {
                sprintf(name, "section_%d_after_rotate.ppm", i);
                m_DebugUtils->dumpBufferToPPM(name, depthBufferArray + offset, bufferHeight, bufferWidth, 5, 3);
            }
        }

        getTime(&mEndSec, &mEndNsec);
        mTimeDiff = getTimeDiff(mStartSec, mStartNsec, mEndSec, mEndNsec);
        ALOGI("<saveDepthMapInfo>mRefocus->saveDepthMapInfo,rotating depthBuffer costs time:%d", mTimeDiff);
    }
}
コード例 #15
0
// prints the current state of the airport parking, waits for 
// semaphore to be released before printing.
void printAirport() {
    sem_wait(&mutex);
    printf("\nAirport State:\n");
    for (int i=0; i<NUM_PARKING_BAYS; ++i) {
        if (parking[i] == NULL) {
            printf("%d: Empty\n", i);
        } else {
            printf("%d: %s (has parked for %.2f seconds)\n", i,
                    parking[i]->flight_number, getTimeDiff(parking[i]->time_landed));
        }
    }
    printf("\n");
    sem_post(&mutex);
    return;
}
コード例 #16
0
void IsoView::draw(AGPainter &p)//const AGRect &r)
{
  if(!inited)
    {
      init();
      inited=true;
      shallUpdate=false;
    }
  if(shallUpdate)
    {
      update();
      shallUpdate=false;
    }

  updatePositions();

  doTick();
  mTime+=getTimeDiff();

  AntargisView::draw(p);

  // overlay selection-rectangle and energy

  std::set
    <AVItem*>::iterator i=mSelected.begin();
  for(;i!=mSelected.end() ;i++)
    {
      AGRect ar=getRect(*i);
      //      ar=r.project(ar);
      p.drawRect(ar,getSelectColor());
    }

  std::map<AVItem*,AntEntity*>::iterator k=mEntities.end();// FIXME: don't draw anything ATM begin();
  for(;k!=mEntities.end();k++)
    {
      AGRect ar=getRect(k->first);
      //      ar=r.project(ar);
      // draw energy
      ar.y-=10;
      ar.h=6;
      p.drawRect(ar,AGColor(0xFF,0,0)); // first red
      ar.w=(short)(ar.w*k->second->getEnergy());
      p.drawRect(ar,AGColor(0,0xFF,0)); // overpaint with green
    }

  // overlay rain
  mRain.draw(p);
}
コード例 #17
0
int main(int argc, char *argv[])
{
	if(argc != 3)
	{
		printf("Usage: binary filename filesize\n");
		exit(1);
	}
	uint64_t diff;
	struct timespec start, end;
	char filename[1024];
	strcpy(filename, argv[1]);

	char buffer[BUFFER_SIZE];
	int i;
	for(i=0; i<BUFFER_SIZE-1; i++)
		buffer[i] = 'a';
	buffer[BUFFER_SIZE] = '\0';
	int fd, total_written=0, num_written=0, times=0;
	//int file_size=100*1024;											// This will be multiplied by BUFFER_SIZE
	int file_size = atoi(argv[2]);
	int k, iterations = 5;

	clock_gettime(CLOCK_REALTIME, &start);
	fd = open(filename, O_RDWR);
	if(fd == -1)
		perror("fd is -1");
	num_written = write(fd, buffer, BUFFER_SIZE);
	// fsync(fd);
	if (num_written != BUFFER_SIZE)
	{
		printf("Error=> bytes written %d, BUFFER_SIZE %d\n", num_written, BUFFER_SIZE);
		close(fd);
		exit(1);
	}
	fsync(fd);
	clock_gettime(CLOCK_REALTIME, &end);
	diff = getTimeDiff(start, end);
	printf("Total bytes written %d\t", total_written);
	//printf("Time for write of %s, %d bytes - %llu\n", filename, total_written, (long long unsigned int)diff);
	printf("%llu\n", (long long unsigned int)diff);
	close(fd);
	//system("sudo sh -c \"sync; echo 3 > /proc/sys/vm/drop_caches\"");
	return 0;
}
コード例 #18
0
ファイル: LOSd.c プロジェクト: anitaNeutrino/anitaFlightSoft
 int doWrite() {
   static unsigned int dataCounter=0;
   static int first=1;
   static struct timeval lastTime;
   struct timeval newTime;
   float timeDiff;
   int retVal;
   if(first) {
     gettimeofday(&lastTime,0);
     first=0;
   }
   //    if(numBytesInBuffer%2==1) numBytesInBuffer++;
   if(numBytesInBuffer>6000)
     printf("Trying to write %d bytes -- %d\n",numBytesInBuffer,laptopDebug);
  if(!laptopDebug) {
    retVal=writeLosData(losBuffer,numBytesInBuffer);
    if(retVal!=0) {
      syslog(LOG_ERR,"Error sending los buffer\n");
      fprintf(stderr,"Error sending los buffer\n");
    }
  }
  else {
    retVal=0;
    //	retVal=fake_los_write(losBuffer,numBytesInBuffer,fakeOutputDir);
  }	

  dataCounter+=numBytesInBuffer;
  //    printf("%d %d\n",numBytesInBuffer,dataCounter);
  if(dataCounter>100000) {
    gettimeofday(&newTime,0);
    timeDiff=getTimeDiff(lastTime,newTime);
    printf("Transferred %u bytes in %2.2f seconds (%3.4f bytes/sec)\n",dataCounter,timeDiff,((float)dataCounter)/timeDiff);
    dataCounter=0;
    lastTime=newTime;
  }

  numBytesInBuffer=0;
  return retVal;    
}
コード例 #19
0
/* 
 * Borwein calculation of PI 
 */
void* calculatePi(void *args){
  int tid;
  double p16 = 1, pi = 0;
  unsigned long long int k;
  uint64_t diff;
  struct timespec start, end;
  
  tid = ((targs*)(args))->tid;
  //printf("Starting thread: %d\n",tid);

  clock_gettime(CLOCK_MONOTONIC, &start);
  for(k=0; k<=precision; k++){
    pi += 1.0/p16 * (4.0/(8*k + 1) - 2.0/(8*k + 4) - 1.0/(8*k + 5) - 1.0/(8*k+6));
    p16 *= 16;
  }
  clock_gettime(CLOCK_MONOTONIC,&end);
  printf("Pi_calculation_elapsed_time:\t%llu\n", (long long unsigned int) getTimeDiff(start,end));

  //printf("Ending thread: %d\n",tid);

  return NULL;
}
コード例 #20
0
ファイル: image_refocus.cpp プロジェクト: csuhanshuai/Gallery
bool ImageRefocus::generateRefocusImage(MUINT8* array, int touchCoordX, int touchCoordY, int depthOfField) {
    ALOGI("<generateRefocusImage>touchCoordX:%d,touchCoordY:%d,depthOfField:%d",
            touchCoordX, touchCoordY, depthOfField);
    mRefocusImageInfo.TouchCoordX = touchCoordX;
    mRefocusImageInfo.TouchCoordY = touchCoordY;
    mRefocusImageInfo.DepthOfField = depthOfField;
    if (!generate()) {
        ALOGI("ERROR:generate fail!!!");
        return FAIL;
    }

    getTime(&mStartSec, &mStartNsec);
    memcpy(array, (MUINT8*)mRefocusResultInfo.RefocusedRGBAImageAddr,
            mRefocusResultInfo.RefocusImageWidth*mRefocusResultInfo.RefocusImageHeight*4);
    getTime(&mEndSec, &mEndNsec);
    mTimeDiff = getTimeDiff(mStartSec, mStartNsec, mEndSec, mEndNsec);
    ALOGI("<generateRefocusImage> memcpy time:%d", mTimeDiff);
    if (mRefocusResultInfo.RefocusImageWidth == 0 || mRefocusResultInfo.RefocusImageHeight == 0) {
        ALOGI("ERROR:error RefocusImageWidth and RefocusImageHeight!!!");
        return FAIL;
    }
    return SUCCESS;
}
コード例 #21
0
ファイル: client.c プロジェクト: nechutny/IPK
/**
 * Main loop sending data to server and signals to fork child
 *
 * @param	arguments	arg	Arguments structure
 */
void sendData(arguments arg)
{
	char *sendline = malloc(arg.size);
	memset(sendline, 1,  arg.size);

	uint32_t time = 0;

	int sleep = 1000000/arg.rate;

	unsigned tout = arg.timeout*1000000;

	do
	{
		memcpy(sendline, &count, sizeof(count));
		time = getTimeDiff();
		//printf("Send data %u\n", count);
		memcpy(sendline+4, &time, sizeof(time));

		sendto(sockfd, sendline, arg.size, 0, (struct sockaddr *)&servaddr, sizeof(servaddr));

		count++;
		if(count%(arg.interval*arg.rate) == 0)
		{
			kill(arg.pid, SIGUSR1);
		}
		usleep(sleep);

	}
	while(tout > time);

	if(count%(arg.interval*arg.rate) != 0)
	{
		kill(arg.pid, SIGUSR1);
	}

	free(sendline);
}
コード例 #22
0
ファイル: wiretap.c プロジェクト: Brianjr0428/Projects
int main(int argc,char **argv) {
	pcap_t *pcap;
	char pcapErr[PCAP_ERRBUF_SIZE],  line[80] ;
	char* title;
	int datalink;
	char timeDuration[MAX_BUF_SIZE];
	char file_name[MAX_BUF_SIZE];

	if (argc != 2) {
		printf("Usage: ./wiretap file.pcap\n");
		printf("       ./wiretap file.pcap > output.txt\n");
		exit(1);
	}
	
	strcpy(file_name, argv[1]);
	pcap = pcap_open_offline(file_name, pcapErr);
	if (pcap == NULL) {
		fprintf(stderr, "pcap_open_offline failed: %s\n", pcapErr);
		exit(EXIT_FAILURE);
	}

	datalink = pcap_datalink(pcap);

	if(datalink != Ethernet) {
		printf("not Ethernet!\n");
		exit(EXIT_FAILURE);
	}
	
	pcap_loop(pcap,-1,my_callback,NULL);

    getTimeDiff(timeDuration); 

	print_summary(timebuffer, start_time, timeDuration);
	printf("=== Link layer ===\n\n");
	print("Source ethernet addresses", eth_src_addr, packets);
	free_nodes(eth_src_addr);
	print("Destination ethernet addresses", eth_dest_addr, packets);
	free_nodes(eth_dest_addr);

	printf("=== Network Layer ===\n\n");
	print("Network layer protocols", net_layer, packets);
	free_nodes(net_layer);
	print("Source IP addresses", IP_src_addr, ip_packets);
	free_nodes(IP_src_addr);
	print("Destination IP addresses", IP_dest_addr, ip_packets);
	free_nodes(IP_dest_addr);
	print("TTLs",TTL_list, ip_packets);
	free_nodes(TTL_list);
	print_arp(arp_participants);
	free_arp_nodes(arp_participants);

	printf("=== Transport Layer ===\n\n");
	print("Transport Layer protocols", transLayer, ip_packets);
	free_nodes(transLayer);

	printf("=== Transport Layer: TCP ===\n\n");
	print("Source TCP ports", TCP_src_ports, TCP_packets);
	free_nodes(TCP_src_ports);
	print("Destination TCP ports", TCP_dest_ports, TCP_packets);
	free_nodes(TCP_dest_ports);
	print("TCP flags", TCP_flags, TCP_packets);
	free_nodes(TCP_flags);
	print("TCP options", TCP_options, TCP_packets);
	free_nodes(TCP_options);

	printf("=== Transport Layer: UDP ===\n\n");
	print("Source UDP ports", UDP_src_ports, UDP_packets);
	free_nodes(UDP_src_ports);
	print("Destination UDP ports", UDP_dest_ports, UDP_packets);
	free_nodes(UDP_dest_ports);

	printf("=== Transport Layer: ICMP ===\n\n");
	print("Source IPs for ICMP", ICMP_src_IP, ICMP_packets);
	free_nodes(ICMP_src_IP);
	print("Destination IPs for ICMP", ICMP_dest_IP, ICMP_packets);
	free_nodes(ICMP_dest_IP);
	print("ICMP types", ICMP_TYPE, ICMP_packets);
	free_nodes(ICMP_TYPE);
	print("ICMP codes", ICMP_CODE, ICMP_packets);
	free_nodes(ICMP_CODE);
	print("ICMP responses", ICMP_RESPONSE, ICMP_packets);
	free_nodes(ICMP_RESPONSE);
	pcap_close(pcap);
}
コード例 #23
0
ファイル: cep_core.c プロジェクト: sspider/etalis
/*
* Zstream implementation for seq (right event)
*/
void _seq_win_cep_r(void* exec)
{
    EtalisEvent* Event_b  = (EtalisEvent*)exec;
    EtalisExecNode* rule_ = Event_b->RootModel->parentNode;
    assert(Event_b != NULL && rule_ != NULL);


    EtalisEvent* Event_a = StackPop(rule_->leftChild->eventStack);

    if(Event_a == NULL) /* stack is empty*/
    {
        free(Event_b);
        return;
    }
    /* Event a is in the stack */
    /* a complex event will be generated if the conditions are met */
    /* testing if the conditions could be proven correct */





    if(getTimeDiff(&(Event_b->timestamps[0]),&(Event_a->timestamps[0])) > rule_->window_size) /* out of the window*/
    {
        /* printf(" --- Time difference is %d > window size of %d\n",Event_b->timestamps[0]-Event_a->timestamps[0],rule_->window_size);
        */
        free(Event_a); /* check this */
        free(Event_b);
        return;
    }


    if (Event_b->RootModel->event.arity != 0 )
    {
        if(aprio_validation(Event_b) != ETALIS_OK) /* argument a priori conditions must be true*/
        {
#ifdef DEBUG
            log_err("Event could be validated !");
#endif
            free(Event_a); /* check*/
            free(Event_b);
            return;
        }

        /* event arguments must be valide - implicite condition */
        if(validate_arguments(Event_b,Event_a) != ETALIS_OK)
        {
#ifdef DEBUG
            printf("Event arguments could not be validated ! \n");
#endif
            free(Event_a); /* check*/
            free(Event_b);
            return;
        }
    }


    EtalisEventNode* cplxEvModel=NULL; /* Complex Event Root Model */

    /* the rest depends on the CEP policy */
    if (_conf.policy==recent) /* recent policy */
    {
        cplxEvModel = rule_->parentEvent;

        /* triggering the complex event */
        EtalisEvent* cplxEvent = (EtalisEvent*)malloc(sizeof(EtalisEvent));
        cplxEvent->RootModel = rule_->parentEvent;
        /* bind the arguments of the complex event */ /* todo validate */
        cplxEvent->args = (int*)malloc(sizeof(int)*cplxEvModel->event.arity);
        size_t arg_iterator=0;
        for(arg_iterator=0; arg_iterator<cplxEvModel->event.arity; arg_iterator++)
        {
            switch (cplxEvModel->arg_links[arg_iterator].event_)
            {
            case 1 :
                *((int*)cplxEvent->args+arg_iterator)=*((int*)Event_a->args+(cplxEvModel->arg_links[arg_iterator].argument_number));
                break;

            case 2 :
                *((int*)cplxEvent->args+arg_iterator)=*((int*)Event_b->args+(cplxEvModel->arg_links[arg_iterator].argument_number));
                break;
            }
        }


        cplxEvent->timestamps[0] = Event_a->timestamps[0]; /* timestamp structure as suggested by the ETALIS paper */
        cplxEvent->timestamps[1] = Event_b->timestamps[1];
        triggerEvent_intern_no_hash(cplxEvent);            /* trigger the complex event (we already know the EventModel, so we don't need to search for it in the _event_hash) */

        /* garbage collect : we don't need these events anymore */
        free(Event_a);
        free(Event_b);
        return;
    }
    else if (_conf.policy==unrestricted)
    {
        /* TODO */
        return ;
    }

}
コード例 #24
0
ファイル: cep_core.c プロジェクト: sspider/etalis
void _seq_batch_r(void* exec)
{



    EtalisEvent* Event_b  = (EtalisEvent*)exec;
    if (Event_b == NULL) return;
    EtalisExecNode* rule_ = Event_b->RootModel->parentNode;

    EtalisEvent* Event_a=NULL;

    /* calculate EAT */

    float EAT = getHighResStamp(&Event_b->timestamps[1]) - rule_->window_size; /* TODO fix */

    if (rule_->leftChild->is_temp)
    {
        _seq_batch_r(StackPop(rule_->leftChild->childNode->rightChild->eventStack));
    }


    do
    {
        /*if (getHighResStamp(&Event_b->timestamps[0]) < EAT ) { free(Event_b); continue;} /* problem : all atomic right side events does not fulfill this condition */
        Event_a = StackPop(rule_->leftChild->eventStack);
        while( Event_a != NULL && getTimeDiff(&(Event_b->timestamps[0]),&(Event_a->timestamps[1])) >= 0 ) /* problem : recursion */
        {
            /*if (getHighResStamp(&Event_a->timestamps[0]) < EAT )*/ /* EAT is not compatible with timestamps */
            if (Event_b->timestamps[1].time - Event_a->timestamps[0].time  > rule_->window_size)
            {
                free (Event_a);
                Event_a = StackPop(rule_->leftChild->eventStack);
                continue; /* normally you don't have to continue here, because events are already choronogically ordered in the stack */ /* fix this */
            }
            if(validate_arguments(Event_b,Event_a) != ETALIS_OK)
            {
#ifdef DEBUG
                printf("Event arguments could not be validated ! \n");
#endif
                free(Event_a); /* check*/
                Event_a = StackPop(rule_->leftChild->eventStack);
                continue;
            }

            EtalisEventNode* cplxEvModel=NULL; /* Complex Event Root Model */

            /* the rest depends on the CEP policy */
            if (_conf.policy==recent) /* recent policy */
            {
                cplxEvModel = rule_->parentEvent;

                /* triggering the complex event */
                EtalisEvent* cplxEvent = (EtalisEvent*)malloc(sizeof(EtalisEvent));
                cplxEvent->RootModel = rule_->parentEvent;
                /* bind the arguments of the complex event */ /* todo validate */
                cplxEvent->args = (int*)malloc(sizeof(int)*cplxEvModel->event.arity);
                size_t arg_iterator=0;
                for(arg_iterator=0; arg_iterator<cplxEvModel->event.arity; arg_iterator++)
                {
                    switch (cplxEvModel->arg_links[arg_iterator].event_)
                    {
                    case 1 :
                        *((int*)cplxEvent->args+arg_iterator)=*((int*)Event_a->args+(cplxEvModel->arg_links[arg_iterator].argument_number));
                        break;

                    case 2 :
                        *((int*)cplxEvent->args+arg_iterator)=*((int*)Event_b->args+(cplxEvModel->arg_links[arg_iterator].argument_number));
                        break;
                    }
                }


                cplxEvent->timestamps[0] = Event_a->timestamps[0]; /* timestamp structure as suggested by the ETALIS paper */
                cplxEvent->timestamps[1] = Event_b->timestamps[1];
                triggerEvent_intern_no_hash(cplxEvent);            /* trigger the complex event (we already know the EventModel, so we don't need to search for it in the _event_hash) */

                /* garbage collect : we don't need these events anymore */
                free(Event_a);
                free(Event_b);
                return;
            }
            else if (_conf.policy==unrestricted)
            {
                /* TODO */
                return ;
            }

            Event_a = StackPop(rule_->leftChild->eventStack);
        }


    }
    while (Event_b = StackPop(Event_b->RootModel->eventStack));









}
コード例 #25
0
ファイル: xlog.cpp プロジェクト: jpalonso1/BigData
void XLog::log(const char* input) {
	std::cout << std::fixed;
	std::cout<<std::setprecision(3);
	std::cout<<"Seconds: "<<getTimeDiff()<<" "<<logName<<" || "<<input<<std::endl;
}
コード例 #26
0
int
main (int argc, char ** argv)
{
    typedef pcl::PointXYZRGB PointT;

    std::string scene_dir, input_mask_dir, output_dir = "/tmp/dol/";
    bool visualize = false;
    bool save_views = false;
    size_t min_mask_points = 50;
    bool first_frame_only=false; // used for evaluation when only using the first view

    v4r::object_modelling::IOL m;

    po::options_description desc("Evaluation Dynamic Object Learning with Ground Truth\n======================================\n **Allowed options");
    desc.add_options()
            ("help,h", "produce help message")
            ("scenes_dir,s", po::value<std::string>(&scene_dir)->required(), "input directory with .pcd files of the scenes. Each folder is considered as seperate sequence. Views are sorted alphabetically and object mask is applied on first view.")
            ("input_mask_dir,m", po::value<std::string>(&input_mask_dir)->required(), "directory containing the object masks used as a seed to learn the object in the first cloud")
            ("output_dir,o", po::value<std::string>(&output_dir)->default_value(output_dir), "Output directory where the model, training data, timing information and parameter values will be stored")

            ("save_views", po::bool_switch(&save_views), "if true, also saves point clouds, camera pose and object masks for each training views. This is necessary for recognition.")

            ("radius,r", po::value<double>(&m.param_.radius_)->default_value(m.param_.radius_), "Radius used for region growing. Neighboring points within this distance are candidates for clustering it to the object model.")
            ("dot_product", po::value<double>(&m.param_.eps_angle_)->default_value(m.param_.eps_angle_), "Threshold for the normals dot product used for region growing. Neighboring points with a surface normal within this threshold are candidates for clustering it to the object model.")
            ("dist_threshold_growing", po::value<double>(&m.param_.dist_threshold_growing_)->default_value(m.param_.dist_threshold_growing_), "")
            ("seed_res", po::value<double>(&m.param_.seed_resolution_)->default_value(m.param_.seed_resolution_), "")
            ("voxel_res", po::value<double>(&m.param_.voxel_resolution_)->default_value(m.param_.voxel_resolution_), "")
            ("ratio", po::value<double>(&m.param_.ratio_supervoxel_)->default_value(m.param_.ratio_supervoxel_), "")
            ("do_erosion", po::value<bool>(&m.param_.do_erosion_)->default_value(m.param_.do_erosion_), "")
            ("do_mst_refinement", po::value<bool>(&m.param_.do_mst_refinement_)->default_value(m.param_.do_mst_refinement_), "")
            ("do_sift_based_camera_pose_estimation", po::value<bool>(&m.param_.do_sift_based_camera_pose_estimation_)->default_value(m.param_.do_sift_based_camera_pose_estimation_), "")
            ("transfer_latest_only", po::value<bool>(&m.param_.transfer_indices_from_latest_frame_only_)->default_value(m.param_.transfer_indices_from_latest_frame_only_), "")
            ("chop_z,z", po::value<double>(&m.param_.chop_z_)->default_value(m.param_.chop_z_), "Cut-off distance of the input clouds with respect to the camera. Points further away than this distance will be ignored.")
            ("normal_method,n", po::value<int>(&m.param_.normal_method_)->default_value(m.param_.normal_method_), "")
            ("ratio_cluster_obj_supported", po::value<double>(&m.param_.ratio_cluster_obj_supported_)->default_value(m.param_.ratio_cluster_obj_supported_), "")
            ("ratio_cluster_occluded", po::value<double>(&m.param_.ratio_cluster_occluded_)->default_value(m.param_.ratio_cluster_occluded_), "")

            ("stat_outlier_removal_meanK", po::value<int>(&m.sor_params_.meanK_)->default_value(m.sor_params_.meanK_), "MeanK used for statistical outlier removal (see PCL documentation)")
            ("stat_outlier_removal_std_mul", po::value<double>(&m.sor_params_.std_mul_)->default_value(m.sor_params_.std_mul_), "Standard Deviation multiplier used for statistical outlier removal (see PCL documentation)")
            ("inlier_threshold_plane_seg", po::value<double>(&m.p_param_.inlDist)->default_value(m.p_param_.inlDist), "")
            ("min_points_smooth_cluster", po::value<int>(&m.p_param_.minPointsSmooth)->default_value(m.p_param_.minPointsSmooth), "Minimum number of points for a cluster")
            ("min_plane_points", po::value<int>(&m.p_param_.minPoints)->default_value(m.p_param_.minPoints), "Minimum number of points for a cluster to be a candidate for a plane")
            ("smooth_clustering", po::value<bool>(&m.p_param_.smooth_clustering)->default_value(m.p_param_.smooth_clustering), "If true, does smooth clustering. Otherwise only plane clustering.")

            ("visualize,v", po::bool_switch(&visualize), "turn visualization on")
     ;

    po::variables_map vm;
    po::store(po::parse_command_line(argc, argv, desc), vm);
    if (vm.count("help"))
    {
        std::cout << desc << std::endl;
        return false;
    }

    try { po::notify(vm); }
    catch(std::exception& e)
    {
        std::cerr << "Error: " << e.what() << std::endl << std::endl << desc << std::endl;
        return false;
    }

    m.initSIFT();

    v4r::io::createDirIfNotExist(output_dir);

    ofstream param_file;
    param_file.open ((output_dir + "/param.nfo").c_str());
    m.printParams(param_file);
    param_file    << "stat_outlier_removal_meanK" << m.sor_params_.meanK_ << std::endl
                  << "stat_outlier_removal_std_mul" << m.sor_params_.std_mul_ << std::endl
                  << "inlier_threshold_plane_seg" << m.p_param_.inlDist << std::endl
                  << "min_points_smooth_cluster" << m.p_param_.minPointsSmooth << std::endl
                  << "min_plane_points" << m.p_param_.minPoints << std::endl;
    param_file.close();

    std::vector< std::string> sub_folder_names = v4r::io::getFoldersInDirectory( scene_dir );
    if( sub_folder_names.empty() )
        sub_folder_names.push_back("");

    v4r::io::createDirIfNotExist(output_dir + "/models");

    for (const std::string &sub_folder_name : sub_folder_names)
    {
        const std::string output_rec_model = output_dir + "/" + sub_folder_name + "/models";
        v4r::io::createDirIfNotExist(output_rec_model);

        const std::string annotations_dir = input_mask_dir + "/" + sub_folder_name;
        std::vector< std::string > mask_file_v = v4r::io::getFilesInDirectory(annotations_dir, ".*.txt", false);

        for (size_t o_id=0; o_id<mask_file_v.size(); o_id++)
        {
            const std::string mask_file = annotations_dir + "/" + mask_file_v[o_id];

            size_t idx_tmp;
            std::vector<size_t> mask;
            std::ifstream initial_mask_file ( mask_file.c_str() );
            while (initial_mask_file >> idx_tmp)
                mask.push_back(idx_tmp);

            initial_mask_file.close();

            if ( mask.size() < min_mask_points) // not enough points to grow an object
                continue;

            const std::string scene_path = scene_dir + "/" + sub_folder_name;
            std::vector< std::string > views = v4r::io::getFilesInDirectory(scene_path, ".*.pcd", false);

            std::cout << "Learning object from mask " << mask_file << " for scene " << scene_path << std::endl;

            timeval start, stop;

            gettimeofday(&start, NULL);
            for(size_t v_id=0; v_id<views.size(); v_id++)
            {
                const std::string view_file = scene_path + "/" + views[ v_id ];
                pcl::PointCloud<PointT>::Ptr pCloud(new pcl::PointCloud<PointT>());
                pcl::io::loadPCDFile(view_file, *pCloud);
                const Eigen::Matrix4f trans = v4r::RotTrans2Mat4f(pCloud->sensor_orientation_, pCloud->sensor_origin_);

                pCloud->sensor_origin_ = Eigen::Vector4f::Zero();   // for correct visualization
                pCloud->sensor_orientation_ = Eigen::Quaternionf::Identity();

                if (v_id==0)
                    m.learn_object(*pCloud, trans, mask);
                else
                {
                    if(!first_frame_only)
                        m.learn_object(*pCloud, trans);
                }
            }
            gettimeofday(&stop, NULL);

            std::string out_fn = mask_file_v[o_id];
            boost::replace_last (out_fn, "mask.txt", "dol");
            m.save_model(output_rec_model, out_fn, save_views);
            if (visualize)
                m.visualize();
            m.clear();

            // write running time to file
            const std::string timing_fn = output_dir+"/"+sub_folder_name+"/timing.nfo";
            double learning_time = getTimeDiff(stop, start);
            ofstream f( timing_fn.c_str() );
            f << learning_time;
            f.close();
        }
    }
    return 0;
}
コード例 #27
0
ファイル: timeUtils.hpp プロジェクト: bailey-lab/cppprogutils
	double totalTime(){
		return getTimeDiff(start_);
	}
コード例 #28
0
ファイル: timeUtils.hpp プロジェクト: bailey-lab/cppprogutils
	/**@brief Get formatted time since last point formatted
	 *
	 * @param decPlaces How many decimal places to round to
	 * @return A string with the time formatted for hrs, min, secs etc.
	 */
	std::string timeLapFormatted(int32_t decPlaces = 6){
		return getTimeFormat(getTimeDiff(currentLap_),true, decPlaces);
	}
コード例 #29
0
ファイル: timeUtils.hpp プロジェクト: bailey-lab/cppprogutils
	/**@brief Get time in seconds since last point
	 * @return A double for time in seconds
	 */
	double timeLap(){
		return getTimeDiff(currentLap_);
	}
コード例 #30
0
ファイル: timeUtils.hpp プロジェクト: bailey-lab/cppprogutils
	/**@brief Get formatted time since start formatted
	 *
	 * @param decPlaces How many decimal places to round to
	 * @return A string with the time formatted for hrs, min, secs etc.
	 */
	std::string totalTimeFormatted(int32_t decPlaces = 6){
		return getTimeFormat(getTimeDiff(start_),true, decPlaces);
	}