예제 #1
0
void QKinectIO::load(QString filename, std::vector<unsigned short>& info, std::vector<unsigned short>& depthBuffer)
{
    std::ifstream in_file;
    in_file.open(filename.toStdString(), std::ios::in | std::ios::binary);
    vector_read(in_file, info);
    vector_read(in_file, depthBuffer);
    in_file.close();
}
예제 #2
0
void QKinectIO::loadFrame(const QString& filename, KinectFrame& frame)
{
    std::ifstream in_file;
    in_file.open(filename.toStdString(), std::ifstream::binary);
    vector_read(in_file, frame.info);
    vector_read(in_file, frame.color);
    vector_read(in_file, frame.depth);
    in_file.close();
}
예제 #3
0
파일: vector.c 프로젝트: aaroncdc/libsosc
void vectortest2(void)
{
	VECTOR test;
	int a = 2, b = 4, c = 6, d = 8;
	test = makeVECTOR(sizeof(int), 1);
	vectorpush(&test, &a);
	vectorpush(&test, &c);
	vectorinsert(&test, &b, 1);
	vectorinsert(&test, &d, 0);
	int n = 0;
	for(int x = 0; x < test.size; x++)
	{
		vector_read(&test, &n, x);
		printf("\n Pos %i: %i", x, n);
	}
	return;
}
예제 #4
0
파일: vector.c 프로젝트: aaroncdc/libsosc
int vectortest(void)
{
    	VECTOR test;
        VECTOR fusetest;
	int n = 10, a = 5, b = 0, cnt = 0;
	int* thrdVal;
	test = makeVECTOR(sizeof(int), 3); //Create VECTOR. Reserve space for 3 integer elements.
        fusetest = makeVECTOR(sizeof(int), 3); //Create VECTOR. Reserve space for 3 integer elements.
        
        vectorpush(&fusetest, (void*)&a);
        vectorpush(&fusetest, (void*)&b);
        vectorpush(&fusetest, (void*)&n);
        
	//Show the VECTOR size and allocated space.
	printf("VECTOR size: %i, max: %i\n", test.size, test.maxsize);

	//Push 10 values to the VECTOR
	do
	{
		if(vectorpush(&test, &n) < 1)
		{
			printf("Error pushing element %i\n", cnt);
			exit;
		}
		n += 2;
		cnt++;
	}while(cnt < 10);

	vectorinsert(&test, &a, 5);
	vectordelete(&test, 3);
	a += 12;
	vectorinsert(&test, &a, 3);
	vectorpop(&test, &b);
	printf("Pop: %i\n", b);
	vector_read(&test, &b, 8);
	printf("Read 8: %i\n", b);
	vector_reverse(&test);
	vector_resize(&test, 20);
	cnt = 0;
	do
	{
		if(vectorpush(&test, &n) < 1)
		{
			printf("Error pushing element %i\n", cnt);
			exit;
		}
		n += 2;
		cnt++;
	}while(cnt < 5);

	//Show the new VECTOR size and allocated space.
	printf("VECTOR size: %i, max: %i\n", test.size, test.maxsize);
	cnt = 0;
	//Show every value inside the VECTOR
	do
	{
		thrdVal = (int*)&test.data[sizeof(int)*cnt];
		printf("test[%i] = %i\n", cnt,*thrdVal);
		cnt++;
	}while(cnt < test.size);

	vector_shrink_to_fit(&test);
	vector_swap(&test, &a, 9);
	vector_swap_b(&test, 1, 13);

	printf("VECTOR size: %i, max: %i\n", test.size, test.maxsize);
	cnt = 0;
	//Show every value inside the VECTOR
	do
	{
		thrdVal = (int*)&test.data[sizeof(int)*cnt];
		printf("test[%i] = %i\n", cnt,*thrdVal);
		cnt++;
	}while(cnt < test.size);
        
        printf("\n- vector fuse -\n");
        printf("VECTOR size: %i, max: %i\n", fusetest.size, fusetest.maxsize);
        printf("fusetest[0] = %i\n", *thrdVal);
        vector_fuse(&fusetest, &test);
        cnt = 0;
        printf("VECTOR size after fuse: %i, max: %i\n", fusetest.size, fusetest.maxsize);
        do{
            vector_read(&fusetest, thrdVal, cnt);
            printf("%i: %i\n", cnt, *thrdVal);
            cnt++;
        }while(cnt < fusetest.size);
        
        //Vector copy
        printf("Before copy...\n");
        cnt = 0;
        do
	{
		thrdVal = (int*)&test.data[sizeof(int)*cnt];
		printf("test[%i] = %i\n", cnt,*thrdVal);
		cnt++;
	}while(cnt < test.size);
        
        vector_copy(&test, &fusetest, 1, 4, 2);
        printf("After copy...\n");
        cnt = 0;
	do
	{
		thrdVal = (int*)&test.data[sizeof(int)*cnt];
		printf("test[%i] = %i\n", cnt,*thrdVal);
		cnt++;
	}while(cnt < test.size);
        printf("VECTOR size: %i, max: %i\n", test.size, test.maxsize);
        
        //Clean the memory
	vectorclear(&test);
	printf("VECTOR size: %i, max: %i\n", test.size, test.maxsize);
        
	return 0;
}
예제 #5
0
파일: main.c 프로젝트: zhanxw/mycode
int main(int argc, char *argv[])
{
    //////////////////////////////////////////////////////////////////////
    // Handel argument
    if (argc != 4) {
        usage(argv[0]);
        exit(1);
    }
    const unsigned int shuffle_time = atof(argv[1]);
    const char* inputX = argv[2];
    const char* inputY = argv[3]; 

    debug_level_set(SILENT);
    printf("begin allocating memory:\n");
    vec_p x, y;
    x = vector_new(4);
    y = vector_new(4);

    printf("begin read:\n");
    vector_read(x, inputX);
    vector_read(y, inputY);
    // vector_print(x);

    double* ret = malloc(sizeof(double)*shuffle_time);
    assert(ret);

    
    //////////////////////////////////////////////////////////////////////
    // Method 1
    // parallel this part
    timing_start();
    for (int i = 0; i < shuffle_time; i++) {
        inplace_shuffle(y->value, y->len);
        ret[i] = vector_corr(x,y);
    }
    timing_stop();
    timing_diff();

    //////////////////////////////////////////////////////////////////////
    // Method 2
    timing_start();
    vector_corr_permutation(x, y, ret, shuffle_time);
    timing_stop();
    timing_diff();

    //////////////////////////////////////////////////////////////////////
    // Method 3
    timing_start();
    mkl_vector_corr_permutation(x, y, ret, shuffle_time);
    timing_stop();
    timing_diff();



    exit(0);
    // output result
    printf("Result\n");

    for (int i = 0; i < shuffle_time; i++) {
        printf("%f\n", ret[i]);
    }

    vector_delete(&x);
    vector_delete(&y);
    free(ret);
    return 0;
    
}