コード例 #1
0
ファイル: ui.cpp プロジェクト: RemyYang/FastHumanDetection
fhd_ui::fhd_ui(fhd_context* fhd)
    : fhd(fhd),
      file_browser("."),
      depth_texture(fhd_create_texture(512, 424)),
      normals_texture(fhd_create_texture(fhd->cells_x, fhd->cells_y)),
      normals_seg_texture(fhd_create_texture(fhd->cells_x, fhd->cells_y)),
      downscaled_depth(fhd_create_texture(fhd->cells_x, fhd->cells_y)),
      depth_segmentation(fhd_create_texture(fhd->cells_x, fhd->cells_y)),
      filtered_regions(fhd_create_texture(fhd->cells_x, fhd->cells_y)),
      selected_candidates(fhd->candidates_capacity, false),
      candidate_images(fhd->candidates_capacity) {
#if WIN32
  frame_source.reset(new fhd_kinect_source());
#else
  frame_source.reset(new fhd_debug_frame_source());
#endif

  for (int i = 0; i < fhd->candidates_capacity; i++) {
    fhd_texture t = fhd_create_texture(FHD_HOG_WIDTH, FHD_HOG_HEIGHT);
    textures.push_back(t);
    fhd_image_init(&candidate_images[i], FHD_HOG_WIDTH, FHD_HOG_HEIGHT);
  }

  for (int i = 0; i < fhd->cells_x * fhd->cells_y; i++) {
    uint8_t r = uint8_t(pcg32_boundedrand(255));
    uint8_t g = uint8_t(pcg32_boundedrand(255));
    uint8_t b = uint8_t(pcg32_boundedrand(255));
    colors.emplace_back(r, g, b);
  }
}
コード例 #2
0
ファイル: util.c プロジェクト: cran/BigQuic
/*************************************************************************
* This file randomly permutes the contents of an array.
* flag == 0, don't initialize perm
* flag == 1, set p[i] = i 
**************************************************************************/
void RandomPermute(int n, idxtype *p, int flag)
{
  int i, j, u, v;
  idxtype tmp;

  if (flag == 1) {
    for (i=0; i<n; i++)
      p[i] = i;
  }

  for(i = 1; i < n; i++)
  {
    //j = R::runif(0,i + 1 - .00000000001);
    //j = random() % (i+1);
    //Temp Disabled for debugging, SWITCH BACK TO PCG FOR FINAL
    j = (int)pcg32_boundedrand(i + 1 - .00000000001);
    tmp = p[i];
    p[i] = p[j];
    p[j] = tmp;
  }

/*
  if (flag == 1) {
    for (i=0; i<n; i++)
      p[i] = i;
  }

  if (n <= 4)
    return;

  for (i=0; i<n; i+=16) {
    u = RandomInRangeFast(n-4);
    v = RandomInRangeFast(n-4);
    SWAP(p[v], p[u], tmp);
    SWAP(p[v+1], p[u+1], tmp);
    SWAP(p[v+2], p[u+2], tmp);
    SWAP(p[v+3], p[u+3], tmp);
    }
*/
}
コード例 #3
0
ファイル: space.c プロジェクト: pt300/spaceshit
int main(int argc, char* argv[]) {
	char flags = 0;
	//char* box;
	uint16_t* scr; //also going to store info about whether it's '.' or '*'. 9 bit values dun exist :/ will try doing that later. It's too much butt pain inducing
	char* msgbox = NULL;
	int bxs = 0;
	int bhs[5];
	int mv[3];
	struct winsize w;
	ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
	if(argc>1) {
		//parse arggggggggggggggggggggsss
		int ac;
		while((ac = getopt (argc, argv, "hsb:")) != -1) {
			switch(ac) {
			case 'h':
				; //fug you stupid standards
				char* ctp = strrchr(argv[0], '/');
				if(!ctp)
					ctp = argv[0];
				else
					ctp++;
				printf("%s: Generate colorful space in console.\n"
						" Optional arguments:\n"
						"   -s\tSkip generation phase and instantly print out entire space.\n"
						"   -b\tPrint out floating window with text provided as argument to that option.\n", ctp);
				exit(0);
				break;
			case 's':
				flags|=1;
				break;
			case 'b':
				if(!(flags&2)) {
					int stl = strlen(optarg);
					bxs = (stl > (w.ws_col/2)) ? w.ws_col/2 : stl;
					msgbox = malloc((bxs+8)*6+(bxs+6)*3+6*3+5);
					bxs += 6;
					char* bci = msgbox;
					int bcfi = bxs;
					strcpy(bci, "┌");
					bci+=3;
					while(bcfi--) {
						strcpy(bci, "─");
						bci+=3;
					}
					strcpy(bci, "┐");
					bci+=3;
					*(bci++) = '\0';
					strcpy(bci, "│");
					bci+=3;
					bcfi = bxs;
					while(bcfi--) {
						*(bci++) = ' ';
					}
					strcpy(bci, "│");
					bci+=3;
					*(bci++) = '\0';
					strcpy(bci, "│");
					bci+=3;
					bcfi = 3;
					while(bcfi--) {
						*(bci++) = ' ';
					}
					strncpy(bci, optarg, bxs-6);
					bci+=bxs-6;
					bcfi = 3;
					while(bcfi--) {
						*(bci++) = ' ';
					}
					strcpy(bci, "│");
					bci+=3;
					*(bci++) = '\0';
					strcpy(bci, "│");
					bci+=3;
					bcfi = bxs;
					while(bcfi--) {
						*(bci++) = ' ';
					}
					strcpy(bci, "│");
					bci+=3;
					*(bci++) = '\0';
					strcpy(bci, "└");
					bci+=3;
					bcfi = bxs;
					while(bcfi--) {
						strcpy(bci, "─");
						bci+=3;
					}
					strcpy(bci, "┘");
					bci+=3;
					*(bci++) = '\0';
					bxs += 2;
					bhs[0] = bxs*3;
					bhs[1] = bxs+4;
					bhs[2] = bxs+4;
					bhs[3] = bxs+4;
					bhs[4] = bxs*3;
					//oh god that's looking so awful
				}
				flags|=2;
				break;
			case '?':
				if (optopt == 'b') {
					exit(0);
				}
				break;
			}
		}
	}
	//scr = calloc(((((w.ws_col-1)*(w.ws_row-1))*9)/16)+1, sizeof(uint16_t));
	scr = calloc((w.ws_col+2)*(w.ws_row+2), sizeof(uint16_t));
	signal(SIGINT, finish);
	struct termios new_settings;
	tcgetattr(0,&stored_settings);
	new_settings = stored_settings;
	new_settings.c_lflag &= ~(ECHO | ICANON);
	tcsetattr(0,TCSANOW,&new_settings);
	pcg32_srandom(time(NULL) ^ (intptr_t)&printf, rand());
	int cnt = w.ws_row;
	puts("\e[?25l");
	while(--cnt) {
		putchar('\n');
	}
	cnt = w.ws_row*w.ws_col/15;
	w.ws_col++;
	w.ws_row++;
	int cpc[4];
	while(cnt--) {
		cpc[0] = (int)pcg32_boundedrand(w.ws_row);
		cpc[1] = (int)pcg32_boundedrand(w.ws_col);
		cpc[2] = (int)pcg32_boundedrand(216)+17;
		cpc[3] = pcg32_boundedrand(10)?1:0;
		*(scr+cpc[1]+cpc[0]*w.ws_col) = cpc[2]|(cpc[3]<<8);
		printf("\e[%i;%iH\e[38;5;%im%c", cpc[0], cpc[1], cpc[2], cpc[3] ?'.':'*');