Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example of how to use VipsOperation after filling a VipsImage from local buffer ( vips_image_new_from_memory() ) #2842

Closed
skf-git opened this issue Jun 5, 2022 · 1 comment

Comments

@skf-git
Copy link

skf-git commented Jun 5, 2022

I am trying to define a function so that I can apply a VipsOperation to a local an image buffer of Gray format (YY extracted from YUYV), so my buffer contains image pixels, one byte each pixel, with width=VRES and height=HRES.

I basically wanted to extract the difference of angles of main lines that the operation stores in (Xsize).

I didn't define VipsOperation before as I thought of calling vips_hough_line function with only VipsImages declared and initialised as in the code.

But the operation was failing (sends -1 instead of 0) when I don't set the optional argument (width and height) and it reports the error I followed below when I do set them as in the code.

I kept some different lines I tried commented in case whoever sees the issue trues to reproduce it or try what I tried. But these are poor guesses without proper knowledge of how this actually works (GObject and more specifically here "g_param_spec_pool_lookup " as shown in gdb backtrace).

void vips_image_process(unsigned char * vips_buffer, unsigned char * prev_vips_buffer){


	printf("\ndone 0\n");
	/*if( VIPS_INIT(NULL) ){
		vips_error_exit( NULL );
	}*/
	VipsImage *image_curr;
	VipsImage *image_prev;
	VipsOperation *op;
	op = vips_operation_new( "hough_line" );

	printf("\ndone 1\n");
	image_curr = vips_image_new_from_memory(vips_buffer, (size_t)((unsigned)(PIXEL_SIZE*VRES*HRES)), VRES, HRES, BYTES_PER_PIXEL,VIPS_FORMAT_UCHAR);
	//image_curr = vips_image_new_from_memory(vips_buffer, (size_t)((unsigned)(PIXEL_SIZE*VRES*HRES)), PIXEL_SIZE*VRES, PIXEL_SIZE*HRES, BYTES_PER_PIXEL,VIPS_FORMAT_UCHAR);

	//image_curr = vips_image_new_from_buffer(vips_buffer, PIXEL_SIZE*VRES*HRES,(char*)NULL, NULL);
	//image_curr = vips_image_matrix_from_array(width, height, *array, size);
	printf("done 2\n");

	image_prev = vips_image_new_from_memory(prev_vips_buffer, (size_t)((unsigned)(PIXEL_SIZE*VRES*HRES)), VRES, HRES, BYTES_PER_PIXEL,VIPS_FORMAT_UCHAR);

	//image_prev = vips_image_new_from_memory(prev_vips_buffer, (size_t)((unsigned)(PIXEL_SIZE*VRES*HRES)), PIXEL_SIZE*VRES, PIXEL_SIZE*HRES, BYTES_PER_PIXEL,VIPS_FORMAT_UCHAR);
	//image_prev = vips_image_new_from_buffer(vips_buffer, PIXEL_SIZE*VRES*HRES, (char*)NULL, NULL);
	//image_prev = vips_image_matrix_from_array(width, height, *array, size);


	printf("done 3\n");
	VipsImage *im_hough_curr = vips_image_new();
	VipsImage *im_hough_prev = vips_image_new();
	printf("done 4\n");

	//vips_check_init();

	if( vips_hough_line( image_curr, &im_hough_curr, VRES, HRES, NULL)==0 ){
		printf("first hough compute done");
	}
	if( vips_hough_line(image_prev, &im_hough_prev, VRES, HRES, NULL)==0 ){
		printf("Angle difference : %d", abs( im_hough_curr->Xsize - im_hough_prev->Xsize) );
	}
	else{
		printf("Vips Hough Computation Error. ");
	}

	//vips_image_finalize( (GObject*)image_curr );
	//vips_image_finalize( (GObject*)image_prev );
	//vips_image_finalize( (GObject*)im_hough_curr );
	//vips_image_finalize( (GObject*)im_hough_prev );

	//vips_shutdown();

	g_object_unref( im_hough_curr );
	g_object_unref( im_hough_prev );
	g_object_unref( image_prev );
	g_object_unref( image_curr );


}

I get this error that I spent a lot of time now trying to see how to correct it.

Undefined command: "". Try "help".
(gdb) #0 0x00007ffff6f48ef8 in __strchr_avx2 () at ../sysdeps/x86_64/multiarch/strchr-avx2.S:57
(gdb) #1 0x00007ffff73e74df in g_param_spec_pool_lookup () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
(gdb) #2 0x00007ffff73e1331 in g_object_class_find_property () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
(gdb) #3 0x00007ffff7757858 in vips_object_get_argument () at /usr/lib/x86_64-linux-gnu/libvips.so.42
(gdb) #4 0x00007ffff7758ae9 in vips_object_set_valist () at /usr/lib/x86_64-linux-gnu/libvips.so.42
(gdb) #5 0x00007ffff77682dd in vips_call_required_optional () at /usr/lib/x86_64-linux-gnu/libvips.so.42
(gdb) #6 0x00007ffff7768c56 in () at /usr/lib/x86_64-linux-gnu/libvips.so.42
(gdb) #7 0x00007ffff77690f9 in vips_call_split () at /usr/lib/x86_64-linux-gnu/libvips.so.42
(gdb) #8 0x00007ffff7689736 in vips_hough_line () at /usr/lib/x86_64-linux-gnu/libvips.so.42
(gdb) #9 0x0000555555556018 in vips_image_process (vips_buffer=0x55555591b3a0 <scratchpad_buffer> "DCEFLJHIJHGHIIIIIKKJIIHHHHIKKKIHHIHHIIHJIIGGHHHGFHGGHHHIHHHGHHHJIJKLNMMONNNMMNOONNNMKIJJIIIIHIJIHGHIJJKKLMMNOOONONNNNNNNOPOOOPPOQOPPQQOPOPPOOPQPOOQQQQQQQQPQQPONOOOOOPPRRSRRQQQPOPRRRSSTTRTSQOPOUURSSQOO"..., prev_vips_buffer=0x555556789020 <last_frame> "DCEFLJHIJHGHIIIIIKKJIIHHHHIKKKIHHIHHIIHJIIGGHHHGFHGGHHHIHHHGHHHJIJKLNMMONNNMMNOONNNMKIJJIIIIHIJIHGHIJJKKLMMNOOONONNNNNNNOPOOOPPOQOPPQQOPOPPOOPQPOOQQQQQQQQPQQPONOOOOOPPRRSRRQQQPOPRRRSSTTRTSQOPOUURSSQOO"...) at capturelib.c:789
(gdb) #10 0x0000555555555ba2 in process_image (p=0x555555759230 <ring_buffer+16>, size=614400) at capturelib.c:546
(gdb) #11 0x000055555555649c in mainloop () at capturelib.c:932
(gdb) #12 0x0000555555556eef in v4l2_frame_acquisition_loop (dev_name=0x555555557754 "/dev/video0") at capturelib.c:1269
(gdb) #13 0x0000555555555174 in main (argc=1, argv=0x7fffffffdea8) at capture.c:27

Thank you in advance.

@skf-git skf-git changed the title Example of how to use VipsOperation after filling a VipsImage from local buffer (new_from_memory) Example of how to use VipsOperation after filling a VipsImage from local buffer ( vips_image_new_from_memory() ) Jun 5, 2022
@jcupitt
Copy link
Member

jcupitt commented Jun 6, 2022

Hi @skf-git,

Sorry, I don't really understand the problem. Do you just want to run hough_line twice?

Could you post a complete program I can compile and test?

@libvips libvips locked and limited conversation to collaborators Jun 6, 2022
@jcupitt jcupitt converted this issue into discussion #2843 Jun 6, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants